From 9463c8ade91940d3ed509c0c40dc6abc5cd2aefe Mon Sep 17 00:00:00 2001 From: D4rK7355608 Date: Wed, 10 Jul 2024 20:39:22 +0300 Subject: [PATCH] Fixed the support screen and added swipe action to the app manager --- CHANGELOG.md | 14 +++++ app/build.gradle.kts | 2 +- .../ui/appmanager/AppManagerComposable.kt | 62 ++++++++++++------- .../com/d4rk/cleaner/ui/help/HelpActivity.kt | 1 - .../cleaner/ui/support/SupportComposable.kt | 13 ++-- 5 files changed, 60 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 077eb66..249a30e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# Version 2.0.0: +- **New**: Added a progress bar to the main screen, offering an approximate visualization of storage usage. +- **New**: Users can now select specific files for deletion after the scan completes, allowing for granular control. +- **New**: Enhanced the post-scan screen to display previews of images and videos, aiding in file selection. +- **New**: Introduced the option to select all files for deletion, streamlining the cleaning process. +- **New**: Completely overhauled the memory manager, now showcasing storage usage categorized by file types. +- **New**: Added support for dynamic colors on compatible devices, allowing the app to adapt to system-wide color palettes. +- **New**: Refined the AMOLED theme for a more immersive dark mode experience. +- **New**: Incorporated updated translations thanks to valuable contributions from the community. +- **New**: Introduced a dedicated section for managing security and privacy settings within the app. +- **New**: Implemented new animations and improved overall app responsiveness for a smoother user experience. +- **Major**: Migrated the entire app to Jetpack Compose, providing a modern and improved user interface. +- **Major**: Completely reworked the app's logic using view models and coroutines for enhanced performance and maintainability. + # Version 1.1.0: - **Minor**: Added GitHub issues templates. diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 64e8ebe..3fe4f99 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,7 +14,7 @@ android { applicationId = "com.d4rk.cleaner" minSdk = 26 targetSdk = 34 - versionCode = 86 + versionCode = 88 versionName = "2.0.0" archivesName = "${applicationId}-v${versionName}" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 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 24050d6..6b4afae 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 @@ -9,6 +9,7 @@ import android.graphics.Canvas import android.graphics.drawable.BitmapDrawable import android.net.Uri import android.provider.Settings +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -18,6 +19,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.pager.HorizontalPager +import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.MoreVert @@ -36,9 +39,9 @@ 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 import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -54,22 +57,22 @@ 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 kotlinx.coroutines.launch import java.io.File /** * Composable function for managing and displaying different app categories. */ +@OptIn(ExperimentalFoundationApi::class) @Composable 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() + val pagerState = rememberPagerState(pageCount = { tabs.size }) + val coroutineScope = rememberCoroutineScope() LaunchedEffect(context) { if (!PermissionsUtils.hasStoragePermissions(context)) { @@ -79,11 +82,11 @@ fun AppManagerComposable() { Column { TabRow( - selectedTabIndex = selectedIndex, + selectedTabIndex = pagerState.currentPage, indicator = { tabPositions -> - if (selectedIndex < tabPositions.size) { + if (pagerState.currentPage < tabPositions.size) { TabRowDefaults.PrimaryIndicator( - modifier = Modifier.tabIndicatorOffset(tabPositions[selectedIndex]), + modifier = Modifier.tabIndicatorOffset(tabPositions[pagerState.currentPage]).fillMaxWidth(), shape = RoundedCornerShape( topStart = 3.dp, topEnd = 3.dp, bottomEnd = 0.dp, bottomStart = 0.dp ), @@ -92,22 +95,37 @@ fun AppManagerComposable() { }, ) { tabs.forEachIndexed { index, title -> - Tab(text = { - Text( - text = title, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - color = MaterialTheme.colorScheme.onSurface - ) - }, selected = selectedIndex == index, onClick = { selectedIndex = index }) + Tab( + text = { + Text( + text = title, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + color = MaterialTheme.colorScheme.onSurface + ) + }, + selected = pagerState.currentPage == index, + onClick = { + coroutineScope.launch { + pagerState.animateScrollToPage(index) + } + } + ) } } - when (selectedIndex) { - 0 -> AppsComposable( - apps = installedApps.filter { it.flags and ApplicationInfo.FLAG_SYSTEM == 0 }) - 1 -> AppsComposable( - apps = installedApps.filter { it.flags and ApplicationInfo.FLAG_SYSTEM != 0 }) - 2 -> ApksComposable(apkFiles = apkFiles) + + HorizontalPager( + state = pagerState, // Only provide pagerState here + ) { page -> + when (page) { + 0 -> AppsComposable( + apps = viewModel.installedApps.collectAsState().value.filter { it.flags and ApplicationInfo.FLAG_SYSTEM == 0 } + ) + 1 -> AppsComposable( + apps = viewModel.installedApps.collectAsState().value.filter { it.flags and ApplicationInfo.FLAG_SYSTEM != 0 } + ) + 2 -> ApksComposable(apkFiles = viewModel.apkFiles.collectAsState().value) + } } } } diff --git a/app/src/main/kotlin/com/d4rk/cleaner/ui/help/HelpActivity.kt b/app/src/main/kotlin/com/d4rk/cleaner/ui/help/HelpActivity.kt index c35ae22..40592c5 100644 --- a/app/src/main/kotlin/com/d4rk/cleaner/ui/help/HelpActivity.kt +++ b/app/src/main/kotlin/com/d4rk/cleaner/ui/help/HelpActivity.kt @@ -25,6 +25,5 @@ class HelpActivity : AppCompatActivity() { } } } - } } \ No newline at end of file diff --git a/app/src/main/kotlin/com/d4rk/cleaner/ui/support/SupportComposable.kt b/app/src/main/kotlin/com/d4rk/cleaner/ui/support/SupportComposable.kt index 3e74b04..e186ba9 100644 --- a/app/src/main/kotlin/com/d4rk/cleaner/ui/support/SupportComposable.kt +++ b/app/src/main/kotlin/com/d4rk/cleaner/ui/support/SupportComposable.kt @@ -30,7 +30,6 @@ import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.rememberTopAppBarState import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll @@ -40,7 +39,6 @@ import androidx.compose.ui.unit.dp import com.android.billingclient.api.BillingClient import com.android.billingclient.api.BillingClientStateListener import com.android.billingclient.api.BillingResult -import com.android.billingclient.api.SkuDetails import com.d4rk.cleaner.R import com.d4rk.cleaner.ads.LargeBannerAdsComposable import com.d4rk.cleaner.data.datastore.DataStore @@ -52,7 +50,6 @@ import com.d4rk.cleaner.utils.compose.bounceClick fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) { val context = LocalContext.current val dataStore = DataStore.getInstance(context) - val skuDetailsMap = remember { mutableStateMapOf() } val billingClient = rememberBillingClient(context, viewModel) val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState()) Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = { @@ -105,7 +102,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) { activity.initiatePurchase( "low_donation", viewModel.skuDetails, - billingClient + billingClient, ) }, ) { @@ -115,7 +112,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) { modifier = Modifier.size(ButtonDefaults.IconSize) ) Spacer(modifier = Modifier.size(ButtonDefaults.IconSpacing)) - Text(skuDetailsMap["low_donation"]?.price ?: "") + Text(viewModel.skuDetails["low_donation"]?.price ?: "") } } item { @@ -127,7 +124,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) { activity.initiatePurchase( "normal_donation", viewModel.skuDetails, - billingClient + billingClient, ) }, ) { @@ -156,7 +153,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) { activity.initiatePurchase( "high_donation", viewModel.skuDetails, - billingClient + billingClient, ) }, ) { @@ -179,7 +176,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) { activity.initiatePurchase( "extreme_donation", viewModel.skuDetails, - billingClient + billingClient, ) }, ) {