mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 23:12:55 +00:00
Move outbox to navigation menu
This commit is contained in:
parent
01fcffe8c9
commit
73a23b9d50
4 changed files with 77 additions and 27 deletions
|
@ -178,6 +178,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
DrawerItem item = drawerArray.getItem(position);
|
DrawerItem item = drawerArray.getItem(position);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
|
Log.i("Navigation id=" + item.getId() + " menu=" + item.getMenuId());
|
||||||
|
|
||||||
switch (item.getMenuId()) {
|
switch (item.getMenuId()) {
|
||||||
case R.string.menu_answers:
|
case R.string.menu_answers:
|
||||||
|
@ -220,6 +221,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
long account = item.getId();
|
long account = item.getId();
|
||||||
if (account > 0)
|
if (account > 0)
|
||||||
onMenuFolders(account);
|
onMenuFolders(account);
|
||||||
|
else
|
||||||
|
onMenuOutbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
drawerLayout.closeDrawer(drawerList);
|
drawerLayout.closeDrawer(drawerList);
|
||||||
|
@ -296,6 +299,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
!Objects.equals(account.color, other.color) ||
|
!Objects.equals(account.color, other.color) ||
|
||||||
!Objects.equals(account.state, other.state) ||
|
!Objects.equals(account.state, other.state) ||
|
||||||
account.unseen != other.unseen ||
|
account.unseen != other.unseen ||
|
||||||
|
account.unsent != other.unsent ||
|
||||||
account.operations != other.operations) {
|
account.operations != other.operations) {
|
||||||
changed = true;
|
changed = true;
|
||||||
break;
|
break;
|
||||||
|
@ -310,7 +314,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
|
|
||||||
List<DrawerItem> items = new ArrayList<>();
|
List<DrawerItem> items = new ArrayList<>();
|
||||||
|
|
||||||
int operations = 0;
|
int unsent = 0;
|
||||||
|
int pending = 0;
|
||||||
for (TupleAccountEx account : accounts) {
|
for (TupleAccountEx account : accounts) {
|
||||||
String title;
|
String title;
|
||||||
if (account.unseen > 0)
|
if (account.unseen > 0)
|
||||||
|
@ -322,35 +327,44 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
? account.primary ? R.drawable.baseline_folder_special_24 : R.drawable.baseline_folder_24
|
? account.primary ? R.drawable.baseline_folder_special_24 : R.drawable.baseline_folder_24
|
||||||
: R.drawable.baseline_folder_open_24,
|
: R.drawable.baseline_folder_open_24,
|
||||||
title, account.color, account.unseen > 0));
|
title, account.color, account.unseen > 0));
|
||||||
operations += account.operations;
|
unsent += account.unsent;
|
||||||
|
pending += account.operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
items.add(new DrawerItem(-1));
|
items.add(new DrawerItem(-1));
|
||||||
items.add(new DrawerItem(-2, R.drawable.baseline_reply_24, R.string.menu_answers));
|
|
||||||
|
|
||||||
String title;
|
String outbox;
|
||||||
if (operations == 0)
|
if (unsent > 0)
|
||||||
title = getString(R.string.menu_operations);
|
outbox = getString(R.string.title_name_count, getString(R.string.title_folder_outbox), nf.format(unsent));
|
||||||
else
|
else
|
||||||
title = getString(R.string.title_name_count,
|
outbox = getString(R.string.title_folder_outbox);
|
||||||
getString(R.string.menu_operations),
|
items.add(new DrawerItem(-2, R.drawable.baseline_send_24, outbox, null, unsent > 0));
|
||||||
nf.format(operations));
|
|
||||||
items.add(new DrawerItem(-3, R.string.menu_operations, R.drawable.baseline_list_24, title, operations > 0));
|
|
||||||
|
|
||||||
items.add(new DrawerItem(-4, R.drawable.baseline_settings_applications_24, R.string.menu_setup));
|
items.add(new DrawerItem(-3, R.drawable.baseline_reply_24, R.string.menu_answers));
|
||||||
items.add(new DrawerItem(-5));
|
|
||||||
items.add(new DrawerItem(-6, R.drawable.baseline_help_24, R.string.menu_legend));
|
String operations;
|
||||||
|
if (pending == 0)
|
||||||
|
operations = getString(R.string.menu_operations);
|
||||||
|
else
|
||||||
|
operations = getString(R.string.title_name_count,
|
||||||
|
getString(R.string.menu_operations),
|
||||||
|
nf.format(pending));
|
||||||
|
items.add(new DrawerItem(-4, R.string.menu_operations, R.drawable.baseline_list_24, operations, pending > 0));
|
||||||
|
|
||||||
|
items.add(new DrawerItem(-5, R.drawable.baseline_settings_applications_24, R.string.menu_setup));
|
||||||
|
items.add(new DrawerItem(-6));
|
||||||
|
items.add(new DrawerItem(-7, R.drawable.baseline_help_24, R.string.menu_legend));
|
||||||
|
|
||||||
if (Helper.getIntentFAQ().resolveActivity(getPackageManager()) != null)
|
if (Helper.getIntentFAQ().resolveActivity(getPackageManager()) != null)
|
||||||
items.add(new DrawerItem(-7, R.drawable.baseline_question_answer_24, R.string.menu_faq));
|
items.add(new DrawerItem(-8, R.drawable.baseline_question_answer_24, R.string.menu_faq));
|
||||||
|
|
||||||
if (BuildConfig.BETA_RELEASE)
|
if (BuildConfig.BETA_RELEASE)
|
||||||
items.add(new DrawerItem(-8, R.drawable.baseline_report_problem_24, R.string.menu_issue));
|
items.add(new DrawerItem(-9, R.drawable.baseline_report_problem_24, R.string.menu_issue));
|
||||||
|
|
||||||
if (Helper.getIntentPrivacy().resolveActivity(getPackageManager()) != null)
|
if (Helper.getIntentPrivacy().resolveActivity(getPackageManager()) != null)
|
||||||
items.add(new DrawerItem(-9, R.drawable.baseline_account_box_24, R.string.menu_privacy));
|
items.add(new DrawerItem(-10, R.drawable.baseline_account_box_24, R.string.menu_privacy));
|
||||||
|
|
||||||
items.add(new DrawerItem(-10, R.drawable.baseline_info_24, R.string.menu_about));
|
items.add(new DrawerItem(-11, R.drawable.baseline_info_24, R.string.menu_about));
|
||||||
|
|
||||||
boolean pro = (getIntentPro() == null || getIntentPro().resolveActivity(getPackageManager()) != null);
|
boolean pro = (getIntentPro() == null || getIntentPro().resolveActivity(getPackageManager()) != null);
|
||||||
boolean invite = (getIntentInvite().resolveActivity(getPackageManager()) != null);
|
boolean invite = (getIntentInvite().resolveActivity(getPackageManager()) != null);
|
||||||
|
@ -358,19 +372,19 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
boolean other = (getIntentOtherApps().resolveActivity(getPackageManager()) != null);
|
boolean other = (getIntentOtherApps().resolveActivity(getPackageManager()) != null);
|
||||||
|
|
||||||
if (pro || invite || rate || other)
|
if (pro || invite || rate || other)
|
||||||
items.add(new DrawerItem(-11));
|
items.add(new DrawerItem(-12));
|
||||||
|
|
||||||
if (pro)
|
if (pro)
|
||||||
items.add(new DrawerItem(-12, R.drawable.baseline_monetization_on_24, R.string.menu_pro));
|
items.add(new DrawerItem(-13, R.drawable.baseline_monetization_on_24, R.string.menu_pro));
|
||||||
|
|
||||||
if (invite)
|
if (invite)
|
||||||
items.add(new DrawerItem(-13, R.drawable.baseline_people_24, R.string.menu_invite));
|
items.add(new DrawerItem(-14, R.drawable.baseline_people_24, R.string.menu_invite));
|
||||||
|
|
||||||
if (rate)
|
if (rate)
|
||||||
items.add(new DrawerItem(-14, R.drawable.baseline_star_24, R.string.menu_rate));
|
items.add(new DrawerItem(-15, R.drawable.baseline_star_24, R.string.menu_rate));
|
||||||
|
|
||||||
if (other)
|
if (other)
|
||||||
items.add(new DrawerItem(-15, R.drawable.baseline_get_app_24, R.string.menu_other));
|
items.add(new DrawerItem(-16, R.drawable.baseline_get_app_24, R.string.menu_other));
|
||||||
|
|
||||||
drawerArray.set(items);
|
drawerArray.set(items);
|
||||||
}
|
}
|
||||||
|
@ -844,6 +858,36 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
}.execute(this, args, "menu:inbox");
|
}.execute(this, args, "menu:inbox");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onMenuOutbox() {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
|
||||||
|
new SimpleTask<Long>() {
|
||||||
|
@Override
|
||||||
|
protected Long onExecute(Context context, Bundle args) {
|
||||||
|
DB db = DB.getInstance(context);
|
||||||
|
EntityFolder outbox = db.folder().getOutbox();
|
||||||
|
return (outbox == null ? -1 : outbox.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onExecuted(Bundle args, Long folder) {
|
||||||
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||||
|
getSupportFragmentManager().popBackStack("unified", 0);
|
||||||
|
|
||||||
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(ActivityView.this);
|
||||||
|
lbm.sendBroadcast(
|
||||||
|
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
|
||||||
|
.putExtra("account", -1)
|
||||||
|
.putExtra("folder", folder));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
|
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
|
||||||
|
}
|
||||||
|
}.execute(this, args, "menu:inbox");
|
||||||
|
}
|
||||||
|
|
||||||
private void onMenuAnswers() {
|
private void onMenuAnswers() {
|
||||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||||
getSupportFragmentManager().popBackStack("answers", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
getSupportFragmentManager().popBackStack("answers", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
|
|
|
@ -55,6 +55,13 @@ public interface DaoAccount {
|
||||||
" AND folder.type <> '" + EntityFolder.OUTBOX + "'" +
|
" AND folder.type <> '" + EntityFolder.OUTBOX + "'" +
|
||||||
" AND NOT ui_seen" +
|
" AND NOT ui_seen" +
|
||||||
" AND NOT ui_hide) AS unseen" +
|
" AND NOT ui_hide) AS unseen" +
|
||||||
|
", (SELECT COUNT(message.id)" +
|
||||||
|
" FROM message" +
|
||||||
|
" JOIN folder ON folder.id = message.folder" +
|
||||||
|
" WHERE message.account = account.id" +
|
||||||
|
" AND folder.type = '" + EntityFolder.OUTBOX + "'" +
|
||||||
|
" AND NOT ui_seen" +
|
||||||
|
" AND NOT ui_hide) AS unsent" +
|
||||||
" FROM account" +
|
" FROM account" +
|
||||||
" LEFT JOIN operation ON operation.account = account.id" +
|
" LEFT JOIN operation ON operation.account = account.id" +
|
||||||
" WHERE synchronize" +
|
" WHERE synchronize" +
|
||||||
|
|
|
@ -62,11 +62,8 @@ public interface DaoFolder {
|
||||||
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
|
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
|
||||||
" WHERE CASE WHEN :account IS NULL" +
|
" WHERE CASE WHEN :account IS NULL" +
|
||||||
" THEN folder.unified AND account.synchronize" +
|
" THEN folder.unified AND account.synchronize" +
|
||||||
" ELSE" +
|
" ELSE folder.account = :account AND account.synchronize" +
|
||||||
" (folder.account = :account" +
|
" AND CASE WHEN :parent IS NULL THEN folder.parent IS NULL ELSE folder.parent = :parent END" +
|
||||||
" AND account.synchronize" +
|
|
||||||
" AND CASE WHEN :parent IS NULL THEN folder.parent IS NULL ELSE folder.parent = :parent END)" +
|
|
||||||
" OR (folder.account IS NULL AND :parent IS NULL)" +
|
|
||||||
" END" +
|
" END" +
|
||||||
" GROUP BY folder.id")
|
" GROUP BY folder.id")
|
||||||
LiveData<List<TupleFolderEx>> liveFolders(Long account, Long parent);
|
LiveData<List<TupleFolderEx>> liveFolders(Long account, Long parent);
|
||||||
|
|
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
||||||
|
|
||||||
public class TupleAccountEx extends EntityAccount {
|
public class TupleAccountEx extends EntityAccount {
|
||||||
public int unseen;
|
public int unseen;
|
||||||
|
public int unsent;
|
||||||
public int operations;
|
public int operations;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,6 +30,7 @@ public class TupleAccountEx extends EntityAccount {
|
||||||
TupleAccountEx other = (TupleAccountEx) obj;
|
TupleAccountEx other = (TupleAccountEx) obj;
|
||||||
return (super.equals(obj) &&
|
return (super.equals(obj) &&
|
||||||
this.unseen == other.unseen &&
|
this.unseen == other.unseen &&
|
||||||
|
this.unsent == other.unsent &&
|
||||||
this.operations == other.operations);
|
this.operations == other.operations);
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue