feat: Move implementation from the manager repo

This commit is contained in:
Ax333l
2025-01-14 00:21:33 +01:00
parent c102f748aa
commit b06cc39d61
11 changed files with 61 additions and 124 deletions

View File

@@ -11,18 +11,18 @@ body:
<source <source
width="256px" width="256px"
media="(prefers-color-scheme: dark)" media="(prefers-color-scheme: dark)"
srcset="https://raw.githubusercontent.com/revanced/revanced-manager-downloader-template/main/assets/revanced-headline/revanced-headline-vertical-dark.svg" srcset="https://raw.githubusercontent.com/revanced/revanced-manager-apkmirror-downloader/main/assets/revanced-headline/revanced-headline-vertical-dark.svg"
> >
<img <img
width="256px" width="256px"
src="https://raw.githubusercontent.com/revanced/revanced-manager-downloader-template/main/assets/revanced-headline/revanced-headline-vertical-light.svg" src="https://raw.githubusercontent.com/revanced/revanced-manager-apkmirror-downloader/main/assets/revanced-headline/revanced-headline-vertical-light.svg"
> >
</picture> </picture>
<br> <br>
<a href="https://revanced.app/"> <a href="https://revanced.app/">
<picture> <picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/revanced/revanced-manager-downloader-template/main/assets/revanced-logo/revanced-logo.svg" /> <source height="24px" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/revanced/revanced-manager-apkmirror-downloader/main/assets/revanced-logo/revanced-logo.svg" />
<img height="24px" src="https://raw.githubusercontent.com/revanced/revanced-manager-downloader-template/main/assets/revanced-logo/revanced-logo.svg" /> <img height="24px" src="https://raw.githubusercontent.com/revanced/revanced-manager-apkmirror-downloader/main/assets/revanced-logo/revanced-logo.svg" />
</picture> </picture>
</a>&nbsp;&nbsp;&nbsp; </a>&nbsp;&nbsp;&nbsp;
<a href="https://github.com/ReVanced"> <a href="https://github.com/ReVanced">
@@ -66,12 +66,10 @@ body:
Continuing the legacy of Vanced Continuing the legacy of Vanced
</p> </p>
# ReVanced Manager downloader template bug report
Before creating a new bug report, please keep the following in mind: 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). - **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-downloader-template/blob/main/CONTRIBUTING.md). - **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). - **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 - type: textarea
attributes: attributes:
@@ -85,7 +83,7 @@ body:
- type: textarea - type: textarea
attributes: attributes:
label: Error logs 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 render: shell
- type: textarea - type: textarea
attributes: attributes:

View File

@@ -2,4 +2,4 @@ blank_issues_enabled: false
contact_links: contact_links:
- name: 🗨 Discussions - name: 🗨 Discussions
url: https://github.com/revanced/revanced-suggestions/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! about: Have something unspecific to this plugin in mind? Search for or start a new discussion!

View File

@@ -11,18 +11,18 @@ body:
<source <source
width="256px" width="256px"
media="(prefers-color-scheme: dark)" media="(prefers-color-scheme: dark)"
srcset="https://raw.githubusercontent.com/revanced/revanced-manager-downloader-template/main/assets/revanced-headline/revanced-headline-vertical-dark.svg" srcset="https://raw.githubusercontent.com/revanced/revanced-manager-apkmirror-downloader/main/assets/revanced-headline/revanced-headline-vertical-dark.svg"
> >
<img <img
width="256px" width="256px"
src="https://raw.githubusercontent.com/revanced/revanced-manager-downloader-template/main/assets/revanced-headline/revanced-headline-vertical-light.svg" src="https://raw.githubusercontent.com/revanced/revanced-manager-apkmirror-downloader/main/assets/revanced-headline/revanced-headline-vertical-light.svg"
> >
</picture> </picture>
<br> <br>
<a href="https://revanced.app/"> <a href="https://revanced.app/">
<picture> <picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/revanced/revanced-manager-downloader-template/main/assets/revanced-logo/revanced-logo.svg" /> <source height="24px" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/revanced/revanced-manager-apkmirror-downloader/main/assets/revanced-logo/revanced-logo.svg" />
<img height="24px" src="https://raw.githubusercontent.com/revanced/revanced-manager-downloader-template/main/assets/revanced-logo/revanced-logo.svg" /> <img height="24px" src="https://raw.githubusercontent.com/revanced/revanced-manager-apkmirror-downloader/main/assets/revanced-logo/revanced-logo.svg" />
</picture> </picture>
</a>&nbsp;&nbsp;&nbsp; </a>&nbsp;&nbsp;&nbsp;
<a href="https://github.com/ReVanced"> <a href="https://github.com/ReVanced">
@@ -66,12 +66,10 @@ body:
Continuing the legacy of Vanced Continuing the legacy of Vanced
</p> </p>
# ReVanced Manager downloader template feature request
Before creating a new feature request, please keep the following in mind: 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). - **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-downloader-template/blob/main/CONTRIBUTING.md). - **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). - **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 - type: textarea
attributes: attributes:
@@ -82,10 +80,10 @@ body:
- type: textarea - type: textarea
attributes: attributes:
label: Motivation label: Motivation
description: | description: |
A strong motivation is necessary for a feature request to be considered. 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 is the explicit use case?
- What are the benefits? - What are the benefits?
- What makes this feature important? - What makes this feature important?

