Reintroduce flexible inset mapping
This was cut from R due to timing. Reintroducing for R QPR1. Allows for the usage of flexible inset mapping Bug: 156304383 Test: atest WindowInsetsControllerTest Change-Id: I51992277409da40f28bdf36b62203d4a07af933b
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
|
||||
package com.android.systemui.car.navigationbar;
|
||||
|
||||
import static android.view.InsetsState.ITYPE_BOTTOM_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_CLIMATE_BAR;
|
||||
import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.InsetsState.ITYPE_TOP_GESTURES;
|
||||
import static android.view.InsetsState.containsType;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||
|
||||
@@ -368,13 +370,15 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
height,
|
||||
WindowManager.LayoutParams.TYPE_STATUS_BAR,
|
||||
WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
|
||||
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
lp.setTitle("TopCarNavigationBar");
|
||||
lp.providesInsetsTypes = new int[]{ITYPE_STATUS_BAR, ITYPE_TOP_GESTURES};
|
||||
lp.setFitInsetsTypes(0);
|
||||
lp.windowAnimations = 0;
|
||||
lp.gravity = Gravity.TOP;
|
||||
mWindowManager.addView(mTopNavigationBarWindow, lp);
|
||||
@@ -388,13 +392,14 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
height,
|
||||
WindowManager.LayoutParams.TYPE_NAVIGATION_BAR,
|
||||
WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
|
||||
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
lp.setTitle("BottomCarNavigationBar");
|
||||
lp.providesInsetsTypes = new int[]{ITYPE_NAVIGATION_BAR, ITYPE_BOTTOM_GESTURES};
|
||||
lp.windowAnimations = 0;
|
||||
lp.gravity = Gravity.BOTTOM;
|
||||
mWindowManager.addView(mBottomNavigationBarWindow, lp);
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package com.android.systemui.car.navigationbar;
|
||||
|
||||
import static android.view.WindowInsets.Type.systemBars;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Insets;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -79,9 +82,28 @@ public class CarNavigationBarView extends LinearLayout {
|
||||
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) {
|
||||
applyMargins(windowInsets.getInsets(systemBars()));
|
||||
return windowInsets;
|
||||
}
|
||||
|
||||
private void applyMargins(Insets insets) {
|
||||
final int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child.getLayoutParams() instanceof LayoutParams) {
|
||||
LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
if (lp.rightMargin != insets.right || lp.leftMargin != insets.left
|
||||
|| lp.topMargin != insets.top || lp.bottomMargin != insets.bottom) {
|
||||
lp.rightMargin = insets.right;
|
||||
lp.leftMargin = insets.left;
|
||||
lp.topMargin = insets.top;
|
||||
lp.bottomMargin = insets.bottom;
|
||||
child.requestLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Used to forward touch events even if the touch was initiated from a child component
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
|
||||
Reference in New Issue
Block a user