Show number of pending operations in navigation menu

pull/153/head
M66B 6 years ago
parent c4961ce7d2
commit d4e8f8dc59

File diff suppressed because it is too large Load Diff

@ -211,34 +211,34 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
PackageManager pm = getPackageManager();
if (getIntentExport().resolveActivity(pm) != null)
items.add(new DrawerItem(-1, R.string.title_setup_export, R.drawable.baseline_archive_24));
items.add(new DrawerItem(-1, R.drawable.baseline_archive_24, R.string.title_setup_export));
if (getIntentImport().resolveActivity(pm) != null)
items.add(new DrawerItem(-2, R.string.title_setup_import, R.drawable.baseline_unarchive_24));
items.add(new DrawerItem(-2, R.drawable.baseline_unarchive_24, R.string.title_setup_import));
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String theme = prefs.getString("theme", "system");
if ("light".equals(theme))
items.add(new DrawerItem(-3, R.string.title_setup_dark_theme, R.drawable.baseline_palette_24));
items.add(new DrawerItem(-3, R.drawable.baseline_palette_24, R.string.title_setup_dark_theme));
else if ("dark".equals(theme))
items.add(new DrawerItem(-4, R.string.title_setup_black_theme, R.drawable.baseline_palette_24));
items.add(new DrawerItem(-4, R.drawable.baseline_palette_24, R.string.title_setup_black_theme));
else if ("black".equals(theme))
items.add(new DrawerItem(-5, R.string.title_setup_system_theme, R.drawable.baseline_palette_24));
items.add(new DrawerItem(-5, R.drawable.baseline_palette_24, R.string.title_setup_system_theme));
else
items.add(new DrawerItem(-6, R.string.title_setup_light_theme, R.drawable.baseline_palette_24));
items.add(new DrawerItem(-6, R.drawable.baseline_palette_24, R.string.title_setup_light_theme));
if (getIntentNotifications(this).resolveActivity(pm) != null)
items.add(new DrawerItem(-7, R.string.title_setup_notifications, R.drawable.baseline_notifications_24));
items.add(new DrawerItem(-7, R.drawable.baseline_notifications_24, R.string.title_setup_notifications));
items.add(new DrawerItem(-8, R.string.title_setup_advanced, R.drawable.baseline_settings_applications_24));
items.add(new DrawerItem(-8, R.drawable.baseline_settings_applications_24, R.string.title_setup_advanced));
items.add(new DrawerItem(-9));
items.add(new DrawerItem(-10, R.string.menu_legend, R.drawable.baseline_help_24));
items.add(new DrawerItem(-10, R.drawable.baseline_help_24, R.string.menu_legend));
if (Helper.getIntentFAQ().resolveActivity(getPackageManager()) != null)
items.add(new DrawerItem(-11, R.string.menu_faq, R.drawable.baseline_question_answer_24));
items.add(new DrawerItem(-11, R.drawable.baseline_question_answer_24, R.string.menu_faq));
if (Helper.getIntentPrivacy().resolveActivity(getPackageManager()) != null)
items.add(new DrawerItem(-12, R.string.menu_privacy, R.drawable.baseline_account_box_24));
items.add(new DrawerItem(-13, R.string.menu_about, R.drawable.baseline_info_24));
items.add(new DrawerItem(-12, R.drawable.baseline_account_box_24, R.string.menu_privacy));
items.add(new DrawerItem(-13, R.drawable.baseline_info_24, R.string.menu_about));
drawerArray.set(items);

