diff options
| author | Matthew Ng <ngmatthew@google.com> | 2016-12-20 15:36:29 -0800 |
|---|---|---|
| committer | Matthew Ng <ngmatthew@google.com> | 2017-01-26 10:31:50 -0800 |
| commit | e15352e516fb6ecde12866f0eb27c32470ddbded (patch) | |
| tree | a37616181d01b8c9da88e6923f07327fd306d735 /core/java | |
| parent | 04b926a68b85d9b93f7de2647f9f4770532b2e0f (diff) | |
Splitscreen for minimized state that works with resizable launchers
If a launcher is resizable, going to minimized mode (dock task and then
press home) would show a cropped height of the task at the top in a
minimized state and the fullscreen stack would show the home launcher
which takes the rest of the remaining height. If the launcher is not
resizable, it will default the original behavior.
To enable this in a launcher, add android:resizeableActivity="true" in
the AndroidManifest.xml in the <application/> tag.
Test: manual - rotating while minimized, minimizing using dragging task
or holding overview nav button, installing resizable launcher with a
non-resizable launcher
Fixes: 32504542
Change-Id: Idf4015b40f9bec81b70f146f0f2d7df8ccfb4cf0
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/IDockedStackListener.aidl | 5 | ||||
| -rw-r--r-- | core/java/com/android/internal/policy/DividerSnapAlgorithm.java | 28 |
2 files changed, 29 insertions, 4 deletions
diff --git a/core/java/android/view/IDockedStackListener.aidl b/core/java/android/view/IDockedStackListener.aidl index 36a81db2880a..4cf7cf3ef1f0 100644 --- a/core/java/android/view/IDockedStackListener.aidl +++ b/core/java/android/view/IDockedStackListener.aidl @@ -40,8 +40,11 @@ oneway interface IDockedStackListener { * * @param minimized Whether the docked stack is currently minimized. * @param animDuration The duration of the animation for changing the minimized state. + * @param isHomeStackResizable If the home stack is resizable, a portion of the docked stack + * will be shown with the divider */ - void onDockedStackMinimizedChanged(boolean minimized, long animDuration); + void onDockedStackMinimizedChanged(boolean minimized, long animDuration, + boolean isHomeStackResizable); /** * Called when window manager decides to adjust the divider for IME. Like the minimized state, diff --git a/core/java/com/android/internal/policy/DividerSnapAlgorithm.java b/core/java/com/android/internal/policy/DividerSnapAlgorithm.java index cf14471f381a..11e71026bf09 100644 --- a/core/java/com/android/internal/policy/DividerSnapAlgorithm.java +++ b/core/java/com/android/internal/policy/DividerSnapAlgorithm.java @@ -53,6 +53,11 @@ public class DividerSnapAlgorithm { */ private static final int SNAP_ONLY_1_1 = 2; + /** + * 1 snap target: minimized height, (1 - minimized height) + */ + private static final int SNAP_MODE_MINIMIZED = 3; + private final float mMinFlingVelocityPxPerSecond; private final float mMinDismissVelocityPxPerSecond; private final int mDisplayWidth; @@ -62,6 +67,7 @@ public class DividerSnapAlgorithm { private final Rect mInsets = new Rect(); private final int mSnapMode; private final int mMinimalSizeResizableTask; + private final int mTaskHeightInMinimizedMode; private final float mFixedRatio; private boolean mIsHorizontalDivision; @@ -93,6 +99,11 @@ public class DividerSnapAlgorithm { public DividerSnapAlgorithm(Resources res, int displayWidth, int displayHeight, int dividerSize, boolean isHorizontalDivision, Rect insets) { + this(res, displayWidth, displayHeight, dividerSize, isHorizontalDivision, insets, false); + } + + public DividerSnapAlgorithm(Resources res, int displayWidth, int displayHeight, int dividerSize, + boolean isHorizontalDivision, Rect insets, boolean isMinimizedMode) { mMinFlingVelocityPxPerSecond = MIN_FLING_VELOCITY_DP_PER_SECOND * res.getDisplayMetrics().density; mMinDismissVelocityPxPerSecond = @@ -102,12 +113,14 @@ public class DividerSnapAlgorithm { mDisplayHeight = displayHeight; mIsHorizontalDivision = isHorizontalDivision; mInsets.set(insets); - mSnapMode = res.getInteger( - com.android.internal.R.integer.config_dockedStackDividerSnapMode); + mSnapMode = isMinimizedMode ? SNAP_MODE_MINIMIZED : + res.getInteger(com.android.internal.R.integer.config_dockedStackDividerSnapMode); mFixedRatio = res.getFraction( com.android.internal.R.fraction.docked_stack_divider_fixed_ratio, 1, 1); mMinimalSizeResizableTask = res.getDimensionPixelSize( com.android.internal.R.dimen.default_minimal_size_resizable_task); + mTaskHeightInMinimizedMode = res.getDimensionPixelSize( + com.android.internal.R.dimen.task_height_of_minimized_mode); calculateTargets(isHorizontalDivision); mFirstSplitTarget = mTargets.get(1); mLastSplitTarget = mTargets.get(mTargets.size() - 2); @@ -246,6 +259,7 @@ public class DividerSnapAlgorithm { int dividerMax = isHorizontalDivision ? mDisplayHeight : mDisplayWidth; + int navBarSize = isHorizontalDivision ? mInsets.bottom : mInsets.right; mTargets.add(new SnapTarget(-mDividerSize, -mDividerSize, SnapTarget.FLAG_DISMISS_START, 0.35f)); switch (mSnapMode) { @@ -258,8 +272,10 @@ public class DividerSnapAlgorithm { case SNAP_ONLY_1_1: addMiddleTarget(isHorizontalDivision); break; + case SNAP_MODE_MINIMIZED: + addMinimizedTarget(isHorizontalDivision); + break; } - int navBarSize = isHorizontalDivision ? mInsets.bottom : mInsets.right; mTargets.add(new SnapTarget(dividerMax - navBarSize, dividerMax, SnapTarget.FLAG_DISMISS_END, 0.35f)); } @@ -315,6 +331,12 @@ public class DividerSnapAlgorithm { mTargets.add(new SnapTarget(position, position, SnapTarget.FLAG_NONE)); } + private void addMinimizedTarget(boolean isHorizontalDivision) { + int position = mTaskHeightInMinimizedMode; + position += isHorizontalDivision ? mInsets.top : mInsets.left; + mTargets.add(new SnapTarget(position, position, SnapTarget.FLAG_NONE)); + } + public SnapTarget getMiddleTarget() { return mMiddleTarget; } |
