mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
parent
3bda7cb26b
commit
89b1fa341b
@ -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
|
||||
}
|
||||
|
@ -170,6 +170,13 @@ class ModuleItem(val item: Module) : ObservableItem<ModuleItem>(), 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) {
|
||||
|
@ -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<ModuleItem>.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()
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
|
@ -97,7 +97,21 @@
|
||||
android:background="?colorSurfaceVariant"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_description" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/module_info"
|
||||
style="@style/WidgetFoundation.Icon"
|
||||
gone="@{item.repo == null}"
|
||||
android:layout_width="wrap_content"
|
||||
android:alpha=".5"
|
||||
android:onClick="@{() -> viewModel.infoPressed(item)}"
|
||||
android:paddingEnd="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_remove"
|
||||
app:layout_constraintEnd_toStartOf="@+id/module_remove"
|
||||
app:layout_constraintTop_toTopOf="@+id/module_remove"
|
||||
app:srcCompat="@drawable/ic_info" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/module_remove"
|
||||
style="@style/WidgetFoundation.Button.Text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
Loading…
Reference in New Issue
Block a user