Skip to content

Commit

Permalink
Updated the cleaner UI
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jun 25, 2024
1 parent 7316dee commit db99d13
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 87 deletions.
14 changes: 14 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 = 26
targetSdk = 34
versionCode = 69
versionCode = 72
versionName = "2.0.0"
archivesName = "${applicationId}-v${versionName}"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.ACTION_OPEN_DOCUMENT_TREE" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission
android:name="android.permission.READ_MEDIA_IMAGES"
tools:ignore="SelectedPhotoAccess" />
Expand All @@ -23,8 +22,7 @@
tools:ignore="SelectedPhotoAccess" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="SelectedPhotoAccess" />
android:maxSdkVersion="32" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29"
Expand Down
42 changes: 25 additions & 17 deletions app/src/main/kotlin/com/d4rk/cleaner/MainComposable.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.d4rk.cleaner

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -41,6 +43,8 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.d4rk.cleaner.ads.FullBannerAdsComposable
import com.d4rk.cleaner.data.datastore.DataStore
import com.d4rk.cleaner.data.navigation.NavigationItem
import com.d4rk.cleaner.data.navigation.Screen
import com.d4rk.cleaner.ui.appmanager.AppManagerComposable
Expand Down Expand Up @@ -89,6 +93,7 @@ fun MainComposable() {
val scope = rememberCoroutineScope()
val navController = rememberNavController()
val context = LocalContext.current
val dataStore = DataStore.getInstance(context)
val selectedItemIndex by rememberSaveable { mutableIntStateOf(-1) }
ModalNavigationDrawer(drawerState = drawerState, drawerContent = {
ModalDrawerSheet {
Expand Down Expand Up @@ -184,23 +189,26 @@ fun MainComposable() {
}
})
}, bottomBar = {
NavigationBar {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route
bottomBarItems.forEach { screen ->
NavigationBarItem(icon = {
val iconResource =
if (currentRoute == screen.route) screen.selectedIcon else screen.icon
Icon(iconResource, contentDescription = null)
},
label = { Text(stringResource(screen.title)) },
selected = currentRoute == screen.route,
onClick = {
navController.navigate(screen.route) {
popUpTo(navController.graph.startDestinationId)
launchSingleTop = true
}
})
Column {
FullBannerAdsComposable(modifier = Modifier.fillMaxWidth(), dataStore = dataStore)
NavigationBar {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route
bottomBarItems.forEach { screen ->
NavigationBarItem(icon = {
val iconResource =
if (currentRoute == screen.route) screen.selectedIcon else screen.icon
Icon(iconResource, contentDescription = null)
},
label = { Text(stringResource(screen.title)) },
selected = currentRoute == screen.route,
onClick = {
navController.navigate(screen.route) {
popUpTo(navController.graph.startDestinationId)
launchSingleTop = true
}
})
}
}
}
}) { innerPadding ->
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/kotlin/com/d4rk/cleaner/data/CpuApp.kt

This file was deleted.

16 changes: 0 additions & 16 deletions app/src/main/kotlin/com/d4rk/cleaner/data/CpuAppDiffCallback.kt

This file was deleted.

76 changes: 47 additions & 29 deletions app/src/main/kotlin/com/d4rk/cleaner/ui/home/HomeComposable.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package com.d4rk.cleaner.ui.home

import android.app.Activity
import android.content.Context
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.expandHorizontally
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkHorizontally
import androidx.compose.foundation.Image
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -39,7 +45,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -64,7 +69,8 @@ fun HomeComposable() {
val progress by viewModel.progress.observeAsState(0.3f)
val storageUsed by viewModel.storageUsed.observeAsState("0")
val storageTotal by viewModel.storageTotal.observeAsState("0")
val showCleaningComposable = remember { mutableStateOf(false) }
val showCleaningComposable by viewModel.showCleaningComposable.observeAsState(false)
val isAnalyzing by viewModel.isAnalyzing.observeAsState(false)
Column(
modifier = Modifier.fillMaxSize()
) {
Expand All @@ -73,7 +79,7 @@ fun HomeComposable() {
.weight(4f)
.fillMaxWidth()
) {
if (!showCleaningComposable.value) {
if (!showCleaningComposable) {
CircularDeterminateIndicator(
progress = progress,
storageUsed = storageUsed,
Expand Down Expand Up @@ -101,43 +107,55 @@ fun HomeComposable() {
.padding(bottom = 16.dp),
horizontalArrangement = Arrangement.SpaceEvenly
) {
FilledTonalButton(
modifier = Modifier
.weight(1f)
.fillMaxHeight()
.padding(start = 16.dp, end = 8.dp)
.bounceClick(),
onClick = {
Utils.openActivity(
context, StartupActivity::class.java
)
},
shape = MaterialTheme.shapes.medium
AnimatedVisibility(
visible = showCleaningComposable,
enter = fadeIn() + expandHorizontally(expandFrom = Alignment.Start),
exit = fadeOut() + shrinkHorizontally(shrinkTowards = Alignment.Start),
modifier = Modifier.weight(1f)
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
FilledTonalButton(
modifier = Modifier
.fillMaxSize()
.padding(ButtonDefaults.ContentPadding)
.weight(1f)
.fillMaxHeight()
.animateContentSize()
.padding(start = 16.dp, end = 8.dp)
.bounceClick(),
onClick = {
viewModel.clean(activity = context as Activity)
Utils.openActivity(
context, StartupActivity::class.java
)
},
shape = MaterialTheme.shapes.medium,
enabled = !isAnalyzing
) {
Icon(
painterResource(R.drawable.ic_broom),
contentDescription = null,
modifier = Modifier.size(ButtonDefaults.IconSize)
)
Text(text = "Clean", style = MaterialTheme.typography.bodyMedium)
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxSize()
.padding(ButtonDefaults.ContentPadding)
) {
Icon(
painterResource(R.drawable.ic_broom),
contentDescription = null,
modifier = Modifier.size(ButtonDefaults.IconSize)
)
Text(text = "Clean", style = MaterialTheme.typography.bodyMedium)
}
}
}
FilledTonalButton(
modifier = Modifier
.weight(1f)
.fillMaxHeight()
.padding(start = 8.dp, end = 16.dp)
.animateContentSize()
.padding(start = if (showCleaningComposable) 8.dp else 16.dp, end = 16.dp)
.bounceClick(),
onClick = {
viewModel.analyze()
showCleaningComposable.value = true
if (!showCleaningComposable) {
viewModel.analyze(activity = context as Activity)
}
},
shape = MaterialTheme.shapes.medium
) {
Expand Down
Loading

0 comments on commit db99d13

Please sign in to comment.