Merge "Implement cropping of windows based on system UI elements." into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3fd4a38221
@ -16820,6 +16820,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
|
||||
*/
|
||||
boolean mUse32BitDrawingCache;
|
||||
|
||||
/**
|
||||
* Describes the parts of the window that are currently completely
|
||||
* obscured by system UI elements.
|
||||
*/
|
||||
final Rect mSystemInsets = new Rect();
|
||||
|
||||
/**
|
||||
* For windows that are full-screen but using insets to layout inside
|
||||
* of the screen decorations, these are the current insets for the
|
||||
|
@ -262,6 +262,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
final Rect mPendingVisibleInsets = new Rect();
|
||||
final Rect mPendingContentInsets = new Rect();
|
||||
final Rect mPendingSystemInsets = new Rect();
|
||||
final Rect mActiveRect = new Rect();
|
||||
final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
|
||||
= new ViewTreeObserver.InternalInsetsInfo();
|
||||
|
||||
@ -271,7 +272,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
final Configuration mPendingConfiguration = new Configuration();
|
||||
|
||||
class ResizedInfo {
|
||||
Rect coveredInsets;
|
||||
Rect systemInsets;
|
||||
Rect contentInsets;
|
||||
Rect visibleInsets;
|
||||
Configuration newConfig;
|
||||
}
|
||||
@ -567,6 +569,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
if (mTranslator != null) {
|
||||
mTranslator.translateRectInScreenToAppWindow(mAttachInfo.mContentInsets);
|
||||
}
|
||||
mPendingSystemInsets.set(0, 0, 0, 0);
|
||||
mPendingContentInsets.set(mAttachInfo.mContentInsets);
|
||||
mPendingVisibleInsets.set(0, 0, 0, 0);
|
||||
if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow);
|
||||
@ -1222,6 +1225,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
getRunQueue().executeActions(attachInfo.mHandler);
|
||||
|
||||
boolean insetsChanged = false;
|
||||
boolean activeRectChanged = false;
|
||||
|
||||
boolean layoutRequested = mLayoutRequested && !mStopped;
|
||||
if (layoutRequested) {
|
||||
@ -1233,7 +1237,12 @@ public final class ViewRootImpl implements ViewParent,
|
||||
// to opposite of the added touch mode.
|
||||
mAttachInfo.mInTouchMode = !mAddedTouchMode;
|
||||
ensureTouchModeLocally(mAddedTouchMode);
|
||||
activeRectChanged = true;
|
||||
} else {
|
||||
if (!mPendingSystemInsets.equals(mAttachInfo.mSystemInsets)) {
|
||||
mAttachInfo.mSystemInsets.set(mPendingSystemInsets);
|
||||
activeRectChanged = true;
|
||||
}
|
||||
if (!mPendingContentInsets.equals(mAttachInfo.mContentInsets)) {
|
||||
insetsChanged = true;
|
||||
}
|
||||
@ -1386,7 +1395,11 @@ public final class ViewRootImpl implements ViewParent,
|
||||
updateConfiguration(mPendingConfiguration, !mFirst);
|
||||
mPendingConfiguration.seq = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!mPendingSystemInsets.equals(mAttachInfo.mSystemInsets)) {
|
||||
activeRectChanged = true;
|
||||
mAttachInfo.mSystemInsets.set(mPendingSystemInsets);
|
||||
}
|
||||
contentInsetsChanged = !mPendingContentInsets.equals(
|
||||
mAttachInfo.mContentInsets);
|
||||
visibleInsetsChanged = !mPendingVisibleInsets.equals(
|
||||
@ -1489,6 +1502,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
// before actually drawing them, so it can display then
|
||||
// all at once.
|
||||
newSurface = true;
|
||||
activeRectChanged = true;
|
||||
mFullRedrawNeeded = true;
|
||||
mPreviousTransparentRegion.setEmpty();
|
||||
|
||||
@ -1553,8 +1567,11 @@ public final class ViewRootImpl implements ViewParent,
|
||||
// !!FIXME!! This next section handles the case where we did not get the
|
||||
// window size we asked for. We should avoid this by getting a maximum size from
|
||||
// the window session beforehand.
|
||||
mWidth = frame.width();
|
||||
mHeight = frame.height();
|
||||
if (mWidth != frame.width() || mHeight != frame.height()) {
|
||||
activeRectChanged = true;
|
||||
mWidth = frame.width();
|
||||
mHeight = frame.height();
|
||||
}
|
||||
|
||||
if (mSurfaceHolder != null) {
|
||||
// The app owns the surface; tell it about what is going on.
|
||||
@ -1670,6 +1687,14 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
}
|
||||
|
||||
if (activeRectChanged && mSurface.isValid()) {
|
||||
mActiveRect.set(attachInfo.mSystemInsets.left, attachInfo.mSystemInsets.top,
|
||||
mWidth - attachInfo.mSystemInsets.right,
|
||||
mHeight - attachInfo.mSystemInsets.bottom);
|
||||
//Log.i(TAG, "Active rect " + mWindowAttributes.getTitle() + ": " + mActiveRect);
|
||||
mSurface.setActiveRect(mActiveRect);
|
||||
}
|
||||
|
||||
final boolean didLayout = layoutRequested && !mStopped;
|
||||
boolean triggerGlobalLayoutListener = didLayout
|
||||
|| attachInfo.mRecomputeGlobalAttributes;
|
||||
@ -2784,7 +2809,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
ResizedInfo ri = (ResizedInfo)msg.obj;
|
||||
|
||||
if (mWinFrame.width() == msg.arg1 && mWinFrame.height() == msg.arg2
|
||||
&& mPendingContentInsets.equals(ri.coveredInsets)
|
||||
&& mPendingSystemInsets.equals(ri.systemInsets)
|
||||
&& mPendingContentInsets.equals(ri.contentInsets)
|
||||
&& mPendingVisibleInsets.equals(ri.visibleInsets)
|
||||
&& ((ResizedInfo)msg.obj).newConfig == null) {
|
||||
break;
|
||||
@ -2800,7 +2826,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mWinFrame.right = msg.arg1;
|
||||
mWinFrame.top = 0;
|
||||
mWinFrame.bottom = msg.arg2;
|
||||
mPendingContentInsets.set(((ResizedInfo)msg.obj).coveredInsets);
|
||||
mPendingSystemInsets.set(((ResizedInfo)msg.obj).systemInsets);
|
||||
mPendingContentInsets.set(((ResizedInfo)msg.obj).contentInsets);
|
||||
mPendingVisibleInsets.set(((ResizedInfo)msg.obj).visibleInsets);
|
||||
if (msg.what == MSG_RESIZED_REPORT) {
|
||||
mReportNextDraw = true;
|
||||
@ -4009,15 +4036,16 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
public void dispatchResized(int w, int h, Rect coveredInsets,
|
||||
public void dispatchResized(int w, int h, Rect systemInsets, Rect contentInsets,
|
||||
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
|
||||
if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": w=" + w
|
||||
+ " h=" + h + " coveredInsets=" + coveredInsets.toShortString()
|
||||
+ " h=" + h + " systemInsets=" + systemInsets.toShortString()
|
||||
+ " contentInsets=" + contentInsets.toShortString()
|
||||
+ " visibleInsets=" + visibleInsets.toShortString()
|
||||
+ " reportDraw=" + reportDraw);
|
||||
Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT :MSG_RESIZED);
|
||||
if (mTranslator != null) {
|
||||
mTranslator.translateRectInScreenToAppWindow(coveredInsets);
|
||||
mTranslator.translateRectInScreenToAppWindow(contentInsets);
|
||||
mTranslator.translateRectInScreenToAppWindow(visibleInsets);
|
||||
w *= mTranslator.applicationInvertedScale;
|
||||
h *= mTranslator.applicationInvertedScale;
|
||||
@ -4025,7 +4053,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
msg.arg1 = w;
|
||||
msg.arg2 = h;
|
||||
ResizedInfo ri = new ResizedInfo();
|
||||
ri.coveredInsets = new Rect(coveredInsets);
|
||||
ri.systemInsets = new Rect(systemInsets);
|
||||
ri.contentInsets = new Rect(contentInsets);
|
||||
ri.visibleInsets = new Rect(visibleInsets);
|
||||
ri.newConfig = newConfig;
|
||||
msg.obj = ri;
|
||||
@ -4676,8 +4705,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
|
||||
final ViewRootImpl viewAncestor = mViewAncestor.get();
|
||||
if (viewAncestor != null) {
|
||||
viewAncestor.dispatchResized(w, h, contentInsets, visibleInsets, reportDraw,
|
||||
newConfig);
|
||||
viewAncestor.dispatchResized(w, h, systemInsets, contentInsets,
|
||||
visibleInsets, reportDraw, newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user