mirror of https://github.com/M66B/FairEmail.git
Delete shortcuts, not
This commit is contained in:
parent
391f32f5b2
commit
295419b0be
|
@ -345,4 +345,24 @@ class Shortcuts {
|
|||
static void requestPinShortcut(Context context, ShortcutInfoCompat info) {
|
||||
ShortcutManagerCompat.requestPinShortcut(context.getApplicationContext(), info, null);
|
||||
}
|
||||
|
||||
static void cleanup(Context context) {
|
||||
if (!BuildConfig.DEBUG)
|
||||
return;
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
List<ShortcutInfoCompat> pinned =
|
||||
ShortcutManagerCompat.getShortcuts(context, ShortcutManagerCompat.FLAG_MATCH_PINNED);
|
||||
for (ShortcutInfoCompat shortcut : pinned) {
|
||||
String[] id = shortcut.getId().split(":");
|
||||
if (id.length == 2 && "message".equals(id[0])) {
|
||||
Intent intent = shortcut.getIntent();
|
||||
long account = intent.getLongExtra("account", -1L);
|
||||
String thread = intent.getStringExtra("thread");
|
||||
List<EntityMessage> messages = db.message().getMessagesByThread(account, thread, null, null);
|
||||
if (messages != null && messages.size() == 0)
|
||||
; // Delete the shortcut, if only this was possible ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,6 +374,8 @@ public class WorkerCleanup extends Worker {
|
|||
|
||||
DB.createEmergencyBackup(context);
|
||||
|
||||
Shortcuts.cleanup(context);
|
||||
|
||||
if (manual) {
|
||||
// https://www.sqlite.org/lang_vacuum.html
|
||||
long size = context.getDatabasePath(db.getOpenHelper().getDatabaseName()).length();
|
||||
|
|
Loading…
Reference in New Issue