Optimization

pull/214/head
M66B 12 months ago
parent 3d54182e2b
commit 78c12a460c

@ -477,7 +477,7 @@ public class FragmentOptions extends FragmentBase {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
} }
static void reset(Context context, String[] options, Runnable confirmed) { static void reset(Context context, List<String> options, Runnable confirmed) {
new AlertDialog.Builder(context) new AlertDialog.Builder(context)
.setIcon(R.drawable.twotone_help_24) .setIcon(R.drawable.twotone_help_24)
.setTitle(R.string.title_setup_defaults) .setTitle(R.string.title_setup_defaults)

@ -51,6 +51,10 @@ import androidx.appcompat.widget.SwitchCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class FragmentOptionsBehavior extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsBehavior extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view; private View view;
private ImageButton ibHelp; private ImageButton ibHelp;
@ -113,7 +117,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 String[] RESET_OPTIONS = new String[]{ private 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",
@ -125,7 +129,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
"reset_snooze", "auto_block_sender", "auto_hide_answer", "swipe_reply", "reset_snooze", "auto_block_sender", "auto_hide_answer", "swipe_reply",
"move_thread_all", "move_thread_sent", "move_thread_all", "move_thread_sent",
"default_folder" "default_folder"
}; ));
@Override @Override
@Nullable @Nullable
@ -639,6 +643,9 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
if ("default_snooze".equals(key)) if ("default_snooze".equals(key))
return; return;

@ -66,6 +66,8 @@ import java.security.KeyStore;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import javax.net.SocketFactory; import javax.net.SocketFactory;
@ -124,7 +126,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private Group grpValidated; private Group grpValidated;
private Group grpCustomSsl; private Group grpCustomSsl;
private final static String[] RESET_OPTIONS = new String[]{ private 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",
@ -134,7 +136,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
"ssl_update", "ssl_harden", "ssl_harden_strict", "cert_strict", "cert_transparency", "check_names", "ssl_update", "ssl_harden", "ssl_harden_strict", "cert_strict", "cert_transparency", "check_names",
"open_safe", "http_redirect", "open_safe", "http_redirect",
"bouncy_castle", "bc_fips" "bouncy_castle", "bc_fips"
}; ));
@Override @Override
@Nullable @Nullable
@ -665,6 +667,9 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
if ("timeout".equals(key)) if ("timeout".equals(key))
return; return;
if ("dns_extra".equals(key)) if ("dns_extra".equals(key))

@ -60,6 +60,8 @@ import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -202,7 +204,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private NumberFormat NF = NumberFormat.getNumberInstance(); private NumberFormat NF = NumberFormat.getNumberInstance();
private final static String[] RESET_OPTIONS = new String[]{ private 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", "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers",
@ -226,7 +228,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"list_count", "bundled_fonts", "narrow_fonts", "parse_classes", "list_count", "bundled_fonts", "narrow_fonts", "parse_classes",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_titles", "background_color", "text_color", "text_size", "text_font", "text_align", "text_titles",
"authentication", "authentication_indicator" "authentication", "authentication_indicator"
}; ));
@Override @Override
@Nullable @Nullable
@ -1435,6 +1437,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
if ("message_zoom".equals(key)) if ("message_zoom".equals(key))
return; return;

@ -75,6 +75,7 @@ import java.security.Security;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
@ -117,12 +118,12 @@ public class FragmentOptionsEncryption extends FragmentBase
static final int REQUEST_IMPORT_CERTIFICATE = 1; static final int REQUEST_IMPORT_CERTIFICATE = 1;
private final static String[] RESET_OPTIONS = new String[]{ private 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",
"sign_algo_smime", "encrypt_algo_smime", "check_certificate" "sign_algo_smime", "encrypt_algo_smime", "check_certificate"
}; ));
@Override @Override
@Nullable @Nullable
@ -625,6 +626,9 @@ public class FragmentOptionsEncryption extends FragmentBase
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
getMainHandler().removeCallbacks(update); getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS); getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
} }

