Commit b390d492 authored by Romain Hunault's avatar Romain Hunault

Merge branch 'dev-tmp' into 'dev'

Fix #14 Remove "Do you like QKSMS?"
Fix #16 Backup not working (disabled)
Fix #13 Replace QKSMS by Message

See merge request !6
parents 4638c70f 9cd97a73
Pipeline #11519 passed with stage
in 9 minutes and 35 seconds
/*
* 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.mapper
import com.f2prateek.rx.preferences2.RxSharedPreferences
import com.moez.QKSMS.manager.AnalyticsManager
import com.moez.QKSMS.manager.RatingManager
import io.reactivex.rxkotlin.Observables
import javax.inject.Inject
class RatingManagerImpl @Inject constructor(
rxPrefs: RxSharedPreferences,
private val analyticsManager: AnalyticsManager
) : RatingManager {
companion object {
private const val RATING_THRESHOLD = 10
}
private val sessions = rxPrefs.getInteger("sessions", 0)
private val rated = rxPrefs.getBoolean("rated", false)
private val dismissed = rxPrefs.getBoolean("dismissed", false)
override val shouldShowRating = Observables.combineLatest(
sessions.asObservable(),
rated.asObservable(),
dismissed.asObservable()
) { sessions, rated, dismissed ->
sessions > RATING_THRESHOLD && !rated && !dismissed
}
override fun addSession() {
sessions.set(sessions.get() + 1)
}
override fun rate() {
analyticsManager.track("Clicked Rate")
rated.set(true)
}
override fun dismiss() {
analyticsManager.track("Clicked Rate (Dismiss)")
dismissed.set(true)
}
}
/*
* 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.manager
import io.reactivex.Observable
interface RatingManager {
val shouldShowRating: Observable<Boolean>
/**
* Whether or not we should show the rating UI should depend on the number of sessions
*/
fun addSession()
fun rate()
fun dismiss()
}
\ No newline at end of file
......@@ -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,14 +90,11 @@ 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 }))
}
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
override val dismissRatingIntent by lazy { rateDismiss.clicks() }
override val rateIntent by lazy { rateOkay.clicks() }
override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges }
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
override val swipeConversationIntent by lazy { itemTouchCallback.swipes }
......@@ -159,14 +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)
rateIcon.setTint(theme.theme)
compose.setBackgroundTint(theme.theme)
// Set the FAB compose icon color
......@@ -213,12 +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
rateLayout.setVisible(state.showRating)
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,
......
......@@ -30,8 +30,6 @@ interface MainView : QkView<MainState> {
val homeIntent: Observable<*>
val drawerItemIntent: Observable<DrawerItem>
val optionsItemIntent: Observable<Int>
val dismissRatingIntent: Observable<*>
val rateIntent: Observable<*>
val conversationsSelectedIntent: Observable<List<Long>>
val confirmDeleteIntent: Observable<List<Long>>
val swipeConversationIntent: Observable<Pair<Long, Int>>
......
......@@ -23,21 +23,9 @@ 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.manager.RatingManager
import com.moez.QKSMS.model.SyncLog
import com.moez.QKSMS.repository.ConversationRepository
import com.moez.QKSMS.repository.SyncRepository
......@@ -53,7 +41,6 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject
class MainViewModel @Inject constructor(
billingManager: BillingManager,
markAllSeen: MarkAllSeen,
migratePreferences: MigratePreferences,
syncRepository: SyncRepository,
......@@ -69,7 +56,6 @@ class MainViewModel @Inject constructor(
private val navigator: Navigator,
private val permissionManager: PermissionManager,
private val prefs: Preferences,
private val ratingManager: RatingManager,
private val syncMessages: SyncMessages
) : QkViewModel<MainView, MainState>(MainState(page = Inbox(data = conversationRepo.getConversations()))) {
......@@ -87,15 +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) } }
// Show the rating UI
disposables += ratingManager.shouldShowRating
.subscribe { show -> newState { copy(showRating = show) } }
// Migrate the preferences from 2.7.3
migratePreferences.execute(Unit)
......@@ -107,7 +84,6 @@ class MainViewModel @Inject constructor(
syncMessages.execute(Unit)
}
ratingManager.addSession()
markAllSeen.execute(Unit)
}
......@@ -246,17 +222,6 @@ class MainViewModel @Inject constructor(
.autoDisposable(view.scope())
.subscribe()
view.rateIntent
.autoDisposable(view.scope())
.subscribe {
navigator.showRating()
ratingManager.rate()
}
view.dismissRatingIntent
.autoDisposable(view.scope())
.subscribe { ratingManager.dismiss() }
view.conversationsSelectedIntent
.withLatestFrom(state) { selection, state ->
val pin = selection
......
......@@ -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(