View File

@@ -5,7 +5,7 @@
media="(prefers-color-scheme: dark)" media="(prefers-color-scheme: dark)"
srcset="assets/revanced-headline/revanced-headline-vertical-dark.svg" srcset="assets/revanced-headline/revanced-headline-vertical-dark.svg"
> >
<img <img
width="256px" width="256px"
src="assets/revanced-headline/revanced-headline-vertical-light.svg" src="assets/revanced-headline/revanced-headline-vertical-light.svg"
> >
@@ -58,70 +58,34 @@
Continuing the legacy of Vanced Continuing the legacy of Vanced
</p> </p>
# 👋🔌 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) ![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)
Template repository for ReVanced Manager downloader plugins. An [APKMirror](https://www.apkmirror.com/) plugin for ReVanced Manager.
## ❓ 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)
## 🧑‍💻 Usage ## 🧑‍💻 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 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.
- 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.
## 📚 Everything else ## 📚 Everything else
### 📙 Contributing ### 📙 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). You can find the contribution guidelines [here](CONTRIBUTING.md).
### 🛠️ Building ### 🛠️ 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: 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 2. Run `gradlew assembleRelease` to build the project
> [!NOTE] > [!NOTE]
@@ -137,9 +101,9 @@ Follow the steps below to build ReVanced Manager downloader template:
## 📜 Licence ## 📜 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. 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 [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. and modify the plugin 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, Any modifications must also be made available under the GPL,
along with build & install instructions. along with build & install instructions.

View File

@@ -10,7 +10,7 @@ dependencies {
} }
android { android {
val packageName = "app.revanced.manager.plugin.downloader.example" val packageName = "app.revanced.manager.plugin.downloader.apkmirror"
namespace = packageName namespace = packageName
compileSdk = 35 compileSdk = 35

2
proguard-rules.pro vendored
View File

@@ -1 +1 @@
-keep public class app.revanced.manager.plugin.downloader.example.* -keep public class app.revanced.manager.plugin.downloader.apkmirror.*

View File

@@ -1,4 +1,4 @@
rootProject.name = "revanced-manager-downloader-template" rootProject.name = "revanced-manager-apkmirror-downloader"
pluginManagement.repositories { pluginManagement.repositories {
gradlePluginPortal() gradlePluginPortal()

View File

@@ -9,12 +9,8 @@
android:label="@string/app_name" android:label="@string/app_name"
tools:targetApi="35"> tools:targetApi="35">
<!--
ReVanced Manager will look for a plugin definition in this class.
CHeck the file for more information.
-->
<meta-data <meta-data
android:name="app.revanced.manager.plugin.downloader.class" android:name="app.revanced.manager.plugin.downloader.class"
android:value="app.revanced.manager.plugin.downloader.example.ExampleDownloaderKt" /> android:value="app.revanced.manager.plugin.downloader.apkmirror.APKMirrorDownloaderKt" />
</application> </application>
</manifest> </manifest>

View File

@@ -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()
}
}

View File

@@ -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 }
}
}

View File

@@ -1,3 +1,3 @@
<resources> <resources>
<string name="app_name">Example downloader</string> <string name="app_name">ReVanced Manager: APKMirror downloader</string>
</resources> </resources>