mirror of
https://github.com/kuba2k2/NavLib.git
synced 2025-01-18 06:16:43 -06:00
Fix setting drawer drag margin on Android 10+
This commit is contained in:
parent
7430169359
commit
578306480b
@ -1,2 +1 @@
|
||||
-keep class androidx.drawerlayout.widget.DrawerLayout { *; }
|
||||
-keep class androidx.customview.widget.ViewDragHelper { *; }
|
1
navlib/proguard-rules.pro
vendored
1
navlib/proguard-rules.pro
vendored
@ -21,4 +21,3 @@
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
-keep class androidx.drawerlayout.widget.DrawerLayout { *; }
|
||||
-keep class androidx.customview.widget.ViewDragHelper { *; }
|
@ -280,19 +280,17 @@ class NavDrawer(
|
||||
val mDrawerLayout = drawerLayout
|
||||
val mDragger = mDrawerLayout::class.java.getDeclaredField(
|
||||
"mLeftDragger"
|
||||
)//mRightDragger for right obviously
|
||||
)
|
||||
mDragger.isAccessible = true
|
||||
val draggerObj = mDragger.get(mDrawerLayout) as ViewDragHelper?
|
||||
draggerObj?.edgeSize = size.toInt()
|
||||
|
||||
val mEdgeSize = draggerObj?.javaClass?.getDeclaredField(
|
||||
"mEdgeSize"
|
||||
// update for SDK >= 29 (Android 10)
|
||||
val useSystemInsets = mDrawerLayout::class.java.getDeclaredField(
|
||||
"sEdgeSizeUsingSystemGestureInsets"
|
||||
)
|
||||
mEdgeSize?.isAccessible = true
|
||||
|
||||
mEdgeSize?.setInt(
|
||||
draggerObj,
|
||||
size.toInt()
|
||||
) //optimal value as for me, you may set any constant in dp
|
||||
useSystemInsets.isAccessible = true
|
||||
useSystemInsets.set(null, false)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
Loading…
x
Reference in New Issue
Block a user