mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-18 21:28:54 +00:00
Small behavior improvement
This commit is contained in:
parent
5a44a6bd48
commit
4c34d918a3
1 changed files with 13 additions and 1 deletions
|
@ -93,6 +93,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
private SwitchCompat swCheckBlocklist;
|
private SwitchCompat swCheckBlocklist;
|
||||||
private SwitchCompat swUseBlocklist;
|
private SwitchCompat swUseBlocklist;
|
||||||
private RecyclerView rvBlocklist;
|
private RecyclerView rvBlocklist;
|
||||||
|
private AdapterBlocklist badapter;
|
||||||
|
|
||||||
private Group grpExempted;
|
private Group grpExempted;
|
||||||
|
|
||||||
|
@ -379,6 +380,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
prefs.edit().putBoolean("check_blocklist", checked).apply();
|
prefs.edit().putBoolean("check_blocklist", checked).apply();
|
||||||
swUseBlocklist.setEnabled(checked);
|
swUseBlocklist.setEnabled(checked);
|
||||||
|
if (badapter != null)
|
||||||
|
badapter.enabledChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -391,7 +394,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
|
|
||||||
rvBlocklist.setHasFixedSize(false);
|
rvBlocklist.setHasFixedSize(false);
|
||||||
rvBlocklist.setLayoutManager(new LinearLayoutManager(getContext()));
|
rvBlocklist.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
AdapterBlocklist badapter = new AdapterBlocklist(getContext(), DnsBlockList.getListsAvailable());
|
badapter = new AdapterBlocklist(getContext(), DnsBlockList.getListsAvailable());
|
||||||
rvBlocklist.setAdapter(badapter);
|
rvBlocklist.setAdapter(badapter);
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
|
@ -679,6 +682,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
private Context context;
|
private Context context;
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
|
|
||||||
|
private boolean enabled;
|
||||||
private List<DnsBlockList.BlockList> items;
|
private List<DnsBlockList.BlockList> items;
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements CompoundButton.OnCheckedChangeListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements CompoundButton.OnCheckedChangeListener {
|
||||||
|
@ -700,6 +704,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
private void bindTo(DnsBlockList.BlockList blocklist) {
|
private void bindTo(DnsBlockList.BlockList blocklist) {
|
||||||
cbEnabled.setText(blocklist.name);
|
cbEnabled.setText(blocklist.name);
|
||||||
cbEnabled.setChecked(DnsBlockList.isEnabled(context, blocklist));
|
cbEnabled.setChecked(DnsBlockList.isEnabled(context, blocklist));
|
||||||
|
cbEnabled.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -719,6 +724,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
|
|
||||||
setHasStableIds(true);
|
setHasStableIds(true);
|
||||||
this.items = items;
|
this.items = items;
|
||||||
|
enabledChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void enabledChanged() {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
this.enabled = prefs.getBoolean("check_blocklist", false);
|
||||||
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue