Skip to content

Commit 9463c8a

Browse files
Fixed the support screen and added swipe action to the app manager
1 parent c81bd8f commit 9463c8a

File tree

5 files changed

+60
-32
lines changed

5 files changed

+60
-32
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Version 2.0.0:
2+
- **New**: Added a progress bar to the main screen, offering an approximate visualization of storage usage.
3+
- **New**: Users can now select specific files for deletion after the scan completes, allowing for granular control.
4+
- **New**: Enhanced the post-scan screen to display previews of images and videos, aiding in file selection.
5+
- **New**: Introduced the option to select all files for deletion, streamlining the cleaning process.
6+
- **New**: Completely overhauled the memory manager, now showcasing storage usage categorized by file types.
7+
- **New**: Added support for dynamic colors on compatible devices, allowing the app to adapt to system-wide color palettes.
8+
- **New**: Refined the AMOLED theme for a more immersive dark mode experience.
9+
- **New**: Incorporated updated translations thanks to valuable contributions from the community.
10+
- **New**: Introduced a dedicated section for managing security and privacy settings within the app.
11+
- **New**: Implemented new animations and improved overall app responsiveness for a smoother user experience.
12+
- **Major**: Migrated the entire app to Jetpack Compose, providing a modern and improved user interface.
13+
- **Major**: Completely reworked the app's logic using view models and coroutines for enhanced performance and maintainability.
14+
115
# Version 1.1.0:
216

