forked from upstream-mirrors/quik
Use foreground service to perform restore
This commit is contained in:
@@ -153,6 +153,9 @@
|
||||
</receiver>
|
||||
|
||||
<service android:name="com.android.mms.transaction.TransactionService" />
|
||||
<service
|
||||
android:name=".feature.widget.WidgetService"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
<service
|
||||
android:name=".service.HeadlessSmsSendService"
|
||||
android:exported="true"
|
||||
@@ -167,9 +170,7 @@
|
||||
<data android:scheme="mmsto" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".feature.widget.WidgetService"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
<service android:name=".service.RestoreBackupService" />
|
||||
<service android:name=".service.SendScheduledMessageService" />
|
||||
<service android:name=".service.SendSmsService" />
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||
import com.moez.QKSMS.extensions.isImage
|
||||
import com.moez.QKSMS.feature.compose.ComposeActivity
|
||||
import com.moez.QKSMS.feature.qkreply.QkReplyActivity
|
||||
import com.moez.QKSMS.interactor.DeleteMessages
|
||||
import com.moez.QKSMS.manager.PermissionManager
|
||||
import com.moez.QKSMS.mapper.CursorToPartImpl
|
||||
import com.moez.QKSMS.receiver.DeleteMessagesReceiver
|
||||
@@ -65,6 +64,8 @@ class NotificationManagerImpl @Inject constructor(
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_CHANNEL_ID = "notifications_default"
|
||||
const val BACKUP_RESTORE_CHANNEL_ID = "notifications_backup_restore"
|
||||
|
||||
val VIBRATE_PATTERN = longArrayOf(0, 200, 0, 200)
|
||||
}
|
||||
|
||||
@@ -374,4 +375,21 @@ class NotificationManagerImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getNotificationForBackup(): NotificationCompat.Builder {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
val name = context.getString(R.string.backup_notification_channel_name)
|
||||
val importance = NotificationManager.IMPORTANCE_LOW
|
||||
val channel = NotificationChannel(BACKUP_RESTORE_CHANNEL_ID, name, importance)
|
||||
val notificationManager = context.getSystemService(NotificationManager::class.java)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
return NotificationCompat.Builder(context, BACKUP_RESTORE_CHANNEL_ID)
|
||||
.setContentTitle(context.getString(R.string.backup_restoring))
|
||||
.setSmallIcon(R.drawable.ic_file_download_black_24dp)
|
||||
.setPriority(NotificationCompat.PRIORITY_MIN)
|
||||
.setProgress(0, 0, true)
|
||||
.setOngoing(true)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,12 +18,13 @@
|
||||
*/
|
||||
package com.moez.QKSMS.feature.backup
|
||||
|
||||
import android.content.Context
|
||||
import com.moez.QKSMS.common.Navigator
|
||||
import com.moez.QKSMS.common.base.QkPresenter
|
||||
import com.moez.QKSMS.common.util.BillingManager
|
||||
import com.moez.QKSMS.interactor.PerformBackup
|
||||
import com.moez.QKSMS.interactor.PerformRestore
|
||||
import com.moez.QKSMS.repository.BackupRepository
|
||||
import com.moez.QKSMS.service.RestoreBackupService
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
@@ -33,9 +34,9 @@ import javax.inject.Inject
|
||||
class BackupPresenter @Inject constructor(
|
||||
backupRepo: BackupRepository,
|
||||
private val billingManager: BillingManager,
|
||||
private val context: Context,
|
||||
private val navigator: Navigator,
|
||||
private val performBackup: PerformBackup,
|
||||
private val performRestore: PerformRestore
|
||||
private val performBackup: PerformBackup
|
||||
) : QkPresenter<BackupView, BackupState>(BackupState()) {
|
||||
|
||||
init {
|
||||
@@ -65,7 +66,7 @@ class BackupPresenter @Inject constructor(
|
||||
|
||||
view.restoreFileSelected()
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { backup -> performRestore.execute(backup) }
|
||||
.subscribe { backup -> RestoreBackupService.start(context, backup.path) }
|
||||
|
||||
view.fabClicks()
|
||||
.withLatestFrom(billingManager.upgradeStatus) { _, upgraded -> upgraded }
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.moez.QKSMS.injection.android
|
||||
|
||||
import com.moez.QKSMS.injection.scope.ActivityScope
|
||||
import com.moez.QKSMS.service.HeadlessSmsSendService
|
||||
import com.moez.QKSMS.service.RestoreBackupService
|
||||
import com.moez.QKSMS.service.SendScheduledMessageService
|
||||
import com.moez.QKSMS.service.SendSmsService
|
||||
import dagger.Module
|
||||
@@ -32,6 +33,10 @@ abstract class ServiceBuilderModule {
|
||||
@ContributesAndroidInjector()
|
||||
abstract fun bindHeadlessSmsSendService(): HeadlessSmsSendService
|
||||
|
||||
@ActivityScope
|
||||
@ContributesAndroidInjector()
|
||||
abstract fun bindRestoreBackupService(): RestoreBackupService
|
||||
|
||||
@ActivityScope
|
||||
@ContributesAndroidInjector()
|
||||
abstract fun bindSendScheduledMessageReceiver(): SendScheduledMessageService
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
</plurals>
|
||||
<string name="backup_disclaimer">Currently, only SMS is supported by Backup and Restore. MMS support and scheduled backups will be coming soon!</string>
|
||||
<string name="backup_now">Backup now</string>
|
||||
<string name="backup_notification_channel_name">Backup and restore</string>
|
||||
|
||||
<string name="scheduled_title">Scheduled</string>
|
||||
<string name="scheduled_empty_description">Automatically send a message, at the exact moment you\'d like</string>
|
||||
|
||||
Reference in New Issue
Block a user