@ -46,6 +46,9 @@ import androidx.preference.PreferenceManager;
import com.google.android.material.textfield.TextInputLayout; import com.google.android.material.textfield.TextInputLayout;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class FragmentOptionsIntegrations extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsIntegrations extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view; private View view;
@ -88,13 +91,13 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP
private NumberFormat NF = NumberFormat.getNumberInstance(); private NumberFormat NF = NumberFormat.getNumberInstance();
private final static String[] RESET_OPTIONS = new String[]{ private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
"lt_enabled", "lt_sentence", "lt_auto", "lt_picky", "lt_highlight", "lt_description", "lt_uri", "lt_user", "lt_key", "lt_enabled", "lt_sentence", "lt_auto", "lt_picky", "lt_highlight", "lt_description", "lt_uri", "lt_user", "lt_key",
"deepl_enabled", "deepl_enabled",
"vt_enabled", "vt_apikey", "vt_enabled", "vt_apikey",
"send_enabled", "send_host", "send_dlimit", "send_tlimit", "send_enabled", "send_host", "send_dlimit", "send_tlimit",
"openai_enabled", "openai_uri", "openai_apikey", "openai_model", "openai_temperature", "openai_moderation" "openai_enabled", "openai_uri", "openai_apikey", "openai_model", "openai_temperature", "openai_moderation"
}; ));
@Override @Override
@Nullable @Nullable
@ -519,6 +522,9 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
if ("lt_uri".equals(key) || if ("lt_uri".equals(key) ||
"lt_user".equals(key) || "lt_user".equals(key) ||
"lt_key".equals(key) || "lt_key".equals(key) ||

@ -90,6 +90,7 @@ import java.lang.reflect.Field;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
@ -262,7 +263,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 String[] RESET_OPTIONS = new String[]{ private 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",
@ -287,7 +288,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"easy_correct", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "mdn", "easy_correct", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "mdn",
"app_chooser", "app_chooser_share", "adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape", "app_chooser", "app_chooser_share", "adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape",
"delete_confirmation", "global_keywords", "test_iab" "delete_confirmation", "global_keywords", "test_iab"
}; ));
private final static String[] RESET_QUESTIONS = new String[]{ private final static String[] RESET_QUESTIONS = new String[]{
"first", "app_support", "notify_archive", "first", "app_support", "notify_archive",
@ -2059,6 +2060,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
if ("last_cleanup".equals(key)) if ("last_cleanup".equals(key))
setLastCleanup(prefs.getLong(key, -1)); setLastCleanup(prefs.getLong(key, -1));

@ -62,6 +62,9 @@ import androidx.appcompat.widget.SwitchCompat;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -132,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 String[] RESET_OPTIONS = new String[]{ private 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",
@ -145,7 +148,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
"wearable_preview", "wearable_preview",
"notify_messaging", "notify_messaging",
"biometrics_notify", "notify_open_folder", "background_service", "alert_once" "biometrics_notify", "notify_open_folder", "background_service", "alert_once"
}; ));
@Override @Override
@Nullable @Nullable
@ -801,6 +804,9 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
getMainHandler().removeCallbacks(update); getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS); getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
} }

@ -55,6 +55,8 @@ import androidx.webkit.WebViewFeature;
import java.io.IOException; import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -113,7 +115,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 String[] RESET_OPTIONS = new String[]{ private 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",
@ -124,7 +126,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
"generic_ua", "safe_browsing", "load_emoji", "generic_ua", "safe_browsing", "load_emoji",
"disconnect_auto_update", "disconnect_links", "disconnect_images", "disconnect_auto_update", "disconnect_links", "disconnect_images",
"wipe_mnemonic" "wipe_mnemonic"
}; ));
@Override @Override
@Nullable @Nullable
@ -636,6 +638,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
getMainHandler().removeCallbacks(update); getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS); getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
} }

@ -57,6 +57,8 @@ import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder; import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -121,7 +123,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swReplyMove; private SwitchCompat swReplyMove;
private SwitchCompat swReplyMoveInbox; private SwitchCompat swReplyMoveInbox;
private final static String[] RESET_OPTIONS = new String[]{ private 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",
"send_reminders", "send_chips", "send_nav_color", "send_pending", "send_reminders", "send_chips", "send_nav_color", "send_pending",
@ -139,7 +141,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"receipt_default", "receipt_type", "receipt_legacy", "receipt_default", "receipt_type", "receipt_legacy",
"forward_new", "forward_new",
"lookup_mx", "reply_move", "reply_move_inbox" "lookup_mx", "reply_move", "reply_move_inbox"
}; ));
@Override @Override
@Nullable @Nullable
@ -742,6 +744,9 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
getMainHandler().removeCallbacks(update); getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS); getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
} }

@ -64,7 +64,9 @@ import org.json.JSONObject;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -128,7 +130,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private int textColorTertiary; private int textColorTertiary;
private int colorAccent; private int colorAccent;
private final static String[] RESET_OPTIONS = new String[]{ private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
"enabled", "poll_interval", "auto_optimize", "enabled", "poll_interval", "auto_optimize",
"schedule", "schedule_start", "schedule_end", "schedule_start_weekend", "schedule_end_weekend", "weekend", "schedule", "schedule_start", "schedule_end", "schedule_start_weekend", "schedule_end_weekend", "weekend",
"sync_quick_imap", "sync_quick_pop", "sync_quick_imap", "sync_quick_pop",
@ -138,7 +140,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
"check_authentication", "check_tls", "check_reply_domain", "check_mx", "check_authentication", "check_tls", "check_reply_domain", "check_mx",
"check_blocklist", "use_blocklist", "use_blocklist_pop", "check_blocklist", "use_blocklist", "use_blocklist_pop",
"tune_keep_alive" "tune_keep_alive"
}; ));
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -646,6 +648,9 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (!RESET_OPTIONS.contains(key))
return;
getMainHandler().removeCallbacks(update); getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS); getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
} }

Loading…
Cancel
Save