Commit 14f65bca authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Fix messages not backing up

parent c5c93c01
Pipeline #184213 passed with stage
in 4 minutes and 50 seconds
......@@ -166,6 +166,16 @@ 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
......@@ -193,4 +203,4 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter>(
override fun stopRestore() = stopRestoreDialog.show()
}
\ No newline at end of file
}
......@@ -25,6 +25,7 @@ import com.moez.QKSMS.common.base.QkPresenter
import com.moez.QKSMS.common.util.DateFormatter
import com.moez.QKSMS.common.util.extensions.makeToast
import com.moez.QKSMS.interactor.PerformBackup
import com.moez.QKSMS.manager.BillingManager
import com.moez.QKSMS.manager.PermissionManager
import com.moez.QKSMS.repository.BackupRepository
import com.uber.autodispose.android.lifecycle.scope
......@@ -38,6 +39,7 @@ 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,
......@@ -71,6 +73,9 @@ 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) {
......@@ -84,9 +89,11 @@ class BackupPresenter @Inject constructor(
view.restoreClicks()
.withLatestFrom(
backupRepo.getBackupProgress(),
backupRepo.getRestoreProgress())
{ _, backupProgress, restoreProgress ->
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)
!permissionManager.hasStorage() -> view.requestStoragePermission()
......@@ -113,6 +120,16 @@ class BackupPresenter @Inject constructor(
.autoDisposable(view.scope())
.subscribe { backupRepo.stopRestore() }
view.fabClicks()
.withLatestFrom(billingManager.upgradeStatus) { _, upgraded -> upgraded }
.autoDisposable(view.scope())
.subscribe { upgraded ->
when {
!upgraded -> navigator.showQksmsPlusActivity("backup_fab")
!permissionManager.hasStorage() -> view.requestStoragePermission()
upgraded -> performBackup.execute(Unit)
}
}
}
}
\ No newline at end of file
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment