Implement non-disappearing View for split staging instructions
The instructions for how to perform a splitscreen operation, previously conveyed through a disappearing Toast, are now conveyed through a custom View object. Fixes: 219987907 Test: Manual Change-Id: Iff2bb6e334e0325e8a091d76a5f9b8767071365f
This commit is contained in:
@@ -27,6 +27,7 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
|
||||
import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.THREE_BUTTONS;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
|
||||
|
||||
@@ -47,7 +48,9 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
|
||||
@@ -484,6 +487,58 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitInstructionsParams(View out, DeviceProfile dp, int splitInstructionsHeight,
|
||||
int splitInstructionsWidth, int threeButtonNavShift) {
|
||||
out.setPivotX(0);
|
||||
out.setPivotY(0);
|
||||
out.setRotation(getDegreesRotated());
|
||||
int distanceToEdge;
|
||||
if ((DisplayController.getNavigationMode(out.getContext()) == THREE_BUTTONS)
|
||||
&& (dp.isTwoPanels || dp.isTablet)) {
|
||||
// If 3-button nav is active, align the splitInstructionsView with it.
|
||||
distanceToEdge = dp.getTaskbarOffsetY()
|
||||
+ ((dp.taskbarSize - splitInstructionsHeight) / 2);
|
||||
} else {
|
||||
// If 3-button nav is not active, set bottom margin according to spec.
|
||||
if (dp.isPhone) {
|
||||
if (dp.isLandscape) {
|
||||
distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_phone_landscape);
|
||||
} else {
|
||||
distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_phone_portrait);
|
||||
}
|
||||
} else if (dp.isTwoPanels) {
|
||||
if (dp.isLandscape) {
|
||||
distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_twopanels_landscape);
|
||||
} else {
|
||||
distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_twopanels_portrait);
|
||||
}
|
||||
} else {
|
||||
if (dp.isLandscape) {
|
||||
distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_tablet_landscape);
|
||||
} else {
|
||||
distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_tablet_portrait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Center the view in case of unbalanced insets on left or right of screen
|
||||
int insetCorrectionX = (dp.getInsets().right - dp.getInsets().left) / 2;
|
||||
// Adjust for any insets on the bottom edge
|
||||
int insetCorrectionY = dp.getInsets().bottom;
|
||||
out.setTranslationX(insetCorrectionX + threeButtonNavShift);
|
||||
out.setTranslationY(-distanceToEdge + insetCorrectionY);
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) out.getLayoutParams();
|
||||
lp.gravity = CENTER_HORIZONTAL | BOTTOM;
|
||||
out.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFinalSplitPlaceholderBounds(int splitDividerSize, DeviceProfile dp,
|
||||
@StagePosition int stagePosition, Rect out1, Rect out2) {
|
||||
|
||||
Reference in New Issue
Block a user