Skip to content

Commit 8a56135

Browse files
committed
Refresh app list when package change & Bump to 3.0.5
1 parent 70e75dd commit 8a56135

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

app/src/main/java/icu/nullptr/hidemyapplist/MyApp.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
44
import android.app.Application
55
import com.tsng.hidemyapplist.R
66
import icu.nullptr.hidemyapplist.service.PrefManager
7+
import icu.nullptr.hidemyapplist.ui.receiver.AppChangeReceiver
78
import icu.nullptr.hidemyapplist.ui.util.makeToast
89
import kotlinx.coroutines.CoroutineScope
910
import kotlinx.coroutines.Dispatchers
@@ -35,6 +36,7 @@ class MyApp : Application() {
3536
exitProcess(0)
3637
}
3738
hmaApp = this
39+
AppChangeReceiver.register(this)
3840

3941
DayNightDelegate.setApplicationContext(this)
4042
DayNightDelegate.setDefaultNightMode(PrefManager.darkTheme)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package icu.nullptr.hidemyapplist.ui.receiver
2+
3+
import android.content.BroadcastReceiver
4+
import android.content.Context
5+
import android.content.Intent
6+
import android.content.IntentFilter
7+
import android.util.Log
8+
import icu.nullptr.hidemyapplist.util.PackageHelper
9+
10+
class AppChangeReceiver : BroadcastReceiver() {
11+
12+
companion object {
13+
private const val TAG = "AppChangeReceiver"
14+
15+
private val actions = setOf(
16+
Intent.ACTION_PACKAGE_ADDED,
17+
Intent.ACTION_PACKAGE_REMOVED,
18+
Intent.ACTION_PACKAGE_REPLACED
19+
)
20+
21+
fun register(context: Context) {
22+
val filter = IntentFilter().apply {
23+
actions.forEach(::addAction)
24+
addDataScheme("package")
25+
}
26+
context.registerReceiver(AppChangeReceiver(), filter)
27+
}
28+
}
29+
30+
override fun onReceive(context: Context, intent: Intent) {
31+
if (intent.action in actions) {
32+
Log.i(TAG, "Received intent: $intent")
33+
PackageHelper.invalidateCache()
34+
}
35+
}
36+
}

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fun String.execute(currentWorkingDir: File = file("./")): String {
3535
val minSdkVer by extra(24)
3636
val targetSdkVer by extra(33)
3737

38-
val appVerName by extra("3.0.4-Beta")
38+
val appVerName by extra("3.0.5-Beta")
3939
val serviceVerCode by extra(87)
4040
val minBackupVerCode by extra(65)
4141

0 commit comments

Comments
 (0)