Loading quickstep/src/com/android/quickstep/ActivityControlHelper.java +3 −4 Original line number Diff line number Diff line Loading @@ -41,10 +41,9 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.util.ViewOnDrawExecutor; import com.android.quickstep.fallback.FallbackRecentsView; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.views.LauncherLayoutListener; import com.android.quickstep.views.LauncherRecentsView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; Loading Loading @@ -142,7 +141,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { @Override public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { LauncherRecentsView.getPageRect(dp, context, outRect); LayoutUtils.calculateLauncherTaskSize(context, dp, outRect); if (dp.isVerticalBarLayout()) { Rect targetInsets = dp.getInsets(); int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right; Loading Loading @@ -295,7 +294,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { @Override public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { FallbackRecentsView.getPageRect(dp, context, outRect); LayoutUtils.calculateFallbackTaskSize(context, dp, outRect); if (dp.isVerticalBarLayout()) { Rect targetInsets = dp.getInsets(); int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right; Loading quickstep/src/com/android/quickstep/RecentsActivity.java +26 −15 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.app.ActivityOptions; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; Loading @@ -38,6 +37,7 @@ import android.view.View; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherAnimationRunner; Loading Loading @@ -73,12 +73,7 @@ public class RecentsActivity extends BaseDraggingActivity { super.onCreate(savedInstanceState); mOldConfig = new Configuration(getResources().getConfiguration()); // In case we are reusing IDP, create a copy so that we dont conflict with Launcher // activity. LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); setDeviceProfile(appState != null ? appState.getInvariantDeviceProfile().getDeviceProfile(this).copy(this) : new InvariantDeviceProfile(this).getDeviceProfile(this)); initDeviceProfile(); setContentView(R.layout.fallback_recents_activity); mRecentsRootView = findViewById(R.id.drag_layer); Loading Loading @@ -108,15 +103,15 @@ public class RecentsActivity extends BaseDraggingActivity { super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig); } public void onRootViewSizeChanged() { if (isInMultiWindowModeCompat()) { onHandleConfigChanged(); } } private void onHandleConfigChanged() { mUserEventDispatcher = null; // In case we are reusing IDP, create a copy so that we dont conflict with Launcher // activity. LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); setDeviceProfile(appState != null ? appState.getInvariantDeviceProfile().getDeviceProfile(this).copy(this) : new InvariantDeviceProfile(this).getDeviceProfile(this)); initDeviceProfile(); AbstractFloatingView.closeOpenViews(this, true, AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE); Loading @@ -124,7 +119,23 @@ public class RecentsActivity extends BaseDraggingActivity { mRecentsRootView.setup(); mRecentsRootView.dispatchInsets(); mRecentsRootView.requestLayout(); } private void initDeviceProfile() { // In case we are reusing IDP, create a copy so that we dont conflict with Launcher // activity. LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); if (isInMultiWindowModeCompat()) { InvariantDeviceProfile idp = appState == null ? new InvariantDeviceProfile(this) : appState.getInvariantDeviceProfile(); DeviceProfile dp = idp.getDeviceProfile(this); mDeviceProfile = dp.getMultiWindowProfile(this, mRecentsRootView.getLastKnownSize()); } else { // If we are reusing the Invariant device profile, make a copy. mDeviceProfile = appState == null ? new InvariantDeviceProfile(this).getDeviceProfile(this) : appState.getInvariantDeviceProfile().getDeviceProfile(this).copy(this); } } @Override Loading quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +1 −5 Original line number Diff line number Diff line Loading @@ -64,11 +64,7 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity> { @Override protected void getTaskSize(DeviceProfile dp, Rect outRect) { LayoutUtils.calculateTaskSize(getContext(), dp, 0, outRect); LayoutUtils.calculateFallbackTaskSize(getContext(), dp, outRect); } @AnyThread public static void getPageRect(DeviceProfile grid, Context context, Rect outRect) { LayoutUtils.calculateTaskSize(context, grid, 0, outRect); } } quickstep/src/com/android/quickstep/fallback/RecentsRootView.java +20 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.quickstep.fallback; import android.annotation.TargetApi; import android.content.Context; import android.graphics.Point; import android.graphics.Rect; import android.util.AttributeSet; Loading @@ -31,6 +32,8 @@ public class RecentsRootView extends BaseDragLayer<RecentsActivity> { private final RecentsActivity mActivity; private final Point mLastKnownSize = new Point(10, 10); public RecentsRootView(Context context, AttributeSet attrs) { super(context, attrs); mActivity = (RecentsActivity) BaseActivity.fromContext(context); Loading @@ -39,10 +42,27 @@ public class RecentsRootView extends BaseDragLayer<RecentsActivity> { | SYSTEM_UI_FLAG_LAYOUT_STABLE); } public Point getLastKnownSize() { return mLastKnownSize; } public void setup() { mControllers = new TouchController[] { new RecentsTaskController(mActivity) }; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Check size changes before the actual measure, to avoid multiple measure calls. int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); if (mLastKnownSize.x != width || mLastKnownSize.y != height) { mLastKnownSize.set(width, height); mActivity.onRootViewSizeChanged(); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } @TargetApi(23) @Override protected boolean fitSystemWindows(Rect insets) { Loading quickstep/src/com/android/quickstep/util/LayoutUtils.java +37 −13 Original line number Diff line number Diff line Loading @@ -15,40 +15,64 @@ */ package com.android.quickstep.util; import static java.lang.annotation.RetentionPolicy.SOURCE; import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; import android.graphics.RectF; import android.support.annotation.AnyThread; import android.support.annotation.IntDef; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import java.lang.annotation.Retention; public class LayoutUtils { private static final int MULTI_WINDOW_STRATEGY_HALF_SCREEN = 1; private static final int MULTI_WINDOW_STRATEGY_DEVICE_PROFILE = 2; @Retention(SOURCE) @IntDef({MULTI_WINDOW_STRATEGY_HALF_SCREEN, MULTI_WINDOW_STRATEGY_DEVICE_PROFILE}) private @interface MultiWindowStrategy {} public static void calculateLauncherTaskSize(Context context, DeviceProfile dp, Rect outRect) { float extraSpace = dp.isVerticalBarLayout() ? 0 : dp.hotseatBarSizePx; calculateTaskSize(context, dp, extraSpace, outRect); calculateTaskSize(context, dp, extraSpace, MULTI_WINDOW_STRATEGY_HALF_SCREEN, outRect); } public static void calculateFallbackTaskSize(Context context, DeviceProfile dp, Rect outRect) { calculateTaskSize(context, dp, 0, MULTI_WINDOW_STRATEGY_DEVICE_PROFILE, outRect); } @AnyThread public static void calculateTaskSize(Context context, DeviceProfile dp, float extraVerticalSpace, Rect outRect) { float extraVerticalSpace, @MultiWindowStrategy int multiWindowStrategy, Rect outRect) { float taskWidth, taskHeight, paddingHorz; Resources res = context.getResources(); Rect insets = dp.getInsets(); if (dp.isMultiWindowMode) { if (multiWindowStrategy == MULTI_WINDOW_STRATEGY_HALF_SCREEN) { DeviceProfile fullDp = dp.getFullScreenProfile(); // Use availableWidthPx and availableHeightPx instead of widthPx and heightPx to // account for system insets taskWidth = fullDp.availableWidthPx; taskHeight = fullDp.availableHeightPx; float halfDividerSize = res.getDimension(R.dimen.multi_window_task_divider_size) / 2; float halfDividerSize = res.getDimension(R.dimen.multi_window_task_divider_size) / 2; if (fullDp.isLandscape) { taskWidth = taskWidth / 2 - halfDividerSize; } else { taskHeight = taskHeight / 2 - halfDividerSize; } } else { // multiWindowStrategy == MULTI_WINDOW_STRATEGY_DEVICE_PROFILE taskWidth = dp.widthPx; taskHeight = dp.heightPx; } paddingHorz = res.getDimension(R.dimen.multi_window_task_card_horz_space); } else { taskWidth = dp.availableWidthPx; Loading Loading
quickstep/src/com/android/quickstep/ActivityControlHelper.java +3 −4 Original line number Diff line number Diff line Loading @@ -41,10 +41,9 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.util.ViewOnDrawExecutor; import com.android.quickstep.fallback.FallbackRecentsView; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.views.LauncherLayoutListener; import com.android.quickstep.views.LauncherRecentsView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; Loading Loading @@ -142,7 +141,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { @Override public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { LauncherRecentsView.getPageRect(dp, context, outRect); LayoutUtils.calculateLauncherTaskSize(context, dp, outRect); if (dp.isVerticalBarLayout()) { Rect targetInsets = dp.getInsets(); int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right; Loading Loading @@ -295,7 +294,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { @Override public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { FallbackRecentsView.getPageRect(dp, context, outRect); LayoutUtils.calculateFallbackTaskSize(context, dp, outRect); if (dp.isVerticalBarLayout()) { Rect targetInsets = dp.getInsets(); int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right; Loading
quickstep/src/com/android/quickstep/RecentsActivity.java +26 −15 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.app.ActivityOptions; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; Loading @@ -38,6 +37,7 @@ import android.view.View; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherAnimationRunner; Loading Loading @@ -73,12 +73,7 @@ public class RecentsActivity extends BaseDraggingActivity { super.onCreate(savedInstanceState); mOldConfig = new Configuration(getResources().getConfiguration()); // In case we are reusing IDP, create a copy so that we dont conflict with Launcher // activity. LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); setDeviceProfile(appState != null ? appState.getInvariantDeviceProfile().getDeviceProfile(this).copy(this) : new InvariantDeviceProfile(this).getDeviceProfile(this)); initDeviceProfile(); setContentView(R.layout.fallback_recents_activity); mRecentsRootView = findViewById(R.id.drag_layer); Loading Loading @@ -108,15 +103,15 @@ public class RecentsActivity extends BaseDraggingActivity { super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig); } public void onRootViewSizeChanged() { if (isInMultiWindowModeCompat()) { onHandleConfigChanged(); } } private void onHandleConfigChanged() { mUserEventDispatcher = null; // In case we are reusing IDP, create a copy so that we dont conflict with Launcher // activity. LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); setDeviceProfile(appState != null ? appState.getInvariantDeviceProfile().getDeviceProfile(this).copy(this) : new InvariantDeviceProfile(this).getDeviceProfile(this)); initDeviceProfile(); AbstractFloatingView.closeOpenViews(this, true, AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE); Loading @@ -124,7 +119,23 @@ public class RecentsActivity extends BaseDraggingActivity { mRecentsRootView.setup(); mRecentsRootView.dispatchInsets(); mRecentsRootView.requestLayout(); } private void initDeviceProfile() { // In case we are reusing IDP, create a copy so that we dont conflict with Launcher // activity. LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); if (isInMultiWindowModeCompat()) { InvariantDeviceProfile idp = appState == null ? new InvariantDeviceProfile(this) : appState.getInvariantDeviceProfile(); DeviceProfile dp = idp.getDeviceProfile(this); mDeviceProfile = dp.getMultiWindowProfile(this, mRecentsRootView.getLastKnownSize()); } else { // If we are reusing the Invariant device profile, make a copy. mDeviceProfile = appState == null ? new InvariantDeviceProfile(this).getDeviceProfile(this) : appState.getInvariantDeviceProfile().getDeviceProfile(this).copy(this); } } @Override Loading
quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +1 −5 Original line number Diff line number Diff line Loading @@ -64,11 +64,7 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity> { @Override protected void getTaskSize(DeviceProfile dp, Rect outRect) { LayoutUtils.calculateTaskSize(getContext(), dp, 0, outRect); LayoutUtils.calculateFallbackTaskSize(getContext(), dp, outRect); } @AnyThread public static void getPageRect(DeviceProfile grid, Context context, Rect outRect) { LayoutUtils.calculateTaskSize(context, grid, 0, outRect); } }
quickstep/src/com/android/quickstep/fallback/RecentsRootView.java +20 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.quickstep.fallback; import android.annotation.TargetApi; import android.content.Context; import android.graphics.Point; import android.graphics.Rect; import android.util.AttributeSet; Loading @@ -31,6 +32,8 @@ public class RecentsRootView extends BaseDragLayer<RecentsActivity> { private final RecentsActivity mActivity; private final Point mLastKnownSize = new Point(10, 10); public RecentsRootView(Context context, AttributeSet attrs) { super(context, attrs); mActivity = (RecentsActivity) BaseActivity.fromContext(context); Loading @@ -39,10 +42,27 @@ public class RecentsRootView extends BaseDragLayer<RecentsActivity> { | SYSTEM_UI_FLAG_LAYOUT_STABLE); } public Point getLastKnownSize() { return mLastKnownSize; } public void setup() { mControllers = new TouchController[] { new RecentsTaskController(mActivity) }; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Check size changes before the actual measure, to avoid multiple measure calls. int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); if (mLastKnownSize.x != width || mLastKnownSize.y != height) { mLastKnownSize.set(width, height); mActivity.onRootViewSizeChanged(); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } @TargetApi(23) @Override protected boolean fitSystemWindows(Rect insets) { Loading
quickstep/src/com/android/quickstep/util/LayoutUtils.java +37 −13 Original line number Diff line number Diff line Loading @@ -15,40 +15,64 @@ */ package com.android.quickstep.util; import static java.lang.annotation.RetentionPolicy.SOURCE; import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; import android.graphics.RectF; import android.support.annotation.AnyThread; import android.support.annotation.IntDef; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import java.lang.annotation.Retention; public class LayoutUtils { private static final int MULTI_WINDOW_STRATEGY_HALF_SCREEN = 1; private static final int MULTI_WINDOW_STRATEGY_DEVICE_PROFILE = 2; @Retention(SOURCE) @IntDef({MULTI_WINDOW_STRATEGY_HALF_SCREEN, MULTI_WINDOW_STRATEGY_DEVICE_PROFILE}) private @interface MultiWindowStrategy {} public static void calculateLauncherTaskSize(Context context, DeviceProfile dp, Rect outRect) { float extraSpace = dp.isVerticalBarLayout() ? 0 : dp.hotseatBarSizePx; calculateTaskSize(context, dp, extraSpace, outRect); calculateTaskSize(context, dp, extraSpace, MULTI_WINDOW_STRATEGY_HALF_SCREEN, outRect); } public static void calculateFallbackTaskSize(Context context, DeviceProfile dp, Rect outRect) { calculateTaskSize(context, dp, 0, MULTI_WINDOW_STRATEGY_DEVICE_PROFILE, outRect); } @AnyThread public static void calculateTaskSize(Context context, DeviceProfile dp, float extraVerticalSpace, Rect outRect) { float extraVerticalSpace, @MultiWindowStrategy int multiWindowStrategy, Rect outRect) { float taskWidth, taskHeight, paddingHorz; Resources res = context.getResources(); Rect insets = dp.getInsets(); if (dp.isMultiWindowMode) { if (multiWindowStrategy == MULTI_WINDOW_STRATEGY_HALF_SCREEN) { DeviceProfile fullDp = dp.getFullScreenProfile(); // Use availableWidthPx and availableHeightPx instead of widthPx and heightPx to // account for system insets taskWidth = fullDp.availableWidthPx; taskHeight = fullDp.availableHeightPx; float halfDividerSize = res.getDimension(R.dimen.multi_window_task_divider_size) / 2; float halfDividerSize = res.getDimension(R.dimen.multi_window_task_divider_size) / 2; if (fullDp.isLandscape) { taskWidth = taskWidth / 2 - halfDividerSize; } else { taskHeight = taskHeight / 2 - halfDividerSize; } } else { // multiWindowStrategy == MULTI_WINDOW_STRATEGY_DEVICE_PROFILE taskWidth = dp.widthPx; taskHeight = dp.heightPx; } paddingHorz = res.getDimension(R.dimen.multi_window_task_card_horz_space); } else { taskWidth = dp.availableWidthPx; Loading