Merge "Allow for the lock screen to have a different set of nav buttons" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bdf8770ae3
@@ -27,4 +27,5 @@
|
||||
<bool name="config_enableLeftNavigationBar">false</bool>
|
||||
<bool name="config_enableRightNavigationBar">false</bool>
|
||||
<bool name="config_enableBottomNavigationBar">true</bool>
|
||||
<bool name="config_hideNavWhenKeyguardBouncerShown">true</bool>
|
||||
</resources>
|
||||
|
||||
22
packages/SystemUI/res/values/ids_car.xml
Normal file
22
packages/SystemUI/res/values/ids_car.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2018 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
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- Values used for finding elements on the system ui nav bars -->
|
||||
<item type="id" name="lock_screen_nav_buttons"/>
|
||||
<item type="id" name="nav_buttons"/>
|
||||
</resources>
|
||||
@@ -17,17 +17,29 @@ package com.android.systemui.car;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
import com.android.systemui.Dependency.DependencyProvider;
|
||||
import com.android.systemui.SystemUIFactory;
|
||||
import com.android.systemui.statusbar.NotificationEntryManager;
|
||||
import com.android.systemui.statusbar.car.CarFacetButtonController;
|
||||
import com.android.systemui.statusbar.car.CarStatusBar;
|
||||
import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager;
|
||||
import com.android.systemui.statusbar.car.hvac.HvacController;
|
||||
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
|
||||
|
||||
/**
|
||||
* Class factory to provide car specific SystemUI components.
|
||||
*/
|
||||
public class CarSystemUIFactory extends SystemUIFactory {
|
||||
|
||||
public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context,
|
||||
ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) {
|
||||
return new CarStatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectDependencies(ArrayMap<Object, DependencyProvider> providers,
|
||||
Context context) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -73,36 +74,43 @@ public class CarFacetButtonController {
|
||||
*/
|
||||
public void taskChanged(List<ActivityManager.StackInfo> stackInfoList) {
|
||||
int displayId = getDisplayId();
|
||||
ActivityManager.StackInfo validStackInfo = null;
|
||||
for (ActivityManager.StackInfo stackInfo :stackInfoList) {
|
||||
// if the display id is known and does not match the stack we skip
|
||||
if (displayId != -1 && displayId != stackInfo.displayId ||
|
||||
stackInfo.topActivity == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mSelectedFacetButton != null) {
|
||||
mSelectedFacetButton.setSelected(false);
|
||||
}
|
||||
|
||||
String packageName = stackInfo.topActivity.getPackageName();
|
||||
CarFacetButton facetButton = findFacetButtongByComponentName(stackInfo.topActivity);
|
||||
if (facetButton == null) {
|
||||
facetButton = mButtonsByPackage.get(packageName);
|
||||
}
|
||||
|
||||
if (facetButton == null) {
|
||||
String category = getPackageCategory(packageName);
|
||||
if (category != null) {
|
||||
facetButton = mButtonsByCategory.get(category);
|
||||
}
|
||||
}
|
||||
|
||||
if (facetButton != null) {
|
||||
facetButton.setSelected(true);
|
||||
mSelectedFacetButton = facetButton;
|
||||
return;
|
||||
// If the display id is unknown or it matches the stack, it's valid for use
|
||||
if ((displayId == -1 || displayId == stackInfo.displayId) &&
|
||||
stackInfo.topActivity != null) {
|
||||
validStackInfo = stackInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (validStackInfo == null) {
|
||||
// No stack was found that was on the same display as the facet buttons thus return
|
||||
return;
|
||||
}
|
||||
|
||||
if (mSelectedFacetButton != null) {
|
||||
mSelectedFacetButton.setSelected(false);
|
||||
}
|
||||
|
||||
String packageName = validStackInfo.topActivity.getPackageName();
|
||||
CarFacetButton facetButton = findFacetButtongByComponentName(validStackInfo.topActivity);
|
||||
if (facetButton == null) {
|
||||
facetButton = mButtonsByPackage.get(packageName);
|
||||
}
|
||||
|
||||
if (facetButton == null) {
|
||||
String category = getPackageCategory(packageName);
|
||||
if (category != null) {
|
||||
facetButton = mButtonsByCategory.get(category);
|
||||
}
|
||||
}
|
||||
|
||||
if (facetButton != null && facetButton.getVisibility() == View.VISIBLE) {
|
||||
facetButton.setSelected(true);
|
||||
mSelectedFacetButton = facetButton;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int getDisplayId() {
|
||||
|
||||
@@ -36,10 +36,11 @@ import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
* in a linear layout.
|
||||
*/
|
||||
class CarNavigationBarView extends LinearLayout {
|
||||
private LinearLayout mNavButtons;
|
||||
private View mNavButtons;
|
||||
private AlphaOptimizedImageButton mNotificationsButton;
|
||||
private CarStatusBar mCarStatusBar;
|
||||
private Context mContext;
|
||||
private View mLockScreenButtons;
|
||||
|
||||
public CarNavigationBarView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -49,6 +50,7 @@ class CarNavigationBarView extends LinearLayout {
|
||||
@Override
|
||||
public void onFinishInflate() {
|
||||
mNavButtons = findViewById(R.id.nav_buttons);
|
||||
mLockScreenButtons = findViewById(R.id.lock_screen_nav_buttons);
|
||||
|
||||
mNotificationsButton = findViewById(R.id.notifications);
|
||||
if (mNotificationsButton != null) {
|
||||
@@ -74,4 +76,28 @@ class CarNavigationBarView extends LinearLayout {
|
||||
protected void onNotificationsClick(View v) {
|
||||
mCarStatusBar.togglePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* If there are buttons declared in the layout they will be shown and the normal
|
||||
* Nav buttons will be hidden.
|
||||
*/
|
||||
public void showKeyguardButtons() {
|
||||
if (mLockScreenButtons == null) {
|
||||
return;
|
||||
}
|
||||
mLockScreenButtons.setVisibility(View.VISIBLE);
|
||||
mNavButtons.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* If there are buttons declared in the layout they will be hidden and the normal
|
||||
* Nav buttons will be shown.
|
||||
*/
|
||||
public void hideKeyguardButtons() {
|
||||
if (mLockScreenButtons == null) {
|
||||
return;
|
||||
}
|
||||
mNavButtons.setVisibility(View.VISIBLE);
|
||||
mLockScreenButtons.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +141,52 @@ public class CarStatusBar extends StatusBar implements
|
||||
buildNavBarContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for showing or hiding just the navigation bars. This is indented to be used when
|
||||
* the full screen user selector is shown.
|
||||
*/
|
||||
void setNavBarVisibility(@View.Visibility int visibility) {
|
||||
if (mNavigationBarWindow != null) {
|
||||
mNavigationBarWindow.setVisibility(visibility);
|
||||
}
|
||||
if (mLeftNavigationBarWindow != null) {
|
||||
mLeftNavigationBarWindow.setVisibility(visibility);
|
||||
}
|
||||
if (mRightNavigationBarWindow != null) {
|
||||
mRightNavigationBarWindow.setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hideKeyguard() {
|
||||
boolean result = super.hideKeyguard();
|
||||
if (mNavigationBarView != null) {
|
||||
mNavigationBarView.hideKeyguardButtons();
|
||||
}
|
||||
if (mLeftNavigationBarView != null) {
|
||||
mLeftNavigationBarView.hideKeyguardButtons();
|
||||
}
|
||||
if (mRightNavigationBarView != null) {
|
||||
mRightNavigationBarView.hideKeyguardButtons();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void showKeyguard() {
|
||||
super.showKeyguard();
|
||||
if (mNavigationBarView != null) {
|
||||
mNavigationBarView.showKeyguardButtons();
|
||||
}
|
||||
if (mLeftNavigationBarView != null) {
|
||||
mLeftNavigationBarView.showKeyguardButtons();
|
||||
}
|
||||
if (mRightNavigationBarView != null) {
|
||||
mRightNavigationBarView.showKeyguardButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.android.systemui.statusbar.car;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
|
||||
|
||||
public class CarStatusBarKeyguardViewManager extends StatusBarKeyguardViewManager {
|
||||
|
||||
protected boolean mShouldHideNavBar;
|
||||
|
||||
public CarStatusBarKeyguardViewManager(Context context,
|
||||
ViewMediatorCallback callback,
|
||||
LockPatternUtils lockPatternUtils) {
|
||||
super(context, callback, lockPatternUtils);
|
||||
mShouldHideNavBar =context.getResources()
|
||||
.getBoolean(R.bool.config_hideNavWhenKeyguardBouncerShown);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateNavigationBarVisibility(boolean navBarVisible) {
|
||||
if(!mShouldHideNavBar) {
|
||||
return;
|
||||
}
|
||||
CarStatusBar statusBar = (CarStatusBar) mStatusBar;
|
||||
statusBar.setNavBarVisibility(navBarVisible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
@@ -586,20 +586,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
boolean navBarVisible = isNavBarVisible();
|
||||
boolean lastNavBarVisible = getLastNavBarVisible();
|
||||
if (navBarVisible != lastNavBarVisible || mFirstUpdate) {
|
||||
if (mStatusBar.getNavigationBarView() != null) {
|
||||
if (navBarVisible) {
|
||||
long delay = getNavBarShowDelay();
|
||||
if (delay == 0) {
|
||||
mMakeNavigationBarVisibleRunnable.run();
|
||||
} else {
|
||||
mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable,
|
||||
delay);
|
||||
}
|
||||
} else {
|
||||
mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable);
|
||||
mStatusBar.getNavigationBarView().getRootView().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
updateNavigationBarVisibility(navBarVisible);
|
||||
}
|
||||
|
||||
if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) {
|
||||
@@ -626,6 +613,23 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
mStatusBar.onKeyguardViewManagerStatesUpdated();
|
||||
}
|
||||
|
||||
protected void updateNavigationBarVisibility(boolean navBarVisible) {
|
||||
if (mStatusBar.getNavigationBarView() != null) {
|
||||
if (navBarVisible) {
|
||||
long delay = getNavBarShowDelay();
|
||||
if (delay == 0) {
|
||||
mMakeNavigationBarVisibleRunnable.run();
|
||||
} else {
|
||||
mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable,
|
||||
delay);
|
||||
}
|
||||
} else {
|
||||
mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable);
|
||||
mStatusBar.getNavigationBarView().getRootView().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the navigation bar should be made visible based on the current state.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user