Added hiding of UI elements when no root access is detected

This commit is contained in:
Viktor De Pasquale 2019-04-14 13:17:51 +02:00
parent 36e83edddc
commit b2fa5b551e
3 changed files with 10 additions and 9 deletions

View File

@ -66,6 +66,8 @@ class HomeViewModel(
"" ""
} }
val hasRoot = KObservableField(false)
private var shownDialog = false private var shownDialog = false
private val current = resources.getString(R.string.current_installed) private val current = resources.getString(R.string.current_installed)
private val latest = resources.getString(R.string.latest_version) private val latest = resources.getString(R.string.latest_version)
@ -110,6 +112,8 @@ class HomeViewModel(
Config.remoteMagiskVersionString = null Config.remoteMagiskVersionString = null
Config.remoteMagiskVersionCode = -1 Config.remoteMagiskVersionCode = -1
hasRoot.value = Shell.rootAccess()
if (Networking.checkNetworkStatus(app)) { if (Networking.checkNetworkStatus(app)) {
CheckUpdates.check() CheckUpdates.check()
} else { } else {

View File

@ -5,7 +5,6 @@ import com.topjohnwu.magisk.BuildConfig
import com.topjohnwu.magisk.Config import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.model.events.* import com.topjohnwu.magisk.model.events.*
import com.topjohnwu.magisk.utils.Event
import com.topjohnwu.magisk.view.MarkDownWindow import com.topjohnwu.magisk.view.MarkDownWindow
import com.topjohnwu.magisk.view.dialogs.EnvFixDialog import com.topjohnwu.magisk.view.dialogs.EnvFixDialog
import com.topjohnwu.magisk.view.dialogs.ManagerInstallDialog import com.topjohnwu.magisk.view.dialogs.ManagerInstallDialog
@ -125,14 +124,6 @@ class MagiskFragment : NewMagiskFragment<HomeViewModel, com.topjohnwu.magisk.dat
}*/ }*/
} }
private fun getListeningEvents(): IntArray {
return intArrayOf(Event.UPDATE_CHECK_DONE)
}
private fun onEvent(event: Int) {
updateCheckUI()
}
private fun updateUI() { private fun updateUI() {
/*(requireActivity() as MainActivity).checkHideSection() /*(requireActivity() as MainActivity).checkHideSection()
val image: Int val image: Int

View File

@ -103,10 +103,12 @@
<View <View
style="@style/Widget.Divider.Horizontal" style="@style/Widget.Divider.Horizontal"
gone="@{!viewModel.hasRoot}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_margin="@dimen/margin_generic" /> android:layout_margin="@dimen/margin_generic" />
<LinearLayout <LinearLayout
gone="@{!viewModel.hasRoot}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
@ -184,10 +186,12 @@
<View <View
style="@style/Widget.Divider.Horizontal" style="@style/Widget.Divider.Horizontal"
gone="@{!viewModel.hasRoot}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_margin="@dimen/margin_generic" /> android:layout_margin="@dimen/margin_generic" />
<LinearLayout <LinearLayout
gone="@{!viewModel.hasRoot}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
@ -460,11 +464,13 @@
<View <View
style="@style/Widget.Divider.Horizontal" style="@style/Widget.Divider.Horizontal"
gone="@{!viewModel.hasRoot}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_margin="@dimen/margin_generic" /> android:layout_margin="@dimen/margin_generic" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.Button.Text" style="@style/Widget.Button.Text"
gone="@{!viewModel.hasRoot}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.uninstallPressed()}" android:onClick="@{() -> viewModel.uninstallPressed()}"