Squashed commit of the following:

commit 1f890b96beb893c866ed9b47d8e3a9ac6e20662f
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Wed Jan 31 17:41:22 2018 -0500

    Clean up bindView in PlusViewModel

commit c71f4853d385df66a79f9372ecf29507cb64152b
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Wed Jan 31 02:14:37 2018 -0500

    Move QKSMS+ to sliding menu

commit a23d1dd6d314935cd96c530e3419a3a2ca4cab27
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Wed Jan 31 00:28:42 2018 -0500

    Make selected plan more visible

commit 540cda206ede1d3b81d7d42438257f76f9f07cd4
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Wed Jan 31 00:27:03 2018 -0500

    Allow changing dynamic textcolor programatically

commit 859325dd5ffa7aa5958ae2eb5c9eac62bcb8f7bd
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 22:26:41 2018 -0500

    Dark mode support for ripple selected state

commit 6a1d5c387fe0a08ef05573f3f07a1cd82b1a37ec
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 22:18:27 2018 -0500

    Remove explicit upgrade button, click plan to buy

commit 4a6e85b0c513c8604f8993f78add2b3910c0b49d
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 20:43:09 2018 -0500

    Show thank you UI if user has upgraded

commit 080fccf40b4461b6a833ba77fce1267bd8251281
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 17:52:02 2018 -0500

    Allow changing plans

commit ac122f138b1840de39f7a7bd1fb36727056233e1
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 16:33:59 2018 -0500

    Allow purchase of subscription

commit 3e689443ec197a929308d9add270ae6777cdeae1
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 23:21:31 2018 -0500

    Allow selection of different plans

commit d51a90160898b39de5ba4e69fdc8351e2fe7093c
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 19:42:56 2018 -0500

    Collapsing toolbar for QKSMS+ activity

commit 06c0d5a834884f144ad7e149b7dea3b0ba38b643
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 18:02:05 2018 -0500

    Display pricing information in QKSMS+ activity

commit c0be51eec5e1b091dbe8ba69f28c48e5379011f3
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 17:26:16 2018 -0500

    Add ability to view QKSMS+ activity from settings

commit 51e7782a274503401d53a22ccbe55eab2523f200
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 15:41:40 2018 -0500

    Indicate currently selected theme

commit 0b3bb3e24b3c40ac517cf05404638061f9b520b8
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 15:19:28 2018 -0500

    Move ThemeAdapter package

commit 828b6fe10afd6493884ee8d1c472dcd39f5371d4
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 15:10:14 2018 -0500

    Evenly space theme swatches with other items and borders

commit 220499c0676f03c282b201dfd67faa10f20a546d
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 14:45:47 2018 -0500

    Evenly distribute theme swatches

commit 4d0995da773f720411b22091fc58d03497d38438
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 22:53:49 2018 -0500

    Use separate activity for Theme picker

commit 3886c1890a6320667f9999071213f181e4e2de79
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 20:00:17 2018 -0500

    Update more text

commit 3e3995fdf58ee849f6fedabd895aff42f521e473
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 19:56:04 2018 -0500

    Update text for blocking

commit b8ffbf30761105abe1150279994c8d0ebd7a68b7
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 19:49:11 2018 -0500

    Build layout for QKSMS+ activity

commit 90518ad8291d5028ceb765ca60fe1d36a5edb33a
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 19:48:59 2018 -0500

    Improve layout preview support for some custom views

commit 3b301b641e1b747d0ac7192bb50e51d494fe6ef8
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 02:22:54 2018 -0500

    Use up-to-date material design colors

commit e8c9cec67767c8702f1b6ccf7ee89c22e585132c
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 01:21:24 2018 -0500

    Add strings and icons for QKSMS+ features
