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();
args.putLongArray("ids", ids);
args.putString("type", type);
new SimpleTask<List<Long>>() {
@Override
protected List<Long> onExecute(Context context, Bundle args) throws Throwable {
long[] ids = args.getLongArray("ids");
String type = args.getString("type");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean filter_seen = prefs.getBoolean("filter_seen", false);
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false);
boolean filter_snoozed = prefs.getBoolean("filter_snoozed", true);
boolean filter_seen = prefs.getBoolean(FragmentMessages.getFilter("seen", type), false);
boolean filter_unflagged = prefs.getBoolean(FragmentMessages.getFilter("unflagged", type), false);
boolean filter_snoozed = prefs.getBoolean(FragmentMessages.getFilter("snoozed", type), true);
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);
if (criteria == null) {
boolean filter_seen = prefs.getBoolean("filter_seen", false);
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false);
boolean filter_seen = prefs.getBoolean(FragmentMessages.getFilter("seen", browsable.type), false);
boolean filter_unflagged = prefs.getBoolean(FragmentMessages.getFilter("unflagged", browsable.type), false);
EntityLog.log(context, "Boundary filter seen=" + filter_seen + " unflagged=" + filter_unflagged);
List<SearchTerm> and = new ArrayList<>();

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

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

Loading…
Cancel
Save