Added backup receivers

This commit is contained in:
merkost 2023-07-28 16:33:53 +10:00
parent 53c5f54677
commit ada0702929
3 changed files with 49 additions and 0 deletions

View File

@ -107,6 +107,22 @@
android:resource="@xml/widget_info" />
</receiver>
<receiver
android:name=".receivers.BootCompletedReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<receiver
android:name=".receivers.AutomaticBackupReceiver"
android:exported="false" />
<activity-alias
android:name=".activities.SplashActivity.Red"
android:enabled="false"

View File

@ -0,0 +1,16 @@
package com.simplemobiletools.notes.pro.receivers
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.PowerManager
class AutomaticBackupReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
val wakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "simplenotes:automaticbackupreceiver")
wakelock.acquire(3000)
context.backupNotes()
}
}

View File

@ -0,0 +1,17 @@
package com.simplemobiletools.notes.pro.receivers
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
class BootCompletedReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
ensureBackgroundThread {
context.apply {
checkAndBackupNotesOnBoot()
}
}
}
}