Compare commits

...

93 Commits

Author SHA1 Message Date
Ushie
a346f8857f build: Bump version to v0.0.26 2022-09-26 16:52:04 +03:00
oSumAtrIX
e12532ea4c chore: bump patcher dependency version to v5.1.0 2022-09-26 04:34:23 +02:00
afn
7ecf951bfb fix: tweak card appearances (#296)
* fix: tweak card appearances

* Update patch_selector_card.dart
2022-09-25 18:13:37 +05:30
Aunali321
db18874ea1 fix: now using country code for languages. 2022-09-25 14:38:25 +05:30
oSumAtrIX
18a69776cd feat: en_US.json language asset file 2022-09-25 08:26:08 +02:00
oSumAtrIX
21cadf6450 feat: remove en.json language asset 2022-09-25 08:22:21 +02:00
oSumAtrIX
5ddbe6e252 Update Crowdin configuration file 2022-09-25 08:19:47 +02:00
afn
6d1427e01e fix: move changelog into app item custom card (#294) 2022-09-25 00:19:02 +05:30
Alberto Ponces
6ac901f1d6 build: Bump version to v0.0.24 2022-09-24 13:50:44 +01:00
Alberto Ponces
587ba795bb Revert "fix: Prevent content from being overlapped by system navigation bar"
This reverts commit 4d82ff3011.
2022-09-24 13:49:46 +01:00
Alberto Ponces
6b66c7bbd0 build: Bump version to v0.0.23 2022-09-24 12:16:02 +01:00
Alberto Ponces
f398b6863a Merge branch 'flutter' of github.com:revanced/revanced-manager into flutter 2022-09-24 12:12:24 +01:00
Alberto Ponces
4d82ff3011 fix: Prevent content from being overlapped by system navigation bar 2022-09-24 12:06:36 +01:00
Alberto Ponces
2a0ea78d7f feat: Adds support for patching on x86 and x64 devices
Introduces new aapt2 binaries from revanced/aapt2
2022-09-24 12:05:36 +01:00
Aunali321
4722880647 feat: better patch version background. 2022-09-24 13:47:09 +05:30
Aunali321
32fabcfa3f fix: nav overlapping install buttons. 2022-09-24 12:53:46 +05:30
Alberto Ponces
e0c46e4268 fix: Show "Share log" menu option even if patching has errors 2022-09-23 17:22:39 +01:00
Alberto Ponces
d84230fa22 feat: Merge integrations if a patch or any of its dependencies need them 2022-09-23 17:20:19 +01:00
Alberto Ponces
9561153bfb feat: Hide "Install as Root" button if user does not have root access at all 2022-09-23 15:47:30 +01:00
Alberto Ponces
c8c35ca801 build: Bump version to v0.0.22 2022-09-23 15:34:18 +01:00
Alberto Ponces
cf99069804 fix: Handle minor lint errors 2022-09-23 15:33:27 +01:00
Alberto Ponces
6abb761724 refactor: Move some logic to ManagerAPI and PatcherAPI 2022-09-23 15:31:24 +01:00
Alberto Ponces
4609ed9eba fix: Make sure we are getting app from from storage when selection is from storage 2022-09-23 15:21:58 +01:00
Aunali321
c0f743df89 feat: HTTP2 support for api requests. (#290) 2022-09-23 19:06:06 +05:30
Aunali321
f00f910973 Merge branch 'flutter' of https://github.com/revanced/revanced-manager into flutter 2022-09-23 14:58:19 +05:30
Aunali321
2bc486dcec build: Bump version to v0.0.21. 2022-09-23 14:58:07 +05:30
Aunali321
148981da18 refactor: removed dropdown for branch. 2022-09-23 14:57:05 +05:30
Aunali321
d8df377427 feat: warning dialog when selecting all patches. 2022-09-23 14:53:21 +05:30
Aunali321
efe1306aac fix: reverse versions list to have recents first. 2022-09-23 13:35:47 +05:30
Aunali321
ead308740f refactor: move custom button to shared dir. 2022-09-23 13:00:30 +05:30
oSumAtrIX
fa0f250e27 build: bump patcher dependency version to v5.0.1 2022-09-23 07:45:44 +02:00
oSumAtrIX
185d883b65 feat: acknowledgements section for template feature-issue 2022-09-23 07:33:30 +02:00
oSumAtrIX
9d8b2e1a35 feat: acknowledgements section for template feature-issue 2022-09-23 07:32:44 +02:00
Alberto Ponces
a6a7ff5040 build: Bump version to v0.0.19 2022-09-23 00:39:44 +01:00
Alberto Ponces
1028ec8e2a fix: Prevent Manager from crashing when a patcher exception occurs and print its stack trace on installer's log 2022-09-23 00:38:42 +01:00
Alberto Ponces
f9242c1958 build: Bump version to v0.0.18 2022-09-22 14:04:59 +01:00
Alberto Ponces
f9865166b0 fix: TikTok integrations and settings patches should be merged if needed 2022-09-22 14:02:07 +01:00
Alberto Ponces
f0f934f6a1 fix: Prevent printing of denied root permission exceptions for unrooted users 2022-09-22 14:01:05 +01:00
Alberto Ponces
3d25655851 fix: Uninstall button should always be shown 2022-09-22 09:46:28 +01:00
oSumAtrIX
733190e76c build: bump version to v0.0.17+17 2022-09-21 05:19:26 +02:00
oSumAtrIX
ab312dec43 build: bump patcher dependency version to v5.0.0 2022-09-21 04:16:19 +02:00
oSumAtrIX
70159b8cd8 Update Crowdin configuration file 2022-09-20 19:17:29 +02:00
oSumAtrIX
97060913a2 Update Crowdin configuration file 2022-09-20 19:07:41 +02:00
oSumAtrIX
4a0c5f9935 Update Crowdin configuration file 2022-09-20 12:06:23 +02:00
Alberto Ponces
f643a31455 Merge branch 'flutter' of github.com:revanced/revanced-manager into flutter 2022-09-20 10:05:06 +01:00
Alberto Ponces
03b87a50ea fix: Use a proper app name when MicroG is applied 2022-09-20 10:04:51 +01:00
Alberto Ponces
4631982d42 fix: Use original packageName to get compatible patches 2022-09-20 10:04:02 +01:00
Palm
4c4b694db9 chore: update English language capitalizations and format (#228)
* chore: update English language capitalizations and format

* chore: revert capitalization changes as requested
2022-09-20 12:27:20 +05:30
Alberto Ponces
fd099fb632 build: Bump version to v0.0.16 2022-09-20 02:38:55 +01:00
Alberto Ponces
e374e03355 fix: Readd padding between Application Items 2022-09-20 02:38:28 +01:00
Alberto Ponces
d0293f5412 build: Bump version to v0.0.15 2022-09-20 01:54:41 +01:00
Alberto Ponces
6f72c2ebec fix: Fix unfixed fixes which needed to be fixed (better now??) 2022-09-20 01:07:36 +01:00
Alberto Ponces
07407933d9 fix: Don't select patches by default based on their excluded flag 2022-09-20 00:59:14 +01:00
Alberto Ponces
2f4726ea68 fix: Add toast service to simplify creation of toasts 2022-09-20 00:49:31 +01:00
Alberto Ponces
207e94de5a fix: Fix Update Manager's button 2022-09-20 00:03:37 +01:00
Alberto Ponces
7231d44e02 fix: Push Custom Sources tile to Advanced section and reorder a bit 2022-09-19 23:31:21 +01:00
Alberto Ponces
bd5b38d88e fix: Add rounded borders on Unpatch button inkwell as well 2022-09-19 23:25:39 +01:00
Unknown
530dd78752 fix: make inkwells visible (#205) 2022-09-19 17:55:44 +01:00
Alberto Ponces
efcf455b24 Merge branch 'flutter' of github.com:revanced/revanced-manager into flutter 2022-09-19 17:40:11 +01:00
Alberto Ponces
bed2cf76d5 feat: Prevent exiting installer on new back button as well and show why exiting is not possible during patching 2022-09-19 17:40:06 +01:00
Aunali321
5c8079ae95 fix: warn about no armv7 support. 2022-09-19 21:34:52 +05:30
Alberto Ponces
2a2bb8212f fix: Add back button on app bars of secondary views 2022-09-19 16:24:31 +01:00
Aunali321
3e6e94c098 fix: disable creating blank issues. 2022-09-19 18:23:33 +05:30
Aunali321
ce100d97fd refactor: add dropdown for feature template. 2022-09-19 18:22:51 +05:30
Aunali321
743a661c10 refactor: use dropdown for branch. 2022-09-19 18:10:59 +05:30
Unknown
2b7287c04c feat: CustomScrollView in app and patches selector views (#208) 2022-09-19 12:57:40 +01:00
Aunali321
9bdccb3c9d refactor: more strict bug issue template. 2022-09-19 17:17:48 +05:30
Alberto Ponces
b8171253c7 fix: Readd divider mistakenly removed in #194 2022-09-19 09:56:51 +01:00
Unknown
d6dde3e23b fix: (settings) remove padding from inkwells (#194) 2022-09-19 09:39:25 +01:00
Unknown
fc5414c788 fix: delete tests (#196) 2022-09-19 09:13:40 +01:00
Alberto Ponces
ed9038ffe8 build: Bump version to v0.0.14 2022-09-19 01:47:51 +01:00
Alberto Ponces
269a71d336 fix: Improve foreground service init and disable 2022-09-19 01:46:12 +01:00
Alberto Ponces
9405334a7d fix: Fix multiple APK shares 2022-09-19 01:45:24 +01:00
Alberto Ponces
2f14746124 feat: Add install error dialogs to prevent faulty installations 2022-09-19 01:44:27 +01:00
Alberto Ponces
6c2ceed91f fix: Improve API URL handling and force init after setting a new config 2022-09-19 00:28:26 +01:00
Alberto Ponces
c333fa3c33 fix: Prefer Yes/No instead of OK/Cancel on a few dialogs 2022-09-18 22:53:04 +01:00
Alberto Ponces
79d0396630 fix: No need for an uninstall confirmation dialog as OS already handles this 2022-09-18 22:47:24 +01:00
Unknown
110c3326bd fix: navigation bar color (#197) 2022-09-18 22:20:08 +01:00
Alberto Ponces
9c5b0b9c14 fix: Readd permission_handler with a proper fix 2022-09-18 22:13:29 +01:00
Aunali321
c5ad337daa feat: Custom api endpoints. (#216)
Co-authored-by: Alberto Ponces <ponces26@gmail.com>
2022-09-18 23:12:30 +05:30
Aunali321
a9f64e449b refactor: basic prerequisites in readme. 2022-09-18 23:01:12 +05:30
Unknown
48f0bc625d feat: animate switching updates on HomeView (#209) 2022-09-18 16:49:18 +01:00
Aunali321
4c6b93320f build: Bump bump version to v0.0.13 2022-09-18 12:22:39 +05:30
Aunali321
2f3bb6cfe4 refactor: better wording. 2022-09-18 12:18:47 +05:30
oSumAtrIX
0e1fa1a5d6 build: bump patcher dependency 2022-09-18 08:38:03 +02:00
Alberto Ponces
38fb3444e4 build: Bump version to v0.0.12 2022-09-18 05:07:12 +01:00
Alberto Ponces
f10b5aebac fix: Decrease app name space a bit to prevent overflowing 2022-09-18 05:06:51 +01:00
Alberto Ponces
5a3884e159 fix: Fix uninstall apps 2022-09-18 05:06:23 +01:00
Alberto Ponces
41ac2b0df8 build: Bump version to v0.0.11 2022-09-18 04:47:23 +01:00
Alberto Ponces
52e7d76c9d fix: Fix spacing of App Info buttons 2022-09-18 04:46:21 +01:00
Alberto Ponces
3aa80cacc0 fix: Fix duplicate entries on non-root installations 2022-09-18 04:44:44 +01:00
Alberto Ponces
dd52c379b4 fix: Show updatable app item only on updatable apps listing 2022-09-18 04:12:33 +01:00
Alberto Ponces
5d073bddf2 fix: Minor i18n typo 2022-09-18 03:41:16 +01:00
61 changed files with 1965 additions and 1452 deletions

View File

@@ -20,12 +20,6 @@ body:
- Other - Other
validations: validations:
required: true required: true
- type: textarea
attributes:
label: Branch
description: Which github branch did you use (Flutter or Compose)?
validations:
required: true
- type: textarea - type: textarea
attributes: attributes:
label: Bug description label: Bug description
@@ -41,11 +35,56 @@ body:
required: true required: true
- type: textarea - type: textarea
attributes: attributes:
label: Relevant log output label: Android version
description: Android version used.
validations:
required: true
- type: textarea
attributes:
label: Manager version
description: Manager version used.
validations:
required: true
- type: textarea
attributes:
label: Target package name
description: App you tried to patch.
validations:
required: true
- type: textarea
attributes:
label: Target package version.
description: Version of the app you tried to patch.
validations:
required: true
- type: dropdown
attributes:
label: Installation type
options:
- Non-root
- Root
validations:
required: true
- type: textarea
attributes:
label: Patches selected.
description: Patches you selected for the app.
validations:
required: true
- type: textarea
attributes:
label: Device logs (exported using Manager settings).
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell render: shell
validations: validations:
required: true required: true
- type: textarea
attributes:
label: Installer logs (exported using Installer menu option) [unneeded if issue is not during patching].
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
validations:
required: false
- type: textarea - type: textarea
attributes: attributes:
label: Screenshots or videos label: Screenshots or videos
@@ -65,3 +104,17 @@ body:
description: Add additional context here. description: Add additional context here.
validations: validations:
required: false required: false
- type: checkboxes
id: acknowledgements
attributes:
label: Acknowledgements
description: Your issue will be closed if you haven't done these steps.
options:
- label: I have searched the existing issues and this is a new and no duplicate or related to another open issue.
required: true
- label: I have written a short but informative title.
required: true
- label: I filled out all of the requested information in this issue properly.
required: true
- label: The issue is related solely to the ReVanced Manager
required: true

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1 @@
blank_issues_enabled: false

View File

@@ -12,12 +12,6 @@ body:
- Other - Other
validations: validations:
required: true required: true
- type: textarea
attributes:
label: Branch
description: Which github branch did you use (Flutter or Compose)?
validations:
required: true
- type: textarea - type: textarea
attributes: attributes:
label: Issue label: Issue
@@ -41,4 +35,18 @@ body:
label: Additional context label: Additional context
description: Add additional context here. description: Add additional context here.
validations: validations:
required: false required: false
- type: checkboxes
id: acknowledgements
attributes:
label: Acknowledgements
description: Your issue will be closed if you haven't done these steps.
options:
- label: I have searched the existing issues and this is a new and no duplicate or related to another open issue.
required: true
- label: I have written a short but informative title.
required: true
- label: I filled out all of the requested information in this issue properly.
required: true
- label: The issue is related solely to the ReVanced Manager
required: true

View File

@@ -12,4 +12,9 @@ For suggestions and bug reports, open an issue [here](https://github.com/revance
If you wish to discuss the Manager, a thread has been made under the [#chat](https://discord.com/channels/952946952348270622/1002922226443632761) channel in the Discord server, please note that this thread may be temporary and may be removed in the future. If you wish to discuss the Manager, a thread has been made under the [#chat](https://discord.com/channels/952946952348270622/1002922226443632761) channel in the Discord server, please note that this thread may be temporary and may be removed in the future.
## ⚠️ Disclaimer ## ⚠️ Disclaimer
*Please note that even though we're releasing the Manager, it is an ALPHA version. Meaning there's a big chance that the Manager might not work at all for you.* *Please note that even though we're releasing the Manager, it is an ALPHA version. Meaning there's a big chance that the Manager might not work at all for you.*
## Prerequisites
1. Android 8 or higher.
2. Does not work on armv7
3. For YouTube and YouTube Music - Vanced MicroG(Only for non-root).

View File

@@ -71,7 +71,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// ReVanced // ReVanced
implementation "app.revanced:revanced-patcher:4.4.1" implementation "app.revanced:revanced-patcher:5.1.0"
// Signing & aligning // Signing & aligning
implementation("org.bouncycastle:bcpkix-jdk15on:1.70") implementation("org.bouncycastle:bcpkix-jdk15on:1.70")

View File

@@ -1,15 +1,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.revanced.manager.flutter"> package="app.revanced.manager.flutter">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" /> <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" /> <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application <application
android:label="ReVanced Manager" android:label="ReVanced Manager"

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -74,7 +74,6 @@ class MainActivity : FlutterActivity() {
result.notImplemented() result.notImplemented()
} }
} }
else -> result.notImplemented() else -> result.notImplemented()
} }
} }
@@ -101,161 +100,174 @@ class MainActivity : FlutterActivity() {
val integrations = File(integrationsPath) val integrations = File(integrationsPath)
val keyStoreFile = File(keyStoreFilePath) val keyStoreFile = File(keyStoreFilePath)
val patches = DexPatchBundle(
patchBundleFilePath,
DexClassLoader(
patchBundleFilePath,
cacheDirPath,
null,
javaClass.classLoader
)
).loadPatches().filter { patch -> selectedPatches.any { it == patch.patchName } }
Thread { Thread {
handler.post { try {
installerChannel.invokeMethod( val patches = DexPatchBundle(
"update", patchBundleFilePath,
mapOf( DexClassLoader(
"progress" to 0.1, patchBundleFilePath,
"header" to "",
"log" to "Copying original apk"
)
)
}
originalFile.copyTo(inputFile, true)
handler.post {
installerChannel.invokeMethod(
"update",
mapOf(
"progress" to 0.2,
"header" to "Unpacking apk...",
"log" to "Unpacking input apk"
)
)
}
val patcher =
Patcher(
PatcherOptions(
inputFile,
cacheDirPath, cacheDirPath,
resourcePatching, null,
Aapt.binary(applicationContext).absolutePath, javaClass.classLoader
cacheDirPath,
logger = ManagerLogger()
) )
) ).loadPatches().filter { patch -> selectedPatches.any { it == patch.patchName } }
handler.post {
installerChannel.invokeMethod(
"update",
mapOf("progress" to 0.3, "header" to "", "log" to "")
)
}
if (mergeIntegrations) {
handler.post { handler.post {
installerChannel.invokeMethod( installerChannel.invokeMethod(
"update", "update",
mapOf( mapOf(
"progress" to 0.4, "progress" to 0.1,
"header" to "Merging integrations...", "header" to "",
"log" to "Merging integrations" "log" to "Copying original apk"
) )
) )
} }
patcher.addFiles(listOf(integrations)) {} originalFile.copyTo(inputFile, true)
}
handler.post { handler.post {
installerChannel.invokeMethod( installerChannel.invokeMethod(
"update", "update",
mapOf( mapOf(
"progress" to 0.5, "progress" to 0.2,
"header" to "Applying patches...", "header" to "Unpacking apk...",
"log" to "" "log" to "Unpacking input apk"
)
) )
) }
} val patcher =
patcher.addPatches(patches) Patcher(
patcher.applyPatches().forEach { (patch, res) -> PatcherOptions(
if (res.isSuccess) { inputFile,
val msg = "[success] $patch" cacheDirPath,
resourcePatching,
Aapt.binary(applicationContext).absolutePath,
cacheDirPath,
logger = ManagerLogger()
)
)
handler.post {
installerChannel.invokeMethod(
"update",
mapOf("progress" to 0.3, "header" to "", "log" to "")
)
}
if (mergeIntegrations) {
handler.post { handler.post {
installerChannel.invokeMethod( installerChannel.invokeMethod(
"update", "update",
mapOf( mapOf(
"progress" to 0.5, "progress" to 0.4,
"header" to "", "header" to "Merging integrations...",
"log" to msg "log" to "Merging integrations"
) )
) )
} }
return@forEach patcher.addFiles(listOf(integrations)) {}
} }
val msg = "[error] $patch:" + res.exceptionOrNull()!!
handler.post { handler.post {
installerChannel.invokeMethod( installerChannel.invokeMethod(
"update", "update",
mapOf("progress" to 0.5, "header" to "", "log" to msg) mapOf(
"progress" to 0.5,
"header" to "Applying patches...",
"log" to ""
)
) )
} }
}
handler.post { patcher.addPatches(patches)
installerChannel.invokeMethod( patcher.applyPatches().forEach { (patch, res) ->
"update", if (res.isSuccess) {
mapOf( val msg = "[success] $patch"
"progress" to 0.7, handler.post {
"header" to "Repacking apk...", installerChannel.invokeMethod(
"log" to "Repacking patched apk" "update",
) mapOf(
) "progress" to 0.5,
} "header" to "",
val res = patcher.save() "log" to msg
ZipFile(patchedFile).use { file -> )
res.dexFiles.forEach { )
file.addEntryCompressData( }
ZipEntry.createWithName(it.name), return@forEach
it.stream.readBytes() }
val msg = "[error] $patch:" + res.exceptionOrNull()!!
handler.post {
installerChannel.invokeMethod(
"update",
mapOf("progress" to 0.5, "header" to "", "log" to msg)
)
}
}
handler.post {
installerChannel.invokeMethod(
"update",
mapOf(
"progress" to 0.7,
"header" to "Repacking apk...",
"log" to "Repacking patched apk"
)
) )
} }
res.resourceFile?.let { val res = patcher.save()
ZipFile(patchedFile).use { file ->
res.dexFiles.forEach {
file.addEntryCompressData(
ZipEntry.createWithName(it.name),
it.stream.readBytes()
)
}
res.resourceFile?.let {
file.copyEntriesFromFileAligned(
ZipFile(it),
ZipAligner::getEntryAlignment
)
}
file.copyEntriesFromFileAligned( file.copyEntriesFromFileAligned(
ZipFile(it), ZipFile(inputFile),
ZipAligner::getEntryAlignment ZipAligner::getEntryAlignment
) )
} }
file.copyEntriesFromFileAligned( handler.post {
ZipFile(inputFile), installerChannel.invokeMethod(
ZipAligner::getEntryAlignment "update",
) mapOf(
} "progress" to 0.9,
handler.post { "header" to "Signing apk...",
installerChannel.invokeMethod( "log" to ""
"update", )
mapOf(
"progress" to 0.9,
"header" to "Signing apk...",
"log" to ""
) )
) }
} Signer("ReVanced", "s3cur3p@ssw0rd").signApk(patchedFile, outFile, keyStoreFile)
Signer("ReVanced", "s3cur3p@ssw0rd").signApk(patchedFile, outFile, keyStoreFile)
handler.post { handler.post {
installerChannel.invokeMethod( installerChannel.invokeMethod(
"update", "update",
mapOf( mapOf(
"progress" to 1.0, "progress" to 1.0,
"header" to "Finished!", "header" to "Finished!",
"log" to "Finished!" "log" to "Finished!"
)
) )
) }
} catch (ex: Throwable) {
val stack = ex.stackTraceToString()
handler.post {
installerChannel.invokeMethod(
"update",
mapOf(
"progress" to -100.0,
"header" to "Aborting...",
"log" to "An error occurred! Aborting\nError:\n$stack"
)
)
}
} }
handler.post { result.success(null) } handler.post { result.success(null) }
} }.start()
.start()
} }
inner class ManagerLogger : Logger { inner class ManagerLogger : Logger {

View File

@@ -3,8 +3,8 @@
"cancelButton": "Cancel", "cancelButton": "Cancel",
"enabledLabel": "Enabled", "enabledLabel": "Enabled",
"disabledLabel": "Disabled", "disabledLabel": "Disabled",
"yesLabel": "Yes", "yesButton": "Yes",
"noLabel": "No", "noButton": "No",
"navigationView": { "navigationView": {
"dashboardTab": "Dashboard", "dashboardTab": "Dashboard",
"patcherTab": "Patcher", "patcherTab": "Patcher",
@@ -14,18 +14,18 @@
"widgetTitle": "Dashboard", "widgetTitle": "Dashboard",
"updatesSubtitle": "Updates", "updatesSubtitle": "Updates",
"patchedSubtitle": "Patched Applications", "patchedSubtitle": "Patched Applications",
"updatesAvailable": "Updates Available", "updatesAvailable": "Updates available",
"noUpdates": "No updates available", "noUpdates": "No updates available",
"noInstallations": "No patched applications installed", "noInstallations": "No patched applications installed",
"installed": "Installed", "installed": "Installed",
"updateDialogTitle": "Update", "updateDialogTitle": "Update Manager",
"updateDialogText": "Are you sure you want to download and update Manager?", "updateDialogText": "Are you sure you want to download and update ReVanced Manager?",
"notificationTitle": "ReVanced Manager was updated!", "notificationTitle": "ReVanced Manager was updated",
"notificationText": "Tap to open the app", "notificationText": "Tap to open the app",
"downloadingMessage": "Downloading update!", "downloadingMessage": "Downloading update...",
"installingMessage": "Installing update... Hang on!", "installingMessage": "Installing update...",
"errorDownloadMessage": "Unable to download update!", "errorDownloadMessage": "Unable to download update",
"errorInstallMessage": "Unable to download update!", "errorInstallMessage": "Unable to install update",
"noConnection": "No internet connection" "noConnection": "No internet connection"
}, },
"applicationItem": { "applicationItem": {
@@ -34,7 +34,7 @@
"changelogLabel": "Changelog" "changelogLabel": "Changelog"
}, },
"latestCommitCard": { "latestCommitCard": {
"loadingLabel": "Loading", "loadingLabel": "Loading...",
"timeagoLabel": "{time} ago", "timeagoLabel": "{time} ago",
"patcherLabel": "Patcher: ", "patcherLabel": "Patcher: ",
"managerLabel": "Manager: ", "managerLabel": "Manager: ",
@@ -44,12 +44,12 @@
"widgetTitle": "Patcher", "widgetTitle": "Patcher",
"patchButton": "Patch", "patchButton": "Patch",
"patchDialogTitle": "Warning", "patchDialogTitle": "Warning",
"patchDialogText": "You have selected a resource patch and a split APK installation was detected so patching errors can occur.\nAre you sure you want to proceed with patching a split base APK?" "patchDialogText": "You have selected a resource patch and a split APK installation was detected so patching errors may occur.\nAre you sure you want to proceed with patching a split base APK?"
}, },
"appSelectorCard": { "appSelectorCard": {
"widgetTitle": "Select application", "widgetTitle": "Select application",
"widgetTitleSelected": "Selected application", "widgetTitleSelected": "Selected application",
"widgetSubtitle": "No application selected.", "widgetSubtitle": "No application selected",
"noAppsLabel": "No applications found.", "noAppsLabel": "No applications found.",
"currentVersion": "Current", "currentVersion": "Current",
"recommendedVersion": "Recommended", "recommendedVersion": "Recommended",
@@ -58,27 +58,31 @@
"patchSelectorCard": { "patchSelectorCard": {
"widgetTitle": "Select patches", "widgetTitle": "Select patches",
"widgetTitleSelected": "Selected patches", "widgetTitleSelected": "Selected patches",
"widgetSubtitle": "Select an application first.", "widgetSubtitle": "Select an application first",
"widgetEmptySubtitle": "No patches selected." "widgetEmptySubtitle": "No patches selected"
}, },
"socialMediaCard": { "socialMediaCard": {
"widgetTitle": "Social Media", "widgetTitle": "Socials",
"widgetSubtitle": "We are online!" "widgetSubtitle": "We are online!"
}, },
"appSelectorView": { "appSelectorView": {
"viewTitle": "Select application",
"searchBarHint": "Search applications", "searchBarHint": "Search applications",
"storageButton": "Storage", "storageButton": "Storage",
"errorMessage": "Unable to use selected application." "errorMessage": "Unable to use selected application."
}, },
"patchesSelectorView": { "patchesSelectorView": {
"viewTitle": "Select patches",
"searchBarHint": "Search patches", "searchBarHint": "Search patches",
"doneButton": "Done", "doneButton": "Done",
"noPatchesFound": "No patches found for the selected app." "noPatchesFound": "No patches found for the selected app",
"selectAllPatchesWarningTitle": "Warning",
"selectAllPatchesWarningContent": "You are about to select all patches, that includes unrecommended patches and can cause unwanted behavior."
}, },
"patchItem": { "patchItem": {
"unsupportedWarningButton": "Unsupported version", "unsupportedWarningButton": "Unsupported version",
"unsupportedDialogTitle": "Warning", "unsupportedDialogTitle": "Warning",
"unsupportedDialogText": "Selecting this patch may or may not result in patching errors.\n\nApp version: {packageVersion}\nCurrent supported versions:\n{supportedVersions}" "unsupportedDialogText": "Selecting this patch may result in patching errors.\n\nApp version: {packageVersion}\nCurrent supported versions:\n{supportedVersions}"
}, },
"installerView": { "installerView": {
"widgetTitle": "Installer", "widgetTitle": "Installer",
@@ -89,14 +93,19 @@
"notificationTitle": "ReVanced Manager is patching", "notificationTitle": "ReVanced Manager is patching",
"notificationText": "Tap to return to the installer", "notificationText": "Tap to return to the installer",
"shareApkMenuOption": "Share APK", "shareApkMenuOption": "Share APK",
"shareLogMenuOption": "Share log" "shareLogMenuOption": "Share log",
"installErrorDialogTitle": "Error",
"installErrorDialogText1": "Root install is not possible with the current patches selection.\nRepatch your app or choose non-root install.",
"installErrorDialogText2": "Non-root install is not possible with the current patches selection.\nRepatch your app or choose root install if you have your device rooted.",
"installErrorDialogText3": "Root install is not possible as the original APK was selected from storage.\nSelect an installed app or choose non-root install.",
"noExit": "Installer is still running..."
}, },
"settingsView": { "settingsView": {
"widgetTitle": "Settings", "widgetTitle": "Settings",
"appearanceSectionTitle": "Appearance", "appearanceSectionTitle": "Appearance",
"patcherSectionTitle": "Patcher",
"teamSectionTitle": "Team", "teamSectionTitle": "Team",
"infoSectionTitle": "Info", "infoSectionTitle": "Info",
"advancedSectionTitle": "Advanced",
"darkThemeLabel": "Dark Mode", "darkThemeLabel": "Dark Mode",
"darkThemeHint": "Welcome to the Dark Side", "darkThemeHint": "Welcome to the Dark Side",
"dynamicThemeLabel": "Material You", "dynamicThemeLabel": "Material You",
@@ -106,16 +115,20 @@
"frenchOption": "French", "frenchOption": "French",
"sourcesLabel": "Sources", "sourcesLabel": "Sources",
"sourcesLabelHint": "Configure your custom sources", "sourcesLabelHint": "Configure your custom sources",
"orgPatchesLabel" : "Patches Org", "orgPatchesLabel": "Patches Organization",
"sourcesPatchesLabel" : "Patches Source", "sourcesPatchesLabel": "Patches Source",
"orgIntegrationsLabel": "Integrations Org", "orgIntegrationsLabel": "Integrations Organization",
"sourcesIntegrationsLabel": "Integrations Source", "sourcesIntegrationsLabel": "Integrations Source",
"sourcesResetDialogTitle": "Reset", "sourcesResetDialogTitle": "Reset",
"sourcesResetDialogText": "Are you sure you want to reset custom sources to their default values?", "sourcesResetDialogText": "Are you sure you want to reset custom sources to their default values?",
"apiURLResetDialogText": "Are you sure you want to reset API URL to its default value?",
"contributorsLabel": "Contributors", "contributorsLabel": "Contributors",
"contributorsHint": "A list of contributors of ReVanced", "contributorsHint": "A list of contributors of ReVanced",
"logsLabel": "Logs", "logsLabel": "Logs",
"logsHint": "Share device debug logs", "logsHint": "Share device debug logs",
"apiURLLabel": "API URL",
"apiURLHint": "Configure your custom API URL",
"selectApiURL": "Select URL",
"aboutLabel": "About", "aboutLabel": "About",
"snackbarMessage": "Copied to clipboard" "snackbarMessage": "Copied to clipboard"
}, },
@@ -125,9 +138,6 @@
"uninstallButton": "Uninstall", "uninstallButton": "Uninstall",
"patchButton": "Patch", "patchButton": "Patch",
"unpatchButton": "Unpatch", "unpatchButton": "Unpatch",
"uninstallDialogTitle": "Uninstall",
"uninstallDialogText": "Are you sure you want to uninstall this app?",
"unpatchDialogTitle": "Unpatch",
"unpatchDialogText": "Are you sure you want to unpatch this app?", "unpatchDialogText": "Are you sure you want to unpatch this app?",
"rootDialogTitle": "Error", "rootDialogTitle": "Error",
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.", "rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",

3
crowdin.yml Normal file
View File

@@ -0,0 +1,3 @@
files:
- source: /assets/i18n/en.json
translation: /assets/i18n/%locale_with_underscore%.json

View File

@@ -2,6 +2,7 @@ import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/revanced_api.dart'; import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart'; import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart';
import 'package:revanced_manager/ui/views/contributors/contributors_view.dart'; import 'package:revanced_manager/ui/views/contributors/contributors_view.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
@@ -36,6 +37,7 @@ import 'package:stacked_services/stacked_services.dart';
LazySingleton(classType: PatcherAPI), LazySingleton(classType: PatcherAPI),
LazySingleton(classType: RevancedAPI), LazySingleton(classType: RevancedAPI),
LazySingleton(classType: GithubAPI), LazySingleton(classType: GithubAPI),
LazySingleton(classType: Toast),
], ],
) )
class AppSetup {} class AppSetup {}

View File

@@ -9,15 +9,18 @@ import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart'; import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
import 'package:stacked_themes/stacked_themes.dart'; import 'package:stacked_themes/stacked_themes.dart';
import 'package:timezone/data/latest.dart' as tz;
Future main() async { Future main() async {
await ThemeManager.initialise(); await ThemeManager.initialise();
await setupLocator(); await setupLocator();
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await locator<ManagerAPI>().initialize(); await locator<ManagerAPI>().initialize();
await locator<PatcherAPI>().initialize(); String apiUrl = locator<ManagerAPI>().getApiUrl();
locator<RevancedAPI>().initialize(); await locator<RevancedAPI>().initialize(apiUrl);
locator<GithubAPI>().initialize(); locator<GithubAPI>().initialize();
await locator<PatcherAPI>().initialize();
tz.initializeTimeZones();
runApp(const MyApp()); runApp(const MyApp());
} }
@@ -32,7 +35,7 @@ class MyApp extends StatelessWidget {
localizationsDelegates: [ localizationsDelegates: [
FlutterI18nDelegate( FlutterI18nDelegate(
translationLoader: FileTranslationLoader( translationLoader: FileTranslationLoader(
fallbackFile: 'en', fallbackFile: 'en_US',
basePath: 'assets/i18n', basePath: 'assets/i18n',
), ),
), ),

View File

@@ -17,6 +17,7 @@ class PatchedApplication {
Uint8List icon; Uint8List icon;
DateTime patchDate; DateTime patchDate;
bool isRooted; bool isRooted;
bool isFromStorage;
bool hasUpdates; bool hasUpdates;
List<String> appliedPatches; List<String> appliedPatches;
List<String> changelog; List<String> changelog;
@@ -29,6 +30,7 @@ class PatchedApplication {
required this.icon, required this.icon,
required this.patchDate, required this.patchDate,
this.isRooted = false, this.isRooted = false,
this.isFromStorage = false,
this.hasUpdates = false, this.hasUpdates = false,
this.appliedPatches = const [], this.appliedPatches = const [],
this.changelog = const [], this.changelog = const [],

View File

@@ -6,11 +6,18 @@ import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:dio_http2_adapter/dio_http2_adapter.dart';
@lazySingleton @lazySingleton
class GithubAPI { class GithubAPI {
final String apiUrl = 'https://api.github.com'; final Dio _dio = Dio(
final Dio _dio = Dio(); BaseOptions(baseUrl: 'https://api.github.com'),
)..httpClientAdapter = Http2Adapter(
ConnectionManager(
idleTimeout: 10000,
onClientCreate: (_, config) => config.onBadCertificate = (_) => true,
),
);
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig()); final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final Options _cacheOptions = buildCacheOptions( final Options _cacheOptions = buildCacheOptions(
const Duration(days: 1), const Duration(days: 1),
@@ -37,7 +44,7 @@ class GithubAPI {
Future<Map<String, dynamic>?> _getLatestRelease(String repoName) async { Future<Map<String, dynamic>?> _getLatestRelease(String repoName) async {
try { try {
var response = await _dio.get( var response = await _dio.get(
'$apiUrl/repos/$repoName/releases/latest', '/repos/$repoName/releases/latest',
options: _cacheOptions, options: _cacheOptions,
); );
return response.data; return response.data;
@@ -55,7 +62,7 @@ class GithubAPI {
'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}'; 'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}';
try { try {
var response = await _dio.get( var response = await _dio.get(
'$apiUrl/repos/$repoName/commits', '/repos/$repoName/commits',
queryParameters: { queryParameters: {
'path': path, 'path': path,
'per_page': 3, 'per_page': 3,

View File

@@ -19,6 +19,7 @@ class ManagerAPI {
final String patcherRepo = 'revanced-patcher'; final String patcherRepo = 'revanced-patcher';
final String cliRepo = 'revanced-cli'; final String cliRepo = 'revanced-cli';
late SharedPreferences _prefs; late SharedPreferences _prefs;
String defaultApiUrl = 'https://revanced-releases-api.afterst0rm.xyz';
String defaultPatcherRepo = 'revanced/revanced-patcher'; String defaultPatcherRepo = 'revanced/revanced-patcher';
String defaultPatchesRepo = 'revanced/revanced-patches'; String defaultPatchesRepo = 'revanced/revanced-patches';
String defaultIntegrationsRepo = 'revanced/revanced-integrations'; String defaultIntegrationsRepo = 'revanced/revanced-integrations';
@@ -29,6 +30,19 @@ class ManagerAPI {
_prefs = await SharedPreferences.getInstance(); _prefs = await SharedPreferences.getInstance();
} }
String getApiUrl() {
return _prefs.getString('apiUrl') ?? defaultApiUrl;
}
Future<void> setApiUrl(String url) async {
if (url.isEmpty || url == ' ') {
url = defaultApiUrl;
}
await _revancedAPI.initialize(url);
await _revancedAPI.clearAllCache();
await _prefs.setString('apiUrl', url);
}
String getPatchesRepo() { String getPatchesRepo() {
return _prefs.getString('patchesRepo') ?? defaultPatchesRepo; return _prefs.getString('patchesRepo') ?? defaultPatchesRepo;
} }
@@ -83,8 +97,10 @@ class ManagerAPI {
Future<void> savePatchedApp(PatchedApplication app) async { Future<void> savePatchedApp(PatchedApplication app) async {
List<PatchedApplication> patchedApps = getPatchedApps(); List<PatchedApplication> patchedApps = getPatchedApps();
patchedApps.removeWhere((a) => a.packageName == app.packageName); patchedApps.removeWhere((a) => a.packageName == app.packageName);
ApplicationWithIcon? installed = ApplicationWithIcon? installed = await DeviceApps.getApp(
await DeviceApps.getApp(app.packageName, true) as ApplicationWithIcon?; app.packageName,
true,
) as ApplicationWithIcon?;
if (installed != null) { if (installed != null) {
app.name = installed.appName; app.name = installed.appName;
app.version = installed.versionName!; app.version = installed.versionName!;
@@ -110,10 +126,11 @@ class ManagerAPI {
} }
Future<List<Patch>> getPatches() async { Future<List<Patch>> getPatches() async {
if (getPatchesRepo() == defaultPatchesRepo) { String repoName = getPatchesRepo();
if (repoName == defaultPatchesRepo) {
return await _revancedAPI.getPatches(); return await _revancedAPI.getPatches();
} else { } else {
return await _githubAPI.getPatches(getPatchesRepo()); return await _githubAPI.getPatches(repoName);
} }
} }
@@ -187,9 +204,10 @@ class ManagerAPI {
List<String> installedApps = await _rootAPI.getInstalledApps(); List<String> installedApps = await _rootAPI.getInstalledApps();
for (String packageName in installedApps) { for (String packageName in installedApps) {
if (!patchedApps.any((app) => app.packageName == packageName)) { if (!patchedApps.any((app) => app.packageName == packageName)) {
ApplicationWithIcon? application = ApplicationWithIcon? application = await DeviceApps.getApp(
await DeviceApps.getApp(packageName, true) packageName,
as ApplicationWithIcon?; true,
) as ApplicationWithIcon?;
if (application != null) { if (application != null) {
unsavedApps.add( unsavedApps.add(
PatchedApplication( PatchedApplication(
@@ -212,10 +230,12 @@ class ManagerAPI {
); );
for (Application app in userApps) { for (Application app in userApps) {
if (app.packageName.startsWith('app.revanced') && if (app.packageName.startsWith('app.revanced') &&
!app.packageName.startsWith('app.revanced.manager.')) { !app.packageName.startsWith('app.revanced.manager.') &&
ApplicationWithIcon? application = !patchedApps.any((uapp) => uapp.packageName == app.packageName)) {
await DeviceApps.getApp(app.packageName, true) ApplicationWithIcon? application = await DeviceApps.getApp(
as ApplicationWithIcon?; app.packageName,
true,
) as ApplicationWithIcon?;
if (application != null) { if (application != null) {
unsavedApps.add( unsavedApps.add(
PatchedApplication( PatchedApplication(
@@ -299,4 +319,14 @@ class ManagerAPI {
} }
return newCommits; return newCommits;
} }
Future<bool> isSplitApk(PatchedApplication patchedApp) async {
Application? app;
if (patchedApp.isFromStorage) {
app = await DeviceApps.getAppFromStorage(patchedApp.apkFilePath);
} else {
app = await DeviceApps.getApp(patchedApp.packageName);
}
return app != null && app.isSplit;
}
} }

View File

@@ -53,9 +53,10 @@ class PatcherAPI {
for (Package package in patch.compatiblePackages) { for (Package package in patch.compatiblePackages) {
try { try {
if (!filteredApps.any((app) => app.packageName == package.name)) { if (!filteredApps.any((app) => app.packageName == package.name)) {
ApplicationWithIcon? app = ApplicationWithIcon? app = await DeviceApps.getApp(
await DeviceApps.getApp(package.name, true) package.name,
as ApplicationWithIcon?; true,
) as ApplicationWithIcon?;
if (app != null) { if (app != null) {
filteredApps.add(app); filteredApps.add(app);
} }
@@ -69,10 +70,14 @@ class PatcherAPI {
} }
Future<List<Patch>> getFilteredPatches(String packageName) async { Future<List<Patch>> getFilteredPatches(String packageName) async {
String newPackageName = packageName.replaceFirst(
'app.revanced.',
'com.google.',
);
return _patches return _patches
.where((patch) => .where((patch) =>
!patch.name.contains('settings') && !patch.name.contains('settings') &&
patch.compatiblePackages.any((pack) => pack.name == packageName)) patch.compatiblePackages.any((pack) => pack.name == newPackageName))
.toList(); .toList();
} }
@@ -82,21 +87,38 @@ class PatcherAPI {
.toList(); .toList();
} }
bool dependencyNeedsIntegrations(String name) {
return name.contains('integrations') ||
_patches.any(
(patch) =>
patch.name == name &&
(patch.dependencies.any(
(dep) => dependencyNeedsIntegrations(dep),
)),
);
}
Future<bool> needsIntegrations(List<Patch> selectedPatches) async { Future<bool> needsIntegrations(List<Patch> selectedPatches) async {
return selectedPatches.any( return selectedPatches.any(
(patch) => patch.dependencies.contains('integrations'), (patch) => patch.dependencies.any(
(dep) => dependencyNeedsIntegrations(dep),
),
); );
} }
Future<bool> needsResourcePatching(List<Patch> selectedPatches) async { Future<bool> needsResourcePatching(List<Patch> selectedPatches) async {
return selectedPatches.any( return selectedPatches.any(
(patch) => patch.dependencies.any((dep) => dep.contains('resource-')), (patch) => patch.dependencies.any(
(dep) => dep.contains('resource-'),
),
); );
} }
Future<bool> needsSettingsPatch(List<Patch> selectedPatches) async { Future<bool> needsSettingsPatch(List<Patch> selectedPatches) async {
return selectedPatches.any( return selectedPatches.any(
(patch) => patch.dependencies.contains('settings'), (patch) => patch.dependencies.any(
(dep) => dep.contains('settings'),
),
); );
} }
@@ -199,10 +221,9 @@ class PatcherAPI {
String prefix = appName.toLowerCase().replaceAll(' ', '-'); String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk'; String newName = '$prefix-revanced_v$version.apk';
int lastSeparator = _outFile!.path.lastIndexOf('/'); int lastSeparator = _outFile!.path.lastIndexOf('/');
File share = _outFile!.renameSync( String newPath = _outFile!.path.substring(0, lastSeparator + 1) + newName;
_outFile!.path.substring(0, lastSeparator + 1) + newName, File shareFile = _outFile!.copySync(newPath);
); ShareExtend.share(shareFile.path, 'file');
ShareExtend.share(share.path, 'file');
} }
} }

View File

@@ -6,18 +6,27 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:timeago/timeago.dart'; import 'package:timeago/timeago.dart';
import 'package:dio_http2_adapter/dio_http2_adapter.dart';
@lazySingleton @lazySingleton
class RevancedAPI { class RevancedAPI {
final String apiUrl = 'https://revanced-releases-api.afterst0rm.xyz'; late Dio _dio = Dio();
final Dio _dio = Dio();
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig()); final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final Options _cacheOptions = buildCacheOptions( final Options _cacheOptions = buildCacheOptions(
const Duration(days: 1), const Duration(days: 1),
maxStale: const Duration(days: 7), maxStale: const Duration(days: 7),
); );
void initialize() { Future<void> initialize(String apiUrl) async {
_dio = Dio(BaseOptions(
baseUrl: apiUrl,
))
..httpClientAdapter = Http2Adapter(
ConnectionManager(
idleTimeout: 10000,
onClientCreate: (_, config) => config.onBadCertificate = (_) => true,
),
);
_dio.interceptors.add(_dioCacheManager.interceptor); _dio.interceptors.add(_dioCacheManager.interceptor);
} }
@@ -28,10 +37,7 @@ class RevancedAPI {
Future<Map<String, List<dynamic>>> getContributors() async { Future<Map<String, List<dynamic>>> getContributors() async {
Map<String, List<dynamic>> contributors = {}; Map<String, List<dynamic>> contributors = {};
try { try {
var response = await _dio.get( var response = await _dio.get('/contributors', options: _cacheOptions);
'$apiUrl/contributors',
options: _cacheOptions,
);
List<dynamic> repositories = response.data['repositories']; List<dynamic> repositories = response.data['repositories'];
for (Map<String, dynamic> repo in repositories) { for (Map<String, dynamic> repo in repositories) {
String name = repo['name']; String name = repo['name'];
@@ -45,7 +51,7 @@ class RevancedAPI {
Future<List<Patch>> getPatches() async { Future<List<Patch>> getPatches() async {
try { try {
var response = await _dio.get('$apiUrl/patches', options: _cacheOptions); var response = await _dio.get('/patches', options: _cacheOptions);
List<dynamic> patches = response.data; List<dynamic> patches = response.data;
return patches.map((patch) => Patch.fromJson(patch)).toList(); return patches.map((patch) => Patch.fromJson(patch)).toList();
} on Exception { } on Exception {
@@ -58,7 +64,7 @@ class RevancedAPI {
String repoName, String repoName,
) async { ) async {
try { try {
var response = await _dio.get('$apiUrl/tools', options: _cacheOptions); var response = await _dio.get('/tools', options: _cacheOptions);
List<dynamic> tools = response.data['tools']; List<dynamic> tools = response.data['tools'];
return tools.firstWhereOrNull( return tools.firstWhereOrNull(
(t) => (t) =>
@@ -71,10 +77,14 @@ class RevancedAPI {
} }
Future<String?> getLatestReleaseVersion( Future<String?> getLatestReleaseVersion(
String extension, String repoName) async { String extension,
String repoName,
) async {
try { try {
Map<String, dynamic>? release = Map<String, dynamic>? release = await _getLatestRelease(
await _getLatestRelease(extension, repoName); extension,
repoName,
);
if (release != null) { if (release != null) {
return release['version']; return release['version'];
} }

View File

@@ -5,10 +5,23 @@ class RootAPI {
final String _postFsDataDirPath = '/data/adb/post-fs-data.d'; final String _postFsDataDirPath = '/data/adb/post-fs-data.d';
final String _serviceDDirPath = '/data/adb/service.d'; final String _serviceDDirPath = '/data/adb/service.d';
Future<bool> isRooted() async {
try {
bool? isRooted = await Root.isRootAvailable();
return isRooted != null && isRooted;
} on Exception {
return false;
}
}
Future<bool> hasRootPermissions() async { Future<bool> hasRootPermissions() async {
try { try {
bool? isRooted = await Root.isRooted(); bool? isRooted = await Root.isRootAvailable();
return isRooted != null && isRooted; if (isRooted != null && isRooted) {
isRooted = await Root.isRooted();
return isRooted != null && isRooted;
}
return false;
} on Exception { } on Exception {
return false; return false;
} }

23
lib/services/toast.dart Normal file
View File

@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:fluttertoast/fluttertoast.dart' as t;
class Toast {
final t.FToast _fToast = t.FToast();
late BuildContext buildContext;
void initialize(BuildContext context) {
_fToast.init(context);
}
void show(String text) {
t.Fluttertoast.showToast(
msg: FlutterI18n.translate(
_fToast.context!,
text,
),
toastLength: t.Toast.LENGTH_LONG,
gravity: t.ToastGravity.CENTER,
);
}
}

View File

@@ -31,53 +31,77 @@ class _AppSelectorViewState extends State<AppSelectorView> {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),
body: SafeArea( body: CustomScrollView(
child: Padding( slivers: [
padding: SliverAppBar(
const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0), pinned: true,
child: Column( floating: true,
children: <Widget>[ snap: false,
SearchBar( title: I18nText(
showSelectIcon: false, 'appSelectorView.viewTitle',
hintText: FlutterI18n.translate( child: Text(
context, '',
'appSelectorView.searchBarHint', style: TextStyle(
color: Theme.of(context).textTheme.headline6!.color,
), ),
onQueryChanged: (searchQuery) {
setState(() {
_query = searchQuery;
});
},
), ),
const SizedBox(height: 12), ),
Expanded( leading: IconButton(
child: model.noApps icon: Icon(
? Center( Icons.arrow_back,
child: I18nText('appSelectorCard.noAppsLabel'), color: Theme.of(context).textTheme.headline6!.color,
)
: model.apps.isEmpty
? const AppSkeletonLoader()
: ListView(
padding: const EdgeInsets.only(bottom: 80),
children: model
.getFilteredApps(_query)
.map((app) => InkWell(
onTap: () {
model.selectApp(app);
Navigator.of(context).pop();
},
child: InstalledAppItem(
name: app.appName,
pkgName: app.packageName,
icon: app.icon,
),
))
.toList(),
),
), ),
], onPressed: () => Navigator.of(context).pop(),
),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(64.0),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0,
horizontal: 12.0,
),
child: SearchBar(
showSelectIcon: false,
hintText: FlutterI18n.translate(
context,
'appSelectorView.searchBarHint',
),
onQueryChanged: (searchQuery) {
setState(() {
_query = searchQuery;
});
},
),
),
),
), ),
), SliverToBoxAdapter(
child: model.noApps
? Center(
child: I18nText('appSelectorCard.noAppsLabel'),
)
: model.apps.isEmpty
? const AppSkeletonLoader()
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0)
.copyWith(bottom: 80),
child: Column(
children: model
.getFilteredApps(_query)
.map((app) => InstalledAppItem(
name: app.appName,
pkgName: app.packageName,
icon: app.icon,
onTap: () {
model.selectApp(app);
Navigator.of(context).pop();
},
))
.toList(),
),
),
),
],
), ),
), ),
); );

View File

@@ -2,16 +2,16 @@ import 'dart:io';
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
class AppSelectorViewModel extends BaseViewModel { class AppSelectorViewModel extends BaseViewModel {
final PatcherAPI _patcherAPI = locator<PatcherAPI>(); final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final Toast _toast = locator<Toast>();
final List<ApplicationWithIcon> apps = []; final List<ApplicationWithIcon> apps = [];
bool noApps = false; bool noApps = false;
@@ -43,9 +43,10 @@ class AppSelectorViewModel extends BaseViewModel {
); );
if (result != null && result.files.single.path != null) { if (result != null && result.files.single.path != null) {
File apkFile = File(result.files.single.path!); File apkFile = File(result.files.single.path!);
ApplicationWithIcon? application = ApplicationWithIcon? application = await DeviceApps.getAppFromStorage(
await DeviceApps.getAppFromStorage(apkFile.path, true) apkFile.path,
as ApplicationWithIcon?; true,
) as ApplicationWithIcon?;
if (application != null) { if (application != null) {
locator<PatcherViewModel>().selectedApp = PatchedApplication( locator<PatcherViewModel>().selectedApp = PatchedApplication(
name: application.appName, name: application.appName,
@@ -54,20 +55,14 @@ class AppSelectorViewModel extends BaseViewModel {
apkFilePath: result.files.single.path!, apkFilePath: result.files.single.path!,
icon: application.icon, icon: application.icon,
patchDate: DateTime.now(), patchDate: DateTime.now(),
isFromStorage: true,
); );
locator<PatcherViewModel>().selectedPatches.clear(); locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().notifyListeners(); locator<PatcherViewModel>().notifyListeners();
} }
} }
} on Exception { } on Exception {
Fluttertoast.showToast( _toast.show('appSelectorView.errorMessage');
msg: FlutterI18n.translate(
context,
'appSelectorView.errorMessage',
),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.CENTER,
);
} }
} }

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:animations/animations.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/homeView/available_updates_card.dart'; import 'package:revanced_manager/ui/widgets/homeView/available_updates_card.dart';
@@ -27,6 +28,7 @@ class HomeView extends StatelessWidget {
child: CustomScrollView( child: CustomScrollView(
slivers: <Widget>[ slivers: <Widget>[
CustomSliverAppBar( CustomSliverAppBar(
isMainView: true,
title: I18nText( title: I18nText(
'homeView.widgetTitle', 'homeView.widgetTitle',
child: Text( child: Text(
@@ -83,9 +85,26 @@ class HomeView extends StatelessWidget {
], ],
), ),
const SizedBox(height: 14), const SizedBox(height: 14),
model.showUpdatableApps PageTransitionSwitcher(
? AvailableUpdatesCard() transitionBuilder:
: InstalledAppsCard(), (child, primaryAnimation, secondaryAnimation) {
return FadeThroughTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
fillColor: Colors.transparent,
child: child,
);
},
layoutBuilder: (entries) {
return Stack(
alignment: Alignment.topCenter,
children: entries,
);
},
child: model.showUpdatableApps
? AvailableUpdatesCard()
: InstalledAppsCard(),
),
], ],
), ),
), ),

View File

@@ -6,24 +6,26 @@ import 'package:device_apps/device_apps.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/app/app.router.dart'; import 'package:revanced_manager/app/app.router.dart';
import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart'; import 'package:stacked_services/stacked_services.dart';
import 'package:timezone/timezone.dart' as tz;
@lazySingleton @lazySingleton
class HomeViewModel extends BaseViewModel { class HomeViewModel extends BaseViewModel {
final NavigationService _navigationService = locator<NavigationService>(); final NavigationService _navigationService = locator<NavigationService>();
final ManagerAPI _managerAPI = locator<ManagerAPI>(); final ManagerAPI _managerAPI = locator<ManagerAPI>();
final PatcherAPI _patcherAPI = locator<PatcherAPI>(); final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final Toast _toast = locator<Toast>();
final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
DateTime? _lastUpdate; DateTime? _lastUpdate;
bool showUpdatableApps = true; bool showUpdatableApps = true;
@@ -38,16 +40,13 @@ class HomeViewModel extends BaseViewModel {
onSelectNotification: (p) => onSelectNotification: (p) =>
DeviceApps.openApp('app.revanced.manager.flutter'), DeviceApps.openApp('app.revanced.manager.flutter'),
); );
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestPermission();
bool isConnected = await Connectivity().checkConnection(); bool isConnected = await Connectivity().checkConnection();
if (!isConnected) { if (!isConnected) {
Fluttertoast.showToast( _toast.show('homeView.noConnection');
msg: FlutterI18n.translate(
context,
'homeView.noConnection',
),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.CENTER,
);
} }
_getPatchedApps(); _getPatchedApps();
_managerAPI.reAssessSavedApps().then((_) => _getPatchedApps()); _managerAPI.reAssessSavedApps().then((_) => _getPatchedApps());
@@ -74,7 +73,10 @@ class HomeViewModel extends BaseViewModel {
} }
void _getPatchedApps() { void _getPatchedApps() {
patchedInstalledApps = _managerAPI.getPatchedApps().toList(); patchedInstalledApps = _managerAPI
.getPatchedApps()
.where((app) => app.hasUpdates == false)
.toList();
patchedUpdatableApps = _managerAPI patchedUpdatableApps = _managerAPI
.getPatchedApps() .getPatchedApps()
.where((app) => app.hasUpdates == true) .where((app) => app.hasUpdates == true)
@@ -99,69 +101,48 @@ class HomeViewModel extends BaseViewModel {
return false; return false;
} }
void updateManager(BuildContext context) async { Future<void> updateManager(BuildContext context) async {
Fluttertoast.showToast( try {
msg: FlutterI18n.translate( _toast.show('homeView.downloadingMessage');
context, File? managerApk = await _managerAPI.downloadManager();
'homeView.downloadingMessage', if (managerApk != null) {
), await flutterLocalNotificationsPlugin.zonedSchedule(
toastLength: Toast.LENGTH_LONG, 0,
gravity: ToastGravity.CENTER, FlutterI18n.translate(
);
File? managerApk = await _managerAPI.downloadManager();
if (managerApk != null) {
flutterLocalNotificationsPlugin.show(
0,
FlutterI18n.translate(
context,
'homeView.notificationTitle',
),
FlutterI18n.translate(
context,
'homeView.notificationText',
),
const NotificationDetails(
android: AndroidNotificationDetails(
'revanced_manager_channel',
'ReVanced Manager Channel',
),
),
);
try {
Fluttertoast.showToast(
msg: FlutterI18n.translate(
context, context,
'homeView.installingMessage', 'homeView.notificationTitle',
), ),
toastLength: Toast.LENGTH_LONG, FlutterI18n.translate(
gravity: ToastGravity.CENTER, context,
'homeView.notificationText',
),
tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)),
const NotificationDetails(
android: AndroidNotificationDetails(
'revanced_manager_channel',
'ReVanced Manager Channel',
importance: Importance.max,
priority: Priority.high,
ticker: 'ticker',
),
),
androidAllowWhileIdle: true,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
); );
_toast.show('homeView.installingMessage');
await AppInstaller.installApk(managerApk.path); await AppInstaller.installApk(managerApk.path);
} on Exception { } else {
Fluttertoast.showToast( _toast.show('homeView.errorDownloadMessage');
msg: FlutterI18n.translate(
context,
'homeView.errorInstallMessage',
),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.CENTER,
);
} }
} else { } on Exception {
Fluttertoast.showToast( _toast.show('homeView.errorInstallMessage');
msg: FlutterI18n.translate(
context,
'homeView.errorDownloadMessage',
),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.CENTER,
);
} }
} }
Future<void> showUpdateConfirmationDialog(BuildContext context) async { Future<void> showUpdateConfirmationDialog(BuildContext parentContext) async {
return showDialog( return showDialog(
context: context, context: parentContext,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: I18nText('homeView.updateDialogTitle'), title: I18nText('homeView.updateDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer, backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
@@ -169,14 +150,14 @@ class HomeViewModel extends BaseViewModel {
actions: <Widget>[ actions: <Widget>[
CustomMaterialButton( CustomMaterialButton(
isFilled: false, isFilled: false,
label: I18nText('cancelButton'), label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
CustomMaterialButton( CustomMaterialButton(
label: I18nText('okButton'), label: I18nText('yesButton'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
updateManager(context); updateManager(parentContext);
}, },
) )
], ],

View File

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart'; import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/installerView/gradient_progress_indicator.dart'; import 'package:revanced_manager/ui/widgets/installerView/gradient_progress_indicator.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_popup_menu.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_popup_menu.dart';
@@ -18,132 +18,137 @@ class InstallerView extends StatelessWidget {
onModelReady: (model) => model.initialize(context), onModelReady: (model) => model.initialize(context),
viewModelBuilder: () => InstallerViewModel(), viewModelBuilder: () => InstallerViewModel(),
builder: (context, model, child) => WillPopScope( builder: (context, model, child) => WillPopScope(
child: Scaffold( child: SafeArea(
body: CustomScrollView( top: false,
controller: model.scrollController, child: Scaffold(
slivers: <Widget>[ body: CustomScrollView(
CustomSliverAppBar( controller: model.scrollController,
title: Text( slivers: <Widget>[
model.headerLogs, CustomSliverAppBar(
style: GoogleFonts.inter( title: Text(
color: Theme.of(context).textTheme.headline6!.color, model.headerLogs,
), style: GoogleFonts.inter(
), color: Theme.of(context).textTheme.headline6!.color,
actions: <Widget>[
Visibility(
visible: !model.isPatching && !model.hasErrors,
child: CustomPopupMenu(
onSelected: (value) => model.onMenuSelection(value),
children: {
0: I18nText(
'installerView.shareApkMenuOption',
child: const Text(
'',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
1: I18nText(
'installerView.shareLogMenuOption',
child: const Text(
'',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
},
), ),
), ),
], onBackButtonPressed: () => model.onWillPop(context),
bottom: PreferredSize( actions: <Widget>[
preferredSize: const Size(double.infinity, 1.0), Visibility(
child: visible: !model.isPatching,
GradientProgressIndicator(progress: model.progress!)), child: CustomPopupMenu(
), onSelected: (value) => model.onMenuSelection(value),
SliverPadding( children: {
padding: const EdgeInsets.all(20.0), if (!model.hasErrors)
sliver: SliverList( 0: I18nText(
delegate: SliverChildListDelegate.fixed( 'installerView.shareApkMenuOption',
<Widget>[ child: const Text(
CustomCard( '',
child: Text( style: TextStyle(
model.logs, fontWeight: FontWeight.bold,
style: GoogleFonts.jetBrainsMono( ),
fontSize: 13, ),
height: 1.5, ),
1: I18nText(
'installerView.shareLogMenuOption',
child: const Text(
'',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
},
),
),
],
bottom: PreferredSize(
preferredSize: const Size(double.infinity, 1.0),
child:
GradientProgressIndicator(progress: model.progress!)),
),
SliverPadding(
padding: const EdgeInsets.all(20.0),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
CustomCard(
child: Text(
model.logs,
style: GoogleFonts.jetBrainsMono(
fontSize: 13,
height: 1.5,
),
), ),
), ),
), ],
], ),
), ),
), ),
), SliverFillRemaining(
SliverFillRemaining( hasScrollBody: false,
hasScrollBody: false, child: Align(
child: Align( alignment: Alignment.bottomCenter,
alignment: Alignment.bottomCenter, child: Visibility(
child: Visibility( visible: !model.isPatching && !model.hasErrors,
visible: !model.isPatching && !model.hasErrors, child: Padding(
child: Padding( padding: const EdgeInsets.all(20.0).copyWith(top: 0.0),
padding: const EdgeInsets.all(20.0).copyWith(top: 0.0), child: Row(
child: Row( mainAxisAlignment: MainAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
children: <Widget>[ Visibility(
Visibility( visible: model.isInstalled,
visible: model.isInstalled, child: CustomMaterialButton(
child: CustomMaterialButton( label: I18nText('installerView.openButton'),
label: I18nText('installerView.openButton'), isExpanded: true,
isExpanded: true, onPressed: () {
onPressed: () { model.openApp();
model.openApp(); model.cleanPatcher();
model.cleanPatcher(); Navigator.of(context).pop();
Navigator.of(context).pop(); },
}, ),
), ),
), Visibility(
Visibility( visible: !model.isInstalled && model.isRooted,
visible: !model.isInstalled, child: CustomMaterialButton(
child: CustomMaterialButton( isFilled: false,
isFilled: false, label:
label: I18nText('installerView.installRootButton'),
I18nText('installerView.installRootButton'), isExpanded: true,
isExpanded: true, onPressed: () => model.installResult(
onPressed: () => model.installResult(true), context,
true,
),
),
), ),
), Visibility(
Visibility( visible: !model.isInstalled,
visible: !model.isInstalled, child: const SizedBox(
child: const SizedBox( width: 16,
width: 16, ),
), ),
), Visibility(
Visibility( visible: !model.isInstalled,
visible: !model.isInstalled, child: CustomMaterialButton(
child: CustomMaterialButton( label: I18nText('installerView.installButton'),
label: I18nText('installerView.installButton'), isExpanded: true,
isExpanded: true, onPressed: () => model.installResult(
onPressed: () => model.installResult(false), context,
false,
),
),
), ),
), ],
], ),
), ),
), ),
), ),
), ),
), ],
], ),
), ),
), ),
onWillPop: () async { onWillPop: () => model.onWillPop(context),
if (!model.isPatching) {
model.cleanPatcher();
Navigator.of(context).pop();
}
return false;
},
), ),
); );
} }

View File

@@ -1,21 +1,27 @@
// ignore_for_file: use_build_context_synchronously
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_background/flutter_background.dart'; import 'package:flutter_background/flutter_background.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
//import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/root_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:wakelock/wakelock.dart'; import 'package:wakelock/wakelock.dart';
class InstallerViewModel extends BaseViewModel { class InstallerViewModel extends BaseViewModel {
final ManagerAPI _managerAPI = locator<ManagerAPI>(); final ManagerAPI _managerAPI = locator<ManagerAPI>();
final PatcherAPI _patcherAPI = locator<PatcherAPI>(); final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final RootAPI _rootAPI = RootAPI();
final Toast _toast = locator<Toast>();
final PatchedApplication _app = locator<PatcherViewModel>().selectedApp!; final PatchedApplication _app = locator<PatcherViewModel>().selectedApp!;
final List<Patch> _patches = locator<PatcherViewModel>().selectedPatches; final List<Patch> _patches = locator<PatcherViewModel>().selectedPatches;
static const _installerChannel = MethodChannel( static const _installerChannel = MethodChannel(
@@ -25,14 +31,16 @@ class InstallerViewModel extends BaseViewModel {
double? progress = 0.0; double? progress = 0.0;
String logs = ''; String logs = '';
String headerLogs = ''; String headerLogs = '';
bool isRooted = false;
bool isPatching = true; bool isPatching = true;
bool isInstalled = false; bool isInstalled = false;
bool hasErrors = false; bool hasErrors = false;
Future<void> initialize(BuildContext context) async { Future<void> initialize(BuildContext context) async {
if (true /*await Permission.ignoreBatteryOptimizations.isGranted*/) { isRooted = await _rootAPI.isRooted();
if (await Permission.ignoreBatteryOptimizations.isGranted) {
try { try {
await FlutterBackground.initialize( FlutterBackground.initialize(
androidConfig: FlutterBackgroundAndroidConfig( androidConfig: FlutterBackgroundAndroidConfig(
notificationTitle: FlutterI18n.translate( notificationTitle: FlutterI18n.translate(
context, context,
@@ -48,8 +56,7 @@ class InstallerViewModel extends BaseViewModel {
defType: 'drawable', defType: 'drawable',
), ),
), ),
); ).then((value) => FlutterBackground.enableBackgroundExecution());
await FlutterBackground.enableBackgroundExecution();
} on Exception { } on Exception {
// ignore // ignore
} }
@@ -76,14 +83,20 @@ class InstallerViewModel extends BaseViewModel {
} }
void update(double value, String header, String log) { void update(double value, String header, String log) {
if (value > 0) { if (value >= 0.0) {
progress = value; progress = value;
} }
isPatching = progress == 1.0 ? false : true; if (value == 0.0) {
if (progress == 0.0) {
logs = ''; logs = '';
isPatching = true;
isInstalled = false; isInstalled = false;
hasErrors = false; hasErrors = false;
} else if (value == 1.0) {
isPatching = false;
hasErrors = false;
} else if (value == -100.0) {
isPatching = false;
hasErrors = true;
} }
if (header.isNotEmpty) { if (header.isNotEmpty) {
headerLogs = header; headerLogs = header;
@@ -93,6 +106,9 @@ class InstallerViewModel extends BaseViewModel {
logs += '\n'; logs += '\n';
} }
logs += log; logs += log;
if (logs[logs.length - 1] == '\n') {
logs = logs.substring(0, logs.length - 1);
}
Future.delayed(const Duration(milliseconds: 500)).then((value) { Future.delayed(const Duration(milliseconds: 500)).then((value) {
scrollController.animateTo( scrollController.animateTo(
scrollController.position.maxScrollExtent, scrollController.position.maxScrollExtent,
@@ -115,46 +131,76 @@ class InstallerViewModel extends BaseViewModel {
_patches, _patches,
); );
} catch (e) { } catch (e) {
hasErrors = true; update(
update(-1.0, 'Aborting...', 'An error occurred! Aborting\nError: $e'); -100.0,
'Aborting...',
'An error occurred! Aborting\nError:\n$e',
);
} }
} else { } else {
hasErrors = true; update(-100.0, 'Aborting...', 'No app or patches selected! Aborting');
update(-1.0, 'Aborting...', 'No app or patches selected! Aborting');
} }
if (true /*await Permission.ignoreBatteryOptimizations.isGranted*/) { if (FlutterBackground.isBackgroundExecutionEnabled) {
try { try {
await FlutterBackground.disableBackgroundExecution(); FlutterBackground.disableBackgroundExecution();
} on Exception { } on Exception {
// ignore // ignore
} }
} }
await Wakelock.disable(); await Wakelock.disable();
isPatching = false;
} }
void installResult(bool installAsRoot) async { void installResult(BuildContext context, bool installAsRoot) async {
_app.isRooted = installAsRoot; _app.isRooted = installAsRoot;
update( bool hasMicroG = _patches.any((p) => p.name.endsWith('microg-support'));
1.0, bool rootMicroG = installAsRoot && hasMicroG;
'Installing...', bool rootFromStorage = installAsRoot && _app.isFromStorage;
_app.isRooted bool ytWithoutRootMicroG =
? 'Installing patched file using root method' !installAsRoot && !hasMicroG && _app.packageName.contains('youtube');
: 'Installing patched file using nonroot method', if (rootMicroG || rootFromStorage || ytWithoutRootMicroG) {
); return showDialog(
isInstalled = await _patcherAPI.installPatchedFile(_app); context: context,
if (isInstalled) { builder: (context) => AlertDialog(
update(1.0, 'Installed!', 'Installed!'); title: I18nText('installerView.installErrorDialogTitle'),
_app.patchDate = DateTime.now(); backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
_app.appliedPatches = _patches.map((p) => p.name).toList(); content: I18nText(
bool hasMicroG = _patches.any((p) => p.name.endsWith('microg-support')); rootMicroG
if (hasMicroG) { ? 'installerView.installErrorDialogText1'
_app.packageName = _app.packageName.replaceFirst( : rootFromStorage
'com.google.', ? 'installerView.installErrorDialogText3'
'app.revanced.', : 'installerView.installErrorDialogText2',
); ),
actions: <Widget>[
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => Navigator.of(context).pop(),
)
],
),
);
} else {
update(
1.0,
'Installing...',
_app.isRooted
? 'Installing patched file using root method'
: 'Installing patched file using nonroot method',
);
isInstalled = await _patcherAPI.installPatchedFile(_app);
if (isInstalled) {
update(1.0, 'Installed!', 'Installed!');
_app.isFromStorage = false;
_app.patchDate = DateTime.now();
_app.appliedPatches = _patches.map((p) => p.name).toList();
if (hasMicroG) {
_app.name += ' ReVanced';
_app.packageName = _app.packageName.replaceFirst(
'com.google.',
'app.revanced.',
);
}
await _managerAPI.savePatchedApp(_app);
} }
await _managerAPI.savePatchedApp(_app);
} }
} }
@@ -187,4 +233,14 @@ class InstallerViewModel extends BaseViewModel {
break; break;
} }
} }
Future<bool> onWillPop(BuildContext context) async {
if (isPatching) {
_toast.show('installerView.noExit');
return false;
}
cleanPatcher();
Navigator.of(context).pop();
return true;
}
} }

View File

@@ -3,8 +3,10 @@ import 'package:dynamic_themes/dynamic_themes.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
//import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/services/root_api.dart'; import 'package:revanced_manager/services/root_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/home/home_view.dart'; import 'package:revanced_manager/ui/views/home/home_view.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_view.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_view.dart';
import 'package:revanced_manager/ui/views/settings/settings_view.dart'; import 'package:revanced_manager/ui/views/settings/settings_view.dart';
@@ -14,29 +16,32 @@ import 'package:stacked/stacked.dart';
@lazySingleton @lazySingleton
class NavigationViewModel extends IndexTrackingViewModel { class NavigationViewModel extends IndexTrackingViewModel {
void initialize(BuildContext context) async { void initialize(BuildContext context) async {
locator<Toast>().initialize(context);
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.getBool('permissionsRequested') == null) {
await prefs.setBool('permissionsRequested', true);
RootAPI().hasRootPermissions().then(
(value) => Permission.requestInstallPackages.request().then(
(value) => Permission.ignoreBatteryOptimizations.request(),
),
);
}
if (prefs.getBool('useDarkTheme') == null) { if (prefs.getBool('useDarkTheme') == null) {
bool isDark = bool isDark =
MediaQuery.of(context).platformBrightness != Brightness.light; MediaQuery.of(context).platformBrightness != Brightness.light;
await prefs.setBool('useDarkTheme', isDark); await prefs.setBool('useDarkTheme', isDark);
await DynamicTheme.of(context)!.setTheme(isDark ? 1 : 0); await DynamicTheme.of(context)!.setTheme(isDark ? 1 : 0);
} }
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
SystemChrome.setSystemUIOverlayStyle( SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle( SystemUiOverlayStyle(
systemNavigationBarColor: systemNavigationBarColor: Colors.transparent,
DynamicTheme.of(context)!.theme.colorScheme.surface,
systemNavigationBarIconBrightness: systemNavigationBarIconBrightness:
DynamicTheme.of(context)!.theme.brightness == Brightness.light DynamicTheme.of(context)!.theme.brightness == Brightness.light
? Brightness.dark ? Brightness.dark
: Brightness.light, : Brightness.light,
), ),
); );
//if (prefs.getBool('permissionsRequested') == null) {
//await prefs.setBool('permissionsRequested', true);
RootAPI().hasRootPermissions();
//Permission.requestInstallPackages.request();
//Permission.ignoreBatteryOptimizations.request();
//}
} }
Widget getViewForIndex(int index) { Widget getViewForIndex(int index) {

View File

@@ -28,6 +28,7 @@ class PatcherView extends StatelessWidget {
body: CustomScrollView( body: CustomScrollView(
slivers: <Widget>[ slivers: <Widget>[
CustomSliverAppBar( CustomSliverAppBar(
isMainView: true,
title: I18nText( title: I18nText(
'patcherView.widgetTitle', 'patcherView.widgetTitle',
child: Text( child: Text(

View File

@@ -1,4 +1,3 @@
import 'package:device_apps/device_apps.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
@@ -6,14 +5,16 @@ import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/app/app.router.dart'; import 'package:revanced_manager/app/app.router.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart'; import 'package:stacked_services/stacked_services.dart';
@lazySingleton @lazySingleton
class PatcherViewModel extends BaseViewModel { class PatcherViewModel extends BaseViewModel {
final NavigationService _navigationService = locator<NavigationService>(); final NavigationService _navigationService = locator<NavigationService>();
final ManagerAPI _managerAPI = locator<ManagerAPI>();
final PatcherAPI _patcherAPI = locator<PatcherAPI>(); final PatcherAPI _patcherAPI = locator<PatcherAPI>();
PatchedApplication? selectedApp; PatchedApplication? selectedApp;
List<Patch> selectedPatches = []; List<Patch> selectedPatches = [];
@@ -39,13 +40,12 @@ class PatcherViewModel extends BaseViewModel {
} }
Future<bool> isValidPatchConfig() async { Future<bool> isValidPatchConfig() async {
bool needsResourcePatching = bool needsResourcePatching = await _patcherAPI.needsResourcePatching(
await _patcherAPI.needsResourcePatching(selectedPatches); selectedPatches,
);
if (needsResourcePatching && selectedApp != null) { if (needsResourcePatching && selectedApp != null) {
Application? app = await DeviceApps.getApp(selectedApp!.packageName); bool isSplit = await _managerAPI.isSplitApk(selectedApp!);
if (app != null && app.isSplit) { return !isSplit;
return false;
}
} }
return true; return true;
} }
@@ -64,11 +64,11 @@ class PatcherViewModel extends BaseViewModel {
actions: <Widget>[ actions: <Widget>[
CustomMaterialButton( CustomMaterialButton(
isFilled: false, isFilled: false,
label: I18nText('cancelButton'), label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
CustomMaterialButton( CustomMaterialButton(
label: I18nText('okButton'), label: I18nText('yesButton'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
navigateToInstaller(); navigateToInstaller();

View File

@@ -33,144 +33,175 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
}, },
), ),
), ),
body: SafeArea( body: CustomScrollView(
child: Padding( slivers: [
padding: SliverAppBar(
const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0), pinned: true,
child: Column( floating: true,
children: <Widget>[ snap: false,
SearchBar( title: I18nText(
showSelectIcon: true, 'patchesSelectorView.viewTitle',
hintText: FlutterI18n.translate( child: Text(
context, '',
'patchesSelectorView.searchBarHint', style: TextStyle(
color: Theme.of(context).textTheme.headline6!.color,
), ),
onQueryChanged: (searchQuery) {
setState(() {
_query = searchQuery;
});
},
onSelectAll: (value) => model.selectAllPatches(value),
), ),
const SizedBox(height: 12), ),
Expanded( leading: IconButton(
child: model.patches.isEmpty icon: Icon(
? Padding( Icons.arrow_back,
padding: const EdgeInsets.all(8.0), color: Theme.of(context).textTheme.headline6!.color,
child: Center( ),
child: I18nText( onPressed: () => Navigator.of(context).pop(),
'patchesSelectorView.noPatchesFound', ),
child: Text( bottom: PreferredSize(
'', preferredSize: const Size.fromHeight(64.0),
style: Theme.of(context).textTheme.bodyMedium, child: Padding(
), padding: const EdgeInsets.symmetric(
), vertical: 8.0,
horizontal: 12.0,
),
child: SearchBar(
showSelectIcon: true,
hintText: FlutterI18n.translate(
context,
'patchesSelectorView.searchBarHint',
),
onQueryChanged: (searchQuery) {
setState(() {
_query = searchQuery;
});
},
onSelectAll: (value) {
if (value) {
model.selectAllPatcherWarning(context);
}
model.selectAllPatches(value);
},
),
),
),
),
SliverToBoxAdapter(
child: model.patches.isEmpty
? Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: I18nText(
'patchesSelectorView.noPatchesFound',
child: Text(
'',
style: Theme.of(context).textTheme.bodyMedium,
), ),
) ),
: ListView( ),
padding: const EdgeInsets.only(bottom: 80), )
children: model : Padding(
.getQueriedPatches(_query) padding: const EdgeInsets.symmetric(horizontal: 12.0)
.map( .copyWith(bottom: 80),
(patch) => PatchItem( child: Column(
name: patch.name, children: model
simpleName: patch.getSimpleName(), .getQueriedPatches(_query)
version: patch.version, .map(
description: patch.description, (patch) => PatchItem(
packageVersion: model.getAppVersion(), name: patch.name,
supportedPackageVersions: simpleName: patch.getSimpleName(),
model.getSupportedVersions(patch), version: patch.version,
isUnsupported: !model.isPatchSupported(patch), description: patch.description,
isSelected: model.isSelected(patch), packageVersion: model.getAppVersion(),
onChanged: (value) => supportedPackageVersions:
model.selectPatch(patch, value), model.getSupportedVersions(patch),
), isUnsupported: !model.isPatchSupported(patch),
/* TODO: Enable this and make use of new Patch Options implementation isSelected: model.isSelected(patch),
patch.hasOptions ? ExpandablePanel( onChanged: (value) =>
controller: expController, model.selectPatch(patch, value),
theme: const ExpandableThemeData( ),
hasIcon: false, /* TODO: Enable this and make use of new Patch Options implementation
tapBodyToExpand: true, patch.hasOptions ? ExpandablePanel(
tapBodyToCollapse: true, controller: expController,
tapHeaderToExpand: true, theme: const ExpandableThemeData(
), hasIcon: false,
header: Column( tapBodyToExpand: true,
children: <Widget>[ tapBodyToCollapse: true,
GestureDetector( tapHeaderToExpand: true,
onLongPress: () => ),
expController.toggle(), header: Column(
child: PatchItem( children: <Widget>[
name: patch.name, GestureDetector(
simpleName: patch.getSimpleName(), onLongPress: () =>
description: patch.description, expController.toggle(),
version: patch.version, child: PatchItem(
packageVersion: name: patch.name,
model.getAppVersion(), simpleName: patch.getSimpleName(),
supportedPackageVersions: model description: patch.description,
.getSupportedVersions(patch), version: patch.version,
isUnsupported: !model packageVersion:
.isPatchSupported(patch), model.getAppVersion(),
isSelected: supportedPackageVersions: model
model.isSelected(patch), .getSupportedVersions(patch),
onChanged: (value) => model isUnsupported: !model
.selectPatch(patch, value), .isPatchSupported(patch),
child: const Padding( isSelected:
padding: EdgeInsets.symmetric( model.isSelected(patch),
vertical: 8.0, onChanged: (value) => model
), .selectPatch(patch, value),
child: Text( child: const Padding(
'Long press for additional options.', padding: EdgeInsets.symmetric(
), vertical: 8.0,
),
child: Text(
'Long press for additional options.',
), ),
), ),
), ),
], ),
],
),
expanded: Padding(
padding: const EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 10,
), ),
expanded: Padding( child: Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 10.0, vertical: 8,
horizontal: 10, horizontal: 8,
), ),
child: Container( decoration: BoxDecoration(
padding: const EdgeInsets.symmetric( color: Theme.of(context)
vertical: 8, .colorScheme
horizontal: 8, .tertiary
), .withOpacity(0.1),
decoration: BoxDecoration( borderRadius:
color: Theme.of(context) BorderRadius.circular(12),
.colorScheme ),
.tertiary child: Column(
.withOpacity(0.1), children: <Widget>[
borderRadius: Text(
BorderRadius.circular(12), 'Patch options',
), style: GoogleFonts.inter(
child: Column( fontSize: 18,
children: <Widget>[ fontWeight: FontWeight.w600,
Text(
'Patch options',
style: GoogleFonts.inter(
fontSize: 18,
fontWeight: FontWeight.w600,
),
), ),
const OptionsTextField( ),
hint: 'App name'), const OptionsTextField(
const OptionsFilePicker( hint: 'App name'),
optionName: 'Choose a logo', const OptionsFilePicker(
), optionName: 'Choose a logo',
], ),
), ],
), ),
), ),
collapsed: Container(), ),
) */ collapsed: Container(),
) ) */
.toList(), )
), .toList(),
), ),
], ),
), ),
), ],
), ),
), ),
); );

View File

@@ -1,10 +1,13 @@
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:flutter_i18n/widgets/I18nText.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:flutter/material.dart';
class PatchesSelectorViewModel extends BaseViewModel { class PatchesSelectorViewModel extends BaseViewModel {
final PatcherAPI _patcherAPI = locator<PatcherAPI>(); final PatcherAPI _patcherAPI = locator<PatcherAPI>();
@@ -17,13 +20,6 @@ class PatchesSelectorViewModel extends BaseViewModel {
locator<PatcherViewModel>().selectedApp!.packageName, locator<PatcherViewModel>().selectedApp!.packageName,
)); ));
patches.sort((a, b) => a.name.compareTo(b.name)); patches.sort((a, b) => a.name.compareTo(b.name));
if (selectedPatches.isEmpty) {
for (Patch patch in patches) {
if (!patch.excluded && isPatchSupported(patch)) {
selectedPatches.add(patch);
}
}
}
notifyListeners(); notifyListeners();
} }
@@ -42,6 +38,23 @@ class PatchesSelectorViewModel extends BaseViewModel {
notifyListeners(); notifyListeners();
} }
Future<void> selectAllPatcherWarning(BuildContext context) {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('patchesSelectorView.selectAllPatchesWarningTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('patchesSelectorView.selectAllPatchesWarningContent'),
actions: <Widget>[
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => Navigator.of(context).pop(),
)
],
),
);
}
void selectAllPatches(bool isSelected) { void selectAllPatches(bool isSelected) {
selectedPatches.clear(); selectedPatches.clear();
if (isSelected) { if (isSelected) {

View File

@@ -13,6 +13,9 @@ import 'package:stacked/stacked.dart';
class SettingsView extends StatelessWidget { class SettingsView extends StatelessWidget {
const SettingsView({Key? key}) : super(key: key); const SettingsView({Key? key}) : super(key: key);
static const _settingsDivider =
Divider(thickness: 1.0, indent: 20.0, endIndent: 20.0);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ViewModelBuilder<SettingsViewModel>.reactive( return ViewModelBuilder<SettingsViewModel>.reactive(
@@ -21,6 +24,7 @@ class SettingsView extends StatelessWidget {
body: CustomScrollView( body: CustomScrollView(
slivers: <Widget>[ slivers: <Widget>[
CustomSliverAppBar( CustomSliverAppBar(
isMainView: true,
title: I18nText( title: I18nText(
'settingsView.widgetTitle', 'settingsView.widgetTitle',
child: Text( child: Text(
@@ -31,122 +35,135 @@ class SettingsView extends StatelessWidget {
), ),
), ),
), ),
SliverPadding( SliverList(
padding: const EdgeInsets.all(20.0), delegate: SliverChildListDelegate.fixed(
sliver: SliverList( <Widget>[
delegate: SliverChildListDelegate.fixed( SettingsSection(
<Widget>[ title: 'settingsView.appearanceSectionTitle',
SettingsSection( children: <Widget>[
title: 'settingsView.appearanceSectionTitle', CustomSwitchTile(
children: <Widget>[ padding: const EdgeInsets.symmetric(horizontal: 20.0),
CustomSwitchTile( title: I18nText(
title: I18nText( 'settingsView.darkThemeLabel',
'settingsView.darkThemeLabel', child: const Text(
child: const Text( '',
'', style: TextStyle(
style: TextStyle( fontSize: 20,
fontSize: 20, fontWeight: FontWeight.w500,
fontWeight: FontWeight.w500,
),
), ),
), ),
subtitle: I18nText('settingsView.darkThemeHint'),
value: model.getDarkThemeStatus(),
onTap: (value) => model.setUseDarkTheme(
context,
value,
),
), ),
FutureBuilder<int>( subtitle: I18nText('settingsView.darkThemeHint'),
future: model.getSdkVersion(), value: model.getDarkThemeStatus(),
builder: (context, snapshot) => Visibility( onTap: (value) => model.setUseDarkTheme(
visible: snapshot.hasData && context,
snapshot.data! >= ANDROID_12_SDK_VERSION, value,
child: CustomSwitchTile( ),
title: I18nText( ),
'settingsView.dynamicThemeLabel', FutureBuilder<int>(
child: const Text( future: model.getSdkVersion(),
'', builder: (context, snapshot) => Visibility(
style: TextStyle( visible: snapshot.hasData &&
fontSize: 20, snapshot.data! >= ANDROID_12_SDK_VERSION,
fontWeight: FontWeight.w500, child: CustomSwitchTile(
), padding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.dynamicThemeLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
), ),
), ),
subtitle: ),
I18nText('settingsView.dynamicThemeHint'), subtitle: I18nText('settingsView.dynamicThemeHint'),
value: model.getDynamicThemeStatus(), value: model.getDynamicThemeStatus(),
onTap: (value) => model.setUseDynamicTheme( onTap: (value) => model.setUseDynamicTheme(
context, context,
value, value,
),
), ),
), ),
), ),
], ),
), ],
SettingsTileDialog( ),
title: 'settingsView.languageLabel', SettingsTileDialog(
subtitle: 'English', padding: const EdgeInsets.symmetric(horizontal: 20.0),
onTap: () => model.showLanguagesDialog(context), title: 'settingsView.languageLabel',
), subtitle: 'English',
const Divider(thickness: 1.0), onTap: () => model.showLanguagesDialog(context),
SettingsSection( ),
title: 'settingsView.patcherSectionTitle', _settingsDivider,
children: <Widget>[ SettingsSection(
SettingsTileDialog( title: 'settingsView.teamSectionTitle',
title: 'settingsView.sourcesLabel', children: <Widget>[
subtitle: 'settingsView.sourcesLabelHint', ListTile(
onTap: () => model.showSourcesDialog(context), contentPadding:
), const EdgeInsets.symmetric(horizontal: 20.0),
], title: I18nText(
), 'settingsView.contributorsLabel',
const Divider(thickness: 1.0), child: const Text(
SettingsSection( '',
title: 'settingsView.teamSectionTitle', style: TextStyle(
children: <Widget>[ fontSize: 20,
ListTile( fontWeight: FontWeight.w500,
contentPadding: EdgeInsets.zero,
title: I18nText(
'settingsView.contributorsLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
), ),
), ),
subtitle: I18nText('settingsView.contributorsHint'),
onTap: () => model.navigateToContributors(),
), ),
const SocialMediaWidget(), subtitle: I18nText('settingsView.contributorsHint'),
], onTap: () => model.navigateToContributors(),
), ),
const Divider(thickness: 1.0), const SocialMediaWidget(
SettingsSection( padding: EdgeInsets.symmetric(horizontal: 20.0),
title: 'settingsView.infoSectionTitle', ),
children: <Widget>[ ],
ListTile( ),
contentPadding: EdgeInsets.zero, _settingsDivider,
title: I18nText( SettingsSection(
'settingsView.logsLabel', title: 'settingsView.advancedSectionTitle',
child: const Text( children: <Widget>[
'', SettingsTileDialog(
style: TextStyle( padding: const EdgeInsets.symmetric(horizontal: 20.0),
fontSize: 20, title: 'settingsView.apiURLLabel',
fontWeight: FontWeight.w500, subtitle: 'settingsView.apiURLHint',
), onTap: () => model.showApiUrlDialog(context),
),
SettingsTileDialog(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
title: 'settingsView.sourcesLabel',
subtitle: 'settingsView.sourcesLabelHint',
onTap: () => model.showSourcesDialog(context),
),
],
),
_settingsDivider,
SettingsSection(
title: 'settingsView.infoSectionTitle',
children: <Widget>[
ListTile(
contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.logsLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
), ),
), ),
subtitle: I18nText('settingsView.logsHint'),
onTap: () => model.exportLogcatLogs(),
), ),
const AboutWidget(), subtitle: I18nText('settingsView.logsHint'),
], onTap: () => model.exportLogcatLogs(),
), ),
], const AboutWidget(
), padding: EdgeInsets.symmetric(horizontal: 20.0),
),
],
),
],
), ),
), ),
], ],

View File

@@ -10,7 +10,7 @@ import 'package:path_provider/path_provider.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/app/app.router.dart'; import 'package:revanced_manager/app/app.router.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart'; import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart';
import 'package:share_extend/share_extend.dart'; import 'package:share_extend/share_extend.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
@@ -27,6 +27,7 @@ class SettingsViewModel extends BaseViewModel {
final TextEditingController _patSourceController = TextEditingController(); final TextEditingController _patSourceController = TextEditingController();
final TextEditingController _orgIntSourceController = TextEditingController(); final TextEditingController _orgIntSourceController = TextEditingController();
final TextEditingController _intSourceController = TextEditingController(); final TextEditingController _intSourceController = TextEditingController();
final TextEditingController _apiUrlController = TextEditingController();
void setLanguage(String language) { void setLanguage(String language) {
notifyListeners(); notifyListeners();
@@ -55,12 +56,6 @@ class SettingsViewModel extends BaseViewModel {
} else { } else {
await DynamicTheme.of(context)!.setTheme(value ? 3 : 1); await DynamicTheme.of(context)!.setTheme(value ? 3 : 1);
} }
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
systemNavigationBarColor:
DynamicTheme.of(context)!.theme.colorScheme.surface,
),
);
notifyListeners(); notifyListeners();
} }
@@ -78,8 +73,6 @@ class SettingsViewModel extends BaseViewModel {
} }
SystemChrome.setSystemUIOverlayStyle( SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle( SystemUiOverlayStyle(
systemNavigationBarColor:
DynamicTheme.of(context)!.theme.colorScheme.surface,
systemNavigationBarIconBrightness: systemNavigationBarIconBrightness:
value ? Brightness.light : Brightness.dark, value ? Brightness.light : Brightness.dark,
), ),
@@ -208,6 +201,65 @@ class SettingsViewModel extends BaseViewModel {
); );
} }
Future<void> showApiUrlDialog(BuildContext context) async {
String apiUrl = _managerAPI.getApiUrl();
_apiUrlController.text = apiUrl.replaceAll('https://', '');
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: Row(
children: <Widget>[
I18nText('settingsView.apiURLLabel'),
const Spacer(),
IconButton(
icon: const Icon(Icons.manage_history_outlined),
onPressed: () => showApiUrlResetDialog(context),
color: Theme.of(context).colorScheme.secondary,
)
],
),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: SingleChildScrollView(
child: Column(
children: <Widget>[
CustomTextField(
leadingIcon: Icon(
Icons.api_outlined,
color: Theme.of(context).colorScheme.secondary,
),
inputController: _apiUrlController,
label: I18nText('settingsView.selectApiURL'),
hint: apiUrl.split('/')[0],
onChanged: (value) => notifyListeners(),
),
],
),
),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),
onPressed: () {
_apiUrlController.clear();
Navigator.of(context).pop();
},
),
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () {
String apiUrl = _apiUrlController.text;
if (!apiUrl.startsWith('https')) {
apiUrl = 'https://$apiUrl';
}
_managerAPI.setApiUrl(apiUrl);
Navigator.of(context).pop();
},
)
],
),
);
}
Future<void> showResetConfirmationDialog(BuildContext context) async { Future<void> showResetConfirmationDialog(BuildContext context) async {
return showDialog( return showDialog(
context: context, context: context,
@@ -218,11 +270,11 @@ class SettingsViewModel extends BaseViewModel {
actions: <Widget>[ actions: <Widget>[
CustomMaterialButton( CustomMaterialButton(
isFilled: false, isFilled: false,
label: I18nText('cancelButton'), label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
CustomMaterialButton( CustomMaterialButton(
label: I18nText('okButton'), label: I18nText('yesButton'),
onPressed: () { onPressed: () {
_managerAPI.setPatchesRepo(''); _managerAPI.setPatchesRepo('');
_managerAPI.setIntegrationsRepo(''); _managerAPI.setIntegrationsRepo('');
@@ -235,6 +287,32 @@ class SettingsViewModel extends BaseViewModel {
); );
} }
Future<void> showApiUrlResetDialog(BuildContext context) async {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('settingsView.sourcesResetDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('settingsView.apiURLResetDialogText'),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton(
label: I18nText('yesButton'),
onPressed: () {
_managerAPI.setApiUrl('');
Navigator.of(context).pop();
Navigator.of(context).pop();
},
)
],
),
);
}
Future<int> getSdkVersion() async { Future<int> getSdkVersion() async {
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo; AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
return info.version.sdkInt ?? -1; return info.version.sdkInt ?? -1;

View File

@@ -34,7 +34,7 @@ class AppInfoView extends StatelessWidget {
), ),
), ),
SliverPadding( SliverPadding(
padding: const EdgeInsets.all(20.0), padding: const EdgeInsets.symmetric(vertical: 20.0),
sliver: SliverList( sliver: SliverList(
delegate: SliverChildListDelegate.fixed( delegate: SliverChildListDelegate.fixed(
<Widget>[ <Widget>[
@@ -61,148 +61,192 @@ class AppInfoView extends StatelessWidget {
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.subtitle1,
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
CustomCard( Padding(
child: IntrinsicHeight( padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Row( child: CustomCard(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, padding: EdgeInsets.zero,
children: <Widget>[ child: SizedBox(
InkWell( height: 94.0,
onTap: () => model.openApp(app), child: Row(
child: Column( mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
children: <Widget>[ Expanded(
Icon( child: Material(
Icons.open_in_new_outlined, type: MaterialType.transparency,
color: child: InkWell(
Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular(16.0),
), onTap: () => model.openApp(app),
const SizedBox(height: 10), child: Column(
I18nText( mainAxisAlignment:
'appInfoView.openButton', MainAxisAlignment.center,
child: Text( children: <Widget>[
'', Icon(
style: TextStyle( Icons.open_in_new_outlined,
color: Theme.of(context)
.colorScheme
.primary,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
VerticalDivider(
color: Theme.of(context).canvasColor,
),
InkWell(
onTap: () => model.showUninstallAlertDialog(
context,
app,
false,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.delete_outline,
color:
Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 10),
I18nText(
'appInfoView.uninstallButton',
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
VerticalDivider(
color: Theme.of(context).canvasColor,
),
InkWell(
onTap: () {
model.navigateToPatcher(app);
Navigator.of(context).pop();
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.build_outlined,
color:
Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 10),
I18nText(
'appInfoView.patchButton',
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
Visibility(
visible: app.isRooted,
child: VerticalDivider(
color: Theme.of(context).canvasColor,
),
),
Visibility(
visible: app.isRooted,
child: InkWell(
onTap: () => model.showUninstallAlertDialog(
context,
app,
true,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.settings_backup_restore_outlined,
color:
Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 10),
I18nText(
'appInfoView.unpatchButton',
child: Text(
'',
style: TextStyle(
color: Theme.of(context) color: Theme.of(context)
.colorScheme .colorScheme
.primary, .primary,
fontWeight: FontWeight.bold,
), ),
), const SizedBox(height: 10),
I18nText(
'appInfoView.openButton',
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
fontWeight: FontWeight.bold,
),
),
),
],
), ),
], ),
), ),
), ),
), VerticalDivider(
], color: Theme.of(context).canvasColor,
indent: 12.0,
endIndent: 12.0,
width: 1.0,
),
Expanded(
child: Material(
type: MaterialType.transparency,
child: InkWell(
borderRadius: BorderRadius.circular(16.0),
onTap: () => model.showUninstallDialog(
context,
app,
false,
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.delete_outline,
color: Theme.of(context)
.colorScheme
.primary,
),
const SizedBox(height: 10),
I18nText(
'appInfoView.uninstallButton',
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
),
),
VerticalDivider(
color: Theme.of(context).canvasColor,
indent: 12.0,
endIndent: 12.0,
width: 1.0,
),
Expanded(
child: Material(
type: MaterialType.transparency,
child: InkWell(
borderRadius: BorderRadius.circular(16.0),
onTap: () {
model.navigateToPatcher(app);
Navigator.of(context).pop();
},
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.build_outlined,
color: Theme.of(context)
.colorScheme
.primary,
),
const SizedBox(height: 10),
I18nText(
'appInfoView.patchButton',
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
),
),
if (app.isRooted)
VerticalDivider(
color: Theme.of(context).canvasColor,
indent: 12.0,
endIndent: 12.0,
width: 1.0,
),
if (app.isRooted)
Expanded(
child: Material(
type: MaterialType.transparency,
child: InkWell(
borderRadius: BorderRadius.circular(16.0),
onTap: () => model.showUninstallDialog(
context,
app,
true,
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons
.settings_backup_restore_outlined,
color: Theme.of(context)
.colorScheme
.primary,
),
const SizedBox(height: 10),
I18nText(
'appInfoView.unpatchButton',
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
),
),
],
),
), ),
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
ListTile( ListTile(
contentPadding: EdgeInsets.zero, contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText( title: I18nText(
'appInfoView.packageNameLabel', 'appInfoView.packageNameLabel',
child: const Text( child: const Text(
@@ -217,7 +261,8 @@ class AppInfoView extends StatelessWidget {
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
ListTile( ListTile(
contentPadding: EdgeInsets.zero, contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText( title: I18nText(
'appInfoView.installTypeLabel', 'appInfoView.installTypeLabel',
child: const Text( child: const Text(
@@ -234,7 +279,8 @@ class AppInfoView extends StatelessWidget {
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
ListTile( ListTile(
contentPadding: EdgeInsets.zero, contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText( title: I18nText(
'appInfoView.patchedDateLabel', 'appInfoView.patchedDateLabel',
child: const Text( child: const Text(
@@ -255,7 +301,8 @@ class AppInfoView extends StatelessWidget {
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
ListTile( ListTile(
contentPadding: EdgeInsets.zero, contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText( title: I18nText(
'appInfoView.appliedPatchesLabel', 'appInfoView.appliedPatchesLabel',
child: const Text( child: const Text(

View File

@@ -1,3 +1,4 @@
// ignore_for_file: use_build_context_synchronously
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
@@ -10,7 +11,7 @@ import 'package:revanced_manager/services/root_api.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:revanced_manager/utils/string.dart'; import 'package:revanced_manager/utils/string.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
@@ -19,19 +20,26 @@ class AppInfoViewModel extends BaseViewModel {
final PatcherAPI _patcherAPI = locator<PatcherAPI>(); final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final RootAPI _rootAPI = RootAPI(); final RootAPI _rootAPI = RootAPI();
Future<void> uninstallApp(PatchedApplication app, bool onlyUnpatch) async { Future<void> uninstallApp(
BuildContext context,
PatchedApplication app,
bool onlyUnpatch,
) async {
bool isUninstalled = true;
if (app.isRooted) { if (app.isRooted) {
bool hasRootPermissions = await _rootAPI.hasRootPermissions(); bool hasRootPermissions = await _rootAPI.hasRootPermissions();
if (hasRootPermissions) { if (hasRootPermissions) {
_rootAPI.deleteApp(app.packageName, app.apkFilePath); await _rootAPI.deleteApp(app.packageName, app.apkFilePath);
_managerAPI.deletePatchedApp(app);
if (!onlyUnpatch) { if (!onlyUnpatch) {
DeviceApps.uninstallApp(app.packageName); await DeviceApps.uninstallApp(app.packageName);
} }
} }
} else { } else {
DeviceApps.uninstallApp(app.packageName); isUninstalled = await DeviceApps.uninstallApp(app.packageName);
_managerAPI.deletePatchedApp(app); }
if (isUninstalled) {
await _managerAPI.deletePatchedApp(app);
locator<HomeViewModel>().initialize(context);
} }
} }
@@ -43,7 +51,7 @@ class AppInfoViewModel extends BaseViewModel {
locator<NavigationViewModel>().setIndex(1); locator<NavigationViewModel>().setIndex(1);
} }
Future<void> showUninstallAlertDialog( Future<void> showUninstallDialog(
BuildContext context, BuildContext context,
PatchedApplication app, PatchedApplication app,
bool onlyUnpatch, bool onlyUnpatch,
@@ -65,38 +73,38 @@ class AppInfoViewModel extends BaseViewModel {
), ),
); );
} else { } else {
return showDialog( if (onlyUnpatch) {
context: context, return showDialog(
builder: (context) => AlertDialog( context: context,
title: I18nText( builder: (context) => AlertDialog(
onlyUnpatch title: I18nText(
? 'appInfoView.unpatchDialogTitle' 'appInfoView.unpatchButton',
: 'appInfoView.uninstallDialogTitle',
),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText(
onlyUnpatch
? 'appInfoView.unpatchDialogText'
: 'appInfoView.uninstallDialogText',
),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),
onPressed: () => Navigator.of(context).pop(),
), ),
CustomMaterialButton( backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
label: I18nText('okButton'), content: I18nText(
onPressed: () { 'appInfoView.unpatchDialogText',
uninstallApp(app, onlyUnpatch); ),
locator<HomeViewModel>().initialize(context); actions: <Widget>[
Navigator.of(context).pop(); CustomMaterialButton(
Navigator.of(context).pop(); isFilled: false,
}, label: I18nText('noButton'),
) onPressed: () => Navigator.of(context).pop(),
], ),
), CustomMaterialButton(
); label: I18nText('yesButton'),
onPressed: () {
uninstallApp(context, app, onlyUnpatch);
Navigator.of(context).pop();
Navigator.of(context).pop();
},
)
],
),
);
} else {
uninstallApp(context, app, onlyUnpatch);
Navigator.of(context).pop();
}
} }
} }

View File

@@ -10,6 +10,7 @@ class AppSkeletonLoader extends StatelessWidget {
return Skeleton( return Skeleton(
isLoading: true, isLoading: true,
skeleton: ListView.builder( skeleton: ListView.builder(
shrinkWrap: true,
itemCount: 7, itemCount: 7,
itemBuilder: (context, index) => Padding( itemBuilder: (context, index) => Padding(
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8.0), padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8.0),

View File

@@ -6,12 +6,14 @@ class InstalledAppItem extends StatefulWidget {
final String name; final String name;
final String pkgName; final String pkgName;
final Uint8List icon; final Uint8List icon;
final Function()? onTap;
const InstalledAppItem({ const InstalledAppItem({
Key? key, Key? key,
required this.name, required this.name,
required this.pkgName, required this.pkgName,
required this.icon, required this.icon,
this.onTap,
}) : super(key: key); }) : super(key: key);
@override @override
@@ -24,6 +26,7 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0), padding: const EdgeInsets.symmetric(vertical: 4.0),
child: CustomCard( child: CustomCard(
onTap: widget.onTap,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[

View File

@@ -33,7 +33,7 @@ class _ContributorsCardState extends State<ContributorsCard> {
'', '',
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w500,
), ),
), ),
), ),

View File

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
class LatestCommitCard extends StatefulWidget { class LatestCommitCard extends StatefulWidget {
@@ -49,7 +49,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
), ),
], ],
), ),
const SizedBox(height: 8), const SizedBox(height: 4),
Row( Row(
children: <Widget>[ children: <Widget>[
I18nText('latestCommitCard.managerLabel'), I18nText('latestCommitCard.managerLabel'),

View File

@@ -1,49 +0,0 @@
import 'package:flutter/material.dart';
class CustomMaterialButton extends StatelessWidget {
final Widget label;
final bool isFilled;
final bool isExpanded;
final Function()? onPressed;
const CustomMaterialButton({
Key? key,
required this.label,
this.isFilled = true,
this.isExpanded = false,
required this.onPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
isExpanded
? const EdgeInsets.symmetric(horizontal: 24, vertical: 12)
: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
),
shape: MaterialStateProperty.all(
StadiumBorder(
side: isFilled
? BorderSide.none
: BorderSide(
width: 1,
color: Theme.of(context).colorScheme.primary,
),
),
),
backgroundColor: MaterialStateProperty.all(
isFilled ? Theme.of(context).colorScheme.primary : Colors.transparent,
),
foregroundColor: MaterialStateProperty.all(
isFilled
? Theme.of(context).colorScheme.surface
: Theme.of(context).colorScheme.primary,
),
),
onPressed: onPressed,
child: label,
);
}
}

View File

@@ -15,61 +15,59 @@ class AppSelectorCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return CustomCard(
onTap: onPressed, onTap: onPressed,
child: CustomCard( child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
children: <Widget>[ I18nText(
I18nText( locator<PatcherViewModel>().selectedApp == null
locator<PatcherViewModel>().selectedApp == null ? 'appSelectorCard.widgetTitle'
? 'appSelectorCard.widgetTitle' : 'appSelectorCard.widgetTitleSelected',
: 'appSelectorCard.widgetTitleSelected', child: const Text(
child: const Text( '',
'', style: TextStyle(
style: TextStyle( fontSize: 18,
fontSize: 18, fontWeight: FontWeight.w500,
fontWeight: FontWeight.w500,
),
), ),
), ),
const SizedBox(height: 10), ),
locator<PatcherViewModel>().selectedApp == null const SizedBox(height: 8),
? I18nText('appSelectorCard.widgetSubtitle') locator<PatcherViewModel>().selectedApp == null
: Row( ? I18nText('appSelectorCard.widgetSubtitle')
children: <Widget>[ : Row(
SizedBox( children: <Widget>[
height: 18.0, SizedBox(
child: ClipOval( height: 18.0,
child: Image.memory( child: ClipOval(
locator<PatcherViewModel>().selectedApp == null child: Image.memory(
? Uint8List(0) locator<PatcherViewModel>().selectedApp == null
: locator<PatcherViewModel>().selectedApp!.icon, ? Uint8List(0)
fit: BoxFit.cover, : locator<PatcherViewModel>().selectedApp!.icon,
), fit: BoxFit.cover,
), ),
), ),
const SizedBox(width: 6), ),
Text(locator<PatcherViewModel>().getAppSelectionString()), const SizedBox(width: 6),
], Text(
), locator<PatcherViewModel>()
locator<PatcherViewModel>().selectedApp == null .getAppSelectionString(),
? Container() style: const TextStyle(fontWeight: FontWeight.w600),
: Column(
children: [
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
locator<PatcherViewModel>()
.getRecommendedVersionString(context),
style: const TextStyle(fontStyle: FontStyle.italic),
),
), ),
], ],
), ),
], locator<PatcherViewModel>().selectedApp == null
), ? Container()
: Column(
children: [
const SizedBox(height: 4),
Text(
locator<PatcherViewModel>()
.getRecommendedVersionString(context),
),
],
),
],
), ),
); );
} }

View File

@@ -15,32 +15,30 @@ class PatchSelectorCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return CustomCard(
onTap: onPressed, onTap: onPressed,
child: CustomCard( child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
children: <Widget>[ I18nText(
I18nText( locator<PatcherViewModel>().selectedPatches.isEmpty
locator<PatcherViewModel>().selectedPatches.isEmpty ? 'patchSelectorCard.widgetTitle'
? 'patchSelectorCard.widgetTitle' : 'patchSelectorCard.widgetTitleSelected',
: 'patchSelectorCard.widgetTitleSelected', child: const Text(
child: const Text( '',
'', style: TextStyle(
style: TextStyle( fontSize: 18,
fontSize: 18, fontWeight: FontWeight.w500,
fontWeight: FontWeight.w500,
),
), ),
), ),
const SizedBox(height: 10), ),
locator<PatcherViewModel>().selectedApp == null const SizedBox(height: 4),
? I18nText('patchSelectorCard.widgetSubtitle') locator<PatcherViewModel>().selectedApp == null
: locator<PatcherViewModel>().selectedPatches.isEmpty ? I18nText('patchSelectorCard.widgetSubtitle')
? I18nText('patchSelectorCard.widgetEmptySubtitle') : locator<PatcherViewModel>().selectedPatches.isEmpty
: Text(_getPatchesSelection()), ? I18nText('patchSelectorCard.widgetEmptySubtitle')
], : Text(_getPatchesSelection()),
), ],
), ),
); );
} }
@@ -48,7 +46,7 @@ class PatchSelectorCard extends StatelessWidget {
String _getPatchesSelection() { String _getPatchesSelection() {
String text = ''; String text = '';
for (Patch p in locator<PatcherViewModel>().selectedPatches) { for (Patch p in locator<PatcherViewModel>().selectedPatches) {
text += '${p.getSimpleName()} (v${p.version})\n'; text += '\u2022 ${p.getSimpleName()} (v${p.version})\n';
} }
return text.substring(0, text.length - 1); return text.substring(0, text.length - 1);
} }

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
@@ -39,102 +39,109 @@ class _PatchItemState extends State<PatchItem> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0), padding: const EdgeInsets.symmetric(vertical: 4.0),
child: InkWell( child: CustomCard(
borderRadius: BorderRadius.circular(16),
onTap: () { onTap: () {
setState(() => widget.isSelected = !widget.isSelected); setState(() => widget.isSelected = !widget.isSelected);
widget.onChanged(widget.isSelected); widget.onChanged(widget.isSelected);
}, },
child: CustomCard( child: Column(
child: Column( children: <Widget>[
children: <Widget>[ Row(
Row( mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[
children: <Widget>[ Flexible(
Flexible( child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
children: <Widget>[ Row(
Row( crossAxisAlignment: CrossAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end, children: <Widget>[
children: <Widget>[ Text(
Text( widget.simpleName,
widget.simpleName, maxLines: 2,
style: const TextStyle( overflow: TextOverflow.visible,
fontSize: 16, style: const TextStyle(
fontWeight: FontWeight.w600, fontSize: 16,
), fontWeight: FontWeight.w600,
), ),
const SizedBox(width: 4), ),
Text(widget.version) const SizedBox(width: 6),
], Text(
), widget.version,
const SizedBox(height: 4), style: TextStyle(
Text( fontSize: 16,
widget.description, color: Theme.of(context).colorScheme.secondary,
softWrap: true, ),
maxLines: 3, ),
overflow: TextOverflow.visible, ],
style: const TextStyle(fontSize: 14),
),
],
),
),
Transform.scale(
scale: 1.2,
child: Checkbox(
value: widget.isSelected,
activeColor: Theme.of(context).colorScheme.primary,
checkColor:
Theme.of(context).colorScheme.secondaryContainer,
side: BorderSide(
width: 2.0,
color: Theme.of(context).colorScheme.primary,
), ),
onChanged: (newValue) { const SizedBox(height: 4),
setState(() => widget.isSelected = newValue!); Text(
widget.onChanged(widget.isSelected); widget.description,
}, softWrap: true,
maxLines: 3,
overflow: TextOverflow.visible,
style: TextStyle(
fontSize: 14,
color: Theme.of(context).colorScheme.onSecondaryContainer,
),
),
],
),
),
Transform.scale(
scale: 1.2,
child: Checkbox(
value: widget.isSelected,
activeColor: Theme.of(context).colorScheme.primary,
checkColor:
Theme.of(context).colorScheme.secondaryContainer,
side: BorderSide(
width: 2.0,
color: Theme.of(context).colorScheme.primary,
), ),
) onChanged: (newValue) {
], setState(() => widget.isSelected = newValue!);
), widget.onChanged(widget.isSelected);
widget.isUnsupported },
? Row( ),
children: <Widget>[ )
Padding( ],
padding: const EdgeInsets.only(top: 8), ),
child: TextButton.icon( widget.isUnsupported
label: ? Row(
I18nText('patchItem.unsupportedWarningButton'), children: <Widget>[
icon: const Icon(Icons.warning), Padding(
onPressed: () => _showUnsupportedWarningDialog(), padding: const EdgeInsets.only(top: 8),
style: ButtonStyle( child: TextButton.icon(
shape: MaterialStateProperty.all( label: I18nText('patchItem.unsupportedWarningButton'),
RoundedRectangleBorder( icon: const Icon(Icons.warning, size: 20.0),
borderRadius: BorderRadius.circular(12), onPressed: () => _showUnsupportedWarningDialog(),
side: BorderSide( style: ButtonStyle(
width: 1, shape: MaterialStateProperty.all(
color: RoundedRectangleBorder(
Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(8),
), side: BorderSide(
width: 1,
color:
Theme.of(context).colorScheme.secondary,
), ),
), ),
backgroundColor: MaterialStateProperty.all( ),
Colors.transparent, backgroundColor: MaterialStateProperty.all(
), Colors.transparent,
foregroundColor: MaterialStateProperty.all( ),
Theme.of(context).colorScheme.secondary, foregroundColor: MaterialStateProperty.all(
), Theme.of(context).colorScheme.secondary,
), ),
), ),
), ),
], ),
) ],
: Container(), )
widget.child ?? const SizedBox(), : Container(),
], widget.child ?? const SizedBox(),
), ],
), ),
), ),
); );
@@ -151,7 +158,7 @@ class _PatchItemState extends State<PatchItem> {
translationParams: { translationParams: {
'packageVersion': widget.packageVersion, 'packageVersion': widget.packageVersion,
'supportedVersions': 'supportedVersions':
'\u2022 ${widget.supportedPackageVersions.join('\n\u2022 ')}', '\u2022 ${widget.supportedPackageVersions.reversed.join('\n\u2022 ')}',
}, },
), ),
actions: <Widget>[ actions: <Widget>[

View File

@@ -4,7 +4,9 @@ import 'package:revanced_manager/utils/about_info.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
class AboutWidget extends StatefulWidget { class AboutWidget extends StatefulWidget {
const AboutWidget({Key? key}) : super(key: key); const AboutWidget({Key? key, this.padding}) : super(key: key);
final EdgeInsetsGeometry? padding;
@override @override
State<AboutWidget> createState() => _AboutWidgetState(); State<AboutWidget> createState() => _AboutWidgetState();
@@ -13,28 +15,15 @@ class AboutWidget extends StatefulWidget {
class _AboutWidgetState extends State<AboutWidget> { class _AboutWidgetState extends State<AboutWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return FutureBuilder<Map<String, dynamic>>(
padding: const EdgeInsets.symmetric(vertical: 8.0), future: AboutInfo.getInfo(),
child: Column( builder: (context, snapshot) {
crossAxisAlignment: CrossAxisAlignment.start, return Padding(
children: <Widget>[ padding: const EdgeInsets.symmetric(vertical: 8.0),
I18nText( child: ListTile(
'settingsView.aboutLabel', contentPadding: widget.padding ?? EdgeInsets.zero,
child: const Text( onLongPress: snapshot.hasData
'', ? () {
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 4),
FutureBuilder<Map<String, dynamic>>(
future: AboutInfo.getInfo(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return GestureDetector(
onLongPress: () {
Clipboard.setData( Clipboard.setData(
ClipboardData( ClipboardData(
text: 'Version: ${snapshot.data!['version']}\n' text: 'Version: ${snapshot.data!['version']}\n'
@@ -50,8 +39,20 @@ class _AboutWidgetState extends State<AboutWidget> {
Theme.of(context).colorScheme.secondary, Theme.of(context).colorScheme.secondary,
), ),
); );
}, }
child: Column( : null,
title: I18nText(
'settingsView.aboutLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
subtitle: snapshot.hasData
? Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
@@ -90,15 +91,11 @@ class _AboutWidgetState extends State<AboutWidget> {
), ),
), ),
], ],
), )
); : const SizedBox(),
} else {
return Container();
}
},
), ),
], );
), },
); );
} }
} }

View File

@@ -6,6 +6,7 @@ class CustomSwitchTile extends StatelessWidget {
final Widget subtitle; final Widget subtitle;
final bool value; final bool value;
final Function(bool) onTap; final Function(bool) onTap;
final EdgeInsetsGeometry? padding;
const CustomSwitchTile({ const CustomSwitchTile({
Key? key, Key? key,
@@ -13,14 +14,16 @@ class CustomSwitchTile extends StatelessWidget {
required this.subtitle, required this.subtitle,
required this.value, required this.value,
required this.onTap, required this.onTap,
this.padding,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListTile( return ListTile(
contentPadding: EdgeInsets.zero, contentPadding: padding ?? EdgeInsets.zero,
title: title, title: title,
subtitle: subtitle, subtitle: subtitle,
onTap: () => onTap(!value),
trailing: CustomSwitch( trailing: CustomSwitch(
value: value, value: value,
onChanged: onTap, onChanged: onTap,

View File

@@ -17,7 +17,7 @@ class SettingsSection extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
padding: const EdgeInsets.only(top: 16.0, bottom: 10.0), padding: const EdgeInsets.only(top: 16.0, bottom: 10.0, left: 20.0),
child: I18nText( child: I18nText(
title, title,
child: Text( child: Text(

View File

@@ -5,18 +5,20 @@ class SettingsTileDialog extends StatelessWidget {
final String title; final String title;
final String subtitle; final String subtitle;
final Function()? onTap; final Function()? onTap;
final EdgeInsetsGeometry? padding;
const SettingsTileDialog({ const SettingsTileDialog({
Key? key, Key? key,
required this.title, required this.title,
required this.subtitle, required this.subtitle,
required this.onTap, required this.onTap,
this.padding,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListTile( return ListTile(
contentPadding: EdgeInsets.zero, contentPadding: padding ?? EdgeInsets.zero,
title: I18nText( title: I18nText(
title, title,
child: const Text( child: const Text(

View File

@@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class SocialMediaItem extends StatelessWidget {
final Widget? icon;
final Widget title;
final Widget? subtitle;
final String? url;
const SocialMediaItem({
Key? key,
this.icon,
required this.title,
this.subtitle,
this.url,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListTile(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
contentPadding: EdgeInsets.zero,
leading: SizedBox(
width: 48.0,
child: Center(
child: icon,
),
),
title: DefaultTextStyle(
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.onSecondaryContainer,
),
child: title,
),
subtitle: subtitle != null
? DefaultTextStyle(
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.primary,
),
child: subtitle!,
)
: null,
onTap: () => url != null
? launchUrl(
Uri.parse(url!),
mode: LaunchMode.externalApplication,
)
: null,
);
}
}

View File

@@ -2,11 +2,16 @@ import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:revanced_manager/ui/widgets/settingsView/social_media_item.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
import 'package:url_launcher/url_launcher.dart';
class SocialMediaWidget extends StatelessWidget { class SocialMediaWidget extends StatelessWidget {
const SocialMediaWidget({Key? key}) : super(key: key); final EdgeInsetsGeometry? padding;
const SocialMediaWidget({
Key? key,
this.padding,
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -14,11 +19,13 @@ class SocialMediaWidget extends StatelessWidget {
theme: ExpandableThemeData( theme: ExpandableThemeData(
hasIcon: true, hasIcon: true,
iconColor: Theme.of(context).iconTheme.color, iconColor: Theme.of(context).iconTheme.color,
iconPadding: const EdgeInsets.symmetric(vertical: 16.0), iconPadding: const EdgeInsets.symmetric(vertical: 16.0)
.add(padding ?? EdgeInsets.zero)
.resolve(Directionality.of(context)),
animationDuration: const Duration(milliseconds: 400), animationDuration: const Duration(milliseconds: 400),
), ),
header: ListTile( header: ListTile(
contentPadding: EdgeInsets.zero, contentPadding: padding ?? EdgeInsets.zero,
title: I18nText( title: I18nText(
'socialMediaCard.widgetTitle', 'socialMediaCard.widgetTitle',
child: const Text( child: const Text(
@@ -31,169 +38,52 @@ class SocialMediaWidget extends StatelessWidget {
), ),
subtitle: I18nText('socialMediaCard.widgetSubtitle'), subtitle: I18nText('socialMediaCard.widgetSubtitle'),
), ),
expanded: CustomCard( expanded: Padding(
child: Column( padding: padding ?? EdgeInsets.zero,
children: <Widget>[ child: CustomCard(
ListTile( child: Column(
contentPadding: EdgeInsets.zero, children: const <Widget>[
leading: Padding( SocialMediaItem(
padding: const EdgeInsets.all(8.0), icon: FaIcon(FontAwesomeIcons.github),
child: FaIcon( title: Text('GitHub'),
FontAwesomeIcons.github, subtitle: Text('github.com/revanced'),
color: Theme.of(context).colorScheme.secondary, url: 'https://github.com/revanced',
),
), ),
title: Text( SocialMediaItem(
'GitHub', icon: FaIcon(FontAwesomeIcons.discord),
style: TextStyle( title: Text('Discord'),
color: Theme.of(context).colorScheme.secondary, subtitle: Text('discord.gg/revanced'),
), url: 'https://discord.gg/rF2YcEjcrT',
), ),
subtitle: Text( SocialMediaItem(
'github.com/revanced', icon: FaIcon(FontAwesomeIcons.telegram),
style: TextStyle( title: Text('Telegram'),
color: Theme.of(context).colorScheme.secondary, subtitle: Text('t.me/app_revanced'),
), url: 'https://t.me/app_revanced',
), ),
onTap: () => launchUrl( SocialMediaItem(
Uri.parse('https://github.com/revanced'), icon: FaIcon(FontAwesomeIcons.reddit),
mode: LaunchMode.externalApplication, title: Text('Reddit'),
subtitle: Text('r/revancedapp'),
url: 'https://reddit.com/r/revancedapp',
), ),
), SocialMediaItem(
ListTile( icon: FaIcon(FontAwesomeIcons.twitter),
contentPadding: EdgeInsets.zero, title: Text('Twitter'),
leading: Padding( subtitle: Text('@revancedapp'),
padding: const EdgeInsets.all(8.0).copyWith(left: 5), url: 'https://twitter.com/revancedapp',
child: FaIcon(
FontAwesomeIcons.discord,
color: Theme.of(context).colorScheme.secondary,
),
), ),
title: Text( SocialMediaItem(
'Discord', icon: FaIcon(FontAwesomeIcons.youtube),
style: TextStyle( title: Text('YouTube'),
color: Theme.of(context).colorScheme.secondary, subtitle: Text('youtube.com/revanced'),
), url: 'https://youtube.com/revanced',
), ),
subtitle: Text( ],
'discord.gg/revanced', ),
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
onTap: () => launchUrl(
Uri.parse('https://discord.gg/rF2YcEjcrT'),
mode: LaunchMode.externalApplication,
),
),
ListTile(
contentPadding: EdgeInsets.zero,
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: FaIcon(
FontAwesomeIcons.telegram,
color: Theme.of(context).colorScheme.secondary,
),
),
title: Text(
'Telegram',
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
subtitle: Text(
't.me/app_revanced',
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
onTap: () => launchUrl(
Uri.parse('https://t.me/app_revanced'),
mode: LaunchMode.externalApplication,
),
),
ListTile(
contentPadding: EdgeInsets.zero,
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: FaIcon(
FontAwesomeIcons.reddit,
color: Theme.of(context).colorScheme.secondary,
),
),
title: Text(
'Reddit',
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
subtitle: Text(
'r/revancedapp',
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
onTap: () => launchUrl(
Uri.parse('https://reddit.com/r/revancedapp'),
mode: LaunchMode.externalApplication,
),
),
ListTile(
contentPadding: EdgeInsets.zero,
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: FaIcon(
FontAwesomeIcons.twitter,
color: Theme.of(context).colorScheme.secondary,
),
),
title: Text(
'Twitter',
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
subtitle: Text(
'@revancedapp',
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
onTap: () => launchUrl(
Uri.parse('https://twitter.com/revancedapp'),
mode: LaunchMode.externalApplication,
),
),
ListTile(
contentPadding: EdgeInsets.zero,
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: FaIcon(
FontAwesomeIcons.youtube,
color: Theme.of(context).colorScheme.secondary,
),
),
title: Text(
'YouTube',
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
subtitle: Text(
'youtube.com/revanced',
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
onTap: () => launchUrl(
Uri.parse('https://youtube.com/revanced'),
mode: LaunchMode.externalApplication,
),
),
],
), ),
), ),
collapsed: Container(), collapsed: const SizedBox(),
); );
} }
} }

View File

@@ -1,7 +1,7 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
import 'package:expandable/expandable.dart'; import 'package:expandable/expandable.dart';
import 'package:timeago/timeago.dart'; import 'package:timeago/timeago.dart';
@@ -50,92 +50,94 @@ class _ApplicationItemState extends State<ApplicationItem>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ExpandableController expController = ExpandableController(); ExpandableController expController = ExpandableController();
return ExpandablePanel( return Container(
controller: expController, margin: const EdgeInsets.only(bottom: 16.0),
theme: const ExpandableThemeData( child: CustomCard(
inkWellBorderRadius: BorderRadius.all(Radius.circular(16)), onTap: () {
tapBodyToCollapse: false, expController.toggle();
tapBodyToExpand: false, _animationController.isCompleted
tapHeaderToExpand: false, ? _animationController.reverse()
hasIcon: false, : _animationController.forward();
animationDuration: Duration(milliseconds: 450), },
), child: ExpandablePanel(
header: CustomCard( controller: expController,
child: Row( theme: const ExpandableThemeData(
children: <Widget>[ inkWellBorderRadius: BorderRadius.all(Radius.circular(16)),
SizedBox( tapBodyToCollapse: false,
width: 40, tapBodyToExpand: false,
child: Image.memory(widget.icon, height: 40, width: 40), tapHeaderToExpand: false,
), hasIcon: false,
const SizedBox(width: 4), animationDuration: Duration(milliseconds: 450),
Padding( ),
padding: const EdgeInsets.only(left: 15.0), header: Row(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( SizedBox(
widget.name.length > 10 width: 40,
? '${widget.name.substring(0, 10)}...' child: Image.memory(widget.icon, height: 40, width: 40),
: widget.name, ),
style: const TextStyle( const SizedBox(width: 4),
fontSize: 16, Padding(
fontWeight: FontWeight.w500, padding: const EdgeInsets.only(left: 15.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.name.length > 12
? '${widget.name.substring(0, 12)}...'
: widget.name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
Text(format(widget.patchDate)),
],
), ),
), ),
Text(format(widget.patchDate)), const Spacer(),
RotationTransition(
turns: Tween(begin: 0.0, end: 0.50)
.animate(_animationController),
child: const Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.arrow_drop_down),
),
),
const SizedBox(width: 8),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
CustomMaterialButton(
label: widget.isUpdatableApp
? I18nText('applicationItem.patchButton')
: I18nText('applicationItem.infoButton'),
onPressed: widget.onPressed,
),
],
),
], ],
), ),
), collapsed: const SizedBox(),
const Spacer(), expanded: Padding(
Padding( padding: const EdgeInsets.only(top: 16.0, left: 4.0, right: 4.0, bottom: 4.0),
padding: const EdgeInsets.only(right: 5.0), child: Column(
child: RotationTransition( crossAxisAlignment: CrossAxisAlignment.start,
turns:
Tween(begin: 0.0, end: 0.50).animate(_animationController),
child: IconButton(
onPressed: () {
expController.toggle();
_animationController.isCompleted
? _animationController.reverse()
: _animationController.forward();
},
icon: const Icon(Icons.arrow_drop_down),
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[ children: <Widget>[
CustomMaterialButton( I18nText(
label: widget.isUpdatableApp 'applicationItem.changelogLabel',
? I18nText('applicationItem.patchButton') child: const Text(
: I18nText('applicationItem.infoButton'), '',
onPressed: widget.onPressed, style: TextStyle(fontWeight: FontWeight.w700),
),
), ),
const SizedBox(height: 4),
Text('\u2022 ${widget.changelog.join('\n\u2022 ')}'),
], ],
), ),
], ),
), ),
), )
collapsed: const Text(''),
expanded: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
I18nText(
'applicationItem.changelogLabel',
child: const Text(
'',
style: TextStyle(fontWeight: FontWeight.w700),
),
),
const SizedBox(height: 4),
Text('\u2022 ${widget.changelog.join('\n\u2022 ')}'),
],
),
),
); );
} }
} }

View File

@@ -3,30 +3,33 @@ import 'package:flutter/material.dart';
class CustomCard extends StatelessWidget { class CustomCard extends StatelessWidget {
final bool isFilled; final bool isFilled;
final Widget child; final Widget child;
final Function()? onTap;
final EdgeInsetsGeometry? padding;
const CustomCard({ const CustomCard({
Key? key, Key? key,
this.isFilled = true, this.isFilled = true,
required this.child, required this.child,
this.onTap,
this.padding,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Material(
decoration: BoxDecoration( type: isFilled ? MaterialType.card : MaterialType.transparency,
color: isFilled
? Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4)
: Colors.transparent,
borderRadius: BorderRadius.circular(16),
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
color: isFilled child: Padding(
? Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.40) padding: padding ?? const EdgeInsets.all(20.0),
: Colors.transparent, child: child,
border: isFilled ),
? null
: Border.all(
width: 1,
color: Theme.of(context).colorScheme.secondary,
),
), ),
padding: const EdgeInsets.all(20),
child: child,
); );
} }
} }

View File

@@ -0,0 +1,130 @@
import 'package:flutter/material.dart';
class CustomMaterialButton extends StatelessWidget {
final Widget label;
final bool isFilled;
final bool isExpanded;
final Function()? onPressed;
const CustomMaterialButton({
Key? key,
required this.label,
this.isFilled = true,
this.isExpanded = false,
required this.onPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
isExpanded
? const EdgeInsets.symmetric(horizontal: 24, vertical: 12)
: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
),
shape: MaterialStateProperty.all(
StadiumBorder(
side: isFilled
? BorderSide.none
: BorderSide(
width: 1,
color: Theme.of(context).colorScheme.primary,
),
),
),
backgroundColor: MaterialStateProperty.all(
isFilled ? Theme.of(context).colorScheme.primary : Colors.transparent,
),
foregroundColor: MaterialStateProperty.all(
isFilled
? Theme.of(context).colorScheme.surface
: Theme.of(context).colorScheme.primary,
),
),
onPressed: onPressed,
child: label,
);
}
}
// ignore: must_be_immutable
class TimerButton extends StatefulWidget {
Widget label;
bool isFilled;
int seconds;
final bool isRunning;
final Function()? onTimerEnd;
TimerButton({
Key? key,
required this.seconds,
required this.isRunning,
required this.onTimerEnd,
this.label = const Text(''),
this.isFilled = true,
}) : super(key: key);
@override
State<TimerButton> createState() => _TimerButtonState();
}
class _TimerButtonState extends State<TimerButton> {
void timer(int seconds) {
Future.delayed(const Duration(seconds: 1), () {
if (seconds > 0) {
setState(() {
seconds--;
});
timer(seconds);
} else {
widget.onTimerEnd!();
}
});
}
@override
void initState() {
//decrement seconds
if (widget.isRunning) {
timer(widget.seconds);
}
super.initState();
}
@override
Widget build(BuildContext build) {
return TextButton(
style: ButtonStyle(
shape: MaterialStateProperty.all(
StadiumBorder(
side: widget.isFilled
? BorderSide.none
: BorderSide(
width: 1,
color: Theme.of(context).colorScheme.primary,
),
),
),
backgroundColor: MaterialStateProperty.all(
widget.isFilled
? Theme.of(context).colorScheme.primary
: Colors.transparent,
),
foregroundColor: MaterialStateProperty.all(
widget.isFilled
? Theme.of(context).colorScheme.surface
: Theme.of(context).colorScheme.primary,
),
),
onPressed: widget.isRunning ? null : widget.onTimerEnd,
child: Text(
widget.isRunning ? '${widget.seconds}' : 'Install',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
);
}
}

View File

@@ -4,12 +4,16 @@ class CustomSliverAppBar extends StatelessWidget {
final Widget title; final Widget title;
final List<Widget>? actions; final List<Widget>? actions;
final PreferredSizeWidget? bottom; final PreferredSizeWidget? bottom;
final bool isMainView;
final Function()? onBackButtonPressed;
const CustomSliverAppBar({ const CustomSliverAppBar({
Key? key, Key? key,
required this.title, required this.title,
this.actions, this.actions,
this.bottom, this.bottom,
this.isMainView = false,
this.onBackButtonPressed,
}) : super(key: key); }) : super(key: key);
@override @override
@@ -19,16 +23,29 @@ class CustomSliverAppBar extends StatelessWidget {
snap: false, snap: false,
floating: false, floating: false,
expandedHeight: 100.0, expandedHeight: 100.0,
automaticallyImplyLeading: false, automaticallyImplyLeading: !isMainView,
flexibleSpace: FlexibleSpaceBar(
titlePadding: EdgeInsets.only(
bottom: bottom != null ? 16.0 : 14.0,
left: isMainView ? 20.0 : 55.0,
),
title: title,
),
leading: isMainView
? null
: IconButton(
icon: Icon(
Icons.arrow_back,
color: Theme.of(context).textTheme.headline6!.color,
),
onPressed:
onBackButtonPressed ?? () => Navigator.of(context).pop(),
),
backgroundColor: MaterialStateColor.resolveWith( backgroundColor: MaterialStateColor.resolveWith(
(states) => states.contains(MaterialState.scrolledUnder) (states) => states.contains(MaterialState.scrolledUnder)
? Theme.of(context).colorScheme.surface ? Theme.of(context).colorScheme.surface
: Theme.of(context).canvasColor, : Theme.of(context).canvasColor,
), ),
flexibleSpace: FlexibleSpaceBar(
titlePadding: const EdgeInsets.only(bottom: 16.0, left: 20.0),
title: title,
),
actions: actions, actions: actions,
bottom: bottom, bottom: bottom,
); );

View File

@@ -21,7 +21,7 @@ class SearchBar extends StatefulWidget {
class _SearchBarState extends State<SearchBar> { class _SearchBarState extends State<SearchBar> {
final TextEditingController _textController = TextEditingController(); final TextEditingController _textController = TextEditingController();
bool _toggleSelectAll = true; bool _toggleSelectAll = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
publish_to: 'none' publish_to: 'none'
version: 0.0.10+10 version: 0.0.26+26
environment: environment:
sdk: ">=2.17.5 <3.0.0" sdk: ">=2.17.5 <3.0.0"
@@ -20,6 +20,7 @@ dependencies:
ref: revanced-manager ref: revanced-manager
device_info_plus: ^4.1.2 device_info_plus: ^4.1.2
dio: ^4.0.6 dio: ^4.0.6
dio_http2_adapter: ^2.0.0
dio_http_cache_lts: ^0.4.1 dio_http_cache_lts: ^0.4.1
dynamic_color: ^1.5.4 dynamic_color: ^1.5.4
dynamic_themes: ^1.1.0 dynamic_themes: ^1.1.0
@@ -52,9 +53,12 @@ dependencies:
ref: feature/nullSafe ref: feature/nullSafe
package_info_plus: ^1.4.3+1 package_info_plus: ^1.4.3+1
path_provider: ^2.0.11 path_provider: ^2.0.11
#permission_handler: ^10.0.0 permission_handler: ^10.0.0
pull_to_refresh: ^2.0.0 pull_to_refresh: ^2.0.0
root: ^2.0.2 root:
git:
url: https://github.com/gokul1630/root
ref: main
share_extend: ^2.0.0 share_extend: ^2.0.0
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
skeletons: ^0.0.3 skeletons: ^0.0.3
@@ -63,6 +67,7 @@ dependencies:
stacked_services: ^0.9.3 stacked_services: ^0.9.3
stacked_themes: ^0.3.9 stacked_themes: ^0.3.9
timeago: ^3.2.2 timeago: ^3.2.2
timezone: ^0.8.0
url_launcher: ^6.1.5 url_launcher: ^6.1.5
wakelock: ^0.6.2 wakelock: ^0.6.2

View File

@@ -1,30 +0,0 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:revanced_manager/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}