Add failed state
This commit is contained in:
parent
8df96ff664
commit
a6950b8aca
@ -14,6 +14,7 @@ import com.topjohnwu.magisk.ktx.get
|
|||||||
import com.topjohnwu.magisk.ktx.packageInfo
|
import com.topjohnwu.magisk.ktx.packageInfo
|
||||||
import com.topjohnwu.magisk.ktx.packageName
|
import com.topjohnwu.magisk.ktx.packageName
|
||||||
import com.topjohnwu.magisk.ktx.processes
|
import com.topjohnwu.magisk.ktx.processes
|
||||||
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
import com.topjohnwu.magisk.utils.set
|
import com.topjohnwu.magisk.utils.set
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -46,6 +47,10 @@ class HideViewModel : BaseViewModel(), Queryable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun refresh() = viewModelScope.launch {
|
override fun refresh() = viewModelScope.launch {
|
||||||
|
if (!Utils.showSuperUser()) {
|
||||||
|
state = State.LOADING_FAILED
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
state = State.LOADING
|
state = State.LOADING
|
||||||
val (apps, diff) = withContext(Dispatchers.Default) {
|
val (apps, diff) = withContext(Dispatchers.Default) {
|
||||||
val pm = get<PackageManager>()
|
val pm = get<PackageManager>()
|
||||||
|
@ -18,6 +18,7 @@ import com.topjohnwu.magisk.databinding.ComparableRvItem
|
|||||||
import com.topjohnwu.magisk.events.SnackbarEvent
|
import com.topjohnwu.magisk.events.SnackbarEvent
|
||||||
import com.topjohnwu.magisk.events.dialog.BiometricEvent
|
import com.topjohnwu.magisk.events.dialog.BiometricEvent
|
||||||
import com.topjohnwu.magisk.events.dialog.SuperuserRevokeDialog
|
import com.topjohnwu.magisk.events.dialog.SuperuserRevokeDialog
|
||||||
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
import com.topjohnwu.magisk.view.TappableHeadlineItem
|
import com.topjohnwu.magisk.view.TappableHeadlineItem
|
||||||
import com.topjohnwu.magisk.view.TextItem
|
import com.topjohnwu.magisk.view.TextItem
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -48,6 +49,10 @@ class SuperuserViewModel(
|
|||||||
// ---
|
// ---
|
||||||
|
|
||||||
override fun refresh() = viewModelScope.launch {
|
override fun refresh() = viewModelScope.launch {
|
||||||
|
if (!Utils.showSuperUser()) {
|
||||||
|
state = State.LOADING_FAILED
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
state = State.LOADING
|
state = State.LOADING
|
||||||
val (policies, diff) = withContext(Dispatchers.Default) {
|
val (policies, diff) = withContext(Dispatchers.Default) {
|
||||||
val policies = db.fetchAll {
|
val policies = db.fetchAll {
|
||||||
|
@ -23,7 +23,7 @@ object Utils {
|
|||||||
|
|
||||||
fun showSuperUser(): Boolean {
|
fun showSuperUser(): Boolean {
|
||||||
return Info.env.isActive && (Const.USER_ID == 0
|
return Info.env.isActive && (Const.USER_ID == 0
|
||||||
|| Config.suMultiuserMode != Config.Value.MULTIUSER_MODE_OWNER_MANAGED)
|
|| Config.suMultiuserMode == Config.Value.MULTIUSER_MODE_USER)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openLink(context: Context, link: Uri) {
|
fun openLink(context: Context, link: Uri) {
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/hide_filter_toggle"
|
android:id="@+id/hide_filter_toggle"
|
||||||
|
invisibleUnless="@{viewModel.loaded || !viewModel.items.empty}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
@ -86,6 +87,24 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
goneUnless="@{viewModel.loadFailed}"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/not_available"
|
||||||
|
android:textAppearance="@style/AppearanceFoundation.Title"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -57,6 +57,24 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
goneUnless="@{viewModel.loadFailed}"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/not_available"
|
||||||
|
android:textAppearance="@style/AppearanceFoundation.Title"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user