@ -300,7 +300,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
!Objects.equals(account.name, other.name) ||
!Objects.equals(account.color, other.color) ||
!Objects.equals(account.state, other.state) ||
account.unseen != other.unseen) {
account.unseen != other.unseen ||
account.operations != other.operations) {
changed = true;
break;
}
@ -314,6 +315,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
List<DrawerItem> items = new ArrayList<>();
int operations = 0;
for (TupleAccountEx account : accounts) {
String title;
if (account.unseen > 0)
@ -324,26 +326,36 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
"connected".equals(account.state)
? account.primary ? R.drawable.baseline_folder_special_24 : R.drawable.baseline_folder_24
: R.drawable.baseline_folder_open_24,
account.color, title, account.unseen > 0));
title, account.color, account.unseen > 0));
operations += account.operations;
}
items.add(new DrawerItem(-1));
items.add(new DrawerItem(-2, R.string.menu_answers, R.drawable.baseline_reply_24));
items.add(new DrawerItem(-3, R.string.menu_operations, R.drawable.baseline_list_24));
items.add(new DrawerItem(-4, R.string.menu_setup, R.drawable.baseline_settings_applications_24));
items.add(new DrawerItem(-2, R.drawable.baseline_reply_24, R.string.menu_answers));
String title;
if (operations == 0)
title = getString(R.string.menu_operations);
else
title = getString(R.string.title_name_count,
getString(R.string.menu_operations),
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(-5));
items.add(new DrawerItem(-6, R.string.menu_legend, R.drawable.baseline_help_24));
items.add(new DrawerItem(-6, R.drawable.baseline_help_24, R.string.menu_legend));
if (Helper.getIntentFAQ().resolveActivity(getPackageManager()) != null)
items.add(new DrawerItem(-7, R.string.menu_faq, R.drawable.baseline_question_answer_24));
items.add(new DrawerItem(-7, R.drawable.baseline_question_answer_24, R.string.menu_faq));
if (BuildConfig.BETA_RELEASE)
items.add(new DrawerItem(-8, R.string.menu_issue, R.drawable.baseline_report_problem_24));
items.add(new DrawerItem(-8, R.drawable.baseline_report_problem_24, R.string.menu_issue));
if (Helper.getIntentPrivacy().resolveActivity(getPackageManager()) != null)
items.add(new DrawerItem(-9, R.string.menu_privacy, R.drawable.baseline_account_box_24));
items.add(new DrawerItem(-9, R.drawable.baseline_account_box_24, R.string.menu_privacy));
items.add(new DrawerItem(-10, R.string.menu_about, R.drawable.baseline_info_24));
items.add(new DrawerItem(-10, R.drawable.baseline_info_24, R.string.menu_about));
boolean pro = (getIntentPro() == null || getIntentPro().resolveActivity(getPackageManager()) != null);
boolean invite = (getIntentInvite().resolveActivity(getPackageManager()) != null);
@ -354,16 +366,16 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
items.add(new DrawerItem(-11));
if (pro)
items.add(new DrawerItem(-12, R.string.menu_pro, R.drawable.baseline_monetization_on_24));
items.add(new DrawerItem(-12, R.drawable.baseline_monetization_on_24, R.string.menu_pro));
if (invite)
items.add(new DrawerItem(-13, R.string.menu_invite, R.drawable.baseline_people_24));
items.add(new DrawerItem(-13, R.drawable.baseline_people_24, R.string.menu_invite));
if (rate)
items.add(new DrawerItem(-14, R.string.menu_rate, R.drawable.baseline_star_24));
items.add(new DrawerItem(-14, R.drawable.baseline_star_24, R.string.menu_rate));
if (other)
items.add(new DrawerItem(-15, R.string.menu_other, R.drawable.baseline_get_app_24));
items.add(new DrawerItem(-15, R.drawable.baseline_get_app_24, R.string.menu_other));
drawerArray.set(items);
}

@ -49,7 +49,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 52,
version = 53,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -560,6 +560,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `folder` ADD COLUMN `total` INTEGER");
}
})
.addMigrations(new Migration(52, 53) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `operation` ADD COLUMN `account` INTEGER");
}
})
.build();
}

@ -44,7 +44,7 @@ public interface DaoAccount {
@Query("SELECT * FROM account WHERE synchronize")
LiveData<List<EntityAccount>> liveSynchronizingAccounts();
@Query("SELECT *" +
@Query("SELECT account.*, COUNT(operation.id) AS operations" +
", (SELECT COUNT(message.id)" +
" FROM message" +
" JOIN folder ON folder.id = message.folder" +
@ -56,7 +56,9 @@ public interface DaoAccount {
" AND NOT ui_seen" +
" AND NOT ui_hide) AS unseen" +
" FROM account" +
" WHERE synchronize")
" LEFT JOIN operation ON operation.account = account.id" +
" WHERE synchronize" +
" GROUP BY account.id")
LiveData<List<TupleAccountEx>> liveAccountsEx();
@Query("SELECT * FROM account WHERE id = :id")

@ -17,7 +17,7 @@ public class DrawerItem {
this.layout = R.layout.item_drawer_separator;
}
DrawerItem(long id, int resid, int icon) {
DrawerItem(long id, int icon, int resid) {
this.id = id;
this.menu = resid;
this.layout = R.layout.item_drawer;
@ -25,7 +25,16 @@ public class DrawerItem {
this.resid = resid;
}
DrawerItem(long id, int icon, Integer color, String title, boolean highlight) {
DrawerItem(long id, int menu, int icon, String title, boolean highlight) {
this.id = id;
this.menu = menu;
this.layout = R.layout.item_drawer;
this.icon = icon;
this.title = title;
this.highlight = highlight;
}
DrawerItem(long id, int icon, String title, Integer color, boolean highlight) {
this.id = id;
this.layout = R.layout.item_drawer;
this.icon = icon;

@ -56,6 +56,7 @@ public class EntityOperation {
@PrimaryKey(autoGenerate = true)
public Long id;
public Long account; // performance
@NonNull
public Long folder;
public Long message;
@ -201,6 +202,7 @@ public class EntityOperation {
}
EntityOperation operation = new EntityOperation();
operation.account = message.account;
operation.folder = folder;
operation.message = message.id;
operation.name = name;
@ -228,6 +230,7 @@ public class EntityOperation {
if (db.operation().getOperationCount(fid, EntityOperation.SYNC) == 0) {
EntityOperation operation = new EntityOperation();
operation.account = folder.account;
operation.folder = folder.id;
operation.message = null;
operation.name = SYNC;

@ -21,13 +21,15 @@ package eu.faircode.email;
public class TupleAccountEx extends EntityAccount {
public int unseen;
public int operations;
@Override
public boolean equals(Object obj) {
if (obj instanceof TupleAccountEx) {
TupleAccountEx other = (TupleAccountEx) obj;
return (super.equals(obj) &&
this.unseen == other.unseen);
this.unseen == other.unseen &&
this.operations == other.operations);
} else
return false;
}

Loading…
Cancel
Save