317
- **Minor**: Added GitHub issues templates.

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ android {
1414
applicationId = "com.d4rk.cleaner"
1515
minSdk = 26
1616
targetSdk = 34
17-
versionCode = 86
17+
versionCode = 88
1818
versionName = "2.0.0"
1919
archivesName = "${applicationId}-v${versionName}"
2020
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

app/src/main/kotlin/com/d4rk/cleaner/ui/appmanager/AppManagerComposable.kt

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.graphics.Canvas
99
import android.graphics.drawable.BitmapDrawable
1010
import android.net.Uri
1111
import android.provider.Settings
12+
import androidx.compose.foundation.ExperimentalFoundationApi
1213
import androidx.compose.foundation.Image
1314
import androidx.compose.foundation.layout.Box
1415
import androidx.compose.foundation.layout.Column
@@ -18,6 +19,8 @@ import androidx.compose.foundation.layout.padding
1819
import androidx.compose.foundation.layout.size
1920
import androidx.compose.foundation.lazy.LazyColumn
2021
import androidx.compose.foundation.lazy.items
22+
import androidx.compose.foundation.pager.HorizontalPager
23+
import androidx.compose.foundation.pager.rememberPagerState
2124
import androidx.compose.foundation.shape.RoundedCornerShape
2225
import androidx.compose.material.icons.Icons
2326
import androidx.compose.material.icons.outlined.MoreVert
@@ -36,9 +39,9 @@ import androidx.compose.runtime.Composable
3639
import androidx.compose.runtime.LaunchedEffect
3740
import androidx.compose.runtime.collectAsState
3841
import androidx.compose.runtime.getValue
39-
import androidx.compose.runtime.mutableIntStateOf
4042
import androidx.compose.runtime.mutableStateOf
4143
import androidx.compose.runtime.remember
44+
import androidx.compose.runtime.rememberCoroutineScope
4245
import androidx.compose.runtime.setValue
4346
import androidx.compose.ui.Alignment
4447
import androidx.compose.ui.Modifier
@@ -54,22 +57,22 @@ import androidx.lifecycle.viewmodel.compose.viewModel
5457
import com.d4rk.cleaner.R
5558
import com.d4rk.cleaner.data.model.ui.ApkInfo
5659
import com.d4rk.cleaner.utils.PermissionsUtils
60+
import kotlinx.coroutines.launch
5761
import java.io.File
5862

5963
/**
6064
* Composable function for managing and displaying different app categories.
6165
*/
66+
@OptIn(ExperimentalFoundationApi::class)
6267
@Composable
6368
fun AppManagerComposable() {
64-
6569
val viewModel: AppManagerViewModel = viewModel(
6670
factory = AppManagerViewModelFactory(LocalContext.current.applicationContext as Application)
6771
)
6872
val context = LocalContext.current
6973
val tabs = listOf("Installed Apps", "System Apps", "App Install Files")
70-
var selectedIndex by remember { mutableIntStateOf(0) }
71-
val installedApps by viewModel.installedApps.collectAsState()
72-
val apkFiles by viewModel.apkFiles.collectAsState()
74+
val pagerState = rememberPagerState(pageCount = { tabs.size })
75+
val coroutineScope = rememberCoroutineScope()
7376

7477
LaunchedEffect(context) {
7578
if (!PermissionsUtils.hasStoragePermissions(context)) {
@@ -79,11 +82,11 @@ fun AppManagerComposable() {
7982

8083
Column {
8184
TabRow(
82-
selectedTabIndex = selectedIndex,
85+
selectedTabIndex = pagerState.currentPage,
8386
indicator = { tabPositions ->
84-
if (selectedIndex < tabPositions.size) {
87+
if (pagerState.currentPage < tabPositions.size) {
8588
TabRowDefaults.PrimaryIndicator(
86-
modifier = Modifier.tabIndicatorOffset(tabPositions[selectedIndex]),
89+
modifier = Modifier.tabIndicatorOffset(tabPositions[pagerState.currentPage]).fillMaxWidth(),
8790
shape = RoundedCornerShape(
8891
topStart = 3.dp, topEnd = 3.dp, bottomEnd = 0.dp, bottomStart = 0.dp
8992
),
@@ -92,22 +95,37 @@ fun AppManagerComposable() {
9295
},
9396
) {
9497
tabs.forEachIndexed { index, title ->
95-
Tab(text = {
96-
Text(
97-
text = title,
98-
maxLines = 1,
99-
overflow = TextOverflow.Ellipsis,
100-
color = MaterialTheme.colorScheme.onSurface
101-
)
102-
}, selected = selectedIndex == index, onClick = { selectedIndex = index })
98+
Tab(
99+
text = {
100+
Text(
101+
text = title,
102+
maxLines = 1,
103+
overflow = TextOverflow.Ellipsis,
104+
color = MaterialTheme.colorScheme.onSurface
105+
)
106+
},
107+
selected = pagerState.currentPage == index,
108+
onClick = {
109+
coroutineScope.launch {
110+
pagerState.animateScrollToPage(index)
111+
}
112+
}
113+
)
103114
}
104115
}
105-
when (selectedIndex) {
106-
0 -> AppsComposable(
107-
apps = installedApps.filter { it.flags and ApplicationInfo.FLAG_SYSTEM == 0 })
108-
1 -> AppsComposable(
109-
apps = installedApps.filter { it.flags and ApplicationInfo.FLAG_SYSTEM != 0 })
110-
2 -> ApksComposable(apkFiles = apkFiles)
116+
117+
HorizontalPager(
118+
state = pagerState, // Only provide pagerState here
119+
) { page ->
120+
when (page) {
121+
0 -> AppsComposable(
122+
apps = viewModel.installedApps.collectAsState().value.filter { it.flags and ApplicationInfo.FLAG_SYSTEM == 0 }
123+
)
124+
1 -> AppsComposable(
125+
apps = viewModel.installedApps.collectAsState().value.filter { it.flags and ApplicationInfo.FLAG_SYSTEM != 0 }
126+
)
127+
2 -> ApksComposable(apkFiles = viewModel.apkFiles.collectAsState().value)
128+
}
111129
}
112130
}
113131
}

app/src/main/kotlin/com/d4rk/cleaner/ui/help/HelpActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ class HelpActivity : AppCompatActivity() {
2525
}
2626
}
2727
}
28-
2928
}
3029
}

app/src/main/kotlin/com/d4rk/cleaner/ui/support/SupportComposable.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import androidx.compose.material3.TopAppBarDefaults
3030
import androidx.compose.material3.rememberTopAppBarState
3131
import androidx.compose.runtime.Composable
3232
import androidx.compose.runtime.DisposableEffect
33-
import androidx.compose.runtime.mutableStateMapOf
3433
import androidx.compose.runtime.remember
3534
import androidx.compose.ui.Modifier
3635
import androidx.compose.ui.input.nestedscroll.nestedScroll
@@ -40,7 +39,6 @@ import androidx.compose.ui.unit.dp
4039
import com.android.billingclient.api.BillingClient
4140
import com.android.billingclient.api.BillingClientStateListener
4241
import com.android.billingclient.api.BillingResult
43-
import com.android.billingclient.api.SkuDetails
4442
import com.d4rk.cleaner.R
4543
import com.d4rk.cleaner.ads.LargeBannerAdsComposable
4644
import com.d4rk.cleaner.data.datastore.DataStore
@@ -52,7 +50,6 @@ import com.d4rk.cleaner.utils.compose.bounceClick
5250
fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
5351
val context = LocalContext.current
5452
val dataStore = DataStore.getInstance(context)
55-
val skuDetailsMap = remember { mutableStateMapOf<String, SkuDetails>() }
5653
val billingClient = rememberBillingClient(context, viewModel)
5754
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
5855
Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = {
@@ -105,7 +102,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
105102
activity.initiatePurchase(
106103
"low_donation",
107104
viewModel.skuDetails,
108-
billingClient
105+
billingClient,
109106
)
110107
},
111108
) {
@@ -115,7 +112,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
115112
modifier = Modifier.size(ButtonDefaults.IconSize)
116113
)
117114
Spacer(modifier = Modifier.size(ButtonDefaults.IconSpacing))
118-
Text(skuDetailsMap["low_donation"]?.price ?: "")
115+
Text(viewModel.skuDetails["low_donation"]?.price ?: "")
119116
}
120117
}
121118
item {
@@ -127,7 +124,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
127124
activity.initiatePurchase(
128125
"normal_donation",
129126
viewModel.skuDetails,
130-
billingClient
127+
billingClient,
131128
)
132129
},
133130
) {
@@ -156,7 +153,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
156153
activity.initiatePurchase(
157154
"high_donation",
158155
viewModel.skuDetails,
159-
billingClient
156+
billingClient,
160157
)
161158
},
162159
) {
@@ -179,7 +176,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
179176
activity.initiatePurchase(
180177
"extreme_donation",
181178
viewModel.skuDetails,
182-
billingClient
179+
billingClient,
183180
)
184181
},
185182
) {

0 commit comments

Comments
 (0)