-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refresh app list when package change & Bump to 3.0.5
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/icu/nullptr/hidemyapplist/ui/receiver/AppChangeReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package icu.nullptr.hidemyapplist.ui.receiver | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.IntentFilter | ||
import android.util.Log | ||
import icu.nullptr.hidemyapplist.util.PackageHelper | ||
|
||
class AppChangeReceiver : BroadcastReceiver() { | ||
|
||
companion object { | ||
private const val TAG = "AppChangeReceiver" | ||
|
||
private val actions = setOf( | ||
Intent.ACTION_PACKAGE_ADDED, | ||
Intent.ACTION_PACKAGE_REMOVED, | ||
Intent.ACTION_PACKAGE_REPLACED | ||
) | ||
|
||
fun register(context: Context) { | ||
val filter = IntentFilter().apply { | ||
actions.forEach(::addAction) | ||
addDataScheme("package") | ||
} | ||
context.registerReceiver(AppChangeReceiver(), filter) | ||
} | ||
} | ||
|
||
override fun onReceive(context: Context, intent: Intent) { | ||
if (intent.action in actions) { | ||
Log.i(TAG, "Received intent: $intent") | ||
PackageHelper.invalidateCache() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters