mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat(Installer): use BottomAppBar (#1428)
This commit is contained in:
parent
5fff0a2923
commit
3c5776214f
@ -13,7 +13,9 @@ import androidx.compose.foundation.verticalScroll
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Cancel
|
import androidx.compose.material.icons.filled.Cancel
|
||||||
import androidx.compose.material.icons.filled.CheckCircle
|
import androidx.compose.material.icons.filled.CheckCircle
|
||||||
import androidx.compose.material.icons.outlined.MoreVert
|
import androidx.compose.material.icons.outlined.FileDownload
|
||||||
|
import androidx.compose.material.icons.outlined.PostAdd
|
||||||
|
import androidx.compose.material.icons.outlined.Save
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
@ -36,8 +38,8 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
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.patcher.worker.Step
|
|
||||||
import app.revanced.manager.patcher.worker.State
|
import app.revanced.manager.patcher.worker.State
|
||||||
|
import app.revanced.manager.patcher.worker.Step
|
||||||
import app.revanced.manager.ui.component.AppScaffold
|
import app.revanced.manager.ui.component.AppScaffold
|
||||||
import app.revanced.manager.ui.component.AppTopBar
|
import app.revanced.manager.ui.component.AppTopBar
|
||||||
import app.revanced.manager.ui.component.ArrowButton
|
import app.revanced.manager.ui.component.ArrowButton
|
||||||
@ -59,7 +61,6 @@ fun InstallerScreen(
|
|||||||
val patcherState by vm.patcherState.observeAsState(null)
|
val patcherState by vm.patcherState.observeAsState(null)
|
||||||
val steps by vm.progress.collectAsStateWithLifecycle()
|
val steps by vm.progress.collectAsStateWithLifecycle()
|
||||||
val canInstall by remember { derivedStateOf { patcherState == true && (vm.installedPackageName != null || !vm.isInstalling) } }
|
val canInstall by remember { derivedStateOf { patcherState == true && (vm.installedPackageName != null || !vm.isInstalling) } }
|
||||||
var dropdownActive by rememberSaveable { mutableStateOf(false) }
|
|
||||||
var showInstallPicker by rememberSaveable { mutableStateOf(false) }
|
var showInstallPicker by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
if (showInstallPicker)
|
if (showInstallPicker)
|
||||||
@ -72,23 +73,40 @@ fun InstallerScreen(
|
|||||||
topBar = {
|
topBar = {
|
||||||
AppTopBar(
|
AppTopBar(
|
||||||
title = stringResource(R.string.installer),
|
title = stringResource(R.string.installer),
|
||||||
onBackClick = onBackClick,
|
onBackClick = onBackClick
|
||||||
actions = {
|
|
||||||
IconButton(onClick = { dropdownActive = true }) {
|
|
||||||
Icon(Icons.Outlined.MoreVert, stringResource(R.string.more))
|
|
||||||
}
|
|
||||||
DropdownMenu(
|
|
||||||
expanded = dropdownActive,
|
|
||||||
onDismissRequest = { dropdownActive = false }
|
|
||||||
) {
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(stringResource(R.string.save_logs)) },
|
|
||||||
onClick = { vm.exportLogs(context) },
|
|
||||||
enabled = patcherState != null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
bottomBar = {
|
||||||
|
AnimatedVisibility(patcherState != null) {
|
||||||
|
BottomAppBar(
|
||||||
|
actions = {
|
||||||
|
if (canInstall) {
|
||||||
|
IconButton(onClick = { exportApkLauncher.launch("${vm.packageName}.apk") }) {
|
||||||
|
Icon(Icons.Outlined.Save, stringResource(id = R.string.save_apk))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IconButton(onClick = { vm.exportLogs(context) }) {
|
||||||
|
Icon(Icons.Outlined.PostAdd, stringResource(id = R.string.save_logs))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
floatingActionButton = {
|
||||||
|
if (canInstall) {
|
||||||
|
ExtendedFloatingActionButton(
|
||||||
|
text = { Text(stringResource(vm.appButtonText)) },
|
||||||
|
icon = { Icon(Icons.Outlined.FileDownload, stringResource(id = R.string.install_app)) },
|
||||||
|
containerColor = BottomAppBarDefaults.bottomAppBarFabColor,
|
||||||
|
elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation(),
|
||||||
|
onClick = {
|
||||||
|
if (vm.installedPackageName == null)
|
||||||
|
showInstallPicker = true
|
||||||
|
else
|
||||||
|
vm.open()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
Column(
|
Column(
|
||||||
@ -100,33 +118,6 @@ fun InstallerScreen(
|
|||||||
steps.forEach {
|
steps.forEach {
|
||||||
InstallStep(it)
|
InstallStep(it)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.Bottom,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End),
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(start = 16.dp, end = 16.dp, bottom = 16.dp)
|
|
||||||
) {
|
|
||||||
Button(
|
|
||||||
onClick = { exportApkLauncher.launch("${vm.packageName}.apk") },
|
|
||||||
enabled = canInstall
|
|
||||||
) {
|
|
||||||
Text(stringResource(R.string.export_app))
|
|
||||||
}
|
|
||||||
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
if (vm.installedPackageName == null)
|
|
||||||
showInstallPicker = true
|
|
||||||
else
|
|
||||||
vm.open()
|
|
||||||
},
|
|
||||||
enabled = canInstall
|
|
||||||
) {
|
|
||||||
Text(stringResource(vm.appButtonText))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ class InstallerViewModel(
|
|||||||
app.contentResolver.openOutputStream(it)
|
app.contentResolver.openOutputStream(it)
|
||||||
.use { stream -> Files.copy(outputFile.toPath(), stream) }
|
.use { stream -> Files.copy(outputFile.toPath(), stream) }
|
||||||
}
|
}
|
||||||
app.toast(app.getString(R.string.export_app_success))
|
app.toast(app.getString(R.string.save_apk_success))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,8 +229,8 @@
|
|||||||
<string name="install_app_fail">Failed to install app: %s</string>
|
<string name="install_app_fail">Failed to install app: %s</string>
|
||||||
<string name="uninstall_app_fail">Failed to uninstall app: %s</string>
|
<string name="uninstall_app_fail">Failed to uninstall app: %s</string>
|
||||||
<string name="open_app">Open</string>
|
<string name="open_app">Open</string>
|
||||||
<string name="export_app">Export</string>
|
<string name="save_apk">Save APK</string>
|
||||||
<string name="export_app_success">Apk exported</string>
|
<string name="save_apk_success">APK Saved</string>
|
||||||
<string name="sign_fail">Failed to sign Apk: %s</string>
|
<string name="sign_fail">Failed to sign Apk: %s</string>
|
||||||
<string name="save_logs">Save logs</string>
|
<string name="save_logs">Save logs</string>
|
||||||
<string name="select_install_type">Select installation type</string>
|
<string name="select_install_type">Select installation type</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user