mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-05-29 21:10:15 +02:00
Added back safe mode notice
This commit is contained in:
parent
f72de687c5
commit
f5342a09d3
@ -81,6 +81,19 @@ class RepoRvItem(val item: Repo) : ComparableRvItem<RepoRvItem>() {
|
|||||||
override fun itemSameAs(other: RepoRvItem): Boolean = item.id == other.item.id
|
override fun itemSameAs(other: RepoRvItem): Boolean = item.id == other.item.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object SafeModeNotice : ComparableRvItem<SafeModeNotice>() {
|
||||||
|
override val layoutRes = R.layout.item_safe_mode_notice
|
||||||
|
|
||||||
|
override fun onBindingBound(binding: ViewDataBinding) {
|
||||||
|
super.onBindingBound(binding)
|
||||||
|
val params = binding.root.layoutParams as? StaggeredGridLayoutManager.LayoutParams
|
||||||
|
params?.isFullSpan = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun contentSameAs(other: SafeModeNotice) = this == other
|
||||||
|
override fun itemSameAs(other: SafeModeNotice) = this === other
|
||||||
|
}
|
||||||
|
|
||||||
object InstallModule : ComparableRvItem<InstallModule>() {
|
object InstallModule : ComparableRvItem<InstallModule>() {
|
||||||
override val layoutRes = R.layout.item_module_download
|
override val layoutRes = R.layout.item_module_download
|
||||||
|
|
||||||
|
@ -15,10 +15,7 @@ import com.topjohnwu.magisk.model.download.RemoteFileService
|
|||||||
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
|
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
|
||||||
import com.topjohnwu.magisk.model.entity.module.Module
|
import com.topjohnwu.magisk.model.entity.module.Module
|
||||||
import com.topjohnwu.magisk.model.entity.module.Repo
|
import com.topjohnwu.magisk.model.entity.module.Repo
|
||||||
import com.topjohnwu.magisk.model.entity.recycler.InstallModule
|
import com.topjohnwu.magisk.model.entity.recycler.*
|
||||||
import com.topjohnwu.magisk.model.entity.recycler.ModuleItem
|
|
||||||
import com.topjohnwu.magisk.model.entity.recycler.RepoItem
|
|
||||||
import com.topjohnwu.magisk.model.entity.recycler.SectionTitle
|
|
||||||
import com.topjohnwu.magisk.model.events.InstallExternalModuleEvent
|
import com.topjohnwu.magisk.model.events.InstallExternalModuleEvent
|
||||||
import com.topjohnwu.magisk.model.events.OpenChangelogEvent
|
import com.topjohnwu.magisk.model.events.OpenChangelogEvent
|
||||||
import com.topjohnwu.magisk.model.events.dialog.ModuleInstallDialog
|
import com.topjohnwu.magisk.model.events.dialog.ModuleInstallDialog
|
||||||
@ -284,12 +281,17 @@ class ModuleViewModel(
|
|||||||
active: List<ModuleItem> = itemsInstalled,
|
active: List<ModuleItem> = itemsInstalled,
|
||||||
updatable: List<RepoItem.Update> = itemsUpdatable,
|
updatable: List<RepoItem.Update> = itemsUpdatable,
|
||||||
remote: List<RepoItem.Remote> = itemsRemote
|
remote: List<RepoItem.Remote> = itemsRemote
|
||||||
) = (active + InstallModule).prependIfNotEmpty { sectionActive } +
|
) = (active + InstallModule)
|
||||||
|
.prependIfNotEmpty { sectionActive }
|
||||||
|
.prependIf(Config.coreOnly) { SafeModeNotice } +
|
||||||
updatable.prependIfNotEmpty { sectionUpdate } +
|
updatable.prependIfNotEmpty { sectionUpdate } +
|
||||||
remote.prependIfNotEmpty { sectionRemote }
|
remote.prependIfNotEmpty { sectionRemote }
|
||||||
|
|
||||||
|
private fun <T> List<T>.prependIf(condition: Boolean, item: () -> T) =
|
||||||
|
if (condition) listOf(item()) + this else this
|
||||||
|
|
||||||
private fun <T> List<T>.prependIfNotEmpty(item: () -> T) =
|
private fun <T> List<T>.prependIfNotEmpty(item: () -> T) =
|
||||||
if (isNotEmpty()) listOf(item()) + this else this
|
prependIf(isNotEmpty(), item)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
app/src/main/res/layout/item_safe_mode_notice.xml
Normal file
30
app/src/main/res/layout/item_safe_mode_notice.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="item"
|
||||||
|
type="com.topjohnwu.magisk.model.entity.recycler.SafeModeNotice" />
|
||||||
|
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
style="?styleCardNormal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardBackgroundColor="?colorError">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="@dimen/l1"
|
||||||
|
android:text="@string/module_safe_mode_message"
|
||||||
|
android:textAppearance="?appearanceTextCaptionOnPrimary"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
</layout>
|
Loading…
x
Reference in New Issue
Block a user