This commit is contained in:
Moez Bhatti
2018-01-31 21:20:29 -05:00
parent 218b611ae3
commit 317940d4f7
40 changed files with 1443 additions and 172 deletions
@@ -0,0 +1,27 @@
<!--
~ 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/>.
-->
<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="M12,8V4l8,8 -8,8v-4H4V8z"/>
</vector>
+2
View File
@@ -60,6 +60,8 @@
</activity>
<activity android:name="presentation.feature.settings.SettingsActivity" />
<activity android:name="presentation.feature.setup.SetupActivity" />
<activity android:name="presentation.feature.themepicker.ThemePickerActivity" />
<activity android:name="presentation.feature.plus.PlusActivity" />
<receiver android:name="presentation.receiver.DefaultSmsChangedReceiver">
<intent-filter>
@@ -27,10 +27,14 @@ import presentation.feature.compose.ComposeViewModel
import presentation.feature.compose.DetailedChipView
import presentation.feature.main.MainActivity
import presentation.feature.main.MainViewModel
import presentation.feature.plus.PlusActivity
import presentation.feature.plus.PlusViewModel
import presentation.feature.settings.SettingsActivity
import presentation.feature.settings.SettingsViewModel
import presentation.feature.setup.SetupActivity
import presentation.feature.setup.SetupViewModel
import presentation.feature.themepicker.ThemePickerActivity
import presentation.feature.themepicker.ThemePickerViewModel
import presentation.receiver.*
import javax.inject.Singleton
@@ -43,7 +47,9 @@ interface AppComponent {
fun inject(activity: MainActivity)
fun inject(activity: SetupActivity)
fun inject(activity: ComposeActivity)
fun inject(activity: PlusActivity)
fun inject(activity: SettingsActivity)
fun inject(activity: ThemePickerActivity)
fun inject(receiver: DefaultSmsChangedReceiver)
fun inject(receiver: SmsReceiver)
@@ -67,7 +73,9 @@ interface AppComponent {
fun inject(viewModel: MainViewModel)
fun inject(viewModel: SetupViewModel)
fun inject(viewModel: ComposeViewModel)
fun inject(viewModel: PlusViewModel)
fun inject(viewModel: SettingsViewModel)
fun inject(viewModel: ThemePickerViewModel)
fun inject(fetcher: ContactImageLoader.ContactImageFetcher)
@@ -30,13 +30,21 @@ import javax.inject.Inject
class BillingManager @Inject constructor(context: Context) : PurchasesUpdatedListener {
val purchases: Observable<List<Purchase>> = BehaviorSubject.create()
val iabs: Observable<List<SkuDetails>> = BehaviorSubject.create()
val subs: Observable<List<SkuDetails>> = BehaviorSubject.create()
enum class UpgradeStatus { REGULAR, LEGACY, SUPPORTER, DONOR, PHILANTHROPIST }
private val iabSkus = listOf("remove_ads")
private val subSkus = listOf("qksms_plus_3", "qksms_plus_5", "qksms_plus_10")
companion object {
const val SKU_LEGACY = "remove_ads"
const val SKU_3 = "qksms_plus_3"
const val SKU_5 = "qksms_plus_5"
const val SKU_10 = "qksms_plus_10"
}
val subscriptions: Observable<List<SkuDetails>> = BehaviorSubject.create()
val plusStatus: Observable<UpgradeStatus>
private val subSkus = listOf(SKU_3, SKU_5, SKU_10)
private val purchaseList = mutableListOf<Purchase>()
private val purchaseListObservable: Observable<List<Purchase>> = BehaviorSubject.create()
private val billingClient: BillingClient = BillingClient.newBuilder(context).setListener(this).build()
private var isServiceConnected = false
@@ -46,6 +54,17 @@ class BillingManager @Inject constructor(context: Context) : PurchasesUpdatedLis
queryPurchases()
querySkuDetailsAsync()
}
plusStatus = purchaseListObservable
.map { purchases ->
when {
purchases.any { it.sku == SKU_10 } -> UpgradeStatus.PHILANTHROPIST
purchases.any { it.sku == SKU_5 } -> UpgradeStatus.DONOR
purchases.any { it.sku == SKU_3 } -> UpgradeStatus.SUPPORTER
purchases.any { it.sku == SKU_LEGACY } -> UpgradeStatus.LEGACY
else -> UpgradeStatus.PHILANTHROPIST
}
}
}
private fun queryPurchases() {
@@ -62,7 +81,7 @@ class BillingManager @Inject constructor(context: Context) : PurchasesUpdatedLis
// Handle purchase result
purchaseList.clear()
purchaseList.addAll(purchasesResult.purchasesList)
(this.purchases as Subject).onNext(purchaseList)
(this.purchaseListObservable as Subject).onNext(purchaseList)
}
}
@@ -84,25 +103,22 @@ class BillingManager @Inject constructor(context: Context) : PurchasesUpdatedLis
private fun querySkuDetailsAsync() {
executeServiceRequest {
val iabParams = SkuDetailsParams.newBuilder().setSkusList(iabSkus).setType(BillingClient.SkuType.INAPP)
billingClient.querySkuDetailsAsync(iabParams.build()) { responseCode, skuDetailsList ->
if (responseCode == BillingResponse.OK) {
(iabs as Subject).onNext(skuDetailsList)
}
}
val subParams = SkuDetailsParams.newBuilder().setSkusList(subSkus).setType(BillingClient.SkuType.SUBS)
billingClient.querySkuDetailsAsync(subParams.build()) { responseCode, skuDetailsList ->
if (responseCode == BillingResponse.OK) {
(subs as Subject).onNext(skuDetailsList)
(subscriptions as Subject).onNext(skuDetailsList)
}
}
}
}
fun initiatePurchaseFlow(activity: Activity) {
fun initiatePurchaseFlow(activity: Activity, sku: String) {
executeServiceRequest {
val params = BillingFlowParams.newBuilder().setSku("qksms_plus_3").setType(SkuType.SUBS)
val oldSkus = purchaseList
.filter { product -> subSkus.contains(product.sku) }
.map { product -> product.sku }
val params = BillingFlowParams.newBuilder().setSku(sku).setType(SkuType.SUBS).setOldSkus(ArrayList(oldSkus))
billingClient.launchBillingFlow(activity, params.build())
}
}
@@ -117,8 +133,9 @@ class BillingManager @Inject constructor(context: Context) : PurchasesUpdatedLis
override fun onPurchasesUpdated(resultCode: Int, purchases: List<Purchase>?) {
when (resultCode) {
BillingResponse.OK -> {
purchases?.forEach { purchaseList.add(it) }
(this.purchases as Subject).onNext(purchaseList)
purchaseList.clear()
purchases?.let { purchaseList.addAll(it) }
(this.purchaseListObservable as Subject).onNext(purchaseList)
}
else -> {
+27 -7
View File
@@ -32,9 +32,29 @@ import javax.inject.Singleton
@Singleton
class Colors @Inject constructor(private val context: Context, prefs: Preferences) {
companion object {
private const val MINIMUM_CONTRAST_RATIO = 2
}
val materialColors = listOf(
listOf(0xffffebee, 0xffffcdd2, 0xffef9a9a, 0xffe57373, 0xffef5350, 0xfff44336, 0xffe53935, 0xffd32f2f, 0xffc62828, 0xffb71c1c),
listOf(0xffFCE4EC, 0xffF8BBD0, 0xffF48FB1, 0xffF06292, 0xffEC407A, 0xffE91E63, 0xffD81B60, 0xffC2185B, 0xffAD1457, 0xff880E4F),
listOf(0xffF3E5F5, 0xffE1BEE7, 0xffCE93D8, 0xffBA68C8, 0xffAB47BC, 0xff9C27B0, 0xff8E24AA, 0xff7B1FA2, 0xff6A1B9A, 0xff4A148C),
listOf(0xffEDE7F6, 0xffD1C4E9, 0xffB39DDB, 0xff9575CD, 0xff7E57C2, 0xff673AB7, 0xff5E35B1, 0xff512DA8, 0xff4527A0, 0xff311B92),
listOf(0xffE8EAF6, 0xffC5CAE9, 0xff9FA8DA, 0xff7986CB, 0xff5C6BC0, 0xff3F51B5, 0xff3949AB, 0xff303F9F, 0xff283593, 0xff1A237E),
listOf(0xffE3F2FD, 0xffBBDEFB, 0xff90CAF9, 0xff64B5F6, 0xff42A5F5, 0xff2196F3, 0xff1E88E5, 0xff1976D2, 0xff1565C0, 0xff0D47A1),
listOf(0xffE1F5FE, 0xffB3E5FC, 0xff81D4FA, 0xff4FC3F7, 0xff29B6F6, 0xff03A9F4, 0xff039BE5, 0xff0288D1, 0xff0277BD, 0xff01579B),
listOf(0xffE0F7FA, 0xffB2EBF2, 0xff80DEEA, 0xff4DD0E1, 0xff26C6DA, 0xff00BCD4, 0xff00ACC1, 0xff0097A7, 0xff00838F, 0xff006064),
listOf(0xffE0F2F1, 0xffB2DFDB, 0xff80CBC4, 0xff4DB6AC, 0xff26A69A, 0xff009688, 0xff00897B, 0xff00796B, 0xff00695C, 0xff004D40),
listOf(0xffE8F5E9, 0xffC8E6C9, 0xffA5D6A7, 0xff81C784, 0xff66BB6A, 0xff4CAF50, 0xff43A047, 0xff388E3C, 0xff2E7D32, 0xff1B5E20),
listOf(0xffF1F8E9, 0xffDCEDC8, 0xffC5E1A5, 0xffAED581, 0xff9CCC65, 0xff8BC34A, 0xff7CB342, 0xff689F38, 0xff558B2F, 0xff33691E),
listOf(0xffF9FBE7, 0xffF0F4C3, 0xffE6EE9C, 0xffDCE775, 0xffD4E157, 0xffCDDC39, 0xffC0CA33, 0xffAFB42B, 0xff9E9D24, 0xff827717),
listOf(0xffFFFDE7, 0xffFFF9C4, 0xffFFF59D, 0xffFFF176, 0xffFFEE58, 0xffFFEB3B, 0xffFDD835, 0xffFBC02D, 0xffF9A825, 0xffF57F17),
listOf(0xffFFF8E1, 0xffFFECB3, 0xffFFE082, 0xffFFD54F, 0xffFFCA28, 0xffFFC107, 0xffFFB300, 0xffFFA000, 0xffFF8F00, 0xffFF6F00),
listOf(0xffFFF3E0, 0xffFFE0B2, 0xffFFCC80, 0xffFFB74D, 0xffFFA726, 0xffFF9800, 0xffFB8C00, 0xffF57C00, 0xffEF6C00, 0xffE65100),
listOf(0xffFBE9E7, 0xffFFCCBC, 0xffFFAB91, 0xffFF8A65, 0xffFF7043, 0xffFF5722, 0xffF4511E, 0xffE64A19, 0xffD84315, 0xffBF360C),
listOf(0xffEFEBE9, 0xffD7CCC8, 0xffBCAAA4, 0xffA1887F, 0xff8D6E63, 0xff795548, 0xff6D4C41, 0xff5D4037, 0xff4E342E, 0xff3E2723),
listOf(0xffFAFAFA, 0xffF5F5F5, 0xffEEEEEE, 0xffE0E0E0, 0xffBDBDBD, 0xff9E9E9E, 0xff757575, 0xff616161, 0xff424242, 0xff212121),
listOf(0xffECEFF1, 0xffCFD8DC, 0xffB0BEC5, 0xff90A4AE, 0xff78909C, 0xff607D8B, 0xff546E7A, 0xff455A64, 0xff37474F, 0xff263238))
.map { it.map { it.toInt() } }
private val minimumContrastRatio = 2
// Cache these values so they don't need to be recalculated
private val primaryTextLuminance = measureLuminance(getColor(R.color.textPrimaryDark))
@@ -104,7 +124,7 @@ class Colors @Inject constructor(private val context: Context, prefs: Preference
val textPrimaryOnTheme: Observable<Int> = prefs.theme.asObservable()
.map { theme -> measureLuminance(theme) }
.map { themeLuminance -> primaryTextLuminance / themeLuminance }
.map { contrastRatio -> contrastRatio < MINIMUM_CONTRAST_RATIO }
.map { contrastRatio -> contrastRatio < minimumContrastRatio }
.map { contrastRatio -> if (contrastRatio) R.color.textPrimary else R.color.textPrimaryDark }
.map { res -> getColor(res) }
.distinctUntilChanged()
@@ -112,7 +132,7 @@ class Colors @Inject constructor(private val context: Context, prefs: Preference
val textSecondaryOnTheme: Observable<Int> = prefs.theme.asObservable()
.map { theme -> measureLuminance(theme) }
.map { themeLuminance -> secondaryTextLuminance / themeLuminance }
.map { contrastRatio -> contrastRatio < MINIMUM_CONTRAST_RATIO }
.map { contrastRatio -> contrastRatio < minimumContrastRatio }
.map { contrastRatio -> if (contrastRatio) R.color.textSecondary else R.color.textSecondaryDark }
.map { res -> getColor(res) }
.distinctUntilChanged()
@@ -120,7 +140,7 @@ class Colors @Inject constructor(private val context: Context, prefs: Preference
val textTertiaryOnTheme: Observable<Int> = prefs.theme.asObservable()
.map { theme -> measureLuminance(theme) }
.map { themeLuminance -> tertiaryTextLuminance / themeLuminance }
.map { contrastRatio -> contrastRatio < MINIMUM_CONTRAST_RATIO }
.map { contrastRatio -> contrastRatio < minimumContrastRatio }
.map { contrastRatio -> if (contrastRatio) R.color.textTertiary else R.color.textTertiaryDark }
.map { res -> getColor(res) }
.distinctUntilChanged()
@@ -155,7 +175,7 @@ class Colors @Inject constructor(private val context: Context, prefs: Preference
}
/**
* Measures the luminance value of a color to be able to measure the contrast ratio between two colors
* Measures the luminance value of a color to be able to measure the contrast ratio between two materialColors
* Based on https://stackoverflow.com/a/9733420
*/
private fun measureLuminance(color: Int): Double {
@@ -32,14 +32,17 @@ import common.util.NotificationManager
import presentation.feature.compose.ComposeActivity
import presentation.feature.compose.ComposeViewModel
import presentation.feature.main.MainViewModel
import presentation.feature.plus.PlusActivity
import presentation.feature.plus.PlusViewModel
import presentation.feature.settings.SettingsActivity
import presentation.feature.settings.SettingsViewModel
import presentation.feature.setup.SetupActivity
import presentation.feature.setup.SetupViewModel
import presentation.feature.themepicker.ThemePickerActivity
import presentation.feature.themepicker.ThemePickerViewModel
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class Navigator @Inject constructor(val context: Context) {
@@ -53,6 +56,11 @@ class Navigator @Inject constructor(val context: Context) {
startActivity(intent)
}
fun showQksmsPlusActivity() {
val intent = Intent(context, PlusActivity::class.java)
startActivity(intent)
}
fun showDefaultSmsDialog() {
val intent = Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT)
if (Telephony.Sms.getDefaultSmsPackage(context) != context.packageName) {
@@ -78,6 +86,11 @@ class Navigator @Inject constructor(val context: Context) {
startActivity(intent)
}
fun showThemePicker() {
val intent = Intent(context, ThemePickerActivity::class.java)
startActivity(intent)
}
fun makePhoneCall(address: String) {
val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$address"))
startActivity(intent)
@@ -110,9 +123,11 @@ class Navigator @Inject constructor(val context: Context) {
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return when (modelClass) {
MainViewModel::class.java -> MainViewModel()
PlusViewModel::class.java -> PlusViewModel()
SetupViewModel::class.java -> SetupViewModel()
ComposeViewModel::class.java -> ComposeViewModel(intent)
SettingsViewModel::class.java -> SettingsViewModel()
ThemePickerViewModel::class.java -> ThemePickerViewModel()
else -> throw IllegalArgumentException("Invalid ViewModel class. If this is a new ViewModel, please add it to Navigator.kt")
} as T
}
@@ -22,11 +22,13 @@ import android.content.Context
import android.support.v7.widget.LinearLayoutCompat
import android.util.AttributeSet
import android.view.View
import android.widget.TextView
import com.moez.QKSMS.R
import com.uber.autodispose.android.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import common.util.Colors
import common.util.extensions.getColorCompat
import common.util.extensions.setTint
import common.util.extensions.setVisible
import kotlinx.android.synthetic.main.preference_view.view.*
@@ -39,18 +41,34 @@ class PreferenceView @JvmOverloads constructor(context: Context, attrs: Attribut
var title: String? = null
set(value) {
field = value
titleView.text = value
if (isInEditMode) {
findViewById<TextView>(R.id.titleView).text = value
} else {
titleView.text = value
}
}
var summary: String? = null
set(value) {
field = value
summaryView.text = value
summaryView.setVisible(value?.isNotEmpty() == true)
if (isInEditMode) {
findViewById<TextView>(R.id.summaryView).run {
text = value
setVisible(value?.isNotEmpty() == true)
}
} else {
summaryView.text = value
summaryView.setVisible(value?.isNotEmpty() == true)
}
}
init {
appComponent.inject(this)
if (!isInEditMode) {
appComponent.inject(this)
}
View.inflate(context, R.layout.preference_view, this)
setBackgroundResource(R.drawable.ripple)
@@ -77,9 +95,14 @@ class PreferenceView @JvmOverloads constructor(context: Context, attrs: Attribut
override fun onAttachedToWindow() {
super.onAttachedToWindow()
colors.textSecondary
.autoDisposable(scope())
.subscribe { icon.setTint(it) }
if (isInEditMode) {
icon.setTint(context.getColorCompat(R.color.textSecondary))
} else {
colors.textSecondary
.autoDisposable(scope())
.subscribe { icon.setTint(it) }
}
}
}
@@ -22,46 +22,101 @@ import android.content.Context
import android.support.v7.widget.AppCompatTextView
import android.util.AttributeSet
import com.moez.QKSMS.R
import com.uber.autodispose.android.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import common.util.Colors
import common.util.extensions.getColorCompat
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import javax.inject.Inject
open class QkTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null)
: AppCompatTextView(context, attrs) {
companion object {
const val COLOR_PRIMARY = 0
const val COLOR_SECONDARY = 1
const val COLOR_TERTIARY = 2
const val COLOR_PRIMARY_ON_THEME = 3
const val COLOR_SECONDARY_ON_THEME = 4
const val COLOR_TERTIARY_ON_THEME = 5
}
@Inject lateinit var colors: Colors
private var textColorDisposable: Disposable? = null
private var textColorObservable: Observable<Int>? = null
set(value) {
if (field !== value) {
field = value
if (isAttachedToWindow) {
textColorDisposable?.let { disposable ->
if (!disposable.isDisposed) {
disposable.dispose()
}
}
subscribeColorChanges()
}
}
}
init {
appComponent.inject(this)
if (!isInEditMode) {
appComponent.inject(this)
}
context.obtainStyledAttributes(attrs, R.styleable.QkTextView)?.run {
textColorObservable = when (getInt(R.styleable.QkTextView_textColor, -1)) {
0 -> colors.textPrimary
1 -> colors.textSecondary
2 -> colors.textTertiary
3 -> colors.textPrimaryOnTheme
4 -> colors.textSecondaryOnTheme
5 -> colors.textTertiaryOnTheme
else -> null
val colorAttr = getInt(R.styleable.QkTextView_textColor, -1)
if (isInEditMode) {
setTextColor(context.getColorCompat(when (colorAttr) {
COLOR_PRIMARY -> R.color.textPrimary
COLOR_SECONDARY -> R.color.textSecondary
COLOR_TERTIARY -> R.color.textTertiary
COLOR_PRIMARY_ON_THEME -> R.color.textPrimaryDark
COLOR_SECONDARY_ON_THEME -> R.color.textSecondaryDark
COLOR_TERTIARY_ON_THEME -> R.color.textTertiaryDark
else -> R.color.textPrimary
}))
} else {
setColor(colorAttr)
}
recycle()
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
textColorObservable
?.autoDisposable(scope())
fun setColor(colorAttr: Int) {
textColorObservable = when (colorAttr) {
COLOR_PRIMARY -> colors.textPrimary
COLOR_SECONDARY -> colors.textSecondary
COLOR_TERTIARY -> colors.textTertiary
COLOR_PRIMARY_ON_THEME -> colors.textPrimaryOnTheme
COLOR_SECONDARY_ON_THEME -> colors.textSecondaryOnTheme
COLOR_TERTIARY_ON_THEME -> colors.textTertiaryOnTheme
else -> null
}
}
private fun subscribeColorChanges() {
textColorDisposable = textColorObservable
?.subscribe { color ->
setTextColor(color)
setLinkTextColor(color)
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
if (textColorDisposable?.isDisposed != false) {
subscribeColorChanges()
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
textColorDisposable?.dispose()
}
}
@@ -21,10 +21,12 @@ package presentation.common.widget
import android.content.Context
import android.util.AttributeSet
import android.view.View
import com.moez.QKSMS.R
import com.uber.autodispose.android.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import common.util.Colors
import common.util.extensions.getColorCompat
import javax.inject.Inject
class Separator @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : View(context, attrs) {
@@ -32,14 +34,20 @@ class Separator @JvmOverloads constructor(context: Context, attrs: AttributeSet?
@Inject lateinit var colors: Colors
init {
appComponent.inject(this)
if (!isInEditMode) {
appComponent.inject(this)
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
colors.separator
.autoDisposable(scope())
.subscribe { color -> setBackgroundColor(color) }
if (isInEditMode) {
setBackgroundColor(context.getColorCompat(R.color.separatorLight))
} else {
colors.separator
.autoDisposable(scope())
.subscribe { color -> setBackgroundColor(color) }
}
}
}
@@ -74,6 +74,7 @@ class MainActivity : QkActivity<MainViewModel>(), MainView {
scheduled.clicks().map { DrawerItem.SCHEDULED },
blocked.clicks().map { DrawerItem.BLOCKED },
settings.clicks().map { DrawerItem.SETTINGS },
plus.clicks().map { DrawerItem.PLUS },
help.clicks().map { DrawerItem.HELP }))
}
override val conversationClickIntent by lazy { conversationsAdapter.clicks }
@@ -159,6 +160,7 @@ class MainActivity : QkActivity<MainViewModel>(), MainView {
.doOnNext { tintList -> scheduledIcon.imageTintList = tintList }
.doOnNext { tintList -> blockedIcon.imageTintList = tintList }
.doOnNext { tintList -> settingsIcon.imageTintList = tintList }
.doOnNext { tintList -> plusIcon.imageTintList = tintList }
.doOnNext { tintList -> helpIcon.imageTintList = tintList }
.autoDisposable(scope())
.subscribe()
@@ -39,4 +39,4 @@ interface MainView : QkView<MainState> {
}
enum class DrawerItem { INBOX, ARCHIVED, SCHEDULED, BLOCKED, SETTINGS, HELP }
enum class DrawerItem { INBOX, ARCHIVED, SCHEDULED, BLOCKED, SETTINGS, PLUS, HELP }
@@ -27,7 +27,6 @@ import com.moez.QKSMS.R
import com.uber.autodispose.android.lifecycle.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import common.util.BillingManager
import common.util.extensions.toFlowable
import common.util.filter.ConversationFilter
import data.model.MenuItem
@@ -40,14 +39,12 @@ import io.reactivex.rxkotlin.withLatestFrom
import io.realm.Realm
import presentation.common.Navigator
import presentation.common.base.QkViewModel
import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Inject
class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
@Inject lateinit var context: Context
@Inject lateinit var billingManager: BillingManager
@Inject lateinit var navigator: Navigator
@Inject lateinit var conversationFilter: ConversationFilter
@Inject lateinit var messageRepo: MessageRepository
@@ -116,10 +113,6 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
}
markAllSeen.execute(Unit)
billingManager.purchases.subscribe { purchases -> Timber.v("Purchases: $purchases") }
billingManager.iabs.subscribe { iabs -> Timber.v("IABs: $iabs") }
billingManager.subs.subscribe { subs -> Timber.v("Subs: $subs") }
}
override fun bindView(view: MainView) {
@@ -157,6 +150,7 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
view.drawerItemIntent
.doOnNext { newState { it.copy(drawerOpen = false) } }
.doOnNext { if (it == DrawerItem.SETTINGS) navigator.showSettings() }
.doOnNext { if (it == DrawerItem.PLUS) navigator.showQksmsPlusActivity() }
.doOnNext { if (it == DrawerItem.HELP) navigator.showSupport() }
.distinctUntilChanged()
.doOnNext {
@@ -0,0 +1,114 @@
/*
* 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 presentation.feature.plus
import android.os.Bundle
import com.jakewharton.rxbinding2.view.clicks
import com.moez.QKSMS.R
import com.uber.autodispose.android.lifecycle.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import common.util.BillingManager
import common.util.extensions.setBackgroundTint
import common.util.extensions.setTint
import common.util.extensions.setVisible
import kotlinx.android.synthetic.main.qksms_plus_activity.*
import presentation.common.base.QkActivity
import presentation.common.widget.QkTextView
class PlusActivity : QkActivity<PlusViewModel>(), PlusView {
override val viewModelClass = PlusViewModel::class
override val supporterSelectedIntent by lazy { supporter.clicks() }
override val donorSelectedIntent by lazy { donor.clicks() }
override val philanthropistSelectedIntent by lazy { philanthropist.clicks() }
override fun onCreate(savedInstanceState: Bundle?) {
appComponent.inject(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.qksms_plus_activity)
setTitle(R.string.title_qksms_plus)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
viewModel.bindView(this)
colors.textPrimary
.autoDisposable(scope())
.subscribe { color ->
collapsingToolbar.setCollapsedTitleTextColor(color)
collapsingToolbar.setExpandedTitleColor(color)
}
colors.background
.autoDisposable(scope())
.subscribe { color -> window.decorView.setBackgroundColor(color) }
colors.separator
.autoDisposable(scope())
.subscribe { color -> thanks.setBackgroundTint(color) }
colors.theme
.autoDisposable(scope())
.subscribe { color ->
thanksIcon.setTint(color)
supporter.setBackgroundTint(color)
donor.setBackgroundTint(color)
philanthropist.setBackgroundTint(color)
}
}
override fun render(state: PlusState) {
description.text = getString(R.string.qksms_plus_description_summary, state.supporterPrice)
thanks.setVisible(state.currentPlan != BillingManager.UpgradeStatus.REGULAR)
val supportedSelected = state.currentPlan == BillingManager.UpgradeStatus.SUPPORTER
supporter.isSelected = supportedSelected
supporterPrice.text = state.supporterPrice
supporterName.setColor(getPrimaryTextColorAttr(supportedSelected))
supporterPrice.setColor(getPrimaryTextColorAttr(supportedSelected))
supporterPeriod.setColor(getSecondaryTextColorAttr(supportedSelected))
val donorSelected = state.currentPlan == BillingManager.UpgradeStatus.DONOR
donor.isSelected = donorSelected
donorPrice.text = state.donorPrice
donorName.setColor(getPrimaryTextColorAttr(donorSelected))
donorPrice.setColor(getPrimaryTextColorAttr(donorSelected))
donorPeriod.setColor(getSecondaryTextColorAttr(donorSelected))
val philanthropistSelected = state.currentPlan == BillingManager.UpgradeStatus.PHILANTHROPIST
philanthropist.isSelected = philanthropistSelected
philanthropistPrice.text = state.philanthropistPrice
philanthropistName.setColor(getPrimaryTextColorAttr(philanthropistSelected))
philanthropistPrice.setColor(getPrimaryTextColorAttr(philanthropistSelected))
philanthropistPeriod.setColor(getSecondaryTextColorAttr(philanthropistSelected))
}
private fun getPrimaryTextColorAttr(selected: Boolean): Int {
return if (selected) QkTextView.COLOR_PRIMARY_ON_THEME else QkTextView.COLOR_PRIMARY
}
private fun getSecondaryTextColorAttr(selected: Boolean): Int {
return if (selected) QkTextView.COLOR_SECONDARY_ON_THEME else QkTextView.COLOR_SECONDARY
}
override fun initiatePurchaseFlow(billingManager: BillingManager, sku: String) {
billingManager.initiatePurchaseFlow(this, sku)
}
}
@@ -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 presentation.feature.plus
import common.util.BillingManager
data class PlusState(
val currentPlan: BillingManager.UpgradeStatus = BillingManager.UpgradeStatus.REGULAR,
val supporterPrice: String = "",
val donorPrice: String = "",
val philanthropistPrice: String = ""
)
@@ -0,0 +1,33 @@
/*
* 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 presentation.feature.plus
import common.util.BillingManager
import io.reactivex.Observable
import presentation.common.base.QkView
interface PlusView : QkView<PlusState> {
val supporterSelectedIntent: Observable<Unit>
val donorSelectedIntent: Observable<Unit>
val philanthropistSelectedIntent: Observable<Unit>
fun initiatePurchaseFlow(billingManager: BillingManager, sku: String)
}
@@ -0,0 +1,64 @@
/*
* 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 presentation.feature.plus
import com.uber.autodispose.android.lifecycle.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import common.util.BillingManager
import io.reactivex.Observable
import io.reactivex.rxkotlin.plusAssign
import presentation.common.base.QkViewModel
import javax.inject.Inject
class PlusViewModel : QkViewModel<PlusView, PlusState>(PlusState()) {
@Inject lateinit var billingManager: BillingManager
init {
appComponent.inject(this)
disposables += billingManager.plusStatus
.subscribe { plan ->
newState { it.copy(currentPlan = plan) }
}
disposables += billingManager.subscriptions
.subscribe { subs ->
newState {
it.copy(
supporterPrice = subs.firstOrNull { it.sku == BillingManager.SKU_3 }?.price ?: "",
donorPrice = subs.firstOrNull { it.sku == BillingManager.SKU_5 }?.price ?: "",
philanthropistPrice = subs.firstOrNull { it.sku == BillingManager.SKU_10 }?.price ?: "")
}
}
}
override fun bindView(view: PlusView) {
super.bindView(view)
Observable.merge(
view.supporterSelectedIntent.map { BillingManager.SKU_3 },
view.donorSelectedIntent.map { BillingManager.SKU_5 },
view.philanthropistSelectedIntent.map { BillingManager.SKU_10 })
.autoDisposable(view.scope())
.subscribe { sku -> view.initiatePurchaseFlow(billingManager, sku) }
}
}
@@ -28,7 +28,6 @@ import android.os.Build
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import com.google.android.flexbox.FlexboxLayoutManager
import com.jakewharton.rxbinding2.view.clicks
import com.moez.QKSMS.R
import com.uber.autodispose.android.lifecycle.scope
@@ -37,7 +36,6 @@ import common.di.appComponent
import common.util.extensions.dpToPx
import common.util.extensions.setVisible
import data.model.MenuItem
import io.reactivex.Observable
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
import kotlinx.android.synthetic.main.settings_activity.*
@@ -53,7 +51,6 @@ class SettingsActivity : QkActivity<SettingsViewModel>(), SettingsView {
override val viewModelClass = SettingsViewModel::class
override val preferenceClickIntent: Subject<PreferenceView> = PublishSubject.create()
override val themeSelectedIntent: Observable<Int> by lazy { themeAdapter.colorSelected }
override val ringtoneSelectedIntent: Subject<String> = PublishSubject.create()
override val mmsSizeSelectedIntent: Subject<Int> by lazy { menuItemAdapter.menuItemClicks }
@@ -66,50 +63,6 @@ class SettingsActivity : QkActivity<SettingsViewModel>(), SettingsView {
}
}
private val themeDialog by lazy {
AlertDialog.Builder(this)
.setTitle(R.string.settings_dialog_theme_title)
.setView(themeRecyclerView)
.setCancelable(false)
.create()
}
private val themeRecyclerView by lazy {
RecyclerView(this).apply {
val padding = 8.dpToPx(context)
setPadding(padding, padding, padding, padding)
adapter = themeAdapter
clipToPadding = false
clipChildren = false
layoutManager = FlexboxLayoutManager(this@SettingsActivity)
}
}
private val themeAdapter by lazy {
ThemeAdapter(this@SettingsActivity).apply {
data = listOf(
-0x21f24, -0x64245, -0x96678, -0xc93a0, -0x17b1c0, -0x1ae3dd, -0x22e6e3, -0x2fe8ea, -0x3bebef, -0x4fedf6,
-0x31b14, -0x74430, -0xb704f, -0xf9d6e, -0x13bf86, -0x16e19d, -0x27e4a0, -0x3de7a5, -0x52eba9, -0x77f1b1,
-0xc1a0b, -0x1e4119, -0x316c28, -0x459738, -0x54b844, -0x63d850, -0x71db56, -0x84e05e, -0x95e466, -0xb5eb74,
-0x12180a, -0x2e3b17, -0x4c6225, -0x6a8a33, -0x81a83e, -0x98c549, -0xa1ca4f, -0xaed258, -0xbad860, -0xcee46e,
-0x17150a, -0x3a3517, -0x605726, -0x867935, -0xa39440, -0xc0ae4b, -0xc6b655, -0xcfc061, -0xd7ca6d, -0xe5dc82,
-0x181603, -0x2f2601, -0x504001, -0x6e5801, -0x8c7002, -0xa98804, -0xb19311, -0xbaa122, -0xc4af32, -0xd5c94f,
-0x1e0a02, -0x4c1a04, -0x7e2b06, -0xb03c09, -0xd6490a, -0xfc560c, -0xfc641b, -0xfd772f, -0xfd8843, -0xfea865,
-0x1f0806, -0x4d140e, -0x7f2116, -0xb22f1f, -0xd93926, -0xff432c, -0xff533f, -0xff6859, -0xff7c71, -0xff9f9c,
-0x1f0d0f, -0x4d2025, -0x7f343c, -0xb24954, -0xd95966, -0xff6978, -0xff7685, -0xff8695, -0xff96a4, -0xffb2c0,
-0x2f0732, -0x5c165c, -0x8d2a8e, -0xbd42bf, -0xd450d5, -0xda64dc, -0xf570f8, -0xf581f9, -0xfa9100, -0xf2acfe,
-0xe0717, -0x231238, -0x3a1e5b, -0x512a7f, -0x63339b, -0x743cb6, -0x834cbe, -0x9760c8, -0xaa74d1, -0xcc96e2,
-0x60419, -0xf0b3d, -0x191164, -0x23188b, -0x2b1ea9, -0x3223c7, -0x3f35cd, -0x504bd5, -0x6162dc, -0x7d88e9,
-0x219, -0x63c, -0xa63, -0xe8a, -0x11a8, -0x14c5, -0x227cb, -0x43fd3, -0x657db, -0xa80e9,
-0x71f, -0x134d, -0x1f7e, -0x2ab1, -0x35d8, -0x3ef9, -0x4d00, -0x6000, -0x7100, -0x9100,
-0xc20, -0x1f4e, -0x3380, -0x48b3, -0x58da, -0x6800, -0x47400, -0xa8400, -0x109400, -0x19af00,
-0x41619, -0x3344, -0x546f, -0x759b, -0x8fbd, -0xa8de, -0xbaee2, -0x19b5e7, -0x27bceb, -0x40c9f4,
-0x101417, -0x283338, -0x43555c, -0x5e7781, -0x72919d, -0x86aab8, -0x92b3bf, -0xa2bfc9, -0xb1cbd2,
-0x50506, -0xa0a0b, -0x111112, -0x1f1f20, -0x424243, -0x616162, -0x8a8a8b, -0x9e9e9f, -0xbdbdbe, -0xdededf, -0x1000000, -0x1,
-0x13100f, -0x13100f, -0x4f413b, -0x6f5b52, -0x876f64, -0x9f8275, -0xab9186, -0xbaa59c, -0xc8b8b1, -0xd9cdc8)
}
}
private val mmsSizeDialog by lazy {
menuItemAdapter.data = arrayListOf(
MenuItem(R.string.menu_mms_size_100kb, 100),
@@ -161,9 +114,6 @@ class SettingsActivity : QkActivity<SettingsViewModel>(), SettingsView {
}
override fun render(state: SettingsState) {
if (themeDialog.isShowing && !state.selectingTheme) themeDialog.dismiss()
else if (!themeDialog.isShowing && state.selectingTheme) themeDialog.show()
if (progressDialog.isShowing && !state.syncing) progressDialog.dismiss()
else if (!progressDialog.isShowing && state.syncing) progressDialog.show()
@@ -19,7 +19,6 @@
package presentation.feature.settings
data class SettingsState(
val selectingTheme: Boolean = false,
val syncing: Boolean = false,
val isDefaultSmsApp: Boolean = false,
@@ -27,7 +27,6 @@ import presentation.common.widget.PreferenceView
interface SettingsView : QkView<SettingsState> {
val preferenceClickIntent: Subject<PreferenceView>
val themeSelectedIntent: Observable<Int>
val ringtoneSelectedIntent: Observable<String>
val mmsSizeSelectedIntent: Observable<Int>
@@ -94,7 +94,7 @@ class SettingsViewModel : QkViewModel<SettingsView, SettingsState>(SettingsState
when (it.id) {
R.id.defaultSms -> navigator.showDefaultSmsDialog()
R.id.theme -> newState { it.copy(selectingTheme = true) }
R.id.theme -> navigator.showThemePicker()
R.id.dark -> prefs.dark.set(!prefs.dark.get())
@@ -125,13 +125,6 @@ class SettingsViewModel : QkViewModel<SettingsView, SettingsState>(SettingsState
}
}
view.themeSelectedIntent
.autoDisposable(view.scope())
.subscribe { color ->
prefs.theme.set(color)
newState { it.copy(selectingTheme = false) }
}
view.ringtoneSelectedIntent
.autoDisposable(view.scope())
.subscribe { ringtone -> prefs.ringtone.set(ringtone) }
@@ -1,50 +0,0 @@
/*
* 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 presentation.feature.settings
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import com.moez.QKSMS.R
import common.util.extensions.setBackgroundTint
import presentation.common.base.QkAdapter
import presentation.common.base.QkViewHolder
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
import kotlinx.android.synthetic.main.theme_list_item.view.*
class ThemeAdapter(private val context: Context) : QkAdapter<Int>() {
val colorSelected: Subject<Int> = PublishSubject.create()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
val view = LayoutInflater.from(context).inflate(R.layout.theme_list_item, parent, false)
return QkViewHolder(view)
}
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
val theme = getItem(position)
val view = holder.itemView
view.setOnClickListener { colorSelected.onNext(theme) }
view.theme.setBackgroundTint(theme)
}
}
@@ -0,0 +1,125 @@
/*
* 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 presentation.feature.themepicker
import android.content.Context
import android.content.res.Resources
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.ViewGroup
import com.google.android.flexbox.FlexDirection
import com.google.android.flexbox.FlexWrap
import com.google.android.flexbox.FlexboxLayout
import com.moez.QKSMS.R
import common.util.Colors
import common.util.extensions.dpToPx
import common.util.extensions.setBackgroundTint
import common.util.extensions.setTint
import common.util.extensions.setVisible
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
import kotlinx.android.synthetic.main.theme_list_item.view.*
import kotlinx.android.synthetic.main.theme_palette_list_item.view.*
import presentation.common.base.QkAdapter
import presentation.common.base.QkViewHolder
import javax.inject.Inject
class ThemeAdapter @Inject constructor(
private val context: Context,
private val colors: Colors
) : QkAdapter<List<Int>>() {
val colorSelected: Subject<Int> = PublishSubject.create()
var selectedColor: Int = -1
set(value) {
val oldPosition = data.indexOfFirst { it.contains(field) }
val newPosition = data.indexOfFirst { it.contains(value) }
field = value
oldPosition.takeIf { it != -1 }?.let { position -> notifyItemChanged(position) }
newPosition.takeIf { it != -1 }?.let { position -> notifyItemChanged(position) }
}
private var iconTint = 0
private val disposables = CompositeDisposable()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
val view = LayoutInflater.from(context).inflate(R.layout.theme_palette_list_item, parent, false)
view.palette.flexWrap = FlexWrap.WRAP
view.palette.flexDirection = FlexDirection.ROW
return QkViewHolder(view)
}
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
val palette = getItem(position)
val view = holder.itemView
val screenWidth = Resources.getSystem().displayMetrics.widthPixels
val minPadding = (16 * 6).dpToPx(context)
val size = if (screenWidth - minPadding > (56 * 5).dpToPx(context)) {
56.dpToPx(context)
} else {
(screenWidth - minPadding) / 5
}
val swatchPadding = (screenWidth - size * 5) / 12
view.palette.removeAllViews()
view.palette.setPadding(swatchPadding, swatchPadding, swatchPadding, swatchPadding)
(palette.subList(0, 5) + palette.subList(5, 10).reversed())
.mapIndexed { index, color ->
LayoutInflater.from(context).inflate(R.layout.theme_list_item, view.palette, false).apply {
// Send clicks to the selected subject
setOnClickListener { colorSelected.onNext(color) }
// Apply the color to the view
theme.setBackgroundTint(color)
// Control the check visibility and tint
check.setVisible(color == selectedColor)
check.setTint(iconTint)
// Update the size so that the spacing is perfectly even
layoutParams = (layoutParams as FlexboxLayout.LayoutParams).apply {
height = size
width = size
isWrapBefore = index % 5 == 0
setMargins(swatchPadding, swatchPadding, swatchPadding, swatchPadding)
}
}
}
.forEach { theme -> view.palette.addView(theme) }
}
override fun onAttachedToRecyclerView(recyclerView: RecyclerView?) {
disposables += colors.textPrimaryOnTheme
.subscribe { color -> iconTint = color }
}
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView?) {
disposables.clear()
}
}
@@ -0,0 +1,61 @@
/*
* 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 presentation.feature.themepicker
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import com.moez.QKSMS.R
import com.uber.autodispose.android.lifecycle.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import io.reactivex.Observable
import kotlinx.android.synthetic.main.theme_picker_activity.*
import presentation.common.base.QkActivity
import javax.inject.Inject
class ThemePickerActivity : QkActivity<ThemePickerViewModel>(), ThemePickerView {
override val viewModelClass = ThemePickerViewModel::class
override val themeSelectedIntent: Observable<Int> by lazy { themeAdapter.colorSelected }
@Inject lateinit var themeAdapter: ThemeAdapter
override fun onCreate(savedInstanceState: Bundle?) {
appComponent.inject(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.theme_picker_activity)
setTitle(R.string.title_theme)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
viewModel.bindView(this)
themeAdapter.data = colors.materialColors
materialColors.layoutManager = LinearLayoutManager(this)
materialColors.adapter = themeAdapter
colors.background
.autoDisposable(scope())
.subscribe { color -> window.decorView.setBackgroundColor(color) }
}
override fun render(state: ThemePickerState) {
themeAdapter.selectedColor = state.selectedColor
}
}
@@ -0,0 +1,25 @@
/*
* 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 presentation.feature.themepicker
data class ThemePickerState(
val selectedColor: Int = -1
)
@@ -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 presentation.feature.themepicker
import io.reactivex.Observable
import presentation.common.base.QkView
interface ThemePickerView : QkView<ThemePickerState> {
val themeSelectedIntent: Observable<Int>
}
@@ -0,0 +1,48 @@
/*
* 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 presentation.feature.themepicker
import com.uber.autodispose.android.lifecycle.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import common.util.Preferences
import io.reactivex.rxkotlin.plusAssign
import presentation.common.base.QkViewModel
import javax.inject.Inject
class ThemePickerViewModel : QkViewModel<ThemePickerView, ThemePickerState>(ThemePickerState()) {
@Inject lateinit var prefs: Preferences
init {
appComponent.inject(this)
disposables += prefs.theme.asObservable()
.subscribe { color -> newState { it.copy(selectedColor = color) } }
}
override fun bindView(view: ThemePickerView) {
super.bindView(view)
view.themeSelectedIntent
.autoDisposable(view.scope())
.subscribe { color -> prefs.theme.set(color) }
}
}
@@ -0,0 +1,27 @@
<!--
~ 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/>.
-->
<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,17c0,0.55 0.45,1 1,1s1,-0.45 1,-1 -0.45,-1 -1,-1 -1,0.45 -1,1zM11,3v4h2L13,5.08c3.39,0.49 6,3.39 6,6.92 0,3.87 -3.13,7 -7,7s-7,-3.13 -7,-7c0,-1.68 0.59,-3.22 1.58,-4.42L12,13l1.41,-1.41 -6.8,-6.8v0.02C4.42,6.45 3,9.05 3,12c0,4.97 4.02,9 9,9 4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9h-1zM18,12c0,-0.55 -0.45,-1 -1,-1s-1,0.45 -1,1 0.45,1 1,1 1,-0.45 1,-1zM6,12c0,0.55 0.45,1 1,1s1,-0.45 1,-1 -0.45,-1 -1,-1 -1,0.45 -1,1z"/>
</vector>
@@ -0,0 +1,27 @@
<!--
~ 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/>.
-->
<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="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM14,13v4h-4v-4H7l5,-5 5,5h-3z"/>
</vector>
@@ -0,0 +1,27 @@
<!--
~ 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/>.
-->
<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="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
</vector>
@@ -0,0 +1,27 @@
<!--
~ 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/>.
-->
<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="M17.66,7.93L12,2.27 6.34,7.93c-3.12,3.12 -3.12,8.19 0,11.31C7.9,20.8 9.95,21.58 12,21.58c2.05,0 4.1,-0.78 5.66,-2.34 3.12,-3.12 3.12,-8.19 0,-11.31zM12,19.59c-1.6,0 -3.11,-0.62 -4.24,-1.76C6.62,16.69 6,15.19 6,13.59s0.62,-3.11 1.76,-4.24L12,5.1v14.49z"/>
</vector>
@@ -0,0 +1,27 @@
<!--
~ 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/>.
-->
<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="M6,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
</vector>
@@ -0,0 +1,27 @@
<!--
~ 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/>.
-->
<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="M12,3c-4.97,0 -9,4.03 -9,9s4.03,9 9,9c0.83,0 1.5,-0.67 1.5,-1.5 0,-0.39 -0.15,-0.74 -0.39,-1.01 -0.23,-0.26 -0.38,-0.61 -0.38,-0.99 0,-0.83 0.67,-1.5 1.5,-1.5L16,16c2.76,0 5,-2.24 5,-5 0,-4.42 -4.03,-8 -9,-8zM6.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S5.67,9 6.5,9 8,9.67 8,10.5 7.33,12 6.5,12zM9.5,8C8.67,8 8,7.33 8,6.5S8.67,5 9.5,5s1.5,0.67 1.5,1.5S10.33,8 9.5,8zM14.5,8c-0.83,0 -1.5,-0.67 -1.5,-1.5S13.67,5 14.5,5s1.5,0.67 1.5,1.5S15.33,8 14.5,8zM17.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S16.67,9 17.5,9s1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z"/>
</vector>
+18 -1
View File
@@ -19,10 +19,27 @@
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/ripple_material_light">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<solid android:color="@color/white" />
<corners android:radius="2dp" />
</shape>
</item>
<item>
<selector>
<item android:state_selected="true">
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:radius="2dp" />
</shape>
</item>
<item>
<color android:color="@android:color/transparent" />
</item>
</selector>
</item>
</ripple>
+17
View File
@@ -18,6 +18,7 @@
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -113,6 +114,22 @@
</LinearLayout>
<LinearLayout
android:id="@+id/plus"
style="@style/DrawerRow">
<ImageView
android:id="@+id/plusIcon"
style="@style/DrawerIcon"
android:src="@mipmap/ic_launcher"
tools:tint="@color/textSecondary" />
<presentation.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_plus" />
</LinearLayout>
<LinearLayout
android:id="@+id/help"
style="@style/DrawerRow">
@@ -0,0 +1,360 @@
<?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.design.widget.CoordinatorLayout 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"
tools:background="@color/white">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:collapsedTitleTextAppearance="@style/CollapsingToolbarCollapsedText"
app:expandedTitleTextAppearance="@style/CollapsingToolbarExpandedText"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<presentation.common.widget.QkTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:text="@string/qksms_plus_description_title"
android:textSize="16sp"
android:textStyle="bold"
app:textColor="primary" />
<presentation.common.widget.QkTextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:text="@string/qksms_plus_description_summary"
android:textSize="14sp"
app:textColor="secondary" />
<presentation.common.widget.Separator
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<android.support.constraint.ConstraintLayout
android:id="@+id/supporter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp">
<presentation.common.widget.QkTextView
android:id="@+id/supporterName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/qksms_plus_option_supporter"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:textColor="primary" />
<presentation.common.widget.QkTextView
android:id="@+id/supporterPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@id/supporterPeriod"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/supporterName"
app:textColor="primary"
tools:text="$2.99" />
<presentation.common.widget.QkTextView
android:id="@+id/supporterPeriod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/qksms_plus_renewal_year"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/supporterPrice"
app:layout_constraintTop_toBottomOf="@id/supporterName"
app:textColor="secondary" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/donor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp">
<presentation.common.widget.QkTextView
android:id="@+id/donorName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/qksms_plus_option_donor"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:textColor="primary" />
<presentation.common.widget.QkTextView
android:id="@+id/donorPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@id/donorPeriod"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/donorName"
app:textColor="primary"
tools:text="$2.99" />
<presentation.common.widget.QkTextView
android:id="@+id/donorPeriod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/qksms_plus_renewal_year"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/donorPrice"
app:layout_constraintTop_toBottomOf="@id/donorName"
app:textColor="secondary" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/philanthropist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp">
<presentation.common.widget.QkTextView
android:id="@+id/philanthropistName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/qksms_plus_option_philanthropist"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:textColor="primary" />
<presentation.common.widget.QkTextView
android:id="@+id/philanthropistPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@id/philanthropistPeriod"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/philanthropistName"
app:textColor="primary"
tools:text="$2.99" />
<presentation.common.widget.QkTextView
android:id="@+id/philanthropistPeriod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/qksms_plus_renewal_year"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/philanthropistPrice"
app:layout_constraintTop_toBottomOf="@id/philanthropistName"
app:textColor="secondary" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/thanks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="16dp"
android:background="@drawable/rounded_rectangle_2dp"
android:padding="16dp"
tools:backgroundTint="@color/separatorLight">
<ImageView
android:id="@+id/thanksIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_favorite_black_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<presentation.common.widget.QkTextView
android:id="@+id/thanksTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="@string/qksms_plus_thanks_title"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/thanksIcon"
app:textColor="primary" />
<presentation.common.widget.QkTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/qksms_plus_thanks_summary"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="@id/thanksTitle"
app:layout_constraintStart_toStartOf="@id/thanksTitle"
app:layout_constraintTop_toBottomOf="@id/thanksTitle"
app:textColor="secondary" />
</android.support.constraint.ConstraintLayout>
<presentation.common.widget.Separator
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="16dp" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_palette_black_24dp"
app:summary="@string/qksms_plus_themes_summary"
app:title="@string/qksms_plus_themes_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_favorite_black_24dp"
app:summary="@string/qksms_plus_emoji_summary"
app:title="@string/qksms_plus_emoji_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_backup_black_24dp"
app:summary="@string/qksms_plus_backup_summary"
app:title="@string/qksms_plus_backup_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_event_black_24dp"
app:summary="@string/qksms_plus_scheduled_summary"
app:title="@string/qksms_plus_scheduled_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_av_timer_black_24dp"
app:summary="@string/qksms_plus_delayed_summary"
app:title="@string/qksms_plus_delayed_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_invert_colors_black_24dp"
app:summary="@string/qksms_plus_night_summary"
app:title="@string/qksms_plus_night_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_block_black_24dp"
app:summary="@string/qksms_plus_blacklist_summary"
app:title="@string/qksms_plus_blacklist_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_forward_black_24dp"
app:summary="@string/qksms_plus_forward_summary"
app:title="@string/qksms_plus_forward_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_reply_black_24dp"
app:summary="@string/qksms_plus_respond_summary"
app:title="@string/qksms_plus_respond_title" />
<presentation.common.widget.PreferenceView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_more_horiz_black_24dp"
app:summary="@string/qksms_plus_more_summary"
app:title="@string/qksms_plus_more_title" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
@@ -27,8 +27,15 @@
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center"
android:layout_margin="8dp"
android:background="@drawable/circle"
tools:backgroundTint="@color/tools_theme" />
<ImageView
android:id="@+id/check"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:src="@drawable/ic_check_black_24dp"
tools:tint="@color/textPrimaryDark" />
</FrameLayout>
@@ -0,0 +1,35 @@
<?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/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/palette"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<presentation.common.widget.Separator
android:layout_width="match_parent"
android:layout_height="1dp" />
</LinearLayout>
@@ -0,0 +1,44 @@
<?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/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/materialColors"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<View
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="@drawable/ab_shadow" />
</FrameLayout>
</LinearLayout>
+33
View File
@@ -24,8 +24,10 @@
<string name="title_scheduled">Scheduled</string>
<string name="title_blocked">Blocked</string>
<string name="title_settings">Settings</string>
<string name="title_theme">Theme</string>
<string name="title_conversations">Search inbox…</string>
<string name="title_compose">Type a name or number</string>
<string name="title_qksms_plus">QKSMS+</string>
<string name="setup_title">Love texting again</string>
<string name="setup_summary">Make QKSMS your default SMS app</string>
@@ -58,6 +60,7 @@
<string name="drawer_blocked">Blocked</string>
<string name="drawer_more">More</string>
<string name="drawer_settings">Settings</string>
<string name="drawer_plus">QKSMS+</string>
<string name="drawer_help">Help &amp; feedback</string>
<string name="inbox_empty_text">Your conversations will appear here</string>
@@ -85,6 +88,36 @@
<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="qksms_plus_description_title">Pay what you like, unlock everything</string>
<string name="qksms_plus_description_summary">You can save a starving developer for as little as %s a year</string>
<string name="qksms_plus_option_supporter">Supporter</string>
<string name="qksms_plus_option_donor">Donor</string>
<string name="qksms_plus_option_philanthropist">Philanthropist</string>
<string name="qksms_plus_renewal_year">/year</string>
<string name="qksms_plus_upgrade">Upgrade to QKSMS+</string>
<string name="qksms_plus_thanks_title">Thank you for supporting QKSMS!</string>
<string name="qksms_plus_thanks_summary">You now have access to all QKSMS+ features</string>
<string name="qksms_plus_themes_title">Premium themes</string>
<string name="qksms_plus_themes_summary">Unlock beautiful theme colors not available on the Material Design palette</string>
<string name="qksms_plus_emoji_title">Custom auto-emoji</string>
<string name="qksms_plus_emoji_summary">Create custom auto-emoji shortcuts</string>
<string name="qksms_plus_backup_title">Message backup</string>
<string name="qksms_plus_backup_summary">Automatically back up your messages. Never again worry about losing your history if you change phones or your phone gets lost</string>
<string name="qksms_plus_scheduled_title">Scheduled messages</string>
<string name="qksms_plus_scheduled_summary">Wait a few seconds before sending your message</string>
<string name="qksms_plus_delayed_title">Delayed sending</string>
<string name="qksms_plus_delayed_summary">Wait a few seconds before sending your message</string>
<string name="qksms_plus_night_title">Automatic night mode</string>
<string name="qksms_plus_night_summary">Enable night mode based on the time of day</string>
<string name="qksms_plus_blacklist_title">Advanced blocking</string>
<string name="qksms_plus_blacklist_summary">Block messages that contain keywords or match patterns</string>
<string name="qksms_plus_forward_title">Auto-forward</string>
<string name="qksms_plus_forward_summary">Automatically forward messages from certain senders</string>
<string name="qksms_plus_respond_title">Auto-respond</string>
<string name="qksms_plus_respond_summary">Automatically respond to incoming messages with a preset response</string>
<string name="qksms_plus_more_title">More</string>
<string name="qksms_plus_more_summary">QKSMS is under active development, and your subscription will include all future QKSMS+ features!</string>
<string name="settings_dialog_theme_title">Theme</string>
<string name="notification_reply">Reply</string>
+8
View File
@@ -49,6 +49,14 @@
<item name="textColor">tertiary</item>
</style>
<style name="CollapsingToolbarCollapsedText">
<item name="android:textSize">20sp</item>
</style>
<style name="CollapsingToolbarExpandedText">
<item name="android:textSize">48sp</item>
</style>
<style name="DrawerRow">
<item name="android:layout_height">48dp</item>
<item name="android:layout_width">match_parent</item>