From 9fdff0a5527ed93470cb49f2860de118c34f3959 Mon Sep 17 00:00:00 2001 From: Der_Googler <54764558+DerGoogler@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:30:09 +0200 Subject: [PATCH] move provider to about --- app/build.gradle.kts | 2 +- .../ui/screens/settings/SettingsScreen.kt | 16 -- .../ui/screens/settings/about/AboutScreen.kt | 160 ++++++++---------- .../ui/screens/settings/items/NonRootItem.kt | 61 ------- .../ui/screens/settings/items/RootItem.kt | 79 --------- 5 files changed, 72 insertions(+), 246 deletions(-) delete mode 100644 app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/items/NonRootItem.kt delete mode 100644 app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/items/RootItem.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b92fa5c8..928c6dc4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -10,7 +10,7 @@ plugins { alias(libs.plugins.protobuf) } -val baseVersionName = "4.25.32" +val baseVersionName = "4.25.33" android { namespace = "com.dergoogler.mmrl" diff --git a/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/SettingsScreen.kt b/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/SettingsScreen.kt index 07de7a68..40ce12ff 100644 --- a/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/SettingsScreen.kt +++ b/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/SettingsScreen.kt @@ -15,29 +15,22 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource -import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController import com.dergoogler.mmrl.BuildConfig import com.dergoogler.mmrl.R import com.dergoogler.mmrl.app.Const -import com.dergoogler.mmrl.datastore.UserPreferencesCompat.Companion.isNonRoot -import com.dergoogler.mmrl.datastore.UserPreferencesCompat.Companion.isRoot import com.dergoogler.mmrl.datastore.WorkingMode import com.dergoogler.mmrl.ui.component.SettingNormalItem import com.dergoogler.mmrl.ui.component.TopAppBarTitle import com.dergoogler.mmrl.ui.navigation.graphs.SettingsScreen import com.dergoogler.mmrl.ui.providable.LocalUserPreferences -import com.dergoogler.mmrl.ui.screens.settings.items.NonRootItem -import com.dergoogler.mmrl.ui.screens.settings.items.RootItem import com.dergoogler.mmrl.ui.utils.navigateSingleTopTo import com.dergoogler.mmrl.ui.utils.none import com.dergoogler.mmrl.utils.extensions.launchCustomTab -import com.dergoogler.mmrl.viewmodel.SettingsViewModel @Composable fun SettingsScreen( navController: NavController, - viewModel: SettingsViewModel = hiltViewModel() ) { val userPreferences = LocalUserPreferences.current val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() @@ -59,15 +52,6 @@ fun SettingsScreen( .fillMaxWidth() .verticalScroll(rememberScrollState()) ) { - when { - userPreferences.workingMode.isRoot -> RootItem( - isAlive = viewModel.isProviderAlive, - version = viewModel.version - ) - - userPreferences.workingMode.isNonRoot -> NonRootItem() - } - SettingNormalItem( icon = R.drawable.color_swatch, title = stringResource(id = R.string.settings_appearance), diff --git a/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/about/AboutScreen.kt b/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/about/AboutScreen.kt index d12b1ad5..c4d12d7e 100644 --- a/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/about/AboutScreen.kt +++ b/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/about/AboutScreen.kt @@ -5,20 +5,18 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.FilledTonalButton import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedCard import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarScrollBehavior @@ -30,21 +28,28 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController import com.dergoogler.mmrl.BuildConfig import com.dergoogler.mmrl.R import com.dergoogler.mmrl.app.Const -import com.dergoogler.mmrl.ui.component.HtmlText -import com.dergoogler.mmrl.ui.component.Logo +import com.dergoogler.mmrl.datastore.UserPreferencesCompat.Companion.isNonRoot +import com.dergoogler.mmrl.datastore.UserPreferencesCompat.Companion.isRoot import com.dergoogler.mmrl.ui.component.NavigateUpTopBar +import com.dergoogler.mmrl.ui.component.SettingNormalItem +import com.dergoogler.mmrl.ui.component.SettingStaticItem +import com.dergoogler.mmrl.ui.providable.LocalUserPreferences import com.dergoogler.mmrl.ui.utils.none import com.dergoogler.mmrl.utils.extensions.launchCustomTab +import com.dergoogler.mmrl.viewmodel.SettingsViewModel @Composable fun AboutScreen( - navController: NavController + navController: NavController, viewModel: SettingsViewModel = hiltViewModel() ) { val context = LocalContext.current + + val userPreferences = LocalUserPreferences.current val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() Scaffold( @@ -60,96 +65,73 @@ fun AboutScreen( Column( modifier = Modifier .padding(innerPadding) - .fillMaxWidth() - .verticalScroll(rememberScrollState()), - horizontalAlignment = Alignment.CenterHorizontally + .fillMaxSize() + .verticalScroll(rememberScrollState()) ) { - Spacer(modifier = Modifier.height(20.dp)) - Logo( - icon = R.drawable.launcher_outline, - modifier = Modifier.size(65.dp), - contentColor = MaterialTheme.colorScheme.onPrimary, - containerColor = MaterialTheme.colorScheme.primary, - fraction = 0.7f - ) - Spacer(modifier = Modifier.height(20.dp)) - Text( - text = stringResource(id = R.string.app_name), - style = MaterialTheme.typography.titleLarge - ) - Text( - text = stringResource(id = R.string.about_app_version, - BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(top = 5.dp) - ) - Spacer(modifier = Modifier.height(20.dp)) - FilledTonalButton( - onClick = { context.launchCustomTab(Const.GITHUB_URL) } - ) { - Icon( - painter = painterResource(id = R.drawable.github), - contentDescription = null + when { + userPreferences.workingMode.isRoot -> SettingStaticItem( + icon = if (viewModel.isProviderAlive) { + R.drawable.circle_check_filled + } else { + R.drawable.alert_circle_filled + }, + title = if (viewModel.isProviderAlive) { + stringResource( + id = R.string.settings_root_access, + stringResource(id = R.string.settings_root_granted) + ) + } else { + stringResource( + id = R.string.settings_root_access, + stringResource(id = R.string.settings_root_none) + ) + }, + desc = if (viewModel.isProviderAlive) { + stringResource(id = R.string.settings_root_provider, viewModel.version) + } else { + stringResource( + id = R.string.settings_root_provider, + stringResource(id = R.string.settings_root_not_available) + ) + }, + ) + + userPreferences.workingMode.isNonRoot -> SettingStaticItem( + icon = R.drawable.info_circle_filled, + title = stringResource(id = R.string.settings_non_root), + desc = stringResource(id = R.string.settings_non_root_desc), ) - Spacer(modifier = Modifier.width(ButtonDefaults.IconSpacing)) - Text(text = stringResource(id = R.string.about_github)) } - Row( - modifier = Modifier.padding(top = 8.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp) - ) { -// FilledTonalButton( -// onClick = { context.openUrl(Const.TRANSLATE_URL) } -// ) { -// Icon( -// painter = painterResource(id = R.drawable.weblate), -// contentDescription = null, -// modifier = Modifier.size(ButtonDefaults.IconSize) -// ) -// Spacer(modifier = Modifier.width(ButtonDefaults.IconSpacing)) -// Text(text = stringResource(id = R.string.about_weblate)) -// } + SettingNormalItem( + onClick = { context.launchCustomTab(Const.TRANSLATE_URL) }, + icon = R.drawable.weblate, + title = stringResource(id = R.string.about_weblate) + ) - FilledTonalButton( - onClick = { context.launchCustomTab(Const.TELEGRAM_URL) } - ) { - Icon( - painter = painterResource(id = R.drawable.telegram), - contentDescription = null - ) - Spacer(modifier = Modifier.width(ButtonDefaults.IconSpacing)) - Text(text = stringResource(id = R.string.about_telegram)) - } - } + SettingNormalItem( + onClick = { context.launchCustomTab(Const.TELEGRAM_URL) }, + icon = R.drawable.telegram, + title = stringResource(id = R.string.about_telegram) + ) - OutlinedCard( - modifier = Modifier.padding(vertical = 30.dp, horizontal = 20.dp), - shape = RoundedCornerShape(15.dp) - ) { - Column( - modifier = Modifier - .fillMaxWidth() - .padding(all = 15.dp) - ) { - Text( - text = stringResource(id = R.string.about_desc1), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurfaceVariant - ) - Spacer(modifier = Modifier.height(15.dp)) - HtmlText( - text = stringResource(id = R.string.about_desc2, - "Sanmer & DerGoogler"), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurfaceVariant - ) - } - } + SettingNormalItem( + onClick = { context.launchCustomTab(Const.GITHUB_URL) }, + icon = R.drawable.github, + title = stringResource(id = R.string.about_github) + ) + + SettingStaticItem( + title = stringResource( + id = R.string.about_app_version, + BuildConfig.VERSION_NAME, + BuildConfig.VERSION_CODE + ), desc = stringResource( + id = R.string.about_desc2, "Sanmer & DerGoogler" + ) + ) } } } diff --git a/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/items/NonRootItem.kt b/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/items/NonRootItem.kt deleted file mode 100644 index 3970a42b..00000000 --- a/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/items/NonRootItem.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.dergoogler.mmrl.ui.screens.settings.items - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp -import com.dergoogler.mmrl.R - -@Composable -fun NonRootItem() = Surface( - modifier = Modifier.padding(all = 18.dp), - shape = RoundedCornerShape(15.dp), - color = MaterialTheme.colorScheme.secondaryContainer -) { - Row( - modifier = Modifier - .padding(all = 20.dp) - .fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically - ) { - Icon( - modifier = Modifier.size(30.dp), - painter = painterResource(id = R.drawable.info_circle_filled), - contentDescription = null, - tint = MaterialTheme.colorScheme.primary - ) - - Spacer(modifier = Modifier.width(16.dp)) - Column( - modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.spacedBy(4.dp) - ) { - Text( - text = stringResource(id = R.string.settings_non_root), - style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.colorScheme.onSecondaryContainer - ) - - Text( - text = stringResource(id = R.string.settings_non_root_desc), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSecondaryContainer - ) - } - } -} \ No newline at end of file diff --git a/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/items/RootItem.kt b/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/items/RootItem.kt deleted file mode 100644 index 49877ab6..00000000 --- a/app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/settings/items/RootItem.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.dergoogler.mmrl.ui.screens.settings.items - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp -import com.dergoogler.mmrl.R - -@Composable -fun RootItem( - isAlive: Boolean, - version: String -) = Surface( - modifier = Modifier.padding(all = 18.dp), - shape = RoundedCornerShape(15.dp), - color = MaterialTheme.colorScheme.secondaryContainer -) { - Row( - modifier = Modifier - .padding(all = 20.dp) - .fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically - ) { - Icon( - modifier = Modifier.size(30.dp), - painter = painterResource(id = if (isAlive) { - R.drawable.circle_check_filled - } else { - R.drawable.alert_circle_filled - }), - contentDescription = null, - tint = MaterialTheme.colorScheme.primary - ) - - Spacer(modifier = Modifier.width(16.dp)) - Column( - modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.spacedBy(4.dp) - ) { - Text( - text = if (isAlive) { - stringResource(id = R.string.settings_root_access, - stringResource(id = R.string.settings_root_granted)) - } else { - stringResource(id = R.string.settings_root_access, - stringResource(id = R.string.settings_root_none)) - }, - style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.colorScheme.onSecondaryContainer - ) - - Text( - text = if (isAlive) { - stringResource(id = R.string.settings_root_provider, version) - } else { - stringResource(id = R.string.settings_root_provider, - stringResource(id = R.string.settings_root_not_available)) - }, - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSecondaryContainer - ) - } - } -} \ No newline at end of file