Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class PreferenceManager(context: Context) :

var moduleLocation by filePreference("module_location", DEFAULT_MODULE_LOCATION)

var vendettaModuleRepo by stringPreference("vendetta_module_repo", "vendetta-mod/VendettaXposed")

var installMethod by enumPreference("install_method", InstallMethod.DEFAULT)

var logsAlternateBackground by booleanPreference("logs_alternate_bg", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DownloadVendettaStep(

override val nameRes = R.string.step_dl_vd

override val url: String = "https://github.com/vendetta-mod/VendettaXposed/releases/latest/download/app-release.apk"
override val url: String = "https://github.com/${preferenceManager.vendettaModuleRepo}/releases/latest/download/app-release.apk"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the repo is configurable, the asset name is hardcoded, which means other module repo releases have to name their releases the same way.

override val destination = preferenceManager.moduleLocation
override val workingCopy = workingDir.resolve("vendetta.apk")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RestService(

suspend fun getLatestRelease(repo: String) = withContext(Dispatchers.IO) {
httpService.request<Release> {
url("https://api.github.com/repos/vendetta-mod/$repo/releases/latest")
url("https://api.github.com/repos/$repo/releases/latest")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is semantically correct. As you can see GitHub themselves refers the org/name segments as "repos" denoted by the segment before the repo.

}
}

Expand All @@ -28,7 +28,7 @@ class RestService(

suspend fun getCommits(repo: String, page: Int = 1) = withContext(Dispatchers.IO) {
httpService.request<List<Commit>> {
url("https://api.github.com/repos/vendetta-mod/$repo/commits")
url("https://api.github.com/repos/$repo/commits")
parameter("page", page)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package dev.beefers.vendetta.manager.network.utils

import androidx.paging.PagingSource
import androidx.paging.PagingState
import dev.beefers.vendetta.manager.domain.manager.PreferenceManager
import dev.beefers.vendetta.manager.domain.repository.RestRepository
import dev.beefers.vendetta.manager.network.dto.Commit

class CommitsPagingSource(
private val repo: RestRepository
private val repo: RestRepository,
private val prefs: PreferenceManager
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if injecting preferences is clean, but seemed to be the intended approach.

) : PagingSource<Int, Commit>() {

override fun getRefreshKey(state: PagingState<Int, Commit>): Int? =
Expand All @@ -17,7 +19,7 @@ class CommitsPagingSource(
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Commit> {
val page = params.key ?: 0

return when (val response = repo.getCommits("Vendetta", page)) {
return when (val response = repo.getCommits(prefs.vendettaModuleRepo, page)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now displaying commits from Xposed module

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commits of the module aren't what's relevant, the user doesn't care how the app is patched, they care about the mod injected afterwards as that is what they're using

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how to solve this other than adding another text field to specify where to get the commits from.

is ApiResponse.Success -> LoadResult.Page(
data = response.data,
prevKey = if (page > 0) page - 1 else null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ class DeveloperSettings: Screen {
onPrefChange = { prefs.debuggable = it }
)

SettingsTextField(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The developer settings seemed the most suitable location.

label = stringResource(R.string.settings_vendetta_module_repo),
supportingText = stringResource(R.string.settings_vendetta_module_repo_description),
pref = prefs.vendettaModuleRepo,
onPrefChange = { prefs.vendettaModuleRepo = it }
)

SettingsTextField(
label = stringResource(R.string.settings_module_location),
supportingText = stringResource(R.string.settings_module_location_description),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class HomeViewModel(

var showUpdateDialog by mutableStateOf(false)
var isUpdating by mutableStateOf(false)
val commits = Pager(PagingConfig(pageSize = 30)) { CommitsPagingSource(repo) }.flow.cachedIn(screenModelScope)
val commits = Pager(PagingConfig(pageSize = 30)) { CommitsPagingSource(repo, prefs) }.flow.cachedIn(screenModelScope)

init {
getDiscordVersions()
Expand Down Expand Up @@ -107,11 +107,11 @@ class HomeViewModel(

private fun checkForUpdate() {
screenModelScope.launch {
release = repo.getLatestRelease("VendettaManager").dataOrNull
release = repo.getLatestRelease("vendetta-mod/VendettaManager").dataOrNull
release?.let {
showUpdateDialog = it.tagName.toInt() > BuildConfig.VERSION_CODE
}
repo.getLatestRelease("VendettaXposed").ifSuccessful {
repo.getLatestRelease(prefs.vendettaModuleRepo).ifSuccessful {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates are checked correctly for the configurable module repo.

if (prefs.moduleVersion != it.tagName) {
prefs.moduleVersion = it.tagName
val module = File(cacheDir, "vendetta.apk")
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@
<string name="settings_module_location_reset">Reset module location</string>
<string name="settings_package_name">Package name</string>
<string name="settings_version">Discord version</string>
<string name="settings_vendetta_module_repo">Vendetta module repo</string>
<string name="settings_vendetta_module_repo_description">The repository to download the Vendetta module from</string>
<string name="settings_debuggable">Debuggable</string>
<string name="settings_debuggable_description">Enable debuggable flag</string>

Expand Down