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
11600fc1
Commit
11600fc1
authored
Jan 17, 2022
by
vvb2060
Committed by
John Wu
Jan 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use libs instead of copy code
parent
a8640f52
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
45 additions
and
780 deletions
+45
-780
build.gradle.kts
app/build.gradle.kts
+3
-0
BaseUIActivity.kt
...src/main/java/com/topjohnwu/magisk/arch/BaseUIActivity.kt
+3
-1
LayoutInflaterFactory.kt
...m/topjohnwu/magisk/arch/inflater/LayoutInflaterFactory.kt
+0
-85
WindowInsetsHelper.kt
.../com/topjohnwu/magisk/arch/inflater/WindowInsetsHelper.kt
+0
-284
RecyclerView.kt
app/src/main/java/com/topjohnwu/magisk/ktx/RecyclerView.kt
+0
-193
DenyListFragment.kt
...ain/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt
+8
-17
LogFragment.kt
app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt
+8
-17
ModuleFragment.kt
...ain/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt
+8
-114
SettingsFragment.kt
...java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt
+7
-21
SuperuserFragment.kt
...va/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt
+8
-17
attrs.xml
app/src/main/res/values/attrs.xml
+0
-28
ids.xml
app/src/main/res/values/ids.xml
+0
-3
No files found.
app/build.gradle.kts
View file @
11600fc1
...
...
@@ -74,6 +74,9 @@ dependencies {
implementation
(
"com.github.topjohnwu:lz4-java:1.7.1"
)
implementation
(
"com.jakewharton.timber:timber:4.7.1"
)
implementation
(
"org.bouncycastle:bcpkix-jdk15on:1.70"
)
implementation
(
"dev.rikka.rikkax.layoutinflater:layoutinflater:1.2.0"
)
implementation
(
"dev.rikka.rikkax.insets:insets:1.1.1"
)
implementation
(
"dev.rikka.rikkax.recyclerview:recyclerview-ktx:1.3.1"
)
val
vBAdapt
=
"4.0.0"
val
bindingAdapter
=
"me.tatarka.bindingcollectionadapter2:bindingcollectionadapter"
...
...
app/src/main/java/com/topjohnwu/magisk/arch/BaseUIActivity.kt
View file @
11600fc1
...
...
@@ -14,9 +14,10 @@ import androidx.navigation.NavController
import
androidx.navigation.NavDirections
import
androidx.navigation.fragment.NavHostFragment
import
com.topjohnwu.magisk.BR
import
com.topjohnwu.magisk.arch.inflater.LayoutInflaterFactory
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.base.BaseActivity
import
rikka.insets.WindowInsetsHelper
import
rikka.layoutinflater.view.LayoutInflaterFactory
abstract
class
BaseUIActivity
<
VM
:
BaseViewModel
,
Binding
:
ViewDataBinding
>
:
BaseActivity
(),
BaseUIComponent
<
VM
>
{
...
...
@@ -44,6 +45,7 @@ abstract class BaseUIActivity<VM : BaseViewModel, Binding : ViewDataBinding> :
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
layoutInflater
.
factory2
=
LayoutInflaterFactory
(
delegate
)
.
addOnViewCreatedListener
(
WindowInsetsHelper
.
LISTENER
)
super
.
onCreate
(
savedInstanceState
)
...
...
app/src/main/java/com/topjohnwu/magisk/arch/inflater/LayoutInflaterFactory.kt
deleted
100644 → 0
View file @
a8640f52
package
com.topjohnwu.magisk.arch.inflater
import
android.content.Context
import
android.util.AttributeSet
import
android.view.InflateException
import
android.view.LayoutInflater
import
android.view.View
import
androidx.appcompat.app.AppCompatDelegate
import
androidx.collection.SimpleArrayMap
import
java.lang.reflect.Constructor
open
class
LayoutInflaterFactory
(
private
val
delegate
:
AppCompatDelegate
)
:
LayoutInflater
.
Factory2
{
override
fun
onCreateView
(
name
:
String
,
context
:
Context
,
attrs
:
AttributeSet
):
View
?
{
return
onCreateView
(
null
,
name
,
context
,
attrs
)
}
override
fun
onCreateView
(
parent
:
View
?,
name
:
String
,
context
:
Context
,
attrs
:
AttributeSet
):
View
?
{
val
view
=
delegate
.
createView
(
parent
,
name
,
context
,
attrs
)
?:
LayoutInflaterFactoryDefaultImpl
.
createViewFromTag
(
context
,
name
,
attrs
)
onViewCreated
(
view
,
parent
,
name
,
context
,
attrs
)
return
view
}
open
fun
onViewCreated
(
view
:
View
?,
parent
:
View
?,
name
:
String
,
context
:
Context
,
attrs
:
AttributeSet
)
{
if
(
view
==
null
)
return
WindowInsetsHelper
.
attach
(
view
,
attrs
)
}
}
private
object
LayoutInflaterFactoryDefaultImpl
{
private
val
constructorSignature
=
arrayOf
(
Context
::
class
.
java
,
AttributeSet
::
class
.
java
)
private
val
classPrefixList
=
arrayOf
(
"android.widget."
,
"android.view."
,
"android.webkit."
)
private
val
constructorMap
=
SimpleArrayMap
<
String
,
Constructor
<
out
View
?>>()
fun
createViewFromTag
(
context
:
Context
,
name
:
String
,
attrs
:
AttributeSet
):
View
?
{
var
name
=
name
if
(
name
==
"view"
)
{
name
=
attrs
.
getAttributeValue
(
null
,
"class"
)
}
return
try
{
if
(-
1
==
name
.
indexOf
(
'.'
))
{
for
(
prefix
in
classPrefixList
)
{
val
view
:
View
?
=
createViewByPrefix
(
context
,
name
,
attrs
,
prefix
)
if
(
view
!=
null
)
{
return
view
}
}
null
}
else
{
createViewByPrefix
(
context
,
name
,
attrs
,
null
)
}
}
catch
(
e
:
Exception
)
{
null
}
}
@Throws
(
ClassNotFoundException
::
class
,
InflateException
::
class
)
private
fun
createViewByPrefix
(
context
:
Context
,
name
:
String
,
attrs
:
AttributeSet
,
prefix
:
String
?):
View
?
{
var
constructor
=
constructorMap
[
name
]
return
try
{
if
(
constructor
==
null
)
{
// Class not found in the cache, see if it's real, and try to add it
val
clazz
=
Class
.
forName
(
if
(
prefix
!=
null
)
prefix
+
name
else
name
,
false
,
context
.
classLoader
).
asSubclass
(
View
::
class
.
java
)
constructor
=
clazz
.
getConstructor
(*
constructorSignature
)
constructorMap
.
put
(
name
,
constructor
)
}
constructor
!!
.
isAccessible
=
true
constructor
.
newInstance
(
context
,
attrs
)
}
catch
(
e
:
Exception
)
{
null
}
}
}
app/src/main/java/com/topjohnwu/magisk/arch/inflater/WindowInsetsHelper.kt
deleted
100644 → 0
View file @
a8640f52
This diff is collapsed.
Click to expand it.
app/src/main/java/com/topjohnwu/magisk/ktx/RecyclerView.kt
deleted
100644 → 0
View file @
a8640f52
@file
:
Suppress
(
"unused"
)
package
com.topjohnwu.magisk.ktx
import
android.graphics.Canvas
import
android.graphics.Rect
import
android.view.View
import
android.widget.EdgeEffect
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.topjohnwu.magisk.R
fun
RecyclerView
.
addInvalidateItemDecorationsObserver
()
{
adapter
?.
registerAdapterDataObserver
(
object
:
RecyclerView
.
AdapterDataObserver
()
{
override
fun
onItemRangeInserted
(
positionStart
:
Int
,
itemCount
:
Int
)
{
invalidateItemDecorations
()
}
override
fun
onItemRangeRemoved
(
positionStart
:
Int
,
itemCount
:
Int
)
{
invalidateItemDecorations
()
}
override
fun
onItemRangeMoved
(
fromPosition
:
Int
,
toPosition
:
Int
,
itemCount
:
Int
)
{
invalidateItemDecorations
()
}
})
}
fun
RecyclerView
.
addVerticalPadding
(
paddingTop
:
Int
=
0
,
paddingBottom
:
Int
=
0
)
{
addItemDecoration
(
VerticalPaddingDecoration
(
paddingTop
,
paddingBottom
))
}
private
class
VerticalPaddingDecoration
(
private
val
paddingTop
:
Int
=
0
,
private
val
paddingBottom
:
Int
=
0
)
:
RecyclerView
.
ItemDecoration
()
{
private
var
allowTop
:
Boolean
=
true
private
var
allowBottom
:
Boolean
=
true
override
fun
getItemOffsets
(
outRect
:
Rect
,
view
:
View
,
parent
:
RecyclerView
,
state
:
RecyclerView
.
State
)
{
val
adapter
=
parent
.
adapter
?:
return
val
position
=
parent
.
getChildAdapterPosition
(
view
)
val
count
=
adapter
.
itemCount
if
(
position
==
0
&&
allowTop
)
{
outRect
.
top
=
paddingTop
}
else
if
(
position
==
count
-
1
&&
allowBottom
)
{
outRect
.
bottom
=
paddingBottom
}
}
}
fun
RecyclerView
.
addSimpleItemDecoration
(
left
:
Int
=
0
,
top
:
Int
=
0
,
right
:
Int
=
0
,
bottom
:
Int
=
0
,
)
{
addItemDecoration
(
SimpleItemDecoration
(
left
,
top
,
right
,
bottom
))
}
private
class
SimpleItemDecoration
(
private
val
left
:
Int
=
0
,
private
val
top
:
Int
=
0
,
private
val
right
:
Int
=
0
,
private
val
bottom
:
Int
=
0
)
:
RecyclerView
.
ItemDecoration
()
{
private
var
allowLeft
:
Boolean
=
true
private
var
allowTop
:
Boolean
=
true
private
var
allowRight
:
Boolean
=
true
private
var
allowBottom
:
Boolean
=
true
override
fun
getItemOffsets
(
outRect
:
Rect
,
view
:
View
,
parent
:
RecyclerView
,
state
:
RecyclerView
.
State
)
{
if
(
parent
.
adapter
==
null
)
{
return
}
if
(
allowLeft
)
{
outRect
.
left
=
left
}
if
(
allowTop
)
{
outRect
.
top
=
top
}
if
(
allowRight
)
{
outRect
.
right
=
right
}
if
(
allowBottom
)
{
outRect
.
top
=
bottom
}
}
}
fun
RecyclerView
.
fixEdgeEffect
(
overScrollIfContentScrolls
:
Boolean
=
true
,
alwaysClipToPadding
:
Boolean
=
true
)
{
if
(
overScrollIfContentScrolls
)
{
val
listener
=
OverScrollIfContentScrollsListener
()
addOnLayoutChangeListener
(
listener
)
setTag
(
R
.
id
.
tag_rikka_recyclerView_OverScrollIfContentScrollsListener
,
listener
)
}
else
{
val
listener
=
getTag
(
R
.
id
.
tag_rikka_recyclerView_OverScrollIfContentScrollsListener
)
as
?
OverScrollIfContentScrollsListener
if
(
listener
!=
null
)
{
removeOnLayoutChangeListener
(
listener
)
setTag
(
R
.
id
.
tag_rikka_recyclerView_OverScrollIfContentScrollsListener
,
null
)
}
}
edgeEffectFactory
=
if
(
alwaysClipToPadding
&&
!
clipToPadding
)
{
AlwaysClipToPaddingEdgeEffectFactory
()
}
else
{
RecyclerView
.
EdgeEffectFactory
()
}
}
private
class
OverScrollIfContentScrollsListener
:
View
.
OnLayoutChangeListener
{
private
var
show
=
true
override
fun
onLayoutChange
(
v
:
View
,
left
:
Int
,
top
:
Int
,
right
:
Int
,
bottom
:
Int
,
oldLeft
:
Int
,
oldTop
:
Int
,
oldRight
:
Int
,
oldBottom
:
Int
)
{
if
(
shouldDrawOverScroll
(
v
as
RecyclerView
)
!=
show
)
{
show
=
!
show
if
(
show
)
{
v
.
setOverScrollMode
(
View
.
OVER_SCROLL_IF_CONTENT_SCROLLS
)
}
else
{
v
.
setOverScrollMode
(
View
.
OVER_SCROLL_NEVER
)
}
}
}
fun
shouldDrawOverScroll
(
recyclerView
:
RecyclerView
):
Boolean
{
if
(
recyclerView
.
layoutManager
==
null
||
recyclerView
.
adapter
==
null
||
recyclerView
.
adapter
!!
.
itemCount
==
0
)
{
return
false
}
if
(
recyclerView
.
layoutManager
is
LinearLayoutManager
)
{
val
itemCount
=
recyclerView
.
layoutManager
!!
.
itemCount
val
firstPosition
:
Int
=
(
recyclerView
.
layoutManager
as
LinearLayoutManager
?)
!!
.
findFirstCompletelyVisibleItemPosition
()
val
lastPosition
:
Int
=
(
recyclerView
.
layoutManager
as
LinearLayoutManager
?)
!!
.
findLastCompletelyVisibleItemPosition
()
return
firstPosition
!=
0
||
lastPosition
!=
itemCount
-
1
}
return
true
}
}
private
class
AlwaysClipToPaddingEdgeEffectFactory
:
RecyclerView
.
EdgeEffectFactory
()
{
override
fun
createEdgeEffect
(
view
:
RecyclerView
,
direction
:
Int
):
EdgeEffect
{
return
object
:
EdgeEffect
(
view
.
context
)
{
private
var
ensureSize
=
false
private
fun
ensureSize
()
{
if
(
ensureSize
)
return
ensureSize
=
true
when
(
direction
)
{
DIRECTION_LEFT
->
{
setSize
(
view
.
measuredHeight
-
view
.
paddingTop
-
view
.
paddingBottom
,
view
.
measuredWidth
-
view
.
paddingLeft
-
view
.
paddingRight
)
}
DIRECTION_TOP
->
{
setSize
(
view
.
measuredWidth
-
view
.
paddingLeft
-
view
.
paddingRight
,
view
.
measuredHeight
-
view
.
paddingTop
-
view
.
paddingBottom
)
}
DIRECTION_RIGHT
->
{
setSize
(
view
.
measuredHeight
-
view
.
paddingTop
-
view
.
paddingBottom
,
view
.
measuredWidth
-
view
.
paddingLeft
-
view
.
paddingRight
)
}
DIRECTION_BOTTOM
->
{
setSize
(
view
.
measuredWidth
-
view
.
paddingLeft
-
view
.
paddingRight
,
view
.
measuredHeight
-
view
.
paddingTop
-
view
.
paddingBottom
)
}
}
}
override
fun
draw
(
c
:
Canvas
):
Boolean
{
ensureSize
()
val
restore
=
c
.
save
()
when
(
direction
)
{
DIRECTION_LEFT
->
{
c
.
translate
(
view
.
paddingBottom
.
toFloat
(),
0f
)
}
DIRECTION_TOP
->
{
c
.
translate
(
view
.
paddingLeft
.
toFloat
(),
view
.
paddingTop
.
toFloat
())
}
DIRECTION_RIGHT
->
{
c
.
translate
(-
view
.
paddingTop
.
toFloat
(),
0f
)
}
DIRECTION_BOTTOM
->
{
c
.
translate
(
view
.
paddingRight
.
toFloat
(),
view
.
paddingBottom
.
toFloat
())
}
}
val
res
=
super
.
draw
(
c
)
c
.
restoreToCount
(
restore
)
return
res
}
}
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt
View file @
11600fc1
...
...
@@ -12,10 +12,10 @@ import com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.BaseUIFragment
import
com.topjohnwu.magisk.databinding.FragmentDenyMd2Binding
import
com.topjohnwu.magisk.di.viewModel
import
com.topjohnwu.magisk.ktx.addSimpleItemDecoration
import
com.topjohnwu.magisk.ktx.addVerticalPadding
import
com.topjohnwu.magisk.ktx.fixEdgeEffect
import
com.topjohnwu.magisk.ktx.hideKeyboard
import
rikka.recyclerview.addEdgeSpacing
import
rikka.recyclerview.addItemSpacing
import
rikka.recyclerview.fixEdgeEffect
class
DenyListFragment
:
BaseUIFragment
<
DenyListViewModel
,
FragmentDenyMd2Binding
>()
{
...
...
@@ -39,20 +39,11 @@ class DenyListFragment : BaseUIFragment<DenyListViewModel, FragmentDenyMd2Bindin
}
})
val
resource
=
requireContext
().
resources
val
l_50
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l_50
)
val
l1
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l1
)
binding
.
appList
.
addVerticalPadding
(
l_50
,
l1
+
resource
.
getDimensionPixelSize
(
R
.
dimen
.
internal_action_bar_size
)
)
binding
.
appList
.
addSimpleItemDecoration
(
left
=
l1
,
top
=
l_50
,
right
=
l1
,
bottom
=
l_50
,
)
binding
.
appList
.
fixEdgeEffect
()
binding
.
appList
.
apply
{
addEdgeSpacing
(
top
=
R
.
dimen
.
l_50
,
bottom
=
R
.
dimen
.
l1
)
addItemSpacing
(
R
.
dimen
.
l1
,
R
.
dimen
.
l_50
,
R
.
dimen
.
l1
)
fixEdgeEffect
()
}
}
override
fun
onPreBind
(
binding
:
FragmentDenyMd2Binding
)
=
Unit
...
...
app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt
View file @
11600fc1
...
...
@@ -10,11 +10,11 @@ import com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.BaseUIFragment
import
com.topjohnwu.magisk.databinding.FragmentLogMd2Binding
import
com.topjohnwu.magisk.di.viewModel
import
com.topjohnwu.magisk.ktx.addSimpleItemDecoration
import
com.topjohnwu.magisk.ktx.addVerticalPadding
import
com.topjohnwu.magisk.ktx.fixEdgeEffect
import
com.topjohnwu.magisk.ui.MainActivity
import
com.topjohnwu.magisk.utils.MotionRevealHelper
import
rikka.recyclerview.addEdgeSpacing
import
rikka.recyclerview.addItemSpacing
import
rikka.recyclerview.fixEdgeEffect
class
LogFragment
:
BaseUIFragment
<
LogViewModel
,
FragmentLogMd2Binding
>()
{
...
...
@@ -47,20 +47,11 @@ class LogFragment : BaseUIFragment<LogViewModel, FragmentLogMd2Binding>() {
isMagiskLogVisible
=
true
}
val
resource
=
requireContext
().
resources
val
l_50
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l_50
)
val
l1
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l1
)
binding
.
logFilterSuperuser
.
logSuperuser
.
addVerticalPadding
(
0
,
l1
)
binding
.
logFilterSuperuser
.
logSuperuser
.
addSimpleItemDecoration
(
left
=
l1
,
top
=
l_50
,
right
=
l1
,
bottom
=
l_50
,
)
binding
.
logFilterSuperuser
.
logSuperuser
.
fixEdgeEffect
()
binding
.
logFilterSuperuser
.
logSuperuser
.
apply
{
addEdgeSpacing
(
bottom
=
R
.
dimen
.
l1
)
addItemSpacing
(
R
.
dimen
.
l1
,
R
.
dimen
.
l_50
,
R
.
dimen
.
l1
)
fixEdgeEffect
()
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt
View file @
11600fc1
package
com.topjohnwu.magisk.ui.module
import
android.os.Bundle
import
android.view.Menu
import
android.view.MenuInflater
import
android.view.MenuItem
import
android.view.View
import
androidx.core.view.isVisible
import
androidx.recyclerview.widget.RecyclerView
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.BaseUIFragment
import
com.topjohnwu.magisk.arch.ReselectionTarget
import
com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding
import
com.topjohnwu.magisk.di.viewModel
import
com.topjohnwu.magisk.ktx.*
import
com.topjohnwu.magisk.ui.MainActivity
import
com.topjohnwu.magisk.utils.EndlessRecyclerScrollListener
import
com.topjohnwu.magisk.utils.MotionRevealHelper
import
rikka.recyclerview.addEdgeSpacing
import
rikka.recyclerview.addInvalidateItemDecorationsObserver
import
rikka.recyclerview.addItemSpacing
import
rikka.recyclerview.fixEdgeEffect
class
ModuleFragment
:
BaseUIFragment
<
ModuleViewModel
,
FragmentModuleMd2Binding
>(),
ReselectionTarget
{
class
ModuleFragment
:
BaseUIFragment
<
ModuleViewModel
,
FragmentModuleMd2Binding
>()
{
override
val
layoutRes
=
R
.
layout
.
fragment_module_md2
override
val
viewModel
by
viewModel
<
ModuleViewModel
>()
override
val
snackbarAnchorView
:
View
get
()
{
return
if
(
isFilterVisible
)
{
binding
.
moduleFilterInclude
.
moduleFilterTitleSearch
}
else
{
binding
.
moduleFilterToggle
}
}
private
val
listeners
=
hashSetOf
<
EndlessRecyclerScrollListener
>()
private
var
isFilterVisible
get
()
=
binding
.
moduleFilter
.
isVisible
set
(
value
)
{
if
(!
value
)
hideKeyboard
()
MotionRevealHelper
.
withViews
(
binding
.
moduleFilter
,
binding
.
moduleFilterToggle
,
value
)
with
(
activity
as
MainActivity
)
{
requestNavigationHidden
(
value
)
setDisplayHomeAsUpEnabled
(
value
)
}
}
override
fun
onStart
()
{
super
.
onStart
()
...
...
@@ -53,92 +25,14 @@ class ModuleFragment : BaseUIFragment<ModuleViewModel, FragmentModuleMd2Binding>
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
binding
.
moduleFilterToggle
.
setOnClickListener
{
isFilterVisible
=
true
}
binding
.
moduleFilterInclude
.
moduleFilterDone
.
setOnClickListener
{
isFilterVisible
=
false
}
binding
.
moduleFilterInclude
.
moduleFilterList
.
addOnScrollListener
(
object
:
RecyclerView
.
OnScrollListener
()
{
override
fun
onScrollStateChanged
(
recyclerView
:
RecyclerView
,
newState
:
Int
)
{
if
(
newState
!=
RecyclerView
.
SCROLL_STATE_IDLE
)
hideKeyboard
()
}
})
val
resource
=
requireContext
().
resources
val
l_50
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l_50
)
val
l1
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l1
)
binding
.
moduleList
.
apply
{
addVerticalPadding
(
l_50
,
l1
+
l_50
+
resource
.
getDimensionPixelSize
(
R
.
dimen
.
internal_action_bar_size
)
)
addSimpleItemDecoration
(
left
=
l1
,
top
=
l_50
,
right
=
l1
,
bottom
=
l_50
,
)
addEdgeSpacing
(
top
=
R
.
dimen
.
l_50
,
bottom
=
R
.
dimen
.
l1
)
addItemSpacing
(
R
.
dimen
.
l1
,
R
.
dimen
.
l_50
,
R
.
dimen
.
l1
)
fixEdgeEffect
()
post
{
addInvalidateItemDecorationsObserver
()
}
}
binding
.
moduleFilterInclude
.
moduleFilterList
.
apply
{
addVerticalPadding
(
l_50
,
l_50
)
addSimpleItemDecoration
(
left
=
l1
,
top
=
l_50
,
right
=
l1
,
bottom
=
l_50
,
)
fixEdgeEffect
()
}
}
override
fun
onDestroyView
()
{
listeners
.
forEach
{
binding
.
moduleList
.
removeOnScrollListener
(
it
)
binding
.
moduleFilterInclude
.
moduleFilterList
.
removeOnScrollListener
(
it
)
post
{
addInvalidateItemDecorationsObserver
()
}
}
super
.
onDestroyView
()
}
override
fun
onBackPressed
():
Boolean
{
if
(
isFilterVisible
)
{
isFilterVisible
=
false
return
true
}
return
super
.
onBackPressed
()
}
// ---
override
fun
onCreateOptionsMenu
(
menu
:
Menu
,
inflater
:
MenuInflater
)
{
inflater
.
inflate
(
R
.
menu
.
menu_module_md2
,
menu
)
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
):
Boolean
{
when
(
item
.
itemId
)
{
R
.
id
.
action_refresh
->
viewModel
.
forceRefresh
()
}
return
super
.
onOptionsItemSelected
(
item
)
}
// ---
override
fun
onReselected
()
{
binding
.
moduleList
.
scrollToPosition
(
10
)
binding
.
moduleList
.
also
{
it
.
post
{
it
.
smoothScrollToPosition
(
0
)
}
}
}
// ---
override
fun
onPreBind
(
binding
:
FragmentModuleMd2Binding
)
=
Unit
}
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt
View file @
11600fc1
...
...
@@ -6,10 +6,9 @@ import com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.BaseUIFragment
import
com.topjohnwu.magisk.databinding.FragmentSettingsMd2Binding
import
com.topjohnwu.magisk.di.viewModel
import
com.topjohnwu.magisk.ktx.addSimpleItemDecoration
import
com.topjohnwu.magisk.ktx.addVerticalPadding
import
com.topjohnwu.magisk.ktx.fixEdgeEffect
import
com.topjohnwu.magisk.ktx.setOnViewReadyListener
import
rikka.recyclerview.addEdgeSpacing
import
rikka.recyclerview.addItemSpacing
import
rikka.recyclerview.fixEdgeEffect
class
SettingsFragment
:
BaseUIFragment
<
SettingsViewModel
,
FragmentSettingsMd2Binding
>()
{
...
...
@@ -24,24 +23,11 @@ class SettingsFragment : BaseUIFragment<SettingsViewModel, FragmentSettingsMd2Bi
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
binding
.
settingsList
.
setOnViewReadyListener
{
binding
.
settingsList
.
scrollToPosition
(
0
)
binding
.
settingsList
.
apply
{
addEdgeSpacing
(
bottom
=
R
.
dimen
.
l1
)
addItemSpacing
(
R
.
dimen
.
l1
,
R
.
dimen
.
l_50
,
R
.
dimen
.
l1
)
fixEdgeEffect
()
}
val
resource
=
requireContext
().
resources
val
l_50
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l_50
)
val
l1
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l1
)
binding
.
settingsList
.
addVerticalPadding
(
0
,
l1
)
binding
.
settingsList
.
addSimpleItemDecoration
(
left
=
l1
,
top
=
l_50
,
right
=
l1
,
bottom
=
l_50
,
)
binding
.
settingsList
.
fixEdgeEffect
()
}
override
fun
onResume
()
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt
View file @
11600fc1
...
...
@@ -6,9 +6,9 @@ import com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.BaseUIFragment
import
com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding
import
com.topjohnwu.magisk.di.viewModel
import
com.topjohnwu.magisk.ktx.addSimpleItemDecoration
import
com.topjohnwu.magisk.ktx.addVerticalPadd
ing
import
com.topjohnwu.magisk.ktx
.fixEdgeEffect
import
rikka.recyclerview.addEdgeSpacing
import
rikka.recyclerview.addItemSpac
ing
import
rikka.recyclerview
.fixEdgeEffect
class
SuperuserFragment
:
BaseUIFragment
<
SuperuserViewModel
,
FragmentSuperuserMd2Binding
>()
{
...
...
@@ -23,20 +23,11 @@ class SuperuserFragment : BaseUIFragment<SuperuserViewModel, FragmentSuperuserMd
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
val
resource
=
requireContext
().
resources
val
l_50
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l_50
)
val
l1
=
resource
.
getDimensionPixelSize
(
R
.
dimen
.
l1
)
binding
.
superuserList
.
addVerticalPadding
(
l_50
,
l1
)
binding
.
superuserList
.
addSimpleItemDecoration
(
left
=
l1
,
top
=
l_50
,
right
=
l1
,
bottom
=
l_50
,
)
binding
.
superuserList
.
fixEdgeEffect
()
binding
.
superuserList
.
apply
{
addEdgeSpacing
(
top
=
R
.
dimen
.
l_50
,
bottom
=
R
.
dimen
.
l1
)
addItemSpacing
(
R
.
dimen
.
l1
,
R
.
dimen
.
l_50
,
R
.
dimen
.
l1
)
fixEdgeEffect
()
}
}
override
fun
onPreBind
(
binding
:
FragmentSuperuserMd2Binding
)
{}
...
...
app/src/main/res/values/attrs.xml
View file @
11600fc1
...
...
@@ -19,34 +19,6 @@
<!--endregion-->
<declare-styleable
name=
"WindowInsetsHelper"
>
<attr
name=
"edgeToEdge"
format=
"boolean"
/>
<attr
name=
"fitsSystemWindowsInsets"
format=
"flags"
>
<flag
name=
"top"
value=
"0x30"
/>
<flag
name=
"bottom"
value=
"0x50"
/>
<flag
name=
"left"
value=
"0x03"
/>
<flag
name=
"right"
value=
"0x05"
/>
<flag
name=
"start"
value=
"0x00800003"
/>
<flag
name=
"end"
value=
"0x00800005"
/>
</attr>
<attr
name=
"consumeSystemWindowsInsets"
format=
"flags"
>
<flag
name=
"top"
value=
"0x30"
/>
<flag
name=
"bottom"
value=
"0x50"
/>
<flag
name=
"left"
value=
"0x03"
/>
<flag
name=
"right"
value=
"0x05"
/>
<flag
name=
"start"
value=
"0x00800003"
/>
<flag
name=
"end"
value=
"0x00800005"
/>
</attr>
<attr
name=
"layout_fitsSystemWindowsInsets"
format=
"flags"
>
<flag
name=
"top"
value=
"0x30"
/>
<flag
name=
"bottom"
value=
"0x50"
/>
<flag
name=
"left"
value=
"0x03"
/>
<flag
name=
"right"
value=
"0x05"
/>
<flag
name=
"start"
value=
"0x00800003"
/>
<flag
name=
"end"
value=
"0x00800005"
/>
</attr>
</declare-styleable>
<declare-styleable
name=
"ConcealableView"
>
<attr
name=
"state_hidden"
format=
"boolean"
/>
</declare-styleable>
...
...
app/src/main/res/values/ids.xml
View file @
11600fc1
...
...
@@ -2,7 +2,4 @@
<resources>
<item
name=
"recyclerScrollListener"
type=
"id"
/>
<item
name=
"coroutineScope"
type=
"id"
/>
<item
name=
"tag_rikka_material_WindowInsetsHelper"
type=
"id"
/>
<item
name=
"tag_rikka_recyclerView_OverScrollIfContentScrollsListener"
type=
"id"
/>
</resources>
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