package com.android.server.wm;
import static android.app.ActivityManager.DOCKED_STACK_ID;
+import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static com.android.server.wm.TaskStack.DOCKED_BOTTOM;
-import static com.android.server.wm.TaskStack.DOCKED_INVALID;
import static com.android.server.wm.TaskStack.DOCKED_LEFT;
import static com.android.server.wm.TaskStack.DOCKED_RIGHT;
import static com.android.server.wm.TaskStack.DOCKED_TOP;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.RemoteException;
-import android.util.Slog;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
private Rect mOriginalRect = new Rect();
private int mDockSide;
-
DockedStackDividerController(Context context, DisplayContent displayContent) {
mContext = context;
mDisplayContent = displayContent;
com.android.internal.R.dimen.docked_stack_divider_thickness);
}
- private void addDivider() {
+ private void addDivider(Configuration configuration) {
View view = LayoutInflater.from(mContext).inflate(
com.android.internal.R.layout.docked_stack_divider, null);
view.setOnTouchListener(this);
WindowManagerGlobal manager = WindowManagerGlobal.getInstance();
+ final boolean landscape = configuration.orientation == ORIENTATION_LANDSCAPE;
+ final int width = landscape ? mDividerWidth : MATCH_PARENT;
+ final int height = landscape ? MATCH_PARENT : mDividerWidth;
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
- mDividerWidth, MATCH_PARENT, TYPE_DOCK_DIVIDER,
+ width, height, TYPE_DOCK_DIVIDER,
FLAG_TOUCHABLE_WHEN_WAKING | FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL
| FLAG_WATCH_OUTSIDE_TOUCH | FLAG_SPLIT_TOUCH,
PixelFormat.OPAQUE);
return mView != null;
}
- void update() {
+ void update(Configuration configuration, boolean forceUpdate) {
+ if (forceUpdate && mView != null) {
+ removeDivider();
+ }
TaskStack stack = mDisplayContent.getDockedStackLocked();
if (stack != null && mView == null) {
- addDivider();
+ addDivider(configuration);
} else if (stack == null && mView != null) {
removeDivider();
}
}
synchronized(mWindowMap) {
+ final boolean orientationChanged = mCurConfiguration.orientation != config.orientation;
mCurConfiguration = new Configuration(config);
if (mWaitingForConfig) {
mWaitingForConfig = false;
mLastFinishedFreezeSource = "new-config";
}
mWindowPlacerLocked.performSurfacePlacement();
+ if (orientationChanged) {
+ for (int i = mDisplayContents.size() - 1; i >= 0; i--) {
+ DisplayContent content = mDisplayContents.valueAt(i);
+ Message.obtain(mH, H.UPDATE_DOCKED_STACK_DIVIDER, H.DOCK_DIVIDER_FORCE_UPDATE,
+ H.UNUSED, content).sendToTarget();
+ }
+ }
}
}
public static final int RESIZE_STACK = 43;
public static final int RESIZE_TASK = 44;
+ /**
+ * Used to indicate in the message that the dock divider needs to be updated only if it's
+ * necessary.
+ */
+ static final int DOCK_DIVIDER_NO_FORCE_UPDATE = 0;
+ /**
+ * Used to indicate in the message that the dock divider should be force-removed before
+ * updating, so new configuration can be applied.
+ */
+ static final int DOCK_DIVIDER_FORCE_UPDATE = 1;
+ /**
+ * Used to denote that an integer field in a message will not be used.
+ */
+ public static final int UNUSED = 0;
+
@Override
public void handleMessage(Message msg) {
if (DEBUG_WINDOW_TRACE) {
break;
case UPDATE_DOCKED_STACK_DIVIDER: {
DisplayContent content = (DisplayContent) msg.obj;
+ final boolean forceUpdate = msg.arg1 == DOCK_DIVIDER_FORCE_UPDATE;
synchronized (mWindowMap) {
- content.mDividerControllerLocked.update();
+ content.mDividerControllerLocked.update(mCurConfiguration, forceUpdate);
}
}
break;