Add nav bar controller
The controller is respnsible for knowing about the configuration values and setting the notifications related listeners as necessary. Bug: 143143539 Test: manual Change-Id: Iaed21006284493f4e3f8e6f4c827b0d41780f77b
This commit is contained in:
@@ -31,14 +31,15 @@
|
||||
android:paddingStart="@*android:dimen/car_padding_5"
|
||||
android:paddingEnd="@*android:dimen/car_padding_5">
|
||||
|
||||
<com.android.systemui.navigationbar.car.CarNavigationButton
|
||||
<com.android.systemui.navigationbar.car.CarFacetButton
|
||||
android:id="@+id/home"
|
||||
android:layout_width="@*android:dimen/car_touch_target_size"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:src="@drawable/car_ic_overview"
|
||||
systemui:icon="@drawable/car_ic_overview"
|
||||
systemui:intent="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.HOME;launchFlags=0x14000000;end"
|
||||
/>
|
||||
systemui:selectedIcon="@drawable/car_ic_overview_selected"
|
||||
systemui:useMoreIcon="false"/>
|
||||
</LinearLayout>
|
||||
</com.android.systemui.navigationbar.car.CarNavigationBarView>
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@@ -37,8 +36,6 @@ import com.android.systemui.dagger.qualifiers.MainHandler;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.NavigationBarController;
|
||||
import com.android.systemui.statusbar.car.hvac.HvacController;
|
||||
import com.android.systemui.statusbar.car.hvac.TemperatureView;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
|
||||
@@ -52,15 +49,13 @@ import dagger.Lazy;
|
||||
/** Navigation bars customized for the automotive use case. */
|
||||
public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks {
|
||||
|
||||
private final NavigationBarViewFactory mNavigationBarViewFactory;
|
||||
private final CarNavigationBarController mCarNavigationBarController;
|
||||
private final WindowManager mWindowManager;
|
||||
private final DeviceProvisionedController mDeviceProvisionedController;
|
||||
private final Lazy<FacetButtonTaskStackListener> mFacetButtonTaskStackListener;
|
||||
private final Handler mMainHandler;
|
||||
private final Lazy<KeyguardStateController> mKeyguardStateController;
|
||||
private final Lazy<CarFacetButtonController> mFacetButtonController;
|
||||
private final Lazy<NavigationBarController> mNavigationBarController;
|
||||
private final Lazy<HvacController> mHvacController;
|
||||
|
||||
private IStatusBarService mBarService;
|
||||
private CommandQueue mCommandQueue;
|
||||
@@ -82,33 +77,23 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
// it's open.
|
||||
private boolean mDeviceIsSetUpForUser = true;
|
||||
|
||||
// Configuration values for if nav bars should be shown.
|
||||
private boolean mShowBottom;
|
||||
private boolean mShowLeft;
|
||||
private boolean mShowRight;
|
||||
|
||||
|
||||
@Inject
|
||||
public CarNavigationBar(Context context,
|
||||
NavigationBarViewFactory navigationBarViewFactory,
|
||||
CarNavigationBarController carNavigationBarController,
|
||||
WindowManager windowManager,
|
||||
DeviceProvisionedController deviceProvisionedController,
|
||||
Lazy<FacetButtonTaskStackListener> facetButtonTaskStackListener,
|
||||
@MainHandler Handler mainHandler,
|
||||
Lazy<KeyguardStateController> keyguardStateController,
|
||||
Lazy<CarFacetButtonController> facetButtonController,
|
||||
Lazy<NavigationBarController> navigationBarController,
|
||||
Lazy<HvacController> hvacController) {
|
||||
Lazy<NavigationBarController> navigationBarController) {
|
||||
super(context);
|
||||
mNavigationBarViewFactory = navigationBarViewFactory;
|
||||
mCarNavigationBarController = carNavigationBarController;
|
||||
mWindowManager = windowManager;
|
||||
mDeviceProvisionedController = deviceProvisionedController;
|
||||
mFacetButtonTaskStackListener = facetButtonTaskStackListener;
|
||||
mMainHandler = mainHandler;
|
||||
mKeyguardStateController = keyguardStateController;
|
||||
mFacetButtonController = facetButtonController;
|
||||
mNavigationBarController = navigationBarController;
|
||||
mHvacController = hvacController;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,11 +103,6 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard);
|
||||
mBottomNavBarVisible = false;
|
||||
|
||||
// Read configuration.
|
||||
mShowBottom = mContext.getResources().getBoolean(R.bool.config_enableBottomNavigationBar);
|
||||
mShowLeft = mContext.getResources().getBoolean(R.bool.config_enableLeftNavigationBar);
|
||||
mShowRight = mContext.getResources().getBoolean(R.bool.config_enableRightNavigationBar);
|
||||
|
||||
// Get bar service.
|
||||
mBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
||||
@@ -157,7 +137,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
mActivityManagerWrapper = ActivityManagerWrapper.getInstance();
|
||||
mActivityManagerWrapper.registerTaskStackListener(mFacetButtonTaskStackListener.get());
|
||||
|
||||
mHvacController.get().connectToCarService();
|
||||
mCarNavigationBarController.connectToHvac();
|
||||
}
|
||||
|
||||
private void restartNavBarsIfNecessary() {
|
||||
@@ -175,8 +155,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
private void restartNavBars() {
|
||||
// remove and reattach all hvac components such that we don't keep a reference to unused
|
||||
// ui elements
|
||||
mHvacController.get().removeAllComponents();
|
||||
mFacetButtonController.get().removeAll();
|
||||
mCarNavigationBarController.removeAllFromHvac();
|
||||
|
||||
if (mNavigationBarWindow != null) {
|
||||
mNavigationBarWindow.removeAllViews();
|
||||
@@ -199,10 +178,6 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
if (mKeyguardStateController.get().isShowing()) {
|
||||
updateNavBarForKeyguardContent();
|
||||
}
|
||||
|
||||
// CarFacetButtonController was reset therefore we need to re-add the status bar elements
|
||||
// to the controller.
|
||||
// TODO(hseog): Add facet buttons in status bar to controller.
|
||||
}
|
||||
|
||||
private void createNavigationBar(RegisterStatusBarResult result) {
|
||||
@@ -224,54 +199,30 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
}
|
||||
|
||||
private void buildNavBarWindows() {
|
||||
if (mShowBottom) {
|
||||
mNavigationBarWindow = mNavigationBarViewFactory.getBottomWindow();
|
||||
}
|
||||
|
||||
if (mShowLeft) {
|
||||
mLeftNavigationBarWindow = mNavigationBarViewFactory.getLeftWindow();
|
||||
}
|
||||
|
||||
if (mShowRight) {
|
||||
mRightNavigationBarWindow = mNavigationBarViewFactory.getRightWindow();
|
||||
}
|
||||
mNavigationBarWindow = mCarNavigationBarController.getBottomWindow();
|
||||
mLeftNavigationBarWindow = mCarNavigationBarController.getLeftWindow();
|
||||
mRightNavigationBarWindow = mCarNavigationBarController.getRightWindow();
|
||||
}
|
||||
|
||||
private void buildNavBarContent() {
|
||||
if (mShowBottom) {
|
||||
mNavigationBarView = mNavigationBarViewFactory.getBottomBar(mDeviceIsSetUpForUser);
|
||||
mNavigationBarView = mCarNavigationBarController.getBottomBar(mDeviceIsSetUpForUser);
|
||||
if (mNavigationBarView != null) {
|
||||
mNavigationBarWindow.addView(mNavigationBarView);
|
||||
addTemperatureViewToController(mNavigationBarView);
|
||||
}
|
||||
|
||||
if (mShowLeft) {
|
||||
mLeftNavigationBarView = mNavigationBarViewFactory.getLeftBar(mDeviceIsSetUpForUser);
|
||||
mLeftNavigationBarView = mCarNavigationBarController.getLeftBar(mDeviceIsSetUpForUser);
|
||||
if (mLeftNavigationBarView != null) {
|
||||
mLeftNavigationBarWindow.addView(mLeftNavigationBarView);
|
||||
addTemperatureViewToController(mLeftNavigationBarView);
|
||||
}
|
||||
|
||||
if (mShowRight) {
|
||||
mRightNavigationBarView = mNavigationBarViewFactory.getRightBar(mDeviceIsSetUpForUser);
|
||||
mRightNavigationBarView = mCarNavigationBarController.getRightBar(mDeviceIsSetUpForUser);
|
||||
if (mRightNavigationBarView != null) {
|
||||
mRightNavigationBarWindow.addView(mRightNavigationBarView);
|
||||
// Add ability to toggle notification center.
|
||||
addTemperatureViewToController(mRightNavigationBarView);
|
||||
// Add ability to close notification center on touch.
|
||||
}
|
||||
}
|
||||
|
||||
private void addTemperatureViewToController(View v) {
|
||||
if (v instanceof TemperatureView) {
|
||||
mHvacController.get().addHvacTextView((TemperatureView) v);
|
||||
} else if (v instanceof ViewGroup) {
|
||||
ViewGroup viewGroup = (ViewGroup) v;
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
addTemperatureViewToController(viewGroup.getChildAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void attachNavBarWindows() {
|
||||
if (mShowBottom && !mBottomNavBarVisible) {
|
||||
if (mNavigationBarWindow != null && !mBottomNavBarVisible) {
|
||||
mBottomNavBarVisible = true;
|
||||
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||
@@ -287,7 +238,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
mWindowManager.addView(mNavigationBarWindow, lp);
|
||||
}
|
||||
|
||||
if (mShowLeft) {
|
||||
if (mLeftNavigationBarWindow != null) {
|
||||
int width = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.car_left_navigation_bar_width);
|
||||
WindowManager.LayoutParams leftlp = new WindowManager.LayoutParams(
|
||||
@@ -304,7 +255,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
leftlp.gravity = Gravity.LEFT;
|
||||
mWindowManager.addView(mLeftNavigationBarWindow, leftlp);
|
||||
}
|
||||
if (mShowRight) {
|
||||
if (mRightNavigationBarWindow != null) {
|
||||
int width = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.car_right_navigation_bar_width);
|
||||
WindowManager.LayoutParams rightlp = new WindowManager.LayoutParams(
|
||||
@@ -340,23 +291,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
}
|
||||
|
||||
boolean isKeyboardVisible = (vis & InputMethodService.IME_VISIBLE) != 0;
|
||||
showBottomNavBarWindow(isKeyboardVisible);
|
||||
}
|
||||
|
||||
private void showBottomNavBarWindow(boolean isKeyboardVisible) {
|
||||
if (!mShowBottom) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If keyboard is visible and bottom nav bar not visible, this is the correct state, so do
|
||||
// nothing. Same with if keyboard is not visible and bottom nav bar is visible.
|
||||
if (isKeyboardVisible ^ mBottomNavBarVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
mNavigationBarViewFactory.getBottomWindow().setVisibility(
|
||||
isKeyboardVisible ? View.GONE : View.VISIBLE);
|
||||
mBottomNavBarVisible = !isKeyboardVisible;
|
||||
mCarNavigationBarController.setBottomWindowVisibility(!isKeyboardVisible);
|
||||
}
|
||||
|
||||
private void updateNavBarForKeyguardContent() {
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.navigationbar.car;
|
||||
|
||||
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;
|
||||
import com.android.systemui.statusbar.car.hvac.HvacController;
|
||||
import com.android.systemui.statusbar.car.hvac.TemperatureView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
/** A single class which controls the navigation bar views. */
|
||||
@Singleton
|
||||
public class CarNavigationBarController {
|
||||
|
||||
private final Context mContext;
|
||||
private final NavigationBarViewFactory mNavigationBarViewFactory;
|
||||
private final Lazy<HvacController> mHvacControllerLazy;
|
||||
|
||||
private boolean mShowBottom;
|
||||
private boolean mShowLeft;
|
||||
private boolean mShowRight;
|
||||
|
||||
private View.OnTouchListener mTopBarTouchListener;
|
||||
private View.OnTouchListener mBottomBarTouchListener;
|
||||
private View.OnTouchListener mLeftBarTouchListener;
|
||||
private View.OnTouchListener mRightBarTouchListener;
|
||||
private NotificationsShadeController mNotificationsShadeController;
|
||||
|
||||
private CarNavigationBarView mTopView;
|
||||
private CarNavigationBarView mBottomView;
|
||||
private CarNavigationBarView mLeftView;
|
||||
private CarNavigationBarView mRightView;
|
||||
|
||||
@Inject
|
||||
public CarNavigationBarController(Context context,
|
||||
NavigationBarViewFactory navigationBarViewFactory,
|
||||
Lazy<HvacController> hvacControllerLazy) {
|
||||
mContext = context;
|
||||
mNavigationBarViewFactory = navigationBarViewFactory;
|
||||
mHvacControllerLazy = hvacControllerLazy;
|
||||
|
||||
// Read configuration.
|
||||
mShowBottom = mContext.getResources().getBoolean(R.bool.config_enableBottomNavigationBar);
|
||||
mShowLeft = mContext.getResources().getBoolean(R.bool.config_enableLeftNavigationBar);
|
||||
mShowRight = mContext.getResources().getBoolean(R.bool.config_enableRightNavigationBar);
|
||||
}
|
||||
|
||||
/** Connect to hvac service. */
|
||||
public void connectToHvac() {
|
||||
mHvacControllerLazy.get().connectToCarService();
|
||||
}
|
||||
|
||||
/** Clean up hvac. */
|
||||
public void removeAllFromHvac() {
|
||||
mHvacControllerLazy.get().removeAllComponents();
|
||||
}
|
||||
|
||||
/** Gets the bottom window if configured to do so. */
|
||||
@Nullable
|
||||
public ViewGroup getBottomWindow() {
|
||||
return mShowBottom ? mNavigationBarViewFactory.getBottomWindow() : null;
|
||||
}
|
||||
|
||||
/** Gets the left window if configured to do so. */
|
||||
@Nullable
|
||||
public ViewGroup getLeftWindow() {
|
||||
return mShowLeft ? mNavigationBarViewFactory.getLeftWindow() : null;
|
||||
}
|
||||
|
||||
/** Gets the right window if configured to do so. */
|
||||
@Nullable
|
||||
public ViewGroup getRightWindow() {
|
||||
return mShowRight ? mNavigationBarViewFactory.getRightWindow() : null;
|
||||
}
|
||||
|
||||
/** Toggles the bottom nav bar visibility. */
|
||||
public boolean setBottomWindowVisibility(boolean isVisible) {
|
||||
return setWindowVisibility(getBottomWindow(), isVisible);
|
||||
}
|
||||
|
||||
/** Toggles the left nav bar visibility. */
|
||||
public boolean setLeftWindowVisibility(boolean isVisible) {
|
||||
return setWindowVisibility(getLeftWindow(), isVisible);
|
||||
}
|
||||
|
||||
/** Toggles the right nav bar visibility. */
|
||||
public boolean setRightWindowVisibility(boolean isVisible) {
|
||||
return setWindowVisibility(getRightWindow(), isVisible);
|
||||
}
|
||||
|
||||
private boolean setWindowVisibility(ViewGroup window, boolean isVisible) {
|
||||
if (window == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int newVisibility = isVisible ? View.VISIBLE : View.GONE;
|
||||
if (window.getVisibility() == newVisibility) {
|
||||
return false;
|
||||
}
|
||||
|
||||
window.setVisibility(newVisibility);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Gets the top navigation bar with the appropriate listeners set. */
|
||||
@NonNull
|
||||
public CarNavigationBarView getTopBar(boolean isSetUp) {
|
||||
mTopView = mNavigationBarViewFactory.getTopBar(isSetUp);
|
||||
mTopView.setStatusBarWindowTouchListener(mTopBarTouchListener);
|
||||
mTopView.setNotificationsPanelController(mNotificationsShadeController);
|
||||
addTemperatureViewToController(mTopView);
|
||||
return mTopView;
|
||||
}
|
||||
|
||||
/** Gets the bottom navigation bar with the appropriate listeners set. */
|
||||
@Nullable
|
||||
public CarNavigationBarView getBottomBar(boolean isSetUp) {
|
||||
if (!mShowBottom) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mBottomView = mNavigationBarViewFactory.getBottomBar(isSetUp);
|
||||
mBottomView.setStatusBarWindowTouchListener(mBottomBarTouchListener);
|
||||
mBottomView.setNotificationsPanelController(mNotificationsShadeController);
|
||||
addTemperatureViewToController(mBottomView);
|
||||
return mBottomView;
|
||||
}
|
||||
|
||||
/** Gets the left navigation bar with the appropriate listeners set. */
|
||||
@Nullable
|
||||
public CarNavigationBarView getLeftBar(boolean isSetUp) {
|
||||
if (!mShowLeft) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mLeftView = mNavigationBarViewFactory.getLeftBar(isSetUp);
|
||||
mLeftView.setStatusBarWindowTouchListener(mLeftBarTouchListener);
|
||||
mLeftView.setNotificationsPanelController(mNotificationsShadeController);
|
||||
addTemperatureViewToController(mLeftView);
|
||||
return mLeftView;
|
||||
}
|
||||
|
||||
/** Gets the right navigation bar with the appropriate listeners set. */
|
||||
@Nullable
|
||||
public CarNavigationBarView getRightBar(boolean isSetUp) {
|
||||
if (!mShowRight) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mRightView = mNavigationBarViewFactory.getRightBar(isSetUp);
|
||||
mRightView.setStatusBarWindowTouchListener(mRightBarTouchListener);
|
||||
mRightView.setNotificationsPanelController(mNotificationsShadeController);
|
||||
addTemperatureViewToController(mRightView);
|
||||
return mRightView;
|
||||
}
|
||||
|
||||
/** Sets a touch listener for the top navigation bar. */
|
||||
public void registerTopBarTouchListener(View.OnTouchListener listener) {
|
||||
mTopBarTouchListener = listener;
|
||||
if (mTopView != null) {
|
||||
mTopView.setStatusBarWindowTouchListener(mTopBarTouchListener);
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets a touch listener for the bottom navigation bar. */
|
||||
public void registerBottomBarTouchListener(View.OnTouchListener listener) {
|
||||
mBottomBarTouchListener = listener;
|
||||
if (mBottomView != null) {
|
||||
mBottomView.setStatusBarWindowTouchListener(mBottomBarTouchListener);
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets a touch listener for the left navigation bar. */
|
||||
public void registerLeftBarTouchListener(View.OnTouchListener listener) {
|
||||
mLeftBarTouchListener = listener;
|
||||
if (mLeftView != null) {
|
||||
mLeftView.setStatusBarWindowTouchListener(mLeftBarTouchListener);
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets a touch listener for the right navigation bar. */
|
||||
public void registerRightBarTouchListener(View.OnTouchListener listener) {
|
||||
mRightBarTouchListener = listener;
|
||||
if (mRightView != null) {
|
||||
mRightView.setStatusBarWindowTouchListener(mRightBarTouchListener);
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets a notification controller which toggles the notification panel. */
|
||||
public void registerNotificationController(
|
||||
NotificationsShadeController notificationsShadeController) {
|
||||
mNotificationsShadeController = notificationsShadeController;
|
||||
if (mTopView != null) {
|
||||
mTopView.setNotificationsPanelController(mNotificationsShadeController);
|
||||
}
|
||||
if (mBottomView != null) {
|
||||
mBottomView.setNotificationsPanelController(mNotificationsShadeController);
|
||||
}
|
||||
if (mLeftView != null) {
|
||||
mLeftView.setNotificationsPanelController(mNotificationsShadeController);
|
||||
}
|
||||
if (mRightView != null) {
|
||||
mRightView.setNotificationsPanelController(mNotificationsShadeController);
|
||||
}
|
||||
}
|
||||
|
||||
/** Interface for controlling the notifications shade. */
|
||||
public interface NotificationsShadeController {
|
||||
/** Toggles the visibility of the notifications shade. */
|
||||
void togglePanel();
|
||||
}
|
||||
|
||||
private void addTemperatureViewToController(View v) {
|
||||
if (v instanceof TemperatureView) {
|
||||
mHvacControllerLazy.get().addHvacTextView((TemperatureView) v);
|
||||
} else if (v instanceof ViewGroup) {
|
||||
ViewGroup viewGroup = (ViewGroup) v;
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
addTemperatureViewToController(viewGroup.getChildAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import android.widget.LinearLayout;
|
||||
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.car.CarStatusBar;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
|
||||
/**
|
||||
@@ -36,7 +35,7 @@ import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
public class CarNavigationBarView extends LinearLayout {
|
||||
private View mNavButtons;
|
||||
private CarNavigationButton mNotificationsButton;
|
||||
private CarStatusBar mCarStatusBar;
|
||||
private CarNavigationBarController.NotificationsShadeController mNotificationsShadeController;
|
||||
private Context mContext;
|
||||
private View mLockScreenButtons;
|
||||
// used to wire in open/close gestures for notifications
|
||||
@@ -82,8 +81,9 @@ public class CarNavigationBarView extends LinearLayout {
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
public void setStatusBar(CarStatusBar carStatusBar) {
|
||||
mCarStatusBar = carStatusBar;
|
||||
public void setNotificationsPanelController(
|
||||
CarNavigationBarController.NotificationsShadeController controller) {
|
||||
mNotificationsShadeController = controller;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,9 @@ public class CarNavigationBarView extends LinearLayout {
|
||||
}
|
||||
|
||||
protected void onNotificationsClick(View v) {
|
||||
mCarStatusBar.togglePanel();
|
||||
if (mNotificationsShadeController != null) {
|
||||
mNotificationsShadeController.togglePanel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,6 +85,7 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag
|
||||
super.onFinishInflate();
|
||||
setScaleType(ImageView.ScaleType.CENTER);
|
||||
setAlpha(mUnselectedAlpha);
|
||||
setImageResource(mIconResourceId);
|
||||
try {
|
||||
if (mIntent != null) {
|
||||
final Intent intent = Intent.parseUri(mIntent, Intent.URI_INTENT_SCHEME);
|
||||
|
||||
@@ -75,8 +75,8 @@ import com.android.systemui.keyguard.KeyguardViewMediator;
|
||||
import com.android.systemui.keyguard.ScreenLifecycle;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.navigationbar.car.CarFacetButtonController;
|
||||
import com.android.systemui.navigationbar.car.CarNavigationBarController;
|
||||
import com.android.systemui.navigationbar.car.CarNavigationBarView;
|
||||
import com.android.systemui.navigationbar.car.NavigationBarViewFactory;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.qs.QS;
|
||||
import com.android.systemui.qs.car.CarQSFragment;
|
||||
@@ -92,8 +92,6 @@ import com.android.systemui.statusbar.PulseExpansionHandler;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
||||
import com.android.systemui.statusbar.VibratorHelper;
|
||||
import com.android.systemui.statusbar.car.hvac.HvacController;
|
||||
import com.android.systemui.statusbar.car.hvac.TemperatureView;
|
||||
import com.android.systemui.statusbar.notification.BypassHeadsUpNotifier;
|
||||
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
|
||||
import com.android.systemui.statusbar.notification.NewNotifPipeline;
|
||||
@@ -170,14 +168,10 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
private CarNavigationBarView mRightNavigationBarView;
|
||||
|
||||
private final Object mQueueLock = new Object();
|
||||
private boolean mShowLeft;
|
||||
private boolean mShowRight;
|
||||
private boolean mShowBottom;
|
||||
private final NavigationBarViewFactory mNavigationBarViewFactory;
|
||||
private final CarNavigationBarController mCarNavigationBarController;
|
||||
private CarFacetButtonController mCarFacetButtonController;
|
||||
private DeviceProvisionedController mDeviceProvisionedController;
|
||||
private boolean mDeviceIsSetUpForUser = true;
|
||||
private HvacController mHvacController;
|
||||
private DrivingStateHelper mDrivingStateHelper;
|
||||
private PowerManagerHelper mPowerManagerHelper;
|
||||
private FlingAnimationUtils mFlingAnimationUtils;
|
||||
@@ -301,7 +295,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
Lazy<LockscreenWallpaper> lockscreenWallpaperLazy,
|
||||
|
||||
/* Car Settings injected components. */
|
||||
NavigationBarViewFactory navigationBarViewFactory) {
|
||||
CarNavigationBarController carNavigationBarController) {
|
||||
super(
|
||||
context,
|
||||
featureFlags,
|
||||
@@ -363,7 +357,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
scrimController,
|
||||
lockscreenWallpaperLazy);
|
||||
mScrimController = scrimController;
|
||||
mNavigationBarViewFactory = navigationBarViewFactory;
|
||||
mCarNavigationBarController = carNavigationBarController;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -378,10 +372,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
|
||||
mScreenLifecycle.addObserver(mScreenObserver);
|
||||
|
||||
// Need to initialize HVAC controller before calling super.start - before system bars are
|
||||
// created.
|
||||
mHvacController = new HvacController(mContext);
|
||||
|
||||
super.start();
|
||||
|
||||
mNotificationPanel.setScrollingEnabled(true);
|
||||
@@ -395,8 +385,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
createBatteryController();
|
||||
mCarBatteryController.startListening();
|
||||
|
||||
mHvacController.connectToCarService();
|
||||
|
||||
mDeviceProvisionedController.addCallback(
|
||||
new DeviceProvisionedController.DeviceProvisionedListener() {
|
||||
@Override
|
||||
@@ -433,9 +421,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
* before and after the device is provisioned. . Also for change of density and font size.
|
||||
*/
|
||||
private void restartNavBars() {
|
||||
// remove and reattach all hvac components such that we don't keep a reference to unused
|
||||
// ui elements
|
||||
mHvacController.removeAllComponents();
|
||||
mCarFacetButtonController.removeAll();
|
||||
|
||||
if (mNavigationBarWindow != null) {
|
||||
@@ -454,17 +439,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
mCarFacetButtonController.addAllFacetButtons(mStatusBarWindow);
|
||||
}
|
||||
|
||||
private void addTemperatureViewToController(View v) {
|
||||
if (v instanceof TemperatureView) {
|
||||
mHvacController.addHvacTextView((TemperatureView) v);
|
||||
} else if (v instanceof ViewGroup) {
|
||||
ViewGroup viewGroup = (ViewGroup) v;
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
addTemperatureViewToController(viewGroup.getChildAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for showing or hiding just the navigation bars. This is indented to be used when
|
||||
* the full screen user selector is shown.
|
||||
@@ -885,10 +859,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
|
||||
@Override
|
||||
protected void createNavigationBar(@Nullable RegisterStatusBarResult result) {
|
||||
mShowBottom = mContext.getResources().getBoolean(R.bool.config_enableBottomNavigationBar);
|
||||
mShowLeft = mContext.getResources().getBoolean(R.bool.config_enableLeftNavigationBar);
|
||||
mShowRight = mContext.getResources().getBoolean(R.bool.config_enableRightNavigationBar);
|
||||
|
||||
buildNavBarWindows();
|
||||
buildNavBarContent();
|
||||
}
|
||||
@@ -896,50 +866,36 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
private void buildNavBarContent() {
|
||||
buildTopBar();
|
||||
|
||||
if (mShowBottom) {
|
||||
mNavigationBarView = mNavigationBarViewFactory.getBottomBar(mDeviceIsSetUpForUser);
|
||||
mNavigationBarView.setStatusBar(this);
|
||||
mNavigationBarView.setStatusBarWindowTouchListener(mNavBarNotificationTouchListener);
|
||||
}
|
||||
mNavigationBarView = mCarNavigationBarController.getBottomBar(mDeviceIsSetUpForUser);
|
||||
mCarNavigationBarController.registerBottomBarTouchListener(
|
||||
mNavBarNotificationTouchListener);
|
||||
|
||||
if (mShowLeft) {
|
||||
mLeftNavigationBarView = mNavigationBarViewFactory.getLeftBar(mDeviceIsSetUpForUser);
|
||||
mLeftNavigationBarView.setStatusBar(this);
|
||||
mLeftNavigationBarView.setStatusBarWindowTouchListener(
|
||||
mNavBarNotificationTouchListener);
|
||||
}
|
||||
mLeftNavigationBarView = mCarNavigationBarController.getLeftBar(mDeviceIsSetUpForUser);
|
||||
mCarNavigationBarController.registerLeftBarTouchListener(
|
||||
mNavBarNotificationTouchListener);
|
||||
|
||||
if (mShowRight) {
|
||||
mRightNavigationBarView = mNavigationBarViewFactory.getLeftBar(mDeviceIsSetUpForUser);
|
||||
mRightNavigationBarView.setStatusBar(this);
|
||||
mRightNavigationBarView.setStatusBarWindowTouchListener(
|
||||
mNavBarNotificationTouchListener);
|
||||
}
|
||||
mRightNavigationBarView = mCarNavigationBarController.getLeftBar(mDeviceIsSetUpForUser);
|
||||
mCarNavigationBarController.registerRightBarTouchListener(
|
||||
mNavBarNotificationTouchListener);
|
||||
|
||||
mCarNavigationBarController.registerNotificationController(() -> togglePanel());
|
||||
}
|
||||
|
||||
private void buildNavBarWindows() {
|
||||
mTopNavigationBarContainer = mStatusBarWindow
|
||||
.findViewById(R.id.car_top_navigation_bar_container);
|
||||
|
||||
if (mShowBottom) {
|
||||
mNavigationBarWindow = mNavigationBarViewFactory.getBottomWindow();
|
||||
}
|
||||
if (mShowLeft) {
|
||||
mLeftNavigationBarWindow = mNavigationBarViewFactory.getLeftWindow();
|
||||
}
|
||||
if (mShowRight) {
|
||||
mRightNavigationBarWindow = mNavigationBarViewFactory.getRightWindow();
|
||||
}
|
||||
mNavigationBarWindow = mCarNavigationBarController.getBottomWindow();
|
||||
mLeftNavigationBarWindow = mCarNavigationBarController.getLeftWindow();
|
||||
mRightNavigationBarWindow = mCarNavigationBarController.getRightWindow();
|
||||
}
|
||||
|
||||
private void buildTopBar() {
|
||||
mTopNavigationBarContainer.removeAllViews();
|
||||
mTopNavigationBarView = mNavigationBarViewFactory.getTopBar(mDeviceIsSetUpForUser);
|
||||
mTopNavigationBarView = mCarNavigationBarController.getTopBar(mDeviceIsSetUpForUser);
|
||||
mCarNavigationBarController.registerTopBarTouchListener(
|
||||
mTopNavBarNotificationTouchListener);
|
||||
mTopNavigationBarContainer.addView(mTopNavigationBarView);
|
||||
|
||||
mTopNavigationBarView.setStatusBar(this);
|
||||
addTemperatureViewToController(mTopNavigationBarView);
|
||||
mTopNavigationBarView.setStatusBarWindowTouchListener(mTopNavBarNotificationTouchListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user