diff --git a/domain/src/main/java/com/moez/QKSMS/manager/BillingManager.kt b/domain/src/main/java/com/moez/QKSMS/manager/BillingManager.kt deleted file mode 100644 index a1157248..00000000 --- a/domain/src/main/java/com/moez/QKSMS/manager/BillingManager.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2020 Moez Bhatti - * - * 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 . - */ - -package dev.octoshrimpy.quik.manager - -import android.app.Activity -import io.reactivex.Observable - -interface BillingManager { - - companion object { - const val SKU_PLUS = "remove_ads" - const val SKU_PLUS_DONATE = "qksms_plus_donate" - } - - data class Product( - val sku: String, - val price: String, - val priceCurrencyCode: String - ) - - val products: Observable> - val upgradeStatus: Observable - - suspend fun checkForPurchases() - - suspend fun queryProducts() - - suspend fun initiatePurchaseFlow(activity: Activity, sku: String) - -} diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index b328dd8b..af5ae420 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -107,7 +107,6 @@ - diff --git a/presentation/src/main/java/com/moez/QKSMS/common/ExternalNavigator.kt b/presentation/src/main/java/com/moez/QKSMS/common/ExternalNavigator.kt index bda0e5c1..220db36e 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/ExternalNavigator.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/ExternalNavigator.kt @@ -30,7 +30,6 @@ import android.provider.Settings import android.provider.Telephony import androidx.core.net.toUri import dev.octoshrimpy.quik.BuildConfig -import dev.octoshrimpy.quik.manager.BillingManager import dev.octoshrimpy.quik.manager.PermissionManager import javax.inject.Inject import dev.octoshrimpy.quik.feature.notificationprefs.NotificationPrefsActivity @@ -42,7 +41,6 @@ import dev.octoshrimpy.quik.manager.NotificationManager */ class ExternalNavigator @Inject constructor( context: Context, - private val billingManager: BillingManager, private val permissions: PermissionManager, private val notificationManager: NotificationManager ) : QkNavigator(context) { @@ -98,15 +96,15 @@ class ExternalNavigator @Inject constructor( intent.data = "mailto:".toUri() intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("quik@octo.sh")) intent.putExtra(Intent.EXTRA_SUBJECT, "QUIK Support") - intent.putExtra(Intent.EXTRA_TEXT, StringBuilder("\n\n") - .append("\n\n--- Please write your message above this line ---\n\n") - .append("Package: ${context.packageName}\n") - .append("Version: ${BuildConfig.VERSION_NAME}\n") - .append("Device: ${Build.BRAND} ${Build.MODEL}\n") - .append("SDK: ${Build.VERSION.SDK_INT}\n") - .append("Upgraded" - .takeIf { billingManager.upgradeStatus.blockingFirst() } ?: "") - .toString()) + intent.putExtra( + Intent.EXTRA_TEXT, StringBuilder("\n\n") + .append("\n\n--- Please write your message above this line ---\n\n") + .append("Package: ${context.packageName}\n") + .append("Version: ${BuildConfig.VERSION_NAME}\n") + .append("Device: ${Build.BRAND} ${Build.MODEL}\n") + .append("SDK: ${Build.VERSION.SDK_INT}\n") + .toString() + ) startActivityExternal(intent) } diff --git a/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt b/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt index ca50ffc1..a3d6573e 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt @@ -32,7 +32,6 @@ import dev.octoshrimpy.quik.feature.conversationinfo.ConversationInfoActivity import dev.octoshrimpy.quik.feature.gallery.GalleryActivity import dev.octoshrimpy.quik.feature.main.MainActivity import dev.octoshrimpy.quik.feature.messageutils.MessageUtilsActivity -import dev.octoshrimpy.quik.feature.plus.PlusActivity import dev.octoshrimpy.quik.feature.scheduled.ScheduledActivity import dev.octoshrimpy.quik.feature.settings.SettingsActivity import dev.octoshrimpy.quik.model.ScheduledMessage @@ -43,14 +42,6 @@ import javax.inject.Singleton class Navigator @Inject constructor( context: Context ) : QkNavigator(context) { - /** - * @param source String to indicate where this QKSMS+ screen was launched from. This should be - * one of [main_menu, compose_schedule, settings_night, settings_theme] - */ - fun showQksmsPlusActivity(source: String) { - startActivity(Intent(context, PlusActivity::class.java)) - } - fun showMainActivity() { startActivity(Intent(context, MainActivity::class.java)) } diff --git a/presentation/src/main/java/com/moez/QKSMS/common/QKApplication.kt b/presentation/src/main/java/com/moez/QKSMS/common/QKApplication.kt index 36d018fe..e8f90ab6 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/QKApplication.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/QKApplication.kt @@ -39,7 +39,6 @@ import dev.octoshrimpy.quik.common.util.FileLoggingTree import dev.octoshrimpy.quik.injection.AppComponentManager import dev.octoshrimpy.quik.injection.appComponent import dev.octoshrimpy.quik.interactor.SpeakThreads -import dev.octoshrimpy.quik.manager.BillingManager import dev.octoshrimpy.quik.manager.ReferralManager import dev.octoshrimpy.quik.migration.QkMigration import dev.octoshrimpy.quik.migration.QkRealmMigration @@ -59,17 +58,25 @@ class QKApplication : Application(), HasActivityInjector, HasBroadcastReceiverIn * Inject these so that they are forced to initialize */ @Suppress("unused") - @Inject lateinit var qkMigration: QkMigration + @Inject + lateinit var qkMigration: QkMigration - @Inject lateinit var billingManager: BillingManager - @Inject lateinit var dispatchingActivityInjector: DispatchingAndroidInjector - @Inject lateinit var dispatchingBroadcastReceiverInjector: DispatchingAndroidInjector - @Inject lateinit var dispatchingServiceInjector: DispatchingAndroidInjector - @Inject lateinit var fileLoggingTree: FileLoggingTree - @Inject lateinit var nightModeManager: NightModeManager - @Inject lateinit var realmMigration: QkRealmMigration - @Inject lateinit var referralManager: ReferralManager - @Inject lateinit var workerFactory: WorkerFactory + @Inject + lateinit var dispatchingActivityInjector: DispatchingAndroidInjector + @Inject + lateinit var dispatchingBroadcastReceiverInjector: DispatchingAndroidInjector + @Inject + lateinit var dispatchingServiceInjector: DispatchingAndroidInjector + @Inject + lateinit var fileLoggingTree: FileLoggingTree + @Inject + lateinit var nightModeManager: NightModeManager + @Inject + lateinit var realmMigration: QkRealmMigration + @Inject + lateinit var referralManager: ReferralManager + @Inject + lateinit var workerFactory: WorkerFactory override fun onCreate() { super.onCreate() @@ -91,8 +98,6 @@ class QKApplication : Application(), HasActivityInjector, HasBroadcastReceiverIn GlobalScope.launch(Dispatchers.IO) { referralManager.trackReferrer() - billingManager.checkForPurchases() - billingManager.queryProducts() } nightModeManager.updateCurrentTheme() diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/BillingManagerImpl.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/BillingManagerImpl.kt deleted file mode 100644 index 8d671337..00000000 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/BillingManagerImpl.kt +++ /dev/null @@ -1,21 +0,0 @@ -package dev.octoshrimpy.quik.common.util - -import android.app.Activity -import dev.octoshrimpy.quik.manager.BillingManager -import io.reactivex.Observable -import io.reactivex.subjects.BehaviorSubject -import javax.inject.Inject -import javax.inject.Singleton - -@Singleton -class BillingManagerImpl @Inject constructor( -): BillingManager { - - override val products: Observable> = BehaviorSubject.createDefault(listOf()) - override val upgradeStatus: Observable = BehaviorSubject.createDefault(true) - - override suspend fun checkForPurchases() = Unit - override suspend fun queryProducts() = Unit - override suspend fun initiatePurchaseFlow(activity: Activity, sku: String) = Unit - -} \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupController.kt index 322cc639..0e30d416 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupController.kt @@ -201,16 +201,6 @@ class BackupController : QkController R.drawable.ic_file_upload_black_24dp - false -> R.drawable.ic_star_black_24dp - }) - - binding.fabLabel.setText(when (state.upgraded) { - true -> R.string.backup_now - false -> R.string.title_qksms_plus - }) } override fun setBackupLocationClicks(): Observable<*> = binding.location.clicks() diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt index a2eaefd7..804ff626 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt @@ -27,7 +27,6 @@ import dev.octoshrimpy.quik.common.base.QkPresenter import dev.octoshrimpy.quik.common.util.DateFormatter import dev.octoshrimpy.quik.common.util.extensions.makeToast import dev.octoshrimpy.quik.interactor.PerformBackup -import dev.octoshrimpy.quik.manager.BillingManager import dev.octoshrimpy.quik.repository.BackupRepository import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.rxkotlin.plusAssign @@ -37,7 +36,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, @@ -46,111 +44,106 @@ class BackupPresenter @Inject constructor( init { disposables += backupRepo.getBackupProgress() - .sample(16, TimeUnit.MILLISECONDS) - .distinctUntilChanged() - .subscribe { progress -> newState { copy(backupProgress = progress) } } + .sample(16, TimeUnit.MILLISECONDS) + .distinctUntilChanged() + .subscribe { progress -> newState { copy(backupProgress = progress) } } disposables += backupRepo.getRestoreProgress() - .sample(16, TimeUnit.MILLISECONDS) - .distinctUntilChanged() - .subscribe { progress -> newState { copy(restoreProgress = progress) } } - - disposables += billingManager.upgradeStatus - .subscribe { upgraded -> newState { copy(upgraded = upgraded) } } + .sample(16, TimeUnit.MILLISECONDS) + .distinctUntilChanged() + .subscribe { progress -> newState { copy(restoreProgress = progress) } } } override fun bindIntents(view: BackupView) { super.bindIntents(view) view.setBackupLocationClicks() - .observeOn(AndroidSchedulers.mainThread()) - .autoDisposable(view.scope()) - .subscribe { view.selectFolder(backupRepo.getBackupPathUriForPicker()) } + .observeOn(AndroidSchedulers.mainThread()) + .autoDisposable(view.scope()) + .subscribe { view.selectFolder(backupRepo.getBackupPathUriForPicker()) } view.restoreClicks() - .withLatestFrom( - backupRepo.getBackupProgress(), - backupRepo.getRestoreProgress(), - billingManager.upgradeStatus) - { _, backupProgress, restoreProgress, upgraded -> - 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) - else -> view.selectFile(backupRepo.getBackupPathUriForPicker()) - } + .withLatestFrom( + backupRepo.getBackupProgress(), + backupRepo.getRestoreProgress(), + ) + { _, backupProgress, restoreProgress -> + when { + backupProgress.running -> context.makeToast(R.string.backup_restore_error_backup) + restoreProgress.running -> context.makeToast(R.string.backup_restore_error_restore) + else -> view.selectFile(backupRepo.getBackupPathUriForPicker()) } - .autoDisposable(view.scope()) - .subscribe() + } + .autoDisposable(view.scope()) + .subscribe() view.backupClicks() - .withLatestFrom(billingManager.upgradeStatus) { _, upgraded -> upgraded } - .autoDisposable(view.scope()) - .subscribe { upgraded -> - when { - backupRepo.getBackupDocumentTree() == null -> { - newState { copy(showLocationRationale = true) } - } - !upgraded -> navigator.showQksmsPlusActivity("backup_fab") - upgraded -> performBackup.execute(Unit) + .autoDisposable(view.scope()) + .subscribe { + when { + backupRepo.getBackupDocumentTree() == null -> newState { + copy(showLocationRationale = true) } } + performBackup.execute(Unit) + } view.locationRationaleConfirmClicks() - .doOnNext { newState { copy(showLocationRationale = false) } } - .autoDisposable(view.scope()) - .subscribe { view.selectFolder(backupRepo.getBackupPathUriForPicker()) } + .doOnNext { newState { copy(showLocationRationale = false) } } + .autoDisposable(view.scope()) + .subscribe { view.selectFolder(backupRepo.getBackupPathUriForPicker()) } view.locationRationaleCancelClicks() - .doOnNext { newState { copy(showLocationRationale = false) } } - .autoDisposable(view.scope()) - .subscribe() + .doOnNext { newState { copy(showLocationRationale = false) } } + .autoDisposable(view.scope()) + .subscribe() view.selectedBackupErrorClicks() - .autoDisposable(view.scope()) - .subscribe { newState { copy(showSelectedBackupError = false) } } + .autoDisposable(view.scope()) + .subscribe { newState { copy(showSelectedBackupError = false) } } view.confirmRestoreBackupConfirmClicks() - .doOnNext { newState { copy(selectedBackupDetails = null) } } - .withLatestFrom(view.documentSelected()) { _, backup -> backup } - .autoDisposable(view.scope()) - .subscribe { backup -> RestoreBackupService.start(context, backup) } + .doOnNext { newState { copy(selectedBackupDetails = null) } } + .withLatestFrom(view.documentSelected()) { _, backup -> backup } + .autoDisposable(view.scope()) + .subscribe { backup -> RestoreBackupService.start(context, backup) } view.confirmRestoreBackupCancelClicks() - .doOnNext { newState { copy(selectedBackupDetails = null) } } - .autoDisposable(view.scope()) - .subscribe() + .doOnNext { newState { copy(selectedBackupDetails = null) } } + .autoDisposable(view.scope()) + .subscribe() view.stopRestoreClicks() - .autoDisposable(view.scope()) - .subscribe { newState { copy(showStopRestoreDialog = true) } } + .autoDisposable(view.scope()) + .subscribe { newState { copy(showStopRestoreDialog = true) } } view.stopRestoreConfirmed() - .doOnNext { newState { copy(showStopRestoreDialog = false) } } - .autoDisposable(view.scope()) - .subscribe { backupRepo.stopRestore() } + .doOnNext { newState { copy(showStopRestoreDialog = false) } } + .autoDisposable(view.scope()) + .subscribe { backupRepo.stopRestore() } view.stopRestoreCancel() - .autoDisposable(view.scope()) - .subscribe { newState { copy(showStopRestoreDialog = false) } } + .autoDisposable(view.scope()) + .subscribe { newState { copy(showStopRestoreDialog = false) } } view.documentTreeSelected() - .autoDisposable(view.scope()) - .subscribe { uri -> backupRepo.persistBackupDirectory(uri) } + .autoDisposable(view.scope()) + .subscribe { uri -> backupRepo.persistBackupDirectory(uri) } view.documentSelected() - .observeOn(Schedulers.io()) - .autoDisposable(view.scope()) - .subscribe { uri -> - try { - val backupFile = backupRepo.parseBackup(uri) - val date = dateFormatter.getDetailedTimestamp(backupFile.date) - val details = context.getString(R.string.backup_details, date, backupFile.messages) - newState { copy(selectedBackupDetails = details) } - } catch (e: Exception) { - newState { copy(showSelectedBackupError = true) } - } + .observeOn(Schedulers.io()) + .autoDisposable(view.scope()) + .subscribe { uri -> + try { + val backupFile = backupRepo.parseBackup(uri) + val date = dateFormatter.getDetailedTimestamp(backupFile.date) + val details = + context.getString(R.string.backup_details, date, backupFile.messages) + newState { copy(selectedBackupDetails = details) } + } catch (e: Exception) { + newState { copy(showSelectedBackupError = true) } } + } } } \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupState.kt index fe5347c4..da67a24b 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupState.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupState.kt @@ -28,6 +28,4 @@ data class BackupState( val showSelectedBackupError: Boolean = false, val selectedBackupDetails: String? = null, val showStopRestoreDialog: Boolean = false, - - val upgraded: Boolean = true ) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt index 7afefc01..8c2eebe2 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt @@ -135,8 +135,12 @@ class ComposeActivity : QkThemedActivity(), ComposeView { override val scheduleSelectedIntent: Subject = PublishSubject.create() override val changeSimIntent by lazy { binding.sim.clicks() } override val scheduleCancelIntent by lazy { binding.scheduledCancel.clicks() } - override val sendIntent by lazy { Observable.merge(binding.send.clicks(), binding.scheduledSend.clicks()) } - override val viewQksmsPlusIntent: Subject = PublishSubject.create() + override val sendIntent by lazy { + Observable.merge( + binding.send.clicks(), + binding.scheduledSend.clicks() + ) + } override val backPressedIntent: Subject = PublishSubject.create() override val confirmDeleteIntent: Subject> = PublishSubject.create() override val clearCurrentMessageIntent: Subject = PublishSubject.create() @@ -727,13 +731,6 @@ class ComposeActivity : QkThemedActivity(), ComposeView { ?.let(binding.messageList::scrollToPosition) } - override fun showQksmsPlusSnackbar(message: Int) { - Snackbar.make(binding.contentView, message, Snackbar.LENGTH_LONG).run { - setAction(R.string.button_more) { viewQksmsPlusIntent.onNext(Unit) } - setActionTextColor(colors.theme().theme) - show() - } - } override fun showDeleteDialog(messages: List) { val count = messages.size diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt index b2b049ca..f10c1d85 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt @@ -70,7 +70,6 @@ interface ComposeView : QkView { val scheduleCancelIntent: Observable<*> val changeSimIntent: Observable<*> val sendIntent: Observable - val viewQksmsPlusIntent: Subject val backPressedIntent: Observable val confirmDeleteIntent: Observable> val clearCurrentMessageIntent: Subject @@ -108,8 +107,7 @@ interface ComposeView : QkView { fun requestContact() fun setDraft(draft: String) fun scrollToMessage(id: Long) - fun showQksmsPlusSnackbar(@StringRes message: Int) - fun showDeleteDialog( messages: List) + fun showDeleteDialog(messages: List) fun showClearCurrentMessageDialog() fun showReactionsDialog(reactions: List) fun startSpeechRecognition() diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt index 73bdc0f5..0507be0f 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt @@ -62,7 +62,6 @@ import dev.octoshrimpy.quik.interactor.SendExistingMessage import dev.octoshrimpy.quik.interactor.SaveImage import dev.octoshrimpy.quik.interactor.SendNewMessage import dev.octoshrimpy.quik.manager.ActiveConversationManager -import dev.octoshrimpy.quik.manager.BillingManager import dev.octoshrimpy.quik.manager.PermissionManager import dev.octoshrimpy.quik.model.Attachment import dev.octoshrimpy.quik.model.Conversation @@ -112,7 +111,6 @@ class ComposeViewModel @Inject constructor( private val context: Context, private val activeConversationManager: ActiveConversationManager, private val addScheduledMessage: AddScheduledMessage, - private val billingManager: BillingManager, private val actionDelayedMessage: ActionDelayedMessage, private val conversationRepo: ConversationRepository, private val deleteMessages: DeleteMessages, @@ -846,13 +844,9 @@ 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() } + .doOnNext { newState { copy(attaching = false) } } + .autoDisposable(view.scope()) + .subscribe { view.requestDatePicker() } view.scheduleAction .take(1) @@ -1259,11 +1253,6 @@ class ComposeViewModel @Inject constructor( .autoDisposable(view.scope()) .subscribe() - // View QKSMS+ - view.viewQksmsPlusIntent - .autoDisposable(view.scope()) - .subscribe { navigator.showQksmsPlusActivity("compose_schedule") } - // Navigate back view.optionsItemIntent .filter { it == android.R.id.home } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt index 0d622bee..4a0af4e7 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt @@ -94,7 +94,8 @@ class MainActivity : QkThemedActivity(), MainView { } override val homeIntent: Subject = PublishSubject.create() override val navigationIntent: Observable by lazy { - Observable.merge(listOf( + Observable.merge( + listOf( backPressedSubject, binding.drawer.inbox.clicks().map { NavItem.INBOX }, binding.drawer.archived.clicks().map { NavItem.ARCHIVED }, @@ -104,12 +105,10 @@ class MainActivity : QkThemedActivity(), MainView { binding.drawer.messageUtils.clicks().map { NavItem.MESSAGE_UTILS }, binding.drawer.settings.clicks().map { NavItem.SETTINGS }, binding.drawer.about.clicks().map { NavItem.ABOUT }, -// plus.clicks().map { NavItem.PLUS }, -// help.clicks().map { NavItem.HELP }, - binding.drawer.invite.clicks().map { NavItem.INVITE })) + binding.drawer.invite.clicks().map { NavItem.INVITE }) + ) } override val optionsItemIntent: Subject = PublishSubject.create() -// override val plusBannerIntent by lazy { plusBanner.clicks() } override val dismissRatingIntent by lazy { binding.drawer.rateDismiss.clicks() } override val rateIntent by lazy { binding.drawer.rateOkay.clicks() } override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges } @@ -187,16 +186,13 @@ class MainActivity : QkThemedActivity(), MainView { binding.drawer.archivedIcon.imageTintList = tintList } - // Miscellaneous views - listOf(binding.drawer.plusBadge1, binding.drawer.plusBadge2).forEach { badge -> - badge.setBackgroundTint(theme.theme) - badge.setTextColor(theme.textPrimary) - } - syncingBinding.syncingProgress.progressTintList = ColorStateList.valueOf(theme.theme) - syncingBinding.syncingProgress.indeterminateTintList = ColorStateList.valueOf(theme.theme) - binding.drawer.plusIcon.setTint(theme.theme) - binding.drawer.rateIcon.setTint(theme.theme) - binding.compose.setBackgroundTint(theme.theme) + // Miscellaneous views + syncingBinding.syncingProgress.progressTintList = + ColorStateList.valueOf(theme.theme) + syncingBinding.syncingProgress.indeterminateTintList = + ColorStateList.valueOf(theme.theme) + binding.drawer.rateIcon.setTint(theme.theme) + binding.compose.setBackgroundTint(theme.theme) // Set the FAB compose icon color binding.compose.setTint(theme.textPrimary) @@ -266,11 +262,6 @@ class MainActivity : QkThemedActivity(), MainView { findItem(R.id.rename)?.isVisible = selectedConversations == 1 } - listOf(binding.drawer.plusBadge1, binding.drawer.plusBadge2).forEach { badge -> - badge.isVisible = drawerBadgesExperiment.variant && !state.upgraded - } -// plus.isVisible = state.upgraded - binding.drawer.plusBanner.isVisible = !state.upgraded binding.drawer.rateLayout.setVisible(state.showRating) binding.compose.setVisible(state.page is Inbox || state.page is Archived) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainState.kt index d7479139..18860753 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainState.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainState.kt @@ -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, diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt index 837a4246..24a29325 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainView.kt @@ -33,7 +33,6 @@ interface MainView : QkView { val homeIntent: Observable<*> val navigationIntent: Observable val optionsItemIntent: Observable -// val plusBannerIntent: Observable<*> val dismissRatingIntent: Observable<*> val rateIntent: Observable<*> val conversationsSelectedIntent: Observable> @@ -58,4 +57,4 @@ interface MainView : QkView { fun drawerToggled(opened: Boolean) } -enum class NavItem { BACK, INBOX, ARCHIVED, BACKUP, SCHEDULED, BLOCKING, MESSAGE_UTILS, SETTINGS, ABOUT, PLUS, HELP, INVITE } +enum class NavItem { BACK, INBOX, ARCHIVED, BACKUP, SCHEDULED, BLOCKING, MESSAGE_UTILS, SETTINGS, ABOUT, INVITE } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt index df918bec..cc97298c 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt @@ -39,7 +39,6 @@ import dev.octoshrimpy.quik.interactor.SpeakThreads import dev.octoshrimpy.quik.interactor.SyncContacts import dev.octoshrimpy.quik.interactor.SyncMessages import dev.octoshrimpy.quik.listener.ContactAddedListener -import dev.octoshrimpy.quik.manager.BillingManager import dev.octoshrimpy.quik.manager.ChangelogManager import dev.octoshrimpy.quik.manager.PermissionManager import dev.octoshrimpy.quik.manager.RatingManager @@ -63,7 +62,6 @@ import java.util.concurrent.TimeUnit import javax.inject.Inject class MainViewModel @Inject constructor( - billingManager: BillingManager, contactAddedListener: ContactAddedListener, markAllSeen: MarkAllSeen, migratePreferences: MigratePreferences, @@ -104,13 +102,9 @@ class MainViewModel @Inject constructor( // Show the syncing UI disposables += syncRepository.syncProgress - .sample(16, TimeUnit.MILLISECONDS) - .distinctUntilChanged() - .subscribe { syncing -> newState { copy(syncing = syncing) } } - - // Update the upgraded status - disposables += billingManager.upgradeStatus - .subscribe { upgraded -> newState { copy(upgraded = upgraded) } } + .sample(16, TimeUnit.MILLISECONDS) + .distinctUntilChanged() + .subscribe { syncing -> newState { copy(syncing = syncing) } } // Show the rating UI disposables += ratingManager.shouldShowRating @@ -328,42 +322,69 @@ class MainViewModel @Inject constructor( .subscribe { open -> newState { copy(drawerOpen = open) } } view.navigationIntent - .withLatestFrom(state) { drawerItem, state -> - newState { copy(drawerOpen = false) } - when (drawerItem) { - NavItem.BACK -> when { - state.drawerOpen -> Unit - state.page is Searching -> view.clearSearch() - state.page is Inbox && state.page.selected > 0 -> view.clearSelection() - state.page is Archived && state.page.selected > 0 -> view.clearSelection() - state.page !is Inbox -> { - newState { copy(page = Inbox(data = conversationRepo.getConversations(prefs.unreadAtTop.get()))) } + .withLatestFrom(state) { drawerItem, state -> + newState { copy(drawerOpen = false) } + when (drawerItem) { + NavItem.BACK -> when { + state.drawerOpen -> Unit + state.page is Searching -> view.clearSearch() + state.page is Inbox && state.page.selected > 0 -> view.clearSelection() + state.page is Archived && state.page.selected > 0 -> view.clearSelection() + state.page !is Inbox -> { + newState { + copy( + page = Inbox( + data = conversationRepo.getConversations( + prefs.unreadAtTop.get() + ) + ) + ) } - else -> newState { copy(hasError = true) } } - NavItem.BACKUP -> navigator.showBackup() - NavItem.SCHEDULED -> navigator.showScheduled(null) - NavItem.BLOCKING -> navigator.showBlockedConversations() - NavItem.MESSAGE_UTILS -> navigator.showMessageUtils() - NavItem.SETTINGS -> navigator.showSettings() - NavItem.ABOUT -> navigator.showAbout() -// NavItem.PLUS -> navigator.showQksmsPlusActivity("main_menu") -// NavItem.HELP -> navigator.showSupport() - NavItem.INVITE -> externalNavigator.showInvite() - else -> Unit + + else -> newState { copy(hasError = true) } } - drawerItem + + NavItem.BACKUP -> navigator.showBackup() + NavItem.SCHEDULED -> navigator.showScheduled(null) + NavItem.BLOCKING -> navigator.showBlockedConversations() + NavItem.MESSAGE_UTILS -> navigator.showMessageUtils() + NavItem.SETTINGS -> navigator.showSettings() + NavItem.ABOUT -> navigator.showAbout() + NavItem.INVITE -> externalNavigator.showInvite() + else -> Unit } - .distinctUntilChanged() - .doOnNext { drawerItem -> - when (drawerItem) { - NavItem.INBOX -> newState { copy(page = Inbox(data = conversationRepo.getConversations(prefs.unreadAtTop.get()))) } - NavItem.ARCHIVED -> newState { copy(page = Archived(data = conversationRepo.getConversations(prefs.unreadAtTop.get(), true))) } - else -> Unit + drawerItem + } + .distinctUntilChanged() + .doOnNext { drawerItem -> + when (drawerItem) { + NavItem.INBOX -> newState { + copy( + page = Inbox( + data = conversationRepo.getConversations( + prefs.unreadAtTop.get() + ) + ) + ) } + + NavItem.ARCHIVED -> newState { + copy( + page = Archived( + data = conversationRepo.getConversations( + prefs.unreadAtTop.get(), + true + ) + ) + ) + } + + else -> Unit } - .autoDisposable(view.scope()) - .subscribe() + } + .autoDisposable(view.scope()) + .subscribe() view.optionsItemIntent .filter { itemId -> itemId == R.id.select_all } @@ -467,13 +488,6 @@ class MainViewModel @Inject constructor( .autoDisposable(view.scope()) .subscribe { conversation -> view.showRenameDialog(conversation.name) } -// view.plusBannerIntent -// .autoDisposable(view.scope()) -// .subscribe { -// newState { copy(drawerOpen = false) } -// navigator.showQksmsPlusActivity("main_banner") -// } - view.rateIntent .autoDisposable(view.scope()) .subscribe { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivity.kt deleted file mode 100644 index 5ed78709..00000000 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivity.kt +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2017 Moez Bhatti - * - * 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 . - */ -package dev.octoshrimpy.quik.feature.plus - -import android.graphics.Typeface -import android.os.Bundle -import androidx.core.view.children -import androidx.lifecycle.ViewModelProvider -import androidx.lifecycle.ViewModelProviders -import com.jakewharton.rxbinding2.view.clicks -import dagger.android.AndroidInjection -import dev.octoshrimpy.quik.R -import dev.octoshrimpy.quik.common.base.QkThemedActivity -import dev.octoshrimpy.quik.common.util.FontProvider -import dev.octoshrimpy.quik.common.util.extensions.makeToast -import dev.octoshrimpy.quik.common.util.extensions.resolveThemeColor -import dev.octoshrimpy.quik.common.util.extensions.setBackgroundTint -import dev.octoshrimpy.quik.common.util.extensions.setTint -import dev.octoshrimpy.quik.common.util.extensions.setVisible -import dev.octoshrimpy.quik.common.widget.PreferenceView -import dev.octoshrimpy.quik.feature.plus.experiment.UpgradeButtonExperiment -import dev.octoshrimpy.quik.manager.BillingManager -import dev.octoshrimpy.quik.databinding.QksmsPlusActivityBinding -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import timber.log.Timber -import javax.inject.Inject - -class PlusActivity : QkThemedActivity(), PlusView { - - @Inject lateinit var fontProvider: FontProvider - @Inject lateinit var upgradeButtonExperiment: UpgradeButtonExperiment - @Inject lateinit var viewModelFactory: ViewModelProvider.Factory - - private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[PlusViewModel::class.java] } - private lateinit var binding: QksmsPlusActivityBinding - - override val upgradeIntent get() = binding.upgrade.clicks() - override val upgradeDonateIntent get() = binding.upgradeDonate.clicks() - override val donateIntent get() = binding.donate.clicks() - override val themeClicks get() = binding.themes.clicks() - override val scheduleClicks get() = binding.schedule.clicks() - override val backupClicks get() = binding.backup.clicks() - override val delayedClicks get() = binding.delayed.clicks() - override val nightClicks get() = binding.night.clicks() - - override fun onCreate(savedInstanceState: Bundle?) { - AndroidInjection.inject(this) - super.onCreate(savedInstanceState) - binding = QksmsPlusActivityBinding.inflate(layoutInflater) - setContentView(binding.root) - setTitle(R.string.title_qksms_plus) - showBackButton(true) - viewModel.bindView(this) - - binding.free.setVisible(false) - - if (!prefs.systemFont.get()) { - fontProvider.getLato { lato -> - val typeface = Typeface.create(lato, Typeface.BOLD) - binding.toolbarLayout.collapsingToolbar.setCollapsedTitleTypeface(typeface) - binding.toolbarLayout.collapsingToolbar.setExpandedTitleTypeface(typeface) - } - } - - // Make the list titles bold - binding.linearLayout.children - .mapNotNull { it as? PreferenceView } - .map { it.titleView } - .forEach { it.setTypeface(it.typeface, Typeface.BOLD) } - - val textPrimary = resolveThemeColor(android.R.attr.textColorPrimary) - binding.toolbarLayout.collapsingToolbar.setCollapsedTitleTextColor(textPrimary) - binding.toolbarLayout.collapsingToolbar.setExpandedTitleColor(textPrimary) - - val theme = colors.theme().theme - binding.donate.setBackgroundTint(theme) - binding.upgrade.setBackgroundTint(theme) - binding.thanksIcon.setTint(theme) - } - - override fun render(state: PlusState) { - binding.description.text = getString(R.string.qksms_plus_description_summary, state.upgradePrice) - binding.upgrade.text = getString(upgradeButtonExperiment.variant, state.upgradePrice, state.currency) - binding.upgradeDonate.text = getString(R.string.qksms_plus_upgrade_donate, state.upgradeDonatePrice, state.currency) - - val fdroid = true - - binding.free.setVisible(fdroid) - binding.toUpgrade.setVisible(!fdroid && !state.upgraded) - binding.upgraded.setVisible(!fdroid && state.upgraded) - - binding.themes.isEnabled = state.upgraded - binding.schedule.isEnabled = state.upgraded - binding.backup.isEnabled = state.upgraded - binding.delayed.isEnabled = state.upgraded - binding.night.isEnabled = state.upgraded - } - - override fun initiatePurchaseFlow(billingManager: BillingManager, sku: String) { - GlobalScope.launch(Dispatchers.Main) { - try { - billingManager.initiatePurchaseFlow(this@PlusActivity, sku) - } catch (e: Exception) { - Timber.w(e) - makeToast(R.string.qksms_plus_error) - } - } - } - -} diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivityModule.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivityModule.kt deleted file mode 100644 index b1ec4d7b..00000000 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivityModule.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2017 Moez Bhatti - * - * 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 . - */ -package dev.octoshrimpy.quik.feature.plus - -import androidx.lifecycle.ViewModel -import dagger.Module -import dagger.Provides -import dagger.multibindings.IntoMap -import dev.octoshrimpy.quik.injection.ViewModelKey - -@Module -class PlusActivityModule { - - @Provides - @IntoMap - @ViewModelKey(PlusViewModel::class) - fun providePlusViewModel(viewModel: PlusViewModel): ViewModel = viewModel - -} \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusState.kt deleted file mode 100644 index 42cd8aaf..00000000 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusState.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 Moez Bhatti - * - * 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 . - */ -package dev.octoshrimpy.quik.feature.plus - -data class PlusState( - val upgraded: Boolean = true, - val upgradePrice: String = "", - val upgradeDonatePrice: String = "", - val currency: String = "" -) \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusView.kt deleted file mode 100644 index 8788f29a..00000000 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusView.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2017 Moez Bhatti - * - * 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 . - */ -package dev.octoshrimpy.quik.feature.plus - -import dev.octoshrimpy.quik.common.base.QkView -import dev.octoshrimpy.quik.manager.BillingManager -import io.reactivex.Observable - -interface PlusView : QkView { - - val upgradeIntent: Observable - val upgradeDonateIntent: Observable - val donateIntent: Observable<*> - val themeClicks: Observable<*> - val scheduleClicks: Observable<*> - val backupClicks: Observable<*> - val delayedClicks: Observable<*> - val nightClicks: Observable<*> - - fun initiatePurchaseFlow(billingManager: BillingManager, sku: String) - -} \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusViewModel.kt deleted file mode 100644 index 8f84e6cc..00000000 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusViewModel.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2017 Moez Bhatti - * - * 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 . - */ -package dev.octoshrimpy.quik.feature.plus - -import com.uber.autodispose.android.lifecycle.scope -import com.uber.autodispose.autoDisposable -import dev.octoshrimpy.quik.common.Navigator -import dev.octoshrimpy.quik.common.base.QkViewModel -import dev.octoshrimpy.quik.manager.BillingManager -import io.reactivex.Observable -import io.reactivex.rxkotlin.plusAssign -import javax.inject.Inject - -class PlusViewModel @Inject constructor( - private val billingManager: BillingManager, - private val navigator: Navigator -) : QkViewModel(PlusState()) { - - init { - disposables += billingManager.upgradeStatus - .subscribe { upgraded -> newState { copy(upgraded = upgraded) } } - - disposables += billingManager.products - .subscribe { products -> - newState { - val upgrade = products.firstOrNull { it.sku == BillingManager.SKU_PLUS } - val upgradeDonate = products.firstOrNull { it.sku == BillingManager.SKU_PLUS_DONATE } - copy(upgradePrice = upgrade?.price ?: "", upgradeDonatePrice = upgradeDonate?.price ?: "", - currency = upgrade?.priceCurrencyCode ?: upgradeDonate?.priceCurrencyCode ?: "") - } - } - } - - override fun bindView(view: PlusView) { - super.bindView(view) - - Observable.merge( - view.upgradeIntent.map { BillingManager.SKU_PLUS }, - view.upgradeDonateIntent.map { BillingManager.SKU_PLUS_DONATE }) - .autoDisposable(view.scope()) - .subscribe { sku -> view.initiatePurchaseFlow(billingManager, sku) } - -// view.donateIntent -// .autoDisposable(view.scope()) -// .subscribe { navigator.showDonation() } - - view.themeClicks - .autoDisposable(view.scope()) - .subscribe { navigator.showSettings() } - - view.scheduleClicks - .autoDisposable(view.scope()) - .subscribe { navigator.showScheduled(null) } - - view.backupClicks - .autoDisposable(view.scope()) - .subscribe { navigator.showBackup() } - - view.delayedClicks - .autoDisposable(view.scope()) - .subscribe { navigator.showSettings() } - - view.nightClicks - .autoDisposable(view.scope()) - .subscribe { navigator.showSettings() } - } - -} diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/experiment/UpgradeButtonExperiment.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/experiment/UpgradeButtonExperiment.kt deleted file mode 100644 index eee7cc1b..00000000 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/experiment/UpgradeButtonExperiment.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2017 Moez Bhatti - * - * 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 . - */ -package dev.octoshrimpy.quik.feature.plus.experiment - -import android.content.Context -import dev.octoshrimpy.quik.R -import dev.octoshrimpy.quik.experiment.Experiment -import dev.octoshrimpy.quik.experiment.Variant -import javax.inject.Inject - -class UpgradeButtonExperiment @Inject constructor( - context: Context, -) : Experiment(context) { - - override val key: String = "Upgrade Button" - - override val variants: List> = listOf( - Variant("variant_a", R.string.qksms_plus_upgrade), - Variant("variant_b", R.string.qksms_plus_upgrade_b), - Variant("variant_c", R.string.qksms_plus_upgrade_c), - Variant("variant_d", R.string.qksms_plus_upgrade_d)) - - override val default: Int = R.string.qksms_plus_upgrade - -} \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledActivity.kt index ce8aa19d..b0518817 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledActivity.kt @@ -41,11 +41,12 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView { private lateinit var binding: ScheduledActivityBinding - @Inject lateinit var scheduledMessageAdapter: ScheduledMessageAdapter - @Inject lateinit var viewModelFactory: ViewModelProvider.Factory + @Inject + lateinit var scheduledMessageAdapter: ScheduledMessageAdapter + @Inject + lateinit var viewModelFactory: ViewModelProvider.Factory override val composeIntent by lazy { binding.compose.clicks() } - override val upgradeIntent by lazy { binding.upgrade.clicks() } override val messagesSelectedIntent by lazy { scheduledMessageAdapter.selectionChanges } override val optionsItemIntent: Subject = PublishSubject.create() override val deleteScheduledMessages: Subject> = PublishSubject.create() @@ -74,20 +75,20 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView { binding.sampleMessage.setTextColor(theme.textPrimary) binding.compose.setTint(theme.textPrimary) binding.compose.setBackgroundTint(theme.theme) - binding.upgrade.setBackgroundTint(theme.theme) - binding.upgradeIcon.setTint(theme.textPrimary) - binding.upgradeLabel.setTextColor(theme.textPrimary) } } override fun render(state: ScheduledState) { scheduledMessageAdapter.updateData(state.scheduledMessages) - setTitle(when { - (state.selectedMessages > 0) -> - getString(R.string.compose_title_selected, state.selectedMessages) - else -> getString(R.string.scheduled_title) - }) + setTitle( + when { + (state.selectedMessages > 0) -> + getString(R.string.compose_title_selected, state.selectedMessages) + + else -> getString(R.string.scheduled_title) + } + ) // show/hide menu items toolbar?.menu?.findItem(R.id.select_all)?.isVisible = @@ -102,8 +103,7 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView { ((scheduledMessageAdapter.itemCount != 0) && (state.selectedMessages == 1)) // show compose button - binding.compose.isVisible = state.upgraded && (state.conversationId == null) - binding.upgrade.isVisible = !state.upgraded + binding.compose.isVisible = state.conversationId == null } override fun onBackPressed() = backPressedIntent.onNext(Unit) @@ -117,7 +117,11 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView { AlertDialog.Builder(this) .setTitle(R.string.dialog_delete_title) .setMessage(resources.getQuantityString(R.plurals.dialog_delete_chat, count, count)) - .setPositiveButton(R.string.button_delete) { _, _ -> deleteScheduledMessages.onNext(messages) } + .setPositiveButton(R.string.button_delete) { _, _ -> + deleteScheduledMessages.onNext( + messages + ) + } .setNegativeButton(R.string.button_cancel, null) .show() } @@ -127,7 +131,11 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView { AlertDialog.Builder(this) .setTitle(R.string.main_menu_send_now) .setMessage(resources.getQuantityString(R.plurals.dialog_send_now, count, count)) - .setPositiveButton(R.string.main_menu_send_now) { _, _ -> sendScheduledMessages.onNext(messages) } + .setPositiveButton(R.string.main_menu_send_now) { _, _ -> + sendScheduledMessages.onNext( + messages + ) + } .setNegativeButton(R.string.button_cancel, null) .show() } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledState.kt index 25b790e7..be7f91ec 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledState.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledState.kt @@ -23,7 +23,6 @@ import io.realm.RealmResults data class ScheduledState( val scheduledMessages: RealmResults? = null, - val upgraded: Boolean = true, val selectedMessages: Int = 0, val conversationId: Long? = null, ) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledView.kt index 2ca1b2ea..77c5208d 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledView.kt @@ -24,7 +24,6 @@ import io.reactivex.Observable interface ScheduledView : QkView { val composeIntent: Observable<*> - val upgradeIntent: Observable<*> val messagesSelectedIntent: Observable> val optionsItemIntent: Observable val deleteScheduledMessages: Observable> diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledViewModel.kt index 3a8d627e..35492046 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledViewModel.kt @@ -9,7 +9,6 @@ import dev.octoshrimpy.quik.common.base.QkViewModel import dev.octoshrimpy.quik.common.util.ClipboardUtils import dev.octoshrimpy.quik.interactor.DeleteScheduledMessages import dev.octoshrimpy.quik.interactor.SendScheduledMessage -import dev.octoshrimpy.quik.manager.BillingManager import dev.octoshrimpy.quik.repository.ScheduledMessageRepository import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.rxkotlin.plusAssign @@ -19,7 +18,6 @@ import javax.inject.Named class ScheduledViewModel @Inject constructor( @Named("conversationId") private val conversationId: Long?, - billingManager: BillingManager, private val context: Context, private val navigator: Navigator, private val scheduledMessageRepo: ScheduledMessageRepository, @@ -32,8 +30,6 @@ class ScheduledViewModel @Inject constructor( init { loadMessages(conversationId) - disposables += billingManager.upgradeStatus - .subscribe { upgraded -> newState { copy(upgraded = upgraded) } } } override fun bindView(view: ScheduledView) { @@ -159,10 +155,6 @@ class ScheduledViewModel @Inject constructor( navigator.showCompose(mode = "scheduling") view.clearSelection() } - - view.upgradeIntent - .autoDisposable(view.scope()) - .subscribe { navigator.showQksmsPlusActivity("schedule_fab") } } private fun loadMessages(conversationId: Long?) { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt index 07e55208..23962f12 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt @@ -76,7 +76,6 @@ class SettingsController : QkController = PublishSubject.create() private val startTimeSelectedSubject: Subject> = PublishSubject.create() private val endTimeSelectedSubject: Subject> = PublishSubject.create() private val signatureSubject: Subject = PublishSubject.create() @@ -124,8 +123,6 @@ class SettingsController : QkController = binding.about.longClicks() - override fun viewQksmsPlusClicks(): Observable<*> = viewQksmsPlusSubject - override fun nightModeSelected(): Observable = nightModeDialog.adapter.menuItemClicks override fun nightStartSelected(): Observable> = startTimeSelectedSubject @@ -207,16 +204,6 @@ class SettingsController : QkController -// if (!upgraded && mode == Preferences.NIGHT_MODE_AUTO) { -// view.showQksmsPlusSnackbar() -// } else { - nightModeManager.updateNightMode(mode) -// } - } - .autoDisposable(view.scope()) - .subscribe() - - view.viewQksmsPlusClicks() - .autoDisposable(view.scope()) - .subscribe { navigator.showQksmsPlusActivity("settings_night") } + .autoDisposable(view.scope()) + .subscribe { nightModeManager.updateNightMode(it) } view.nightStartSelected() .autoDisposable(view.scope()) @@ -263,15 +250,8 @@ class SettingsPresenter @Inject constructor( .subscribe(prefs.textSize::set) view.sendDelaySelected() - .withLatestFrom(billingManager.upgradeStatus) { duration, upgraded -> -// if (!upgraded && duration != 0) { -// view.showQksmsPlusSnackbar() -// } else { - prefs.sendDelay.set(duration) -// } - } - .autoDisposable(view.scope()) - .subscribe() + .autoDisposable(view.scope()) + .subscribe { prefs.sendDelay.set(it) } view.signatureChanged() .doOnNext(prefs.signature::set) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsView.kt index b0670047..72b32d3a 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsView.kt @@ -25,7 +25,6 @@ import io.reactivex.Observable interface SettingsView : QkViewContract { fun preferenceClicks(): Observable fun aboutLongClicks(): Observable<*> - fun viewQksmsPlusClicks(): Observable<*> fun nightModeSelected(): Observable fun nightStartSelected(): Observable> fun nightEndSelected(): Observable> @@ -35,7 +34,6 @@ interface SettingsView : QkViewContract { fun mmsSizeSelected(): Observable fun messageLinkHandlingSelected(): Observable - fun showQksmsPlusSnackbar() fun showNightModeDialog() fun showStartTimePicker(hour: Int, minute: Int) fun showEndTimePicker(hour: Int, minute: Int) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerController.kt index 1bc1ea26..7cc2f8ee 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerController.kt @@ -48,11 +48,13 @@ class ThemePickerController( @Inject override lateinit var presenter: ThemePickerPresenter - @Inject lateinit var colors: Colors - @Inject lateinit var themeAdapter: ThemeAdapter - @Inject lateinit var themePagerAdapter: ThemePagerAdapter + @Inject + lateinit var colors: Colors - private val viewQksmsPlusSubject: Subject = PublishSubject.create() + @Inject + lateinit var themeAdapter: ThemeAdapter + @Inject + lateinit var themePagerAdapter: ThemePagerAdapter init { appComponent @@ -92,14 +94,6 @@ class ThemePickerController( } } - override fun showQksmsPlusSnackbar() { - Snackbar.make(binding.contentView, R.string.toast_qksms_plus, Snackbar.LENGTH_LONG).run { - setAction(R.string.button_more) { viewQksmsPlusSubject.onNext(Unit) } - setActionTextColor(colors.theme().theme) - show() - } - } - override fun themeSelected(): Observable = themeAdapter.colorSelected override fun hsvThemeSelected(): Observable = binding.hsvPicker.picker.selectedColor @@ -108,8 +102,6 @@ class ThemePickerController( override fun applyHsvThemeClicks(): Observable<*> = binding.hsvPicker.apply.clicks() - override fun viewQksmsPlusClicks(): Observable<*> = viewQksmsPlusSubject - override fun render(state: ThemePickerState) { binding.tabs.setRecipientId(state.recipientId) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerPresenter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerPresenter.kt index 7c7ab313..86a94901 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerPresenter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerPresenter.kt @@ -24,7 +24,6 @@ import com.uber.autodispose.autoDisposable import dev.octoshrimpy.quik.common.Navigator import dev.octoshrimpy.quik.common.base.QkPresenter import dev.octoshrimpy.quik.common.util.Colors -import dev.octoshrimpy.quik.manager.BillingManager import dev.octoshrimpy.quik.manager.WidgetManager import dev.octoshrimpy.quik.util.Preferences import io.reactivex.rxkotlin.Observables @@ -34,7 +33,6 @@ import javax.inject.Named class ThemePickerPresenter @Inject constructor( prefs: Preferences, @Named("recipientId") private val recipientId: Long, - private val billingManager: BillingManager, private val colors: Colors, private val navigator: Navigator, private val widgetManager: WidgetManager @@ -74,24 +72,14 @@ 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 (recipientId == 0L) { - widgetManager.updateTheme() - } - } + .withLatestFrom(view.hsvThemeSelected()) { _, color -> + theme.set(color) + if (recipientId == 0L) { + widgetManager.updateTheme() } - .autoDisposable(view.scope()) - .subscribe() - - // Show QKSMS+ activity - view.viewQksmsPlusClicks() - .autoDisposable(view.scope()) - .subscribe { navigator.showQksmsPlusActivity("settings_theme") } + } + .autoDisposable(view.scope()) + .subscribe() // Reset the theme view.clearHsvThemeClicks() diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerView.kt index eeac4d5f..faf873eb 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerView.kt @@ -27,9 +27,7 @@ interface ThemePickerView : QkViewContract { fun hsvThemeSelected(): Observable fun clearHsvThemeClicks(): Observable<*> fun applyHsvThemeClicks(): Observable<*> - fun viewQksmsPlusClicks(): Observable<*> fun setCurrentTheme(color: Int) - fun showQksmsPlusSnackbar() } \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/injection/AppModule.kt b/presentation/src/main/java/com/moez/QKSMS/injection/AppModule.kt index 8d52fe2f..a9bd0ee8 100644 --- a/presentation/src/main/java/com/moez/QKSMS/injection/AppModule.kt +++ b/presentation/src/main/java/com/moez/QKSMS/injection/AppModule.kt @@ -33,7 +33,6 @@ import dagger.Provides import dev.octoshrimpy.quik.blocking.BlockingClient import dev.octoshrimpy.quik.blocking.BlockingManager import dev.octoshrimpy.quik.common.ViewModelFactory -import dev.octoshrimpy.quik.common.util.BillingManagerImpl import dev.octoshrimpy.quik.common.util.NotificationManagerImpl import dev.octoshrimpy.quik.common.util.ShortcutManagerImpl import dev.octoshrimpy.quik.feature.conversationinfo.injection.ConversationInfoComponent @@ -44,7 +43,6 @@ import dev.octoshrimpy.quik.manager.ActiveConversationManager import dev.octoshrimpy.quik.manager.ActiveConversationManagerImpl import dev.octoshrimpy.quik.manager.AlarmManager import dev.octoshrimpy.quik.manager.AlarmManagerImpl -import dev.octoshrimpy.quik.manager.BillingManager import dev.octoshrimpy.quik.manager.ChangelogManager import dev.octoshrimpy.quik.manager.ChangelogManagerImpl import dev.octoshrimpy.quik.manager.KeyManager @@ -137,10 +135,8 @@ class AppModule(private var application: Application) { // Manager @Provides - fun provideBillingManager(manager: BillingManagerImpl): BillingManager = manager - - @Provides - fun provideActiveConversationManager(manager: ActiveConversationManagerImpl): ActiveConversationManager = manager + fun provideActiveConversationManager(manager: ActiveConversationManagerImpl): ActiveConversationManager = + manager @Provides fun provideAlarmManager(manager: AlarmManagerImpl): AlarmManager = manager diff --git a/presentation/src/main/java/com/moez/QKSMS/injection/android/ActivityBuilderModule.kt b/presentation/src/main/java/com/moez/QKSMS/injection/android/ActivityBuilderModule.kt index 80b400b4..287c8f72 100644 --- a/presentation/src/main/java/com/moez/QKSMS/injection/android/ActivityBuilderModule.kt +++ b/presentation/src/main/java/com/moez/QKSMS/injection/android/ActivityBuilderModule.kt @@ -34,8 +34,6 @@ import dev.octoshrimpy.quik.feature.main.MainActivityModule import dev.octoshrimpy.quik.feature.messageutils.MessageUtilsActivity import dev.octoshrimpy.quik.feature.notificationprefs.NotificationPrefsActivity import dev.octoshrimpy.quik.feature.notificationprefs.NotificationPrefsActivityModule -import dev.octoshrimpy.quik.feature.plus.PlusActivity -import dev.octoshrimpy.quik.feature.plus.PlusActivityModule import dev.octoshrimpy.quik.feature.qkreply.QkReplyActivity import dev.octoshrimpy.quik.feature.qkreply.QkReplyActivityModule import dev.octoshrimpy.quik.feature.scheduled.ScheduledActivity @@ -51,10 +49,6 @@ abstract class ActivityBuilderModule { @ContributesAndroidInjector(modules = [MainActivityModule::class]) abstract fun bindMainActivity(): MainActivity - @ActivityScope - @ContributesAndroidInjector(modules = [PlusActivityModule::class]) - abstract fun bindPlusActivity(): PlusActivity - @ActivityScope @ContributesAndroidInjector(modules = []) abstract fun bindBackupActivity(): BackupActivity diff --git a/presentation/src/main/res/layout/backup_controller.xml b/presentation/src/main/res/layout/backup_controller.xml index a0a3e9ea..943dbafe 100644 --- a/presentation/src/main/res/layout/backup_controller.xml +++ b/presentation/src/main/res/layout/backup_controller.xml @@ -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" /> diff --git a/presentation/src/main/res/layout/drawer_view.xml b/presentation/src/main/res/layout/drawer_view.xml index b44cf461..d97ec0d8 100644 --- a/presentation/src/main/res/layout/drawer_view.xml +++ b/presentation/src/main/res/layout/drawer_view.xml @@ -83,18 +83,6 @@ style="@style/DrawerText" android:text="@string/backup_title" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -236,66 +182,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/presentation/src/main/res/layout/scheduled_activity.xml b/presentation/src/main/res/layout/scheduled_activity.xml index 08199c0e..8e858a68 100644 --- a/presentation/src/main/res/layout/scheduled_activity.xml +++ b/presentation/src/main/res/layout/scheduled_activity.xml @@ -150,39 +150,6 @@ android:visibility="visible" tools:backgroundTint="@color/tools_theme" /> - - - - - - - -