Skip to content

Commit

Permalink
Merge branch 'compose-dev' into settings-reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
validcube authored Aug 5, 2024
2 parents 819e550 + c18901c commit 0d29082
Show file tree
Hide file tree
Showing 20 changed files with 273 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PreferencesManager(

val firstLaunch = booleanPreference("first_launch", true)
val managerAutoUpdates = booleanPreference("manager_auto_updates", false)
val showManagerUpdateDialogOnLaunch = booleanPreference("show_manager_update_dialog_on_launch", true)

val disablePatchVersionCompatCheck = booleanPreference("disable_patch_version_compatibility_check", false)
val disableSelectionWarning = booleanPreference("disable_selection_warning", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class EditorContext(private val prefs: MutablePreferences) {

abstract class Preference<T>(
private val dataStore: DataStore<Preferences>,
protected val default: T
val default: T
) {
internal abstract fun Preferences.read(): T
internal abstract fun MutablePreferences.write(value: T)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.content.Context
import app.revanced.manager.patcher.LibraryResolver
import android.os.Build.SUPPORTED_ABIS as DEVICE_ABIS
object Aapt : LibraryResolver() {
private val WORKING_ABIS = setOf("arm64-v8a", "x86", "x86_64")
private val WORKING_ABIS = setOf("arm64-v8a", "x86", "x86_64", "armeabi-v7a")

fun supportsDevice() = (DEVICE_ABIS intersect WORKING_ABIS).isNotEmpty()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun AlertDialogExtended(
) {
Column(modifier = Modifier.padding(vertical = 24.dp)) {
Column(
modifier = Modifier.padding(horizontal = 24.dp)
modifier = Modifier.padding(horizontal = 24.dp).fillMaxWidth()
) {
icon?.let {
ContentStyle(color = iconContentColor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ fun AppIcon(
Image(
image,
contentDescription,
Modifier.placeholder(visible = showPlaceHolder, color = MaterialTheme.colorScheme.inverseOnSurface, shape = RoundedCornerShape(100)).then(modifier),
modifier,
colorFilter = colorFilter
)

showPlaceHolder = false
} else {
AsyncImage(
packageInfo,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package app.revanced.manager.ui.component

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Update
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import app.revanced.manager.R

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AvailableUpdateDialog(
onDismiss: () -> Unit,
onConfirm: () -> Unit,
setShowManagerUpdateDialogOnLaunch: (Boolean) -> Unit,
newVersion: String
) {
var dontShowAgain by rememberSaveable { mutableStateOf(false) }
val dismissDialog = {
setShowManagerUpdateDialogOnLaunch(!dontShowAgain)
onDismiss()
}

AlertDialogExtended(
onDismissRequest = dismissDialog,
confirmButton = {
TextButton(
onClick = {
dismissDialog()
onConfirm()
}
) {
Text(stringResource(R.string.show))
}
},
dismissButton = {
TextButton(
onClick = dismissDialog
) {
Text(stringResource(R.string.dismiss))
}
},
icon = {
Icon(imageVector = Icons.Outlined.Update, contentDescription = null)
},
title = {
Text(stringResource(R.string.update_available))
},
text = {
Column(
modifier = Modifier.padding(horizontal = 8.dp),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
Text(
modifier = Modifier.padding(horizontal = 16.dp),
text = stringResource(R.string.update_available_dialog_description, newVersion)
)
ListItem(
modifier = Modifier.clickable { dontShowAgain = !dontShowAgain },
headlineContent = {
Text(stringResource(R.string.never_show_again))
},
leadingContent = {
CompositionLocalProvider(LocalMinimumInteractiveComponentEnforcement provides false) {
Checkbox(checked = dontShowAgain, onCheckedChange = { dontShowAgain = it })
}
}
)
}
},
textHorizontalPadding = PaddingValues(0.dp)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ fun BaseBundleDialog(
ColumnWithScrollbar(
modifier = Modifier
.fillMaxWidth()
.padding(
start = 8.dp,
top = 8.dp,
end = 4.dp,
)
.then(modifier)
) {
if (name != null) {
Expand Down
84 changes: 37 additions & 47 deletions app/src/main/java/app/revanced/manager/ui/screen/DashboardScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,17 @@ import android.net.Uri
import android.provider.Settings
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.BatteryAlert
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.outlined.Apps
import androidx.compose.material.icons.outlined.DeleteOutline
import androidx.compose.material.icons.outlined.Refresh
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.outlined.Source
import androidx.compose.material.icons.outlined.Update
import androidx.compose.material.icons.outlined.WarningAmber
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
Expand All @@ -55,6 +29,7 @@ import app.revanced.manager.domain.bundles.PatchBundleSource.Extensions.isDefaul
import app.revanced.manager.patcher.aapt.Aapt
import app.revanced.manager.ui.component.AppTopBar
import app.revanced.manager.ui.component.AutoUpdatesDialog
import app.revanced.manager.ui.component.AvailableUpdateDialog
import app.revanced.manager.ui.component.NotificationCard
import app.revanced.manager.ui.component.bundle.BundleItem
import app.revanced.manager.ui.component.bundle.BundleTopBar
Expand Down Expand Up @@ -113,6 +88,20 @@ fun DashboardScreen(
)
}

var showDialog by rememberSaveable { mutableStateOf(vm.prefs.showManagerUpdateDialogOnLaunch.getBlocking()) }
val availableUpdate by remember {
derivedStateOf { vm.updatedManagerVersion.takeIf { showDialog } }
}

availableUpdate?.let { version ->
AvailableUpdateDialog(
onDismiss = { showDialog = false },
setShowManagerUpdateDialogOnLaunch = vm::setShowManagerUpdateDialogOnLaunch,
onConfirm = onUpdateClick,
newVersion = version
)
}

Scaffold(
topBar = {
if (bundlesSelectable) {
Expand Down Expand Up @@ -154,6 +143,23 @@ fun DashboardScreen(
AppTopBar(
title = stringResource(R.string.app_name),
actions = {
if (!vm.updatedManagerVersion.isNullOrEmpty()) {
IconButton(
onClick = onUpdateClick,
) {
BadgedBox(
badge = {
Badge(
// A size value above 6.dp forces the Badge icon to be closer to the center, fixing a clipping issue
modifier = Modifier.size(7.dp),
containerColor = MaterialTheme.colorScheme.primary,
)
}
) {
Icon(Icons.Outlined.Update, stringResource(R.string.update))
}
}
}
IconButton(onClick = onSettingsClick) {
Icon(Icons.Outlined.Settings, stringResource(R.string.settings))
}
Expand Down Expand Up @@ -230,23 +236,7 @@ fun DashboardScreen(
}
)
}
} else null,
vm.updatedManagerVersion?.let {
{
NotificationCard(
text = stringResource(R.string.update_available_dialog_description, it),
icon = Icons.Outlined.Update,
actions = {
TextButton(onClick = vm::dismissUpdateDialog) {
Text(stringResource(R.string.dismiss))
}
TextButton(onClick = onUpdateClick) {
Text(stringResource(R.string.show))
}
}
)
}
}
} else null
)

HorizontalPager(
Expand Down
Loading

0 comments on commit 0d29082

Please sign in to comment.