mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
#1063 - Add "About QKSMS" section in settings
This commit is contained in:
@@ -80,7 +80,7 @@ class SettingsActivity : QkThemedActivity<SettingsViewModel>(), SettingsView {
|
||||
textSizeDialog.adapter.setData(R.array.text_sizes)
|
||||
mmsSizeDialog.adapter.setData(R.array.mms_sizes, R.array.mms_sizes_ids)
|
||||
|
||||
version.text = getString(R.string.settings_version, BuildConfig.VERSION_NAME)
|
||||
about.summary = getString(R.string.settings_version, BuildConfig.VERSION_NAME)
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
|
||||
@@ -156,6 +156,8 @@ class SettingsViewModel : QkViewModel<SettingsView, SettingsState>(SettingsState
|
||||
newState { it.copy(syncing = false) }
|
||||
})
|
||||
}
|
||||
|
||||
R.id.about -> navigator.showAbout()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package feature.settings.about
|
||||
|
||||
import android.os.Bundle
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.BuildConfig
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.base.QkThemedActivity
|
||||
import common.widget.PreferenceView
|
||||
import injection.appComponent
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.about_activity.*
|
||||
|
||||
class AboutActivity : QkThemedActivity<AboutViewModel>(), AboutView {
|
||||
|
||||
override val viewModelClass = AboutViewModel::class
|
||||
override val preferenceClickIntent: Subject<PreferenceView> = PublishSubject.create()
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.about_activity)
|
||||
setTitle(R.string.about_title)
|
||||
showBackButton(true)
|
||||
viewModel.bindView(this)
|
||||
|
||||
version.summary = BuildConfig.VERSION_NAME
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
// Listen to clicks for all of the preferences
|
||||
(0 until preferences.childCount)
|
||||
.map { index -> preferences.getChildAt(index) }
|
||||
.mapNotNull { view -> view as? PreferenceView }
|
||||
.forEach { preference ->
|
||||
preference.clicks().map { preference }.subscribe(preferenceClickIntent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(state: Unit) {
|
||||
// No special rendering required
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package feature.settings.about
|
||||
|
||||
import common.base.QkView
|
||||
import common.widget.PreferenceView
|
||||
import io.reactivex.subjects.Subject
|
||||
|
||||
interface AboutView : QkView<Unit> {
|
||||
|
||||
val preferenceClickIntent: Subject<PreferenceView>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package feature.settings.about
|
||||
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.Navigator
|
||||
import common.base.QkViewModel
|
||||
import injection.appComponent
|
||||
import javax.inject.Inject
|
||||
|
||||
class AboutViewModel : QkViewModel<AboutView, Unit>(Unit) {
|
||||
|
||||
@Inject lateinit var navigator: Navigator
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
||||
override fun bindView(view: AboutView) {
|
||||
super.bindView(view)
|
||||
|
||||
view.preferenceClickIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { preference ->
|
||||
when(preference.id) {
|
||||
R.id.developer -> navigator.showDeveloper()
|
||||
|
||||
R.id.source -> navigator.showSourceCode()
|
||||
|
||||
R.id.changelog -> navigator.showChangelog()
|
||||
|
||||
R.id.contact -> navigator.showSupport()
|
||||
|
||||
R.id.license -> navigator.showLicense()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user