forked from upstream-mirrors/quik
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:
@@ -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 -> {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user