Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
1d831d65
Commit
1d831d65
authored
Feb 01, 2020
by
Viktor De Pasquale
Committed by
John Wu
Feb 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added overflow menu for reboot
parent
c35d0207
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
1 deletion
+73
-1
HomeViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
+9
-0
DataBindingAdapters.kt
...in/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt
+24
-0
include_home_device.xml
app/src/main/res/layout/include_home_device.xml
+7
-1
menu_reboot.xml
app/src/main/res/menu/menu_reboot.xml
+24
-0
dimens.xml
app/src/main/res/values/dimens.xml
+1
-0
styles_md2.xml
app/src/main/res/values/styles_md2.xml
+8
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
View file @
1d831d65
...
@@ -136,6 +136,15 @@ class HomeViewModel(
...
@@ -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
()
{
...
...
app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt
View file @
1d831d65
...
@@ -5,9 +5,11 @@ import android.animation.ValueAnimator
...
@@ -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
...
@@ -460,4 +462,26 @@ fun TextView.setStrikeThroughEnabled(useStrikeThrough: Boolean) {
...
@@ -460,4 +462,26 @@ fun TextView.setStrikeThroughEnabled(useStrikeThrough: Boolean) {
}
else
{
}
else
{
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
()
}
}
}
}
\ No newline at end of file
app/src/main/res/layout/include_home_device.xml
View file @
1d831d65
...
@@ -11,6 +11,10 @@
...
@@ -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 @@
...
@@ -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"
...
...
app/src/main/res/menu/menu_reboot.xml
0 → 100644
View file @
1d831d65
<?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>
\ No newline at end of file
app/src/main/res/values/dimens.xml
View file @
1d831d65
...
@@ -14,6 +14,7 @@
...
@@ -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>
...
...
app/src/main/res/values/styles_md2.xml
View file @
1d831d65
...
@@ -23,6 +23,13 @@
...
@@ -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 @@
...
@@ -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"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment