mirror of
https://github.com/revanced/revanced-manager-compose-old.git
synced 2025-05-01 15:04:26 +02:00
feat: warning when split apk is detected
This commit is contained in:
parent
336c863c7f
commit
335e2cb272
@ -134,7 +134,7 @@ class PatcherWorker(context: Context, parameters: WorkerParameters) :
|
|||||||
Log.d(tag, "Adding ${patches.size} patch(es)")
|
Log.d(tag, "Adding ${patches.size} patch(es)")
|
||||||
patcher.addPatches(patches)
|
patcher.addPatches(patches)
|
||||||
|
|
||||||
// patcher.addFiles(listOf(integrations)) {}
|
patcher.addFiles(listOf(integrations)) {}
|
||||||
|
|
||||||
patcher.applyPatches().forEach { (patch, result) ->
|
patcher.applyPatches().forEach { (patch, result) ->
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package app.revanced.manager.ui.component
|
||||||
|
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.OutlinedButton
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import app.revanced.manager.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SplitAPKDialog(
|
||||||
|
onDismiss: () -> Unit,
|
||||||
|
onConfirm: () -> Unit
|
||||||
|
) {
|
||||||
|
AlertDialog(onDismissRequest = onDismiss, shape = RoundedCornerShape(12.dp),
|
||||||
|
title = {
|
||||||
|
Text(stringResource(id = R.string.warning), textAlign = TextAlign.Center)
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(stringResource(R.string.split_apk_warning))
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
onConfirm()
|
||||||
|
onDismiss()
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Text(text = "OK")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
OutlinedButton(onClick = onDismiss) {
|
||||||
|
Text(text = "Cancel")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
@ -4,13 +4,14 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Build
|
import androidx.compose.material.icons.filled.Build
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
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.Variables.patches
|
import app.revanced.manager.Variables.patches
|
||||||
@ -18,6 +19,7 @@ import app.revanced.manager.Variables.selectedAppPackage
|
|||||||
import app.revanced.manager.Variables.selectedPatches
|
import app.revanced.manager.Variables.selectedPatches
|
||||||
import app.revanced.manager.ui.Resource
|
import app.revanced.manager.ui.Resource
|
||||||
import app.revanced.manager.ui.component.FloatingActionButton
|
import app.revanced.manager.ui.component.FloatingActionButton
|
||||||
|
import app.revanced.manager.ui.component.SplitAPKDialog
|
||||||
import app.revanced.manager.ui.viewmodel.PatcherViewModel
|
import app.revanced.manager.ui.viewmodel.PatcherViewModel
|
||||||
import org.koin.androidx.compose.getViewModel
|
import org.koin.androidx.compose.getViewModel
|
||||||
|
|
||||||
@ -32,11 +34,14 @@ fun PatcherScreen(
|
|||||||
val selectedAppPackage by selectedAppPackage
|
val selectedAppPackage by selectedAppPackage
|
||||||
val hasAppSelected = selectedAppPackage.isPresent
|
val hasAppSelected = selectedAppPackage.isPresent
|
||||||
val patchesLoaded = patches.value is Resource.Success
|
val patchesLoaded = patches.value is Resource.Success
|
||||||
|
var showDialog by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Scaffold(floatingActionButton = {
|
Scaffold(floatingActionButton = {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
enabled = hasAppSelected && viewModel.anyPatchSelected(),
|
enabled = hasAppSelected && viewModel.anyPatchSelected(),
|
||||||
onClick = { viewModel.startPatcher() },
|
onClick = {
|
||||||
|
if (viewModel.checkSplitApk()) { showDialog = true } else viewModel.startPatcher()
|
||||||
|
},
|
||||||
icon = { Icon(Icons.Default.Build, contentDescription = "Patch") },
|
icon = { Icon(Icons.Default.Build, contentDescription = "Patch") },
|
||||||
text = { Text(text = "Patch") }
|
text = { Text(text = "Patch") }
|
||||||
)
|
)
|
||||||
@ -47,6 +52,8 @@ fun PatcherScreen(
|
|||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
) {
|
) {
|
||||||
|
if (showDialog)
|
||||||
|
SplitAPKDialog(onDismiss = { showDialog = false }, onConfirm = { viewModel.startPatcher() })
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(4.dp)
|
.padding(4.dp)
|
||||||
@ -63,7 +70,8 @@ fun PatcherScreen(
|
|||||||
text = if (patchesLoaded) {
|
text = if (patchesLoaded) {
|
||||||
selectedAppPackage.orElse(stringResource(R.string.card_application_not_selected))
|
selectedAppPackage.orElse(stringResource(R.string.card_application_not_selected))
|
||||||
} else {
|
} else {
|
||||||
stringResource(R.string.card_application_not_loaded)},
|
stringResource(R.string.card_application_not_loaded)
|
||||||
|
},
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
modifier = Modifier.padding(0.dp, 8.dp)
|
modifier = Modifier.padding(0.dp, 8.dp)
|
||||||
)
|
)
|
||||||
|
@ -109,6 +109,15 @@ class PatcherViewModel(private val app: Application, private val api: API) : Vie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun checkSplitApk(): Boolean {
|
||||||
|
if (getSelectedPackageInfo()!!.applicationInfo!!.metaData!!.getBoolean("com.android.vending.splits.required", false)) {
|
||||||
|
Log.d(tag, "APK is split.")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
Log.d(tag, "APK is not split.")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private fun loadPatches() = viewModelScope.launch {
|
private fun loadPatches() = viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
val file = api.downloadPatchBundle(app.filesDir)
|
val file = api.downloadPatchBundle(app.filesDir)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<string name="settings">Settings</string>
|
<string name="settings">Settings</string>
|
||||||
<string name="updates">Updates</string>
|
<string name="updates">Updates</string>
|
||||||
<string name="manager">Manager</string>
|
<string name="manager">Manager</string>
|
||||||
|
<string name="update_manager">Update Manager</string>
|
||||||
<string name="update_patch_bundle">Update Patches</string>
|
<string name="update_patch_bundle">Update Patches</string>
|
||||||
<string name="patched_apps">Installed</string>
|
<string name="patched_apps">Installed</string>
|
||||||
<string name="update_all">Update All</string>
|
<string name="update_all">Update All</string>
|
||||||
@ -75,4 +76,6 @@
|
|||||||
<string name="patcher_notification_message">ReVanced Manager is patching</string>
|
<string name="patcher_notification_message">ReVanced Manager is patching</string>
|
||||||
<string name="theme">Theme</string>
|
<string name="theme">Theme</string>
|
||||||
<string name="apply">Apply</string>
|
<string name="apply">Apply</string>
|
||||||
|
<string name="warning">Warning</string>
|
||||||
|
<string name="split_apk_warning">You have selected a resource patch and a split APK installation was detected so patching errors can occur.\nAre you sure you want to proceed with patching a split base APK?</string>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user