diff --git a/app/src/main/kotlin/com/d4rk/cleaner/ui/appmanager/AppManagerComposable.kt b/app/src/main/kotlin/com/d4rk/cleaner/ui/appmanager/AppManagerComposable.kt index 1fb6672..24050d6 100644 --- a/app/src/main/kotlin/com/d4rk/cleaner/ui/appmanager/AppManagerComposable.kt +++ b/app/src/main/kotlin/com/d4rk/cleaner/ui/appmanager/AppManagerComposable.kt @@ -1,5 +1,6 @@ package com.d4rk.cleaner.ui.appmanager +import android.app.Activity import android.app.Application import android.content.Intent import android.content.pm.ApplicationInfo @@ -32,6 +33,7 @@ import androidx.compose.material3.TabRowDefaults import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf @@ -51,6 +53,7 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import com.d4rk.cleaner.R import com.d4rk.cleaner.data.model.ui.ApkInfo +import com.d4rk.cleaner.utils.PermissionsUtils import java.io.File /** @@ -62,11 +65,18 @@ fun AppManagerComposable() { val viewModel: AppManagerViewModel = viewModel( factory = AppManagerViewModelFactory(LocalContext.current.applicationContext as Application) ) + val context = LocalContext.current val tabs = listOf("Installed Apps", "System Apps", "App Install Files") var selectedIndex by remember { mutableIntStateOf(0) } val installedApps by viewModel.installedApps.collectAsState() val apkFiles by viewModel.apkFiles.collectAsState() + LaunchedEffect(context) { + if (!PermissionsUtils.hasStoragePermissions(context)) { + PermissionsUtils.requestStoragePermissions(context as Activity) + } + } + Column { TabRow( selectedTabIndex = selectedIndex, diff --git a/app/src/main/kotlin/com/d4rk/cleaner/ui/memory/MemoryManagerComposable.kt b/app/src/main/kotlin/com/d4rk/cleaner/ui/memory/MemoryManagerComposable.kt index d49c957..5a30d2d 100644 --- a/app/src/main/kotlin/com/d4rk/cleaner/ui/memory/MemoryManagerComposable.kt +++ b/app/src/main/kotlin/com/d4rk/cleaner/ui/memory/MemoryManagerComposable.kt @@ -1,5 +1,6 @@ package com.d4rk.cleaner.ui.memory +import android.app.Activity import androidx.compose.animation.animateContentSize import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.animateFloatAsState @@ -64,6 +65,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel import com.d4rk.cleaner.R import com.d4rk.cleaner.data.model.ui.RamInfo import com.d4rk.cleaner.data.model.ui.StorageInfo +import com.d4rk.cleaner.utils.PermissionsUtils import com.d4rk.cleaner.utils.cleaning.FileUtils.formatSize import com.d4rk.cleaner.utils.compose.components.StorageProgressBar import com.d4rk.cleaner.utils.compose.bounceClick @@ -104,6 +106,9 @@ fun MemoryManagerComposable() { LaunchedEffect(Unit) { viewModel.updateStorageInfo(context) viewModel.updateRamInfo(context) + if (!PermissionsUtils.hasStoragePermissions(context)) { + PermissionsUtils.requestStoragePermissions(context as Activity) + } } if (isLoading) { Box( diff --git a/app/src/main/kotlin/com/d4rk/cleaner/utils/PermissionsUtils.kt b/app/src/main/kotlin/com/d4rk/cleaner/utils/PermissionsUtils.kt index 5ff587e..cc8fc30 100644 --- a/app/src/main/kotlin/com/d4rk/cleaner/utils/PermissionsUtils.kt +++ b/app/src/main/kotlin/com/d4rk/cleaner/utils/PermissionsUtils.kt @@ -170,5 +170,4 @@ object PermissionsUtils { ) } } - } \ No newline at end of file