Skip to content

Commit

Permalink
Fixed the support screen and added swipe action to the app manager
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jul 10, 2024
1 parent c81bd8f commit 9463c8a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 32 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
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 = 86
versionCode = 88
versionName = "2.0.0"
archivesName = "${applicationId}-v${versionName}"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)) {
Expand All @@ -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
),
Expand All @@ -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)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ class HelpActivity : AppCompatActivity() {
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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<String, SkuDetails>() }
val billingClient = rememberBillingClient(context, viewModel)
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = {
Expand Down Expand Up @@ -105,7 +102,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
activity.initiatePurchase(
"low_donation",
viewModel.skuDetails,
billingClient
billingClient,
)
},
) {
Expand All @@ -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 {
Expand All @@ -127,7 +124,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
activity.initiatePurchase(
"normal_donation",
viewModel.skuDetails,
billingClient
billingClient,
)
},
) {
Expand Down Expand Up @@ -156,7 +153,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
activity.initiatePurchase(
"high_donation",
viewModel.skuDetails,
billingClient
billingClient,
)
},
) {
Expand All @@ -179,7 +176,7 @@ fun SupportComposable(viewModel: SupportViewModel, activity: SupportActivity) {
activity.initiatePurchase(
"extreme_donation",
viewModel.skuDetails,
billingClient
billingClient,
)
},
) {
Expand Down

0 comments on commit 9463c8a

Please sign in to comment.