From 82929b231ef17fc34f5b4760d42669b881a745f2 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 12 Aug 2018 16:14:20 +0000 Subject: [PATCH] Fixes --- .../java/eu/faircode/email/AdapterFolder.java | 5 +++-- .../eu/faircode/email/AdapterMessage.java | 2 +- .../eu/faircode/email/FragmentCompose.java | 21 ++++++++++++------- .../eu/faircode/email/FragmentFolder.java | 2 +- .../eu/faircode/email/FragmentIdentity.java | 2 +- .../eu/faircode/email/FragmentMessage.java | 2 +- .../eu/faircode/email/FragmentMessages.java | 6 ++++-- .../java/eu/faircode/email/FragmentSetup.java | 2 +- 8 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterFolder.java b/app/src/main/java/eu/faircode/email/AdapterFolder.java index 81294f2adc..aa163345a7 100644 --- a/app/src/main/java/eu/faircode/email/AdapterFolder.java +++ b/app/src/main/java/eu/faircode/email/AdapterFolder.java @@ -145,8 +145,9 @@ public class AdapterFolder extends RecyclerView.Adapter() { @Override public int compare(TupleFolderEx f1, TupleFolderEx f2) { - int s = ((Integer) EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type)) - .compareTo(EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type)); + int s = Integer.compare( + EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type), + EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type)); if (s != 0) return s; int c = -f1.synchronize.compareTo(f2.synchronize); diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index aa94c03405..00a7c85483 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -203,7 +203,7 @@ public class AdapterMessage extends PagedListAdapter DIFF_CALLBACK = + private static final DiffUtil.ItemCallback DIFF_CALLBACK = new DiffUtil.ItemCallback() { @Override public boolean areItemsTheSame( diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 9664085840..5b42964cca 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -317,12 +317,14 @@ public class FragmentCompose extends FragmentEx { private void handlePickContact(int requestCode, Intent data) { Cursor cursor = null; try { - cursor = getContext().getContentResolver().query(data.getData(), - new String[]{ - ContactsContract.CommonDataKinds.Email.ADDRESS, - ContactsContract.Contacts.DISPLAY_NAME - }, - null, null, null); + Uri uri = data.getData(); + if (uri != null) + cursor = getContext().getContentResolver().query(uri, + new String[]{ + ContactsContract.CommonDataKinds.Email.ADDRESS, + ContactsContract.Contacts.DISPLAY_NAME + }, + null, null, null); if (cursor != null && cursor.moveToFirst()) { int colEmail = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS); int colName = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); @@ -370,7 +372,8 @@ public class FragmentCompose extends FragmentEx { Cursor cursor = null; try { Uri uri = args.getParcelable("uri"); - cursor = context.getContentResolver().query(uri, null, null, null, null, null); + if (uri != null) + cursor = context.getContentResolver().query(uri, null, null, null, null, null); if (cursor == null || !cursor.moveToFirst()) return null; @@ -479,11 +482,13 @@ public class FragmentCompose extends FragmentEx { Log.i(Helper.TAG, "Load draft action=" + action + " id=" + id + " account=" + account + " reference=" + reference); + EntityMessage draft; + DB db = DB.getInstance(context); try { db.beginTransaction(); - EntityMessage draft = db.message().getMessage(id); + draft = db.message().getMessage(id); if (draft == null) { if ("edit".equals(action)) throw new IllegalStateException("Message to edit not found"); diff --git a/app/src/main/java/eu/faircode/email/FragmentFolder.java b/app/src/main/java/eu/faircode/email/FragmentFolder.java index d42f7d2eac..c5d10838d3 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolder.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolder.java @@ -75,7 +75,7 @@ public class FragmentFolder extends FragmentEx { new SimpleTask() { @Override - protected Void onLoad(Context context, Bundle args) throws Throwable { + protected Void onLoad(Context context, Bundle args) { try { ServiceSynchronize.stop(getContext(), "folder"); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 782efd35d3..cf5fec333a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -278,7 +278,7 @@ public class FragmentIdentity extends FragmentEx { return null; } finally { - ServiceSynchronize.restart(getContext(), "account"); + ServiceSynchronize.restart(getContext(), "identity"); } } diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index 83e2c67b04..45b6202ee7 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -337,7 +337,7 @@ public class FragmentMessage extends FragmentEx { top_navigation.setVisibility(View.VISIBLE); bottom_navigation.getMenu().findItem(R.id.action_spam).setVisible(!inOutbox && !inArchive && !inJunk && hasJunk); - bottom_navigation.getMenu().findItem(R.id.action_trash).setVisible(!inOutbox && !inArchive && hasTrash); + bottom_navigation.getMenu().findItem(R.id.action_trash).setVisible(!inOutbox && hasTrash); bottom_navigation.getMenu().findItem(R.id.action_move).setVisible(!inOutbox && (!inInbox || hasUser)); bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(!inOutbox && !inArchive && hasArchive); bottom_navigation.getMenu().findItem(R.id.action_reply).setVisible(!inOutbox); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index bed8f5f939..c0a1f7e1b5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -185,8 +185,10 @@ public class FragmentMessages extends FragmentEx { @Override protected void onLoaded(Bundle args, Long account) { - fab.setTag(account); - fab.setVisibility(View.VISIBLE); + if (account != null) { + fab.setTag(account); + fab.setVisibility(View.VISIBLE); + } } @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java index 1dab8b0646..6205370acd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java @@ -155,7 +155,7 @@ public class FragmentSetup extends FragmentEx { // Create outbox new SimpleTask() { @Override - protected Void onLoad(Context context, Bundle args) throws Throwable { + protected Void onLoad(Context context, Bundle args) { DB db = DB.getInstance(context); try { db.beginTransaction();