diff --git a/app/src/main/java/com/topjohnwu/magisk/data/database/Repo.kt b/app/src/main/java/com/topjohnwu/magisk/data/database/Repo.kt index c97dd8ed7..fd13b9ecb 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/database/Repo.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/database/Repo.kt @@ -14,6 +14,9 @@ interface RepoBase { @Query("SELECT * FROM repos WHERE id = :id AND versionCode > :versionCode LIMIT 1") fun getUpdatableRepoById(id: String, versionCode: Int): Repo? + @Query("SELECT * FROM repos WHERE id = :id LIMIT 1") + fun getRepoById(id: String): Repo? + companion object { const val LIMIT = 10 } diff --git a/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt b/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt index b748ffc94..3d4bb21a7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt @@ -170,6 +170,13 @@ class ModuleItem(val item: Module) : ObservableItem(), Observable { override val layoutRes = R.layout.item_module_md2 + @get:Bindable + var repo: Repo? = null + set(value) { + field = value + notifyChange(BR.repo) + } + @get:Bindable var isEnabled = item.enable set(value) { diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt index 84648a5be..362802949 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt @@ -129,6 +129,7 @@ class ModuleViewModel( override fun refresh() = Single.fromCallable { Module.loadModules() } .map { it.map { ModuleItem(it) } } .map { it.order() } + .map { it.loadDetail() } .map { build(active = it, updatable = loadUpdates(it)) } .map { it to items.calculateDiff(it) } .applyViewModel(this) @@ -222,6 +223,13 @@ class ModuleViewModel( .sortedBy { it.item.name.toLowerCase(currentLocale) } .toList() + @WorkerThread + private fun List.loadDetail() = onEach { module -> + Single.fromCallable { dao.getRepoById(module.item.id)!! } + .subscribeK { module.repo = it } + .add() + } + private fun update(repo: Repo, progress: Int) = Single.fromCallable { itemsRemote + itemsSearch } .map { it.first { it.item.id == repo.id } } @@ -263,6 +271,9 @@ class ModuleViewModel( fun downloadPressed(item: RepoItem) = ModuleInstallDialog(item.item).publish() fun installPressed() = InstallExternalModuleEvent().publish() fun infoPressed(item: RepoItem) = OpenChangelogEvent(item.item).publish() + fun infoPressed(item: ModuleItem) { + OpenChangelogEvent(item.repo ?: return).publish() + } // --- diff --git a/app/src/main/res/layout/item_module_md2.xml b/app/src/main/res/layout/item_module_md2.xml index efdc590ca..f06d5561b 100644 --- a/app/src/main/res/layout/item_module_md2.xml +++ b/app/src/main/res/layout/item_module_md2.xml @@ -97,7 +97,21 @@ android:background="?colorSurfaceVariant" app:layout_constraintTop_toBottomOf="@+id/module_description" /> + +