Prepare for flexible system bars
Bug: 140423092 Test: manual Change-Id: I1a3da8438970304d35c4fa1364b47070952a144f
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
android:gravity="top"
|
||||
android:paddingTop="30dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/system_bar_background"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<com.android.systemui.car.navigationbar.CarNavigationButton
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
android:gravity="top"
|
||||
android:paddingTop="30dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/system_bar_background"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<com.android.systemui.car.navigationbar.CarNavigationButton
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
android:gravity="top"
|
||||
android:paddingTop="30dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/system_bar_background"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<com.android.systemui.car.navigationbar.CarNavigationButton
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
android:gravity="top"
|
||||
android:paddingTop="30dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/system_bar_background"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<com.android.systemui.car.navigationbar.CarNavigationButton
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.systemui.car.navigationbar;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.InsetsState.containsType;
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
|
||||
@@ -28,7 +27,6 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@@ -349,33 +347,38 @@ 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_SPLIT_TOUCH
|
||||
| WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
|
||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
|
||||
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
lp.token = new Binder();
|
||||
lp.gravity = Gravity.TOP;
|
||||
lp.setFitInsetsTypes(0 /* types */);
|
||||
lp.setTitle("TopCarNavigationBar");
|
||||
lp.packageName = mContext.getPackageName();
|
||||
lp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
lp.providesInsetsTypes = new int[]{ITYPE_STATUS_BAR};
|
||||
lp.setFitInsetsTypes(0);
|
||||
lp.windowAnimations = 0;
|
||||
lp.gravity = Gravity.TOP;
|
||||
mWindowManager.addView(mTopNavigationBarWindow, lp);
|
||||
}
|
||||
|
||||
if (mBottomNavigationBarWindow != null && !mBottomNavBarVisible) {
|
||||
mBottomNavBarVisible = true;
|
||||
int height = mResources.getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.navigation_bar_height);
|
||||
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.TYPE_NAVIGATION_BAR,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
height,
|
||||
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};
|
||||
lp.windowAnimations = 0;
|
||||
lp.gravity = Gravity.BOTTOM;
|
||||
mWindowManager.addView(mBottomNavigationBarWindow, lp);
|
||||
}
|
||||
|
||||
@@ -392,11 +395,10 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
PixelFormat.TRANSLUCENT);
|
||||
leftlp.setTitle("LeftCarNavigationBar");
|
||||
leftlp.windowAnimations = 0;
|
||||
leftlp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
|
||||
leftlp.gravity = Gravity.LEFT;
|
||||
leftlp.setFitInsetsTypes(0 /* types */);
|
||||
mWindowManager.addView(mLeftNavigationBarWindow, leftlp);
|
||||
}
|
||||
|
||||
if (mRightNavigationBarWindow != null) {
|
||||
int width = mResources.getDimensionPixelSize(
|
||||
R.dimen.car_right_navigation_bar_width);
|
||||
@@ -410,9 +412,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
PixelFormat.TRANSLUCENT);
|
||||
rightlp.setTitle("RightCarNavigationBar");
|
||||
rightlp.windowAnimations = 0;
|
||||
rightlp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
|
||||
rightlp.gravity = Gravity.RIGHT;
|
||||
rightlp.setFitInsetsTypes(0 /* types */);
|
||||
mWindowManager.addView(mRightNavigationBarWindow, rightlp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.systemui.R;
|
||||
@@ -160,8 +159,12 @@ public class CarNavigationBarController {
|
||||
}
|
||||
|
||||
/** Gets the top navigation bar with the appropriate listeners set. */
|
||||
@NonNull
|
||||
@Nullable
|
||||
public CarNavigationBarView getTopBar(boolean isSetUp) {
|
||||
if (!mShowTop) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mTopView = mNavigationBarViewFactory.getTopBar(isSetUp);
|
||||
setupBar(mTopView, mTopBarTouchListener, mNotificationsShadeController);
|
||||
return mTopView;
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
|
||||
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;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.systemui.Dependency;
|
||||
@@ -44,7 +48,6 @@ public class CarNavigationBarView extends LinearLayout {
|
||||
// used to wire in open/close gestures for notifications
|
||||
private OnTouchListener mStatusBarWindowTouchListener;
|
||||
|
||||
|
||||
public CarNavigationBarView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mConsumeTouchWhenPanelOpen = getResources().getBoolean(
|
||||
@@ -75,6 +78,30 @@ public class CarNavigationBarView extends LinearLayout {
|
||||
setClickable(true);
|
||||
}
|
||||
|
||||
@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