Skip to content

Commit

Permalink
Added permissions for the app manager and memory manager
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jul 10, 2024
1 parent 0888d7d commit 742ad57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

/**
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,4 @@ object PermissionsUtils {
)
}
}

}

0 comments on commit 742ad57

Please sign in to comment.