Show changelog after app update

This commit is contained in:
moezbhatti
2019-06-17 02:17:30 -04:00
parent 74268a2c96
commit 274b217a56
14 changed files with 394 additions and 1 deletions
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.moez.QKSMS.manager
import android.content.Context
import com.moez.QKSMS.model.SyncLog
import com.moez.QKSMS.util.Preferences
import io.realm.Realm
import javax.inject.Inject
class ChangelogManagerImpl @Inject constructor(
private val context: Context,
private val prefs: Preferences
) : ChangelogManager {
override fun didUpdate(): Boolean {
val oldVersion = prefs.version.get()
val newVersion = context.packageManager.getPackageInfo(context.packageName, 0).versionCode
val lastSync = Realm.getDefaultInstance().use { realm -> realm.where(SyncLog::class.java)?.max("date") ?: 0 }
if (oldVersion != newVersion) {
prefs.version.set(newVersion)
}
return when {
oldVersion == 0 && lastSync != 0 -> true // Just updated to 3.6.5. TODO: Remove this after 3.6.5
oldVersion == 0 -> false // First install
oldVersion != newVersion -> true // Update
else -> false
}
}
}
@@ -87,6 +87,7 @@ class Preferences @Inject constructor(private val rxPrefs: RxSharedPreferences)
val mobileOnly = rxPrefs.getBoolean("mobileOnly", false)
val mmsSize = rxPrefs.getInteger("mmsSize", 300)
val logging = rxPrefs.getBoolean("logging", false)
val version = rxPrefs.getInteger("version", 0)
fun theme(threadId: Long = 0): Preference<Int> {
val default = rxPrefs.getInteger("theme", 0xFF0097A7.toInt())