Skip to content

Commit 01cdffc

Browse files
fix: Use Morphe patches API (#12)
1 parent 8ed769f commit 01cdffc

16 files changed

Lines changed: 314 additions & 426 deletions

File tree

api/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ publishing {
107107
developer {
108108
id = "Morphe"
109109
name = "Morphe"
110-
email = "contact@morphe.software"
110+
url = "https://morphe.software"
111111
}
112112
}
113113
scm {
114-
// FIXME
115114
val ghRepo = System.getenv("GITHUB_REPOSITORY") ?: "MorpheApp/morphe-manager"
116115
connection = "scm:git:git://github.com/$ghRepo.git"
117116
developerConnection = "scm:git:git@github.com:$ghRepo.git"

app/src/main/java/app/revanced/manager/ManagerApplication.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ManagerApplication : Application() {
3838
private val patchBundleRepository: PatchBundleRepository by inject()
3939
private val downloaderPluginRepository: DownloaderPluginRepository by inject()
4040
private val fs: Filesystem by inject()
41-
private val httpService: HttpService by inject()
41+
// private val httpService: HttpService by inject()
4242

4343
override fun onCreate() {
4444
super.onCreate()
@@ -94,6 +94,7 @@ class ManagerApplication : Application() {
9494
scope.launch(Dispatchers.Default) {
9595
downloaderPluginRepository.reload()
9696
}
97+
// Morphe
9798
// scope.launch(Dispatchers.Default) {
9899
// PatchListCatalog.refreshIfNeeded(httpService)
99100
// }

app/src/main/java/app/revanced/manager/data/room/bundles/PatchBundleEntity.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ sealed class Source {
1010
override fun toString() = SENTINEL
1111
}
1212

13-
// object API : Source() {
14-
// const val SENTINEL = "api"
15-
//
16-
// override fun toString() = SENTINEL
17-
// }
13+
object API : Source() {
14+
const val SENTINEL = "api"
15+
16+
override fun toString() = SENTINEL
17+
}
1818

1919
data class Remote(val url: Url) : Source() {
2020
override fun toString() = url.toString()
@@ -31,7 +31,7 @@ sealed class Source {
3131

3232
fun from(value: String) = when (value) {
3333
Local.SENTINEL -> Local
34-
// API.SENTINEL -> API
34+
API.SENTINEL -> API
3535
else -> if (gitHubPullRequestPattern.matches(value)) {
3636
GitHubPullRequest(Url(value))
3737
} else Remote(Url(value))

app/src/main/java/app/revanced/manager/domain/bundles/RemotePatchBundle.kt

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -165,41 +165,41 @@ class JsonPatchBundle(
165165
)
166166
}
167167

168-
//class APIPatchBundle(
169-
// name: String,
170-
// uid: Int,
171-
// displayName: String?,
172-
// createdAt: Long?,
173-
// updatedAt: Long?,
174-
// installedVersionSignature: String?,
175-
// error: Throwable?,
176-
// directory: File,
177-
// endpoint: String,
178-
// autoUpdate: Boolean,
179-
//) : RemotePatchBundle(name, uid, displayName, createdAt, updatedAt, installedVersionSignature, error, directory, endpoint, autoUpdate) {
180-
// private val api: ReVancedAPI by inject()
181-
//
182-
// override suspend fun getLatestInfo() = api.getPatchesUpdate().getOrThrow()
183-
// override fun copy(
184-
// error: Throwable?,
185-
// name: String,
186-
// displayName: String?,
187-
// createdAt: Long?,
188-
// updatedAt: Long?,
189-
// autoUpdate: Boolean
190-
// ) = APIPatchBundle(
191-
// name,
192-
// uid,
193-
// displayName,
194-
// createdAt,
195-
// updatedAt,
196-
// installedVersionSignature,
197-
// error,
198-
// directory,
199-
// endpoint,
200-
// autoUpdate,
201-
// )
202-
//}
168+
class APIPatchBundle(
169+
name: String,
170+
uid: Int,
171+
displayName: String?,
172+
createdAt: Long?,
173+
updatedAt: Long?,
174+
installedVersionSignature: String?,
175+
error: Throwable?,
176+
directory: File,
177+
endpoint: String,
178+
autoUpdate: Boolean,
179+
) : RemotePatchBundle(name, uid, displayName, createdAt, updatedAt, installedVersionSignature, error, directory, endpoint, autoUpdate) {
180+
private val api: ReVancedAPI by inject()
181+
182+
override suspend fun getLatestInfo() = api.getPatchesUpdate().getOrThrow()
183+
override fun copy(
184+
error: Throwable?,
185+
name: String,
186+
displayName: String?,
187+
createdAt: Long?,
188+
updatedAt: Long?,
189+
autoUpdate: Boolean
190+
) = APIPatchBundle(
191+
name,
192+
uid,
193+
displayName,
194+
createdAt,
195+
updatedAt,
196+
installedVersionSignature,
197+
error,
198+
directory,
199+
endpoint,
200+
autoUpdate,
201+
)
202+
}
203203

204204
class GitHubPullRequestBundle(
205205
name: String,

app/src/main/java/app/revanced/manager/domain/manager/PreferencesManager.kt

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ class PreferencesManager(
2828
val theme = enumPreference("theme", Theme.SYSTEM)
2929
val appLanguage = stringPreference("app_language", "en")
3030

31-
val patchesBundleJsonUrl = stringPreference(
32-
"patches_bundle_json_url",
33-
PatchBundleConstants.BUNDLE_URL_STABLE
34-
)
35-
// val api = stringPreference("api_url", "https://api.revanced.app")
36-
// PR #35: https://github.com/Jman-Github/Universal-ReVanced-Manager/pull/35
31+
// val api = stringPreference("api_url", "https://api.morphe.app")
3732
val gitHubPat = stringPreference("github_pat", "")
3833
val includeGitHubPatInExports = booleanPreference("include_github_pat_in_exports", false)
3934

@@ -94,15 +89,7 @@ class PreferencesManager(
9489
}
9590

9691
object PatchBundleConstants {
97-
const val BUNDLE_URL_RELEASES = "https://github.com/HundEdFeteTree/HappyFunTest/releases/latest"
98-
const val BUNDLE_URL_STABLE = "https://raw.githubusercontent.com/HundEdFeteTree/HappyFunTest/refs/heads/main/bundles/test-stable-patches-bundle.json"
99-
const val BUNDLE_URL_LATEST = "https://raw.githubusercontent.com/HundEdFeteTree/HappyFunTest/refs/heads/main/bundles/test-latest-patches-bundle.json"
100-
101-
fun getBundleUrl(usePrerelease: Boolean): String {
102-
// Latest will always be pre-release, or the latest stable
103-
// which may contain additional changes not published in dev release
104-
return if (usePrerelease) BUNDLE_URL_LATEST else BUNDLE_URL_STABLE
105-
}
92+
const val BUNDLE_URL_RELEASES = "https://github.com/MorpheApp/morphe-patches/releases/latest"
10693
}
10794

10895
@Serializable
@@ -115,7 +102,6 @@ class PreferencesManager(
115102
val themePresetSelectionEnabled: Boolean? = null,
116103
val stripUnusedNativeLibs: Boolean? = null,
117104
val theme: Theme? = null,
118-
val patchesBundleJsonUrl: String? = null,
119105
val appLanguage: String? = null,
120106
// val api: String? = null,
121107
val gitHubPat: String? = null,
@@ -162,7 +148,6 @@ class PreferencesManager(
162148
// api = api.get(),
163149
gitHubPat = gitHubPat.get().takeIf { includeGitHubPatInExports.get() },
164150
includeGitHubPatInExports = includeGitHubPatInExports.get(),
165-
patchesBundleJsonUrl = patchesBundleJsonUrl.get(),
166151
useProcessRuntime = useProcessRuntime.get(),
167152
patcherProcessMemoryLimit = patcherProcessMemoryLimit.get(),
168153
autoCollapsePatcherSteps = autoCollapsePatcherSteps.get(),
@@ -205,7 +190,6 @@ class PreferencesManager(
205190
// snapshot.api?.let { api.value = it }
206191
snapshot.gitHubPat?.let { gitHubPat.value = it }
207192
snapshot.includeGitHubPatInExports?.let { includeGitHubPatInExports.value = it }
208-
snapshot.patchesBundleJsonUrl?.let { patchesBundleJsonUrl.value = it }
209193
snapshot.useProcessRuntime?.let { useProcessRuntime.value = it }
210194
snapshot.patcherProcessMemoryLimit?.let { patcherProcessMemoryLimit.value = it }
211195
snapshot.autoCollapsePatcherSteps?.let { autoCollapsePatcherSteps.value = it }

0 commit comments

Comments
 (0)