mirror of
https://github.com/kuba2k2/NavLib.git
synced 2025-01-18 14:16:44 -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.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
|
#-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
-keep class androidx.drawerlayout.widget.DrawerLayout { *; }
|
-keep class androidx.drawerlayout.widget.DrawerLayout { *; }
|
||||||
-keep class androidx.customview.widget.ViewDragHelper { *; }
|
|
@ -280,19 +280,17 @@ class NavDrawer(
|
|||||||
val mDrawerLayout = drawerLayout
|
val mDrawerLayout = drawerLayout
|
||||||
val mDragger = mDrawerLayout::class.java.getDeclaredField(
|
val mDragger = mDrawerLayout::class.java.getDeclaredField(
|
||||||
"mLeftDragger"
|
"mLeftDragger"
|
||||||
)//mRightDragger for right obviously
|
)
|
||||||
mDragger.isAccessible = true
|
mDragger.isAccessible = true
|
||||||
val draggerObj = mDragger.get(mDrawerLayout) as ViewDragHelper?
|
val draggerObj = mDragger.get(mDrawerLayout) as ViewDragHelper?
|
||||||
|
draggerObj?.edgeSize = size.toInt()
|
||||||
|
|
||||||
val mEdgeSize = draggerObj?.javaClass?.getDeclaredField(
|
// update for SDK >= 29 (Android 10)
|
||||||
"mEdgeSize"
|
val useSystemInsets = mDrawerLayout::class.java.getDeclaredField(
|
||||||
|
"sEdgeSizeUsingSystemGestureInsets"
|
||||||
)
|
)
|
||||||
mEdgeSize?.isAccessible = true
|
useSystemInsets.isAccessible = true
|
||||||
|
useSystemInsets.set(null, false)
|
||||||
mEdgeSize?.setInt(
|
|
||||||
draggerObj,
|
|
||||||
size.toInt()
|
|
||||||
) //optimal value as for me, you may set any constant in dp
|
|
||||||
}
|
}
|
||||||
catch (e: Exception) {
|
catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user