Skip to content

Commit

Permalink
Uninstalling apps is now faster and smoother! The app list updates in…
Browse files Browse the repository at this point in the history
…stantly.
  • Loading branch information
Mihai-Cristian Condrea committed Nov 3, 2024
1 parent 52099b8 commit 37d85a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
applicationId = "com.d4rk.cleaner"
minSdk = 23
targetSdk = 35
versionCode = 142
versionCode = 143
versionName = "3.0.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
resourceConfigurations += listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fun AppsComposable(
} else {
LazyColumn(modifier = Modifier.fillMaxSize()) {
items(items = apps, key = { app -> app.packageName }) { app ->
AppItemComposable(app, viewModel = viewModel)
AppItemComposable(app, viewModel = viewModel, modifier = Modifier.animateItem())
}
}
}
Expand All @@ -205,7 +205,8 @@ fun AppsComposable(
*/
@Composable
fun AppItemComposable(
app: ApplicationInfo, viewModel: AppManagerViewModel
app: ApplicationInfo, viewModel: AppManagerViewModel,
modifier : Modifier
) {
val context: Context = LocalContext.current
val view: View = LocalView.current
Expand All @@ -219,7 +220,7 @@ fun AppItemComposable(
val appSize: String = "%.2f MB".format(sizeInMB.toFloat())
var showMenu: Boolean by remember { mutableStateOf(value = false) }
val model: Drawable = app.loadIcon(packageManager)
OutlinedCard(modifier = Modifier.padding(start = 8.dp, end = 8.dp, top = 8.dp)) {
OutlinedCard(modifier = modifier.padding(start = 8.dp, end = 8.dp, top = 8.dp)) {
Row(
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ class AppManagerViewModel(application: Application) : BaseViewModel(application)
private val packageRemovedReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
if (intent?.action == Intent.ACTION_PACKAGE_REMOVED) {
loadAppData()
val packageName = intent.data?.schemeSpecificPart
packageName?.let {
_uiState.update { currentState ->
val updatedInstalledApps = currentState.installedApps.filterNot { it.packageName == packageName }
return@update currentState.copy(installedApps = updatedInstalledApps)
}
}
}
}
}
Expand Down

0 comments on commit 37d85a8

Please sign in to comment.