Skip to content

Commit

Permalink
Add ... canta description :P
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Feb 20, 2025
1 parent 60b7cec commit 2f90d4f
Show file tree
Hide file tree
Showing 35 changed files with 114 additions and 14 deletions.
68 changes: 56 additions & 12 deletions app/src/main/java/org/samo_lego/canta/ui/CantaApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import android.content.Context
import android.content.pm.PackageManager
import android.widget.Toast
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
Expand All @@ -15,6 +21,7 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
Expand All @@ -34,23 +41,30 @@ import androidx.compose.material3.TabRow
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.samo_lego.canta.R
import org.samo_lego.canta.packageName
import org.samo_lego.canta.ui.component.AppIconImage
import org.samo_lego.canta.ui.component.AppList
import org.samo_lego.canta.ui.component.CantaTopBar
import org.samo_lego.canta.ui.dialog.ExplainBadgesDialog
Expand Down Expand Up @@ -113,6 +127,8 @@ private fun MainContent(
}
}

val cantaIcon = remember(context) { context.packageManager.getApplicationIcon(packageName) }

Scaffold(
topBar = {
CantaTopBar(
Expand All @@ -136,8 +152,23 @@ private fun MainContent(
MaterialTheme.colorScheme.tertiaryContainer
},
shape = RoundedCornerShape(32.dp),
modifier = Modifier.padding(16.dp).navigationBarsPadding(),
modifier = Modifier
.padding(16.dp)
.navigationBarsPadding(),
onClick = {
// Check if only Canta is selected
// Super secret don't tell anyone you saw this
if (selectedAppsType == AppsType.INSTALLED &&
appListViewModel.selectedApps.size == 1 &&
appListViewModel.selectedApps.contains(packageName)
) {
// Show easter egg toast
Toast.makeText(context, "Can'ta ouch this!", Toast.LENGTH_SHORT)
.show()

return@FloatingActionButton
}

if (selectedAppsType == AppsType.INSTALLED) {
showUninstallConfirmDialog =
appListViewModel.selectedApps.isNotEmpty()
Expand All @@ -154,17 +185,30 @@ private fun MainContent(
)
},
) {
when (selectedAppsType) {
AppsType.INSTALLED ->
Icon(
Icons.Default.Delete,
contentDescription = stringResource(R.string.uninstall)
)
AppsType.UNINSTALLED ->
Icon(
Icons.Default.InstallMobile,
contentDescription = stringResource(R.string.reinstall)
)
// Show Canta icon if only Canta is selected
if (selectedAppsType == AppsType.INSTALLED &&
appListViewModel.selectedApps.size == 1 &&
appListViewModel.selectedApps.contains(packageName)
) {
AppIconImage(
appIconImage = cantaIcon,
contentDescription = stringResource(R.string.app_name)
)
} else {
when (selectedAppsType) {
AppsType.INSTALLED ->
Icon(
Icons.Default.Delete,
contentDescription =
stringResource(R.string.uninstall)
)
AppsType.UNINSTALLED ->
Icon(
Icons.Default.InstallMobile,
contentDescription =
stringResource(R.string.reinstall)
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fun AppList(appType: AppsType = AppsType.INSTALLED) {

LaunchedEffect(Unit) {
if (appListModel.appList.isEmpty()) {
appListModel.loadInstalled(context.packageManager, context.filesDir)
appListModel.loadInstalled(context.packageManager, context.filesDir, context)
}
}

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/org/samo_lego/canta/ui/dialog/CantaAppInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.samo_lego.canta.ui.dialog

import android.content.Context
import org.samo_lego.canta.R
import org.samo_lego.canta.util.BloatData
import org.samo_lego.canta.util.RemovalRecommendation


fun cantaBloatData(context: Context): BloatData {
return BloatData(
installData = null,
description = context.getString(R.string.canta_description),
removal = RemovalRecommendation.RECOMMENDED,
)
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package org.samo_lego.canta.ui.viewmodel

import android.content.Context
import android.content.pm.PackageManager
import android.icu.text.Collator
import android.util.Log
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.json.JSONObject
import org.samo_lego.canta.extension.getAllPackagesInfo
import org.samo_lego.canta.extension.mutableStateSetOf
import org.samo_lego.canta.packageName
import org.samo_lego.canta.ui.dialog.cantaBloatData
import org.samo_lego.canta.util.AppInfo
import org.samo_lego.canta.util.BloatData
import org.samo_lego.canta.util.BloatUtils
Expand Down Expand Up @@ -57,7 +61,7 @@ class AppListViewModel : ViewModel() {
}
}

suspend fun loadInstalled(packageManager: PackageManager, filesDir: File) {
suspend fun loadInstalled(packageManager: PackageManager, filesDir: File, context: Context) {
isLoading = true

withContext(Dispatchers.IO) {
Expand Down Expand Up @@ -92,6 +96,9 @@ class AppListViewModel : ViewModel() {
bloatMap[key] = bloatData
}

// Add Canta app info
bloatMap[packageName] = cantaBloatData(context)

// Assign bloat data to apps
apps = apps.map { app ->
if (bloatMap[app.packageName] != null) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-af/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
<string name="copy">نسخ</string>
<string name="app_settings">معلومات التطبيق</string>
<string name="close">إغلاق</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<string name="copy">Zkopírovat</string>
<string name="app_settings">Informace o aplikací</string>
<string name="close">Zavřít</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Αντιγραφή</string>
<string name="app_settings">Πληρ. εφαρμογής</string>
<string name="close">Κλείσιμο</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copiar</string>
<string name="app_settings">Información de la aplicación</string>
<string name="close">Cerrar</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copier</string>
<string name="app_settings">Infos sur l\'application</string>
<string name="close">Fermer</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-he/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Másolás</string>
<string name="app_settings">Alkalmazásinformáció</string>
<string name="close">Bezár</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copia</string>
<string name="app_settings">App info</string>
<string name="close">Chiudi</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-no/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<string name="copy">Copy</string>
<string name="app_settings">App info</string>
<string name="close">Close</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<string name="badge_info">Informações da etiqueta</string>
<string name="got_it">Entendi</string>
<string name="loading_badges">Carregando etiquetas</string>
<string name="canta_description">Canta is an open source uninstaller app that uses Shizuku to remove system and user apps.\nIt allows you to debloat your device as you wish, no PC required.\n\nSpecial thanks to Universal Debloater Alliance (https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/).\nCanta would\'t be the same without their work.</string>
</resources>
Loading

0 comments on commit 2f90d4f

Please sign in to comment.