Skip to content

Commit ada0702

Browse files
committed
Added backup receivers
1 parent 53c5f54 commit ada0702

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@
107107
android:resource="@xml/widget_info" />
108108
</receiver>
109109

110+
<receiver
111+
android:name=".receivers.BootCompletedReceiver"
112+
android:exported="true">
113+
114+
<intent-filter>
115+
<action android:name="android.intent.action.BOOT_COMPLETED" />
116+
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
117+
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
118+
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
119+
</intent-filter>
120+
</receiver>
121+
122+
<receiver
123+
android:name=".receivers.AutomaticBackupReceiver"
124+
android:exported="false" />
125+
110126
<activity-alias
111127
android:name=".activities.SplashActivity.Red"
112128
android:enabled="false"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.simplemobiletools.notes.pro.receivers
2+
3+
import android.content.BroadcastReceiver
4+
import android.content.Context
5+
import android.content.Intent
6+
import android.os.PowerManager
7+
8+
class AutomaticBackupReceiver : BroadcastReceiver() {
9+
10+
override fun onReceive(context: Context, intent: Intent) {
11+
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
12+
val wakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "simplenotes:automaticbackupreceiver")
13+
wakelock.acquire(3000)
14+
context.backupNotes()
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.simplemobiletools.notes.pro.receivers
2+
3+
import android.content.BroadcastReceiver
4+
import android.content.Context
5+
import android.content.Intent
6+
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
7+
8+
class BootCompletedReceiver : BroadcastReceiver() {
9+
10+
override fun onReceive(context: Context, intent: Intent) {
11+
ensureBackgroundThread {
12+
context.apply {
13+
checkAndBackupNotesOnBoot()
14+
}
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)