more refactor
This commit is contained in:
parent
735a91606c
commit
a9cfa22468
|
@ -0,0 +1,6 @@
|
|||
package com.vanced.manager.domain.model
|
||||
|
||||
data class NotificationPrefModel(
|
||||
val app: String,
|
||||
val prefKey: String
|
||||
)
|
|
@ -78,7 +78,7 @@ class AppDtoMapper(
|
|||
when (app.name) {
|
||||
VANCED_NAME -> listOf(
|
||||
RadiobuttonInstallationOption(
|
||||
title = R.string.app_installation_options_theme,
|
||||
titleId = R.string.app_installation_options_theme,
|
||||
preference = vancedThemePref,
|
||||
buttons = app.versions?.map {
|
||||
RadioButtonPreference(
|
||||
|
@ -88,7 +88,7 @@ class AppDtoMapper(
|
|||
} ?: emptyList()
|
||||
),
|
||||
RadiobuttonInstallationOption(
|
||||
title = R.string.app_installation_options_version,
|
||||
titleId = R.string.app_installation_options_version,
|
||||
preference = vancedVersionPref,
|
||||
buttons = app.versions?.map {
|
||||
RadioButtonPreference(
|
||||
|
@ -98,7 +98,7 @@ class AppDtoMapper(
|
|||
} ?: emptyList()
|
||||
),
|
||||
CheckboxInstallationOption(
|
||||
title = R.string.app_installation_options_language,
|
||||
titleId = R.string.app_installation_options_language,
|
||||
preference = vancedLanguagesPref,
|
||||
buttons = app.versions?.map {
|
||||
CheckboxPreference(
|
||||
|
@ -110,7 +110,7 @@ class AppDtoMapper(
|
|||
)
|
||||
MUSIC_NAME -> listOf(
|
||||
RadiobuttonInstallationOption(
|
||||
title = R.string.app_installation_options_version,
|
||||
titleId = R.string.app_installation_options_version,
|
||||
preference = musicVersionPref,
|
||||
buttons = app.versions?.map {
|
||||
RadioButtonPreference(
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.vanced.manager.ui.components.color.managerAnimatedColor
|
|||
import com.vanced.manager.ui.components.color.managerSurfaceColor
|
||||
import com.vanced.manager.ui.components.color.managerTextColor
|
||||
import com.vanced.manager.ui.components.menu.ManagerDropdownMenuItem
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
import com.vanced.manager.ui.screens.Screen
|
||||
import com.vanced.manager.ui.theme.ManagerTheme
|
||||
import com.vanced.manager.ui.theme.isDark
|
||||
|
@ -90,7 +91,7 @@ class MainActivity : AppCompatActivity() {
|
|||
val currentScreenRoute = navController.currentBackStackEntryAsState().value?.destination?.route
|
||||
TopAppBar(
|
||||
title = {
|
||||
ToolbarTitleText(screens.find { it.route == currentScreenRoute }?.displayName)
|
||||
ToolbarTitleText(managerString(stringId = screens.find { it.route == currentScreenRoute }?.displayName))
|
||||
},
|
||||
backgroundColor = managerAnimatedColor(color = MaterialTheme.colors.surface),
|
||||
actions = {
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
|
|||
fun ManagerThemedTextButton(
|
||||
modifier: Modifier = Modifier,
|
||||
backgroundColor: Color = managerAccentColor(),
|
||||
@StringRes stringId: Int,
|
||||
text: String,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
ManagerThemedButton(
|
||||
|
@ -21,6 +21,6 @@ fun ManagerThemedTextButton(
|
|||
backgroundColor = backgroundColor,
|
||||
onClick = onClick
|
||||
) {
|
||||
ManagerText(stringId = stringId)
|
||||
ManagerText(text = text)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.vanced.manager.ui.components.dialog
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
|
@ -15,27 +14,6 @@ import com.vanced.manager.ui.components.card.ManagerCard
|
|||
import com.vanced.manager.ui.components.text.ManagerText
|
||||
import com.vanced.manager.ui.utils.defaultContentPaddingHorizontal
|
||||
|
||||
@Composable
|
||||
fun ManagerDialog(
|
||||
@StringRes titleId: Int,
|
||||
onDismissRequest: () -> Unit,
|
||||
buttons: @Composable ColumnScope.() -> Unit,
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
ManagerDialog(
|
||||
title = {
|
||||
ManagerText(
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
stringId = titleId,
|
||||
textStyle = MaterialTheme.typography.h2
|
||||
)
|
||||
},
|
||||
onDismissRequest = onDismissRequest,
|
||||
buttons = buttons,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ManagerDialog(
|
||||
title: String,
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.vanced.manager.ui.components.layout
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.google.accompanist.swiperefresh.SwipeRefresh
|
||||
import com.google.accompanist.swiperefresh.SwipeRefreshIndicator
|
||||
import com.google.accompanist.swiperefresh.SwipeRefreshState
|
||||
import com.vanced.manager.ui.components.color.managerAccentColor
|
||||
|
||||
@Composable
|
||||
fun ManagerSwipeRefresh(
|
||||
refreshState: SwipeRefreshState,
|
||||
onRefresh: () -> Unit,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
SwipeRefresh(
|
||||
state = refreshState,
|
||||
onRefresh = onRefresh,
|
||||
indicator = { state, trigger ->
|
||||
SwipeRefreshIndicator(
|
||||
state = state,
|
||||
refreshTriggerDistance = trigger,
|
||||
scale = true,
|
||||
contentColor = managerAccentColor()
|
||||
)
|
||||
},
|
||||
content = content
|
||||
)
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.vanced.manager.ui.components.preference
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
|
@ -9,6 +8,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.toMutableStateList
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.button.ManagerThemedTextButton
|
||||
import com.vanced.manager.ui.components.list.CheckboxItem
|
||||
|
@ -18,27 +18,28 @@ import kotlinx.coroutines.launch
|
|||
|
||||
@Composable
|
||||
fun CheckboxDialogPreference(
|
||||
@StringRes preferenceTitle: Int,
|
||||
@StringRes preferenceDescription: Int? = null,
|
||||
preferenceTitle: String,
|
||||
preferenceDescriptionConverter: (values: List<String>) -> String = { it.joinToString(separator = ", ") },
|
||||
preference: ManagerPreference<Set<String>>,
|
||||
trailing: @Composable () -> Unit = {},
|
||||
buttons: List<CheckboxPreference>,
|
||||
onSave: (checkedButtons: List<String>) -> Unit = {}
|
||||
) {
|
||||
val selectedButtons = remember { preference.value.value.toMutableStateList() }
|
||||
var pref by preference
|
||||
val selectedButtons = remember { pref.toMutableStateList() }
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
DialogPreference(
|
||||
preferenceTitleId = preferenceTitle,
|
||||
preferenceDescriptionId = preferenceDescription,
|
||||
preferenceTitle = preferenceTitle,
|
||||
preferenceDescription = preferenceDescriptionConverter(selectedButtons),
|
||||
trailing = trailing,
|
||||
buttons = { isShown ->
|
||||
ManagerThemedTextButton(
|
||||
stringId = R.string.dialog_button_save,
|
||||
text = stringResource(id = R.string.dialog_button_save),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = {
|
||||
coroutineScope.launch {
|
||||
isShown.value = false
|
||||
preference.save(selectedButtons.toSet())
|
||||
pref = selectedButtons.toSet()
|
||||
onSave(selectedButtons)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,11 @@
|
|||
package com.vanced.manager.ui.components.preference
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import com.vanced.manager.ui.components.checkbox.ManagerCheckbox
|
||||
import com.vanced.manager.ui.preferences.ManagerPreference
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun CheckboxPreference(
|
||||
@StringRes preferenceTitle: Int,
|
||||
@StringRes preferenceDescription: Int? = null,
|
||||
preference: ManagerPreference<Boolean>,
|
||||
onCheckedChange: (isChecked: Boolean) -> Unit = {}
|
||||
) {
|
||||
val isChecked by preference
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
val onClick: () -> Unit = {
|
||||
coroutineScope.launch {
|
||||
preference.save(!isChecked)
|
||||
onCheckedChange(isChecked)
|
||||
}
|
||||
}
|
||||
|
||||
Preference(
|
||||
preferenceTitleId = preferenceTitle,
|
||||
preferenceDescriptionId = preferenceDescription,
|
||||
onClick = onClick,
|
||||
trailing = {
|
||||
ManagerCheckbox(
|
||||
isChecked = isChecked,
|
||||
onCheckedChange = { onClick() }
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CheckboxPreference(
|
||||
preferenceTitle: String,
|
||||
|
@ -44,16 +13,15 @@ fun CheckboxPreference(
|
|||
preference: ManagerPreference<Boolean>,
|
||||
onCheckedChange: (isChecked: Boolean) -> Unit = {}
|
||||
) {
|
||||
val isChecked by preference
|
||||
var isChecked by preference
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
val onClick: () -> Unit = {
|
||||
coroutineScope.launch {
|
||||
preference.save(!isChecked)
|
||||
isChecked = !isChecked
|
||||
onCheckedChange(isChecked)
|
||||
}
|
||||
}
|
||||
|
||||
Preference(
|
||||
preferenceTitle = preferenceTitle,
|
||||
preferenceDescription = preferenceDescription,
|
||||
|
|
|
@ -8,62 +8,6 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import com.vanced.manager.ui.components.dialog.ManagerDialog
|
||||
|
||||
@Composable
|
||||
fun DialogPreference(
|
||||
@StringRes preferenceTitleId: Int,
|
||||
@StringRes preferenceDescriptionId: Int? = null,
|
||||
trailing: @Composable () -> Unit = {},
|
||||
buttons: @Composable ColumnScope.(isShown: MutableState<Boolean>) -> Unit,
|
||||
content: @Composable ColumnScope.() -> Unit
|
||||
) {
|
||||
val isShown = remember { mutableStateOf(false) }
|
||||
Preference(
|
||||
preferenceTitleId = preferenceTitleId,
|
||||
preferenceDescriptionId = preferenceDescriptionId,
|
||||
trailing = trailing
|
||||
) {
|
||||
isShown.value = true
|
||||
}
|
||||
if (isShown.value) {
|
||||
ManagerDialog(
|
||||
titleId = preferenceTitleId,
|
||||
onDismissRequest = {
|
||||
isShown.value = false
|
||||
},
|
||||
buttons = { buttons(isShown) },
|
||||
content = content
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DialogPreference(
|
||||
@StringRes preferenceTitleId: Int,
|
||||
preferenceDescription: String? = null,
|
||||
trailing: @Composable () -> Unit = {},
|
||||
buttons: @Composable ColumnScope.(isShown: MutableState<Boolean>) -> Unit,
|
||||
content: @Composable ColumnScope.() -> Unit
|
||||
) {
|
||||
val isShown = remember { mutableStateOf(false) }
|
||||
Preference(
|
||||
preferenceTitleId = preferenceTitleId,
|
||||
preferenceDescription = preferenceDescription,
|
||||
trailing = trailing
|
||||
) {
|
||||
isShown.value = true
|
||||
}
|
||||
if (isShown.value) {
|
||||
ManagerDialog(
|
||||
titleId = preferenceTitleId,
|
||||
onDismissRequest = {
|
||||
isShown.value = false
|
||||
},
|
||||
buttons = { buttons(isShown) },
|
||||
content = content
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DialogPreference(
|
||||
preferenceTitle: String,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.vanced.manager.ui.components.preference
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.LocalContentColor
|
||||
|
@ -14,40 +13,6 @@ import com.vanced.manager.ui.components.list.ManagerListItem
|
|||
import com.vanced.manager.ui.components.text.ManagerText
|
||||
import com.vanced.manager.ui.utils.defaultContentPaddingHorizontal
|
||||
|
||||
@Composable
|
||||
fun Preference(
|
||||
@StringRes preferenceTitleId: Int,
|
||||
@StringRes preferenceDescriptionId: Int? = null,
|
||||
trailing: @Composable () -> Unit = {},
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
Preference(
|
||||
preferenceTitle = { ManagerText(stringId = preferenceTitleId) },
|
||||
preferenceDescription = if (preferenceDescriptionId != null) {{
|
||||
ManagerText(stringId = preferenceDescriptionId)
|
||||
}} else null,
|
||||
trailing = trailing,
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Preference(
|
||||
@StringRes preferenceTitleId: Int,
|
||||
preferenceDescription: String? = null,
|
||||
trailing: @Composable () -> Unit = {},
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
Preference(
|
||||
preferenceTitle = { ManagerText(stringId = preferenceTitleId) },
|
||||
preferenceDescription = if (preferenceDescription != null) {{
|
||||
ManagerText(text = preferenceDescription)
|
||||
}} else null,
|
||||
trailing = trailing,
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Preference(
|
||||
preferenceTitle: String,
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
package com.vanced.manager.ui.components.preference
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.button.ManagerThemedTextButton
|
||||
import com.vanced.manager.ui.components.list.RadiobuttonItem
|
||||
import com.vanced.manager.ui.preferences.ManagerPreference
|
||||
import com.vanced.manager.ui.preferences.RadioButtonPreference
|
||||
import com.vanced.manager.ui.widgets.button.ManagerSaveButton
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun RadiobuttonDialogPreference(
|
||||
@StringRes preferenceTitle: Int,
|
||||
preferenceTitle: String,
|
||||
preferenceDescriptionConverter: (value: String) -> String = { it },
|
||||
preference: ManagerPreference<String>,
|
||||
trailing: @Composable () -> Unit = {},
|
||||
buttons: List<RadioButtonPreference>,
|
||||
|
@ -26,21 +24,17 @@ fun RadiobuttonDialogPreference(
|
|||
val coroutineScope = rememberCoroutineScope()
|
||||
var currentSelection by remember { mutableStateOf(preference.value.value) }
|
||||
DialogPreference(
|
||||
preferenceTitleId = preferenceTitle,
|
||||
preferenceDescription = currentSelection,
|
||||
preferenceTitle = preferenceTitle,
|
||||
preferenceDescription = preferenceDescriptionConverter(currentSelection),
|
||||
trailing = trailing,
|
||||
buttons = { isShown ->
|
||||
ManagerThemedTextButton(
|
||||
stringId = R.string.dialog_button_save,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = {
|
||||
coroutineScope.launch {
|
||||
isShown.value = false
|
||||
preference.save(currentSelection)
|
||||
onSave(currentSelection)
|
||||
}
|
||||
ManagerSaveButton {
|
||||
coroutineScope.launch {
|
||||
isShown.value = false
|
||||
preference.save(currentSelection)
|
||||
onSave(currentSelection)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
) {
|
||||
LazyColumn(
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
package com.vanced.manager.ui.components.text
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.lifecycle.managerString
|
||||
|
||||
@Composable
|
||||
fun AppVersionText(
|
||||
@StringRes stringId: Int,
|
||||
version: String?
|
||||
text: String
|
||||
) {
|
||||
ManagerText(
|
||||
version ?: managerString(stringId = R.string.app_content_unavailable),
|
||||
stringId = stringId,
|
||||
text = text,
|
||||
textStyle = MaterialTheme.typography.body2,
|
||||
)
|
||||
}
|
|
@ -10,11 +10,11 @@ import com.vanced.manager.ui.utils.defaultContentPaddingHorizontal
|
|||
|
||||
@Composable
|
||||
fun CategoryTitleText(
|
||||
@StringRes stringId: Int
|
||||
text: String
|
||||
) {
|
||||
ManagerText(
|
||||
modifier = Modifier.padding(start = defaultContentPaddingHorizontal),
|
||||
stringId = stringId,
|
||||
text = text,
|
||||
textStyle = MaterialTheme.typography.h2,
|
||||
color = managerAnimatedColor(MaterialTheme.colors.onSurface)
|
||||
)
|
||||
|
|
|
@ -6,23 +6,6 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import com.vanced.manager.ui.components.lifecycle.managerString
|
||||
|
||||
@Composable
|
||||
fun ManagerText(
|
||||
vararg formatArgs: Any,
|
||||
modifier: Modifier = Modifier,
|
||||
color: Color = Color.Unspecified,
|
||||
textStyle: TextStyle = LocalTextStyle.current,
|
||||
stringId: Int?,
|
||||
) {
|
||||
ManagerText(
|
||||
modifier = modifier,
|
||||
color = color,
|
||||
textStyle = textStyle,
|
||||
text = managerString(stringId, *formatArgs),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ManagerText(
|
||||
|
|
|
@ -6,10 +6,10 @@ import com.vanced.manager.ui.components.color.managerAnimatedColor
|
|||
|
||||
@Composable
|
||||
fun ToolbarTitleText(
|
||||
stringId: Int?
|
||||
text: String
|
||||
) {
|
||||
ManagerText(
|
||||
stringId = stringId,
|
||||
text = text,
|
||||
textStyle = MaterialTheme.typography.h1,
|
||||
color = managerAnimatedColor(MaterialTheme.colors.onSurface)
|
||||
)
|
||||
|
|
|
@ -3,16 +3,15 @@ package com.vanced.manager.ui.layouts
|
|||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
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 androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
@ -22,7 +21,7 @@ import com.vanced.manager.ui.components.card.ManagerLinkCard
|
|||
import com.vanced.manager.ui.components.card.ManagerThemedCard
|
||||
import com.vanced.manager.ui.components.layout.ManagerScrollableColumn
|
||||
import com.vanced.manager.ui.components.layout.ScrollableItemRow
|
||||
import com.vanced.manager.ui.components.lifecycle.managerString
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
import com.vanced.manager.ui.components.list.ManagerListItem
|
||||
import com.vanced.manager.ui.components.text.ManagerText
|
||||
import com.vanced.manager.ui.widgets.layout.CategoryLayout
|
||||
|
@ -126,7 +125,7 @@ fun AboutLayout() {
|
|||
AboutManagerCard()
|
||||
credits.fastForEach { credit ->
|
||||
CategoryLayout(
|
||||
categoryNameId = credit.nameId,
|
||||
categoryName = managerString(stringId = credit.nameId),
|
||||
categoryNameSpacing = 4.dp
|
||||
) {
|
||||
Column {
|
||||
|
@ -149,7 +148,11 @@ fun AboutLayout() {
|
|||
}
|
||||
}
|
||||
}
|
||||
CategoryLayout(categoryNameId = R.string.about_category_sources) {
|
||||
CategoryLayout(
|
||||
categoryName = managerString(
|
||||
stringId = R.string.about_category_sources
|
||||
),
|
||||
) {
|
||||
ScrollableItemRow(items = sources) { source ->
|
||||
ManagerLinkCard(
|
||||
title = managerString(source.nameId),
|
||||
|
@ -165,25 +168,14 @@ fun AboutLayout() {
|
|||
fun AboutManagerCard() {
|
||||
ManagerThemedCard {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
// .clip(managerShape())
|
||||
// .background(
|
||||
// Brush.horizontalGradient(
|
||||
// colors = listOf(
|
||||
// vancedBlue,
|
||||
// vancedRed
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
modifier = Modifier,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
text = "Vanced Manager",
|
||||
textAlign = TextAlign.Center,
|
||||
text = managerString(stringId = R.string.app_name),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 8.dp),
|
||||
fontSize = 30.sp,
|
||||
color = Color.White
|
||||
)
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
|
@ -193,12 +185,9 @@ fun AboutManagerCard() {
|
|||
}
|
||||
append("d")
|
||||
},
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 8.dp),
|
||||
fontSize = 16.sp,
|
||||
color = Color.White
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,21 @@
|
|||
package com.vanced.manager.ui.layouts
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
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
|
||||
import com.google.accompanist.swiperefresh.SwipeRefresh
|
||||
import com.google.accompanist.swiperefresh.SwipeRefreshIndicator
|
||||
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.components.layout.ManagerSwipeRefresh
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
import com.vanced.manager.ui.utils.defaultContentPaddingVertical
|
||||
import com.vanced.manager.ui.viewmodel.HomeViewModel
|
||||
import com.vanced.manager.ui.widgets.home.apps.card.AppCard
|
||||
import com.vanced.manager.ui.widgets.home.apps.HomeAppsItem
|
||||
import com.vanced.manager.ui.widgets.home.socialmedia.HomeSocialMediaItem
|
||||
import com.vanced.manager.ui.widgets.home.sponsors.HomeSponsorsItem
|
||||
import com.vanced.manager.ui.widgets.layout.CategoryLayout
|
||||
import com.vanced.manager.util.socialMedia
|
||||
import com.vanced.manager.util.sponsors
|
||||
import org.koin.androidx.compose.getViewModel
|
||||
|
||||
@Composable
|
||||
|
@ -34,52 +24,35 @@ fun HomeLayout() {
|
|||
val viewModel: HomeViewModel = getViewModel()
|
||||
val isFetching by viewModel.isFetching.observeAsState(false)
|
||||
val refreshState = rememberSwipeRefreshState(isRefreshing = isFetching)
|
||||
SwipeRefresh(
|
||||
state = refreshState,
|
||||
onRefresh = { viewModel.fetch() },
|
||||
indicator = { state, trigger ->
|
||||
SwipeRefreshIndicator(
|
||||
state = state,
|
||||
refreshTriggerDistance = trigger,
|
||||
scale = true,
|
||||
contentColor = managerAccentColor()
|
||||
)
|
||||
}
|
||||
ManagerSwipeRefresh(
|
||||
refreshState = refreshState,
|
||||
onRefresh = { viewModel.fetch() }
|
||||
) {
|
||||
ManagerScrollableColumn(
|
||||
contentPaddingVertical = defaultContentPaddingVertical,
|
||||
itemSpacing = 18.dp
|
||||
) {
|
||||
CategoryLayout(
|
||||
categoryNameId = R.string.home_category_apps,
|
||||
categoryName = managerString(
|
||||
stringId = R.string.home_category_apps
|
||||
),
|
||||
contentPaddingHorizontal = 0.dp
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
viewModel.apps.fastForEach { app ->
|
||||
val observedApp by app.observeAsState(initial = App())
|
||||
AppCard(observedApp, isFetching)
|
||||
}
|
||||
}
|
||||
HomeAppsItem(viewModel, isFetching)
|
||||
}
|
||||
CategoryLayout(categoryNameId = R.string.home_category_support_us) {
|
||||
ScrollableItemRow(items = sponsors) { sponsor ->
|
||||
ManagerLinkCard(
|
||||
icon = sponsor.icon,
|
||||
title = sponsor.title,
|
||||
link = sponsor.link
|
||||
)
|
||||
}
|
||||
CategoryLayout(
|
||||
categoryName = managerString(
|
||||
stringId = R.string.home_category_support_us
|
||||
)
|
||||
) {
|
||||
HomeSponsorsItem()
|
||||
}
|
||||
CategoryLayout(categoryNameId = R.string.home_category_social_media) {
|
||||
ScrollableItemRow(items = socialMedia) { socialMedia ->
|
||||
ManagerLinkCard(
|
||||
icon = socialMedia.icon,
|
||||
title = socialMedia.title,
|
||||
link = socialMedia.link
|
||||
)
|
||||
}
|
||||
CategoryLayout(
|
||||
categoryName = managerString(
|
||||
stringId = R.string.home_category_social_media
|
||||
)
|
||||
) {
|
||||
HomeSocialMediaItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,14 @@
|
|||
package com.vanced.manager.ui.layouts
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.layout.ManagerScrollableColumn
|
||||
import com.vanced.manager.ui.components.preference.CheckboxPreference
|
||||
import com.vanced.manager.ui.components.preference.Preference
|
||||
import com.vanced.manager.ui.components.preference.RadiobuttonDialogPreference
|
||||
import com.vanced.manager.ui.preferences.RadioButtonPreference
|
||||
import com.vanced.manager.ui.preferences.holder.managerVariantPref
|
||||
import com.vanced.manager.ui.preferences.holder.useCustomTabsPref
|
||||
import com.vanced.manager.ui.preferences.managerBooleanPreference
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
import com.vanced.manager.ui.utils.defaultContentPaddingVertical
|
||||
import com.vanced.manager.ui.widgets.layout.CategoryLayout
|
||||
import com.vanced.manager.ui.widgets.settings.SettingsAccentColorItem
|
||||
import com.vanced.manager.ui.widgets.settings.ThemeSettingsItem
|
||||
|
||||
data class NotificationPrefModel(
|
||||
val app: String,
|
||||
val prefKey: String
|
||||
)
|
||||
|
||||
private val notificationApps = arrayOf(
|
||||
NotificationPrefModel(
|
||||
app = "YouTube Vanced",
|
||||
prefKey = "vanced"
|
||||
),
|
||||
NotificationPrefModel(
|
||||
app = "YouTube Music Vanced",
|
||||
prefKey = "music"
|
||||
),
|
||||
NotificationPrefModel(
|
||||
app = "Vanced microG",
|
||||
prefKey = "microg"
|
||||
)
|
||||
)
|
||||
import com.vanced.manager.ui.widgets.layout.SettingsCategoryLayout
|
||||
import com.vanced.manager.ui.widgets.settings.*
|
||||
|
||||
@Composable
|
||||
fun SettingsLayout() {
|
||||
|
@ -43,59 +16,23 @@ fun SettingsLayout() {
|
|||
contentPaddingVertical = defaultContentPaddingVertical,
|
||||
itemSpacing = 12.dp
|
||||
) {
|
||||
CategoryLayout(
|
||||
categoryNameId = R.string.settings_category_behaviour,
|
||||
contentPaddingHorizontal = 0.dp,
|
||||
categoryNameSpacing = 4.dp
|
||||
SettingsCategoryLayout(
|
||||
categoryName = managerString(
|
||||
stringId = R.string.settings_category_behaviour
|
||||
)
|
||||
) {
|
||||
Column {
|
||||
CheckboxPreference(
|
||||
preferenceTitle = R.string.settings_preference_use_custom_tabs_title,
|
||||
preferenceDescription = R.string.settings_preference_use_custom_tabs_summary,
|
||||
preference = useCustomTabsPref
|
||||
)
|
||||
notificationApps.forEach {
|
||||
with(it) {
|
||||
CheckboxPreference(
|
||||
preferenceTitle = "$app Push Notifications",
|
||||
preferenceDescription = "Receive push notifications when an update for $app is released",
|
||||
preference = managerBooleanPreference(
|
||||
key = "${prefKey}_notifications",
|
||||
defaultValue = true
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
RadiobuttonDialogPreference(
|
||||
preferenceTitle = R.string.settings_preference_variant_title,
|
||||
preference = managerVariantPref,
|
||||
buttons = listOf(
|
||||
RadioButtonPreference(
|
||||
title = "nonroot",
|
||||
key = "nonroot"
|
||||
),
|
||||
RadioButtonPreference(
|
||||
title = "root",
|
||||
key = "root"
|
||||
),
|
||||
)
|
||||
)
|
||||
Preference(
|
||||
preferenceTitleId = R.string.settings_preference_clear_files_title,
|
||||
preferenceDescriptionId = null,
|
||||
onClick = {}
|
||||
)
|
||||
}
|
||||
SettingsCustomTabsItem()
|
||||
SettingsNotificationsItem()
|
||||
SettingsManagerVariantItem()
|
||||
|
||||
}
|
||||
CategoryLayout(
|
||||
categoryNameId = R.string.settings_category_appearance,
|
||||
contentPaddingHorizontal = 0.dp,
|
||||
categoryNameSpacing = 4.dp
|
||||
SettingsCategoryLayout(
|
||||
categoryName = managerString(
|
||||
stringId = R.string.settings_category_appearance
|
||||
)
|
||||
) {
|
||||
Column {
|
||||
SettingsAccentColorItem()
|
||||
ThemeSettingsItem()
|
||||
}
|
||||
SettingsAccentColorItem()
|
||||
ThemeSettingsItem()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@ class ManagerPreference<T>(
|
|||
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>) = value.value
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, newValue: T) {
|
||||
save(newValue)
|
||||
}
|
||||
|
||||
fun save(newValue: T) {
|
||||
_value.value = newValue
|
||||
sharedPreferences.edit {
|
||||
|
@ -34,7 +38,7 @@ class ManagerPreference<T>(
|
|||
}
|
||||
}
|
||||
|
||||
//It's Chewsday innit - © Bri'ish ppl
|
||||
//It's Chewsday innit
|
||||
init {
|
||||
_value.value = getter(sharedPreferences)
|
||||
}
|
||||
|
|
|
@ -2,5 +2,11 @@ package com.vanced.manager.ui.preferences.holder
|
|||
|
||||
const val MANAGER_VARIANT_DEFAULT_VALUE = "nonroot"
|
||||
|
||||
const val VANCED_ENABLED_DEFAULT_VALUE = true
|
||||
const val MUSIC_ENABLED_DEFAULT_VALUE = true
|
||||
const val MANAGER_THEME_DEFAULT_VALUE = "System Default"
|
||||
|
||||
const val VANCED_THEME_DEFAULT_VALUE = "Dark"
|
||||
val VANCED_LANGUAGE_DEFAULT_VALUE = setOf("en")
|
||||
|
||||
const val APP_VERSION_DEFAULT_VALUE = "latest"
|
||||
|
||||
const val APP_ENABLED_DEFAULT_VALUE = true
|
|
@ -7,17 +7,16 @@ import com.vanced.manager.ui.preferences.managerStringSetPreference
|
|||
import com.vanced.manager.ui.theme.defAccentColor
|
||||
|
||||
val useCustomTabsPref = managerBooleanPreference(USE_CUSTOM_TABS_KEY)
|
||||
|
||||
val managerVariantPref = managerStringPreference(MANAGER_VARIANT_KEY, MANAGER_VARIANT_DEFAULT_VALUE)
|
||||
|
||||
val managerThemePref = managerStringPreference(MANAGER_THEME_KEY, "System Default")
|
||||
val managerThemePref = managerStringPreference(MANAGER_THEME_KEY, MANAGER_THEME_DEFAULT_VALUE)
|
||||
val managerAccentColorPref = managerLongPreference(MANAGER_ACCENT_COLOR_KEY, defAccentColor)
|
||||
|
||||
val vancedThemePref = managerStringPreference(APP_VANCED_THEME_KEY, "Dark")
|
||||
val vancedVersionPref = managerStringPreference(APP_VANCED_VERSION_KEY, "latest")
|
||||
val vancedLanguagesPref = managerStringSetPreference(APP_VANCED_LANGUAGE_KEY, setOf("en"))
|
||||
val vancedThemePref = managerStringPreference(APP_VANCED_THEME_KEY, VANCED_THEME_DEFAULT_VALUE)
|
||||
val vancedVersionPref = managerStringPreference(APP_VANCED_VERSION_KEY, APP_VERSION_DEFAULT_VALUE)
|
||||
val vancedLanguagesPref = managerStringSetPreference(APP_VANCED_LANGUAGE_KEY, VANCED_LANGUAGE_DEFAULT_VALUE)
|
||||
|
||||
val musicVersionPref = managerStringPreference(APP_MUSIC_VERSION_KEY, "latest")
|
||||
val musicVersionPref = managerStringPreference(APP_MUSIC_VERSION_KEY, APP_VERSION_DEFAULT_VALUE)
|
||||
|
||||
val vancedEnabled = managerBooleanPreference(VANCED_ENABLED_KEY, VANCED_ENABLED_DEFAULT_VALUE)
|
||||
val musicEnabled = managerBooleanPreference(MUSIC_ENABLED_KEY, MUSIC_ENABLED_DEFAULT_VALUE)
|
||||
val vancedEnabled = managerBooleanPreference(VANCED_ENABLED_KEY, APP_ENABLED_DEFAULT_VALUE)
|
||||
val musicEnabled = managerBooleanPreference(MUSIC_ENABLED_KEY, APP_ENABLED_DEFAULT_VALUE)
|
|
@ -1,4 +1,4 @@
|
|||
package com.vanced.manager.ui.components.lifecycle
|
||||
package com.vanced.manager.ui.resources
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.Composable
|
|
@ -0,0 +1,21 @@
|
|||
package com.vanced.manager.ui.widgets.button
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.button.ManagerThemedTextButton
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
|
||||
@Composable
|
||||
fun ManagerCancelButton(
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
ManagerThemedTextButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = managerString(
|
||||
stringId = R.string.dialog_button_cancel
|
||||
),
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.vanced.manager.ui.widgets.button
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.button.ManagerThemedTextButton
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
|
||||
@Composable
|
||||
fun ManagerCloseButton(
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
ManagerThemedTextButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = managerString(
|
||||
stringId = R.string.dialog_button_close
|
||||
),
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.vanced.manager.ui.widgets.button
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.button.ManagerThemedTextButton
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
|
||||
@Composable
|
||||
fun ManagerDownloadButton(
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
ManagerThemedTextButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = managerString(
|
||||
stringId = R.string.app_download_dialog_confirm
|
||||
),
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.vanced.manager.ui.widgets.button
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
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.managerAccentColor
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
|
||||
@Composable
|
||||
fun ManagerSaveButton(
|
||||
backgroundColor: Color = managerAccentColor(),
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
ManagerThemedTextButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = managerString(
|
||||
stringId = R.string.dialog_button_save
|
||||
),
|
||||
backgroundColor = backgroundColor,
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.vanced.manager.ui.widgets.home.apps
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.util.fastForEach
|
||||
import com.vanced.manager.domain.model.App
|
||||
import com.vanced.manager.ui.viewmodel.HomeViewModel
|
||||
import com.vanced.manager.ui.widgets.home.apps.card.AppCard
|
||||
|
||||
@Composable
|
||||
fun HomeAppsItem(
|
||||
viewModel: HomeViewModel,
|
||||
isFetching: Boolean
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
viewModel.apps.fastForEach { app ->
|
||||
val observedApp by app.observeAsState(initial = App())
|
||||
AppCard(observedApp, isFetching)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,10 +10,10 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.button.IconButton
|
||||
import com.vanced.manager.ui.components.color.ThemedCardContentColorProvider
|
||||
import com.vanced.manager.ui.components.text.ManagerText
|
||||
import com.vanced.manager.ui.utils.defaultContentPaddingHorizontal
|
||||
import com.vanced.manager.ui.components.text.AppVersionText
|
||||
|
@ -37,14 +37,24 @@ fun AppActionCard(
|
|||
.wrapContentWidth(Alignment.Start),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
ManagerText(stringId = R.string.app_versions)
|
||||
AppVersionText(
|
||||
stringId = R.string.app_version_latest,
|
||||
version = appRemoteVersion
|
||||
ManagerText(
|
||||
text = stringResource(id = R.string.app_versions)
|
||||
)
|
||||
AppVersionText(
|
||||
stringId = R.string.app_version_installed,
|
||||
version = appInstalledVersion
|
||||
text = stringResource(
|
||||
id = R.string.app_version_latest,
|
||||
appRemoteVersion ?: stringResource(
|
||||
id = R.string.app_content_unavailable
|
||||
)
|
||||
)
|
||||
)
|
||||
AppVersionText(
|
||||
text = stringResource(
|
||||
id = R.string.app_version_installed,
|
||||
appInstalledVersion ?: stringResource(
|
||||
id = R.string.app_content_unavailable
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
Row(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.vanced.manager.ui.widgets.home.apps.dialog
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -8,10 +7,10 @@ import androidx.compose.runtime.MutableState
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.button.ManagerThemedTextButton
|
||||
import com.vanced.manager.ui.components.dialog.ManagerDialog
|
||||
import com.vanced.manager.ui.components.lifecycle.managerString
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
import com.vanced.manager.ui.components.text.ManagerText
|
||||
import com.vanced.manager.ui.widgets.button.ManagerCloseButton
|
||||
|
||||
@Composable
|
||||
fun AppChangelogDialog(
|
||||
|
@ -24,10 +23,7 @@ fun AppChangelogDialog(
|
|||
title = managerString(R.string.app_info_title, appName),
|
||||
onDismissRequest = { showDialog.value = false },
|
||||
buttons = {
|
||||
ManagerThemedTextButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
stringId = R.string.dialog_button_close
|
||||
) {
|
||||
ManagerCloseButton {
|
||||
showDialog.value = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.vanced.manager.ui.widgets.home.download
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.button.ManagerThemedTextButton
|
||||
import com.vanced.manager.ui.widgets.button.ManagerCancelButton
|
||||
import com.vanced.manager.ui.widgets.button.ManagerDownloadButton
|
||||
|
||||
@Composable
|
||||
fun AppDownloadDialogButtons(
|
||||
|
@ -14,15 +12,7 @@ fun AppDownloadDialogButtons(
|
|||
onCancelClick: () -> Unit,
|
||||
) {
|
||||
when (showProgress.value) {
|
||||
true -> ManagerThemedTextButton(
|
||||
stringId = R.string.dialog_button_cancel,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = onCancelClick
|
||||
)
|
||||
false -> ManagerThemedTextButton(
|
||||
stringId = R.string.app_download_dialog_confirm,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = onDownloadClick
|
||||
)
|
||||
true -> ManagerCancelButton(onClick = onCancelClick)
|
||||
false -> ManagerDownloadButton(onClick = onDownloadClick)
|
||||
}
|
||||
}
|
|
@ -1,18 +1,19 @@
|
|||
package com.vanced.manager.ui.widgets.home.installation
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
import com.vanced.manager.ui.components.preference.CheckboxDialogPreference
|
||||
import com.vanced.manager.ui.preferences.CheckboxPreference
|
||||
import com.vanced.manager.ui.preferences.ManagerPreference
|
||||
|
||||
data class CheckboxInstallationOption(
|
||||
@StringRes val title: Int,
|
||||
@StringRes val titleId: Int,
|
||||
val preference: ManagerPreference<Set<String>>,
|
||||
val buttons: List<CheckboxPreference>
|
||||
) : InstallationOption(
|
||||
item = {
|
||||
CheckboxDialogPreference(
|
||||
preferenceTitle = title,
|
||||
preferenceTitle = managerString(stringId = titleId),
|
||||
preference = preference,
|
||||
buttons = buttons
|
||||
)
|
||||
|
|
|
@ -4,15 +4,16 @@ import androidx.annotation.StringRes
|
|||
import com.vanced.manager.ui.components.preference.RadiobuttonDialogPreference
|
||||
import com.vanced.manager.ui.preferences.ManagerPreference
|
||||
import com.vanced.manager.ui.preferences.RadioButtonPreference
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
|
||||
data class RadiobuttonInstallationOption(
|
||||
@StringRes val title: Int,
|
||||
@StringRes val titleId: Int,
|
||||
val preference: ManagerPreference<String>,
|
||||
val buttons: List<RadioButtonPreference>
|
||||
) : InstallationOption(
|
||||
item = {
|
||||
RadiobuttonDialogPreference(
|
||||
preferenceTitle = title,
|
||||
preferenceTitle = managerString(stringId = titleId),
|
||||
preference = preference,
|
||||
buttons = buttons
|
||||
)
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.vanced.manager.ui.widgets.home.socialmedia
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.vanced.manager.ui.components.card.ManagerLinkCard
|
||||
import com.vanced.manager.ui.components.layout.ScrollableItemRow
|
||||
import com.vanced.manager.util.socialMedia
|
||||
|
||||
@Composable
|
||||
fun HomeSocialMediaItem() {
|
||||
ScrollableItemRow(items = socialMedia) { socialMedia ->
|
||||
ManagerLinkCard(
|
||||
icon = socialMedia.icon,
|
||||
title = socialMedia.title,
|
||||
link = socialMedia.link
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.vanced.manager.ui.widgets.home.sponsors
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.vanced.manager.ui.components.card.ManagerLinkCard
|
||||
import com.vanced.manager.ui.components.layout.ScrollableItemRow
|
||||
import com.vanced.manager.util.sponsors
|
||||
|
||||
@Composable
|
||||
fun HomeSponsorsItem() {
|
||||
ScrollableItemRow(items = sponsors) { sponsor ->
|
||||
ManagerLinkCard(
|
||||
icon = sponsor.icon,
|
||||
title = sponsor.title,
|
||||
link = sponsor.link
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.vanced.manager.ui.widgets.layout
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
@ -11,7 +10,7 @@ import com.vanced.manager.ui.components.text.CategoryTitleText
|
|||
|
||||
@Composable
|
||||
fun CategoryLayout(
|
||||
@StringRes categoryNameId: Int,
|
||||
categoryName: String,
|
||||
contentPaddingHorizontal: Dp = defaultContentPaddingHorizontal,
|
||||
categoryNameSpacing: Dp = defaultContentPaddingVertical,
|
||||
content: @Composable () -> Unit,
|
||||
|
@ -20,7 +19,7 @@ fun CategoryLayout(
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalArrangement = Arrangement.spacedBy(categoryNameSpacing),
|
||||
) {
|
||||
CategoryTitleText(stringId = categoryNameId)
|
||||
CategoryTitleText(text = categoryName)
|
||||
Box(
|
||||
modifier = Modifier.padding(horizontal = contentPaddingHorizontal)
|
||||
) {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.vanced.manager.ui.widgets.layout
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun SettingsCategoryLayout(
|
||||
categoryName: String,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
CategoryLayout(
|
||||
categoryName = categoryName,
|
||||
contentPaddingHorizontal = 0.dp,
|
||||
categoryNameSpacing = 4.dp
|
||||
) {
|
||||
Column {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,20 +3,22 @@ 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.resources.managerString
|
||||
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
|
||||
import com.vanced.manager.ui.widgets.button.ManagerSaveButton
|
||||
|
||||
@Composable
|
||||
fun SettingsAccentColorItem() {
|
||||
var localAccentColor by remember { mutableStateOf(managerAccentColorPref.value.value) }
|
||||
DialogPreference(
|
||||
preferenceTitleId = R.string.settings_preference_accent_color_title,
|
||||
preferenceTitle = managerString(
|
||||
stringId = R.string.settings_preference_accent_color_title
|
||||
),
|
||||
preferenceDescription = "#" + Integer.toHexString(localAccentColor.toInt()),
|
||||
buttons = { isShown ->
|
||||
ManagerThemedTextButton(
|
||||
stringId = R.string.dialog_button_save,
|
||||
ManagerSaveButton(
|
||||
backgroundColor = Color(localAccentColor)
|
||||
) {
|
||||
isShown.value = false
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.vanced.manager.ui.widgets.settings
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.preference.Preference
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
|
||||
@Composable
|
||||
fun SettingsClearFilesItem() {
|
||||
Preference(
|
||||
preferenceTitle = managerString(
|
||||
stringId = R.string.settings_preference_clear_files_title
|
||||
),
|
||||
preferenceDescription = null,
|
||||
onClick = {}
|
||||
)
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.vanced.manager.ui.widgets.settings
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.preference.CheckboxPreference
|
||||
import com.vanced.manager.ui.preferences.holder.useCustomTabsPref
|
||||
|
||||
@Composable
|
||||
fun SettingsCustomTabsItem() {
|
||||
CheckboxPreference(
|
||||
preferenceTitle = stringResource(id = R.string.settings_preference_use_custom_tabs_title),
|
||||
preferenceDescription = stringResource(id = R.string.settings_preference_use_custom_tabs_summary),
|
||||
preference = useCustomTabsPref
|
||||
)
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.vanced.manager.ui.widgets.settings
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.components.preference.RadiobuttonDialogPreference
|
||||
import com.vanced.manager.ui.preferences.RadioButtonPreference
|
||||
import com.vanced.manager.ui.preferences.holder.managerVariantPref
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
|
||||
@Composable
|
||||
fun SettingsManagerVariantItem() {
|
||||
RadiobuttonDialogPreference(
|
||||
preferenceTitle = managerString(
|
||||
stringId = R.string.settings_preference_variant_title
|
||||
),
|
||||
preference = managerVariantPref,
|
||||
buttons = listOf(
|
||||
RadioButtonPreference(
|
||||
title = "nonroot",
|
||||
key = "nonroot"
|
||||
),
|
||||
RadioButtonPreference(
|
||||
title = "root",
|
||||
key = "root"
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.vanced.manager.ui.widgets.settings
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.vanced.manager.ui.components.preference.CheckboxPreference
|
||||
import com.vanced.manager.ui.preferences.managerBooleanPreference
|
||||
import com.vanced.manager.util.notificationApps
|
||||
|
||||
@Composable
|
||||
fun SettingsNotificationsItem() {
|
||||
notificationApps.forEach {
|
||||
with(it) {
|
||||
CheckboxPreference(
|
||||
preferenceTitle = "$app Push Notifications",
|
||||
preferenceDescription = "Receive push notifications when an update for $app is released",
|
||||
preference = managerBooleanPreference(
|
||||
key = "${prefKey}_notifications",
|
||||
defaultValue = true
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,25 +5,41 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.ui.components.preference.RadiobuttonDialogPreference
|
||||
import com.vanced.manager.ui.preferences.RadioButtonPreference
|
||||
import com.vanced.manager.ui.preferences.holder.managerThemePref
|
||||
import com.vanced.manager.ui.resources.managerString
|
||||
|
||||
@Composable
|
||||
fun ThemeSettingsItem() {
|
||||
val lightTheme = managerString(stringId = R.string.settings_preference_theme_light)
|
||||
val darkTheme = managerString(stringId = R.string.settings_preference_theme_dark)
|
||||
val sysDefTheme = managerString(stringId = R.string.settings_option_system_default)
|
||||
|
||||
val lightKey = "Light"
|
||||
val darkKey = "Dark"
|
||||
val sysDefKey = "System Default"
|
||||
|
||||
RadiobuttonDialogPreference(
|
||||
preferenceTitle = R.string.settings_preference_theme_title,
|
||||
preferenceTitle = managerString(stringId = R.string.settings_preference_theme_title),
|
||||
preference = managerThemePref,
|
||||
buttons = listOf(
|
||||
RadioButtonPreference(
|
||||
title = "Light Theme",
|
||||
key = "Light"
|
||||
title = lightTheme,
|
||||
key = lightKey
|
||||
),
|
||||
RadioButtonPreference(
|
||||
title = "Dark Theme",
|
||||
key = "Dark"
|
||||
title = darkTheme,
|
||||
key = darkKey
|
||||
),
|
||||
RadioButtonPreference(
|
||||
title = "System Default",
|
||||
key = "System Default"
|
||||
title = sysDefTheme,
|
||||
key = sysDefKey
|
||||
)
|
||||
)
|
||||
),
|
||||
preferenceDescriptionConverter = {
|
||||
when (it) {
|
||||
lightKey -> lightTheme
|
||||
darkKey -> darkTheme
|
||||
else -> sysDefTheme
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.vanced.manager.util
|
||||
|
||||
import com.vanced.manager.domain.model.NotificationPrefModel
|
||||
import com.vanced.manager.network.util.MICROG_NAME
|
||||
import com.vanced.manager.network.util.MUSIC_NAME
|
||||
import com.vanced.manager.network.util.VANCED_NAME
|
||||
|
||||
val notificationApps = arrayOf(
|
||||
NotificationPrefModel(
|
||||
app = VANCED_NAME,
|
||||
prefKey = "vanced"
|
||||
),
|
||||
NotificationPrefModel(
|
||||
app = MUSIC_NAME,
|
||||
prefKey = "music"
|
||||
),
|
||||
NotificationPrefModel(
|
||||
app = MICROG_NAME,
|
||||
prefKey = "microg"
|
||||
)
|
||||
)
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<!-- Settings Page-->
|
||||
<string name="settings_category_appearance">Appearance</string>
|
||||
<string name="settings_category_behaviour">Behavior</string>
|
||||
<string name="settings_category_behaviour">Behaviour</string>
|
||||
<string name="settings_option_system_default">System Default</string>
|
||||
<string name="settings_preference_accent_color_title">Accent Color</string>
|
||||
<string name="settings_preference_clear_files_title">Clear downloaded files</string>
|
||||
|
|
Loading…
Reference in New Issue