From 2bddf838c6991dfb5cfd286449fcd86193efa47d Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 21 Oct 2018 07:48:18 +0000 Subject: [PATCH] Added text action to search primary archive --- app/src/main/AndroidManifest.xml | 10 ++++- .../java/eu/faircode/email/ActivityView.java | 39 +++++++++++++++++++ .../java/eu/faircode/email/DaoFolder.java | 5 +++ .../eu/faircode/email/FragmentMessages.java | 7 +--- app/src/main/res/values/strings.xml | 3 +- 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fb34be07..0d8048b2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -50,9 +50,15 @@ + android:parentActivityName=".ActivityMain"> + + + + + + () { + @Override + protected Long onLoad(Context context, Bundle args) { + EntityFolder archive = DB.getInstance(context).folder().getPrimaryArchive(); + if (archive == null) + throw new IllegalArgumentException(getString(R.string.title_no_archive)); + return archive.id; + } + + @Override + protected void onLoaded(Bundle args, Long archive) { + Bundle sargs = new Bundle(); + sargs.putLong("folder", archive); + sargs.putString("search", args.getString("search")); + + FragmentMessages fragment = new FragmentMessages(); + fragment.setArguments(sargs); + + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search"); + fragmentTransaction.commit(); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.unexpectedError(ActivityView.this, ex); + } + }.load(this, args); + } } @Override diff --git a/app/src/main/java/eu/faircode/email/DaoFolder.java b/app/src/main/java/eu/faircode/email/DaoFolder.java index bcb54ebb..3485a37c 100644 --- a/app/src/main/java/eu/faircode/email/DaoFolder.java +++ b/app/src/main/java/eu/faircode/email/DaoFolder.java @@ -96,6 +96,11 @@ public interface DaoFolder { " WHERE `primary` AND type = '" + EntityFolder.DRAFTS + "'") EntityFolder getPrimaryDrafts(); + @Query("SELECT folder.* FROM folder" + + " JOIN account ON account.id = folder.account" + + " WHERE `primary` AND type = '" + EntityFolder.ARCHIVE + "'") + EntityFolder getPrimaryArchive(); + @Query("SELECT * FROM folder WHERE type = '" + EntityFolder.OUTBOX + "'") EntityFolder getOutbox(); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 4a68d5d3..627912c8 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -657,12 +657,9 @@ public class FragmentMessages extends FragmentEx { @Override protected void onLoaded(Bundle args, Void data) { - Intent intent = new Intent(); - intent.putExtra("folder", args.getLong("folder", folder)); - intent.putExtra("search", args.getString("search")); - FragmentMessages fragment = new FragmentMessages(); - fragment.setArguments(intent.getExtras()); + fragment.setArguments(args); + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search"); fragmentTransaction.commit(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 85e5fad3..211cf434 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -124,7 +124,8 @@ Host name missing User name missing Password missing - Drafts folder missing + No primary account or no drafts folder + No primary account or no archive folder This provider does not support push messages. Reception of new messages can be delayed. IMAP UIDPLUS not supported, see the FAQ Delete this account permanently?