Added select all for search results

pull/159/head
M66B 5 years ago
parent 03f7f4271b
commit 834e84273b

@ -201,13 +201,15 @@ public interface DaoMessage {
List<Long> getMessageIdsByFolder(Long folder); List<Long> getMessageIdsByFolder(Long folder);
@Query("SELECT message.id" + @Query("SELECT message.id" +
" FROM folder" + " FROM message" +
" JOIN message ON message.folder = folder.id" + " JOIN folder ON folder.id = message.folder" +
" WHERE CASE WHEN :folder IS NULL THEN folder.unified ELSE folder.id = :folder END" + " WHERE ((:search AND ui_found)" +
" OR (NOT :search AND :folder IS NULL AND folder.unified)" +
" OR (NOT :search AND folder.id = :folder))" +
" AND ui_hide = 0" + " AND ui_hide = 0" +
" AND (ui_snoozed IS NULL OR :snoozed)" + " AND (:snoozed OR ui_snoozed IS NULL)" +
" ORDER BY message.received DESC") " ORDER BY message.received DESC")
List<Long> getMessageAll(Long folder, boolean snoozed); List<Long> getMessageIds(Long folder, boolean search, boolean snoozed);
@Query("SELECT id" + @Query("SELECT id" +
" FROM message" + " FROM message" +

@ -2445,7 +2445,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_compact).setChecked(prefs.getBoolean("compact", false)); menu.findItem(R.id.menu_compact).setChecked(prefs.getBoolean("compact", false));
menu.findItem(R.id.menu_select_all).setVisible(!outbox && menu.findItem(R.id.menu_select_all).setVisible(!outbox &&
(viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER)); (viewType == AdapterMessage.ViewType.UNIFIED ||
viewType == AdapterMessage.ViewType.FOLDER ||
viewType == AdapterMessage.ViewType.SEARCH));
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
} }
@ -2610,16 +2612,18 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", folder); args.putLong("id", folder);
args.putBoolean("search", viewType == AdapterMessage.ViewType.SEARCH);
args.putBoolean("snoozed", snoozed); args.putBoolean("snoozed", snoozed);
new SimpleTask<List<Long>>() { new SimpleTask<List<Long>>() {
@Override @Override
protected List<Long> onExecute(Context context, Bundle args) { protected List<Long> onExecute(Context context, Bundle args) {
long id = args.getLong("id"); long id = args.getLong("id");
boolean search = args.getBoolean("search");
boolean snoozed = args.getBoolean("snoozed"); boolean snoozed = args.getBoolean("snoozed");
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
return db.message().getMessageAll(id < 0 ? null : id, snoozed); return db.message().getMessageIds(id < 0 ? null : id, search, snoozed);
} }
@Override @Override

Loading…
Cancel
Save