mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
display dialog after selecting file
This commit is contained in:
@@ -664,10 +664,7 @@
|
||||
<string name="pref_managekeys_export_secret_keys">Export Secret Keys</string>
|
||||
<string name="pref_managekeys_export_explain">Export secret keys to \"%1$s\"?</string>
|
||||
<string name="pref_managekeys_import_secret_keys">Import Secret Keys</string>
|
||||
<!-- pref_managekeys_import_explain is deprecated, use pref_managekeys_import_explain_path and pref_managekeys_import_explain_tips -->
|
||||
<string name="pref_managekeys_import_explain">Import secret keys from \"%1$s\"?\n\n• Existing secret keys will not be deleted\n\n• The last imported key will be used as the new default key unless it has the word \"legacy\" in its filename.</string>
|
||||
<string name="pref_managekeys_import_explain_path">Import secret keys from \"%1$s\"?</string>
|
||||
<string name="pref_managekeys_import_explain_tips">• Existing secret keys will not be deleted\n\n• The last imported key will be used as the new default key unless it has the word \"legacy\" in its filename.</string>
|
||||
<string name="pref_managekeys_secret_keys_exported_to_x">Secret keys written successfully to \"%1$s\".</string>
|
||||
<string name="pref_managekeys_secret_keys_imported_from_x">Secret keys imported from \"%1$s\".</string>
|
||||
<!-- No need to translate "Wallpaper" literally. Chose what is common in your language for a "Wallpaper" or a "Background". Avoid adding the term "image" here, as the "Wallpaper" may also be just a single color. -->
|
||||
|
||||
@@ -202,7 +202,7 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
|
||||
String name = AttachmentManager.getFileName(getContext(), uri);
|
||||
if (name == null || name.isEmpty()) name = "FILE";
|
||||
File file = copyToCacheDir(uri);
|
||||
startImex(DcContext.DC_IMEX_IMPORT_SELF_KEYS, file.getAbsolutePath(), name);
|
||||
showImportKeysDialog(file.getAbsolutePath(), name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -330,12 +330,13 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
|
||||
/***********************************************************************************************
|
||||
* Key Import/Export
|
||||
**********************************************************************************************/
|
||||
protected void importSelfKeys() {
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
AttachmentManager.selectMediaType(getActivity(), "application/pgp-keys", new String[]{"text/plain"}, PICK_SELF_KEYS, StorageUtil.getDownloadUri());
|
||||
} else {
|
||||
startImex(DcContext.DC_IMEX_IMPORT_SELF_KEYS);
|
||||
}
|
||||
protected void showImportKeysDialog(String imexPath, String pathAsDisplayedToUser) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.pref_managekeys_import_secret_keys)
|
||||
.setMessage(getActivity().getString(R.string.pref_managekeys_import_explain, pathAsDisplayedToUser))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, (dialogInterface2, i2) -> startImex(DcContext.DC_IMEX_IMPORT_SELF_KEYS, imexPath, pathAsDisplayedToUser))
|
||||
.show();
|
||||
}
|
||||
|
||||
private class ManageKeysListener implements Preference.OnPreferenceClickListener {
|
||||
@@ -371,16 +372,12 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
|
||||
.show();
|
||||
}
|
||||
else {
|
||||
String explain = getActivity().getString(R.string.pref_managekeys_import_explain_tips);
|
||||
if (Build.VERSION.SDK_INT < 30) { // in older Android we always import from Download folder
|
||||
explain = getActivity().getString(R.string.pref_managekeys_import_explain_path, DcHelper.getImexDir().getAbsolutePath()) + "\n\n" + explain;
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
AttachmentManager.selectMediaType(getActivity(), "application/pgp-keys", new String[]{"text/plain"}, PICK_SELF_KEYS, StorageUtil.getDownloadUri());
|
||||
} else {
|
||||
String path = DcHelper.getImexDir().getAbsolutePath();
|
||||
showImportKeysDialog(path, path);
|
||||
}
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.pref_managekeys_import_secret_keys)
|
||||
.setMessage(explain)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, (dialogInterface2, i2) -> importSelfKeys())
|
||||
.show();
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user