Compare commits

..

20 Commits

Author SHA1 Message Date
semantic-release-bot
35fb59b31d chore: Release v1.26.0-dev.15 [skip ci]
# app [1.26.0-dev.15](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.14...v1.26.0-dev.15) (2025-12-29)

### Bug Fixes

* install dialog getting stuck ([#2900](https://github.com/ReVanced/revanced-manager/issues/2900)) ([18a4df9](18a4df9af9))
2025-12-29 22:49:24 +00:00
Ax333l
18a4df9af9 fix: install dialog getting stuck (#2900) 2025-12-29 23:42:14 +01:00
semantic-release-bot
bd69b45a69 chore: Release v1.26.0-dev.14 [skip ci]
# app [1.26.0-dev.14](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.13...v1.26.0-dev.14) (2025-12-28)

### Bug Fixes

* Update selected patch count when SelectionState changes ([#2896](https://github.com/ReVanced/revanced-manager/issues/2896)) ([0d26df0](0d26df03f4))
2025-12-28 18:20:22 +00:00
Robert
0d26df03f4 fix: Update selected patch count when SelectionState changes (#2896) 2025-12-28 19:13:00 +01:00
semantic-release-bot
c436a7a100 chore: Release v1.26.0-dev.13 [skip ci]
# app [1.26.0-dev.13](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.12...v1.26.0-dev.13) (2025-12-17)

### Features

* Make patcher screen design more consistent with inspiration ([#2805](https://github.com/ReVanced/revanced-manager/issues/2805)) ([dbb6c01](dbb6c01e89))
2025-12-17 20:05:47 +00:00
Ushie
dbb6c01e89 feat: Make patcher screen design more consistent with inspiration (#2805) 2025-12-17 22:58:02 +03:00
semantic-release-bot
e0d529c2df chore: Release v1.26.0-dev.12 [skip ci]
# app [1.26.0-dev.12](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.11...v1.26.0-dev.12) (2025-12-17)

### Features

* Improve trust plugin dialog design ([#2420](https://github.com/ReVanced/revanced-manager/issues/2420)) ([0300da9](0300da9eac))
2025-12-17 16:04:25 +00:00
Ushie
0300da9eac feat: Improve trust plugin dialog design (#2420) 2025-12-17 18:54:04 +03:00
LisoUseInAIKyrios
4e5057ecad chore: Use raw string encoding to prevent AI translation errors (#2794)
Co-authored-by: Pun Butrach <pun.butrach@gmail.com>
2025-10-25 20:17:49 +07:00
Pun Butrach
1ef5c1c5c5 docs: Adjust feature request template to match other repository 2025-10-25 19:40:31 +07:00
Coby
39f52c1242 chore: Correct grammar mistakes (#2791)
Co-authored-by: Kobe <kobew5050@gmail.com>
2025-10-25 19:14:34 +07:00
semantic-release-bot
0c62837454 chore: Release v1.26.0-dev.11 [skip ci]
# app [1.26.0-dev.11](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.10...v1.26.0-dev.11) (2025-10-25)

### Features

* Add pure black theme ([#2824](https://github.com/ReVanced/revanced-manager/issues/2824)) ([3d75ffe](3d75ffe6a7))
2025-10-25 03:55:05 +00:00
alieRN
3d75ffe6a7 feat: Add pure black theme (#2824) 2025-10-25 10:46:50 +07:00
Coby
d188d5a410 docs: Fix typos and settings order (#2785)
Co-authored-by: Kobe <kobew5050@gmail.com>
Co-authored-by: Pun Butrach <pun.butrach@gmail.com>
2025-10-18 00:34:59 +07:00
semantic-release-bot
b43ac8a1af chore: Release v1.26.0-dev.10 [skip ci]
# app [1.26.0-dev.10](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.9...v1.26.0-dev.10) (2025-10-06)

### Bug Fixes

* prevent back presses during installation ([2ff7072](2ff70728b4))
2025-10-06 17:48:23 +00:00
Ax333l
2ff70728b4 fix: prevent back presses during installation 2025-10-06 19:40:21 +02:00
semantic-release-bot
e5097b5ecd chore: Release v1.26.0-dev.9 [skip ci]
# app [1.26.0-dev.9](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.8...v1.26.0-dev.9) (2025-10-06)

### Bug Fixes

* Instantly re-fetch patch bundle on pre-release preference update ([d5671db](d5671db3a7)), closes [#2784](https://github.com/ReVanced/revanced-manager/issues/2784)
2025-10-06 00:44:24 +00:00
Ushie
d5671db3a7 fix: Instantly re-fetch patch bundle on pre-release preference update
Closes #2784
2025-10-06 03:36:14 +03:00
semantic-release-bot
a314ba209d chore: Release v1.26.0-dev.8 [skip ci]
# app [1.26.0-dev.8](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.7...v1.26.0-dev.8) (2025-10-06)

### Bug Fixes

* Offcenter loading indicator in AppSelector ([12d92ba](12d92ba811))
2025-10-06 00:18:33 +00:00
Ushie
12d92ba811 fix: Offcenter loading indicator in AppSelector 2025-10-06 03:10:16 +03:00
33 changed files with 699 additions and 539 deletions

View File

@@ -1,3 +1,7 @@
name: ⭐ Feature request
description: Create a detailed request for a new feature.
title: 'feat: '
labels: ['Feature request']
body: body:
- type: markdown - type: markdown
attributes: attributes:

View File

@@ -1,3 +1,59 @@
# app [1.26.0-dev.15](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.14...v1.26.0-dev.15) (2025-12-29)
### Bug Fixes
* install dialog getting stuck ([#2900](https://github.com/ReVanced/revanced-manager/issues/2900)) ([18a4df9](https://github.com/ReVanced/revanced-manager/commit/18a4df9af9cac120fdb8e4ff7aadd2e2a8d5c1a6))
# app [1.26.0-dev.14](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.13...v1.26.0-dev.14) (2025-12-28)
### Bug Fixes
* Update selected patch count when SelectionState changes ([#2896](https://github.com/ReVanced/revanced-manager/issues/2896)) ([0d26df0](https://github.com/ReVanced/revanced-manager/commit/0d26df03f463195dae550240c7f652680763079c))
# app [1.26.0-dev.13](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.12...v1.26.0-dev.13) (2025-12-17)
### Features
* Make patcher screen design more consistent with inspiration ([#2805](https://github.com/ReVanced/revanced-manager/issues/2805)) ([dbb6c01](https://github.com/ReVanced/revanced-manager/commit/dbb6c01e89a5e710185ff4304de0ac9e19bed053))
# app [1.26.0-dev.12](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.11...v1.26.0-dev.12) (2025-12-17)
### Features
* Improve trust plugin dialog design ([#2420](https://github.com/ReVanced/revanced-manager/issues/2420)) ([0300da9](https://github.com/ReVanced/revanced-manager/commit/0300da9eac6c0fc29dbbb66622c0d52f4cf68934))
# app [1.26.0-dev.11](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.10...v1.26.0-dev.11) (2025-10-25)
### Features
* Add pure black theme ([#2824](https://github.com/ReVanced/revanced-manager/issues/2824)) ([3d75ffe](https://github.com/ReVanced/revanced-manager/commit/3d75ffe6a7a39efdebe13dbd07c937c1de409ead))
# app [1.26.0-dev.10](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.9...v1.26.0-dev.10) (2025-10-06)
### Bug Fixes
* prevent back presses during installation ([2ff7072](https://github.com/ReVanced/revanced-manager/commit/2ff70728b490b92f212a82dcf599bc0c23f589e7))
# app [1.26.0-dev.9](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.8...v1.26.0-dev.9) (2025-10-06)
### Bug Fixes
* Instantly re-fetch patch bundle on pre-release preference update ([d5671db](https://github.com/ReVanced/revanced-manager/commit/d5671db3a77541c07bbbb4c3baca02f3ba0703f2)), closes [#2784](https://github.com/ReVanced/revanced-manager/issues/2784)
# app [1.26.0-dev.8](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.7...v1.26.0-dev.8) (2025-10-06)
### Bug Fixes
* Offcenter loading indicator in AppSelector ([12d92ba](https://github.com/ReVanced/revanced-manager/commit/12d92ba8110f5d1ac78aeecfa575444b5c53f561))
# app [1.26.0-dev.7](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.6...v1.26.0-dev.7) (2025-10-03) # app [1.26.0-dev.7](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.6...v1.26.0-dev.7) (2025-10-03)

View File

@@ -108,6 +108,10 @@ dependencies {
// Compose Icons // Compose Icons
implementation(libs.compose.icons.fontawesome) implementation(libs.compose.icons.fontawesome)
// Ackpine
implementation(libs.ackpine.core)
implementation(libs.ackpine.ktx)
} }
buildscript { buildscript {

View File

@@ -1 +1 @@
version = 1.26.0-dev.7 version = 1.26.0-dev.15

View File

@@ -51,9 +51,6 @@
<activity android:name=".plugin.downloader.webview.WebViewActivity" android:exported="false" android:theme="@style/Theme.WebViewActivity" /> <activity android:name=".plugin.downloader.webview.WebViewActivity" android:exported="false" android:theme="@style/Theme.WebViewActivity" />
<service android:name=".service.InstallService" />
<service android:name=".service.UninstallService" />
<service <service
android:name="androidx.work.impl.foreground.SystemForegroundService" android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="specialUse" android:foregroundServiceType="specialUse"
@@ -75,5 +72,15 @@
android:value="androidx.startup" android:value="androidx.startup"
tools:node="remove" /> tools:node="remove" />
</provider> </provider>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="ru.solrudev.ackpine.AckpineInitializer"
tools:node="remove" />
</provider>
</application> </application>
</manifest> </manifest>

View File

@@ -81,6 +81,7 @@ class MainActivity : ComponentActivity() {
) )
val theme by vm.prefs.theme.getAsState() val theme by vm.prefs.theme.getAsState()
val dynamicColor by vm.prefs.dynamicColor.getAsState() val dynamicColor by vm.prefs.dynamicColor.getAsState()
val pureBlackTheme by vm.prefs.pureBlackTheme.getAsState()
EventEffect(vm.legacyImportActivityFlow) { EventEffect(vm.legacyImportActivityFlow) {
try { try {
@@ -91,7 +92,8 @@ class MainActivity : ComponentActivity() {
ReVancedManagerTheme( ReVancedManagerTheme(
darkTheme = theme == Theme.SYSTEM && isSystemInDarkTheme() || theme == Theme.DARK, darkTheme = theme == Theme.SYSTEM && isSystemInDarkTheme() || theme == Theme.DARK,
dynamicColor = dynamicColor dynamicColor = dynamicColor,
pureBlackTheme = pureBlackTheme
) { ) {
ReVancedManager(vm) ReVancedManager(vm)
} }

View File

@@ -48,7 +48,8 @@ class ManagerApplication : Application() {
workerModule, workerModule,
viewModelModule, viewModelModule,
databaseModule, databaseModule,
rootModule rootModule,
ackpineModule
) )
} }

View File

@@ -0,0 +1,19 @@
package app.revanced.manager.di
import android.content.Context
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module
import ru.solrudev.ackpine.installer.PackageInstaller
import ru.solrudev.ackpine.uninstaller.PackageUninstaller
val ackpineModule = module {
fun provideInstaller(context: Context) = PackageInstaller.getInstance(context)
fun provideUninstaller(context: Context) = PackageUninstaller.getInstance(context)
single {
provideInstaller(androidContext())
}
single {
provideUninstaller(androidContext())
}
}

View File

@@ -9,6 +9,7 @@ class PreferencesManager(
context: Context context: Context
) : BasePreferencesManager(context, "settings") { ) : BasePreferencesManager(context, "settings") {
val dynamicColor = booleanPreference("dynamic_color", true) val dynamicColor = booleanPreference("dynamic_color", true)
val pureBlackTheme = booleanPreference("pure_black_theme", false)
val theme = enumPreference("theme", Theme.SYSTEM) val theme = enumPreference("theme", Theme.SYSTEM)
val api = stringPreference("api_url", "https://api.revanced.app") val api = stringPreference("api_url", "https://api.revanced.app")

View File

@@ -1,53 +0,0 @@
package app.revanced.manager.service
import android.app.Service
import android.content.Intent
import android.content.pm.PackageInstaller
import android.os.Build
import android.os.IBinder
@Suppress("DEPRECATION")
class InstallService : Service() {
override fun onStartCommand(
intent: Intent, flags: Int, startId: Int
): Int {
val extraStatus = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999)
val extraStatusMessage = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)
val extraPackageName = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME)
when (extraStatus) {
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
startActivity(if (Build.VERSION.SDK_INT >= 33) {
intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)
} else {
intent.getParcelableExtra(Intent.EXTRA_INTENT)
}.apply {
this?.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
})
}
else -> {
sendBroadcast(Intent().apply {
action = APP_INSTALL_ACTION
`package` = packageName
putExtra(EXTRA_INSTALL_STATUS, extraStatus)
putExtra(EXTRA_INSTALL_STATUS_MESSAGE, extraStatusMessage)
putExtra(EXTRA_PACKAGE_NAME, extraPackageName)
})
}
}
stopSelf()
return START_NOT_STICKY
}
override fun onBind(intent: Intent?): IBinder? = null
companion object {
const val APP_INSTALL_ACTION = "APP_INSTALL_ACTION"
const val EXTRA_INSTALL_STATUS = "EXTRA_INSTALL_STATUS"
const val EXTRA_INSTALL_STATUS_MESSAGE = "EXTRA_INSTALL_STATUS_MESSAGE"
const val EXTRA_PACKAGE_NAME = "EXTRA_PACKAGE_NAME"
}
}

View File

@@ -1,5 +1,6 @@
package app.revanced.manager.ui.component package app.revanced.manager.ui.component
import android.annotation.SuppressLint
import android.content.pm.PackageInstaller import android.content.pm.PackageInstaller
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.annotation.StringRes import androidx.annotation.StringRes
@@ -79,7 +80,7 @@ private fun installerStatusDialogButton(
enum class DialogKind( enum class DialogKind(
val flag: Int, val flag: Int,
val title: Int, val title: Int,
@StringRes val contentStringResId: Int, @param:StringRes val contentStringResId: Int,
val icon: ImageVector = Icons.Outlined.ErrorOutline, val icon: ImageVector = Icons.Outlined.ErrorOutline,
val confirmButton: InstallerStatusDialogButton = installerStatusDialogButton(R.string.ok), val confirmButton: InstallerStatusDialogButton = installerStatusDialogButton(R.string.ok),
val dismissButton: InstallerStatusDialogButton? = null, val dismissButton: InstallerStatusDialogButton? = null,
@@ -133,10 +134,8 @@ enum class DialogKind(
title = R.string.installation_storage_issue_dialog_title, title = R.string.installation_storage_issue_dialog_title,
contentStringResId = R.string.installation_storage_issue_description, contentStringResId = R.string.installation_storage_issue_description,
), ),
@RequiresApi(34)
FAILURE_TIMEOUT( FAILURE_TIMEOUT(
flag = PackageInstaller.STATUS_FAILURE_TIMEOUT, flag = @SuppressLint("InlinedApi") PackageInstaller.STATUS_FAILURE_TIMEOUT,
title = R.string.installation_timeout_dialog_title, title = R.string.installation_timeout_dialog_title,
contentStringResId = R.string.installation_timeout_description, contentStringResId = R.string.installation_timeout_description,
confirmButton = installerStatusDialogButton(R.string.install_app) { model -> confirmButton = installerStatusDialogButton(R.string.install_app) { model ->

View File

@@ -190,6 +190,7 @@ fun BundleInformationDialog(
prefs.usePatchesPrereleases.update( prefs.usePatchesPrereleases.update(
it it
) )
onUpdate()
} }
} }
) )
@@ -197,6 +198,7 @@ fun BundleInformationDialog(
modifier = Modifier.clickable { modifier = Modifier.clickable {
composableScope.launch { composableScope.launch {
prefs.usePatchesPrereleases.update(!useBundlePrerelease) prefs.usePatchesPrereleases.update(!useBundlePrerelease)
onUpdate()
} }
} }
) )

View File

@@ -1,7 +1,7 @@
package app.revanced.manager.ui.component.patcher package app.revanced.manager.ui.component.patcher
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState import androidx.compose.animation.Crossfade
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
@@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.Spacer
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.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
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
@@ -21,6 +20,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
@@ -53,20 +53,11 @@ fun Steps(
category: StepCategory, category: StepCategory,
steps: List<Step>, steps: List<Step>,
stepCount: Pair<Int, Int>? = null, stepCount: Pair<Int, Int>? = null,
stepProgressProvider: StepProgressProvider stepProgressProvider: StepProgressProvider,
isExpanded: Boolean = false,
onExpand: () -> Unit,
onClick: () -> Unit
) { ) {
var expanded by rememberSaveable { mutableStateOf(true) }
val categoryColor by animateColorAsState(
if (expanded) MaterialTheme.colorScheme.surfaceContainerHigh else Color.Transparent,
label = "category"
)
val cardColor by animateColorAsState(
if (expanded) MaterialTheme.colorScheme.surfaceContainer else Color.Transparent,
label = "card"
)
val state = remember(steps) { val state = remember(steps) {
when { when {
steps.all { it.state == State.COMPLETED } -> State.COMPLETED steps.all { it.state == State.COMPLETED } -> State.COMPLETED
@@ -76,48 +67,52 @@ fun Steps(
} }
} }
LaunchedEffect(state) {
if (state == State.RUNNING)
onExpand()
}
Column( Column(
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(16.dp)) .clip(MaterialTheme.shapes.large)
.fillMaxWidth() .fillMaxWidth()
.background(cardColor) .background(MaterialTheme.colorScheme.surfaceContainerLow)
) { ) {
Row( Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(14.dp),
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(16.dp)) .clickable(true, onClick = onClick)
.clickable { expanded = !expanded } .fillMaxWidth()
.background(categoryColor) .padding(20.dp)
) { ) {
Row( StepIcon(state = state, size = 24.dp)
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier.padding(16.dp)
) {
StepIcon(state = state, size = 24.dp)
Text(stringResource(category.displayName)) Text(stringResource(category.displayName))
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
val stepProgress = remember(stepCount, steps) { val stepProgress = remember(stepCount, steps) {
stepCount?.let { (current, total) -> "$current/$total" } stepCount?.let { (current, total) -> "$current/$total" }
?: "${steps.count { it.state == State.COMPLETED }}/${steps.size}" ?: "${steps.count { it.state == State.COMPLETED }}/${steps.size}"
}
Text(
text = stepProgress,
style = MaterialTheme.typography.labelSmall
)
ArrowButton(modifier = Modifier.size(24.dp), expanded = expanded, onClick = null)
} }
Text(
text = stepProgress,
style = MaterialTheme.typography.labelSmall
)
ArrowButton(modifier = Modifier.size(24.dp), expanded = isExpanded, onClick = null)
} }
AnimatedVisibility(visible = expanded) { AnimatedVisibility(visible = isExpanded) {
Column( Column(
modifier = Modifier.fillMaxWidth() modifier = Modifier
.background(MaterialTheme.colorScheme.background.copy(0.6f))
.fillMaxWidth()
.padding(top = 10.dp)
) { ) {
steps.forEach { step -> steps.forEachIndexed { index, step ->
val (progress, progressText) = when (step.progressKey) { val (progress, progressText) = when (step.progressKey) {
null -> null null -> null
ProgressKey.DOWNLOAD -> stepProgressProvider.downloadProgress?.let { (downloaded, total) -> ProgressKey.DOWNLOAD -> stepProgressProvider.downloadProgress?.let { (downloaded, total) ->
@@ -131,7 +126,9 @@ fun Steps(
state = step.state, state = step.state,
message = step.message, message = step.message,
progress = progress, progress = progress,
progressText = progressText progressText = progressText,
isFirst = index == 0,
isLast = index == steps.lastIndex,
) )
} }
} }
@@ -145,7 +142,9 @@ fun SubStep(
state: State, state: State,
message: String? = null, message: String? = null,
progress: Float? = null, progress: Float? = null,
progressText: String? = null progressText: String? = null,
isFirst: Boolean = false,
isLast: Boolean = false,
) { ) {
var messageExpanded by rememberSaveable { mutableStateOf(true) } var messageExpanded by rememberSaveable { mutableStateOf(true) }
@@ -156,22 +155,22 @@ fun SubStep(
clickable { messageExpanded = !messageExpanded } clickable { messageExpanded = !messageExpanded }
else this else this
} }
.padding(top = if (isFirst) 10.dp else 8.dp, bottom = if (isLast) 20.dp else 8.dp)
.padding(horizontal = 20.dp)
) { ) {
Row( Row(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp), horizontalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
) { ) {
Box( StepIcon(
modifier = Modifier.size(24.dp), size = 18.dp,
contentAlignment = Alignment.Center state = state,
) { progress = progress,
StepIcon(state, progress, size = 20.dp) )
}
Text( Text(
text = name, text = name,
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.labelLarge,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f, true), modifier = Modifier.weight(1f, true),
@@ -201,7 +200,7 @@ fun SubStep(
text = message.orEmpty(), text = message.orEmpty(),
style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.secondary, color = MaterialTheme.colorScheme.secondary,
modifier = Modifier.padding(horizontal = 52.dp, vertical = 8.dp) modifier = Modifier.padding(horizontal = 36.dp, vertical = 8.dp)
) )
} }
} }
@@ -211,40 +210,44 @@ fun SubStep(
fun StepIcon(state: State, progress: Float? = null, size: Dp) { fun StepIcon(state: State, progress: Float? = null, size: Dp) {
val strokeWidth = Dp(floor(size.value / 10) + 1) val strokeWidth = Dp(floor(size.value / 10) + 1)
when (state) { Crossfade(targetState = state, label = "State CrossFade") { state ->
State.COMPLETED -> Icon( when (state) {
Icons.Filled.CheckCircle, State.COMPLETED -> Icon(
contentDescription = stringResource(R.string.step_completed), Icons.Filled.CheckCircle,
tint = MaterialTheme.colorScheme.surfaceTint, contentDescription = stringResource(R.string.step_completed),
modifier = Modifier.size(size) tint = Color(0xFF59B463),
) modifier = Modifier.size(size)
State.FAILED -> Icon(
Icons.Filled.Cancel,
contentDescription = stringResource(R.string.step_failed),
tint = MaterialTheme.colorScheme.error,
modifier = Modifier.size(size)
)
State.WAITING -> Icon(
Icons.Outlined.Circle,
contentDescription = stringResource(R.string.step_waiting),
tint = MaterialTheme.colorScheme.surfaceVariant,
modifier = Modifier.size(size)
)
State.RUNNING ->
LoadingIndicator(
modifier = stringResource(R.string.step_running).let { description ->
Modifier
.size(size)
.semantics {
contentDescription = description
}
},
progress = { progress },
strokeWidth = strokeWidth
) )
State.FAILED -> Icon(
Icons.Filled.Cancel,
contentDescription = stringResource(R.string.step_failed),
tint = MaterialTheme.colorScheme.error,
modifier = Modifier.size(size)
)
State.WAITING -> Icon(
Icons.Outlined.Circle,
contentDescription = stringResource(R.string.step_waiting),
tint = MaterialTheme.colorScheme.onSurface.copy(.2f),
modifier = Modifier.size(size)
)
State.RUNNING -> {
LoadingIndicator(
modifier = stringResource(R.string.step_running).let { description ->
Modifier
.size(size)
.semantics {
contentDescription = description
}
},
progress = { progress },
strokeWidth = strokeWidth
)
}
}
} }
} }

View File

@@ -234,7 +234,13 @@ fun AppSelectorScreen(
} }
} else { } else {
item { LoadingIndicator() } item {
Box(
modifier = Modifier.fillParentMaxSize(), contentAlignment = Alignment.Center
) {
LoadingIndicator()
}
}
} }
} }
} }

View File

@@ -55,6 +55,7 @@ import app.revanced.manager.ui.model.StepCategory
import app.revanced.manager.ui.viewmodel.PatcherViewModel import app.revanced.manager.ui.viewmodel.PatcherViewModel
import app.revanced.manager.util.APK_MIMETYPE import app.revanced.manager.util.APK_MIMETYPE
import app.revanced.manager.util.EventEffect import app.revanced.manager.util.EventEffect
import app.revanced.manager.util.toast
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
@@ -76,11 +77,10 @@ fun PatcherScreen(
var showInstallPicker by rememberSaveable { mutableStateOf(false) } var showInstallPicker by rememberSaveable { mutableStateOf(false) }
var showDismissConfirmationDialog by rememberSaveable { mutableStateOf(false) } var showDismissConfirmationDialog by rememberSaveable { mutableStateOf(false) }
fun onPageBack() { fun onPageBack() = when {
if(patcherSucceeded == null) patcherSucceeded == null -> showDismissConfirmationDialog = true
showDismissConfirmationDialog = true viewModel.isInstalling -> context.toast(context.getString(R.string.patcher_install_in_progress))
else else -> onLeave()
onLeave()
} }
BackHandler(onBack = ::onPageBack) BackHandler(onBack = ::onPageBack)
@@ -213,6 +213,12 @@ fun PatcherScreen(
.padding(paddingValues) .padding(paddingValues)
.fillMaxSize() .fillMaxSize()
) { ) {
var expandedCategory by rememberSaveable { mutableStateOf<StepCategory?>(null) }
val expandCategory: (StepCategory?) -> Unit = { category ->
expandedCategory = category
}
LinearProgressIndicator( LinearProgressIndicator(
progress = { viewModel.progress }, progress = { viewModel.progress },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
@@ -231,7 +237,12 @@ fun PatcherScreen(
category = category, category = category,
steps = steps, steps = steps,
stepCount = if (category == StepCategory.PATCHING) viewModel.patchesProgress else null, stepCount = if (category == StepCategory.PATCHING) viewModel.patchesProgress else null,
stepProgressProvider = viewModel stepProgressProvider = viewModel,
isExpanded = expandedCategory == category,
onExpand = { expandCategory(category) },
onClick = {
expandCategory(if (expandedCategory == category) null else category)
}
) )
} }
} }

View File

@@ -25,6 +25,7 @@ import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
@@ -76,12 +77,12 @@ fun SelectedAppInfoScreen(
val bundles by vm.bundleInfoFlow.collectAsStateWithLifecycle(emptyList()) val bundles by vm.bundleInfoFlow.collectAsStateWithLifecycle(emptyList())
val allowIncompatiblePatches by vm.prefs.disablePatchVersionCompatCheck.getAsState() val allowIncompatiblePatches by vm.prefs.disablePatchVersionCompatCheck.getAsState()
val patches = remember(bundles, allowIncompatiblePatches) { val patches by remember {
vm.getPatches(bundles, allowIncompatiblePatches) derivedStateOf {
} vm.getPatches(bundles, allowIncompatiblePatches)
val selectedPatchCount = remember(patches) { }
patches.values.sumOf { it.size }
} }
val selectedPatchCount = patches.values.sumOf { it.size }
val launcher = rememberLauncherForActivityResult( val launcher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.StartActivityForResult(), contract = ActivityResultContracts.StartActivityForResult(),

View File

@@ -2,6 +2,8 @@ package app.revanced.manager.ui.screen.settings
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
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
@@ -10,10 +12,13 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.outlined.Delete import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.AlertDialog import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
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.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextButton import androidx.compose.material3.TextButton
@@ -28,6 +33,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@@ -36,10 +42,10 @@ import app.revanced.manager.R
import app.revanced.manager.network.downloader.DownloaderPluginState import app.revanced.manager.network.downloader.DownloaderPluginState
import app.revanced.manager.ui.component.AppLabel import app.revanced.manager.ui.component.AppLabel
import app.revanced.manager.ui.component.AppTopBar import app.revanced.manager.ui.component.AppTopBar
import app.revanced.manager.ui.component.ConfirmDialog
import app.revanced.manager.ui.component.ExceptionViewerDialog import app.revanced.manager.ui.component.ExceptionViewerDialog
import app.revanced.manager.ui.component.GroupHeader import app.revanced.manager.ui.component.GroupHeader
import app.revanced.manager.ui.component.LazyColumnWithScrollbar import app.revanced.manager.ui.component.LazyColumnWithScrollbar
import app.revanced.manager.ui.component.ConfirmDialog
import app.revanced.manager.ui.component.haptics.HapticCheckbox import app.revanced.manager.ui.component.haptics.HapticCheckbox
import app.revanced.manager.ui.component.settings.SettingsListItem import app.revanced.manager.ui.component.settings.SettingsListItem
import app.revanced.manager.ui.viewmodel.DownloadsViewModel import app.revanced.manager.ui.viewmodel.DownloadsViewModel
@@ -52,6 +58,7 @@ fun DownloadsSettingsScreen(
onBackClick: () -> Unit, onBackClick: () -> Unit,
viewModel: DownloadsViewModel = koinViewModel() viewModel: DownloadsViewModel = koinViewModel()
) { ) {
val context = LocalContext.current
val downloadedApps by viewModel.downloadedApps.collectAsStateWithLifecycle(emptyList()) val downloadedApps by viewModel.downloadedApps.collectAsStateWithLifecycle(emptyList())
val pluginStates by viewModel.downloaderPluginStates.collectAsStateWithLifecycle() val pluginStates by viewModel.downloaderPluginStates.collectAsStateWithLifecycle()
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
@@ -75,7 +82,7 @@ fun DownloadsSettingsScreen(
onBackClick = onBackClick, onBackClick = onBackClick,
actions = { actions = {
if (viewModel.appSelection.isNotEmpty()) { if (viewModel.appSelection.isNotEmpty()) {
IconButton(onClick = { showDeleteConfirmationDialog = true }) { IconButton(onClick = { viewModel.deleteApps() }) {
Icon(Icons.Default.Delete, stringResource(R.string.delete)) Icon(Icons.Default.Delete, stringResource(R.string.delete))
} }
} }
@@ -121,6 +128,11 @@ fun DownloadsSettingsScreen(
.digest(androidSignature.toByteArray()) .digest(androidSignature.toByteArray())
hash.toHexString(format = HexFormat.UpperCase) hash.toHexString(format = HexFormat.UpperCase)
} }
val appName = remember {
packageInfo.applicationInfo?.loadLabel(context.packageManager)
?.toString()
?: packageName
}
when (state) { when (state) {
is DownloaderPluginState.Loaded -> TrustDialog( is DownloaderPluginState.Loaded -> TrustDialog(
@@ -130,6 +142,8 @@ fun DownloadsSettingsScreen(
packageName, packageName,
signature signature
), ),
pluginName = appName,
signature = signature,
onDismiss = ::dismiss, onDismiss = ::dismiss,
onConfirm = { onConfirm = {
viewModel.revokePluginTrust(packageName) viewModel.revokePluginTrust(packageName)
@@ -147,10 +161,10 @@ fun DownloadsSettingsScreen(
is DownloaderPluginState.Untrusted -> TrustDialog( is DownloaderPluginState.Untrusted -> TrustDialog(
title = R.string.downloader_plugin_trust_dialog_title, title = R.string.downloader_plugin_trust_dialog_title,
body = stringResource( body = stringResource(
R.string.downloader_plugin_trust_dialog_body, R.string.downloader_plugin_trust_dialog_body
packageName,
signature
), ),
pluginName = appName,
signature = signature,
onDismiss = ::dismiss, onDismiss = ::dismiss,
onConfirm = { onConfirm = {
viewModel.trustPlugin(packageName) viewModel.trustPlugin(packageName)
@@ -226,6 +240,8 @@ fun DownloadsSettingsScreen(
private fun TrustDialog( private fun TrustDialog(
@StringRes title: Int, @StringRes title: Int,
body: String, body: String,
pluginName: String,
signature: String,
onDismiss: () -> Unit, onDismiss: () -> Unit,
onConfirm: () -> Unit onConfirm: () -> Unit
) { ) {
@@ -238,10 +254,39 @@ private fun TrustDialog(
}, },
dismissButton = { dismissButton = {
TextButton(onClick = onDismiss) { TextButton(onClick = onDismiss) {
Text(stringResource(R.string.dismiss)) Text(stringResource(R.string.cancel))
} }
}, },
title = { Text(stringResource(title)) }, title = { Text(stringResource(title)) },
text = { Text(body) } text = {
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(body)
Card {
Column(
Modifier.padding(12.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Text(
stringResource(
R.string.downloader_plugin_trust_dialog_plugin,
pluginName
),
)
OutlinedCard(
colors = CardDefaults.outlinedCardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHighest
)
) {
Text(
stringResource(
R.string.downloader_plugin_trust_dialog_signature,
signature.chunked(2).joinToString(" ")
), modifier = Modifier.padding(12.dp)
)
}
}
}
}
}
) )
} }

View File

@@ -1,6 +1,7 @@
package app.revanced.manager.ui.screen.settings package app.revanced.manager.ui.screen.settings
import android.os.Build import android.os.Build
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
@@ -96,6 +97,14 @@ fun GeneralSettingsScreen(
description = R.string.dynamic_color_description description = R.string.dynamic_color_description
) )
} }
AnimatedVisibility(theme != Theme.LIGHT) {
BooleanItem(
preference = prefs.pureBlackTheme,
coroutineScope = coroutineScope,
headline = R.string.pure_black_theme,
description = R.string.pure_black_theme_description
)
}
} }
} }
} }

View File

@@ -80,6 +80,7 @@ private val LightColorScheme = lightColorScheme(
fun ReVancedManagerTheme( fun ReVancedManagerTheme(
darkTheme: Boolean, darkTheme: Boolean,
dynamicColor: Boolean, dynamicColor: Boolean,
pureBlackTheme: Boolean,
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {
val colorScheme = when { val colorScheme = when {
@@ -93,6 +94,10 @@ fun ReVancedManagerTheme(
darkTheme -> DarkColorScheme darkTheme -> DarkColorScheme
else -> LightColorScheme else -> LightColorScheme
}.let {
if (darkTheme && pureBlackTheme)
it.copy(background = Color.Black, surface = Color.Black)
else it
} }
val view = LocalView.current val view = LocalView.current

View File

@@ -1,17 +1,11 @@
package app.revanced.manager.ui.viewmodel package app.revanced.manager.ui.viewmodel
import android.app.Application import android.app.Application
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageInfo import android.content.pm.PackageInfo
import android.content.pm.PackageInstaller
import android.util.Log import android.util.Log
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import app.revanced.manager.R import app.revanced.manager.R
@@ -19,7 +13,6 @@ import app.revanced.manager.data.room.apps.installed.InstallType
import app.revanced.manager.data.room.apps.installed.InstalledApp import app.revanced.manager.data.room.apps.installed.InstalledApp
import app.revanced.manager.domain.installer.RootInstaller import app.revanced.manager.domain.installer.RootInstaller
import app.revanced.manager.domain.repository.InstalledAppRepository import app.revanced.manager.domain.repository.InstalledAppRepository
import app.revanced.manager.service.UninstallService
import app.revanced.manager.util.PM import app.revanced.manager.util.PM
import app.revanced.manager.util.PatchSelection import app.revanced.manager.util.PatchSelection
import app.revanced.manager.util.simpleMessage import app.revanced.manager.util.simpleMessage
@@ -30,6 +23,8 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.koin.core.component.KoinComponent import org.koin.core.component.KoinComponent
import org.koin.core.component.inject import org.koin.core.component.inject
import ru.solrudev.ackpine.session.Session
import ru.solrudev.ackpine.uninstaller.UninstallFailure
class InstalledAppInfoViewModel( class InstalledAppInfoViewModel(
packageName: String packageName: String
@@ -87,51 +82,28 @@ class InstalledAppInfoViewModel(
fun uninstall() { fun uninstall() {
val app = installedApp ?: return val app = installedApp ?: return
when (app.installType) { viewModelScope.launch {
InstallType.DEFAULT -> pm.uninstallPackage(app.currentPackageName) when (app.installType) {
InstallType.DEFAULT -> {
InstallType.MOUNT -> viewModelScope.launch { when (val result = pm.uninstallPackage(app.currentPackageName)) {
rootInstaller.uninstall(app.currentPackageName) is Session.State.Failed<UninstallFailure> -> {
installedAppRepository.delete(app) val msg = result.failure.message.orEmpty()
onBackClick() context.toast(
} this@InstalledAppInfoViewModel.context.getString(
} R.string.uninstall_app_fail,
} msg
)
private val uninstallBroadcastReceiver = object : BroadcastReceiver() { )
override fun onReceive(context: Context?, intent: Intent?) { return@launch
when (intent?.action) {
UninstallService.APP_UNINSTALL_ACTION -> {
val extraStatus =
intent.getIntExtra(UninstallService.EXTRA_UNINSTALL_STATUS, -999)
val extraStatusMessage =
intent.getStringExtra(UninstallService.EXTRA_UNINSTALL_STATUS_MESSAGE)
if (extraStatus == PackageInstaller.STATUS_SUCCESS) {
viewModelScope.launch {
installedApp?.let {
installedAppRepository.delete(it)
}
onBackClick()
} }
} else if (extraStatus != PackageInstaller.STATUS_FAILURE_ABORTED) { Session.State.Succeeded -> {}
this@InstalledAppInfoViewModel.context.toast(this@InstalledAppInfoViewModel.context.getString(R.string.uninstall_app_fail, extraStatusMessage))
} }
} }
}
}
}.also {
ContextCompat.registerReceiver(
context,
it,
IntentFilter(UninstallService.APP_UNINSTALL_ACTION),
ContextCompat.RECEIVER_NOT_EXPORTED
)
}
override fun onCleared() { InstallType.MOUNT -> rootInstaller.uninstall(app.currentPackageName)
super.onCleared() }
context.unregisterReceiver(uninstallBroadcastReceiver) installedAppRepository.delete(app)
onBackClick()
}
} }
} }

View File

@@ -1,11 +1,9 @@
package app.revanced.manager.ui.viewmodel package app.revanced.manager.ui.viewmodel
import android.app.Application import android.app.Application
import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.pm.PackageInstaller as AndroidPackageInstaller
import android.content.pm.PackageInstaller
import android.net.Uri import android.net.Uri
import android.os.ParcelUuid import android.os.ParcelUuid
import android.util.Log import android.util.Log
@@ -16,7 +14,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.autoSaver import androidx.compose.runtime.saveable.autoSaver
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.runtime.toMutableStateList import androidx.compose.runtime.toMutableStateList
import androidx.core.content.ContextCompat
import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.map import androidx.lifecycle.map
@@ -37,8 +34,6 @@ import app.revanced.manager.patcher.logger.Logger
import app.revanced.manager.patcher.worker.PatcherWorker import app.revanced.manager.patcher.worker.PatcherWorker
import app.revanced.manager.plugin.downloader.PluginHostApi import app.revanced.manager.plugin.downloader.PluginHostApi
import app.revanced.manager.plugin.downloader.UserInteractionException import app.revanced.manager.plugin.downloader.UserInteractionException
import app.revanced.manager.service.InstallService
import app.revanced.manager.service.UninstallService
import app.revanced.manager.ui.model.InstallerModel import app.revanced.manager.ui.model.InstallerModel
import app.revanced.manager.ui.model.ProgressKey import app.revanced.manager.ui.model.ProgressKey
import app.revanced.manager.ui.model.SelectedApp import app.revanced.manager.ui.model.SelectedApp
@@ -48,16 +43,19 @@ import app.revanced.manager.ui.model.StepCategory
import app.revanced.manager.ui.model.StepProgressProvider import app.revanced.manager.ui.model.StepProgressProvider
import app.revanced.manager.ui.model.navigation.Patcher import app.revanced.manager.ui.model.navigation.Patcher
import app.revanced.manager.util.PM import app.revanced.manager.util.PM
import app.revanced.manager.util.asCode
import app.revanced.manager.util.saveableVar import app.revanced.manager.util.saveableVar
import app.revanced.manager.util.saver.snapshotStateListSaver import app.revanced.manager.util.saver.snapshotStateListSaver
import app.revanced.manager.util.simpleMessage
import app.revanced.manager.util.tag
import app.revanced.manager.util.toast import app.revanced.manager.util.toast
import app.revanced.manager.util.uiSafe import app.revanced.manager.util.uiSafe
import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.async
import kotlinx.coroutines.cancel
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -66,6 +64,15 @@ import kotlinx.coroutines.withContext
import org.koin.core.component.KoinComponent import org.koin.core.component.KoinComponent
import org.koin.core.component.get import org.koin.core.component.get
import org.koin.core.component.inject import org.koin.core.component.inject
import ru.solrudev.ackpine.installer.InstallFailure
import ru.solrudev.ackpine.installer.PackageInstaller
import ru.solrudev.ackpine.installer.createSession
import ru.solrudev.ackpine.installer.getSession
import ru.solrudev.ackpine.session.ProgressSession
import ru.solrudev.ackpine.session.Session
import ru.solrudev.ackpine.session.await
import ru.solrudev.ackpine.session.parameters.Confirmation
import ru.solrudev.ackpine.uninstaller.UninstallFailure
import java.io.File import java.io.File
import java.nio.file.Files import java.nio.file.Files
import java.time.Duration import java.time.Duration
@@ -81,6 +88,7 @@ class PatcherViewModel(
private val installedAppRepository: InstalledAppRepository by inject() private val installedAppRepository: InstalledAppRepository by inject()
private val rootInstaller: RootInstaller by inject() private val rootInstaller: RootInstaller by inject()
private val savedStateHandle: SavedStateHandle = get() private val savedStateHandle: SavedStateHandle = get()
private val ackpineInstaller: PackageInstaller = get()
private var installedApp: InstalledApp? = null private var installedApp: InstalledApp? = null
private val selectedApp = input.selectedApp private val selectedApp = input.selectedApp
@@ -95,7 +103,6 @@ class PatcherViewModel(
mutableStateOf<String?>(null) mutableStateOf<String?>(null)
} }
private set private set
private var ongoingPmSession: Boolean by savedStateHandle.saveableVar { false }
var packageInstallerStatus: Int? by savedStateHandle.saveable( var packageInstallerStatus: Int? by savedStateHandle.saveable(
key = "packageInstallerStatus", key = "packageInstallerStatus",
stateSaver = autoSaver() stateSaver = autoSaver()
@@ -104,7 +111,7 @@ class PatcherViewModel(
} }
private set private set
var isInstalling by mutableStateOf(ongoingPmSession) var isInstalling by mutableStateOf(false)
private set private set
private var currentActivityRequest: Pair<CompletableDeferred<Boolean>, String>? by mutableStateOf( private var currentActivityRequest: Pair<CompletableDeferred<Boolean>, String>? by mutableStateOf(
@@ -123,6 +130,18 @@ class PatcherViewModel(
} }
} }
/**
* This coroutine scope is used to await installations.
* It should not be cancelled on system-initiated process death since that would cancel the installation process.
*/
private val installerCoroutineScope = CoroutineScope(Dispatchers.Main)
/**
* Holds the package name of the Apk we are trying to install.
*/
private var installerPkgName: String by savedStateHandle.saveableVar { "" }
private var installerSessionId: ParcelUuid? by savedStateHandle.saveableVar()
private var inputFile: File? by savedStateHandle.saveableVar() private var inputFile: File? by savedStateHandle.saveableVar()
private val outputFile = tempDir.resolve("output.apk") private val outputFile = tempDir.resolve("output.apk")
@@ -174,67 +193,68 @@ class PatcherViewModel(
private val workManager = WorkManager.getInstance(app) private val workManager = WorkManager.getInstance(app)
private val patcherWorkerId by savedStateHandle.saveable<ParcelUuid> { private val patcherWorkerId by savedStateHandle.saveable<ParcelUuid> {
ParcelUuid(workerRepository.launchExpedited<PatcherWorker, PatcherWorker.Args>( ParcelUuid(
"patching", PatcherWorker.Args( workerRepository.launchExpedited<PatcherWorker, PatcherWorker.Args>(
input.selectedApp, "patching", PatcherWorker.Args(
outputFile.path, input.selectedApp,
input.selectedPatches, outputFile.path,
input.options, input.selectedPatches,
logger, input.options,
onDownloadProgress = { logger,
withContext(Dispatchers.Main) { onDownloadProgress = {
downloadProgress = it withContext(Dispatchers.Main) {
} downloadProgress = it
}, }
onPatchCompleted = { withContext(Dispatchers.Main) { completedPatchCount += 1 } }, },
setInputFile = { withContext(Dispatchers.Main) { inputFile = it } }, onPatchCompleted = { withContext(Dispatchers.Main) { completedPatchCount += 1 } },
handleStartActivityRequest = { plugin, intent -> setInputFile = { withContext(Dispatchers.Main) { inputFile = it } },
withContext(Dispatchers.Main) { handleStartActivityRequest = { plugin, intent ->
if (currentActivityRequest != null) throw Exception("Another request is already pending.") withContext(Dispatchers.Main) {
try { if (currentActivityRequest != null) throw Exception("Another request is already pending.")
// Wait for the dialog interaction.
val accepted = with(CompletableDeferred<Boolean>()) {
currentActivityRequest = this to plugin.name
await()
}
if (!accepted) throw UserInteractionException.RequestDenied()
// Launch the activity and wait for the result.
try { try {
with(CompletableDeferred<ActivityResult>()) { // Wait for the dialog interaction.
launchedActivity = this val accepted = with(CompletableDeferred<Boolean>()) {
launchActivityChannel.send(intent) currentActivityRequest = this to plugin.name
await() await()
} }
if (!accepted) throw UserInteractionException.RequestDenied()
// Launch the activity and wait for the result.
try {
with(CompletableDeferred<ActivityResult>()) {
launchedActivity = this
launchActivityChannel.send(intent)
await()
}
} finally {
launchedActivity = null
}
} finally { } finally {
launchedActivity = null currentActivityRequest = null
}
}
},
onProgress = { name, state, message ->
viewModelScope.launch {
steps[currentStepIndex] = steps[currentStepIndex].run {
copy(
name = name ?: this.name,
state = state ?: this.state,
message = message ?: this.message
)
}
if (state == State.COMPLETED && currentStepIndex != steps.lastIndex) {
currentStepIndex++
steps[currentStepIndex] =
steps[currentStepIndex].copy(state = State.RUNNING)
} }
} finally {
currentActivityRequest = null
} }
} }
}, )
onProgress = { name, state, message -> ))
viewModelScope.launch {
steps[currentStepIndex] = steps[currentStepIndex].run {
copy(
name = name ?: this.name,
state = state ?: this.state,
message = message ?: this.message
)
}
if (state == State.COMPLETED && currentStepIndex != steps.lastIndex) {
currentStepIndex++
steps[currentStepIndex] =
steps[currentStepIndex].copy(state = State.RUNNING)
}
}
}
)
))
} }
val patcherSucceeded = val patcherSucceeded =
@@ -246,64 +266,26 @@ class PatcherViewModel(
} }
} }
private val installerBroadcastReceiver = object : BroadcastReceiver() { init {
override fun onReceive(context: Context?, intent: Intent?) { // TODO: detect system-initiated process death during the patching process.
when (intent?.action) {
InstallService.APP_INSTALL_ACTION -> {
val pmStatus = intent.getIntExtra(
InstallService.EXTRA_INSTALL_STATUS,
PackageInstaller.STATUS_FAILURE
)
intent.getStringExtra(UninstallService.EXTRA_UNINSTALL_STATUS_MESSAGE) installerSessionId?.uuid?.let { id ->
?.let(logger::trace) viewModelScope.launch {
try {
if (pmStatus == PackageInstaller.STATUS_SUCCESS) { isInstalling = true
app.toast(app.getString(R.string.install_app_success)) uiSafe(app, R.string.install_app_fail, "Failed to install") {
installedPackageName = // The process was killed during installation. Await the session again.
intent.getStringExtra(InstallService.EXTRA_PACKAGE_NAME) withContext(Dispatchers.IO) {
viewModelScope.launch { ackpineInstaller.getSession(id)
installedAppRepository.addOrUpdate( }?.let {
installedPackageName!!, awaitInstallation(it)
packageName,
input.selectedApp.version
?: pm.getPackageInfo(outputFile)?.versionName!!,
InstallType.DEFAULT,
input.selectedPatches
)
} }
} else packageInstallerStatus = pmStatus }
} finally {
isInstalling = false isInstalling = false
} }
UninstallService.APP_UNINSTALL_ACTION -> {
val pmStatus = intent.getIntExtra(
UninstallService.EXTRA_UNINSTALL_STATUS,
PackageInstaller.STATUS_FAILURE
)
intent.getStringExtra(UninstallService.EXTRA_UNINSTALL_STATUS_MESSAGE)
?.let(logger::trace)
if (pmStatus != PackageInstaller.STATUS_SUCCESS)
packageInstallerStatus = pmStatus
}
} }
} }
}
init {
// TODO: detect system-initiated process death during the patching process.
ContextCompat.registerReceiver(
app,
installerBroadcastReceiver,
IntentFilter().apply {
addAction(InstallService.APP_INSTALL_ACTION)
addAction(UninstallService.APP_UNINSTALL_ACTION)
},
ContextCompat.RECEIVER_NOT_EXPORTED
)
viewModelScope.launch { viewModelScope.launch {
installedApp = installedAppRepository.get(packageName) installedApp = installedAppRepository.get(packageName)
@@ -313,7 +295,6 @@ class PatcherViewModel(
@OptIn(DelicateCoroutinesApi::class) @OptIn(DelicateCoroutinesApi::class)
override fun onCleared() { override fun onCleared() {
super.onCleared() super.onCleared()
app.unregisterReceiver(installerBroadcastReceiver)
workManager.cancelWorkById(patcherWorkerId.uuid) workManager.cancelWorkById(patcherWorkerId.uuid)
if (input.selectedApp is SelectedApp.Installed && installedApp?.installType == InstallType.MOUNT) { if (input.selectedApp is SelectedApp.Installed && installedApp?.installType == InstallType.MOUNT) {
@@ -328,6 +309,7 @@ class PatcherViewModel(
} }
fun onBack() { fun onBack() {
installerCoroutineScope.cancel()
// tempDir cannot be deleted inside onCleared because it gets called on system-initiated process death. // tempDir cannot be deleted inside onCleared because it gets called on system-initiated process death.
tempDir.deleteRecursively() tempDir.deleteRecursively()
} }
@@ -372,44 +354,93 @@ class PatcherViewModel(
fun open() = installedPackageName?.let(pm::launch) fun open() = installedPackageName?.let(pm::launch)
fun install(installType: InstallType) = viewModelScope.launch { private suspend fun startInstallation(file: File, packageName: String) {
var pmInstallStarted = false val session = withContext(Dispatchers.IO) {
try { ackpineInstaller.createSession(Uri.fromFile(file)) {
isInstalling = true confirmation = Confirmation.IMMEDIATE
}
}
withContext(Dispatchers.Main) {
installerPkgName = packageName
}
awaitInstallation(session)
}
val currentPackageInfo = pm.getPackageInfo(outputFile) private suspend fun awaitInstallation(session: ProgressSession<InstallFailure>) = withContext(
?: throw Exception("Failed to load application info") Dispatchers.Main
) {
// If the app is currently installed val result = installerCoroutineScope.async {
val existingPackageInfo = pm.getPackageInfo(currentPackageInfo.packageName) try {
if (existingPackageInfo != null) { installerSessionId = ParcelUuid(session.id)
// Check if the app version is less than the installed version withContext(Dispatchers.IO) {
if (pm.getVersionCode(currentPackageInfo) < pm.getVersionCode(existingPackageInfo)) { session.await()
// Exit if the selected app version is less than the installed version
packageInstallerStatus = PackageInstaller.STATUS_FAILURE_CONFLICT
return@launch
} }
} finally {
installerSessionId = null
}
}.await()
when (result) {
is Session.State.Failed<InstallFailure> -> {
result.failure.message?.let(logger::trace)
packageInstallerStatus = result.failure.asCode()
} }
when (installType) { Session.State.Succeeded -> {
InstallType.DEFAULT -> { app.toast(app.getString(R.string.install_app_success))
// Check if the app is mounted as root installedPackageName = installerPkgName
// If it is, unmount it first, silently installedAppRepository.addOrUpdate(
if (rootInstaller.hasRootAccess() && rootInstaller.isAppMounted(packageName)) { installerPkgName,
rootInstaller.unmount(packageName) packageName,
} input.selectedApp.version
?: withContext(Dispatchers.IO) { pm.getPackageInfo(outputFile)?.versionName!! },
InstallType.DEFAULT,
input.selectedPatches
)
}
}
}
// Install regularly fun install(installType: InstallType) = viewModelScope.launch {
pm.installApp(listOf(outputFile)) isInstalling = true
pmInstallStarted = true var needsRootUninstall = false
try {
uiSafe(app, R.string.install_app_fail, "Failed to install") {
val currentPackageInfo =
withContext(Dispatchers.IO) { pm.getPackageInfo(outputFile) }
?: throw Exception("Failed to load application info")
// If the app is currently installed
val existingPackageInfo =
withContext(Dispatchers.IO) { pm.getPackageInfo(currentPackageInfo.packageName) }
if (existingPackageInfo != null) {
// Check if the app version is less than the installed version
if (
pm.getVersionCode(currentPackageInfo) < pm.getVersionCode(
existingPackageInfo
)
) {
// Exit if the selected app version is less than the installed version
packageInstallerStatus = AndroidPackageInstaller.STATUS_FAILURE_CONFLICT
return@launch
}
} }
InstallType.MOUNT -> { when (installType) {
try { InstallType.DEFAULT -> {
val packageInfo = pm.getPackageInfo(outputFile) // Check if the app is mounted as root
?: throw Exception("Failed to load application info") // If it is, unmount it first, silently
if (rootInstaller.hasRootAccess() && rootInstaller.isAppMounted(packageName)) {
rootInstaller.unmount(packageName)
}
// Install regularly
startInstallation(outputFile, currentPackageInfo.packageName)
}
InstallType.MOUNT -> {
val label = with(pm) { val label = with(pm) {
packageInfo.label() currentPackageInfo.label()
} }
// Check for base APK, first check if the app is already installed // Check for base APK, first check if the app is already installed
@@ -417,15 +448,17 @@ class PatcherViewModel(
// If the app is not installed, check if the output file is a base apk // If the app is not installed, check if the output file is a base apk
if (currentPackageInfo.splitNames.isNotEmpty()) { if (currentPackageInfo.splitNames.isNotEmpty()) {
// Exit if there is no base APK package // Exit if there is no base APK package
packageInstallerStatus = PackageInstaller.STATUS_FAILURE_INVALID packageInstallerStatus =
AndroidPackageInstaller.STATUS_FAILURE_INVALID
return@launch return@launch
} }
} }
val inputVersion = input.selectedApp.version val inputVersion = input.selectedApp.version
?: inputFile?.let(pm::getPackageInfo)?.versionName ?: withContext(Dispatchers.IO) { inputFile?.let(pm::getPackageInfo)?.versionName }
?: throw Exception("Failed to determine input APK version") ?: throw Exception("Failed to determine input APK version")
needsRootUninstall = true
// Install as root // Install as root
rootInstaller.install( rootInstaller.install(
outputFile, outputFile,
@@ -436,7 +469,7 @@ class PatcherViewModel(
) )
installedAppRepository.addOrUpdate( installedAppRepository.addOrUpdate(
packageInfo.packageName, currentPackageInfo.packageName,
packageName, packageName,
inputVersion, inputVersion,
InstallType.MOUNT, InstallType.MOUNT,
@@ -448,21 +481,20 @@ class PatcherViewModel(
installedPackageName = packageName installedPackageName = packageName
app.toast(app.getString(R.string.install_app_success)) app.toast(app.getString(R.string.install_app_success))
} catch (e: Exception) { needsRootUninstall = false
Log.e(tag, "Failed to install as root", e)
app.toast(app.getString(R.string.install_app_fail, e.simpleMessage()))
try {
rootInstaller.uninstall(packageName)
} catch (_: Exception) {
}
} }
} }
} }
} catch (e: Exception) {
Log.e(tag, "Failed to install", e)
app.toast(app.getString(R.string.install_app_fail, e.simpleMessage()))
} finally { } finally {
if (!pmInstallStarted) isInstalling = false isInstalling = false
if (needsRootUninstall) {
try {
withContext(NonCancellable) {
rootInstaller.uninstall(packageName)
}
} catch (_: Exception) {
}
}
} }
} }
@@ -473,12 +505,27 @@ class PatcherViewModel(
override fun reinstall() { override fun reinstall() {
viewModelScope.launch { viewModelScope.launch {
uiSafe(app, R.string.reinstall_app_fail, "Failed to reinstall") { try {
pm.getPackageInfo(outputFile)?.packageName?.let { pm.uninstallPackage(it) }
?: throw Exception("Failed to load application info")
pm.installApp(listOf(outputFile))
isInstalling = true isInstalling = true
uiSafe(app, R.string.reinstall_app_fail, "Failed to reinstall") {
val pkgName = withContext(Dispatchers.IO) {
pm.getPackageInfo(outputFile)?.packageName
?: throw Exception("Failed to load application info")
}
when (val result = pm.uninstallPackage(pkgName)) {
is Session.State.Failed<UninstallFailure> -> {
result.failure.message?.let(logger::trace)
packageInstallerStatus = result.failure.asCode()
return@launch
}
Session.State.Succeeded -> {}
}
startInstallation(outputFile, pkgName)
}
} finally {
isInstalling = false
} }
} }
} }

View File

@@ -8,7 +8,6 @@ import android.os.Parcelable
import android.util.Log import android.util.Log
import androidx.activity.result.ActivityResult import androidx.activity.result.ActivityResult
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
@@ -129,8 +128,6 @@ class SelectedAppInfoViewModel(
} }
var options: Options by savedStateHandle.saveable { var options: Options by savedStateHandle.saveable {
val state = mutableStateOf<Options>(emptyMap())
viewModelScope.launch { viewModelScope.launch {
if (!persistConfiguration) return@launch // TODO: save options for patched apps. if (!persistConfiguration) return@launch // TODO: save options for patched apps.
val bundlePatches = bundleInfoFlow.first() val bundlePatches = bundleInfoFlow.first()
@@ -141,7 +138,7 @@ class SelectedAppInfoViewModel(
} }
} }
state mutableStateOf(emptyMap())
} }
private set private set
@@ -149,8 +146,6 @@ class SelectedAppInfoViewModel(
if (input.patches != null) if (input.patches != null)
return@saveable mutableStateOf(SelectionState.Customized(input.patches)) return@saveable mutableStateOf(SelectionState.Customized(input.patches))
val selection: MutableState<SelectionState> = mutableStateOf(SelectionState.Default)
// Try to get the previous selection if customization is enabled. // Try to get the previous selection if customization is enabled.
viewModelScope.launch { viewModelScope.launch {
if (!prefs.disableSelectionWarning.get()) return@launch if (!prefs.disableSelectionWarning.get()) return@launch
@@ -160,7 +155,7 @@ class SelectedAppInfoViewModel(
selectionState = SelectionState.Customized(previous) selectionState = SelectionState.Customized(previous)
} }
selection mutableStateOf(SelectionState.Default)
} }
var showSourceSelector by mutableStateOf(false) var showSourceSelector by mutableStateOf(false)
@@ -311,7 +306,7 @@ class SelectedAppInfoViewModel(
} }
} }
enum class Error(@StringRes val resourceId: Int) { enum class Error(@param:StringRes val resourceId: Int) {
NoPlugins(R.string.downloader_no_plugins_available) NoPlugins(R.string.downloader_no_plugins_available)
} }

View File

@@ -1,18 +1,13 @@
package app.revanced.manager.ui.viewmodel package app.revanced.manager.ui.viewmodel
import android.app.Application import android.app.Application
import android.content.BroadcastReceiver import android.net.Uri
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageInstaller
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import app.revanced.manager.R import app.revanced.manager.R
@@ -21,8 +16,6 @@ import app.revanced.manager.data.platform.NetworkInfo
import app.revanced.manager.network.api.ReVancedAPI import app.revanced.manager.network.api.ReVancedAPI
import app.revanced.manager.network.dto.ReVancedAsset import app.revanced.manager.network.dto.ReVancedAsset
import app.revanced.manager.network.service.HttpService import app.revanced.manager.network.service.HttpService
import app.revanced.manager.service.InstallService
import app.revanced.manager.util.PM
import app.revanced.manager.util.toast import app.revanced.manager.util.toast
import app.revanced.manager.util.uiSafe import app.revanced.manager.util.uiSafe
import io.ktor.client.plugins.onDownload import io.ktor.client.plugins.onDownload
@@ -31,7 +24,14 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.koin.core.component.KoinComponent import org.koin.core.component.KoinComponent
import org.koin.core.component.get
import org.koin.core.component.inject import org.koin.core.component.inject
import ru.solrudev.ackpine.installer.InstallFailure
import ru.solrudev.ackpine.installer.PackageInstaller
import ru.solrudev.ackpine.installer.createSession
import ru.solrudev.ackpine.session.Session
import ru.solrudev.ackpine.session.await
import ru.solrudev.ackpine.session.parameters.Confirmation
class UpdateViewModel( class UpdateViewModel(
private val downloadOnScreenEntry: Boolean private val downloadOnScreenEntry: Boolean
@@ -39,10 +39,11 @@ class UpdateViewModel(
private val app: Application by inject() private val app: Application by inject()
private val reVancedAPI: ReVancedAPI by inject() private val reVancedAPI: ReVancedAPI by inject()
private val http: HttpService by inject() private val http: HttpService by inject()
private val pm: PM by inject()
private val networkInfo: NetworkInfo by inject() private val networkInfo: NetworkInfo by inject()
private val fs: Filesystem by inject() private val fs: Filesystem by inject()
private val ackpineInstaller: PackageInstaller = get()
// TODO: save state to handle process death.
var downloadedSize by mutableLongStateOf(0L) var downloadedSize by mutableLongStateOf(0L)
private set private set
var totalSize by mutableLongStateOf(0L) var totalSize by mutableLongStateOf(0L)
@@ -62,14 +63,17 @@ class UpdateViewModel(
private set private set
private val location = fs.tempDir.resolve("updater.apk") private val location = fs.tempDir.resolve("updater.apk")
private val job = viewModelScope.launch {
uiSafe(app, R.string.download_manager_failed, "Failed to download ReVanced Manager") {
releaseInfo = reVancedAPI.getAppUpdate() ?: throw Exception("No update available")
if (downloadOnScreenEntry) { init {
downloadUpdate() viewModelScope.launch {
} else { uiSafe(app, R.string.download_manager_failed, "Failed to download ReVanced Manager") {
state = State.CAN_DOWNLOAD releaseInfo = reVancedAPI.getAppUpdate() ?: throw Exception("No update available")
if (downloadOnScreenEntry) {
downloadUpdate()
} else {
state = State.CAN_DOWNLOAD
}
} }
} }
} }
@@ -98,50 +102,36 @@ class UpdateViewModel(
fun installUpdate() = viewModelScope.launch { fun installUpdate() = viewModelScope.launch {
state = State.INSTALLING state = State.INSTALLING
val result = withContext(Dispatchers.IO) {
ackpineInstaller.createSession(Uri.fromFile(location)) {
confirmation = Confirmation.IMMEDIATE
}.await()
}
pm.installApp(listOf(location)) when (result) {
} is Session.State.Failed<InstallFailure> -> when (val failure = result.failure) {
is InstallFailure.Aborted -> state = State.CAN_INSTALL
private val installBroadcastReceiver = object : BroadcastReceiver() { else -> {
override fun onReceive(context: Context?, intent: Intent?) { val msg = failure.message.orEmpty()
intent?.let { app.toast(app.getString(R.string.install_app_fail, msg))
val pmStatus = intent.getIntExtra(InstallService.EXTRA_INSTALL_STATUS, -999) installError = msg
val extra = state = State.FAILED
intent.getStringExtra(InstallService.EXTRA_INSTALL_STATUS_MESSAGE)!!
when(pmStatus) {
PackageInstaller.STATUS_SUCCESS -> {
app.toast(app.getString(R.string.install_app_success))
state = State.SUCCESS
}
PackageInstaller.STATUS_FAILURE_ABORTED -> {
state = State.CAN_INSTALL
}
else -> {
app.toast(app.getString(R.string.install_app_fail, extra))
installError = extra
state = State.FAILED
}
} }
} }
Session.State.Succeeded -> {
app.toast(app.getString(R.string.install_app_success))
state = State.SUCCESS
}
} }
} }
init {
ContextCompat.registerReceiver(app, installBroadcastReceiver, IntentFilter().apply {
addAction(InstallService.APP_INSTALL_ACTION)
}, ContextCompat.RECEIVER_NOT_EXPORTED)
}
override fun onCleared() { override fun onCleared() {
super.onCleared() super.onCleared()
app.unregisterReceiver(installBroadcastReceiver)
job.cancel()
location.delete() location.delete()
} }
enum class State(@StringRes val title: Int) { enum class State(@param:StringRes val title: Int) {
CAN_DOWNLOAD(R.string.update_available), CAN_DOWNLOAD(R.string.update_available),
DOWNLOADING(R.string.downloading_manager_update), DOWNLOADING(R.string.downloading_manager_update),
CAN_INSTALL(R.string.ready_to_install_update), CAN_INSTALL(R.string.ready_to_install_update),

View File

@@ -0,0 +1,30 @@
package app.revanced.manager.util
import android.annotation.SuppressLint
import android.content.pm.PackageInstaller
import ru.solrudev.ackpine.installer.InstallFailure
import ru.solrudev.ackpine.uninstaller.UninstallFailure
/**
* Converts an Ackpine installation failure into a PM status code
*/
fun InstallFailure.asCode() = when (this) {
is InstallFailure.Aborted -> PackageInstaller.STATUS_FAILURE_ABORTED
is InstallFailure.Blocked -> PackageInstaller.STATUS_FAILURE_BLOCKED
is InstallFailure.Conflict -> PackageInstaller.STATUS_FAILURE_CONFLICT
is InstallFailure.Incompatible -> PackageInstaller.STATUS_FAILURE_INCOMPATIBLE
is InstallFailure.Invalid -> PackageInstaller.STATUS_FAILURE_INVALID
is InstallFailure.Storage -> PackageInstaller.STATUS_FAILURE_STORAGE
is InstallFailure.Timeout -> @SuppressLint("InlinedApi") PackageInstaller.STATUS_FAILURE_TIMEOUT
else -> PackageInstaller.STATUS_FAILURE
}
/**
* Converts an Ackpine uninstallation failure into a PM status code
*/
fun UninstallFailure.asCode() = when (this) {
is UninstallFailure.Aborted -> PackageInstaller.STATUS_FAILURE_ABORTED
is UninstallFailure.Blocked -> PackageInstaller.STATUS_FAILURE_BLOCKED
is UninstallFailure.Conflict -> PackageInstaller.STATUS_FAILURE_CONFLICT
else -> PackageInstaller.STATUS_FAILURE
}

View File

@@ -2,11 +2,8 @@ package app.revanced.manager.util
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Application import android.app.Application
import android.app.PendingIntent
import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageInfo import android.content.pm.PackageInfo
import android.content.pm.PackageInstaller
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.pm.PackageManager.PackageInfoFlags import android.content.pm.PackageManager.PackageInfoFlags
import android.content.pm.PackageManager.NameNotFoundException import android.content.pm.PackageManager.NameNotFoundException
@@ -16,8 +13,6 @@ import android.os.Build
import android.os.Parcelable import android.os.Parcelable
import androidx.compose.runtime.Immutable import androidx.compose.runtime.Immutable
import app.revanced.manager.domain.repository.PatchBundleRepository import app.revanced.manager.domain.repository.PatchBundleRepository
import app.revanced.manager.service.InstallService
import app.revanced.manager.service.UninstallService
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
@@ -25,10 +20,13 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import ru.solrudev.ackpine.session.await
import ru.solrudev.ackpine.session.parameters.Confirmation
import ru.solrudev.ackpine.uninstaller.PackageUninstaller
import ru.solrudev.ackpine.uninstaller.createSession
import ru.solrudev.ackpine.uninstaller.parameters.UninstallParametersDsl
import java.io.File import java.io.File
private const val byteArraySize = 1024 * 1024 // Because 1,048,576 is not readable
@Immutable @Immutable
@Parcelize @Parcelize
data class AppInfo( data class AppInfo(
@@ -40,7 +38,8 @@ data class AppInfo(
@SuppressLint("QueryPermissionsNeeded") @SuppressLint("QueryPermissionsNeeded")
class PM( class PM(
private val app: Application, private val app: Application,
patchBundleRepository: PatchBundleRepository patchBundleRepository: PatchBundleRepository,
private val uninstaller: PackageUninstaller
) { ) {
private val scope = CoroutineScope(Dispatchers.IO) private val scope = CoroutineScope(Dispatchers.IO)
@@ -145,17 +144,11 @@ class PM(
false false
) )
suspend fun installApp(apks: List<File>) = withContext(Dispatchers.IO) { suspend fun uninstallPackage(pkg: String, config: UninstallParametersDsl.() -> Unit = {}) = withContext(Dispatchers.IO) {
val packageInstaller = app.packageManager.packageInstaller uninstaller.createSession(pkg) {
packageInstaller.openSession(packageInstaller.createSession(sessionParams)).use { session -> confirmation = Confirmation.IMMEDIATE
apks.forEach { apk -> session.writeApk(apk) } config()
session.commit(app.installIntentSender) }.await()
}
}
fun uninstallPackage(pkg: String) {
val packageInstaller = app.packageManager.packageInstaller
packageInstaller.uninstall(pkg, app.uninstallIntentSender)
} }
fun launch(pkg: String) = app.packageManager.getLaunchIntentForPackage(pkg)?.let { fun launch(pkg: String) = app.packageManager.getLaunchIntentForPackage(pkg)?.let {
@@ -164,44 +157,4 @@ class PM(
} }
fun canInstallPackages() = app.packageManager.canRequestPackageInstalls() fun canInstallPackages() = app.packageManager.canRequestPackageInstalls()
private fun PackageInstaller.Session.writeApk(apk: File) {
apk.inputStream().use { inputStream ->
openWrite(apk.name, 0, apk.length()).use { outputStream ->
inputStream.copyTo(outputStream, byteArraySize)
fsync(outputStream)
}
}
}
private val intentFlags
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
PendingIntent.FLAG_MUTABLE
else
0
private val sessionParams
get() = PackageInstaller.SessionParams(
PackageInstaller.SessionParams.MODE_FULL_INSTALL
).apply {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
setRequestUpdateOwnership(true)
setInstallReason(PackageManager.INSTALL_REASON_USER)
}
private val Context.installIntentSender
get() = PendingIntent.getService(
this,
0,
Intent(this, InstallService::class.java),
intentFlags
).intentSender
private val Context.uninstallIntentSender
get() = PendingIntent.getService(
this,
0,
Intent(this, UninstallService::class.java),
intentFlags
).intentSender
} }

View File

@@ -33,6 +33,7 @@ import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle import androidx.lifecycle.repeatOnLifecycle
import app.revanced.manager.R import app.revanced.manager.R
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@@ -82,6 +83,8 @@ fun Context.toast(string: String, duration: Int = Toast.LENGTH_SHORT) {
inline fun uiSafe(context: Context, @StringRes toastMsg: Int, logMsg: String, block: () -> Unit) { inline fun uiSafe(context: Context, @StringRes toastMsg: Int, logMsg: String, block: () -> Unit) {
try { try {
block() block()
} catch (e: CancellationException) {
throw e
} catch (error: Exception) { } catch (error: Exception) {
// You can only toast on the main thread. // You can only toast on the main thread.
GlobalScope.launch(Dispatchers.Main) { GlobalScope.launch(Dispatchers.Main) {

View File

@@ -5,8 +5,8 @@
<item quantity="other">%d patches</item> <item quantity="other">%d patches</item>
</plurals> </plurals>
<plurals name="patches_executed"> <plurals name="patches_executed">
<item quantity="one">Executed %d patch</item> <item quantity="one">Execute %d patch</item>
<item quantity="other">Executed %d patches</item> <item quantity="other">Execute %d patches</item>
</plurals> </plurals>
<plurals name="selected_count"> <plurals name="selected_count">
<item quantity="other">%d selected</item> <item quantity="other">%d selected</item>

View File

@@ -1,3 +1,17 @@
<!--
Strings with new lines must be raw strings, where the string is wrapped in double quotes and new lines are regular line breaks and not \n
Raw strings still require escaping embedded double quotes, but single quote characters can be escaped or used as-is.
Raw strings are required because Crowdin AI translations regularly gets confused and
replace \n with an encoded new line character.
Bad:
<string name="summary_key">First \'item\' text\nSecond \"item\" text</string>
Good:
<string name="summary_key">"First 'item' text
Second \"item\" text"</string>
-->
<resources> <resources>
<string name="app_name">ReVanced Manager</string> <string name="app_name">ReVanced Manager</string>
<string name="patcher">Patcher</string> <string name="patcher">Patcher</string>
@@ -55,7 +69,7 @@
<string name="network_metered_warning">You are currently on a metered connection. Data charges from your service provider may apply.</string> <string name="network_metered_warning">You are currently on a metered connection. Data charges from your service provider may apply.</string>
<string name="apk_source_selector_item">Select APK source</string> <string name="apk_source_selector_item">Select APK source</string>
<string name="apk_source_auto">Using all APK downloader</string> <string name="apk_source_auto">Using all APK downloaders</string>
<string name="apk_source_downloader">Using %s</string> <string name="apk_source_downloader">Using %s</string>
<string name="apk_source_installed">Using installed APK</string> <string name="apk_source_installed">Using installed APK</string>
<string name="apk_source_local">Using a local APK file</string> <string name="apk_source_local">Using a local APK file</string>
@@ -86,21 +100,31 @@
<string name="contributors_description">View the contributors of ReVanced</string> <string name="contributors_description">View the contributors of ReVanced</string>
<string name="dynamic_color">Dynamic color</string> <string name="dynamic_color">Dynamic color</string>
<string name="dynamic_color_description">Adapt colors to the wallpaper</string> <string name="dynamic_color_description">Adapt colors to the wallpaper</string>
<string name="pure_black_theme">Pure black theme</string>
<string name="pure_black_theme_description">Use pure black backgrounds for dark theme</string>
<string name="theme">Theme</string> <string name="theme">Theme</string>
<string name="theme_description">Choose between light or dark theme</string> <string name="theme_description">Choose between light or dark theme</string>
<string name="safeguards">Safeguards</string> <string name="safeguards">Safeguards</string>
<string name="patch_compat_check">Disable version compatibility check</string> <string name="patch_compat_check">Disable version compatibility check</string>
<string name="patch_compat_check_description">The check restricts patches to compatible app versions</string> <string name="patch_compat_check_description">Do not restrict patches to compatible app versions</string>
<string name="patch_compat_check_confirmation">Selecting incompatible patches can result in a broken app.\n\nDo you want to proceed anyways?</string> <string name="patch_compat_check_confirmation">"Selecting incompatible patches can result in a broken app.
Do you want to proceed anyways?"</string>
<string name="suggested_version_safeguard">Require suggested app version</string> <string name="suggested_version_safeguard">Require suggested app version</string>
<string name="suggested_version_safeguard_description">Enforce selection of the suggested app version</string> <string name="suggested_version_safeguard_description">Enforce selection of the suggested app version</string>
<string name="suggested_version_safeguard_confirmation">Selecting an app that is not the suggested version may cause unexpected issues.\n\nDo you want to proceed anyways?</string> <string name="suggested_version_safeguard_confirmation">"Selecting an app that is not the suggested version may cause unexpected issues.
Do you want to proceed anyways?"</string>
<string name="patch_selection_safeguard">Allow changing patch selection and options</string> <string name="patch_selection_safeguard">Allow changing patch selection and options</string>
<string name="patch_selection_safeguard_description">Do not prevent selecting or deselecting patches and customization of options</string> <string name="patch_selection_safeguard_description">Do not prevent selecting or deselecting patches and customization of options</string>
<string name="patch_selection_safeguard_confirmation">Changing the selection of patches may cause unexpected issues.\n\nEnable anyways?</string> <string name="patch_selection_safeguard_confirmation">"Changing the selection of patches may cause unexpected issues.
Enable anyways?"</string>
<string name="universal_patches_safeguard">Allow using universal patches</string> <string name="universal_patches_safeguard">Allow using universal patches</string>
<string name="universal_patches_safeguard_description">Do not prevent using universal patches</string> <string name="universal_patches_safeguard_description">Do not prevent using universal patches</string>
<string name="universal_patches_safeguard_confirmation">Universal patches are not as well tested as those that target specific apps.\n\nEnable anyways?</string> <string name="universal_patches_safeguard_confirmation">"Universal patches are not as well tested as those that target specific apps.
Enable anyways?"</string>
<string name="import_keystore">Import keystore</string> <string name="import_keystore">Import keystore</string>
<string name="import_keystore_description">Import a custom keystore</string> <string name="import_keystore_description">Import a custom keystore</string>
<string name="import_keystore_dialog_title">Enter keystore credentials</string> <string name="import_keystore_dialog_title">Enter keystore credentials</string>
@@ -116,7 +140,9 @@
<string name="export_keystore_success">Exported keystore</string> <string name="export_keystore_success">Exported keystore</string>
<string name="regenerate_keystore">Regenerate keystore</string> <string name="regenerate_keystore">Regenerate keystore</string>
<string name="regenerate_keystore_description">Generate a new keystore</string> <string name="regenerate_keystore_description">Generate a new keystore</string>
<string name="regenerate_keystore_dialog_description">You are about to regenerate your keystore the manager will use during the patching process.\n\nYou will not be able to update the previously installed apps from this source.</string> <string name="regenerate_keystore_dialog_description">"You are about to regenerate your keystore the manager will use during the patching process.
You will not be able to update the previously installed apps from this source."</string>
<string name="regenerate_keystore_success">The keystore has been successfully replaced</string> <string name="regenerate_keystore_success">The keystore has been successfully replaced</string>
<string name="import_patch_selection">Import patch selection</string> <string name="import_patch_selection">Import patch selection</string>
<string name="import_patch_selection_description">Import patch selection from a JSON file</string> <string name="import_patch_selection_description">Import patch selection from a JSON file</string>
@@ -132,8 +158,8 @@
<string name="reset_patch_options_description">Reset the stored patch options</string> <string name="reset_patch_options_description">Reset the stored patch options</string>
<string name="reset_patch_selection_success">Patch selection has been reset</string> <string name="reset_patch_selection_success">Patch selection has been reset</string>
<string name="patch_selection_reset_all">Reset patch selection globally</string> <string name="patch_selection_reset_all">Reset patch selection globally</string>
<string name="patch_selection_reset_all_dialog_description">You are about to reset all the patch selections. You will need to manually select each patch again.</string> <string name="patch_selection_reset_all_dialog_description">You are about to reset all patch selections. You will need to manually select each patch again.</string>
<string name="patch_selection_reset_all_description">Resets all the patch selections</string> <string name="patch_selection_reset_all_description">Resets all patch selections</string>
<string name="patch_selection_reset_package">Reset patch selection for app</string> <string name="patch_selection_reset_package">Reset patch selection for app</string>
<string name="patch_selection_reset_package_dialog_description">You are about to reset the patch selection for the app \"%s\". You will have to manually select each patch again.</string> <string name="patch_selection_reset_package_dialog_description">You are about to reset the patch selection for the app \"%s\". You will have to manually select each patch again.</string>
<string name="patch_selection_reset_package_description">Resets patch selection for a single app</string> <string name="patch_selection_reset_package_description">Resets patch selection for a single app</string>
@@ -147,7 +173,7 @@
<string name="patch_options_reset_patches_dialog_description">You are about to reset the patch options for \"%s\". You will have to reapply each option again.</string> <string name="patch_options_reset_patches_dialog_description">You are about to reset the patch options for \"%s\". You will have to reapply each option again.</string>
<string name="patch_options_reset_patches_description">Resets the patch options for a specific collection of patches</string> <string name="patch_options_reset_patches_description">Resets the patch options for a specific collection of patches</string>
<string name="patch_options_reset_all">Reset patch options globally</string> <string name="patch_options_reset_all">Reset patch options globally</string>
<string name="patch_options_reset_all_dialog_description">You are about to reset patch options. You will have to reapply each option again.</string> <string name="patch_options_reset_all_dialog_description">You are about to reset all patch options. You will have to reapply each option again.</string>
<string name="patch_options_reset_all_description">Resets all patch options</string> <string name="patch_options_reset_all_description">Resets all patch options</string>
<string name="downloader_plugins">Plugins</string> <string name="downloader_plugins">Plugins</string>
<string name="downloader_plugin_state_trusted">Trusted</string> <string name="downloader_plugin_state_trusted">Trusted</string>
@@ -155,10 +181,12 @@
<string name="downloader_plugin_state_untrusted">Untrusted</string> <string name="downloader_plugin_state_untrusted">Untrusted</string>
<string name="downloader_plugin_trust_dialog_title">Trust plugin?</string> <string name="downloader_plugin_trust_dialog_title">Trust plugin?</string>
<string name="downloader_plugin_revoke_trust_dialog_title">Revoke trust?</string> <string name="downloader_plugin_revoke_trust_dialog_title">Revoke trust?</string>
<string name="downloader_plugin_trust_dialog_body">Package name: %1$s\nSignature (SHA-256): %2$s</string> <string name="downloader_plugin_trust_dialog_body">Continuing will allow this plugin to run on your system.\n\nOnly enable this plugin if you trust it. Plugins can execute arbitrary code and may compromise your device.</string>
<string name="downloader_plugin_trust_dialog_signature">Signature:\n\n%s</string>
<string name="downloader_plugin_trust_dialog_plugin">Plugin:\n%s</string>
<string name="downloader_plugin_delete_apps_title">Delete selected apps</string> <string name="downloader_plugin_delete_apps_title">Delete selected apps</string>
<string name="downloader_plugin_delete_apps_description">Are you sure you want to delete the selected apps?</string> <string name="downloader_plugin_delete_apps_description">Are you sure you want to delete the selected apps?</string>
<string name="downloader_settings_no_apps">No downloaded apps found</string> <string name="downloader_settings_no_apps">No downloaded apps found.</string>
<string name="search_apps">Search apps…</string> <string name="search_apps">Search apps…</string>
<string name="loading_body">Loading…</string> <string name="loading_body">Loading…</string>
@@ -191,7 +219,7 @@
<string name="appearance">Appearance</string> <string name="appearance">Appearance</string>
<string name="downloaded_apps">Downloaded apps</string> <string name="downloaded_apps">Downloaded apps</string>
<string name="process_runtime">Run Patcher in another process (experimental)</string> <string name="process_runtime">Run Patcher in another process (experimental)</string>
<string name="process_runtime_description">This is faster and allows Patcher to use more memory.</string> <string name="process_runtime_description">This is faster and allows Patcher to use more memory</string>
<string name="process_runtime_memory_limit">Patcher process memory limit</string> <string name="process_runtime_memory_limit">Patcher process memory limit</string>
<string name="process_runtime_memory_limit_description">The max amount of memory that the Patcher process can use (in megabytes)</string> <string name="process_runtime_memory_limit_description">The max amount of memory that the Patcher process can use (in megabytes)</string>
<string name="debug_logs_export">Export debug logs</string> <string name="debug_logs_export">Export debug logs</string>
@@ -199,7 +227,7 @@
<string name="debug_logs_export_failed">Failed to export logs</string> <string name="debug_logs_export_failed">Failed to export logs</string>
<string name="debug_logs_export_success">Exported logs</string> <string name="debug_logs_export_success">Exported logs</string>
<string name="api_url">API URL</string> <string name="api_url">API URL</string>
<string name="api_url_description">The API used to download necessary files.</string> <string name="api_url_description">The API used to download necessary files</string>
<string name="api_url_dialog_title">Change API URL</string> <string name="api_url_dialog_title">Change API URL</string>
<string name="api_url_dialog_description">Change the API URL of ReVanced Manager. ReVanced Manager uses the API to download patches and updates.</string> <string name="api_url_dialog_description">Change the API URL of ReVanced Manager. ReVanced Manager uses the API to download patches and updates.</string>
<string name="api_url_dialog_warning">ReVanced Manager connects to the API to download patches and updates. Make sure that you trust it.</string> <string name="api_url_dialog_warning">ReVanced Manager connects to the API to download patches and updates. Make sure that you trust it.</string>
@@ -235,14 +263,23 @@
<string name="patch_selection_reset_toast">Patch selection and options has been reset to recommended defaults</string> <string name="patch_selection_reset_toast">Patch selection and options has been reset to recommended defaults</string>
<string name="patch_options_reset_toast">Patch options have been reset</string> <string name="patch_options_reset_toast">Patch options have been reset</string>
<string name="non_suggested_version_warning_title">Non suggested version</string> <string name="non_suggested_version_warning_title">Non suggested version</string>
<string name="non_suggested_version_warning_description">The version of the app you have selected does not match the suggested version.\nPlease use the suggested version: %s\n\nTo continue anyway, disable \"Require suggested app version\" in the advanced settings.</string> <string name="non_suggested_version_warning_description">"The version of the app you have selected does not match the suggested version.
Please use the suggested version: %s
To continue anyway, disable \"Require suggested app version\" in the advanced settings."</string>
<string name="selection_warning_title">Stop using defaults?</string> <string name="selection_warning_title">Stop using defaults?</string>
<string name="selection_warning_description">It is recommended to use the default patch selection and options. Changing them may result in unexpected issues.\n\nYou need to turn on \"Allow changing patch selection\" in the advanced settings before toggling patches.</string> <string name="selection_warning_description">"It is recommended to use the default patch selection and options. Changing them may result in unexpected issues.
<string name="universal_patch_warning_description">Universal patches have a more generalized use and do not work as reliably as patches that target specific apps. You may encounter issues while using them.\n\nYou need to turn on \"Allow using universal patches\" in the advanced settings before using universal patches.</string>
You need to turn on \"Allow changing patch selection and options\" in the advanced settings before toggling patches."</string>
<string name="universal_patch_warning_description">"Universal patches have a more generalized use and do not work as reliably as patches that target specific apps. You may encounter issues while using them.
You need to turn on \"Allow using universal patches\" in the advanced settings before using universal patches."</string>
<string name="this_version">This version</string> <string name="this_version">This version</string>
<string name="universal">Any app</string> <string name="universal">Any app</string>
<string name="search_patches">Search patches</string> <string name="search_patches">Search patches</string>
<string name="app_version_not_compatible">This patch is not compatible with the selected app version (%1$s).\n\nIt is only compatible with the following version(s): %2$s.</string> <string name="app_version_not_compatible">"This patch is not compatible with the selected app version (%1$s)
It is only compatible with the following version(s): %2$s"</string>
<string name="continue_with_version">Continue with this version?</string> <string name="continue_with_version">Continue with this version?</string>
<string name="version_not_compatible">Not all patches are compatible with this version (%s). Do you want to continue anyway?</string> <string name="version_not_compatible">Not all patches are compatible with this version (%s). Do you want to continue anyway?</string>
<string name="download_application">Download application?</string> <string name="download_application">Download application?</string>
@@ -276,7 +313,7 @@
<string name="downloader_app_not_found">Downloader did not find the app</string> <string name="downloader_app_not_found">Downloader did not find the app</string>
<string name="downloader_error">Downloader error: %s</string> <string name="downloader_error">Downloader error: %s</string>
<string name="downloader_no_plugins_installed">No downloader installed.</string> <string name="downloader_no_plugins_installed">No downloader installed.</string>
<string name="downloader_no_plugins_available">There are downloader installed but none is trusted. Check your settings.</string> <string name="downloader_no_plugins_available">There are downloaders installed but none are trusted. Check your settings.</string>
<string name="already_patched">Already patched</string> <string name="already_patched">Already patched</string>
<string name="patch_selector_sheet_filter_title">Filter</string> <string name="patch_selector_sheet_filter_title">Filter</string>
@@ -318,6 +355,7 @@
<string name="patcher_notification_text">Tap to return to the patcher</string> <string name="patcher_notification_text">Tap to return to the patcher</string>
<string name="patcher_stop_confirm_title">Stop patcher</string> <string name="patcher_stop_confirm_title">Stop patcher</string>
<string name="patcher_stop_confirm_description">Are you sure you want to stop the patching process?</string> <string name="patcher_stop_confirm_description">Are you sure you want to stop the patching process?</string>
<string name="patcher_install_in_progress">Installation is in progress. Please wait</string>
<string name="execute_patches">Execute patches</string> <string name="execute_patches">Execute patches</string>
<string name="executing_patch">Execute %s</string> <string name="executing_patch">Execute %s</string>
<string name="failed_to_execute_patch">Failed to execute %s</string> <string name="failed_to_execute_patch">Failed to execute %s</string>
@@ -383,7 +421,8 @@
<string name="save_with_count">Save (%1$s)</string> <string name="save_with_count">Save (%1$s)</string>
<string name="update">Update</string> <string name="update">Update</string>
<string name="empty">Empty</string> <string name="empty">Empty</string>
<string name="installing_message">Tap on <b>Update</b> when prompted.\nReVanced Manager will close when updating.</string> <string name="installing_message">"Tap on <b>Update</b> when prompted.
ReVanced Manager will close when updating."</string>
<string name="no_changelogs_found">No changelogs found</string> <string name="no_changelogs_found">No changelogs found</string>
<string name="just_now">Just now</string> <string name="just_now">Just now</string>
<string name="minutes_ago">%sm ago</string> <string name="minutes_ago">%sm ago</string>
@@ -402,7 +441,9 @@
<string name="update_available_dialog_description">A new version of ReVanced Manager (%s) is available.</string> <string name="update_available_dialog_description">A new version of ReVanced Manager (%s) is available.</string>
<string name="failed_to_download_update">Failed to download update: %s</string> <string name="failed_to_download_update">Failed to download update: %s</string>
<string name="download">Download</string> <string name="download">Download</string>
<string name="download_confirmation_metered">You are currently on a metered connection, and data charges from your service provider may apply.\n\nDo you still want to continue?</string> <string name="download_confirmation_metered">"You are currently on a metered connection, and data charges from your service provider may apply.
Do you still want to continue?"</string>
<string name="download_update_confirmation">Download update?</string> <string name="download_update_confirmation">Download update?</string>
<string name="no_contributors_found">No contributors found</string> <string name="no_contributors_found">No contributors found</string>
<string name="select">Select</string> <string name="select">Select</string>
@@ -438,14 +479,16 @@
<string name="add_patches">Add patches</string> <string name="add_patches">Add patches</string>
<string name="auto_update_description">Automatically update when a new version is available</string> <string name="auto_update_description">Automatically update when a new version is available</string>
<string name="patches_prereleases">Use pre-releases</string> <string name="patches_prereleases">Use pre-releases</string>
<string name="patches_prereleases_description">Use pre-release version of %s</string> <string name="patches_prereleases_description">Use pre-release versions of %s</string>
<string name="patches_url">Patches URL</string> <string name="patches_url">Patches URL</string>
<string name="incompatible_patches_dialog">These patches are not compatible with the selected app version (%1$s).\n\nClick on the patches to see more details.</string> <string name="incompatible_patches_dialog">"These patches are not compatible with the selected app version (%1$s).
Click on the patches to see more details."</string>
<string name="incompatible_patch">Incompatible patch</string> <string name="incompatible_patch">Incompatible patch</string>
<string name="any_version">Any</string> <string name="any_version">Any</string>
<string name="never_show_again">Never show again</string> <string name="never_show_again">Never show again</string>
<string name="show_manager_update_dialog_on_launch">Show update message on launch</string> <string name="show_manager_update_dialog_on_launch">Show update message on launch</string>
<string name="show_manager_update_dialog_on_launch_description">Shows a popup notification whenever there is a new update available on launch.</string> <string name="show_manager_update_dialog_on_launch_description">Show a popup notification whenever a new update is available on launch</string>
<string name="failed_to_import_keystore">Failed to import keystore</string> <string name="failed_to_import_keystore">Failed to import keystore</string>
<string name="export">Export</string> <string name="export">Export</string>
<string name="confirm">Confirm</string> <string name="confirm">Confirm</string>

View File

@@ -13,9 +13,9 @@ Learn how to use ReVanced Manager to patch apps.
7. Tap on the `Install` button to install the patched app[^4] 7. Tap on the `Install` button to install the patched app[^4]
[^1]: Here you can see all the apps that are supported by ReVanced. [^1]: Here you can see all the apps that are supported by ReVanced.
You can also add custom apps by tapping on the `+` button in the top right corner. You can also add custom apps by tapping on the `Select from storage` button at the top.
[^2]: It is recommended to use the default set of patches by tapping on the `Reset` button in the bottom right corner. [^2]: It is recommended to use the default set of patches by tapping on the `Reset` button in the bottom right corner.
[^3]: By default, all available downloader will be used to download the app. [^3]: By default, all available downloaders will be used to download the app.
If you want to use a specific downloader, you can change it here. If you want to use a specific downloader, you can change it here.
[^4]: You can export the patched app or the patch logs in the bottom left corner. [^4]: You can export the patched app or the patch logs in the bottom left corner.

View File

@@ -3,7 +3,7 @@
Learn how to manage downloaders. Learn how to manage downloaders.
Refer to the [template](https://github.com/ReVanced/revanced-manager-downloader-template) if you are developer who wants to create a plugin. Refer to the [template](https://github.com/ReVanced/revanced-manager-downloader-template) if you are developer who wants to create a plugin.
Downloaders are Apk files and are installed, updated and uninstalled just like regular Android apps. Downloaders are APK files and are installed, updated and uninstalled just like regular Android apps.
Downloaders can execute arbitrary code inside ReVanced Manager and must be marked as trusted before use. Manager will show a notification in the dashboard when a new downloader is discovered. Downloaders can execute arbitrary code inside ReVanced Manager and must be marked as trusted before use. Manager will show a notification in the dashboard when a new downloader is discovered.
Trust can also be granted and revoked under `Settings` > `Downloads`. Trust can also be granted and revoked under `Settings` > `Downloads`.

View File

@@ -9,7 +9,7 @@ Learn how to update ReVanced Manager.
3. Configure the update settings accordingly[^1] 3. Configure the update settings accordingly[^1]
[^1]: By default, ReVanced Manager will check for updates automatically on launch [^1]: By default, ReVanced Manager will check for updates automatically on launch
and let you when an update is available. and let you know when an update is available.
## ⏭️ What's next ## ⏭️ What's next

View File

@@ -4,29 +4,29 @@ Learn how to configure ReVanced Manager.
## 🔧 Settings ## 🔧 Settings
- **Import & export**: Import or export patch selections, patch options and the signing keystore
- **Downloads**: Enable or disable ReVanced Manager downloader and manage past downloaded apps here - **Downloads**: Enable or disable ReVanced Manager downloader and manage past downloaded apps here
- **Import & export**: Import or export patch selections, patch options and the signing keystore
- **Advanced**: - **Advanced**:
- **API URL**: Set the URL of the ReVanced API, ReVanced Manager will use - **API URL**: Set the URL of the ReVanced API, ReVanced Manager will use
- **Disable version compatibility check**: Patching versions of apps the patches are explicitly compatible with is enforced. - **Disable version compatibility check**: Patching versions of apps the patches are explicitly compatible with is enforced.
Disabling this will allow patching versions of apps the patches are not explicitly compatible with Disabling this will allow patching versions of apps the patches are not explicitly compatible with
> ⚠️ Warning > ⚠️ Warning
> Patches may fail patching versions they are not explicitly compatible with. > Patches may fail on app versions they are not explicitly compatible with.
> Unless you know what you are doing, it is recommended to keep this enabled.
- **Allow changing patch selection**: The default selection of patches is enforced.
Enabling this will allow you to change the patch selection
> ⚠️ Warning
> Changing the selection may cause unexpected issues.
> Unless you know what you are doing, it is recommended to keep this disabled. > Unless you know what you are doing, it is recommended to keep this disabled.
- **Require suggested app version**: Specific versions of apps is enforced based on the patch selection automatically. - **Require suggested app version**: Specific versions of apps is enforced based on the patch selection automatically.
Disabling this will allow you to patch any version of apps Disabling this will allow you to patch any version of apps
> ⚠️ Warning > ⚠️ Warning
> Patches not compatible with the selected version of the app will not be used. > Patches not compatible with the selected version of the app will not be used.
> Unless you know what you are doing, it is recommended to keep this enabled. > Unless you know what you are doing, it is recommended to keep this enabled.
- **Allow universal patches**: Patches that do not specify compatibility with an app explicitly are forcibly disabled. - **Allow changing patch selection and options**: The default selection of patches is enforced.
Enabling this will allow you to change the patch selection
> ⚠️ Warning
> Changing the selection may cause unexpected issues.
> Unless you know what you are doing, it is recommended to keep this disabled.
- **Allow using universal patches**: Patches that do not specify compatibility with an app are forcibly disabled.
Enabling this will allow selecting such patches Enabling this will allow selecting such patches
> ⚠️ Warning > ⚠️ Warning
> Universal patches do not specify compatibility with an app explicitly may not work on all apps regardless. > Universal patches do not specify compatibility with an app and may not work on all apps regardless.
> Unless you know what you are doing, it is recommended to keep this disabled. > Unless you know what you are doing, it is recommended to keep this disabled.
- **About**: View more information and links about ReVanced and ReVanced Manager. - **About**: View more information and links about ReVanced and ReVanced Manager.

View File

@@ -37,6 +37,7 @@ kotlin-process = "1.5.1"
hidden-api-stub = "4.3.3" hidden-api-stub = "4.3.3"
binary-compatibility-validator = "0.17.0" binary-compatibility-validator = "0.17.0"
semver-parser = "3.0.0" semver-parser = "3.0.0"
ackpine = "0.18.5"
[libraries] [libraries]
# AndroidX Core # AndroidX Core
@@ -133,6 +134,10 @@ compose-icons-fontawesome = { group = "com.github.BenjaminHalko.compose-icons",
# Semantic versioning parser # Semantic versioning parser
semver-parser = { module = "io.github.z4kn4fein:semver", version.ref = "semver-parser" } semver-parser = { module = "io.github.z4kn4fein:semver", version.ref = "semver-parser" }
# Ackpine
ackpine-core = { module = "ru.solrudev.ackpine:ackpine-core", version.ref = "ackpine" }
ackpine-ktx = { module = "ru.solrudev.ackpine:ackpine-ktx", version.ref = "ackpine" }
[plugins] [plugins]
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" } android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" } android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }