Skip to content

Commit 9a31d6d

Browse files
committed
feat: add button for info about obtaining patched APK
1 parent 113e06d commit 9a31d6d

File tree

11 files changed

+80
-56
lines changed

11 files changed

+80
-56
lines changed

INFO.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Obtaining Patched APKs
2+
3+
Unfortunately, starting with Android 10, file managers cannot access external data of other apps without root.
4+
You will have to manually download the patched APK via `adb`.
5+
6+
ADB command (assuming the first user profile):
7+
8+
```shell
9+
$ adb pull /storage/emulated/0/Android/data/com.aliucord.manager/cache/patched/patched.apk
10+
```
11+
12+
This file should only be used after the patching process has successfully completed.
13+
If the process failed at any step before "Installing", then the APK will be unusable.
14+
15+
The patched APK **should not be reused on another device**. Refer to the section [below](#backing-up-aliucord)
16+
for more information.
17+
18+
## Backing up Aliucord
19+
20+
Note: This section is about the app installation itself, not the installed plugins, themes, and settings.
21+
22+
The patched Aliucord APK is tailored to the current device's Android version and CPU architecture.
23+
Reusing a patched Aliucord APK from one device on another will likely break. Backing up and
24+
restoring on another device will likely break.
25+
26+
Install Aliucord **directly via Manager** on the device you wish to use it on.

app/src/main/AndroidManifest.xml

-10
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@
3333
android:name=".installers.pm.PMIntentReceiver"
3434
android:exported="false" />
3535

36-
<provider
37-
android:name="androidx.core.content.FileProvider"
38-
android:authorities="${applicationId}.provider"
39-
android:exported="false"
40-
android:grantUriPermissions="true">
41-
<meta-data
42-
android:name="android.support.FILE_PROVIDER_PATHS"
43-
android:resource="@xml/provider_paths" />
44-
</provider>
45-
4636
<activity
4737
android:name=".MainActivity"
4838
android:exported="true"

app/src/main/kotlin/com/aliucord/manager/network/service/AliucordGithubService.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ class AliucordGithubService(
2121
suspend fun getManagerReleases() = github.getReleases(ORG, MANAGER_REPO)
2222
suspend fun getContributors() = github.getContributors(ORG, MAIN_REPO)
2323

24-
private companion object {
24+
companion object {
2525
const val ORG = "Aliucord"
2626
const val MAIN_REPO = "Aliucord"
2727
const val MANAGER_REPO = "Manager"
28+
29+
const val PATCHED_APKS_INFO_URL = "https://github.com/$ORG/$MANAGER_REPO/blob/main/INFO.md#obtaining-patched-apks"
2830
}
2931
}

app/src/main/kotlin/com/aliucord/manager/patcher/steps/patch/SmaliPatchStep.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class SmaliPatchStep : Step(), IDexProvider, KoinComponent {
9999
}
100100

101101
val patched = try {
102-
DiffUtils.patch(smaliFile.readText().split('\n'), patch)
102+
DiffUtils.patch(smaliFile.readLines(), patch)
103103
} catch (t: Throwable) {
104104
throw Error("Failed to smali patch $fullClassName", t)
105105
}

app/src/main/kotlin/com/aliucord/manager/ui/screens/patching/components/MainActionButton.kt app/src/main/kotlin/com/aliucord/manager/ui/components/MainActionButton.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.aliucord.manager.ui.screens.patching.components
1+
package com.aliucord.manager.ui.components
22

33
import androidx.compose.foundation.layout.*
44
import androidx.compose.material3.*

app/src/main/kotlin/com/aliucord/manager/ui/components/settings/SettingsSwitch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ fun SettingsSwitch(
1414
icon: @Composable () -> Unit = {},
1515
pref: Boolean,
1616
onPrefChange: (Boolean) -> Unit,
17+
modifier: Modifier = Modifier,
1718
) {
1819
SettingsItem(
19-
modifier = Modifier.clickable(enabled = !disabled) { onPrefChange(!pref) },
20+
modifier = modifier.clickable(enabled = !disabled) { onPrefChange(!pref) },
2021
text = { Text(text = label, softWrap = true) },
2122
icon = icon,
2223
secondaryText = {

app/src/main/kotlin/com/aliucord/manager/ui/screens/home/HomeScreen.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import androidx.compose.foundation.layout.*
1212
import androidx.compose.foundation.lazy.LazyColumn
1313
import androidx.compose.foundation.lazy.items
1414
import androidx.compose.material3.*
15-
import androidx.compose.runtime.*
15+
import androidx.compose.runtime.Composable
1616
import androidx.compose.ui.Alignment
1717
import androidx.compose.ui.Modifier
1818
import androidx.compose.ui.draw.alpha
19-
import androidx.compose.ui.graphics.*
2019
import androidx.compose.ui.res.stringResource
2120
import androidx.compose.ui.unit.dp
2221
import androidx.compose.ui.unit.sp
@@ -36,7 +35,6 @@ import com.aliucord.manager.ui.util.paddings.PaddingValuesSides
3635
import com.aliucord.manager.ui.util.paddings.exclude
3736
import kotlinx.parcelize.IgnoredOnParcel
3837
import kotlinx.parcelize.Parcelize
39-
import kotlin.math.*
4038

4139
@Parcelize
4240
class HomeScreen : Screen, Parcelable {

app/src/main/kotlin/com/aliucord/manager/ui/screens/patching/PatchingScreen.kt

+16-16
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,24 @@ class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
246246
icon = painterResource(R.drawable.ic_refresh),
247247
onClick = model::restart,
248248
)
249-
250-
MainActionButton(
251-
text = stringResource(R.string.setting_clear_cache),
252-
icon = painterResource(R.drawable.ic_delete_forever),
253-
enabled = !cacheCleared,
254-
colors = IconButtonDefaults.filledTonalIconButtonColors(
255-
containerColor = MaterialTheme.colorScheme.error,
256-
),
257-
onClick = {
258-
cacheCleared = true
259-
model.clearCache()
260-
},
261-
modifier = Modifier
262-
.padding(top = 14.dp)
263-
.fillMaxWidth()
264-
)
265249
}
266250
}
251+
252+
MainActionButton(
253+
text = stringResource(R.string.setting_clear_cache),
254+
icon = painterResource(R.drawable.ic_delete_forever),
255+
enabled = !cacheCleared,
256+
colors = IconButtonDefaults.filledTonalIconButtonColors(
257+
containerColor = MaterialTheme.colorScheme.error,
258+
),
259+
onClick = {
260+
cacheCleared = true
261+
model.clearCache()
262+
},
263+
modifier = Modifier
264+
.padding(top = 14.dp)
265+
.fillMaxWidth()
266+
)
267267
}
268268
}
269269
}

