mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Add overviewShowAsGrid to DeviceProfile
- Simplified a lot of dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get() usage Bug: 194194694 Test: manual Change-Id: Idfb0ad192048106bbe6f8e2a28fa5613b86e5208
This commit is contained in:
@@ -28,7 +28,6 @@ import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
@@ -104,7 +103,7 @@ public class OverviewState extends LauncherState {
|
||||
|
||||
@Override
|
||||
public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) {
|
||||
return deviceProfile.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get();
|
||||
return deviceProfile.overviewShowAsGrid;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,6 @@ import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.statemanager.BaseState;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
@@ -207,7 +206,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
public final void calculateTaskSize(Context context, DeviceProfile dp, Rect outRect,
|
||||
PagedOrientationHandler orientedState) {
|
||||
Resources res = context.getResources();
|
||||
if (dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
if (dp.overviewShowAsGrid) {
|
||||
Rect gridRect = new Rect();
|
||||
calculateGridSize(context, dp, gridRect);
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
@@ -196,7 +195,7 @@ public final class TaskViewUtils {
|
||||
int taskIndex = recentsView.indexOfChild(v);
|
||||
Context context = v.getContext();
|
||||
DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
|
||||
boolean showAsGrid = dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get();
|
||||
boolean showAsGrid = dp.overviewShowAsGrid;
|
||||
boolean parallaxCenterAndAdjacentTask =
|
||||
taskIndex != recentsView.getCurrentPage() && !showAsGrid;
|
||||
float gridTranslationSecondary = recentsView.getGridTranslationSecondary(taskIndex);
|
||||
@@ -465,7 +464,7 @@ public final class TaskViewUtils {
|
||||
if (launcherClosing) {
|
||||
Context context = v.getContext();
|
||||
DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
|
||||
launcherAnim = dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()
|
||||
launcherAnim = dp.overviewShowAsGrid
|
||||
? ObjectAnimator.ofFloat(recentsView, RecentsView.CONTENT_ALPHA, 0)
|
||||
: recentsView.createAdjacentPageAnimForTaskLaunch(taskView);
|
||||
launcherAnim.setInterpolator(Interpolators.TOUCH_RESPONSE_INTERPOLATOR);
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.graphics.Color;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.statemanager.BaseState;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.quickstep.RecentsActivity;
|
||||
@@ -134,11 +133,7 @@ public class RecentsState implements BaseState<RecentsState> {
|
||||
* For this state, whether tasks should layout as a grid rather than a list.
|
||||
*/
|
||||
public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) {
|
||||
return hasFlag(FLAG_SHOW_AS_GRID) && showAsGrid(deviceProfile);
|
||||
}
|
||||
|
||||
private boolean showAsGrid(DeviceProfile deviceProfile) {
|
||||
return deviceProfile.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get();
|
||||
return hasFlag(FLAG_SHOW_AS_GRID) && deviceProfile.overviewShowAsGrid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1139,7 +1139,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
* required to focus the task in grid.
|
||||
*/
|
||||
public void moveFocusedTaskToFront() {
|
||||
if (!(mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get())) {
|
||||
if (!mActivity.getDeviceProfile().overviewShowAsGrid) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1430,7 +1430,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (mActionsView != null) {
|
||||
FrameLayout.LayoutParams layoutParams =
|
||||
(FrameLayout.LayoutParams) mActionsView.getLayoutParams();
|
||||
if (dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
if (dp.overviewShowAsGrid) {
|
||||
layoutParams.gravity = Gravity.BOTTOM;
|
||||
layoutParams.bottomMargin =
|
||||
dp.heightPx - mInsets.bottom - mLastComputedGridSize.bottom;
|
||||
@@ -1563,7 +1563,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
@Override
|
||||
protected int getDestinationPage(int scaledScroll) {
|
||||
if (!(mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get())) {
|
||||
if (!mActivity.getDeviceProfile().overviewShowAsGrid) {
|
||||
return super.getDestinationPage(scaledScroll);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
@@ -138,7 +137,7 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
// NOTE: Changing the pivots means the rotated view gets rotated about the new pivots set,
|
||||
// which would render the X and Y position set here incorrect
|
||||
setPivotX(0);
|
||||
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
if (mActivity.getDeviceProfile().overviewShowAsGrid) {
|
||||
// In tablet, set pivotY to original position without mThumbnailTopMargin adjustment.
|
||||
setPivotY(-taskTopMargin);
|
||||
} else {
|
||||
|
||||
@@ -47,7 +47,6 @@ import androidx.core.graphics.ColorUtils;
|
||||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
@@ -449,7 +448,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
// Note: Disable rotation in grid layout.
|
||||
boolean windowingModeSupportsRotation = !dp.isMultiWindowMode
|
||||
&& thumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN
|
||||
&& !(dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get());
|
||||
&& !dp.overviewShowAsGrid;
|
||||
isOrientationDifferent = isOrientationChange(deltaRotate)
|
||||
&& windowingModeSupportsRotation;
|
||||
if (canvasWidth == 0 || canvasHeight == 0 || scale == 0) {
|
||||
|
||||
@@ -77,7 +77,6 @@ import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
@@ -938,7 +937,7 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
if (mActivity.getDeviceProfile().overviewShowAsGrid) {
|
||||
setPivotX(getLayoutDirection() == LAYOUT_DIRECTION_RTL ? 0 : right - left);
|
||||
setPivotY(mSnapshotView.getTop());
|
||||
} else {
|
||||
@@ -955,11 +954,8 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
* How much to scale down pages near the edge of the screen.
|
||||
*/
|
||||
public static float getEdgeScaleDownFactor(DeviceProfile deviceProfile) {
|
||||
if (deviceProfile.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
return EDGE_SCALE_DOWN_FACTOR_GRID;
|
||||
} else {
|
||||
return EDGE_SCALE_DOWN_FACTOR_CAROUSEL;
|
||||
}
|
||||
return deviceProfile.overviewShowAsGrid ? EDGE_SCALE_DOWN_FACTOR_GRID
|
||||
: EDGE_SCALE_DOWN_FACTOR_CAROUSEL;
|
||||
}
|
||||
|
||||
private void setNonGridScale(float nonGridScale) {
|
||||
@@ -1340,7 +1336,7 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
float boxTranslationY;
|
||||
int expectedWidth;
|
||||
int expectedHeight;
|
||||
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
if (mActivity.getDeviceProfile().overviewShowAsGrid) {
|
||||
final int thumbnailPadding =
|
||||
mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
|
||||
final Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize();
|
||||
|
||||
@@ -179,6 +179,7 @@ public class DeviceProfile {
|
||||
public float allAppsIconTextSizePx;
|
||||
|
||||
// Overview
|
||||
public final boolean overviewShowAsGrid;
|
||||
public int overviewTaskMarginPx;
|
||||
public int overviewTaskIconSizePx;
|
||||
public int overviewTaskThumbnailTopMarginPx;
|
||||
@@ -348,11 +349,11 @@ public class DeviceProfile {
|
||||
? res.getDimensionPixelSize(R.dimen.scalable_grid_qsb_bottom_margin)
|
||||
: 0;
|
||||
|
||||
overviewShowAsGrid = isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get();
|
||||
overviewTaskMarginPx = res.getDimensionPixelSize(R.dimen.overview_task_margin);
|
||||
overviewTaskIconSizePx =
|
||||
isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get() ? res.getDimensionPixelSize(
|
||||
R.dimen.task_thumbnail_icon_size_grid) : res.getDimensionPixelSize(
|
||||
R.dimen.task_thumbnail_icon_size);
|
||||
overviewTaskIconSizePx = overviewShowAsGrid
|
||||
? res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_size_grid)
|
||||
: res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_size);
|
||||
overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx * 2;
|
||||
overviewActionsMarginGesturePx = res.getDimensionPixelSize(
|
||||
R.dimen.overview_actions_bottom_margin_gesture);
|
||||
|
||||
Reference in New Issue
Block a user