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
73c4b212
Commit
73c4b212
authored
Nov 27, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added (partially) settings screen
Most importantly added design and functionality backing for these items
parent
78d7c45b
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
699 additions
and
145 deletions
+699
-145
SettingsItems.kt
...a/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt
+103
-0
SettingsViewModel.kt
...m/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt
+136
-13
DataBindingAdapters.kt
...in/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt
+7
-6
TransitiveText.kt
...rc/main/java/com/topjohnwu/magisk/utils/TransitiveText.kt
+54
-0
color_primary_transient.xml
app/src/main/res/color/color_primary_transient.xml
+1
-0
divider_l_50.xml
app/src/main/res/drawable/divider_l_50.xml
+8
-0
fragment_settings_md2.xml
app/src/main/res/layout/fragment_settings_md2.xml
+17
-114
fragment_theme_md2.xml
app/src/main/res/layout/fragment_theme_md2.xml
+4
-4
item_settings_blank.xml
app/src/main/res/layout/item_settings_blank.xml
+95
-0
item_settings_section.xml
app/src/main/res/layout/item_settings_section.xml
+39
-0
item_settings_selector.xml
app/src/main/res/layout/item_settings_selector.xml
+115
-0
item_settings_toggle.xml
app/src/main/res/layout/item_settings_toggle.xml
+99
-0
item_tappable_headline.xml
app/src/main/res/layout/item_tappable_headline.xml
+4
-4
styles_md2_appearance.xml
app/src/main/res/values/styles_md2_appearance.xml
+12
-0
styles_md2_impl.xml
app/src/main/res/values/styles_md2_impl.xml
+5
-4
No files found.
app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt
0 → 100644
View file @
73c4b212
package
com.topjohnwu.magisk.redesign.settings
import
android.content.Context
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.extensions.get
import
com.topjohnwu.magisk.utils.asTransitive
// --- Customization
object
Customization
:
SettingsItem
.
Section
()
{
override
val
title
=
"Customization"
.
asTransitive
()
}
object
Redesign
:
SettingsItem
.
Toggle
()
{
override
val
title
=
"Redesign"
.
asTransitive
()
override
val
description
=
"Select this to disable redesign. App will automatically shut down"
.
asTransitive
()
override
var
value
:
Boolean
by
dataObservable
(
Config
.
redesign
)
{
Config
.
redesign
=
it
}
}
object
Theme
:
SettingsItem
.
Blank
()
{
override
val
icon
=
R
.
drawable
.
ic_paint
override
val
title
=
R
.
string
.
section_theme
.
asTransitive
()
}
// --- Manager
object
Manager
:
SettingsItem
.
Section
()
{
override
val
title
=
R
.
string
.
manager
.
asTransitive
()
}
object
Language
object
ClearRepoCache
:
SettingsItem
.
Blank
()
{
override
val
title
=
R
.
string
.
settings_clear_cache_title
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_clear_cache_summary
.
asTransitive
()
}
object
Hide
:
SettingsItem
.
Blank
()
{
override
val
title
=
R
.
string
.
settings_hide_manager_title
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_hide_manager_summary
.
asTransitive
()
}
object
Restore
:
SettingsItem
.
Blank
()
{
override
val
title
=
R
.
string
.
settings_restore_manager_title
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_restore_manager_summary
.
asTransitive
()
}
@Suppress
(
"FunctionName"
)
fun
HideOrRestore
()
=
if
(
get
<
Context
>().
packageName
==
BuildConfig
.
APPLICATION_ID
)
Hide
else
Restore
object
DownloadPath
object
UpdateChannel
object
UpdateChecker
:
SettingsItem
.
Toggle
()
{
override
val
title
=
R
.
string
.
settings_check_update_title
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_check_update_summary
.
asTransitive
()
override
var
value
by
dataObservable
(
Config
.
checkUpdate
)
{
Config
.
checkUpdate
=
it
}
}
// check whether is module already installed beforehand?
object
SystemlessHosts
:
SettingsItem
.
Blank
()
{
override
val
title
=
R
.
string
.
settings_hosts_title
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_hosts_summary
.
asTransitive
()
}
object
Biometrics
:
SettingsItem
.
Toggle
()
{
override
val
title
=
R
.
string
.
settings_su_biometric_title
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_su_biometric_summary
.
asTransitive
()
override
var
value
by
dataObservable
(
Config
.
suBiometric
)
{
Config
.
suBiometric
=
it
}
}
// --- Magisk
object
Magisk
:
SettingsItem
.
Section
()
{
override
val
title
=
R
.
string
.
magisk
.
asTransitive
()
}
object
SafeMode
:
SettingsItem
.
Toggle
()
{
override
val
title
=
R
.
string
.
settings_core_only_title
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_core_only_summary
.
asTransitive
()
override
var
value
by
dataObservable
(
Config
.
coreOnly
)
{
Config
.
coreOnly
=
it
}
}
object
MagiskHide
:
SettingsItem
.
Toggle
()
{
override
val
title
=
R
.
string
.
magiskhide
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_magiskhide_summary
.
asTransitive
()
override
var
value
by
dataObservable
(
Config
.
magiskHide
)
{
Config
.
magiskHide
=
it
}
}
// --- Superuser
object
Superuser
:
SettingsItem
.
Section
()
{
override
val
title
=
R
.
string
.
superuser
.
asTransitive
()
}
object
AccessMode
object
MultiuserMode
object
MountNamespaceMode
object
AutomaticResponse
object
RequestTimeout
object
SUNotification
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt
View file @
73c4b212
package
com.topjohnwu.magisk.redesign.settings
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback
import
com.topjohnwu.magisk.extensions.toggle
import
android.view.MotionEvent
import
android.view.View
import
androidx.annotation.CallSuper
import
androidx.databinding.Bindable
import
androidx.databinding.ViewDataBinding
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
import
com.topjohnwu.magisk.BR
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.model.entity.recycler.ObservableItem
import
com.topjohnwu.magisk.model.events.DieEvent
import
com.topjohnwu.magisk.model.navigation.Navigation
import
com.topjohnwu.magisk.redesign.compat.CompatViewModel
import
com.topjohnwu.magisk.utils.KObservableField
import
com.topjohnwu.magisk.redesign.home.itemBindingOf
import
com.topjohnwu.magisk.redesign.module.adapterOf
import
com.topjohnwu.magisk.redesign.superuser.diffListOf
import
com.topjohnwu.magisk.utils.TransitiveText
import
com.topjohnwu.magisk.view.MagiskDialog
import
kotlin.properties.ObservableProperty
import
kotlin.reflect.KProperty
class
SettingsViewModel
:
CompatViewModel
()
{
class
SettingsViewModel
:
CompatViewModel
()
,
SettingsItem
.
Callback
{
val
redesign
=
KObservableField
(
Config
.
redesign
)
val
adapter
=
adapterOf
<
SettingsItem
>()
val
itemBinding
=
itemBindingOf
<
SettingsItem
>
{
it
.
bindExtra
(
BR
.
callback
,
this
)
}
val
items
=
diffListOf
(
// General
// Customization
Customization
,
Theme
,
Redesign
,
// Manager
Manager
,
ClearRepoCache
,
HideOrRestore
(),
UpdateChecker
,
SystemlessHosts
,
Biometrics
,
// Magisk
Magisk
,
SafeMode
,
MagiskHide
,
// Superuser
Superuser
)
init
{
//todo make observable preference
redesign
.
addOnPropertyChangedCallback
{
Config
.
redesign
=
redesign
.
value
DieEvent
().
publish
()
override
fun
onItemPressed
(
view
:
View
,
item
:
SettingsItem
)
=
when
(
item
)
{
// use only instances you want, don't declare everything
Theme
->
Navigation
.
theme
().
publish
()
Redesign
->
DieEvent
().
publish
()
else
->
Unit
}
}
sealed
class
SettingsItem
:
ObservableItem
<
SettingsItem
>()
{
@Bindable
open
val
icon
:
Int
=
0
@Bindable
open
val
title
:
TransitiveText
=
TransitiveText
.
empty
@Bindable
open
val
description
:
TransitiveText
=
TransitiveText
.
empty
protected
open
val
isFullSpan
:
Boolean
=
false
@CallSuper
open
fun
onPressed
(
view
:
View
,
callback
:
Callback
)
{
callback
.
onItemPressed
(
view
,
this
)
// notify only after the callback invocation; callback can invalidate the backing data,
// which wouldn't be recognized with reverse approach
notifyChange
(
BR
.
icon
)
notifyChange
(
BR
.
title
)
notifyChange
(
BR
.
description
)
}
override
fun
onBindingBound
(
binding
:
ViewDataBinding
)
{
super
.
onBindingBound
(
binding
)
if
(
isFullSpan
)
{
val
params
=
binding
.
root
.
layoutParams
as
?
StaggeredGridLayoutManager
.
LayoutParams
params
?.
isFullSpan
=
true
}
}
fun
toggle
(
item
:
KObservableField
<
Boolean
>)
=
item
.
toggle
()
fun
themePressed
()
=
Navigation
.
theme
().
publish
()
override
fun
itemSameAs
(
other
:
SettingsItem
)
=
this
===
other
override
fun
contentSameAs
(
other
:
SettingsItem
)
=
itemSameAs
(
other
)
// ---
interface
Callback
{
fun
onItemPressed
(
view
:
View
,
item
:
SettingsItem
)
}
// ---
abstract
class
Value
<
T
>
:
SettingsItem
()
{
abstract
var
value
:
T
@Bindable
get
protected
inline
fun
dataObservable
(
initialValue
:
T
,
crossinline
setter
:
(
T
)
->
Unit
)
=
object
:
ObservableProperty
<
T
>(
initialValue
)
{
override
fun
afterChange
(
property
:
KProperty
<
*
>,
oldValue
:
T
,
newValue
:
T
)
{
setter
(
newValue
)
notifyChange
(
BR
.
value
)
}
}
}
abstract
class
Toggle
:
Value
<
Boolean
>()
{
override
val
layoutRes
=
R
.
layout
.
item_settings_toggle
override
fun
onPressed
(
view
:
View
,
callback
:
Callback
)
{
value
=
!
value
super
.
onPressed
(
view
,
callback
)
}
fun
onTouched
(
view
:
View
,
callback
:
Callback
,
event
:
MotionEvent
):
Boolean
{
if
(
event
.
action
==
MotionEvent
.
ACTION_UP
)
{
onPressed
(
view
,
callback
)
}
return
true
}
}
abstract
class
Selector
:
Value
<
Int
>()
{
override
val
layoutRes
=
R
.
layout
.
item_settings_selector
override
fun
onPressed
(
view
:
View
,
callback
:
Callback
)
{
MagiskDialog
(
view
.
context
)
//.applyAdapter()
super
.
onPressed
(
view
,
callback
)
}
}
abstract
class
Blank
:
SettingsItem
()
{
override
val
layoutRes
=
R
.
layout
.
item_settings_blank
}
abstract
class
Section
:
SettingsItem
()
{
override
val
layoutRes
=
R
.
layout
.
item_settings_section
override
val
isFullSpan
=
true
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt
View file @
73c4b212
...
...
@@ -296,18 +296,24 @@ fun TextSwitcher.setTextBinding(text: CharSequence) {
"android:layout_marginTop"
,
"android:layout_marginRight"
,
"android:layout_marginBottom"
,
"android:layout_marginStart"
,
"android:layout_marginEnd"
,
requireAll
=
false
)
fun
View
.
setMargins
(
marginLeft
:
Int
?,
marginTop
:
Int
?,
marginRight
:
Int
?,
marginBottom
:
Int
?
marginBottom
:
Int
?,
marginStart
:
Int
?,
marginEnd
:
Int
?
)
=
updateLayoutParams
<
ViewGroup
.
MarginLayoutParams
>
{
marginLeft
?.
let
{
leftMargin
=
it
}
marginTop
?.
let
{
topMargin
=
it
}
marginRight
?.
let
{
rightMargin
=
it
}
marginBottom
?.
let
{
bottomMargin
=
it
}
marginStart
?.
let
{
this
.
marginStart
=
it
}
marginEnd
?.
let
{
this
.
marginEnd
=
it
}
}
@BindingAdapter
(
"nestedScrollingEnabled"
)
...
...
@@ -455,9 +461,4 @@ fun View.setRotationNotAnimated(rotation: Int) {
@BindingAdapter
(
"android:text"
)
fun
TextView
.
setTextSafe
(
text
:
Int
)
{
if
(
text
==
0
)
this
.
text
=
null
else
setText
(
text
)
}
@BindingAdapter
(
"android:theme"
)
fun
View
.
setThemeCompat
(
theme
:
Int
)
{
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/utils/TransitiveText.kt
0 → 100644
View file @
73c4b212
package
com.topjohnwu.magisk.utils
import
android.content.res.Resources
import
android.widget.TextView
import
androidx.databinding.BindingAdapter
import
androidx.databinding.InverseBindingAdapter
sealed
class
TransitiveText
{
abstract
val
isEmpty
:
Boolean
abstract
fun
getText
(
resources
:
Resources
):
CharSequence
// ---
class
String
(
private
val
value
:
CharSequence
)
:
TransitiveText
()
{
override
val
isEmpty
=
value
.
isEmpty
()
override
fun
getText
(
resources
:
Resources
)
=
value
}
class
Res
(
private
val
value
:
Int
,
private
vararg
val
params
:
Any
)
:
TransitiveText
()
{
override
val
isEmpty
=
value
==
0
override
fun
getText
(
resources
:
Resources
)
=
resources
.
getString
(
value
,
*
params
)
}
// ---
companion
object
{
val
empty
=
String
(
""
)
}
}
fun
Int
.
asTransitive
(
vararg
params
:
Any
)
=
TransitiveText
.
Res
(
this
,
*
params
)
fun
CharSequence
.
asTransitive
()
=
TransitiveText
.
String
(
this
)
@BindingAdapter
(
"android:text"
)
fun
TextView
.
setText
(
text
:
TransitiveText
)
{
this
.
text
=
text
.
getText
(
resources
)
}
@InverseBindingAdapter
(
attribute
=
"android:text"
,
event
=
"android:textAttrChanged"
)
fun
TextView
.
getTransitiveText
()
=
text
.
asTransitive
()
\ No newline at end of file
app/src/main/res/color/color_primary_transient.xml
View file @
73c4b212
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:color=
"?colorDisabled"
android:state_enabled=
"false"
/>
<item
android:color=
"?colorSecondary"
android:state_checked=
"false"
/>
<item
android:color=
"?colorPrimary"
/>
</selector>
\ No newline at end of file
app/src/main/res/drawable/divider_l_50.xml
0 → 100644
View file @
73c4b212
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/l_50"
android:height=
"@dimen/l_50"
/>
<solid
android:color=
"@android:color/transparent"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/fragment_settings_md2.xml
View file @
73c4b212
...
...
@@ -5,130 +5,33 @@
<data>
<import
type=
"com.topjohnwu.magisk.R"
/>
<variable
name=
"viewModel"
type=
"com.topjohnwu.magisk.redesign.settings.SettingsViewModel"
/>
</data>
<androidx.core.widget.NestedScrollView
<androidx.recyclerview.widget.RecyclerView
adapter=
"@{viewModel.adapter}"
dividerHorizontal=
"@{R.drawable.divider_l_50}"
dividerVertical=
"@{R.drawable.divider_l_50}"
itemBinding=
"@{viewModel.itemBinding}"
items=
"@{viewModel.items}"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:focusableInTouchMode=
"false"
android:clipToPadding=
"false"
android:fillViewport=
"true"
android:orientation=
"vertical"
android:paddingStart=
"@dimen/l1"
android:paddingTop=
"@{viewModel.insets.top + (int) @dimen/internal_action_bar_size}"
android:paddingBottom=
"@{viewModel.insets.bottom + (int) @dimen/l2}"
android:paddingEnd=
"@dimen/l_50"
android:paddingBottom=
"@{viewModel.insets.bottom + (int) @dimen/l1}"
app:layoutManager=
"androidx.recyclerview.widget.StaggeredGridLayoutManager"
app:spanCount=
"2"
tools:layout_marginTop=
"24dp"
tools:paddingTop=
"@dimen/l1"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingTop=
"@dimen/l1"
>
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/settings_card_redesign"
style=
"@style/WidgetFoundation.Card.Variant.Secondary"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/l1"
android:layout_marginRight=
"@dimen/l1"
android:layout_marginBottom=
"@dimen/l1"
android:onClick=
"@{() -> viewModel.toggle(viewModel.redesign)}"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/settings_card_theme"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:gravity=
"start"
android:paddingStart=
"@dimen/l1"
android:text=
"Redesign"
android:textAppearance=
"@style/AppearanceFoundation.Body.Secondary"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/settings_card_redesign_switch"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<com.google.android.material.switchmaterial.SwitchMaterial
android:id=
"@+id/settings_card_redesign_switch"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginEnd=
"@dimen/l_50"
android:checked=
"@={viewModel.redesign}"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/settings_card_theme"
style=
"@style/WidgetFoundation.Card.Variant.Secondary"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/l1"
android:onClick=
"@{() -> viewModel.themePressed()}"
app:layout_constraintEnd_toStartOf=
"@+id/settings_card_redesign"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/settings_card_theme_dark_icon"
style=
"@style/WidgetFoundation.Icon.Secondary"
android:background=
"@null"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_paint"
/>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/settings_card_theme_dark_pointer"
style=
"@style/WidgetFoundation.Icon.Secondary"
android:background=
"@null"
android:rotation=
"180"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_back_md2"
/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:background=
"@null"
android:gravity=
"start|center_vertical"
android:singleLine=
"true"
android:text=
"@string/section_theme"
android:textAppearance=
"@style/AppearanceFoundation.Body.Secondary"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/settings_card_theme_dark_pointer"
app:layout_constraintStart_toEndOf=
"@+id/settings_card_theme_dark_icon"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
tools:listitem=
"@layout/item_settings_toggle"
tools:paddingTop=
"@dimen/l1"
/>
</layout>
\ No newline at end of file
app/src/main/res/layout/fragment_theme_md2.xml
View file @
73c4b212
...
...
@@ -31,7 +31,7 @@
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/theme_card_dark"
style=
"@style/WidgetFoundation.Card.
Variant.Second
ary"
style=
"@style/WidgetFoundation.Card.
Prim
ary"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:onClick=
"@{() -> viewModel.darkModePressed()}"
...
...
@@ -46,7 +46,7 @@
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/settings_card_dark_icon"
style=
"@style/WidgetFoundation.Icon.
Second
ary"
style=
"@style/WidgetFoundation.Icon.
OnPrim
ary"
android:background=
"@null"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -55,7 +55,7 @@
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/settings_card_dark_pointer"
style=
"@style/WidgetFoundation.Icon.
Second
ary"
style=
"@style/WidgetFoundation.Icon.
OnPrim
ary"
android:background=
"@null"
android:rotation=
"180"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -71,7 +71,7 @@
android:gravity=
"start|center_vertical"
android:singleLine=
"true"
android:text=
"@string/settings_dark_mode_title"
android:textAppearance=
"@style/AppearanceFoundation.Body.
Second
ary"
android:textAppearance=
"@style/AppearanceFoundation.Body.
OnPrim
ary"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/settings_card_dark_pointer"
...
...
app/src/main/res/layout/item_settings_blank.xml
0 → 100644
View file @
73c4b212
<?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"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
<variable
name=
"item"
type=
"com.topjohnwu.magisk.redesign.settings.SettingsItem.Blank"
/>
<variable
name=
"callback"
type=
"com.topjohnwu.magisk.redesign.settings.SettingsItem.Callback"
/>
</data>
<com.google.android.material.card.MaterialCardView
style=
"@style/WidgetFoundation.Card"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"@{(view) -> callback.onItemPressed(view, item)}"
tools:layout_gravity=
"center"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"?listPreferredItemHeightSmall"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/blank_icon"
style=
"@style/WidgetFoundation.Icon"
gone=
"@{item.icon == 0}"
android:background=
"@null"
android:rotation=
"180"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@{item.icon}"
tools:srcCompat=
"@drawable/ic_fingerprint"
/>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/blank_indicator"
style=
"@style/WidgetFoundation.Icon"
android:background=
"@null"
android:rotation=
"180"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_back_md2"
/>
<LinearLayout
android:id=
"@+id/blank_text"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@{item.icon == 0 ? (int) @dimen/l1 : 0}"
android:gravity=
"center_vertical"
android:orientation=
"vertical"
android:paddingTop=
"@dimen/l1"
android:paddingBottom=
"@dimen/l1"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/blank_indicator"
app:layout_constraintStart_toEndOf=
"@+id/blank_icon"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/blank_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:gravity=
"start"
android:text=
"@{item.title}"
android:textAppearance=
"@style/AppearanceFoundation.Body"
android:textStyle=
"bold"
tools:lines=
"1"
tools:text=
"@tools:sample/lorem/random"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/blank_description"
gone=
"@{item.description.empty}"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@{item.description}"
android:textAppearance=
"@style/AppearanceFoundation.Tiny.Variant"
tools:lines=
"2"
tools:text=
"@tools:sample/lorem/random"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
\ No newline at end of file
app/src/main/res/layout/item_settings_section.xml
0 → 100644
View file @
73c4b212
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
<variable
name=
"item"
type=
"com.topjohnwu.magisk.redesign.settings.SettingsItem"
/>
</data>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:paddingTop=
"@dimen/l1"
android:paddingBottom=
"@dimen/l_50"
>
<androidx.appcompat.widget.AppCompatTextView
gone=
"@{item.title.empty}"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@{item.title}"
android:textAppearance=
"@style/AppearanceFoundation.Display.Secondary"
android:textStyle=
"bold"
tools:text=
"@tools:sample/lorem"
/>
<androidx.appcompat.widget.AppCompatTextView
gone=
"@{item.description.empty}"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@{item.description}"
android:textAppearance=
"@style/AppearanceFoundation.Tiny.Bold"
tools:text=
"@tools:sample/lorem/random"
/>
</LinearLayout>
</layout>
\ No newline at end of file
app/src/main/res/layout/item_settings_selector.xml
0 → 100644
View file @
73c4b212
<?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"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
<variable
name=
"item"
type=
"com.topjohnwu.magisk.redesign.settings.SettingsItem.Selector"
/>
<variable
name=
"callback"
type=
"com.topjohnwu.magisk.redesign.settings.SettingsItem.Callback"
/>
</data>
<com.google.android.material.card.MaterialCardView
style=
"@style/WidgetFoundation.Card"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"@{(view) -> callback.onItemPressed(view, item)}"
tools:layout_gravity=
"center"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"?listPreferredItemHeightSmall"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/selector_icon"
style=
"@style/WidgetFoundation.Icon"
gone=
"@{item.icon == 0}"
android:background=
"@null"
android:rotation=
"180"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toTopOf=
"@+id/selector_divider"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@{item.icon}"
tools:srcCompat=
"@drawable/ic_fingerprint"
/>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/selector_indicator"
style=
"@style/WidgetFoundation.Icon"
android:background=
"@null"
android:rotation=
"180"
app:layout_constraintBottom_toTopOf=
"@+id/selector_divider"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_back_md2"
/>
<LinearLayout
android:id=
"@+id/selector_text"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:orientation=
"vertical"
android:paddingTop=
"@dimen/l1"
android:paddingBottom=
"@dimen/l1"
app:layout_constraintBottom_toTopOf=
"@+id/selector_divider"
app:layout_constraintEnd_toStartOf=
"@+id/selector_indicator"
app:layout_constraintStart_toEndOf=
"@+id/selector_icon"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/selector_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginStart=
"@{item.icon == 0 ? (int) @dimen/l1 : 0}"
android:gravity=
"start"
android:text=
"@{item.title}"
android:textAppearance=
"@style/AppearanceFoundation.Body"
android:textStyle=
"bold"
tools:lines=
"1"
tools:text=
"@tools:sample/lorem/random"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/selector_description"
gone=
"@{item.description.empty}"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@{item.description}"
android:textAppearance=
"@style/AppearanceFoundation.Tiny.Variant"
tools:lines=
"2"
tools:text=
"@tools:sample/lorem/random"
/>
</LinearLayout>
<View
android:id=
"@+id/selector_divider"
android:layout_width=
"match_parent"
android:layout_height=
"1.25dp"
android:background=
"?colorOnSurfaceVariant"
app:layout_constraintTop_toBottomOf=
"@+id/selector_text"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/selector_selection"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"@dimen/l1"
android:textAppearance=
"@style/AppearanceFoundation.Caption.Variant"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"@+id/selector_text"
app:layout_constraintTop_toBottomOf=
"@+id/selector_divider"
tools:text=
"@tools:sample/lorem"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
\ No newline at end of file
app/src/main/res/layout/item_settings_toggle.xml
0 → 100644
View file @
73c4b212
<?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"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
<import
type=
"com.topjohnwu.magisk.R"
/>
<variable
name=
"item"
type=
"com.topjohnwu.magisk.redesign.settings.SettingsItem.Toggle"
/>
<variable
name=
"callback"
type=
"com.topjohnwu.magisk.redesign.settings.SettingsItem.Callback"
/>
</data>
<com.google.android.material.card.MaterialCardView
style=
"@style/WidgetFoundation.Card"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"@{(view) -> item.onPressed(view, callback)}"
tools:layout_gravity=
"center"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"?listPreferredItemHeightSmall"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/toggle_icon"
style=
"@style/WidgetFoundation.Icon"
gone=
"@{item.icon == 0}"
android:background=
"@null"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@{item.icon}"
tools:srcCompat=
"@drawable/ic_fingerprint"
/>
<com.google.android.material.switchmaterial.SwitchMaterial
android:id=
"@+id/toggle_indicator"
style=
"@style/WidgetFoundation.Switch"
onTouch=
"@{(view, event) -> item.onTouched(view, callback, event)}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"@dimen/l_25"
android:checked=
"@{item.value}"
android:text=
""
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@{item.icon == 0 ? (int) @dimen/l1 : 0}"
android:layout_marginEnd=
"@dimen/l_50"
android:gravity=
"center_vertical"
android:orientation=
"vertical"
android:paddingTop=
"@dimen/l1"
android:paddingBottom=
"@dimen/l1"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/toggle_indicator"
app:layout_constraintStart_toEndOf=
"@+id/toggle_icon"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/toggle_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:gravity=
"start"
android:text=
"@{item.title}"
android:textAppearance=
"@style/AppearanceFoundation.Body"
android:textStyle=
"bold"
tools:lines=
"1"
tools:text=
"@tools:sample/lorem/random"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/toggle_description"
gone=
"@{item.description.empty}"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@{item.description}"
android:textAppearance=
"@style/AppearanceFoundation.Tiny.Variant"
tools:lines=
"2"
tools:text=
"@tools:sample/lorem/random"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
\ No newline at end of file
app/src/main/res/layout/item_tappable_headline.xml
View file @
73c4b212
...
...
@@ -16,7 +16,7 @@
</data>
<com.google.android.material.card.MaterialCardView
style=
"@style/WidgetFoundation.Card.
Variant.Second
ary"
style=
"@style/WidgetFoundation.Card.
Prim
ary"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"@{() -> listener.onItemPressed(item)}"
...
...
@@ -28,7 +28,7 @@
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/tappable_icon"
style=
"@style/WidgetFoundation.Icon.
Second
ary"
style=
"@style/WidgetFoundation.Icon.
OnPrim
ary"
android:background=
"@null"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -42,7 +42,7 @@
android:requiresFadingEdge=
"horizontal"
android:singleLine=
"true"
android:text=
"@{item.title}"
android:textAppearance=
"@style/AppearanceFoundation.Body.
Second
ary"
android:textAppearance=
"@style/AppearanceFoundation.Body.
OnPrim
ary"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/headline_icon_pointer"
...
...
@@ -52,7 +52,7 @@
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/headline_icon_pointer"
style=
"@style/WidgetFoundation.Icon.
Second
ary"
style=
"@style/WidgetFoundation.Icon.
OnPrim
ary"
android:background=
"@null"
android:rotation=
"180"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
app/src/main/res/values/styles_md2_appearance.xml
View file @
73c4b212
...
...
@@ -6,6 +6,10 @@
<item
name=
"android:textColor"
>
?attr/colorOnSurface
</item>
</style>
<style
name=
"AppearanceFoundation.Display.Secondary"
>
<item
name=
"android:textColor"
>
?colorSecondary
</item>
</style>
<style
name=
"AppearanceFoundation.Display.Variant"
>
<item
name=
"android:textColor"
>
?attr/colorOnSurfaceVariant
</item>
</style>
...
...
@@ -74,6 +78,14 @@
<item
name=
"android:textColor"
>
?attr/colorOnSurfaceVariant
</item>
</style>
<style
name=
"AppearanceFoundation.Caption.Primary"
>
<item
name=
"android:textColor"
>
?attr/colorPrimary
</item>
</style>
<style
name=
"AppearanceFoundation.Caption.Secondary"
>
<item
name=
"android:textColor"
>
?attr/colorSecondary
</item>
</style>
<style
name=
"AppearanceFoundation.Caption.OnPrimary"
>
<item
name=
"android:textColor"
>
?attr/colorOnPrimary
</item>
</style>
...
...
app/src/main/res/values/styles_md2_impl.xml
View file @
73c4b212
...
...
@@ -42,10 +42,6 @@
<item
name=
"strokeColor"
>
?colorPrimary
</item>
</style>
<style
name=
"WidgetFoundation.Card.Variant.Secondary"
>
<item
name=
"strokeColor"
>
?colorSecondary
</item>
</style>
<style
name=
"WidgetFoundation.Card.Elevated"
parent=
"Widget.MaterialComponents.CardView"
>
<item
name=
"cardBackgroundColor"
>
?colorSurfaceSurfaceVariant
</item>
<item
name=
"cardCornerRadius"
>
@dimen/l_50
</item>
...
...
@@ -202,4 +198,9 @@
<item
name=
"android:layout_width"
>
wrap_content
</item>
</style>
<style
name=
"WidgetFoundation.Switch"
parent=
"Widget.AppCompat.CompoundButton.Switch"
>
<item
name=
"thumbTint"
>
@color/color_primary_transient
</item>
</style>
</resources>
\ No newline at end of file
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