mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Added select all
This commit is contained in:
parent
a1c740676e
commit
581e26f1c4
4 changed files with 56 additions and 2 deletions
|
@ -183,6 +183,15 @@ public interface DaoMessage {
|
||||||
" ORDER BY message.received DESC")
|
" ORDER BY message.received DESC")
|
||||||
List<Long> getMessageIdsByFolder(Long folder);
|
List<Long> getMessageIdsByFolder(Long folder);
|
||||||
|
|
||||||
|
@Query("SELECT message.id" +
|
||||||
|
" FROM folder" +
|
||||||
|
" JOIN message ON message.folder = folder.id" +
|
||||||
|
" WHERE CASE WHEN :folder IS NULL THEN folder.unified ELSE folder.id = :folder END" +
|
||||||
|
" AND NOT ui_hide" +
|
||||||
|
" AND (ui_snoozed IS NULL OR :snoozed)" +
|
||||||
|
" ORDER BY message.received DESC")
|
||||||
|
List<Long> getMessageAll(Long folder, boolean snoozed);
|
||||||
|
|
||||||
@Query("SELECT *" +
|
@Query("SELECT *" +
|
||||||
" FROM message" +
|
" FROM message" +
|
||||||
" WHERE account = :account" +
|
" WHERE account = :account" +
|
||||||
|
|
|
@ -1981,6 +1981,9 @@ public class FragmentMessages extends FragmentBase {
|
||||||
menu.findItem(R.id.menu_duplicates).setVisible(viewType == AdapterMessage.ViewType.THREAD);
|
menu.findItem(R.id.menu_duplicates).setVisible(viewType == AdapterMessage.ViewType.THREAD);
|
||||||
menu.findItem(R.id.menu_duplicates).setChecked(prefs.getBoolean("duplicates", true));
|
menu.findItem(R.id.menu_duplicates).setChecked(prefs.getBoolean("duplicates", true));
|
||||||
|
|
||||||
|
menu.findItem(R.id.menu_select_all).setVisible(!outbox &&
|
||||||
|
(viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER));
|
||||||
|
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2038,6 +2041,10 @@ public class FragmentMessages extends FragmentBase {
|
||||||
onMenuDuplicates();
|
onMenuDuplicates();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case R.id.menu_select_all:
|
||||||
|
onMenuSelectAll();
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@ -2101,6 +2108,37 @@ public class FragmentMessages extends FragmentBase {
|
||||||
adapter.setDuplicates(!duplicates);
|
adapter.setDuplicates(!duplicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onMenuSelectAll() {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
boolean snoozed = prefs.getBoolean("snoozed", false);
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("id", folder);
|
||||||
|
args.putBoolean("snoozed", snoozed);
|
||||||
|
|
||||||
|
new SimpleTask<List<Long>>() {
|
||||||
|
@Override
|
||||||
|
protected List<Long> onExecute(Context context, Bundle args) {
|
||||||
|
long id = args.getLong("id");
|
||||||
|
boolean snoozed = args.getBoolean("snoozed");
|
||||||
|
|
||||||
|
DB db = DB.getInstance(context);
|
||||||
|
return db.message().getMessageAll(id < 0 ? null : id, snoozed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onExecuted(Bundle args, List<Long> ids) {
|
||||||
|
for (long id : ids)
|
||||||
|
selectionTracker.select(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
|
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
||||||
|
}
|
||||||
|
}.execute(this, args, "messages:all");
|
||||||
|
}
|
||||||
|
|
||||||
private void loadMessages() {
|
private void loadMessages() {
|
||||||
if (viewType == AdapterMessage.ViewType.THREAD && autonext) {
|
if (viewType == AdapterMessage.ViewType.THREAD && autonext) {
|
||||||
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
|
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
|
||||||
|
|
|
@ -67,4 +67,10 @@
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
android:title="@string/title_duplicates"
|
android:title="@string/title_duplicates"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_select_all"
|
||||||
|
android:icon="@drawable/baseline_format_size_24"
|
||||||
|
android:title="@string/title_select_all"
|
||||||
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -457,12 +457,13 @@
|
||||||
|
|
||||||
<string name="title_compact">Compact view</string>
|
<string name="title_compact">Compact view</string>
|
||||||
<string name="title_zoom">Text size</string>
|
<string name="title_zoom">Text size</string>
|
||||||
|
<string name="title_snoozed">Snoozed</string>
|
||||||
|
<string name="title_duplicates">Show duplicates</string>
|
||||||
|
<string name="title_select_all">Select all</string>
|
||||||
|
|
||||||
<string name="title_address_sent">Sent:</string>
|
<string name="title_address_sent">Sent:</string>
|
||||||
<string name="title_address_unsent">Unsent:</string>
|
<string name="title_address_unsent">Unsent:</string>
|
||||||
<string name="title_address_invalid">Invalid:</string>
|
<string name="title_address_invalid">Invalid:</string>
|
||||||
<string name="title_snoozed">Snoozed</string>
|
|
||||||
<string name="title_duplicates">Show duplicates</string>
|
|
||||||
|
|
||||||
<string name="title_previous">Previous</string>
|
<string name="title_previous">Previous</string>
|
||||||
<string name="title_next">Next</string>
|
<string name="title_next">Next</string>
|
||||||
|
|
Loading…
Reference in a new issue