Merge "Report caption insets change when layout" into rvc-dev am: 9f804f7593
Change-Id: Ia8b4747c9ef657f7b8afb367807526ec7bd08024
This commit is contained in:
@@ -116,15 +116,15 @@ public class InsetsSource implements Parcelable {
|
|||||||
if (!ignoreVisibility && !mVisible) {
|
if (!ignoreVisibility && !mVisible) {
|
||||||
return Insets.NONE;
|
return Insets.NONE;
|
||||||
}
|
}
|
||||||
if (!getIntersection(frame, relativeFrame, mTmpFrame)) {
|
|
||||||
return Insets.NONE;
|
|
||||||
}
|
|
||||||
// During drag-move and drag-resizing, the caption insets position may not get updated
|
// During drag-move and drag-resizing, the caption insets position may not get updated
|
||||||
// before the app frame get updated. To layout the app content correctly during drag events,
|
// before the app frame get updated. To layout the app content correctly during drag events,
|
||||||
// we always return the insets with the corresponding height covering the top.
|
// we always return the insets with the corresponding height covering the top.
|
||||||
if (getType() == ITYPE_CAPTION_BAR) {
|
if (getType() == ITYPE_CAPTION_BAR) {
|
||||||
return Insets.of(0, frame.height(), 0, 0);
|
return Insets.of(0, frame.height(), 0, 0);
|
||||||
}
|
}
|
||||||
|
if (!getIntersection(frame, relativeFrame, mTmpFrame)) {
|
||||||
|
return Insets.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Currently, non-floating IME always intersects at bottom due to issues with cutout.
|
// TODO: Currently, non-floating IME always intersects at bottom due to issues with cutout.
|
||||||
// However, we should let the policy decide from the server.
|
// However, we should let the policy decide from the server.
|
||||||
|
|||||||
@@ -2019,10 +2019,17 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
if (getForeground() != null) {
|
if (getForeground() != null) {
|
||||||
drawableChanged();
|
drawableChanged();
|
||||||
}
|
}
|
||||||
getWindowInsetsController().setCaptionInsetsHeight(getCaptionInsetsHeight());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface to be called when the caption visibility or height changed, to report the
|
||||||
|
* corresponding insets change to the InsetsController.
|
||||||
|
*/
|
||||||
|
public void notifyCaptionHeightChanged() {
|
||||||
|
getWindowInsetsController().setCaptionInsetsHeight(getCaptionInsetsHeight());
|
||||||
|
}
|
||||||
|
|
||||||
void setWindow(PhoneWindow phoneWindow) {
|
void setWindow(PhoneWindow phoneWindow) {
|
||||||
mWindow = phoneWindow;
|
mWindow = phoneWindow;
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
@@ -2093,7 +2100,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
mDecorCaptionView.onConfigurationChanged(displayWindowDecor);
|
mDecorCaptionView.onConfigurationChanged(displayWindowDecor);
|
||||||
enableCaption(displayWindowDecor);
|
enableCaption(displayWindowDecor);
|
||||||
}
|
}
|
||||||
getWindowInsetsController().setCaptionInsetsHeight(getCaptionInsetsHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResourcesLoaded(LayoutInflater inflater, int layoutResource) {
|
void onResourcesLoaded(LayoutInflater inflater, int layoutResource) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.view.ViewOutlineProvider;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
|
import com.android.internal.policy.DecorView;
|
||||||
import com.android.internal.policy.PhoneWindow;
|
import com.android.internal.policy.PhoneWindow;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -305,6 +306,8 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((DecorView) mOwner.getDecorView()).notifyCaptionHeightChanged();
|
||||||
|
|
||||||
// This assumes that the caption bar is at the top.
|
// This assumes that the caption bar is at the top.
|
||||||
mOwner.notifyRestrictedCaptionAreaCallback(mMaximize.getLeft(), mMaximize.getTop(),
|
mOwner.notifyRestrictedCaptionAreaCallback(mMaximize.getLeft(), mMaximize.getTop(),
|
||||||
mClose.getRight(), mClose.getBottom());
|
mClose.getRight(), mClose.getBottom());
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
|
import static android.view.InsetsState.ITYPE_CAPTION_BAR;
|
||||||
import static android.view.InsetsState.ITYPE_IME;
|
import static android.view.InsetsState.ITYPE_IME;
|
||||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||||
|
|
||||||
@@ -46,11 +47,13 @@ public class InsetsSourceTest {
|
|||||||
|
|
||||||
private InsetsSource mSource = new InsetsSource(ITYPE_NAVIGATION_BAR);
|
private InsetsSource mSource = new InsetsSource(ITYPE_NAVIGATION_BAR);
|
||||||
private InsetsSource mImeSource = new InsetsSource(ITYPE_IME);
|
private InsetsSource mImeSource = new InsetsSource(ITYPE_IME);
|
||||||
|
private InsetsSource mCaptionSource = new InsetsSource(ITYPE_CAPTION_BAR);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mSource.setVisible(true);
|
mSource.setVisible(true);
|
||||||
mImeSource.setVisible(true);
|
mImeSource.setVisible(true);
|
||||||
|
mCaptionSource.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -101,6 +104,17 @@ public class InsetsSourceTest {
|
|||||||
assertEquals(Insets.of(0, 0, 0, 100), insets);
|
assertEquals(Insets.of(0, 0, 0, 100), insets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateInsets_caption_resizing() {
|
||||||
|
mCaptionSource.setFrame(new Rect(0, 0, 100, 100));
|
||||||
|
Insets insets = mCaptionSource.calculateInsets(new Rect(0, 0, 200, 200), false);
|
||||||
|
assertEquals(Insets.of(0, 100, 0, 0), insets);
|
||||||
|
insets = mCaptionSource.calculateInsets(new Rect(0, 0, 50, 200), false);
|
||||||
|
assertEquals(Insets.of(0, 100, 0, 0), insets);
|
||||||
|
insets = mCaptionSource.calculateInsets(new Rect(100, 100, 200, 500), false);
|
||||||
|
assertEquals(Insets.of(0, 100, 0, 0), insets);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCalculateInsets_invisible() {
|
public void testCalculateInsets_invisible() {
|
||||||
mSource.setFrame(new Rect(0, 0, 500, 100));
|
mSource.setFrame(new Rect(0, 0, 500, 100));
|
||||||
|
|||||||
Reference in New Issue
Block a user