mirror of https://github.com/M66B/FairEmail.git
Reset options on import
This commit is contained in:
parent
0ba95456d9
commit
dbbc7111e9
|
@ -406,19 +406,14 @@ public class ApplicationEx extends Application
|
||||||
case "watchdog":
|
case "watchdog":
|
||||||
ServiceSynchronize.scheduleWatchdog(this);
|
ServiceSynchronize.scheduleWatchdog(this);
|
||||||
break;
|
break;
|
||||||
case "secure": // privacy
|
|
||||||
case "load_emoji": // privacy
|
|
||||||
case "shortcuts": // misc
|
|
||||||
case "language": // misc
|
|
||||||
case "wal": // misc
|
|
||||||
// Should be excluded for import
|
|
||||||
restart(this, key);
|
|
||||||
break;
|
|
||||||
case "debug":
|
case "debug":
|
||||||
case "log_level":
|
case "log_level":
|
||||||
Log.setLevel(this);
|
Log.setLevel(this);
|
||||||
FairEmailLoggingProvider.setLevel(this);
|
FairEmailLoggingProvider.setLevel(this);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if (FragmentOptionsBackup.RESTART_OPTIONS.contains(key))
|
||||||
|
restart(this, key);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
|
|
|
@ -86,6 +86,7 @@ import java.security.spec.KeySpec;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -135,6 +136,32 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
|
||||||
private static final int REQUEST_EXPORT_HANDLE = 3;
|
private static final int REQUEST_EXPORT_HANDLE = 3;
|
||||||
private static final int REQUEST_IMPORT_HANDLE = 4;
|
private static final int REQUEST_IMPORT_HANDLE = 4;
|
||||||
|
|
||||||
|
final static List<String> DEFER_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
|
"theme",
|
||||||
|
"beige"
|
||||||
|
));
|
||||||
|
|
||||||
|
final static List<String> RESTART_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
|
"secure", // privacy
|
||||||
|
"load_emoji", // privacy
|
||||||
|
"shortcuts", // misc
|
||||||
|
"language", // misc
|
||||||
|
"wal" // misc
|
||||||
|
));
|
||||||
|
|
||||||
|
static final String[][] RESET_ALL_OPTIONS = {
|
||||||
|
FragmentOptionsSynchronize.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
FragmentOptionsSend.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
FragmentOptionsConnection.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
FragmentOptionsDisplay.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
FragmentOptionsBehavior.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
FragmentOptionsPrivacy.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
FragmentOptionsEncryption.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
FragmentOptionsNotifications.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
//FragmentOptionsIntegrations.RESET_OPTIONS.toArray(new String[0]),
|
||||||
|
FragmentOptionsMisc.RESET_OPTIONS.toArray(new String[0])
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -1136,65 +1163,34 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
|
||||||
// Settings
|
// Settings
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
|
||||||
|
for (String[] options : RESET_ALL_OPTIONS)
|
||||||
|
for (String key : options)
|
||||||
|
if (!skipOption(key) &&
|
||||||
|
!DEFER_OPTIONS.contains(key) &&
|
||||||
|
!RESTART_OPTIONS.contains(key)) {
|
||||||
|
if (BuildConfig.DEBUG && prefs.contains(key))
|
||||||
|
postProgress("Clearing " + key);
|
||||||
|
editor.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
JSONArray jsettings = jimport.getJSONArray("settings");
|
JSONArray jsettings = jimport.getJSONArray("settings");
|
||||||
for (int s = 0; s < jsettings.length(); s++) {
|
for (int s = 0; s < jsettings.length(); s++) {
|
||||||
JSONObject jsetting = (JSONObject) jsettings.get(s);
|
JSONObject jsetting = (JSONObject) jsettings.get(s);
|
||||||
String key = jsetting.getString("key");
|
String key = jsetting.getString("key");
|
||||||
|
|
||||||
if ("pro".equals(key) && !BuildConfig.DEBUG)
|
if (DEFER_OPTIONS.contains(key)) {
|
||||||
continue;
|
|
||||||
if ("iab_json".equals(key) || "iab_signature".equals(key))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ("accept_unsupported".equals(key))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ("biometrics".equals(key) || "pin".equals(key))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ("alert_once".equals(key) && !Helper.isXiaomi())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ("default_folder".equals(key))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ("background_service".equals(key) &&
|
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ("tcp_keep_alive".equals(key))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Prevent restart
|
|
||||||
if ("secure".equals(key) ||
|
|
||||||
"load_emoji".equals(key) ||
|
|
||||||
"shortcuts".equals(key) ||
|
|
||||||
"language".equals(key) ||
|
|
||||||
"wal".equals(key)) {
|
|
||||||
postProgress("Skipping " + key + "=" + jsetting.get("value"));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("theme".equals(key) || "beige".equals(key)) {
|
|
||||||
defer.put(key, jsetting.get("value"));
|
defer.put(key, jsetting.get("value"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key != null && key.startsWith("widget."))
|
// Prevent restart
|
||||||
continue;
|
if (RESTART_OPTIONS.contains(key)) {
|
||||||
if (key != null && key.startsWith("unset."))
|
postProgress("Skipping " + key + "=" + jsetting.get("value"));
|
||||||
continue;
|
|
||||||
|
|
||||||
if ("external_search".equals(key)) {
|
|
||||||
boolean external_search = jsetting.getBoolean("value");
|
|
||||||
Helper.enableComponent(context, ActivitySearch.class, external_search);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("external_storage".equals(key))
|
if (skipOption(key))
|
||||||
continue;
|
|
||||||
|
|
||||||
if ("reformatted_hint".equals(key))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Object value = jsetting.get("value");
|
Object value = jsetting.get("value");
|
||||||
|
@ -1323,6 +1319,48 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
|
||||||
}.setHandler(tvLog.getHandler()).execute(this, args, "setup:import");
|
}.setHandler(tvLog.getHandler()).execute(this, args, "setup:import");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean skipOption(String key) {
|
||||||
|
if ("pro".equals(key) && !BuildConfig.DEBUG)
|
||||||
|
return true;
|
||||||
|
if ("iab_json".equals(key) || "iab_signature".equals(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("accept_unsupported".equals(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("biometrics".equals(key) || "pin".equals(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("alert_once".equals(key) && !Helper.isXiaomi())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("default_folder".equals(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("background_service".equals(key) &&
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("tcp_keep_alive".equals(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("external_storage".equals(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("reformatted_hint".equals(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ("external_search".equals(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (key != null && key.startsWith("widget."))
|
||||||
|
return true;
|
||||||
|
if (key != null && key.startsWith("unset."))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void handleK9Import(Uri uri) {
|
private void handleK9Import(Uri uri) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable("uri", uri);
|
args.putParcelable("uri", uri);
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
|
|
||||||
final static int REQUEST_DEFAULT_FOLDER = 1;
|
final static int REQUEST_DEFAULT_FOLDER = 1;
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"restore_on_launch", "sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
|
"restore_on_launch", "sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
|
||||||
"photo_picker", "default_snooze",
|
"photo_picker", "default_snooze",
|
||||||
"pull", "pull_all", "autoscroll", "quick_filter", "quick_scroll", "quick_actions", "swipe_sensitivity", "foldernav",
|
"pull", "pull_all", "autoscroll", "quick_filter", "quick_scroll", "quick_actions", "swipe_sensitivity", "foldernav",
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||||
private Group grpBC;
|
private Group grpBC;
|
||||||
private Group grpCustomSsl;
|
private Group grpCustomSsl;
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"metered", "download", "download_limited", "roaming", "rlah",
|
"metered", "download", "download_limited", "roaming", "rlah",
|
||||||
"download_headers", "download_eml", "download_plain",
|
"download_headers", "download_eml", "download_plain",
|
||||||
"require_validated", "require_validated_captive", "vpn_only",
|
"require_validated", "require_validated_captive", "vpn_only",
|
||||||
|
|
|
@ -209,7 +209,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||||
|
|
||||||
private NumberFormat NF = NumberFormat.getNumberInstance();
|
private NumberFormat NF = NumberFormat.getNumberInstance();
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"theme", "startup",
|
"theme", "startup",
|
||||||
"date", "date_week", "date_fixed", "date_bold", "date_time", "group_category",
|
"date", "date_week", "date_fixed", "date_bold", "date_time", "group_category",
|
||||||
"cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers", "tabular_unread_bg",
|
"cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers", "tabular_unread_bg",
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class FragmentOptionsEncryption extends FragmentBase
|
||||||
|
|
||||||
static final int REQUEST_IMPORT_CERTIFICATE = 1;
|
static final int REQUEST_IMPORT_CERTIFICATE = 1;
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"sign_default", "encrypt_default", "encrypt_auto",
|
"sign_default", "encrypt_default", "encrypt_auto",
|
||||||
"auto_verify", "auto_decrypt", "auto_undecrypt",
|
"auto_verify", "auto_decrypt", "auto_undecrypt",
|
||||||
"openpgp_provider", "autocrypt", "autocrypt_mutual", "encrypt_subject",
|
"openpgp_provider", "autocrypt", "autocrypt_mutual", "encrypt_subject",
|
||||||
|
|
|
@ -268,7 +268,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
private static final int REQUEST_CLASSIFIER = 1;
|
private static final int REQUEST_CLASSIFIER = 1;
|
||||||
private static final long MIN_FILE_SIZE = 1024 * 1024L;
|
private static final long MIN_FILE_SIZE = 1024 * 1024L;
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"sort_answers", "shortcuts", "ical_tentative", "fts",
|
"sort_answers", "shortcuts", "ical_tentative", "fts",
|
||||||
"classification", "class_min_probability", "class_min_difference",
|
"classification", "class_min_probability", "class_min_difference",
|
||||||
"show_filtered", "haptic_feedback",
|
"show_filtered", "haptic_feedback",
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
private Group grpBackground;
|
private Group grpBackground;
|
||||||
private Group grpTiles;
|
private Group grpTiles;
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"notify_newest_first", "notify_summary",
|
"notify_newest_first", "notify_summary",
|
||||||
"notify_trash", "notify_junk", "notify_block_sender", "notify_archive", "notify_move",
|
"notify_trash", "notify_junk", "notify_block_sender", "notify_archive", "notify_move",
|
||||||
"notify_reply", "notify_reply_direct",
|
"notify_reply", "notify_reply_direct",
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
|
|
||||||
private final static int BIP39_WORDS = 6;
|
private final static int BIP39_WORDS = 6;
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"confirm_links", "sanitize_links", "adguard", "adguard_auto_update",
|
"confirm_links", "sanitize_links", "adguard", "adguard_auto_update",
|
||||||
"check_links_dbl", "confirm_files",
|
"check_links_dbl", "confirm_files",
|
||||||
"confirm_images", "ask_images", "html_always_images", "confirm_html", "ask_html",
|
"confirm_images", "ask_images", "html_always_images", "confirm_html", "ask_html",
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||||
private EditText etSendRetryMax;
|
private EditText etSendRetryMax;
|
||||||
private SwitchCompat swSendPartial;
|
private SwitchCompat swSendPartial;
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"keyboard", "keyboard_no_fullscreen",
|
"keyboard", "keyboard_no_fullscreen",
|
||||||
"suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "suggest_account", "auto_identity",
|
"suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "suggest_account", "auto_identity",
|
||||||
"purge_contact_age", "purge_contact_freq",
|
"purge_contact_age", "purge_contact_freq",
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
private int textColorTertiary;
|
private int textColorTertiary;
|
||||||
private int colorAccent;
|
private int colorAccent;
|
||||||
|
|
||||||
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
|
||||||
"enabled", "poll_interval", "auto_optimize",
|
"enabled", "poll_interval", "auto_optimize",
|
||||||
"poll_metered", "poll_unmetered",
|
"poll_metered", "poll_unmetered",
|
||||||
"schedule", "schedule_start", "schedule_end", "schedule_start_weekend", "schedule_end_weekend", "weekend",
|
"schedule", "schedule_start", "schedule_end", "schedule_start_weekend", "schedule_end_weekend", "weekend",
|
||||||
|
|
Loading…
Reference in New Issue