hybrid-navigation 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,636 @@
1
+ package com.navigation.androidx;
2
+
3
+ import android.app.Activity;
4
+ import android.content.Context;
5
+ import android.content.ContextWrapper;
6
+ import android.graphics.Rect;
7
+ import android.os.Build;
8
+ import android.util.AttributeSet;
9
+ import android.view.Gravity;
10
+ import android.view.HapticFeedbackConstants;
11
+ import android.view.MotionEvent;
12
+ import android.view.VelocityTracker;
13
+ import android.view.View;
14
+ import android.view.ViewConfiguration;
15
+ import android.view.ViewGroup;
16
+ import android.window.BackEvent;
17
+ import android.window.OnBackAnimationCallback;
18
+ import android.window.OnBackInvokedCallback;
19
+ import android.window.OnBackInvokedDispatcher;
20
+
21
+ import com.facebook.react.uimanager.RootView;
22
+ import com.facebook.react.uimanager.events.NativeGestureUtil;
23
+
24
+ import java.lang.reflect.Field;
25
+ import java.lang.reflect.InvocationTargetException;
26
+ import java.lang.reflect.Method;
27
+ import java.util.ArrayList;
28
+ import java.util.Collections;
29
+
30
+ import androidx.core.view.GravityCompat;
31
+ import androidx.customview.widget.ViewDragHelper;
32
+ import androidx.drawerlayout.widget.DrawerLayout;
33
+ import androidx.appcompat.app.AppCompatActivity;
34
+
35
+ public class HybridDrawerLayout extends DrawerLayout {
36
+
37
+ private static final int DRAG_NONE = 0;
38
+ private static final int DRAG_OPEN = 1;
39
+ private static final int DRAG_CLOSE = 2;
40
+ private static final int SYSTEM_GESTURE_EXCLUSION_WIDTH_DP = 200;
41
+ private static final int OPEN_EDGE_WIDTH_DP = SYSTEM_GESTURE_EXCLUSION_WIDTH_DP;
42
+ private static final int OPEN_GESTURE_ACTIVATION_DISTANCE_DP = 24;
43
+ private static final int SETTLE_VELOCITY_DP = 350;
44
+ private static final float HORIZONTAL_ACTIVATION_RATIO = 1.2f;
45
+ private static final float OPEN_SETTLE_THRESHOLD = 0.22f;
46
+ private static final float CLOSE_SETTLE_THRESHOLD = 0.78f;
47
+ private static final float DRAWER_CLOSED_EPSILON = 0.01f;
48
+
49
+ private final int openEdgeWidth;
50
+ private final int systemGestureExclusionWidth;
51
+ private final int openGestureTriggerDistance;
52
+ private final int settleVelocity;
53
+ private final int touchSlop;
54
+ private float downX;
55
+ private float downY;
56
+ private float dragStartProgress;
57
+ private boolean closeDragCandidate;
58
+ private boolean openDragCandidate;
59
+ private boolean openGestureEnabled;
60
+ private boolean nativeGestureStarted;
61
+ private int activeDragMode = DRAG_NONE;
62
+ private View activeDrawerChild;
63
+ private View activeNativeGestureView;
64
+ private VelocityTracker velocityTracker;
65
+ private OnBackInvokedCallback backGestureCallback;
66
+ private boolean backGestureCallbackRegistered;
67
+ private boolean backGestureActive;
68
+ private float backGestureProgress;
69
+ private Method getDrawerViewOffsetMethod;
70
+ private Method moveDrawerToOffsetMethod;
71
+
72
+ public HybridDrawerLayout(Context context) {
73
+ this(context, null);
74
+ }
75
+
76
+ public HybridDrawerLayout(Context context, AttributeSet attrs) {
77
+ this(context, attrs, 0);
78
+ }
79
+
80
+ public HybridDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
81
+ super(context, attrs, defStyle);
82
+ float density = getResources().getDisplayMetrics().density;
83
+ openEdgeWidth = Math.round(OPEN_EDGE_WIDTH_DP * density);
84
+ systemGestureExclusionWidth = Math.round(SYSTEM_GESTURE_EXCLUSION_WIDTH_DP * density);
85
+ touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
86
+ openGestureTriggerDistance = Math.max(touchSlop * 2, Math.round(OPEN_GESTURE_ACTIVATION_DISTANCE_DP * density));
87
+ settleVelocity = Math.round(SETTLE_VELOCITY_DP * density);
88
+ setupDrawerInternals();
89
+ }
90
+
91
+ public void setOpenGestureEnabled(boolean enabled) {
92
+ openGestureEnabled = enabled;
93
+ updateSystemGestureExclusionRect();
94
+ updateBackGestureCallback();
95
+ }
96
+
97
+ @Override
98
+ public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
99
+ if (disallowIntercept && (openDragCandidate || activeDragMode != DRAG_NONE)) {
100
+ super.requestDisallowInterceptTouchEvent(false);
101
+ return;
102
+ }
103
+ super.requestDisallowInterceptTouchEvent(disallowIntercept);
104
+ }
105
+
106
+ @Override
107
+ protected void onAttachedToWindow() {
108
+ super.onAttachedToWindow();
109
+ updateSystemGestureExclusionRect();
110
+ updateBackGestureCallback();
111
+ }
112
+
113
+ @Override
114
+ protected void onDetachedFromWindow() {
115
+ unregisterBackGestureCallback();
116
+ super.onDetachedFromWindow();
117
+ }
118
+
119
+ @Override
120
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
121
+ super.onSizeChanged(w, h, oldw, oldh);
122
+ updateSystemGestureExclusionRect();
123
+ }
124
+
125
+ @Override
126
+ public boolean dispatchTouchEvent(MotionEvent event) {
127
+ int action = event.getActionMasked();
128
+ if (action == MotionEvent.ACTION_DOWN) {
129
+ beginTouchTracking(event);
130
+ } else if (velocityTracker != null) {
131
+ velocityTracker.addMovement(event);
132
+ }
133
+
134
+ if (activeDragMode != DRAG_NONE) {
135
+ return handleActiveDrawerDrag(event);
136
+ } else if (action == MotionEvent.ACTION_MOVE) {
137
+ if (tryStartDrawerDrag(event)) {
138
+ return handleActiveDrawerDrag(event);
139
+ }
140
+ } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
141
+ resetTouchTracking();
142
+ }
143
+
144
+ return super.dispatchTouchEvent(event);
145
+ }
146
+
147
+ @Override
148
+ public boolean onInterceptTouchEvent(MotionEvent event) {
149
+ int action = event.getActionMasked();
150
+ if (activeDragMode != DRAG_NONE) {
151
+ return true;
152
+ }
153
+
154
+ if (action == MotionEvent.ACTION_DOWN) {
155
+ return isDrawerVisible(GravityCompat.START) && super.onInterceptTouchEvent(event);
156
+ }
157
+
158
+ if (!isDrawerVisible(GravityCompat.START)) {
159
+ if (!openGestureEnabled || !openDragCandidate) {
160
+ return false;
161
+ }
162
+
163
+ if (action == MotionEvent.ACTION_MOVE && isVerticalGesture(event)) {
164
+ openDragCandidate = false;
165
+ } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
166
+ openDragCandidate = false;
167
+ }
168
+ return false;
169
+ }
170
+
171
+ return super.onInterceptTouchEvent(event);
172
+ }
173
+
174
+ private void setupDrawerInternals() {
175
+ setDrawerEdgeSize(openEdgeWidth);
176
+ getDrawerViewOffsetMethod = findDrawerLayoutMethod("getDrawerViewOffset", View.class);
177
+ moveDrawerToOffsetMethod = findDrawerLayoutMethod("moveDrawerToOffset", View.class, float.class);
178
+ }
179
+
180
+ private void updateBackGestureCallback() {
181
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
182
+ return;
183
+ }
184
+
185
+ if (!openGestureEnabled || !isAttachedToWindow()) {
186
+ unregisterBackGestureCallback();
187
+ return;
188
+ }
189
+
190
+ if (backGestureCallbackRegistered) {
191
+ return;
192
+ }
193
+
194
+ Activity activity = findActivity();
195
+ if (activity == null) {
196
+ return;
197
+ }
198
+
199
+ backGestureCallback = createBackGestureCallback();
200
+ activity.getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
201
+ OnBackInvokedDispatcher.PRIORITY_OVERLAY,
202
+ backGestureCallback
203
+ );
204
+ backGestureCallbackRegistered = true;
205
+ }
206
+
207
+ private void unregisterBackGestureCallback() {
208
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || !backGestureCallbackRegistered) {
209
+ return;
210
+ }
211
+
212
+ Activity activity = findActivity();
213
+ if (activity != null && backGestureCallback != null) {
214
+ activity.getOnBackInvokedDispatcher().unregisterOnBackInvokedCallback(backGestureCallback);
215
+ }
216
+ backGestureCallbackRegistered = false;
217
+ backGestureCallback = null;
218
+ backGestureActive = false;
219
+ backGestureProgress = 0;
220
+ }
221
+
222
+ private OnBackAnimationCallback createBackGestureCallback() {
223
+ return new OnBackAnimationCallback() {
224
+ @Override
225
+ public void onBackStarted(BackEvent backEvent) {
226
+ beginBackGesture(backEvent);
227
+ }
228
+
229
+ @Override
230
+ public void onBackProgressed(BackEvent backEvent) {
231
+ progressBackGesture(backEvent);
232
+ }
233
+
234
+ @Override
235
+ public void onBackCancelled() {
236
+ cancelBackGesture();
237
+ }
238
+
239
+ @Override
240
+ public void onBackInvoked() {
241
+ finishBackGesture();
242
+ }
243
+ };
244
+ }
245
+
246
+ private void beginBackGesture(BackEvent backEvent) {
247
+ backGestureActive = openGestureEnabled
248
+ && backEvent.getSwipeEdge() == BackEvent.EDGE_LEFT
249
+ && isDrawerClosed();
250
+ backGestureProgress = 0;
251
+
252
+ if (backGestureActive) {
253
+ activeDrawerChild = findDrawerChild();
254
+ if (activeDrawerChild == null || activeDrawerChild.getWidth() <= 0) {
255
+ backGestureActive = false;
256
+ return;
257
+ }
258
+ performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
259
+ moveDrawerToProgress(activeDrawerChild, 0);
260
+ }
261
+ }
262
+
263
+ private void progressBackGesture(BackEvent backEvent) {
264
+ if (!backGestureActive || activeDrawerChild == null) {
265
+ return;
266
+ }
267
+
268
+ backGestureProgress = backEvent.getProgress();
269
+ moveDrawerToProgress(activeDrawerChild, backGestureProgress);
270
+ }
271
+
272
+ private void cancelBackGesture() {
273
+ if (backGestureActive) {
274
+ closeDrawer(GravityCompat.START);
275
+ }
276
+ backGestureActive = false;
277
+ backGestureProgress = 0;
278
+ activeDrawerChild = null;
279
+ }
280
+
281
+ private void finishBackGesture() {
282
+ if (!backGestureActive) {
283
+ invokeFallbackBack();
284
+ return;
285
+ }
286
+
287
+ openDrawer(GravityCompat.START);
288
+ backGestureActive = false;
289
+ backGestureProgress = 0;
290
+ activeDrawerChild = null;
291
+ }
292
+
293
+ private void invokeFallbackBack() {
294
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
295
+ unregisterBackGestureCallback();
296
+ }
297
+
298
+ Activity activity = findActivity();
299
+ if (activity instanceof AppCompatActivity) {
300
+ ((AppCompatActivity) activity).getOnBackPressedDispatcher().onBackPressed();
301
+ } else if (activity != null) {
302
+ activity.onBackPressed();
303
+ }
304
+
305
+ post(this::updateBackGestureCallback);
306
+ }
307
+
308
+ private Method findDrawerLayoutMethod(String name, Class<?>... parameterTypes) {
309
+ try {
310
+ Method method = DrawerLayout.class.getDeclaredMethod(name, parameterTypes);
311
+ method.setAccessible(true);
312
+ return method;
313
+ } catch (NoSuchMethodException ignored) {
314
+ return null;
315
+ }
316
+ }
317
+
318
+ private void updateSystemGestureExclusionRect() {
319
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
320
+ if (openGestureEnabled) {
321
+ int width = getWidth() == 0 ? systemGestureExclusionWidth : Math.min(systemGestureExclusionWidth, getWidth());
322
+ setSystemGestureExclusionRects(Collections.singletonList(new Rect(0, 0, width, getHeight())));
323
+ } else {
324
+ setSystemGestureExclusionRects(new ArrayList<>());
325
+ }
326
+ }
327
+ }
328
+
329
+ private void setDrawerEdgeSize(int edgeSize) {
330
+ try {
331
+ Field leftDraggerField = DrawerLayout.class.getDeclaredField("mLeftDragger");
332
+ leftDraggerField.setAccessible(true);
333
+ ViewDragHelper leftDragger = (ViewDragHelper) leftDraggerField.get(this);
334
+ Field edgeSizeField = leftDragger.getClass().getDeclaredField("mEdgeSize");
335
+ edgeSizeField.setAccessible(true);
336
+ edgeSizeField.setInt(leftDragger, edgeSize);
337
+ } catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignored) {
338
+ }
339
+ }
340
+
341
+ private void beginTouchTracking(MotionEvent event) {
342
+ downX = event.getX();
343
+ downY = event.getY();
344
+ dragStartProgress = 0;
345
+ activeDragMode = DRAG_NONE;
346
+ activeDrawerChild = findDrawerChild();
347
+ float drawerProgress = getDrawerProgress(activeDrawerChild);
348
+ closeDragCandidate = drawerProgress > 0;
349
+ openDragCandidate = openGestureEnabled && drawerProgress <= DRAWER_CLOSED_EPSILON && downX <= openEdgeWidth;
350
+ nativeGestureStarted = false;
351
+ activeNativeGestureView = findNativeGestureView(this, downX, downY);
352
+ recycleVelocityTracker();
353
+ velocityTracker = VelocityTracker.obtain();
354
+ velocityTracker.addMovement(event);
355
+ }
356
+
357
+ private boolean tryStartDrawerDrag(MotionEvent event) {
358
+ if (isVerticalGesture(event)) {
359
+ openDragCandidate = false;
360
+ closeDragCandidate = false;
361
+ return false;
362
+ }
363
+
364
+ float dx = event.getX() - downX;
365
+ float dy = Math.abs(event.getY() - downY);
366
+ if (openDragCandidate && dx > openGestureTriggerDistance && dx > dy * HORIZONTAL_ACTIVATION_RATIO) {
367
+ return startDrawerDrag(DRAG_OPEN, event);
368
+ }
369
+
370
+ if (closeDragCandidate && dx < -touchSlop && Math.abs(dx) > dy * HORIZONTAL_ACTIVATION_RATIO) {
371
+ return startDrawerDrag(DRAG_CLOSE, event);
372
+ }
373
+
374
+ return false;
375
+ }
376
+
377
+ private boolean isVerticalGesture(MotionEvent event) {
378
+ float dx = Math.abs(event.getX() - downX);
379
+ float dy = Math.abs(event.getY() - downY);
380
+ return dy > touchSlop && dy > dx;
381
+ }
382
+
383
+ private boolean startDrawerDrag(int dragMode, MotionEvent event) {
384
+ activeDrawerChild = findDrawerChild();
385
+ if (activeDrawerChild == null || activeDrawerChild.getWidth() <= 0) {
386
+ resetTouchTracking();
387
+ return false;
388
+ }
389
+
390
+ activeDragMode = dragMode;
391
+ dragStartProgress = getDrawerProgress(activeDrawerChild);
392
+ notifyNativeGestureStarted(event);
393
+ getParent().requestDisallowInterceptTouchEvent(true);
394
+ performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
395
+ return true;
396
+ }
397
+
398
+ private boolean handleActiveDrawerDrag(MotionEvent event) {
399
+ if (activeDrawerChild == null) {
400
+ resetTouchTracking();
401
+ return false;
402
+ }
403
+
404
+ int action = event.getActionMasked();
405
+ if (action == MotionEvent.ACTION_MOVE) {
406
+ applyDrawerDragProgress(event);
407
+ return true;
408
+ }
409
+
410
+ if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
411
+ applyDrawerDragProgress(event);
412
+ settleDrawerDrag(action == MotionEvent.ACTION_CANCEL, getXVelocity());
413
+ notifyNativeGestureEnded(event);
414
+ resetTouchTracking();
415
+ return true;
416
+ }
417
+
418
+ return true;
419
+ }
420
+
421
+ private void applyDrawerDragProgress(MotionEvent event) {
422
+ int drawerWidth = activeDrawerChild.getWidth();
423
+ if (drawerWidth <= 0) {
424
+ return;
425
+ }
426
+
427
+ float progress = dragStartProgress + (event.getX() - downX) / drawerWidth;
428
+ moveDrawerToProgress(activeDrawerChild, progress);
429
+ }
430
+
431
+ private void settleDrawerDrag(boolean cancelled, float velocityX) {
432
+ if (activeDrawerChild == null) {
433
+ return;
434
+ }
435
+
436
+ boolean shouldOpen;
437
+ if (cancelled) {
438
+ shouldOpen = activeDragMode == DRAG_CLOSE;
439
+ } else {
440
+ float progress = getDrawerProgress(activeDrawerChild);
441
+ if (activeDragMode == DRAG_OPEN) {
442
+ shouldOpen = progress >= OPEN_SETTLE_THRESHOLD || velocityX >= settleVelocity;
443
+ } else {
444
+ shouldOpen = progress >= CLOSE_SETTLE_THRESHOLD && velocityX >= -settleVelocity;
445
+ }
446
+ }
447
+
448
+ if (shouldOpen) {
449
+ openDrawer(GravityCompat.START);
450
+ } else {
451
+ closeDrawer(GravityCompat.START);
452
+ }
453
+ }
454
+
455
+ private void moveDrawerToProgress(View drawerChild, float progress) {
456
+ progress = Math.max(0, Math.min(1, progress));
457
+ if (progress > 0) {
458
+ drawerChild.setVisibility(VISIBLE);
459
+ }
460
+
461
+ if (!invokeMoveDrawerToOffset(drawerChild, progress)) {
462
+ fallbackMoveDrawerToOffset(drawerChild, progress);
463
+ }
464
+
465
+ if (progress == 0) {
466
+ drawerChild.setVisibility(INVISIBLE);
467
+ }
468
+ invalidate();
469
+ }
470
+
471
+ private boolean invokeMoveDrawerToOffset(View drawerChild, float progress) {
472
+ if (moveDrawerToOffsetMethod == null) {
473
+ return false;
474
+ }
475
+
476
+ try {
477
+ moveDrawerToOffsetMethod.invoke(this, drawerChild, progress);
478
+ return true;
479
+ } catch (IllegalAccessException | InvocationTargetException ignored) {
480
+ return false;
481
+ }
482
+ }
483
+
484
+ private void fallbackMoveDrawerToOffset(View drawerChild, float progress) {
485
+ float oldProgress = getDrawerProgress(drawerChild);
486
+ int drawerWidth = drawerChild.getWidth();
487
+ int oldPosition = (int) (drawerWidth * oldProgress);
488
+ int newPosition = (int) (drawerWidth * progress);
489
+ int dx = newPosition - oldPosition;
490
+ drawerChild.offsetLeftAndRight(isStartDrawerOnLeft(drawerChild) ? dx : -dx);
491
+ }
492
+
493
+ private float getDrawerProgress(View drawerChild) {
494
+ if (drawerChild == null) {
495
+ return 0;
496
+ }
497
+
498
+ if (getDrawerViewOffsetMethod != null) {
499
+ try {
500
+ Object value = getDrawerViewOffsetMethod.invoke(this, drawerChild);
501
+ if (value instanceof Float) {
502
+ return clampProgress((Float) value);
503
+ }
504
+ } catch (IllegalAccessException | InvocationTargetException ignored) {
505
+ }
506
+ }
507
+
508
+ int drawerWidth = drawerChild.getWidth();
509
+ if (drawerWidth <= 0) {
510
+ return isDrawerOpen(drawerChild) ? 1 : 0;
511
+ }
512
+
513
+ if (isStartDrawerOnLeft(drawerChild)) {
514
+ return clampProgress((drawerChild.getLeft() + drawerWidth) / (float) drawerWidth);
515
+ }
516
+ return clampProgress((getWidth() - drawerChild.getLeft()) / (float) drawerWidth);
517
+ }
518
+
519
+ private float clampProgress(float progress) {
520
+ return Math.max(0, Math.min(1, progress));
521
+ }
522
+
523
+ private boolean isDrawerClosed() {
524
+ return getDrawerProgress(findDrawerChild()) <= DRAWER_CLOSED_EPSILON;
525
+ }
526
+
527
+ private void notifyNativeGestureStarted(MotionEvent event) {
528
+ if (nativeGestureStarted) {
529
+ return;
530
+ }
531
+ NativeGestureUtil.notifyNativeGestureStarted(getNativeGestureView(), event);
532
+ nativeGestureStarted = true;
533
+ }
534
+
535
+ private void notifyNativeGestureEnded(MotionEvent event) {
536
+ if (!nativeGestureStarted) {
537
+ return;
538
+ }
539
+ NativeGestureUtil.notifyNativeGestureEnded(getNativeGestureView(), event);
540
+ nativeGestureStarted = false;
541
+ }
542
+
543
+ private View getNativeGestureView() {
544
+ return activeNativeGestureView == null ? this : activeNativeGestureView;
545
+ }
546
+
547
+ private void resetTouchTracking() {
548
+ recycleVelocityTracker();
549
+ closeDragCandidate = false;
550
+ openDragCandidate = false;
551
+ activeDragMode = DRAG_NONE;
552
+ activeDrawerChild = null;
553
+ activeNativeGestureView = null;
554
+ dragStartProgress = 0;
555
+ nativeGestureStarted = false;
556
+ }
557
+
558
+ private float getXVelocity() {
559
+ if (velocityTracker == null) {
560
+ return 0;
561
+ }
562
+
563
+ velocityTracker.computeCurrentVelocity(1000);
564
+ return velocityTracker.getXVelocity();
565
+ }
566
+
567
+ private void recycleVelocityTracker() {
568
+ if (velocityTracker == null) {
569
+ return;
570
+ }
571
+
572
+ velocityTracker.recycle();
573
+ velocityTracker = null;
574
+ }
575
+
576
+ private View findDrawerChild() {
577
+ for (int i = getChildCount() - 1; i >= 0; i--) {
578
+ View child = getChildAt(i);
579
+ if (isDrawerChild(child)) {
580
+ return child;
581
+ }
582
+ }
583
+ return null;
584
+ }
585
+
586
+ private View findNativeGestureView(View view, float x, float y) {
587
+ if (view instanceof ViewGroup) {
588
+ ViewGroup group = (ViewGroup) view;
589
+ for (int i = group.getChildCount() - 1; i >= 0; i--) {
590
+ View child = group.getChildAt(i);
591
+ if (child.getVisibility() != VISIBLE || !isPointInsideChild(child, x, y)) {
592
+ continue;
593
+ }
594
+
595
+ float childX = x - child.getLeft() - child.getTranslationX();
596
+ float childY = y - child.getTop() - child.getTranslationY();
597
+ View nativeGestureView = findNativeGestureView(child, childX, childY);
598
+ if (nativeGestureView != null) {
599
+ return nativeGestureView;
600
+ }
601
+ }
602
+ }
603
+
604
+ return view instanceof RootView ? view : null;
605
+ }
606
+
607
+ private boolean isPointInsideChild(View child, float x, float y) {
608
+ float left = child.getLeft() + child.getTranslationX();
609
+ float top = child.getTop() + child.getTranslationY();
610
+ return x >= left && x < left + child.getWidth()
611
+ && y >= top && y < top + child.getHeight();
612
+ }
613
+
614
+ private Activity findActivity() {
615
+ Context context = getContext();
616
+ while (context instanceof ContextWrapper) {
617
+ if (context instanceof Activity) {
618
+ return (Activity) context;
619
+ }
620
+ context = ((ContextWrapper) context).getBaseContext();
621
+ }
622
+ return null;
623
+ }
624
+
625
+ private boolean isDrawerChild(View child) {
626
+ LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
627
+ int gravity = GravityCompat.getAbsoluteGravity(layoutParams.gravity, getLayoutDirection());
628
+ return (gravity & Gravity.LEFT) == Gravity.LEFT || (gravity & Gravity.RIGHT) == Gravity.RIGHT;
629
+ }
630
+
631
+ private boolean isStartDrawerOnLeft(View child) {
632
+ LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
633
+ int gravity = GravityCompat.getAbsoluteGravity(layoutParams.gravity, getLayoutDirection());
634
+ return (gravity & Gravity.LEFT) == Gravity.LEFT;
635
+ }
636
+ }
@@ -27,6 +27,10 @@ public class StackFragment extends AwesomeFragment {
27
27
  setNeedsStatusBarAppearanceUpdate();
28
28
  setNeedsNavigationBarAppearanceUpdate();
29
29
  setNeedsLayoutInDisplayCutoutModeUpdate();
30
+ DrawerFragment drawerFragment = getDrawerFragment();
31
+ if (drawerFragment != null) {
32
+ drawerFragment.updateMenuGestureState();
33
+ }
30
34
  }
31
35
  });
32
36
  }