Merge "Update initial staged split UX." into tm-dev
This commit is contained in:
@@ -436,29 +436,48 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInitialSplitPlaceholderBounds(int placeholderHeight, DeviceProfile dp,
|
||||
@StagePosition int stagePosition, Rect out) {
|
||||
int width = dp.widthPx;
|
||||
out.set(0, 0, width, placeholderHeight);
|
||||
public void getInitialSplitPlaceholderBounds(int placeholderHeight, int placeholderInset,
|
||||
DeviceProfile dp, @StagePosition int stagePosition, Rect out) {
|
||||
int screenWidth = dp.widthPx;
|
||||
int screenHeight = dp.heightPx;
|
||||
out.set(0, 0, screenWidth, placeholderHeight);
|
||||
if (!dp.isLandscape) {
|
||||
// portrait, phone or tablet - spans width of screen, nothing else to do
|
||||
out.inset(placeholderInset, 0);
|
||||
|
||||
// Adjust the top to account for content off screen. This will help to animate the view
|
||||
// in with rounded corners.
|
||||
int totalHeight = (int) (1.0f * screenHeight / 2 * (screenWidth - 2 * placeholderInset)
|
||||
/ screenWidth);
|
||||
out.top -= (totalHeight - placeholderHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now we rotate the portrait rect depending on what side we want pinned
|
||||
boolean pinToRight = stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
|
||||
int screenHeight = dp.heightPx;
|
||||
float postRotateScale = (float) screenHeight / width;
|
||||
float postRotateScale = (float) screenHeight / screenWidth;
|
||||
mTmpMatrix.reset();
|
||||
mTmpMatrix.postRotate(pinToRight ? 90 : 270);
|
||||
mTmpMatrix.postTranslate(pinToRight ? width : 0, pinToRight ? 0 : width);
|
||||
mTmpMatrix.postTranslate(pinToRight ? screenWidth : 0, pinToRight ? 0 : screenWidth);
|
||||
// The placeholder height stays constant after rotation, so we don't change width scale
|
||||
mTmpMatrix.postScale(1, postRotateScale);
|
||||
|
||||
mTmpRectF.set(out);
|
||||
mTmpMatrix.mapRect(mTmpRectF);
|
||||
mTmpRectF.inset(0, placeholderInset);
|
||||
mTmpRectF.roundOut(out);
|
||||
|
||||
// Adjust the top to account for content off screen. This will help to animate the view in
|
||||
// with rounded corners.
|
||||
int totalWidth = (int) (1.0f * screenWidth / 2 * (screenHeight - 2 * placeholderInset)
|
||||
/ screenHeight);
|
||||
int width = out.width();
|
||||
if (pinToRight) {
|
||||
out.right += totalWidth - width;
|
||||
} else {
|
||||
out.left -= totalWidth - width;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user