app/src/main/kotlin/com/aliucord/manager/ui/screens/settings/SettingsScreen.kt

+29-17
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ import androidx.compose.material3.*
1313
import androidx.compose.runtime.*
1414
import androidx.compose.runtime.saveable.rememberSaveable
1515
import androidx.compose.ui.Modifier
16+
import androidx.compose.ui.platform.LocalUriHandler
1617
import androidx.compose.ui.res.painterResource
1718
import androidx.compose.ui.res.stringResource
18-
import androidx.compose.ui.text.style.TextAlign
1919
import androidx.compose.ui.unit.dp
2020
import cafe.adriel.voyager.core.screen.Screen
2121
import cafe.adriel.voyager.koin.getScreenModel
2222
import com.aliucord.manager.R
23+
import com.aliucord.manager.network.service.AliucordGithubService
2324
import com.aliucord.manager.ui.components.BackButton
25+
import com.aliucord.manager.ui.components.MainActionButton
2426
import com.aliucord.manager.ui.components.settings.*
2527
import com.aliucord.manager.ui.screens.settings.components.ThemeDialog
2628
import kotlinx.parcelize.IgnoredOnParcel
@@ -34,6 +36,7 @@ class SettingsScreen : Screen, Parcelable {
3436
@Composable
3537
override fun Content() {
3638
val model = getScreenModel<SettingsModel>()
39+
var clearedCache by rememberSaveable { mutableStateOf(false) }
3740

3841
Scaffold(
3942
topBar = {
@@ -76,10 +79,9 @@ class SettingsScreen : Screen, Parcelable {
7679
label = stringResource(R.string.setting_dynamic_color),
7780
secondaryLabel = stringResource(R.string.setting_dynamic_color_desc),
7881
pref = preferences.dynamicColor,
79-
icon = { Icon(painterResource(R.drawable.ic_palette), null) }
80-
) {
81-
preferences.dynamicColor = it
82-
}
82+
icon = { Icon(painterResource(R.drawable.ic_palette), null) },
83+
onPrefChange = { preferences.dynamicColor = it },
84+
)
8385
}
8486

8587
SettingsHeader(stringResource(R.string.settings_advanced))
@@ -88,34 +90,44 @@ class SettingsScreen : Screen, Parcelable {
8890
label = stringResource(R.string.settings_developer_options),
8991
secondaryLabel = stringResource(R.string.settings_developer_options_desc),
9092
pref = preferences.devMode,
91-
icon = { Icon(painterResource(R.drawable.ic_code), null) }
92-
) {
93-
preferences.devMode = it
94-
}
93+
icon = { Icon(painterResource(R.drawable.ic_code), null) },
94+
onPrefChange = { preferences.devMode = it },
95+
)
9596

9697
SettingsSwitch(
9798
label = stringResource(R.string.setting_keep_patched_apks),
9899
secondaryLabel = stringResource(R.string.setting_keep_patched_apks_desc),
99100
icon = { Icon(painterResource(R.drawable.ic_delete_forever), null) },
100101
pref = preferences.keepPatchedApks,
101102
onPrefChange = model::setKeepPatchedApks,
103+
modifier = Modifier.padding(bottom = 18.dp),
102104
)
103105

104-
var clearedCache by rememberSaveable { mutableStateOf(false) }
105-
Button(
106-
shape = ShapeDefaults.Large,
106+
MainActionButton(
107+
text = stringResource(R.string.setting_clear_cache),
108+
icon = painterResource(R.drawable.ic_delete_forever),
107109
enabled = !clearedCache,
110+
colors = IconButtonDefaults.filledTonalIconButtonColors(
111+
containerColor = MaterialTheme.colorScheme.error,
112+
),
108113
onClick = {
109114
clearedCache = true
110115
model.clearCacheDir()
111116
},
112117
modifier = Modifier
118+
.padding(horizontal = 18.dp, vertical = 10.dp)
113119
.fillMaxWidth()
114-
.padding(18.dp),
115-
) {
116-
Text(
117-
text = stringResource(R.string.setting_clear_cache),
118-
textAlign = TextAlign.Center
120+
)
121+
122+
if (preferences.keepPatchedApks) {
123+
val handler = LocalUriHandler.current
124+
MainActionButton(
125+
text = stringResource(R.string.setting_see_patched_apks),
126+
icon = painterResource(R.drawable.ic_launch),
127+
onClick = { handler.openUri(AliucordGithubService.PATCHED_APKS_INFO_URL) },
128+
modifier = Modifier
129+
.padding(horizontal = 18.dp, vertical = 9.dp)
130+
.fillMaxWidth()
119131
)
120132
}
121133
}

app/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<string name="setting_keep_patched_apks">Keep patched APKs</string>
5151
<string name="setting_keep_patched_apks_desc">Keep all patched files and APKs after installing for debugging.</string>
5252
<string name="setting_keep_patched_apks_error">This device does not support external cache directories!</string>
53+
<string name="setting_see_patched_apks">See patched APKs</string>
5354

5455
<string name="theme_system">System</string>
5556
<string name="theme_dark">Dark</string>

app/src/main/res/xml/provider_paths.xml

-6
This file was deleted.

0 commit comments

Comments
 (0)