diff --git a/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedButton.kt b/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedButton.kt index d48c2a69..fb2bea85 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedButton.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedButton.kt @@ -10,10 +10,13 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.luminance import androidx.compose.ui.unit.dp +import com.vanced.manager.ui.components.color.managerAccentColor +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun ManagerThemedButton( modifier: Modifier = Modifier, + backgroundColor: Color = managerAccentColor(), onClick: () -> Unit, content: @Composable RowScope.() -> Unit ) { @@ -22,8 +25,9 @@ fun ManagerThemedButton( onClick = onClick, shape = MaterialTheme.shapes.medium, colors = ButtonDefaults.buttonColors( + backgroundColor = backgroundColor, contentColor = - if (MaterialTheme.colors.primary.luminance() > 0.7) + if (backgroundColor.luminance() > 0.7) Color.Black else Color.White diff --git a/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedTextButton.kt b/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedTextButton.kt index f0d97c46..e230c38a 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedTextButton.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedTextButton.kt @@ -1,18 +1,24 @@ package com.vanced.manager.ui.components.button import androidx.annotation.StringRes +import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.text.ManagerText +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun ManagerThemedTextButton( modifier: Modifier = Modifier, + backgroundColor: Color = managerAccentColor(), @StringRes stringId: Int, onClick: () -> Unit ) { ManagerThemedButton( modifier = modifier, + backgroundColor = backgroundColor, onClick = onClick ) { ManagerText(stringId = stringId) diff --git a/app/src/main/java/com/vanced/manager/ui/components/card/ManagerItemCard.kt b/app/src/main/java/com/vanced/manager/ui/components/card/ManagerItemCard.kt index 1ac13eba..93d96b84 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/card/ManagerItemCard.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/card/ManagerItemCard.kt @@ -10,11 +10,14 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.vanced.manager.ui.components.color.ThemedItemContentColorProvider +import com.vanced.manager.ui.components.color.managerAccentColor +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref private val cardModifier = Modifier.sizeIn( minHeight = 95.dp, @@ -52,7 +55,7 @@ private fun ManagerItemCardContent( title: String, @DrawableRes icon: Int? = null, ) { - val accentColor = MaterialTheme.colors.primary + val accentColor = managerAccentColor() Canvas(modifier = Modifier.requiredSize(72.dp)) { drawCircle( color = accentColor, diff --git a/app/src/main/java/com/vanced/manager/ui/components/checkbox/ManagerCheckbox.kt b/app/src/main/java/com/vanced/manager/ui/components/checkbox/ManagerCheckbox.kt index 64a9d025..60d758c5 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/checkbox/ManagerCheckbox.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/checkbox/ManagerCheckbox.kt @@ -14,11 +14,14 @@ import androidx.compose.material.icons.rounded.Done import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.vanced.manager.ui.components.card.ManagerCard import com.vanced.manager.ui.components.color.contentColorForColor +import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.color.managerAnimatedColor import com.vanced.manager.ui.components.color.managerThemedCardColor +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @SuppressLint("UnusedTransitionTargetStateParameter") @Composable @@ -26,7 +29,7 @@ fun ManagerCheckbox( isChecked: Boolean, onCheckedChange: (isChecked: Boolean) -> Unit ) { - val accentColor = MaterialTheme.colors.primary + val accentColor = managerAccentColor() val transition = updateTransition(targetState = isChecked, label = "Checked") val cardSize by transition.animateDp( transitionSpec = { diff --git a/app/src/main/java/com/vanced/manager/ui/components/color/ColorContentProvider.kt b/app/src/main/java/com/vanced/manager/ui/components/color/ColorContentProvider.kt index ae55bc22..85791383 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/color/ColorContentProvider.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/color/ColorContentProvider.kt @@ -4,13 +4,15 @@ import androidx.compose.material.LocalContentColor import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.graphics.Color +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun ThemedItemContentColorProvider( content: @Composable () -> Unit ) { CompositionLocalProvider( - LocalContentColor provides contentColorForColor(MaterialTheme.colors.primary), + LocalContentColor provides contentColorForColor(managerAccentColor()), content = content ) } @@ -20,7 +22,7 @@ fun ThemedCardContentColorProvider( content: @Composable () -> Unit ) { CompositionLocalProvider( - LocalContentColor provides contentColorForColor(MaterialTheme.colors.primaryVariant), + LocalContentColor provides contentColorForColor(managerAccentColor()), content = content ) } @@ -30,7 +32,7 @@ fun ThemedContentColorProvider( content: @Composable () -> Unit ) { CompositionLocalProvider( - LocalContentColor provides MaterialTheme.colors.primary, + LocalContentColor provides managerAccentColor(), content = content ) } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/components/color/ColorPicker.kt b/app/src/main/java/com/vanced/manager/ui/components/color/ColorPicker.kt index 4bcb7fb6..268097c0 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/color/ColorPicker.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/color/ColorPicker.kt @@ -2,13 +2,17 @@ package com.vanced.manager.ui.components.color import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.skydoves.colorpickerview.ColorEnvelope import com.skydoves.orchestra.colorpicker.ColorPicker +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun ManagerColorPicker( @@ -18,9 +22,10 @@ fun ManagerColorPicker( ColorPicker( modifier = Modifier .fillMaxWidth() - .height(400.dp), + .height(300.dp), onColorListener = { envelope, _ -> setColor(envelope) }, - children = {} + children = {}, + initialColor = managerAccentColor() ) onColorSelected(selectedColor.color.toLong()) } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/components/color/ManagerColors.kt b/app/src/main/java/com/vanced/manager/ui/components/color/ManagerColors.kt index 7a5905fc..4a38e1d5 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/color/ManagerColors.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/color/ManagerColors.kt @@ -4,8 +4,10 @@ import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.tween import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.luminance +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun contentColorForColor(color: Color) = @@ -15,7 +17,13 @@ fun contentColorForColor(color: Color) = Color.White @Composable -fun managerThemedCardColor() = MaterialTheme.colors.primary.copy(alpha = 0.2f) +fun managerAccentColor(): Color { + val accentColor by managerAccentColorPref + return Color(accentColor) +} + +@Composable +fun managerThemedCardColor() = managerAccentColor().copy(alpha = 0.2f) @Composable fun managerTextColor(): Color = managerAnimatedColor(color = MaterialTheme.colors.onSurface) diff --git a/app/src/main/java/com/vanced/manager/ui/components/list/CheckboxItem.kt b/app/src/main/java/com/vanced/manager/ui/components/list/CheckboxItem.kt index c290fada..6312715e 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/list/CheckboxItem.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/list/CheckboxItem.kt @@ -14,7 +14,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.color.managerTextColor +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun CheckboxItem( @@ -39,8 +41,8 @@ fun CheckboxItem( toggle() }, colors = CheckboxDefaults.colors( - MaterialTheme.colors.primary, - Color.LightGray + checkedColor = managerAccentColor(), + uncheckedColor = Color.LightGray ) ) Text( diff --git a/app/src/main/java/com/vanced/manager/ui/components/list/RadiobuttonItem.kt b/app/src/main/java/com/vanced/manager/ui/components/list/RadiobuttonItem.kt index b3d20e85..8db2b0e3 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/list/RadiobuttonItem.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/list/RadiobuttonItem.kt @@ -14,7 +14,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.color.managerTextColor +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun RadiobuttonItem( @@ -38,8 +40,8 @@ fun RadiobuttonItem( selected = selected, onClick = onClick, colors = RadioButtonDefaults.colors( - MaterialTheme.colors.primary, - Color.LightGray + selectedColor = managerAccentColor(), + unselectedColor = Color.LightGray ) ) Text( diff --git a/app/src/main/java/com/vanced/manager/ui/layouts/HomeLayout.kt b/app/src/main/java/com/vanced/manager/ui/layouts/HomeLayout.kt index a19d1de7..d41ee2b7 100644 --- a/app/src/main/java/com/vanced/manager/ui/layouts/HomeLayout.kt +++ b/app/src/main/java/com/vanced/manager/ui/layouts/HomeLayout.kt @@ -6,6 +6,7 @@ import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.util.fastForEach @@ -15,8 +16,10 @@ import com.google.accompanist.swiperefresh.rememberSwipeRefreshState import com.vanced.manager.R import com.vanced.manager.domain.model.App import com.vanced.manager.ui.components.card.ManagerLinkCard +import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.layout.ManagerScrollableColumn import com.vanced.manager.ui.components.layout.ScrollableItemRow +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref import com.vanced.manager.ui.utils.defaultContentPaddingVertical import com.vanced.manager.ui.viewmodel.HomeViewModel import com.vanced.manager.ui.widgets.home.apps.card.AppCard @@ -39,7 +42,7 @@ fun HomeLayout() { state = state, refreshTriggerDistance = trigger, scale = true, - contentColor = MaterialTheme.colors.primary + contentColor = managerAccentColor() ) } ) { diff --git a/app/src/main/java/com/vanced/manager/ui/layouts/LogLayout.kt b/app/src/main/java/com/vanced/manager/ui/layouts/LogLayout.kt index 991d1660..81189fee 100644 --- a/app/src/main/java/com/vanced/manager/ui/layouts/LogLayout.kt +++ b/app/src/main/java/com/vanced/manager/ui/layouts/LogLayout.kt @@ -7,8 +7,11 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Share import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.color.managerSurfaceColor import com.vanced.manager.ui.components.layout.ManagerLazyColumn +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref import com.vanced.manager.util.logs @Composable @@ -18,7 +21,7 @@ fun LogLayout() { floatingActionButton = { FloatingActionButton( onClick = { /*TODO*/ }, - backgroundColor = MaterialTheme.colors.primary + backgroundColor = managerAccentColor() ) { Icon( imageVector = Icons.Default.Share, diff --git a/app/src/main/java/com/vanced/manager/ui/theme/Color.kt b/app/src/main/java/com/vanced/manager/ui/theme/Color.kt index 63ecdd5f..3bb279fc 100644 --- a/app/src/main/java/com/vanced/manager/ui/theme/Color.kt +++ b/app/src/main/java/com/vanced/manager/ui/theme/Color.kt @@ -1,10 +1,11 @@ package com.vanced.manager.ui.theme import androidx.compose.ui.graphics.Color +import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.preferences.holder.managerAccentColorPref -val accentColor = Color(managerAccentColorPref.value.value) -val accentColorVariant = accentColor.copy(alpha = 0.25f) +val primaryColor = Color(defAccentColor) +val primaryColorVariant = primaryColor.copy(alpha = 0.25f) val darkOnSurface = Color(0xFFD5D5D5) diff --git a/app/src/main/java/com/vanced/manager/ui/theme/Theme.kt b/app/src/main/java/com/vanced/manager/ui/theme/Theme.kt index 70970efb..30f1da9b 100644 --- a/app/src/main/java/com/vanced/manager/ui/theme/Theme.kt +++ b/app/src/main/java/com/vanced/manager/ui/theme/Theme.kt @@ -10,14 +10,14 @@ import com.vanced.manager.ui.preferences.holder.managerThemePref const val defAccentColor = 0xFF0477E1 private val DarkColorPalette = darkColors( - primary = accentColor, - primaryVariant = accentColorVariant, + primary = primaryColor, + primaryVariant = primaryColorVariant, onSurface = darkOnSurface ) private val LightColorPalette = lightColors( - primary = accentColor, - primaryVariant = accentColorVariant, + primary = primaryColor, + primaryVariant = primaryColorVariant, surface = lightSurface, onSurface = lightOnSurface ) diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppActionCard.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppActionCard.kt index 7b3e29eb..3d46ffd9 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppActionCard.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppActionCard.kt @@ -27,44 +27,42 @@ fun AppActionCard( showInstallationOptions: MutableState, hasInstallationOptions: Boolean ) { - ThemedCardContentColorProvider { - Row( - modifier = Modifier.padding(horizontal = defaultContentPaddingHorizontal, vertical = 12.dp), - verticalAlignment = Alignment.CenterVertically + Row( + modifier = Modifier.padding(horizontal = defaultContentPaddingHorizontal, vertical = 12.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Column( + modifier = Modifier + .weight(1f) + .wrapContentWidth(Alignment.Start), + verticalArrangement = Arrangement.spacedBy(4.dp) ) { - Column( - modifier = Modifier - .weight(1f) - .wrapContentWidth(Alignment.Start), - verticalArrangement = Arrangement.spacedBy(4.dp) - ) { - ManagerText(stringId = R.string.app_versions) - AppVersionText( - stringId = R.string.app_version_latest, - version = appRemoteVersion - ) - AppVersionText( - stringId = R.string.app_version_installed, - version = appInstalledVersion - ) + ManagerText(stringId = R.string.app_versions) + AppVersionText( + stringId = R.string.app_version_latest, + version = appRemoteVersion + ) + AppVersionText( + stringId = R.string.app_version_installed, + version = appInstalledVersion + ) + } + Row( + modifier = Modifier + .weight(1f) + .padding(start = 4.dp) + .wrapContentWidth(Alignment.End) + ) { + IconButton(icon = Icons.Outlined.Info, contentDescription = "App Info") { + showAppInfo.value = true } - Row( - modifier = Modifier - .weight(1f) - .padding(start = 4.dp) - .wrapContentWidth(Alignment.End) - ) { - IconButton(icon = Icons.Outlined.Info, contentDescription = "App Info") { - showAppInfo.value = true - } - IconButton(icon = Icons.Rounded.DeleteForever, contentDescription = "Uninstall") {} - IconButton(icon = Icons.Rounded.Launch, contentDescription = "Launch") {} - IconButton(icon = Icons.Rounded.Download, contentDescription = "Install") { - if (hasInstallationOptions) { - showInstallationOptions.value = true - } else { - showDownloadDialog.value = true - } + IconButton(icon = Icons.Rounded.DeleteForever, contentDescription = "Uninstall") {} + IconButton(icon = Icons.Rounded.Launch, contentDescription = "Launch") {} + IconButton(icon = Icons.Rounded.Download, contentDescription = "Install") { + if (hasInstallationOptions) { + showInstallationOptions.value = true + } else { + showDownloadDialog.value = true } } } diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogProgress.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogProgress.kt index 025c95f8..3e4b17b5 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogProgress.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogProgress.kt @@ -3,11 +3,13 @@ package com.vanced.manager.ui.widgets.home.download import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.material.LinearProgressIndicator -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import com.vanced.manager.ui.components.color.managerAccentColor +import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun AppDownloadDialogProgress( @@ -18,10 +20,10 @@ fun AppDownloadDialogProgress( ) { if (showProgress) { when (installing) { - true -> LinearProgressIndicator(color = MaterialTheme.colors.primary) + true -> LinearProgressIndicator(color = managerAccentColor()) false -> LinearProgressIndicator( progress = progress, - color = MaterialTheme.colors.primary + color = managerAccentColor() ) } Row { diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/settings/AccentColorItem.kt b/app/src/main/java/com/vanced/manager/ui/widgets/settings/AccentColorItem.kt index 3319daec..30a8dfaa 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/settings/AccentColorItem.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/settings/AccentColorItem.kt @@ -1,7 +1,9 @@ package com.vanced.manager.ui.widgets.settings import androidx.compose.runtime.* +import androidx.compose.ui.graphics.Color import com.vanced.manager.R +import com.vanced.manager.ui.components.button.ManagerThemedTextButton import com.vanced.manager.ui.components.color.ManagerColorPicker import com.vanced.manager.ui.components.preference.DialogPreference import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @@ -11,9 +13,15 @@ fun SettingsAccentColorItem() { var localAccentColor by remember { mutableStateOf(managerAccentColorPref.value.value) } DialogPreference( preferenceTitleId = R.string.settings_preference_accent_color_title, - preferenceDescription = localAccentColor.toString(), - buttons = { - + preferenceDescription = "#" + Integer.toHexString(localAccentColor.toInt()), + buttons = { isShown -> + ManagerThemedTextButton( + stringId = R.string.dialog_button_save, + backgroundColor = Color(localAccentColor) + ) { + isShown.value = false + managerAccentColorPref.save(localAccentColor) + } } ) { ManagerColorPicker {