* 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();
}
* 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;
@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();
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);
}
private Drawable mHomeDefaultIcon, mHomeCarModeIcon;
private Drawable mRecentIcon;
private Drawable mDockedIcon;
+ private Drawable mImeIcon;
+ private Drawable mMenuIcon;
private NavigationBarGestureHelper mGestureHelper;
private DeadZone mDeadZone;
}
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) {
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);
}
}
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);
}
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);
}
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");
}
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);
}
}
- 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;
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");
}
}
+ @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) {
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();
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() {
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;
// 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;
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;
mBounds.set(bounds);
mRotation = rotation;
+ mDensity = density;
updateAdjustedBounds();
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
}
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;
}
}
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);