- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 73
Allow other module repositories #94
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -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") | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
| } | ||
| } | ||
|  | ||
|  | @@ -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) | ||
| } | ||
| } | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -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 | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? = | ||
|  | @@ -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)) { | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now displaying commits from Xposed module There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -115,6 +115,13 @@ class DeveloperSettings: Screen { | |
| onPrefChange = { prefs.debuggable = it } | ||
| ) | ||
|  | ||
| SettingsTextField( | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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), | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -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() | ||
|  | @@ -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 { | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
|  | ||
There was a problem hiding this comment.
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.