From b06cc39d61b05ff340192c1b5df6c57724a53e83 Mon Sep 17 00:00:00 2001
From: Ax333l
Date: Tue, 14 Jan 2025 00:21:33 +0100
Subject: [PATCH] feat: Move implementation from the manager repo
---
.github/ISSUE_TEMPLATE/bug_report.yml | 18 +++---
.github/ISSUE_TEMPLATE/config.yml | 2 +-
.github/ISSUE_TEMPLATE/feature_request.yml | 22 +++----
README.md | 64 ++++---------------
build.gradle.kts | 2 +-
proguard-rules.pro | 2 +-
settings.gradle.kts | 2 +-
src/main/AndroidManifest.xml | 6 +-
.../apkmirror/APKMirrorDownloader.kt | 23 +++++++
.../downloader/example/ExampleDownloader.kt | 42 ------------
src/main/res/values/strings.xml | 2 +-
11 files changed, 61 insertions(+), 124 deletions(-)
create mode 100644 src/main/kotlin/app/revanced/manager/plugin/downloader/apkmirror/APKMirrorDownloader.kt
delete mode 100644 src/main/kotlin/app/revanced/manager/plugin/downloader/example/ExampleDownloader.kt
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index a5dfea2..a8ddc61 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -11,18 +11,18 @@ body:
-
-
-
+
+
@@ -66,12 +66,10 @@ body:
Continuing the legacy of Vanced
- # ReVanced Manager downloader template bug report
-
Before creating a new bug report, please keep the following in mind:
- - **Do not submit a duplicate bug report**: Search for existing bug reports [here](https://github.com/ReVanced/revanced-manager-downloader-template/issues?q=label%3A%22Bug+report%22).
- - **Review the contribution guidelines**: Make sure your bug report adheres to it. You can find the guidelines [here](https://github.com/ReVanced/revanced-manager-downloader-template/blob/main/CONTRIBUTING.md).
+ - **Do not submit a duplicate bug report**: Search for existing bug reports [here](https://github.com/ReVanced/revanced-manager-apkmirror-downloader/issues?q=label%3A%22Bug+report%22).
+ - **Review the contribution guidelines**: Make sure your bug report adheres to it. You can find the guidelines [here](https://github.com/ReVanced/revanced-manager-apkmirror-downloader/blob/main/CONTRIBUTING.md).
- **Do not use the issue page for support**: If you need help or have questions, check out other platforms on [revanced.app](https://revanced.app).
- type: textarea
attributes:
@@ -85,7 +83,7 @@ body:
- type: textarea
attributes:
label: Error logs
- description: Exceptions can be captured by running `logcat | grep AndroidRuntime` in a shell.
+ description: These can be exported from the Patcher screen or from the Manager settings.
render: shell
- type: textarea
attributes:
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index 2610011..2573ae9 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -2,4 +2,4 @@ blank_issues_enabled: false
contact_links:
- name: 🗨 Discussions
url: https://github.com/revanced/revanced-suggestions/discussions
- about: Have something unspecific to ReVanced Manager downloader in mind? Search for or start a new discussion!
\ No newline at end of file
+ about: Have something unspecific to this plugin in mind? Search for or start a new discussion!
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
index 880cdb7..7afbdc6 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.yml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -11,18 +11,18 @@ body:
-
-
-
+
+
@@ -66,12 +66,10 @@ body:
Continuing the legacy of Vanced
- # ReVanced Manager downloader template feature request
-
Before creating a new feature request, please keep the following in mind:
- - **Do not submit a duplicate feature request**: Search for existing feature requests [here](https://github.com/ReVanced/revanced-manager-downloader-template/issues?q=label%3A%22Feature+request%22).
- - **Review the contribution guidelines**: Make sure your feature request adheres to it. You can find the guidelines [here](https://github.com/ReVanced/revanced-manager-downloader-template/blob/main/CONTRIBUTING.md).
+ - **Do not submit a duplicate feature request**: Search for existing feature requests [here](https://github.com/ReVanced/revanced-manager-apkmirror-downloader/issues?q=label%3A%22Feature+request%22).
+ - **Review the contribution guidelines**: Make sure your feature request adheres to it. You can find the guidelines [here](https://github.com/ReVanced/revanced-manager-apkmirror-downloader/blob/main/CONTRIBUTING.md).
- **Do not use the issue page for support**: If you need help or have questions, check out other platforms on [revanced.app](https://revanced.app).
- type: textarea
attributes:
@@ -82,10 +80,10 @@ body:
- type: textarea
attributes:
label: Motivation
- description: |
+ description: |
A strong motivation is necessary for a feature request to be considered.
-
- - Why should this feature be implemented?
+
+ - Why should this feature be implemented?
- What is the explicit use case?
- What are the benefits?
- What makes this feature important?
diff --git a/README.md b/README.md
index e8bf5f7..0cfbf43 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
media="(prefers-color-scheme: dark)"
srcset="assets/revanced-headline/revanced-headline-vertical-dark.svg"
>
-
@@ -58,70 +58,34 @@
Continuing the legacy of Vanced
-# 👋🔌 ReVanced Manager downloader template
+# 👋🔌 ReVanced Manager APKMirror downloader
-![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/ReVanced/revanced-manager-downloader-template/release.yml)
+![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/ReVanced/revanced-manager-apkmirror-downloader/release.yml)
![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)
-Template repository for ReVanced Manager downloader plugins.
-
-## ❓ About
-
-This is a template to create a new ReVanced Manager downloader repository. An example implementation is included.
-
-## 🚀 Get started
-
-To start using this template, follow these steps:
-
-1. [Create a new repository using this template](https://github.com/new?template_name=revanced-manager-downloader-template&template_owner=ReVanced)
-2. Set up the [build.gradle.kts](build.gradle.kts) file (Specifically, the [package nme](build.gradle.kts#L21).
-3. Update dependencies in the [libs.versions.toml](gradle/libs.versions.toml) file
-4. [Create a pass-phrased GPG master key and subkey](https://mikeross.xyz/create-gpg-key-pair-with-subkeys/)
- 1. Add the private key as a secret named [GPG_PRIVATE_KEY](.github/workflows/release.yml#L51) to your repository
- 2. Add the passphrase as a secret named [GPG_PASSPHRASE](.github/workflows/release.yml#L52) to your repository
- 3. Add the fingerprint of the GPG subkey as a secret named [GPG_FINGERPRINT](.github/workflows/release.yml#L53)
- to your repository
-5. [Generate a keystore](https://developer.android.com/studio/publish/app-signing#generate-key)
- 1. Add the Base64 encoded key store as a secret named [KEYSTORE](.github/workflows/release.yml#L57) to your repository
- 2. Add the keystore password as a secret named [KEYSTORE_PASSWORD](.github/workflows/release.yml#L62) to your repository
- 3. Add the keystore entry alias as a secret named [KEYSTORE_ENTRY_ALIAS](.github/workflows/release.yml#L63) to your repository
- 4. Add the keystore entry password as a secret named [KEYSTORE_ENTRY_PASSWORD](.github/workflows/release.yml#L64) to your repository
-7. Set up the [README.md](README.md) file[^1] (e.g, title, description, license, summary),
-the [issue templates](.github/ISSUE_TEMPLATE)[^2] and the [contribution guidelines](CONTRIBUTING.md)[^3]
-
-🎉 You are now ready to develop and release a ReVanced Manager downloader!
-
-[^1]: [Example README.md file](https://github.com/ReVanced/revanced-manager/blob/main/README.md)
-[^2]: [Example issue templates](https://github.com/ReVanced/revanced-manager/tree/main/.github/ISSUE_TEMPLATE)
-[^3]: [Example contribution guidelines](https://github.com/ReVanced/revanced-manager/blob/main/CONTRIBUTING.md)
+An [APKMirror](https://www.apkmirror.com/) plugin for ReVanced Manager.
## 🧑💻 Usage
-To develop and release ReVanced Manager downloader using this template, some things need to be considered:
+- Plugins are managed as Android apps. Download and install the APK file from the releases page.
+- After installing, restart ReVanced Manager and enable the plugin in the settings.
+- The plugin will now be usable.
-- Development starts in feature branches. Once a feature branch is ready, it is squashed and merged into the `dev` branch
-- The `dev` branch is merged into the `main` branch once it is ready for release
-- Semantic versioning is used to version ReVanced Manager downloader.
-- Semantic commit messages are used for commits
-- Commits on the `dev` branch and `main` branch are automatically released
-via the [release.yml](.github/workflows/release.yml) workflow, which is also responsible for generating the changelog
-and updating the version of ReVanced Manager downloader. It is triggered by pushing to the `dev` or `main` branch.
-The workflow uses the `publish` task to publish the release.
-- The `publish` task depends on the `assembleRelease` task, so it will be run automatically when publishing a release.
+The plugin works by opening the APKMirror website in an embedded browser. If the search string contains a version, you must select that version. Selecting another version in that situation will cause patching to fail.
## 📚 Everything else
### 📙 Contributing
-Thank you for considering contributing to ReVanced Manager downloader.
+Thank you for considering contributing to ReVanced Manager APKMirror downloader.
You can find the contribution guidelines [here](CONTRIBUTING.md).
### 🛠️ Building
-To build ReVanced Manager downloader template, a Java Development Kit (JDK) and Git must be installed.
+To build ReVanced Manager downloader template, a Java Development Kit (JDK) and Git must be installed.
Follow the steps below to build ReVanced Manager downloader template:
-1. Run `git clone git@github.com:ReVanced/revanced-manager-downloader-template.git` to clone the repository
+1. Run `git clone git@github.com:ReVanced/revanced-manager-apkmirror-downloader.git` to clone the repository
2. Run `gradlew assembleRelease` to build the project
> [!NOTE]
@@ -137,9 +101,9 @@ Follow the steps below to build ReVanced Manager downloader template:
## 📜 Licence
-ReVanced Manager downloader template is licensed under the GPLv3 licence.
+This project is licensed under the GPLv3 licence.
Please see the [license file](LICENSE) for more information.
[tl;dr](https://www.tldrlegal.com/license/gnu-general-public-license-v3-gpl-3) you may copy, distribute
-and modify ReVanced Manager downloader template as long as you track changes/dates in source files.
-Any modifications to ReVanced Manager downloader template must also be made available under the GPL,
+and modify the plugin as long as you track changes/dates in source files.
+Any modifications must also be made available under the GPL,
along with build & install instructions.
diff --git a/build.gradle.kts b/build.gradle.kts
index 4f47d5d..8012b04 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -10,7 +10,7 @@ dependencies {
}
android {
- val packageName = "app.revanced.manager.plugin.downloader.example"
+ val packageName = "app.revanced.manager.plugin.downloader.apkmirror"
namespace = packageName
compileSdk = 35
diff --git a/proguard-rules.pro b/proguard-rules.pro
index 926fa23..575abe7 100644
--- a/proguard-rules.pro
+++ b/proguard-rules.pro
@@ -1 +1 @@
--keep public class app.revanced.manager.plugin.downloader.example.*
+-keep public class app.revanced.manager.plugin.downloader.apkmirror.*
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 5f863bc..3c9c5d3 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,4 +1,4 @@
-rootProject.name = "revanced-manager-downloader-template"
+rootProject.name = "revanced-manager-apkmirror-downloader"
pluginManagement.repositories {
gradlePluginPortal()
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index fdee611..149dc26 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -9,12 +9,8 @@
android:label="@string/app_name"
tools:targetApi="35">
-
+ android:value="app.revanced.manager.plugin.downloader.apkmirror.APKMirrorDownloaderKt" />
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/manager/plugin/downloader/apkmirror/APKMirrorDownloader.kt b/src/main/kotlin/app/revanced/manager/plugin/downloader/apkmirror/APKMirrorDownloader.kt
new file mode 100644
index 0000000..c68d78b
--- /dev/null
+++ b/src/main/kotlin/app/revanced/manager/plugin/downloader/apkmirror/APKMirrorDownloader.kt
@@ -0,0 +1,23 @@
+@file:Suppress("Unused")
+
+package app.revanced.manager.plugin.downloader.apkmirror
+
+import android.net.Uri
+import app.revanced.manager.plugin.downloader.webview.WebViewDownloader
+
+val apkMirrorDownloader = WebViewDownloader { packageName, version ->
+ with(Uri.Builder()) {
+ scheme("https")
+ authority("www.apkmirror.com")
+ mapOf(
+ "post_type" to "app_release",
+ "searchtype" to "apk",
+ "s" to (version?.let { "$packageName $it" } ?: packageName),
+ "bundles%5B%5D" to "apk_files" // bundles[]
+ ).forEach { (key, value) ->
+ appendQueryParameter(key, value)
+ }
+
+ build().toString()
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/manager/plugin/downloader/example/ExampleDownloader.kt b/src/main/kotlin/app/revanced/manager/plugin/downloader/example/ExampleDownloader.kt
deleted file mode 100644
index e177694..0000000
--- a/src/main/kotlin/app/revanced/manager/plugin/downloader/example/ExampleDownloader.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-@file:Suppress("Unused")
-
-package app.revanced.manager.plugin.downloader.example
-
-import android.annotation.SuppressLint
-import android.app.Application
-import android.content.Intent
-import android.content.res.AssetFileDescriptor
-import app.revanced.manager.plugin.downloader.*
-
-// This file contains an example downloader implementation using the system file picker.
-// Remember to update the Android manifest if you move the definition file.
-
-val exampleDownloader = Downloader {
- get { packageName, version ->
- // Use the requestStartActivity API to open the system file picker and get the resulting content URI.
- val uri = requestStartActivity(
- Intent(Intent.ACTION_GET_CONTENT)
- .addCategory(Intent.CATEGORY_OPENABLE)
- .setType("application/vnd.android.package-archive")
- )?.data ?: return@get null
-
- println("Package name: $packageName, version: $version")
-
- // We assume the user has selected the correct version, but this might not be the case.
- // Real plugins should verify the version and package name if possible.
- uri to version
- }
-
- // Get an Android context. This is only used for reading the file that the user selected.
- // This hack should not be necessary in a real plugin.
- @SuppressLint("PrivateApi")
- val application = with(Class.forName("android.app.ActivityThread")) {
- val activityThread = getMethod("currentActivityThread")(null)
- getMethod("getApplication")(activityThread) as Application
- }
- download { uri ->
- // Open the file and return an InputStream to it along with the size.
- val fd = application.contentResolver.openAssetFileDescriptor(uri, "r")!!
- AssetFileDescriptor.AutoCloseInputStream(fd) to fd.length.takeIf { it > 0L }
- }
-}
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index e70864b..6dae166 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -1,3 +1,3 @@
- Example downloader
+ ReVanced Manager: APKMirror downloader
\ No newline at end of file