mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Show changelog after app update
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user