mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-02 14:54:25 +02:00
fix issues caused by the compose m3 update
This commit is contained in:
parent
f9e8d30ff6
commit
6fcc2ff07f
@ -7,6 +7,7 @@ import androidx.compose.animation.ExperimentalAnimationApi
|
|||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
|
import androidx.core.view.WindowCompat
|
||||||
import app.revanced.manager.ui.destination.Destination
|
import app.revanced.manager.ui.destination.Destination
|
||||||
import app.revanced.manager.ui.destination.SettingsDestination
|
import app.revanced.manager.ui.destination.SettingsDestination
|
||||||
import app.revanced.manager.ui.model.SelectedApp
|
import app.revanced.manager.ui.model.SelectedApp
|
||||||
@ -35,6 +36,8 @@ class MainActivity : ComponentActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
|
|
||||||
installSplashScreen()
|
installSplashScreen()
|
||||||
|
|
||||||
val vm: MainViewModel = getAndroidViewModel()
|
val vm: MainViewModel = getAndroidViewModel()
|
||||||
|
@ -24,6 +24,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import app.revanced.manager.R
|
import app.revanced.manager.R
|
||||||
|
import app.revanced.manager.util.transparentListItemColors
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AutoUpdatesDialog(onSubmit: (Boolean, Boolean) -> Unit) {
|
fun AutoUpdatesDialog(onSubmit: (Boolean, Boolean) -> Unit) {
|
||||||
@ -77,5 +78,6 @@ private fun AutoUpdatesItem(
|
|||||||
leadingContent = { Icon(icon, null) },
|
leadingContent = { Icon(icon, null) },
|
||||||
headlineContent = { Text(stringResource(headline)) },
|
headlineContent = { Text(stringResource(headline)) },
|
||||||
trailingContent = { Checkbox(checked = checked, onCheckedChange = null) },
|
trailingContent = { Checkbox(checked = checked, onCheckedChange = null) },
|
||||||
modifier = Modifier.clickable { onCheckedChange(!checked) }
|
modifier = Modifier.clickable { onCheckedChange(!checked) },
|
||||||
|
colors = transparentListItemColors
|
||||||
)
|
)
|
@ -1,13 +1,15 @@
|
|||||||
package app.revanced.manager.ui.component
|
package app.revanced.manager.ui.component
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.SearchBar
|
import androidx.compose.material3.SearchBar
|
||||||
|
import androidx.compose.material3.SearchBarColors
|
||||||
|
import androidx.compose.material3.SearchBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@ -27,29 +29,38 @@ fun SearchView(
|
|||||||
placeholder: (@Composable () -> Unit)? = null,
|
placeholder: (@Composable () -> Unit)? = null,
|
||||||
content: @Composable ColumnScope.() -> Unit
|
content: @Composable ColumnScope.() -> Unit
|
||||||
) {
|
) {
|
||||||
|
val colors = SearchBarColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
|
||||||
|
dividerColor = MaterialTheme.colorScheme.outline
|
||||||
|
)
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
val keyboardController = LocalSoftwareKeyboardController.current
|
val keyboardController = LocalSoftwareKeyboardController.current
|
||||||
|
|
||||||
SearchBar(
|
SearchBar(
|
||||||
query = query,
|
inputField = {
|
||||||
onQueryChange = onQueryChange,
|
SearchBarDefaults.InputField(
|
||||||
onSearch = {
|
query = query,
|
||||||
keyboardController?.hide()
|
onQueryChange = onQueryChange,
|
||||||
},
|
onSearch = {
|
||||||
active = true,
|
keyboardController?.hide()
|
||||||
onActiveChange = onActiveChange,
|
},
|
||||||
modifier = Modifier
|
expanded = true,
|
||||||
.fillMaxSize()
|
onExpandedChange = onActiveChange,
|
||||||
.focusRequester(focusRequester),
|
placeholder = placeholder,
|
||||||
placeholder = placeholder,
|
leadingIcon = {
|
||||||
leadingIcon = {
|
IconButton(onClick = { onActiveChange(false) }) {
|
||||||
IconButton({ onActiveChange(false) }) {
|
Icon(
|
||||||
Icon(
|
Icons.AutoMirrored.Filled.ArrowBack,
|
||||||
Icons.AutoMirrored.Filled.ArrowBack,
|
stringResource(R.string.back)
|
||||||
stringResource(R.string.back)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
expanded = true,
|
||||||
|
onExpandedChange = onActiveChange,
|
||||||
|
modifier = Modifier.focusRequester(focusRequester),
|
||||||
|
colors = colors,
|
||||||
content = content
|
content = content
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import app.revanced.manager.R
|
import app.revanced.manager.R
|
||||||
import app.revanced.manager.data.room.apps.installed.InstallType
|
import app.revanced.manager.data.room.apps.installed.InstallType
|
||||||
|
import app.revanced.manager.util.transparentListItemColors
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun InstallPickerDialog(
|
fun InstallPickerDialog(
|
||||||
@ -44,7 +45,7 @@ fun InstallPickerDialog(
|
|||||||
title = { Text(stringResource(R.string.select_install_type)) },
|
title = { Text(stringResource(R.string.select_install_type)) },
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
InstallType.values().forEach {
|
InstallType.entries.forEach {
|
||||||
ListItem(
|
ListItem(
|
||||||
modifier = Modifier.clickable { selectedInstallType = it },
|
modifier = Modifier.clickable { selectedInstallType = it },
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
@ -53,7 +54,8 @@ fun InstallPickerDialog(
|
|||||||
onClick = null
|
onClick = null
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
headlineContent = { Text(stringResource(it.stringResource)) }
|
headlineContent = { Text(stringResource(it.stringResource)) },
|
||||||
|
colors = transparentListItemColors
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ import app.revanced.manager.util.mutableStateSetOf
|
|||||||
import app.revanced.manager.util.saver.snapshotStateListSaver
|
import app.revanced.manager.util.saver.snapshotStateListSaver
|
||||||
import app.revanced.manager.util.saver.snapshotStateSetSaver
|
import app.revanced.manager.util.saver.snapshotStateSetSaver
|
||||||
import app.revanced.manager.util.toast
|
import app.revanced.manager.util.toast
|
||||||
|
import app.revanced.manager.util.transparentListItemColors
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import org.koin.compose.koinInject
|
import org.koin.compose.koinInject
|
||||||
import org.koin.core.component.KoinComponent
|
import org.koin.core.component.KoinComponent
|
||||||
@ -426,7 +427,8 @@ private class PresetOptionEditor<T : Any>(private val innerEditor: OptionEditor<
|
|||||||
selected = selectedPreset == presetKey,
|
selected = selectedPreset == presetKey,
|
||||||
onClick = { selectedPreset = presetKey }
|
onClick = { selectedPreset = presetKey }
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
|
colors = transparentListItemColors
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import app.revanced.manager.ui.component.SearchView
|
|||||||
import app.revanced.manager.ui.model.SelectedApp
|
import app.revanced.manager.ui.model.SelectedApp
|
||||||
import app.revanced.manager.ui.viewmodel.AppSelectorViewModel
|
import app.revanced.manager.ui.viewmodel.AppSelectorViewModel
|
||||||
import app.revanced.manager.util.APK_MIMETYPE
|
import app.revanced.manager.util.APK_MIMETYPE
|
||||||
|
import app.revanced.manager.util.transparentListItemColors
|
||||||
import org.koin.androidx.compose.koinViewModel
|
import org.koin.androidx.compose.koinViewModel
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -74,7 +75,7 @@ fun AppSelectorScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (search) {
|
if (search)
|
||||||
SearchView(
|
SearchView(
|
||||||
query = filterText,
|
query = filterText,
|
||||||
onQueryChange = { filterText = it },
|
onQueryChange = { filterText = it },
|
||||||
@ -82,9 +83,7 @@ fun AppSelectorScreen(
|
|||||||
placeholder = { Text(stringResource(R.string.search_apps)) }
|
placeholder = { Text(stringResource(R.string.search_apps)) }
|
||||||
) {
|
) {
|
||||||
if (appList.isNotEmpty() && filterText.isNotEmpty()) {
|
if (appList.isNotEmpty() && filterText.isNotEmpty()) {
|
||||||
LazyColumnWithScrollbar(
|
LazyColumnWithScrollbar(modifier = Modifier.fillMaxSize()) {
|
||||||
modifier = Modifier.fillMaxSize()
|
|
||||||
) {
|
|
||||||
items(
|
items(
|
||||||
items = filteredAppList,
|
items = filteredAppList,
|
||||||
key = { it.packageName }
|
key = { it.packageName }
|
||||||
@ -115,7 +114,8 @@ fun AppSelectorScreen(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
colors = transparentListItemColors
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -129,17 +129,18 @@ fun AppSelectorScreen(
|
|||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Search,
|
imageVector = Icons.Outlined.Search,
|
||||||
contentDescription = stringResource(R.string.search),
|
contentDescription = stringResource(R.string.search),
|
||||||
modifier = Modifier.size(64.dp)
|
modifier = Modifier.size(64.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.type_anything),
|
text = stringResource(R.string.type_anything),
|
||||||
style = MaterialTheme.typography.bodyLarge
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
|
@ -68,6 +68,7 @@ import app.revanced.manager.ui.viewmodel.PatchesSelectorViewModel.Companion.SHOW
|
|||||||
import app.revanced.manager.util.Options
|
import app.revanced.manager.util.Options
|
||||||
import app.revanced.manager.util.PatchSelection
|
import app.revanced.manager.util.PatchSelection
|
||||||
import app.revanced.manager.util.isScrollingUp
|
import app.revanced.manager.util.isScrollingUp
|
||||||
|
import app.revanced.manager.util.transparentListItemColors
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
||||||
@ -440,7 +441,8 @@ fun PatchItem(
|
|||||||
Icon(Icons.Outlined.Settings, null)
|
Icon(Icons.Outlined.Settings, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
colors = transparentListItemColors
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -465,7 +467,8 @@ fun ListHeader(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
colors = transparentListItemColors
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ import android.widget.Toast
|
|||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.foundation.ScrollState
|
import androidx.compose.foundation.ScrollState
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
|
import androidx.compose.material3.ListItemColors
|
||||||
|
import androidx.compose.material3.ListItemDefaults
|
||||||
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
@ -156,9 +159,21 @@ fun String.relativeTime(context: Context): String {
|
|||||||
|
|
||||||
return when {
|
return when {
|
||||||
duration.toMinutes() < 1 -> context.getString(R.string.just_now)
|
duration.toMinutes() < 1 -> context.getString(R.string.just_now)
|
||||||
duration.toMinutes() < 60 -> context.getString(R.string.minutes_ago, duration.toMinutes().toString())
|
duration.toMinutes() < 60 -> context.getString(
|
||||||
duration.toHours() < 24 -> context.getString(R.string.hours_ago, duration.toHours().toString())
|
R.string.minutes_ago,
|
||||||
duration.toDays() < 30 -> context.getString(R.string.days_ago, duration.toDays().toString())
|
duration.toMinutes().toString()
|
||||||
|
)
|
||||||
|
|
||||||
|
duration.toHours() < 24 -> context.getString(
|
||||||
|
R.string.hours_ago,
|
||||||
|
duration.toHours().toString()
|
||||||
|
)
|
||||||
|
|
||||||
|
duration.toDays() < 30 -> context.getString(
|
||||||
|
R.string.days_ago,
|
||||||
|
duration.toDays().toString()
|
||||||
|
)
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
val formatter = DateTimeFormatter.ofPattern("MMM d")
|
val formatter = DateTimeFormatter.ofPattern("MMM d")
|
||||||
val formattedDate = inputDateTime.format(formatter)
|
val formattedDate = inputDateTime.format(formatter)
|
||||||
@ -176,6 +191,15 @@ fun String.relativeTime(context: Context): String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var transparentListItemColorsCached: ListItemColors? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default ListItem colors, but with [ListItemColors.containerColor] set to [Color.Transparent].
|
||||||
|
*/
|
||||||
|
val transparentListItemColors
|
||||||
|
@Composable get() = transparentListItemColorsCached
|
||||||
|
?: ListItemDefaults.colors(containerColor = Color.Transparent)
|
||||||
|
.also { transparentListItemColorsCached = it }
|
||||||
|
|
||||||
const val isScrollingUpSensitivity = 10
|
const val isScrollingUpSensitivity = 10
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user