Commit 9cd97a73 authored by Amit Kumar's avatar Amit Kumar

Remove QKSMS+ from string, Disable backup for now and Remove Billing Manager

parent 4993e9fc
Pipeline #10979 passed with stage
in 10 minutes and 3 seconds
......@@ -93,7 +93,6 @@
android:value=".common.util.QkChooserTargetService" />
</activity>
<activity android:name=".feature.settings.SettingsActivity" />
<activity android:name=".feature.plus.PlusActivity" />
<activity
android:name=".feature.gallery.GalleryActivity"
android:theme="@style/AppThemeBlack" />
......
......@@ -26,8 +26,6 @@ import android.os.Build
import android.provider.ContactsContract
import android.provider.Settings
import android.provider.Telephony
import com.moez.QKSMS.BuildConfig
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.feature.backup.BackupActivity
import com.moez.QKSMS.feature.blocked.BlockedActivity
import com.moez.QKSMS.feature.compose.ComposeActivity
......@@ -47,7 +45,6 @@ import javax.inject.Singleton
class Navigator @Inject constructor(
private val context: Context,
private val analyticsManager: AnalyticsManager,
private val billingManager: BillingManager,
private val notificationManager: NotificationManager,
private val permissions: PermissionManager
) {
......
/*
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.moez.QKSMS.common.util
import android.app.Activity
import android.content.Context
import com.android.billingclient.api.BillingClient
import com.android.billingclient.api.BillingClient.BillingResponse
import com.android.billingclient.api.BillingClient.SkuType
import com.android.billingclient.api.BillingClientStateListener
import com.android.billingclient.api.BillingFlowParams
import com.android.billingclient.api.Purchase
import com.android.billingclient.api.PurchasesUpdatedListener
import com.android.billingclient.api.SkuDetails
import com.android.billingclient.api.SkuDetailsParams
import com.moez.QKSMS.BuildConfig
import com.moez.QKSMS.manager.AnalyticsManager
import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.Subject
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class BillingManager @Inject constructor(
context: Context,
private val analyticsManager: AnalyticsManager
) : PurchasesUpdatedListener {
companion object {
const val SKU_PLUS = "remove_ads"
const val SKU_PLUS_DONATE = "qksms_plus_donate"
}
val products: Observable<List<SkuDetails>> = BehaviorSubject.create()
val upgradeStatus: Observable<Boolean>
private val skus = listOf(SKU_PLUS, SKU_PLUS_DONATE)
private val purchaseListObservable = BehaviorSubject.create<List<Purchase>>()
private val billingClient: BillingClient = BillingClient.newBuilder(context).setListener(this).build()
private var isServiceConnected = false
init {
startServiceConnection {
queryPurchases()
querySkuDetailsAsync()
}
upgradeStatus = when (BuildConfig.FLAVOR) {
"noAnalytics" -> BehaviorSubject.createDefault(true)
else -> purchaseListObservable
.map { purchases -> purchases.any { it.sku == SKU_PLUS } || purchases.any { it.sku == SKU_PLUS_DONATE } }
.doOnNext { upgraded -> analyticsManager.setUserProperty("Upgraded", upgraded) }
}
}
private fun queryPurchases() {
executeServiceRequest {
// Load the cached data
purchaseListObservable.onNext(billingClient.queryPurchases(SkuType.INAPP).purchasesList.orEmpty())
// On a fresh device, the purchase might not be cached, and so we'll need to force a refresh
billingClient.queryPurchaseHistoryAsync(SkuType.INAPP) { _, _ ->
purchaseListObservable.onNext(billingClient.queryPurchases(SkuType.INAPP).purchasesList.orEmpty())
}
}
}
private fun startServiceConnection(onSuccess: () -> Unit) {
val listener = object : BillingClientStateListener {
override fun onBillingSetupFinished(@BillingResponse billingResponseCode: Int) {
if (billingResponseCode == BillingResponse.OK) {
isServiceConnected = true
onSuccess()
} else {
Timber.w("Billing response: $billingResponseCode")
purchaseListObservable.onNext(listOf())
}
}
override fun onBillingServiceDisconnected() {
isServiceConnected = false
}
}
Flowable.fromCallable { billingClient.startConnection(listener) }
.subscribeOn(Schedulers.io())
.subscribe()
}
private fun querySkuDetailsAsync() {
executeServiceRequest {
val subParams = SkuDetailsParams.newBuilder().setSkusList(skus).setType(BillingClient.SkuType.INAPP)
billingClient.querySkuDetailsAsync(subParams.build()) { responseCode, skuDetailsList ->
if (responseCode == BillingResponse.OK) {
(products as Subject).onNext(skuDetailsList)
}
}
}
}
fun initiatePurchaseFlow(activity: Activity, sku: String) {
executeServiceRequest {
val params = BillingFlowParams.newBuilder().setSku(sku).setType(SkuType.INAPP)
billingClient.launchBillingFlow(activity, params.build())
}
}
private fun executeServiceRequest(runnable: () -> Unit) {
when (isServiceConnected) {
true -> runnable()
false -> startServiceConnection(runnable)
}
}
override fun onPurchasesUpdated(resultCode: Int, purchases: List<Purchase>?) {
if (resultCode == BillingResponse.OK) {
purchaseListObservable.onNext(purchases.orEmpty())
}
}
}
\ No newline at end of file
......@@ -161,16 +161,6 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter>(
backup.summary = state.lastBackup
adapter.data = state.backups
fabIcon.setImageResource(when (state.upgraded) {
true -> R.drawable.ic_file_upload_black_24dp
false -> R.drawable.ic_star_black_24dp
})
fabLabel.setText(when (state.upgraded) {
true -> R.string.backup_now
false -> R.string.title_qksms_plus
})
}
override fun activityVisible(): Observable<*> = activityVisibleSubject
......
......@@ -22,7 +22,6 @@ import android.content.Context
import com.moez.QKSMS.R
import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.base.QkPresenter
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.common.util.DateFormatter
import com.moez.QKSMS.common.util.extensions.makeToast
import com.moez.QKSMS.interactor.PerformBackup
......@@ -38,7 +37,6 @@ import javax.inject.Inject
class BackupPresenter @Inject constructor(
private val backupRepo: BackupRepository,
private val billingManager: BillingManager,
private val context: Context,
private val dateFormatter: DateFormatter,
private val navigator: Navigator,
......@@ -72,9 +70,6 @@ class BackupPresenter @Inject constructor(
}
.startWith(context.getString(R.string.backup_loading))
.subscribe { lastBackup -> newState { copy(lastBackup = lastBackup) } }
disposables += billingManager.upgradeStatus
.subscribe { upgraded -> newState { copy(upgraded = upgraded) } }
}
override fun bindIntents(view: BackupView) {
......@@ -88,11 +83,9 @@ class BackupPresenter @Inject constructor(
view.restoreClicks()
.withLatestFrom(
backupRepo.getBackupProgress(),
backupRepo.getRestoreProgress(),
billingManager.upgradeStatus)
{ _, backupProgress, restoreProgress, upgraded ->
backupRepo.getRestoreProgress())
{ _, backupProgress, restoreProgress ->
when {
!upgraded -> context.makeToast(R.string.backup_restore_error_plus)
backupProgress.running -> context.makeToast(R.string.backup_restore_error_backup)
restoreProgress.running -> context.makeToast(R.string.backup_restore_error_restore)
!permissionManager.hasStorage() -> view.requestStoragePermission()
......
......@@ -28,7 +28,6 @@ import com.moez.QKSMS.R
import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.androidxcompat.scope
import com.moez.QKSMS.common.base.QkViewModel
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.common.util.ClipboardUtils
import com.moez.QKSMS.common.util.MessageDetailsFormatter
import com.moez.QKSMS.common.util.extensions.makeToast
......@@ -39,21 +38,10 @@ import com.moez.QKSMS.extensions.isImage
import com.moez.QKSMS.extensions.mapNotNull
import com.moez.QKSMS.extensions.removeAccents
import com.moez.QKSMS.filter.ContactFilter
import com.moez.QKSMS.interactor.AddScheduledMessage
import com.moez.QKSMS.interactor.CancelDelayedMessage
import com.moez.QKSMS.interactor.ContactSync
import com.moez.QKSMS.interactor.DeleteMessages
import com.moez.QKSMS.interactor.MarkRead
import com.moez.QKSMS.interactor.RetrySending
import com.moez.QKSMS.interactor.SendMessage
import com.moez.QKSMS.interactor.*
import com.moez.QKSMS.manager.ActiveConversationManager
import com.moez.QKSMS.manager.PermissionManager
import com.moez.QKSMS.model.Attachment
import com.moez.QKSMS.model.Attachments
import com.moez.QKSMS.model.Contact
import com.moez.QKSMS.model.Conversation
import com.moez.QKSMS.model.Message
import com.moez.QKSMS.model.PhoneNumber
import com.moez.QKSMS.model.*
import com.moez.QKSMS.repository.ContactRepository
import com.moez.QKSMS.repository.ConversationRepository
import com.moez.QKSMS.repository.MessageRepository
......@@ -85,7 +73,6 @@ class ComposeViewModel @Inject constructor(
private val context: Context,
private val activeConversationManager: ActiveConversationManager,
private val addScheduledMessage: AddScheduledMessage,
private val billingManager: BillingManager,
private val cancelMessage: CancelDelayedMessage,
private val contactFilter: ContactFilter,
private val contactsRepo: ContactRepository,
......@@ -497,10 +484,6 @@ class ComposeViewModel @Inject constructor(
// Choose a time to schedule the message
view.scheduleIntent
.doOnNext { newState { copy(attaching = false) } }
.withLatestFrom(billingManager.upgradeStatus) { _, upgraded -> upgraded }
.filter { upgraded ->
upgraded.also { if (!upgraded) view.showQksmsPlusSnackbar(R.string.compose_scheduled_plus) }
}
.autoDisposable(view.scope())
.subscribe { view.requestDatePicker() }
......
......@@ -90,7 +90,6 @@ class MainActivity : QkThemedActivity(), MainView {
Observable.merge(listOf(
inbox.clicks().map { DrawerItem.INBOX },
archived.clicks().map { DrawerItem.ARCHIVED },
backup.clicks().map { DrawerItem.BACKUP },
scheduled.clicks().map { DrawerItem.SCHEDULED },
blocking.clicks().map { DrawerItem.BLOCKING },
settings.clicks().map { DrawerItem.SETTINGS }))
......@@ -157,13 +156,8 @@ class MainActivity : QkThemedActivity(), MainView {
}
// Miscellaneous views
listOf(plusBadge1, plusBadge2).forEach { badge ->
badge.setBackgroundTint(theme.theme)
badge.setTextColor(theme.textPrimary)
}
syncingProgress?.progressTintList = ColorStateList.valueOf(theme.theme)
syncingProgress?.indeterminateTintList = ColorStateList.valueOf(theme.theme)
plusIcon.setTint(theme.theme)
compose.setBackgroundTint(theme.theme)
// Set the FAB compose icon color
......@@ -210,11 +204,6 @@ class MainActivity : QkThemedActivity(), MainView {
toolbar.menu.findItem(R.id.unread)?.isVisible = !markRead && selectedConversations != 0
toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
listOf(plusBadge1, plusBadge2).forEach { badge ->
badge.isVisible = drawerBadgesExperiment.variant && !state.upgraded
}
plusBanner.isVisible = !state.upgraded
compose.setVisible(state.page is Inbox || state.page is Archived)
conversationsAdapter.emptyView = empty.takeIf { state.page is Inbox || state.page is Archived }
......
......@@ -27,7 +27,6 @@ data class MainState(
val hasError: Boolean = false,
val page: MainPage = Inbox(),
val drawerOpen: Boolean = false,
val upgraded: Boolean = true,
val showRating: Boolean = false,
val syncing: SyncRepository.SyncProgress = SyncRepository.SyncProgress.Idle(),
val defaultSms: Boolean = true,
......
......@@ -23,19 +23,8 @@ import com.moez.QKSMS.R
import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.androidxcompat.scope
import com.moez.QKSMS.common.base.QkViewModel
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.extensions.removeAccents
import com.moez.QKSMS.interactor.DeleteConversations
import com.moez.QKSMS.interactor.MarkAllSeen
import com.moez.QKSMS.interactor.MarkArchived
import com.moez.QKSMS.interactor.MarkBlocked
import com.moez.QKSMS.interactor.MarkPinned
import com.moez.QKSMS.interactor.MarkRead
import com.moez.QKSMS.interactor.MarkUnarchived
import com.moez.QKSMS.interactor.MarkUnpinned
import com.moez.QKSMS.interactor.MarkUnread
import com.moez.QKSMS.interactor.MigratePreferences
import com.moez.QKSMS.interactor.SyncMessages
import com.moez.QKSMS.interactor.*
import com.moez.QKSMS.manager.PermissionManager
import com.moez.QKSMS.model.SyncLog
import com.moez.QKSMS.repository.ConversationRepository
......@@ -52,7 +41,6 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject
class MainViewModel @Inject constructor(
billingManager: BillingManager,
markAllSeen: MarkAllSeen,
migratePreferences: MigratePreferences,
syncRepository: SyncRepository,
......@@ -85,10 +73,6 @@ class MainViewModel @Inject constructor(
.distinctUntilChanged()
.subscribe { syncing -> newState { copy(syncing = syncing) } }
// Update the upgraded status
disposables += billingManager.upgradeStatus
.subscribe { upgraded -> newState { copy(upgraded = upgraded) } }
// Migrate the preferences from 2.7.3
migratePreferences.execute(Unit)
......
......@@ -46,7 +46,6 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView {
override val messageClickIntent by lazy { messageAdapter.clicks }
override val messageMenuIntent by lazy { dialog.adapter.menuItemClicks }
override val composeIntent by lazy { compose.clicks() }
override val upgradeIntent by lazy { upgrade.clicks() }
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ScheduledViewModel::class.java] }
......@@ -77,17 +76,11 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView {
sampleMessage.setTextColor(theme.textPrimary)
compose.setTint(theme.textPrimary)
compose.setBackgroundTint(theme.theme)
upgrade.setBackgroundTint(theme.theme)
upgradeIcon.setTint(theme.textPrimary)
upgradeLabel.setTextColor(theme.textPrimary)
}
}
override fun render(state: ScheduledState) {
messageAdapter.updateData(state.scheduledMessages)
compose.isVisible = state.upgraded
upgrade.isVisible = !state.upgraded
}
override fun showMessageOptions() {
......
......@@ -26,7 +26,6 @@ interface ScheduledView : QkView<ScheduledState> {
val messageClickIntent: Observable<Long>
val messageMenuIntent: Observable<Int>
val composeIntent: Observable<*>
val upgradeIntent: Observable<*>
fun showMessageOptions()
......
......@@ -21,16 +21,13 @@ package com.moez.QKSMS.feature.scheduled
import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.androidxcompat.scope
import com.moez.QKSMS.common.base.QkViewModel
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.interactor.SendScheduledMessage
import com.moez.QKSMS.repository.ScheduledMessageRepository
import com.uber.autodispose.kotlin.autoDisposable
import io.reactivex.rxkotlin.plusAssign
import io.reactivex.rxkotlin.withLatestFrom
import javax.inject.Inject
class ScheduledViewModel @Inject constructor(
billingManager: BillingManager,
private val navigator: Navigator,
private val scheduledMessageRepo: ScheduledMessageRepository,
private val sendScheduledMessage: SendScheduledMessage
......@@ -38,11 +35,6 @@ class ScheduledViewModel @Inject constructor(
scheduledMessages = scheduledMessageRepo.getScheduledMessages()
)) {
init {
disposables += billingManager.upgradeStatus
.subscribe { upgraded -> newState { copy(upgraded = upgraded) } }
}
override fun bindView(view: ScheduledView) {
super.bindView(view)
......
......@@ -161,15 +161,6 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
}
}
override fun showQksmsPlusSnackbar() {
view?.run {
Snackbar.make(contentView, R.string.toast_qksms_plus, Snackbar.LENGTH_LONG).run {
setAction(R.string.button_more) { viewQksmsPlusSubject.onNext(Unit) }
show()
}
}
}
// TODO change this to a PopupWindow
override fun showNightModeDialog() = nightModeDialog.show(activity!!)
......
......@@ -22,7 +22,6 @@ import android.content.Context
import com.moez.QKSMS.R
import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.base.QkPresenter
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.common.util.Colors
import com.moez.QKSMS.common.util.DateFormatter
import com.moez.QKSMS.common.util.extensions.makeToast
......@@ -32,22 +31,20 @@ import com.moez.QKSMS.util.NightModeManager
import com.moez.QKSMS.util.Preferences
import com.uber.autodispose.kotlin.autoDisposable
import io.reactivex.rxkotlin.plusAssign
import io.reactivex.rxkotlin.withLatestFrom
import timber.log.Timber
import java.util.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
class SettingsPresenter @Inject constructor(
private val context: Context,
private val billingManager: BillingManager,
private val colors: Colors,
private val dateFormatter: DateFormatter,
private val navigator: Navigator,
private val nightModeManager: NightModeManager,
private val prefs: Preferences,
private val syncMessages: SyncMessages,
private val syncRepo: SyncRepository
private val context: Context,
private val colors: Colors,
private val dateFormatter: DateFormatter,
private val navigator: Navigator,
private val nightModeManager: NightModeManager,
private val prefs: Preferences,
private val syncMessages: SyncMessages,
private val syncRepo: SyncRepository
) : QkPresenter<SettingsView, SettingsState>(SettingsState(theme = colors.theme().theme)) {
init {
......@@ -59,7 +56,9 @@ class SettingsPresenter @Inject constructor(
val nightModeLabels = context.resources.getStringArray(R.array.night_modes)
disposables += prefs.nightMode.asObservable()
.subscribe { nightMode ->
newState { copy(nightModeSummary = nightModeLabels[nightMode], nightModeId = nightMode) }
newState {
copy(nightModeSummary = nightModeLabels[nightMode], nightModeId = nightMode)
}
}
disposables += prefs.nightStart.asObservable()
......@@ -85,7 +84,11 @@ class SettingsPresenter @Inject constructor(
val delayedSendingLabels = context.resources.getStringArray(R.array.delayed_sending_labels)
disposables += prefs.sendDelay.asObservable()
.subscribe { id -> newState { copy(sendDelaySummary = delayedSendingLabels[id], sendDelayId = id) } }
.subscribe { id ->
newState {
copy(sendDelaySummary = delayedSendingLabels[id], sendDelayId = id)
}
}
disposables += prefs.delivery.asObservable()
.subscribe { enabled -> newState { copy(deliveryEnabled = enabled) } }
......@@ -93,7 +96,9 @@ class SettingsPresenter @Inject constructor(
val textSizeLabels = context.resources.getStringArray(R.array.text_sizes)
disposables += prefs.textSize.asObservable()
.subscribe { textSize ->
newState { copy(textSizeSummary = textSizeLabels[textSize], textSizeId = textSize) }
newState {
copy(textSizeSummary = textSizeLabels[textSize], textSizeId = textSize)
}
}
disposables += prefs.systemFont.asObservable()
......@@ -110,7 +115,9 @@ class SettingsPresenter @Inject constructor(
disposables += prefs.mmsSize.asObservable()
.subscribe { maxMmsSize ->
val index = mmsSizeIds.indexOf(maxMmsSize)
newState { copy(maxMmsSizeSummary = mmsSizeLabels[index], maxMmsSizeId = maxMmsSize) }
newState {
copy(maxMmsSizeSummary = mmsSizeLabels[index], maxMmsSizeId = maxMmsSize)
}
}
disposables += syncRepo.syncProgress
......@@ -136,12 +143,14 @@ class SettingsPresenter @Inject constructor(
R.id.nightStart -> {
val date = nightModeManager.parseTime(prefs.nightStart.get())
view.showStartTimePicker(date.get(Calendar.HOUR_OF_DAY), date.get(Calendar.MINUTE))
view.showStartTimePicker(date.get(Calendar.HOUR_OF_DAY),
date.get(Calendar.MINUTE))
}
R.id.nightEnd -> {
val date = nightModeManager.parseTime(prefs.nightEnd.get())
view.showEndTimePicker(date.get(Calendar.HOUR_OF_DAY), date.get(Calendar.MINUTE))
view.showEndTimePicker(date.get(Calendar.HOUR_OF_DAY),
date.get(Calendar.MINUTE))
}
R.id.black -> prefs.black.set(!prefs.black.get())
......@@ -184,15 +193,8 @@ class SettingsPresenter @Inject constructor(
}
view.nightModeSelected()
.withLatestFrom(billingManager.upgradeStatus) { mode, upgraded ->
if (!upgraded && mode == Preferences.NIGHT_MODE_AUTO) {
view.showQksmsPlusSnackbar()
} else {
nightModeManager.updateNightMode(mode)
}
}
.autoDisposable(view.scope())
.subscribe()
.subscribe { mode -> nightModeManager.updateNightMode(mode) }
view.nightStartSelected()
.autoDisposable(view.scope())
......@@ -207,15 +209,8 @@ class SettingsPresenter @Inject constructor(
.subscribe { prefs.textSize.set(it) }
view.sendDelaySelected()
.withLatestFrom(billingManager.upgradeStatus) { duration, upgraded ->
if (!upgraded && duration != 0) {
view.showQksmsPlusSnackbar()
} else {
prefs.sendDelay.set(duration)
}
}
.autoDisposable(view.scope())
.subscribe()
.subscribe { duration -> prefs.sendDelay.set(duration) }
view.mmsSizeSelected()
.autoDisposable(view.scope())
......
......@@ -33,7 +33,6 @@ interface SettingsView : QkViewContract<SettingsState> {
fun sendDelaySelected(): Observable<Int>
fun mmsSizeSelected(): Observable<Int>
fun showQksmsPlusSnackbar()
fun showNightModeDialog()
fun showStartTimePicker(hour: Int, minute: Int)
fun showEndTimePicker(hour: Int, minute: Int)
......
......@@ -88,13 +88,6 @@ class ThemePickerController(val threadId: Long = 0L) : QkController<ThemePickerV
}
}
override fun showQksmsPlusSnackbar() {
Snackbar.make(contentView, R.string.toast_qksms_plus, Snackbar.LENGTH_LONG).run {
setAction(R.string.button_more) { viewQksmsPlusSubject.onNext(Unit) }
show()
}
}
override fun themeSelected(): Observable<Int> = themeAdapter.colorSelected
override fun hsvThemeSelected(): Observable<Int> = picker.selectedColor
......
......@@ -21,7 +21,6 @@ package com.moez.QKSMS.feature.themepicker
import com.f2prateek.rx.preferences2.Preference
import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.base.QkPresenter
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.common.util.Colors
import com.moez.QKSMS.manager.WidgetManager
import com.moez.QKSMS.util.Preferences
......@@ -34,7 +33,6 @@ import javax.inject.Named
class ThemePickerPresenter @Inject constructor(
prefs: Preferences,
@Named("threadId") private val threadId: Long,
private val billingManager: BillingManager,
private val colors: Colors,
private val navigator: Navigator,
private val widgetManager: WidgetManager
......@@ -74,15 +72,10 @@ class ThemePickerPresenter @Inject constructor(
// Update the theme, when apply is clicked
view.applyHsvThemeClicks()
.withLatestFrom(view.hsvThemeSelected()) { _, color -> color }
.withLatestFrom(billingManager.upgradeStatus) { color, upgraded ->
if (!upgraded) {
view.showQksmsPlusSnackbar()
} else {
theme.set(color)
if (threadId == 0L) {
widgetManager.updateTheme()
}
.withLatestFrom(view.hsvThemeSelected()) { _, color ->
theme.set(color)
if (threadId == 0L) {
widgetManager.updateTheme()
}
}
.autoDisposable(view.scope())
......
......@@ -30,6 +30,4 @@ interface ThemePickerView : QkViewContract<ThemePickerState> {
fun viewQksmsPlusClicks(): Observable<*>
fun setCurrentTheme(color: Int)
fun showQksmsPlusSnackbar()
}
\ No newline at end of file
......@@ -167,7 +167,7 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="12dp"
android:src="@drawable/ic_star_black_24dp"
android:src="@drawable/ic_file_upload_black_24dp"
tools:tint="@color/textPrimaryDark" />
<com.moez.QKSMS.common.widget.QkTextView
......@@ -176,7 +176,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:text="@string/title_qksms_plus"
android:text="@string/backup_now"
android:textColor="@color/textPrimaryDark"
android:textStyle="bold"
app:textSize="primary" />
......