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())
@@ -0,0 +1,28 @@
/*
* 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
interface ChangelogManager {
/**
* Returns true if the app has benn updated since the last time this method was called
*/
fun didUpdate(): Boolean
}
@@ -52,6 +52,7 @@ class TextViewStyler @Inject constructor(
const val SIZE_SECONDARY = 1
const val SIZE_TERTIARY = 2
const val SIZE_TOOLBAR = 3
const val SIZE_DIALOG = 4
fun applyEditModeAttributes(textView: TextView, attrs: AttributeSet?) {
textView.run {
@@ -89,6 +90,7 @@ class TextViewStyler @Inject constructor(
SIZE_SECONDARY -> 14f
SIZE_TERTIARY -> 12f
SIZE_TOOLBAR -> 20f
SIZE_DIALOG -> 18f
else -> textSize / paint.density
}
}
@@ -177,6 +179,14 @@ class TextViewStyler @Inject constructor(
Preferences.TEXT_SIZE_LARGER -> 26f
else -> 20f
}
SIZE_DIALOG -> textView.textSize = when (textSizePref) {
Preferences.TEXT_SIZE_SMALL -> 16f
Preferences.TEXT_SIZE_NORMAL -> 18f
Preferences.TEXT_SIZE_LARGE -> 20f
Preferences.TEXT_SIZE_LARGER -> 24f
else -> 18f
}
}
}
@@ -0,0 +1,54 @@
/*
* 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.feature.changelog
import android.graphics.Typeface
import android.view.LayoutInflater
import android.view.ViewGroup
import com.moez.QKSMS.R
import com.moez.QKSMS.common.base.QkAdapter
import com.moez.QKSMS.common.base.QkViewHolder
import kotlinx.android.synthetic.main.changelog_list_item.*
class ChangelogAdapter(val keywords: List<String>, data: List<String>) : QkAdapter<String>() {
init {
this.data = data
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.changelog_list_item, parent, false)
return QkViewHolder(view).apply {
if (viewType == 0) {
changelogItem.setTypeface(changelogItem.typeface, Typeface.BOLD)
}
}
}
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
val item = getItem(position)
holder.changelogItem.text = item
}
override fun getItemViewType(position: Int): Int {
return if (getItem(position) in keywords) 0 else 1
}
}
@@ -0,0 +1,55 @@
/*
* 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.feature.changelog
import android.view.LayoutInflater
import androidx.appcompat.app.AlertDialog
import com.moez.QKSMS.BuildConfig
import com.moez.QKSMS.R
import com.moez.QKSMS.feature.main.MainActivity
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
import kotlinx.android.synthetic.main.changelog_dialog.view.*
class ChangelogDialog(activity: MainActivity) {
val moreClicks: Subject<Unit> = PublishSubject.create()
private val dialog: AlertDialog
private val adapter = ChangelogAdapter(
activity.resources.getStringArray(R.array.changelog_keywords).asList(),
activity.resources.getStringArray(R.array.changelog).asList())
init {
val layout = LayoutInflater.from(activity).inflate(R.layout.changelog_dialog, null)
dialog = AlertDialog.Builder(activity)
.setCancelable(true)
.setView(layout)
.create()
layout.version.text = activity.getString(R.string.changelog_version, BuildConfig.VERSION_NAME)
layout.changelog.adapter = adapter
layout.more.setOnClickListener { dialog.dismiss(); moreClicks.onNext(Unit) }
layout.dismiss.setOnClickListener { dialog.dismiss() }
}
fun show() = dialog.show()
}
@@ -52,6 +52,7 @@ import com.moez.QKSMS.common.util.extensions.scrapViews
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
import com.moez.QKSMS.common.util.extensions.setTint
import com.moez.QKSMS.common.util.extensions.setVisible
import com.moez.QKSMS.feature.changelog.ChangelogDialog
import com.moez.QKSMS.feature.conversations.ConversationItemTouchCallback
import com.moez.QKSMS.feature.conversations.ConversationsAdapter
import com.moez.QKSMS.repository.SyncRepository
@@ -105,6 +106,7 @@ class MainActivity : QkThemedActivity(), MainView {
override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges }
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
override val swipeConversationIntent by lazy { itemTouchCallback.swipes }
override val changelogMoreIntent by lazy { changelog.moreClicks }
override val undoArchiveIntent: Subject<Unit> = PublishSubject.create()
override val snackbarButtonIntent: Subject<Unit> = PublishSubject.create()
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
@@ -113,6 +115,7 @@ class MainActivity : QkThemedActivity(), MainView {
private val toggle by lazy { ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.main_drawer_open_cd, 0) }
private val itemTouchHelper by lazy { ItemTouchHelper(itemTouchCallback) }
private val progressAnimator by lazy { ObjectAnimator.ofInt(syncingProgress, "progress", 0, 0) }
private val changelog by lazy { ChangelogDialog(this) }
private val archiveSnackbar by lazy {
Snackbar.make(drawerLayout, R.string.toast_archived, Snackbar.LENGTH_LONG).apply {
setAction(R.string.button_undo) { undoArchiveIntent.onNext(Unit) }
@@ -344,6 +347,10 @@ class MainActivity : QkThemedActivity(), MainView {
.show()
}
override fun showChangelog() {
changelog.show()
}
override fun showArchivedSnackbar() {
archiveSnackbar.show()
}
@@ -36,6 +36,7 @@ interface MainView : QkView<MainState> {
val conversationsSelectedIntent: Observable<List<Long>>
val confirmDeleteIntent: Observable<List<Long>>
val swipeConversationIntent: Observable<Pair<Long, Int>>
val changelogMoreIntent: Observable<*>
val undoArchiveIntent: Observable<Unit>
val snackbarButtonIntent: Observable<Unit>
val backPressedIntent: Observable<Unit>
@@ -44,6 +45,7 @@ interface MainView : QkView<MainState> {
fun clearSearch()
fun clearSelection()
fun showDeleteDialog(conversations: List<Long>)
fun showChangelog()
fun showArchivedSnackbar()
}
@@ -36,6 +36,7 @@ import com.moez.QKSMS.interactor.MarkUnpinned
import com.moez.QKSMS.interactor.MarkUnread
import com.moez.QKSMS.interactor.MigratePreferences
import com.moez.QKSMS.interactor.SyncMessages
import com.moez.QKSMS.manager.ChangelogManager
import com.moez.QKSMS.manager.PermissionManager
import com.moez.QKSMS.manager.RatingManager
import com.moez.QKSMS.model.SyncLog
@@ -57,6 +58,7 @@ class MainViewModel @Inject constructor(
markAllSeen: MarkAllSeen,
migratePreferences: MigratePreferences,
syncRepository: SyncRepository,
private val changelogManager: ChangelogManager,
private val conversationRepo: ConversationRepository,
private val deleteConversations: DeleteConversations,
private val markArchived: MarkArchived,
@@ -141,6 +143,15 @@ class MainViewModel @Inject constructor(
.autoDisposable(view.scope())
.subscribe { syncMessages.execute(Unit) }
// Show changelog
if (changelogManager.didUpdate()) {
view.showChangelog()
}
view.changelogMoreIntent
.autoDisposable(view.scope())
.subscribe { navigator.showChangelog() }
view.queryChangedIntent
.debounce(200, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
@@ -1,3 +1,4 @@
/*
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
*
@@ -37,6 +38,8 @@ import com.moez.QKSMS.manager.AlarmManager
import com.moez.QKSMS.manager.AlarmManagerImpl
import com.moez.QKSMS.manager.AnalyticsManager
import com.moez.QKSMS.manager.AnalyticsManagerImpl
import com.moez.QKSMS.manager.ChangelogManager
import com.moez.QKSMS.manager.ChangelogManagerImpl
import com.moez.QKSMS.manager.ExternalBlockingManager
import com.moez.QKSMS.manager.ExternalBlockingManagerImpl
import com.moez.QKSMS.manager.KeyManager
@@ -125,6 +128,9 @@ class AppModule(private var application: Application) {
@Provides
fun externalBlockingManager(manager: ExternalBlockingManagerImpl): ExternalBlockingManager = manager
@Provides
fun changelogManager(manager: ChangelogManagerImpl): ChangelogManager = manager
@Provides
fun provideKeyManager(manager: KeyManagerImpl): KeyManager = manager
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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/>.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:text="@string/changelog_title"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/version"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="1"
app:textColor="primary"
app:textSize="dialog" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/version"
style="@style/TextSecondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
app:layout_constraintBottom_toTopOf="@id/changelog"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintVertical_weight="1"
tools:text="Version 3.6.5" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/changelog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@id/dismiss"
app:layout_constraintTop_toBottomOf="@id/version"
app:layout_constraintVertical_weight="0"
tools:listitem="@layout/changelog_list_item" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/more"
style="@style/TextSecondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?attr/selectableItemBackground"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp"
android:text="@string/changelog_more"
android:textAllCaps="true"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/dismiss"
app:layout_constraintTop_toBottomOf="@id/changelog"
app:layout_constraintVertical_weight="1" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/dismiss"
style="@style/TextSecondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="?attr/selectableItemBackground"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp"
android:text="@string/changelog_dismiss"
android:textAllCaps="true"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/changelog"
app:layout_constraintVertical_weight="1"
app:layout_goneMarginEnd="8dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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/>.
-->
<com.moez.QKSMS.common.widget.QkTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/changelogItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="4dp"
app:textColor="primary"
app:textSize="secondary"
tools:text="- Changelog item" />
@@ -34,6 +34,7 @@
<enum name="secondary" value="1" />
<enum name="tertiary" value="2" />
<enum name="toolbar" value="3" />
<enum name="dialog" value="4" />
</attr>
<declare-styleable name="QkTextView">
@@ -30,4 +30,34 @@
<string name="about_license">GNU General Public License v3.0</string>
<string name="about_copyright">© 2014–2018</string>
</resources>
<string name="changelog_title">New in QKSMS</string>
<string name="changelog_version">Version %s</string>
<string-array name="changelog_keywords">
<item>Added</item>
<item>Improved</item>
<item>Fixed</item>
</string-array>
<string-array name="changelog">
<item>Added</item>
<item>- Support for latest version of Should I Answer</item>
<item>- New swipe action to mark a conversation unread</item>
<item>- Updates will now show a changelog!</item>
<item></item>
<item>Improved</item>
<item>- Added unread indicator to make those conversations easier to spot</item>
<item>- Better support for sharing text from other apps</item>
<item>- Should I Answer integration will respect numbers that you have manually blocked</item>
<item>- Status bar for dark theme will match toolbar</item>
<item>- Make sure to ask to be default SMS app before attempting to perform actions that require it</item>
<item>- Features on QKSMS+ page will now link to their respective parts of the app</item>
<item>- Long list of names for group chat will be shortened</item>
<item></item>
<item>Fixed</item>
<item>- Messages sometimes get stuck "Sending…"</item>
<item>- QK Reply window glitches when it\'s too big</item>
<item>- Crash in compose screen when a contact has no numbers</item>
</string-array>
<string name="changelog_more">More</string>
<string name="changelog_dismiss">Dismiss</string>
</resources>