mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 21:17:37 +00:00
Added overflow menu for reboot
This commit is contained in:
parent
c35d020731
commit
1d831d65f3
@ -136,6 +136,15 @@ class HomeViewModel(
|
|||||||
.subscribeK { Navigation.install().publish() }
|
.subscribeK { Navigation.install().publish() }
|
||||||
.add()
|
.add()
|
||||||
|
|
||||||
|
fun rebootPressed(menuItemId: Int) = when (menuItemId) {
|
||||||
|
R.id.action_reboot_normal -> reboot()
|
||||||
|
R.id.action_reboot_bootloader -> reboot("bootloader")
|
||||||
|
R.id.action_reboot_download -> reboot("download")
|
||||||
|
R.id.action_reboot_edl -> reboot("edl")
|
||||||
|
R.id.action_reboot_recovery -> Shell.su("/system/bin/reboot recovery").submit()
|
||||||
|
else -> Unit
|
||||||
|
}
|
||||||
|
|
||||||
fun toggle(kof: KObservableField<Boolean>) = kof.toggle()
|
fun toggle(kof: KObservableField<Boolean>) = kof.toggle()
|
||||||
|
|
||||||
fun hideNotice() {
|
fun hideNotice() {
|
||||||
|
@ -5,9 +5,11 @@ import android.animation.ValueAnimator
|
|||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.view.ContextThemeWrapper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewAnimationUtils
|
import android.view.ViewAnimationUtils
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.PopupMenu
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
@ -461,3 +463,25 @@ fun TextView.setStrikeThroughEnabled(useStrikeThrough: Boolean) {
|
|||||||
paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface OnPopupMenuItemClickListener {
|
||||||
|
fun onMenuItemClick(itemId: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("popupMenu", "popupMenuOnClickListener", requireAll = false)
|
||||||
|
fun View.setPopupMenu(popupMenu: Int, listener: OnPopupMenuItemClickListener) {
|
||||||
|
tag = tag as? PopupMenu ?: let {
|
||||||
|
val themeWrapper = ContextThemeWrapper(context, R.style.Foundation_PopupMenu)
|
||||||
|
PopupMenu(themeWrapper, this)
|
||||||
|
}
|
||||||
|
setOnClickListener {
|
||||||
|
(tag as PopupMenu).apply {
|
||||||
|
menuInflater.inflate(popupMenu, menu)
|
||||||
|
setOnMenuItemClickListener {
|
||||||
|
listener.onMenuItemClick(it.itemId)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
<import type="com.topjohnwu.magisk.extensions.XSUKt" />
|
<import type="com.topjohnwu.magisk.extensions.XSUKt" />
|
||||||
|
|
||||||
|
<import type="com.topjohnwu.magisk.R" />
|
||||||
|
|
||||||
|
<import type="com.topjohnwu.superuser.Shell" />
|
||||||
|
|
||||||
<variable
|
<variable
|
||||||
name="viewModel"
|
name="viewModel"
|
||||||
type="com.topjohnwu.magisk.ui.home.HomeViewModel" />
|
type="com.topjohnwu.magisk.ui.home.HomeViewModel" />
|
||||||
@ -44,10 +48,12 @@
|
|||||||
app:layout_constraintStart_toEndOf="@+id/home_device_icon"
|
app:layout_constraintStart_toEndOf="@+id/home_device_icon"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<!--todo (diareuse) add dropdown menu so users can choose which reboot they want -->
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/home_device_action_reboot"
|
android:id="@+id/home_device_action_reboot"
|
||||||
style="@style/WidgetFoundation.Button.Text"
|
style="@style/WidgetFoundation.Button.Text"
|
||||||
|
gone="@{!Shell.rootAccess()}"
|
||||||
|
popupMenu="@{R.menu.menu_reboot}"
|
||||||
|
popupMenuOnClickListener="@{(it) -> viewModel.rebootPressed(it)}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/l_50"
|
android:layout_marginEnd="@dimen/l_50"
|
||||||
|
24
app/src/main/res/menu/menu_reboot.xml
Normal file
24
app/src/main/res/menu/menu_reboot.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_reboot_normal"
|
||||||
|
android:title="@string/reboot" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_reboot_bootloader"
|
||||||
|
android:title="@string/reboot_bootloader" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_reboot_download"
|
||||||
|
android:title="@string/reboot_download" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_reboot_edl"
|
||||||
|
android:title="@string/reboot_edl" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_reboot_recovery"
|
||||||
|
android:title="@string/reboot_recovery" />
|
||||||
|
|
||||||
|
</menu>
|
@ -14,6 +14,7 @@
|
|||||||
<dimen name="l_75">12dp</dimen>
|
<dimen name="l_75">12dp</dimen>
|
||||||
<dimen name="l1">16dp</dimen>
|
<dimen name="l1">16dp</dimen>
|
||||||
<dimen name="l2">32dp</dimen>
|
<dimen name="l2">32dp</dimen>
|
||||||
|
<dimen name="l3">48dp</dimen>
|
||||||
|
|
||||||
<dimen name="r1">8dp</dimen>
|
<dimen name="r1">8dp</dimen>
|
||||||
|
|
||||||
|
@ -23,6 +23,13 @@
|
|||||||
</style>
|
</style>
|
||||||
<!--endregion-->
|
<!--endregion-->
|
||||||
|
|
||||||
|
<style name="Foundation.PopupMenu" parent="Widget.AppCompat.PopupMenu">
|
||||||
|
<item name="android:textColor">?colorOnSurface</item>
|
||||||
|
<item name="android:itemBackground">?colorSurfaceVariant</item>
|
||||||
|
<item name="android:itemTextAppearance">@style/AppearanceFoundation.Caption</item>
|
||||||
|
<item name="android:textStyle">bold</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Foundation.Base" parent="Foundation.Compat">
|
<style name="Foundation.Base" parent="Foundation.Compat">
|
||||||
<item name="android:fontFamily">@font/exo</item>
|
<item name="android:fontFamily">@font/exo</item>
|
||||||
<item name="android:includeFontPadding">false</item>
|
<item name="android:includeFontPadding">false</item>
|
||||||
@ -32,6 +39,7 @@
|
|||||||
<item name="selectableItemBackground">@drawable/bg_selectable</item>
|
<item name="selectableItemBackground">@drawable/bg_selectable</item>
|
||||||
<item name="selectableItemBackgroundBorderless">@drawable/bg_selectable_borderless</item>
|
<item name="selectableItemBackgroundBorderless">@drawable/bg_selectable_borderless</item>
|
||||||
<item name="actionBarSize">@dimen/internal_action_bar_size</item>
|
<item name="actionBarSize">@dimen/internal_action_bar_size</item>
|
||||||
|
<item name="popupMenuStyle">@style/Foundation.PopupMenu</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Foundation.Default" parent="Foundation.Base">
|
<style name="Foundation.Default" parent="Foundation.Base">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user