Separated main filter by in/outgoing

pull/197/head
M66B 4 years ago
parent b11ef63ab6
commit f720508c65

@ -5822,16 +5822,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLongArray("ids", ids); args.putLongArray("ids", ids);
args.putString("type", type);
new SimpleTask<List<Long>>() { new SimpleTask<List<Long>>() {
@Override @Override
protected List<Long> onExecute(Context context, Bundle args) throws Throwable { protected List<Long> onExecute(Context context, Bundle args) throws Throwable {
long[] ids = args.getLongArray("ids"); long[] ids = args.getLongArray("ids");
String type = args.getString("type");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean filter_seen = prefs.getBoolean("filter_seen", false); boolean filter_seen = prefs.getBoolean(FragmentMessages.getFilter("seen", type), false);
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false); boolean filter_unflagged = prefs.getBoolean(FragmentMessages.getFilter("unflagged", type), false);
boolean filter_snoozed = prefs.getBoolean("filter_snoozed", true); boolean filter_snoozed = prefs.getBoolean(FragmentMessages.getFilter("snoozed", type), true);
List<Long> removed = new ArrayList<>(); List<Long> removed = new ArrayList<>();

@ -384,8 +384,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
db.folder().setFolderTotal(browsable.id, count < 0 ? null : count); db.folder().setFolderTotal(browsable.id, count < 0 ? null : count);
if (criteria == null) { if (criteria == null) {
boolean filter_seen = prefs.getBoolean("filter_seen", false); boolean filter_seen = prefs.getBoolean(FragmentMessages.getFilter("seen", browsable.type), false);
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false); boolean filter_unflagged = prefs.getBoolean(FragmentMessages.getFilter("unflagged", browsable.type), false);
EntityLog.log(context, "Boundary filter seen=" + filter_seen + " unflagged=" + filter_unflagged); EntityLog.log(context, "Boundary filter seen=" + filter_seen + " unflagged=" + filter_unflagged);
List<SearchTerm> and = new ArrayList<>(); List<SearchTerm> and = new ArrayList<>();

@ -789,24 +789,27 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ibSeen.setOnClickListener(new View.OnClickListener() { ibSeen.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
boolean filter = prefs.getBoolean("filter_seen", true); String name = getFilter("seen", type);
onMenuFilter("filter_seen", !filter); boolean filter = prefs.getBoolean(name, true);
onMenuFilter(name, !filter);
} }
}); });
ibUnflagged.setOnClickListener(new View.OnClickListener() { ibUnflagged.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
boolean filter = prefs.getBoolean("filter_unflagged", true); String name = getFilter("unflagged", type);
onMenuFilter("filter_unflagged", !filter); boolean filter = prefs.getBoolean(name, true);
onMenuFilter(name, !filter);
} }
}); });
ibSnoozed.setOnClickListener(new View.OnClickListener() { ibSnoozed.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
boolean filter = prefs.getBoolean("filter_snoozed", true); String name = getFilter("snoozed", type);
onMenuFilter("filter_snoozed", !filter); boolean filter = prefs.getBoolean(name, true);
onMenuFilter(name, !filter);
} }
}); });
@ -4069,10 +4072,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
String sort = prefs.getString("sort", "time"); String sort = prefs.getString("sort", "time");
boolean ascending = prefs.getBoolean( boolean ascending = prefs.getBoolean(
viewType == AdapterMessage.ViewType.THREAD ? "ascending_thread" : "ascending_list", false); viewType == AdapterMessage.ViewType.THREAD ? "ascending_thread" : "ascending_list", false);
boolean filter_seen = prefs.getBoolean("filter_seen", false); boolean filter_seen = prefs.getBoolean(getFilter("seen", type), false);
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false); boolean filter_unflagged = prefs.getBoolean(getFilter("unflagged", type), false);
boolean filter_unknown = prefs.getBoolean("filter_unknown", false); boolean filter_unknown = prefs.getBoolean(getFilter("unknown", type), false);
boolean filter_snoozed = prefs.getBoolean("filter_snoozed", true); boolean filter_snoozed = prefs.getBoolean(getFilter("snoozed", type), true);
boolean filter_duplicates = prefs.getBoolean("filter_duplicates", true); boolean filter_duplicates = prefs.getBoolean("filter_duplicates", true);
boolean language_detection = prefs.getBoolean("language_detection", false); boolean language_detection = prefs.getBoolean("language_detection", false);
boolean compact = prefs.getBoolean("compact", false); boolean compact = prefs.getBoolean("compact", false);
@ -4233,16 +4236,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
onMenuAscending(!item.isChecked()); onMenuAscending(!item.isChecked());
return true; return true;
} else if (itemId == R.id.menu_filter_seen) { } else if (itemId == R.id.menu_filter_seen) {
onMenuFilter("filter_seen", !item.isChecked()); onMenuFilter(getFilter("seen", type), !item.isChecked());
return true; return true;
} else if (itemId == R.id.menu_filter_unflagged) { } else if (itemId == R.id.menu_filter_unflagged) {
onMenuFilter("filter_unflagged", !item.isChecked()); onMenuFilter(getFilter("unflagged", type), !item.isChecked());
return true; return true;
} else if (itemId == R.id.menu_filter_unknown) { } else if (itemId == R.id.menu_filter_unknown) {
onMenuFilter("filter_unknown", !item.isChecked()); onMenuFilter(getFilter("unknown", type), !item.isChecked());
return true; return true;
} else if (itemId == R.id.menu_filter_snoozed) { } else if (itemId == R.id.menu_filter_snoozed) {
onMenuFilter("filter_snoozed", !item.isChecked()); onMenuFilter(getFilter("snoozed", type), !item.isChecked());
return true; return true;
} else if (itemId == R.id.menu_filter_duplicates) { } else if (itemId == R.id.menu_filter_duplicates) {
onMenuFilterDuplicates(!item.isChecked()); onMenuFilterDuplicates(!item.isChecked());
@ -4513,9 +4516,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
long folder = args.getLong("folder"); long folder = args.getLong("folder");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false); boolean filter_unflagged = prefs.getBoolean(getFilter("unflagged", type), false);
boolean filter_unknown = prefs.getBoolean("filter_unknown", false); boolean filter_unknown = prefs.getBoolean(getFilter("unknown", type), false);
boolean filter_snoozed = prefs.getBoolean("filter_snoozed", true); boolean filter_snoozed = prefs.getBoolean(getFilter("snoozed", type), true);
boolean language_detection = prefs.getBoolean("language_detection", false); boolean language_detection = prefs.getBoolean("language_detection", false);
String filter_language = prefs.getString("filter_language", null); String filter_language = prefs.getString("filter_language", null);
@ -4809,9 +4812,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return; return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean filter_seen = prefs.getBoolean("filter_seen", false); boolean filter_seen = prefs.getBoolean(getFilter("seen", type), false);
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false); boolean filter_unflagged = prefs.getBoolean(getFilter("unflagged", type), false);
boolean filter_unknown = prefs.getBoolean("filter_unknown", false); boolean filter_unknown = prefs.getBoolean(getFilter("unknown", type), false);
boolean language_detection = prefs.getBoolean("language_detection", false); boolean language_detection = prefs.getBoolean("language_detection", false);
String filter_language = prefs.getString("filter_language", null); String filter_language = prefs.getString("filter_language", null);
boolean filter_active = (filter_seen || filter_unflagged || filter_unknown || boolean filter_active = (filter_seen || filter_unflagged || filter_unknown ||
@ -5543,6 +5546,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return TextUtils.join(", ", displays); return TextUtils.join(", ", displays);
} }
static String getFilter(String name, String type) {
return "filter_" + (EntityFolder.isOutgoing(type) ? "out_" : "") + name;
}
private void lockMessage(long id) throws IOException { private void lockMessage(long id) throws IOException {
Context context = getContext(); Context context = getContext();
if (context == null) if (context == null)

@ -445,10 +445,10 @@ public class ViewModelMessages extends ViewModel {
this.sort = prefs.getString("sort", "time"); this.sort = prefs.getString("sort", "time");
this.ascending = prefs.getBoolean( this.ascending = prefs.getBoolean(
viewType == AdapterMessage.ViewType.THREAD ? "ascending_thread" : "ascending_list", false); viewType == AdapterMessage.ViewType.THREAD ? "ascending_thread" : "ascending_list", false);
this.filter_seen = prefs.getBoolean("filter_seen", false); this.filter_seen = prefs.getBoolean(FragmentMessages.getFilter("seen", type), false);
this.filter_unflagged = prefs.getBoolean("filter_unflagged", false); this.filter_unflagged = prefs.getBoolean(FragmentMessages.getFilter("unflagged", type), false);
this.filter_unknown = prefs.getBoolean("filter_unknown", false); this.filter_unknown = prefs.getBoolean(FragmentMessages.getFilter("unknown", type), false);
this.filter_snoozed = prefs.getBoolean("filter_snoozed", true); this.filter_snoozed = prefs.getBoolean(FragmentMessages.getFilter("snoozed", type), true);
boolean language_detection = prefs.getBoolean("language_detection", false); boolean language_detection = prefs.getBoolean("language_detection", false);
String filter_language = prefs.getString("filter_language", null); String filter_language = prefs.getString("filter_language", null);

Loading…
Cancel
Save