diff options
| author | 2016-04-05 20:41:21 -0700 | |
|---|---|---|
| committer | 2016-04-06 19:12:24 +0000 | |
| commit | 11c62e17af9096f76d4532f26cacd809c3a5ef53 (patch) | |
| tree | f3d3f04659e5351a0a22fc39f37734fd675483cf | |
| parent | f583427b0de21037b9bda8a8a66b1ca4e4e1c9b9 (diff) | |
Dynamic density change handling
- In PWM, make sure to read the height values after the new
configuration has been applied.
- Reset all navigation bar button icons when density changes.
- Adjust height of notification bar.
- Reload divider height values in SysUI and WM.
- Snap divider handle to a new position after loading the
new configuration, as the snap points change.
Bug: 26844819
Bug: 27450471
Bug: 27921696
Change-Id: I9e28f0c49f6367c5fcfac010e7a6e98a42e85996
9 files changed, 105 insertions, 63 deletions
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 23b0df2db110..96f179b8db63 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -1397,4 +1397,9 @@ public interface WindowManagerPolicy { * is allowed, so for example, if DOCKED_RIGHT is not allowed, DOCKED_LEFT is allowed. */ public boolean isDockSideAllowed(int dockSide); + + /** + * Called when the configuration has changed, and it's safe to load new values from resources. + */ + public void onConfigurationChanged(); } diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java index ddd3ea163e57..d294c80bdf51 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java @@ -34,8 +34,6 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; * Controls the docked stack divider. */ public class Divider extends SystemUI { - private static final String TAG = "Divider"; - private int mDividerWindowWidth; private DividerWindowManager mWindowManager; private DividerView mView; private DockDividerVisibilityListener mDockDividerVisibilityListener; @@ -46,8 +44,6 @@ public class Divider extends SystemUI { @Override public void start() { mWindowManager = new DividerWindowManager(mContext); - mDividerWindowWidth = mContext.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.docked_stack_divider_thickness); update(mContext.getResources().getConfiguration()); putComponent(Divider.class, this); mDockDividerVisibilityListener = new DockDividerVisibilityListener(); @@ -70,9 +66,11 @@ public class Divider extends SystemUI { mView = (DividerView) LayoutInflater.from(mContext).inflate(R.layout.docked_stack_divider, null); mView.setVisibility(mVisible ? View.VISIBLE : View.INVISIBLE); + final int size = mContext.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.docked_stack_divider_thickness); final boolean landscape = configuration.orientation == ORIENTATION_LANDSCAPE; - final int width = landscape ? mDividerWindowWidth : MATCH_PARENT; - final int height = landscape ? MATCH_PARENT : mDividerWindowWidth; + final int width = landscape ? size : MATCH_PARENT; + final int height = landscape ? MATCH_PARENT : size; mWindowManager.add(mView, width, height); mView.setWindowManager(mWindowManager); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 56a7dbed52cb..68593484a862 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -76,6 +76,8 @@ public class NavigationBarView extends LinearLayout { private Drawable mHomeDefaultIcon, mHomeCarModeIcon; private Drawable mRecentIcon; private Drawable mDockedIcon; + private Drawable mImeIcon; + private Drawable mMenuIcon; private NavigationBarGestureHelper mGestureHelper; private DeadZone mDeadZone; @@ -270,7 +272,8 @@ public class NavigationBarView extends LinearLayout { } private void updateIcons(Context ctx, Configuration oldConfig, Configuration newConfig) { - if (oldConfig.orientation != newConfig.orientation) { + if (oldConfig.orientation != newConfig.orientation + || oldConfig.densityDpi != newConfig.densityDpi) { mDockedIcon = ctx.getDrawable(R.drawable.ic_sysbar_docked); } if (oldConfig.densityDpi != newConfig.densityDpi) { @@ -280,8 +283,10 @@ public class NavigationBarView extends LinearLayout { mBackAltLandIcon = mBackAltIcon; mHomeDefaultIcon = ctx.getDrawable(R.drawable.ic_sysbar_home); - mRecentIcon = ctx.getDrawable(R.drawable.ic_sysbar_recent); + mMenuIcon = ctx.getDrawable(R.drawable.ic_sysbar_menu); + mImeIcon = ctx.getDrawable(R.drawable.ic_ime_switcher_default); + updateCarModeIcons(ctx); } } @@ -348,9 +353,11 @@ public class NavigationBarView extends LinearLayout { final boolean showImeButton = ((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0); getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE); + getImeSwitchButton().setImageDrawable(mImeIcon); // Update menu button in case the IME state has changed. setMenuVisibility(mShowMenu, true); + getMenuButton().setImageDrawable(mMenuIcon); setDisabledFlags(mDisabledFlags, true); } @@ -595,14 +602,12 @@ public class NavigationBarView extends LinearLayout { super.onConfigurationChanged(newConfig); boolean uiCarModeChanged = updateCarMode(newConfig); updateTaskSwitchHelper(); - if (uiCarModeChanged) { - // uiMode changed either from carmode or to carmode. - // replace the nav bar button icons based on which mode - // we are switching to. - setNavigationIconHints(mNavigationIconHints, true); - } updateIcons(getContext(), mConfiguration, newConfig); updateRecentsIcon(); + if (uiCarModeChanged || mConfiguration.densityDpi != newConfig.densityDpi) { + // If car mode or density changes, we need to reset the icons. + setNavigationIconHints(mNavigationIconHints, true); + } mConfiguration.updateFrom(newConfig); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index fce893e0b5f6..32a6f161cfdf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3303,10 +3303,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, protected void loadDimens() { final Resources res = mContext.getResources(); + int oldBarHeight = mNaturalBarHeight; mNaturalBarHeight = res.getDimensionPixelSize( com.android.internal.R.dimen.status_bar_height); - - mMaxAllowedKeyguardNotifications = res.getInteger(R.integer.keyguard_max_notification_count); + if (mStatusBarWindowManager != null && mNaturalBarHeight != oldBarHeight) { + mStatusBarWindowManager.setBarHeight(mNaturalBarHeight); + } + mMaxAllowedKeyguardNotifications = res.getInteger( + R.integer.keyguard_max_notification_count); if (DEBUG) Log.v(TAG, "updateResources"); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java index b271380e496c..888e19c50f38 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java @@ -323,6 +323,11 @@ public class StatusBarWindowManager implements RemoteInputController.Callback { apply(mCurrentState); } + public void setBarHeight(int barHeight) { + mBarHeight = barHeight; + apply(mCurrentState); + } + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("StatusBarWindowManager state:"); pw.println(mCurrentState); diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 14d0457e41c1..a0752aa6fff2 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -1817,41 +1817,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } - mStatusBarHeight = - res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); - - // Height of the navigation bar when presented horizontally at bottom - mNavigationBarHeightForRotationDefault[mPortraitRotation] = - mNavigationBarHeightForRotationDefault[mUpsideDownRotation] = - res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); - mNavigationBarHeightForRotationDefault[mLandscapeRotation] = - mNavigationBarHeightForRotationDefault[mSeascapeRotation] = res.getDimensionPixelSize( - com.android.internal.R.dimen.navigation_bar_height_landscape); - - // Width of the navigation bar when presented vertically along one side - mNavigationBarWidthForRotationDefault[mPortraitRotation] = - mNavigationBarWidthForRotationDefault[mUpsideDownRotation] = - mNavigationBarWidthForRotationDefault[mLandscapeRotation] = - mNavigationBarWidthForRotationDefault[mSeascapeRotation] = - res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); - - // Height of the navigation bar when presented horizontally at bottom - mNavigationBarHeightForRotationInCarMode[mPortraitRotation] = - mNavigationBarHeightForRotationInCarMode[mUpsideDownRotation] = - res.getDimensionPixelSize( - com.android.internal.R.dimen.navigation_bar_height_car_mode); - mNavigationBarHeightForRotationInCarMode[mLandscapeRotation] = - mNavigationBarHeightForRotationInCarMode[mSeascapeRotation] = res.getDimensionPixelSize( - com.android.internal.R.dimen.navigation_bar_height_landscape_car_mode); - - // Width of the navigation bar when presented vertically along one side - mNavigationBarWidthForRotationInCarMode[mPortraitRotation] = - mNavigationBarWidthForRotationInCarMode[mUpsideDownRotation] = - mNavigationBarWidthForRotationInCarMode[mLandscapeRotation] = - mNavigationBarWidthForRotationInCarMode[mSeascapeRotation] = - res.getDimensionPixelSize( - com.android.internal.R.dimen.navigation_bar_width_car_mode); - // SystemUI (status bar) layout policy int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; @@ -1860,6 +1825,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mNavigationBarCanMove = width != height && shortSizeDp < 600; mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); + // Allow a system property to override this. Used by the emulator. // See also hasNavigationBar(). String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); @@ -2290,6 +2256,46 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } + @Override + public void onConfigurationChanged() { + final Resources res = mContext.getResources(); + + mStatusBarHeight = + res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); + + // Height of the navigation bar when presented horizontally at bottom + mNavigationBarHeightForRotationDefault[mPortraitRotation] = + mNavigationBarHeightForRotationDefault[mUpsideDownRotation] = + res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); + mNavigationBarHeightForRotationDefault[mLandscapeRotation] = + mNavigationBarHeightForRotationDefault[mSeascapeRotation] = res.getDimensionPixelSize( + com.android.internal.R.dimen.navigation_bar_height_landscape); + + // Width of the navigation bar when presented vertically along one side + mNavigationBarWidthForRotationDefault[mPortraitRotation] = + mNavigationBarWidthForRotationDefault[mUpsideDownRotation] = + mNavigationBarWidthForRotationDefault[mLandscapeRotation] = + mNavigationBarWidthForRotationDefault[mSeascapeRotation] = + res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); + + // Height of the navigation bar when presented horizontally at bottom + mNavigationBarHeightForRotationInCarMode[mPortraitRotation] = + mNavigationBarHeightForRotationInCarMode[mUpsideDownRotation] = + res.getDimensionPixelSize( + com.android.internal.R.dimen.navigation_bar_height_car_mode); + mNavigationBarHeightForRotationInCarMode[mLandscapeRotation] = + mNavigationBarHeightForRotationInCarMode[mSeascapeRotation] = res.getDimensionPixelSize( + com.android.internal.R.dimen.navigation_bar_height_landscape_car_mode); + + // Width of the navigation bar when presented vertically along one side + mNavigationBarWidthForRotationInCarMode[mPortraitRotation] = + mNavigationBarWidthForRotationInCarMode[mUpsideDownRotation] = + mNavigationBarWidthForRotationInCarMode[mLandscapeRotation] = + mNavigationBarWidthForRotationInCarMode[mSeascapeRotation] = + res.getDimensionPixelSize( + com.android.internal.R.dimen.navigation_bar_width_car_mode); + } + /** {@inheritDoc} */ @Override public int windowTypeToLayerLw(int type) { diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java index 6f7e64f28e74..6ac71c795ca7 100644 --- a/services/core/java/com/android/server/wm/DockedStackDividerController.java +++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java @@ -76,8 +76,8 @@ public class DockedStackDividerController implements DimLayerUser { private final WindowManagerService mService; private final DisplayContent mDisplayContent; - private final int mDividerWindowWidth; - private final int mDividerInsets; + private int mDividerWindowWidth; + private int mDividerInsets; private boolean mResizing; private WindowState mWindow; private final Rect mTmpRect = new Rect(); @@ -105,14 +105,23 @@ public class DockedStackDividerController implements DimLayerUser { mService = service; mDisplayContent = displayContent; final Context context = service.mContext; - mDividerWindowWidth = context.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.docked_stack_divider_thickness); - mDividerInsets = context.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.docked_stack_divider_insets); mDimLayer = new DimLayer(displayContent.mService, this, displayContent.getDisplayId(), "DockedStackDim"); mMinimizedDockInterpolator = AnimationUtils.loadInterpolator( context, android.R.interpolator.fast_out_slow_in); + loadDimens(); + } + + private void loadDimens() { + final Context context = mService.mContext; + mDividerWindowWidth = context.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.docked_stack_divider_thickness); + mDividerInsets = context.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.docked_stack_divider_insets); + } + + void onConfigurationChanged() { + loadDimens(); } boolean isResizing() { diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 0225c9b4105f..3430ac9289a5 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -37,8 +37,8 @@ import java.util.ArrayList; import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.PINNED_STACK_ID; +import static android.content.res.Configuration.DENSITY_DPI_UNDEFINED; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.view.WindowManager.DOCKED_BOTTOM; import static android.view.WindowManager.DOCKED_INVALID; @@ -89,6 +89,9 @@ public class TaskStack implements DimLayer.DimLayerUser, // Device rotation as of the last time {@link #mBounds} was set. int mRotation; + /** Density as of last time {@link #mBounds} was set. */ + int mDensity; + /** Support for non-zero {@link android.view.animation.Animation#getBackgroundColor()} */ DimLayer mAnimationBackgroundSurface; @@ -250,9 +253,11 @@ public class TaskStack implements DimLayer.DimLayerUser, private boolean setBounds(Rect bounds) { boolean oldFullscreen = mFullscreen; int rotation = Surface.ROTATION_0; + int density = DENSITY_DPI_UNDEFINED; if (mDisplayContent != null) { mDisplayContent.getLogicalDisplayRect(mTmpRect); rotation = mDisplayContent.getDisplayInfo().rotation; + density = mDisplayContent.getDisplayInfo().logicalDensityDpi; mFullscreen = bounds == null; if (mFullscreen) { bounds = mTmpRect; @@ -274,6 +279,7 @@ public class TaskStack implements DimLayer.DimLayerUser, mBounds.set(bounds); mRotation = rotation; + mDensity = density; updateAdjustedBounds(); @@ -343,20 +349,21 @@ public class TaskStack implements DimLayer.DimLayerUser, mTmpRect2.set(mBounds); final int newRotation = mDisplayContent.getDisplayInfo().rotation; - if (mRotation == newRotation) { + final int newDensity = mDisplayContent.getDisplayInfo().logicalDensityDpi; + if (mRotation == newRotation && mDensity == newDensity) { setBounds(mTmpRect2); } else { mLastUpdateDisplayInfoRotation = newRotation; - updateBoundsAfterRotation(true); + updateBoundsAfterConfigChange(true); } } boolean onConfigurationChanged() { mLastConfigChangedRotation = getDisplayInfo().rotation; - return updateBoundsAfterRotation(false); + return updateBoundsAfterConfigChange(false); } - boolean updateBoundsAfterRotation(boolean scheduleResize) { + boolean updateBoundsAfterConfigChange(boolean scheduleResize) { if (mLastConfigChangedRotation != mLastUpdateDisplayInfoRotation) { // We wait for the rotation values after configuration change and display info. update // to be equal before updating the bounds due to rotation change otherwise things might @@ -365,8 +372,9 @@ public class TaskStack implements DimLayer.DimLayerUser, } final int newRotation = getDisplayInfo().rotation; + final int newDensity = getDisplayInfo().logicalDensityDpi; - if (mRotation == newRotation) { + if (mRotation == newRotation && mDensity == newDensity) { // Nothing to do here if the rotation didn't change return false; } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index a632bdb7beef..5de2182f1019 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3627,6 +3627,8 @@ public class WindowManagerService extends IWindowManager.Stub } private int[] onConfigurationChanged() { + mPolicy.onConfigurationChanged(); + getDefaultDisplayContentLocked().getDockedDividerController().onConfigurationChanged(); mChangedStackList.clear(); for (int stackNdx = mStackIdToStack.size() - 1; stackNdx >= 0; stackNdx--) { final TaskStack stack = mStackIdToStack.valueAt(stackNdx); |