Batch update preferences

pull/214/head
M66B 1 year ago
parent 6568345e09
commit 65ca2958c9

@ -68,6 +68,8 @@ public class FragmentOptions extends FragmentBase {
private String searching = null;
private SuggestData data = null;
static final long DELAY_SETOPTIONS = 20; // ms
private static final int[] TAB_PAGES = {
R.layout.fragment_setup,
R.layout.fragment_options_synchronize,

@ -285,6 +285,15 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
"cloud_activated".equals(key) ||
"cloud_busy".equals(key) ||
"cloud_last_sync".equals(key)) {
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
}
private Runnable update = new RunnableEx("backup") {
@Override
protected void delegate() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String user = prefs.getString("cloud_user", null);
String password = prefs.getString("cloud_password", null);
boolean auth = !(TextUtils.isEmpty(user) || TextUtils.isEmpty(password));
@ -301,8 +310,9 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
grpLogin.setVisibility(auth ? View.GONE : View.VISIBLE);
grpActivate.setVisibility(auth && !activated && !busy ? View.VISIBLE : View.GONE);
grpLogout.setVisibility(auth ? View.VISIBLE : View.GONE);
}
}
};
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

@ -633,9 +633,17 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
if ("default_snooze".equals(key))
return;
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("behavior") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);

@ -381,9 +381,17 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
if ("timeout".equals(key))
return;
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("connection") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onResume() {
super.onResume();

@ -1409,9 +1409,17 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
if ("message_zoom".equals(key))
return;
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("display") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);

@ -624,9 +624,17 @@ public class FragmentOptionsEncryption extends FragmentBase
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("encryption") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);

@ -2386,9 +2386,17 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
if ("native_arc_whitelist".equals(key))
return;
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("misc") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);

@ -792,9 +792,17 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("notifications") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);

@ -568,9 +568,17 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("privacy") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);

@ -722,9 +722,17 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("send") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);

@ -569,9 +569,17 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
setOptions();
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
}
private Runnable update = new RunnableEx("sync") {
@Override
protected void delegate() {
setOptions();
}
};
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);

Loading…
Cancel
Save