Fixed last activity edge cases

This commit is contained in:
M66B
2022-06-25 08:53:12 +02:00
parent a5d804d91f
commit c473dab127
2 changed files with 18 additions and 3 deletions

View File

@@ -174,11 +174,23 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
@Override
protected Boolean onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String last_activity = prefs.getString("last_activity", null);
long composing = prefs.getLong("last_composing", -1L);
if (ActivityCompose.class.getName().equals(last_activity) && composing >= 0) {
EntityMessage draft = db.message().getMessage(composing);
if (draft == null || draft.ui_hide)
prefs.edit()
.remove("last_activity")
.remove("last_composing")
.apply();
}
if (prefs.getBoolean("has_accounts", false))
return true;
DB db = DB.getInstance(context);
List<EntityAccount> accounts = db.account().getSynchronizingAccounts(null);
boolean hasAccounts = (accounts != null && accounts.size() > 0);