#1063 - Add "About QKSMS" section in settings

This commit is contained in:
Moez Bhatti
2018-04-20 04:19:43 -04:00
parent 7b0524dbc2
commit 510a9d23b5
13 changed files with 293 additions and 10 deletions
@@ -72,6 +72,7 @@
android:excludeFromRecents="true"
android:taskAffinity=""
android:theme="@style/AppThemeLightDialog" />
<activity android:name="feature.settings.about.AboutActivity" />
<receiver android:name="receiver.DefaultSmsChangedReceiver">
<intent-filter>
@@ -46,6 +46,8 @@ import feature.plus.PlusViewModel
import feature.qkreply.QkReplyViewModel
import feature.settings.SettingsActivity
import feature.settings.SettingsViewModel
import feature.settings.about.AboutActivity
import feature.settings.about.AboutViewModel
import feature.setup.SetupActivity
import feature.setup.SetupViewModel
import feature.themepicker.ThemePickerActivity
@@ -134,6 +136,31 @@ class Navigator @Inject constructor(private val context: Context, private val no
startActivity(intent)
}
fun showAbout() {
val intent = Intent(context, AboutActivity::class.java)
startActivity(intent)
}
fun showDeveloper() {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/moezbhatti"))
startActivity(intent)
}
fun showSourceCode() {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/moezbhatti/qksms"))
startActivity(intent)
}
fun showChangelog() {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/moezbhatti/qksms/releases"))
startActivity(intent)
}
fun showLicense() {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/moezbhatti/qksms/blob/master/LICENSE"))
startActivity(intent)
}
fun showBlockedConversations() {
val intent = Intent(context, BlockedActivity::class.java)
startActivity(intent)
@@ -205,6 +232,7 @@ class Navigator @Inject constructor(private val context: Context, private val no
MainViewModel::class.java -> MainViewModel()
PlusViewModel::class.java -> PlusViewModel()
SetupViewModel::class.java -> SetupViewModel()
AboutViewModel::class.java -> AboutViewModel()
ComposeViewModel::class.java -> ComposeViewModel(intent)
ConversationInfoViewModel::class.java -> ConversationInfoViewModel(intent)
GalleryViewModel::class.java -> GalleryViewModel(intent)
@@ -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()
}
}
}
}
@@ -49,6 +49,8 @@ import feature.qkreply.QkReplyActivity
import feature.qkreply.QkReplyViewModel
import feature.settings.SettingsActivity
import feature.settings.SettingsViewModel
import feature.settings.about.AboutActivity
import feature.settings.about.AboutViewModel
import feature.setup.SetupActivity
import feature.setup.SetupViewModel
import feature.themepicker.ThemePickerActivity
@@ -77,6 +79,7 @@ interface AppComponent {
fun inject(activity: MainActivity)
fun inject(activity: SetupActivity)
fun inject(activity: AboutActivity)
fun inject(activity: BlockedActivity)
fun inject(activity: ComposeActivity)
fun inject(activity: ConversationInfoActivity)
@@ -119,6 +122,7 @@ interface AppComponent {
fun inject(viewModel: MainViewModel)
fun inject(viewModel: SetupViewModel)
fun inject(viewModel: AboutViewModel)
fun inject(viewModel: BlockedViewModel)
fun inject(viewModel: ComposeViewModel)
fun inject(viewModel: ConversationInfoViewModel)
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z"/>
</vector>
@@ -0,0 +1,119 @@
<?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/>.
-->
<android.support.constraint.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="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="@style/Toolbar"
app:layout_constraintTop_toTopOf="parent"
tools:background="@color/white">
<common.widget.QkTextView
android:id="@+id/toolbarTitle"
style="@style/ToolbarText"
tools:text="@string/about_title" />
</android.support.v7.widget.Toolbar>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar">
<LinearLayout
android:id="@+id/preferences"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingTop="8dp">
<common.widget.PreferenceView
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/about_version_title"
tools:summary="3.0.8" />
<common.widget.PreferenceView
android:id="@+id/developer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:summary="@string/about_developer"
app:title="@string/about_developer_title" />
<common.widget.PreferenceView
android:id="@+id/source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:summary="@string/about_source"
app:title="@string/about_source_title" />
<common.widget.PreferenceView
android:id="@+id/changelog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:summary="@string/about_changelog"
app:title="@string/about_changelog_title" />
<common.widget.PreferenceView
android:id="@+id/contact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:summary="@string/about_contact"
app:title="@string/about_contact_title" />
<common.widget.PreferenceView
android:id="@+id/license"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:summary="@string/about_license"
app:title="@string/about_license_title" />
<common.widget.PreferenceView
android:id="@+id/copyright"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:summary="@string/about_copyright"
app:title="@string/about_copyright_title" />
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="@drawable/ab_shadow"
app:layout_constraintTop_toBottomOf="@id/toolbar" />
<common.widget.Separator
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout>
@@ -194,16 +194,13 @@
app:summary="@string/settings_sync_summary"
app:title="@string/settings_sync_title" />
<common.widget.QkTextView
android:id="@+id/version"
android:layout_width="wrap_content"
<common.widget.PreferenceView
android:id="@+id/about"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:layout_marginTop="24dp"
app:textColor="tertiary"
app:textSize="secondary"
tools:text="Version 3.0.0" />
app:icon="@drawable/ic_info_outline_black_24dp"
app:title="@string/settings_about_title"
tools:summary="Version 3.0.7" />
</LinearLayout>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="about_developer">Moez Bhatti</string>
<string name="about_source">https://github.com/moezbhatti/qksms</string>
<string name="about_changelog">https://github.com/moezbhatti/qksms/releases</string>
<string name="about_contact">team@qklabs.com</string>
<string name="about_license">GNU General Public License v3.0</string>
<string name="about_copyright">© 2014–2018</string>
</resources>
@@ -123,6 +123,7 @@
<string name="settings_mms_size_title">Max MMS attachment size</string>
<string name="settings_sync_title">Sync messages</string>
<string name="settings_sync_summary">Re-sync your messages with the native Android SMS database</string>
<string name="settings_about_title">About QKSMS</string>
<string name="settings_version">Version %s</string>
<string name="blocked_title">Blocking</string>
@@ -130,6 +131,15 @@
<string name="blocked_unblock_dialog_title">Unblock</string>
<string name="blocked_unblock_dialog_message">Would you like to unblock this conversation?</string>
<string name="about_title">About</string>
<string name="about_version_title">Version</string>
<string name="about_developer_title">Developer</string>
<string name="about_source_title">Source code</string>
<string name="about_changelog_title">Changelog</string>
<string name="about_contact_title">Contact</string>
<string name="about_license_title">License</string>
<string name="about_copyright_title">Copyright</string>
<string name="qksms_plus_description_title">Support development, unlock everything</string>
<string name="qksms_plus_description_summary">You can save a starving developer for just %s</string>
<string name="qksms_plus_upgrade">Lifetime upgrade for %1$s %2$s</string>