From f9a466a9d93543869deecaca08f6ee09597a4703 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 24 Nov 2016 20:27:08 +0100 Subject: when swiping don't clean startup counter entirely. just don't count last startup --- .../java/de/pixart/messenger/persistance/DatabaseBackend.java | 11 ++++++++--- .../de/pixart/messenger/services/XmppConnectionService.java | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/main/java/de/pixart') diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java index 25fb2aeef..ed0f14cd9 100644 --- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java @@ -1326,9 +1326,14 @@ public class DatabaseBackend extends SQLiteOpenHelper { return count >= Config.FREQUENT_RESTARTS_THRESHOLD; } - public void clearStartTimeCounter() { - Log.d(Config.LOGTAG, "resetting start time counter"); + public void clearStartTimeCounter(boolean justOne) { SQLiteDatabase db = this.getWritableDatabase(); - db.execSQL("delete from " + START_TIMES_TABLE); + if (justOne) { + db.execSQL("delete from "+START_TIMES_TABLE+" where timestamp in (select timestamp from "+START_TIMES_TABLE+" order by timestamp desc limit 1)"); + Log.d(Config.LOGTAG,"do not count start up after being swiped away"); + } else { + Log.d(Config.LOGTAG,"resetting start time counter"); + db.execSQL("delete from " + START_TIMES_TABLE); + } } } diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index bde16df00..92588e239 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1130,7 +1130,7 @@ public class XmppConnectionService extends Service { private void logoutAndSave(boolean stop) { int activeAccounts = 0; - databaseBackend.clearStartTimeCounter(); // regular swipes don't count towards restart counter + databaseBackend.clearStartTimeCounter(true); // regular swipes don't count towards restart counter for (final Account account : accounts) { if (account.getStatus() != Account.State.DISABLED) { activeAccounts++; @@ -3765,7 +3765,7 @@ public class XmppConnectionService extends Service { mDatabaseExecutor.execute(new Runnable() { @Override public void run() { - databaseBackend.clearStartTimeCounter(); + databaseBackend.clearStartTimeCounter(false); } }); } -- cgit v1.2.3