Merge "Removing support for fake landscape" into ub-launcher3-master
This commit is contained in:
committed by
Android (Google) Code Review
commit
34a9d75238
-81
@@ -19,12 +19,9 @@ import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -38,7 +35,6 @@ import com.android.launcher3.WorkspaceItemInfo;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.FlingAndHoldTouchController;
|
||||
@@ -71,77 +67,6 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
*/
|
||||
public static final AsyncCommand SET_SHELF_HEIGHT = (context, arg1, arg2) ->
|
||||
SystemUiProxy.INSTANCE.get(context).setShelfHeight(arg1 != 0, arg2);
|
||||
public static final RotationMode ROTATION_LANDSCAPE = new RotationMode(-90) {
|
||||
@Override
|
||||
public void mapRect(int left, int top, int right, int bottom, Rect out) {
|
||||
out.left = top;
|
||||
out.top = right;
|
||||
out.right = bottom;
|
||||
out.bottom = left;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapInsets(Context context, Rect insets, Rect out) {
|
||||
// If there is a display cutout, the top insets in portrait would also include the
|
||||
// cutout, which we will get as the left inset in landscape. Using the max of left and
|
||||
// top allows us to cover both cases (with or without cutout).
|
||||
if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
|
||||
out.top = Math.max(insets.top, insets.left);
|
||||
out.bottom = Math.max(insets.right, insets.bottom);
|
||||
out.left = out.right = 0;
|
||||
} else {
|
||||
out.top = Math.max(insets.top, insets.left);
|
||||
out.bottom = insets.right;
|
||||
out.left = insets.bottom;
|
||||
out.right = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final RotationMode ROTATION_SEASCAPE = new RotationMode(90) {
|
||||
@Override
|
||||
public void mapRect(int left, int top, int right, int bottom, Rect out) {
|
||||
out.left = bottom;
|
||||
out.top = left;
|
||||
out.right = top;
|
||||
out.bottom = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapInsets(Context context, Rect insets, Rect out) {
|
||||
if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
|
||||
out.top = Math.max(insets.top, insets.right);
|
||||
out.bottom = Math.max(insets.left, insets.bottom);
|
||||
out.left = out.right = 0;
|
||||
} else {
|
||||
out.top = Math.max(insets.top, insets.right);
|
||||
out.bottom = insets.left;
|
||||
out.right = insets.bottom;
|
||||
out.left = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toNaturalGravity(int absoluteGravity) {
|
||||
int horizontalGravity = absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||
int verticalGravity = absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||
|
||||
if (horizontalGravity == Gravity.RIGHT) {
|
||||
horizontalGravity = Gravity.LEFT;
|
||||
} else if (horizontalGravity == Gravity.LEFT) {
|
||||
horizontalGravity = Gravity.RIGHT;
|
||||
}
|
||||
|
||||
if (verticalGravity == Gravity.TOP) {
|
||||
verticalGravity = Gravity.BOTTOM;
|
||||
} else if (verticalGravity == Gravity.BOTTOM) {
|
||||
verticalGravity = Gravity.TOP;
|
||||
}
|
||||
|
||||
return ((absoluteGravity & ~Gravity.HORIZONTAL_GRAVITY_MASK)
|
||||
& ~Gravity.VERTICAL_GRAVITY_MASK)
|
||||
| horizontalGravity | verticalGravity;
|
||||
}
|
||||
};
|
||||
private HotseatPredictionController mHotseatPredictionController;
|
||||
|
||||
@Override
|
||||
@@ -152,12 +77,6 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RotationMode getFakeRotationMode(DeviceProfile dp) {
|
||||
return !dp.isVerticalBarLayout() ? RotationMode.NORMAL
|
||||
: (dp.isSeascape() ? ROTATION_SEASCAPE : ROTATION_LANDSCAPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
@@ -46,7 +46,6 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.model.PagedViewOrientedState;
|
||||
import com.android.launcher3.states.RotationHelper;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
@@ -149,8 +148,8 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
|
||||
VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC);
|
||||
}
|
||||
|
||||
public Consumer<MotionEvent> getRecentsViewDispatcher(RotationMode navBarRotationMode) {
|
||||
return mRecentsView != null ? mRecentsView.getEventDispatcher(navBarRotationMode) : null;
|
||||
public Consumer<MotionEvent> getRecentsViewDispatcher(float navbarRotation) {
|
||||
return mRecentsView != null ? mRecentsView.getEventDispatcher(navbarRotation) : null;
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
if (mPassedWindowMoveSlop && mInteractionHandler != null
|
||||
&& !mRecentsViewDispatcher.hasConsumer()) {
|
||||
mRecentsViewDispatcher.setConsumer(mInteractionHandler
|
||||
.getRecentsViewDispatcher(mNavBarPosition.getRotationMode()));
|
||||
.getRecentsViewDispatcher(mNavBarPosition.getRotation()));
|
||||
}
|
||||
int edgeFlags = ev.getEdgeFlags();
|
||||
ev.setEdgeFlags(edgeFlags | EDGE_NAV_BAR);
|
||||
|
||||
@@ -99,7 +99,6 @@ import com.android.launcher3.anim.PropertyListBuilder;
|
||||
import com.android.launcher3.anim.SpringProperty;
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.states.RotationHelper;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
@@ -1984,13 +1983,13 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||
return offsetX;
|
||||
}
|
||||
|
||||
public Consumer<MotionEvent> getEventDispatcher(RotationMode navBarRotationMode) {
|
||||
public Consumer<MotionEvent> getEventDispatcher(float navbarRotation) {
|
||||
float degreesRotated;
|
||||
if (navBarRotationMode == RotationMode.NORMAL) {
|
||||
if (navbarRotation == 0) {
|
||||
degreesRotated = mOrientationState.areMultipleLayoutOrientationsDisabled() ? 0 :
|
||||
RotationHelper.getDegreesFromRotation(mLayoutRotation);
|
||||
} else {
|
||||
degreesRotated = -navBarRotationMode.surfaceRotation;
|
||||
degreesRotated = -navbarRotation;
|
||||
}
|
||||
if (degreesRotated == 0) {
|
||||
return super::onTouchEvent;
|
||||
@@ -2000,7 +1999,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||
// undo that transformation since PagedView also accommodates for the transformation via
|
||||
// PagedOrientationHandler
|
||||
return e -> {
|
||||
if (navBarRotationMode != RotationMode.NORMAL
|
||||
if (navbarRotation != 0
|
||||
&& !mOrientationState.areMultipleLayoutOrientationsDisabled()) {
|
||||
RotationHelper.transformEventForNavBar(e, true);
|
||||
super.onTouchEvent(e);
|
||||
|
||||
@@ -88,9 +88,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
super.onCreate(savedInstanceState);
|
||||
mSystemActions = new SystemActions(this);
|
||||
|
||||
SysUINavigationMode.Mode mode = SysUINavigationMode.INSTANCE.get(this)
|
||||
.addModeChangeListener(this);
|
||||
getRotationHelper().setRotationHadDifferentUI(mode != Mode.NO_BUTTON);
|
||||
SysUINavigationMode.INSTANCE.get(this).addModeChangeListener(this);
|
||||
|
||||
if (!getSharedPrefs().getBoolean(HOME_BOUNCE_SEEN, false)) {
|
||||
getStateManager().addStateListener(new LauncherStateManager.StateListener() {
|
||||
@@ -141,7 +139,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
@Override
|
||||
public void onNavigationModeChanged(Mode newMode) {
|
||||
getDragLayer().recreateControllers();
|
||||
getRotationHelper().setRotationHadDifferentUI(newMode != Mode.NO_BUTTON);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,12 +17,8 @@ package com.android.quickstep.util;
|
||||
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.view.Gravity;
|
||||
import android.view.Surface;
|
||||
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
|
||||
@@ -31,79 +27,6 @@ import com.android.quickstep.SysUINavigationMode;
|
||||
*/
|
||||
public class NavBarPosition {
|
||||
|
||||
public static final RotationMode ROTATION_LANDSCAPE = new RotationMode(-90) {
|
||||
@Override
|
||||
public void mapRect(int left, int top, int right, int bottom, Rect out) {
|
||||
out.left = top;
|
||||
out.top = right;
|
||||
out.right = bottom;
|
||||
out.bottom = left;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapInsets(Context context, Rect insets, Rect out) {
|
||||
// If there is a display cutout, the top insets in portrait would also include the
|
||||
// cutout, which we will get as the left inset in landscape. Using the max of left and
|
||||
// top allows us to cover both cases (with or without cutout).
|
||||
if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
|
||||
out.top = Math.max(insets.top, insets.left);
|
||||
out.bottom = Math.max(insets.right, insets.bottom);
|
||||
out.left = out.right = 0;
|
||||
} else {
|
||||
out.top = Math.max(insets.top, insets.left);
|
||||
out.bottom = insets.right;
|
||||
out.left = insets.bottom;
|
||||
out.right = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final RotationMode ROTATION_SEASCAPE = new RotationMode(90) {
|
||||
@Override
|
||||
public void mapRect(int left, int top, int right, int bottom, Rect out) {
|
||||
out.left = bottom;
|
||||
out.top = left;
|
||||
out.right = top;
|
||||
out.bottom = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapInsets(Context context, Rect insets, Rect out) {
|
||||
if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
|
||||
out.top = Math.max(insets.top, insets.right);
|
||||
out.bottom = Math.max(insets.left, insets.bottom);
|
||||
out.left = out.right = 0;
|
||||
} else {
|
||||
out.top = Math.max(insets.top, insets.right);
|
||||
out.bottom = insets.left;
|
||||
out.right = insets.bottom;
|
||||
out.left = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toNaturalGravity(int absoluteGravity) {
|
||||
int horizontalGravity = absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||
int verticalGravity = absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||
|
||||
if (horizontalGravity == Gravity.RIGHT) {
|
||||
horizontalGravity = Gravity.LEFT;
|
||||
} else if (horizontalGravity == Gravity.LEFT) {
|
||||
horizontalGravity = Gravity.RIGHT;
|
||||
}
|
||||
|
||||
if (verticalGravity == Gravity.TOP) {
|
||||
verticalGravity = Gravity.BOTTOM;
|
||||
} else if (verticalGravity == Gravity.BOTTOM) {
|
||||
verticalGravity = Gravity.TOP;
|
||||
}
|
||||
|
||||
return ((absoluteGravity & ~Gravity.HORIZONTAL_GRAVITY_MASK)
|
||||
& ~Gravity.VERTICAL_GRAVITY_MASK)
|
||||
| horizontalGravity | verticalGravity;
|
||||
}
|
||||
};
|
||||
|
||||
private final SysUINavigationMode.Mode mMode;
|
||||
private final int mDisplayRotation;
|
||||
|
||||
@@ -120,8 +43,7 @@ public class NavBarPosition {
|
||||
return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_270;
|
||||
}
|
||||
|
||||
public RotationMode getRotationMode() {
|
||||
return isLeftEdge() ? ROTATION_SEASCAPE
|
||||
: (isRightEdge() ? ROTATION_LANDSCAPE : RotationMode.NORMAL);
|
||||
public float getRotation() {
|
||||
return isLeftEdge() ? 90 : (isRightEdge() ? -90 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,27 +151,25 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.BubbleTextView, defStyle, 0);
|
||||
mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, false);
|
||||
DeviceProfile grid = mActivity.getDeviceProfile();
|
||||
|
||||
mDisplay = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE);
|
||||
final int defaultIconSize;
|
||||
if (mDisplay == DISPLAY_WORKSPACE) {
|
||||
DeviceProfile grid = mActivity.getWallpaperDeviceProfile();
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
|
||||
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
|
||||
defaultIconSize = grid.iconSizePx;
|
||||
} else if (mDisplay == DISPLAY_ALL_APPS) {
|
||||
DeviceProfile grid = mActivity.getDeviceProfile();
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
|
||||
setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
|
||||
defaultIconSize = grid.allAppsIconSizePx;
|
||||
} else if (mDisplay == DISPLAY_FOLDER) {
|
||||
DeviceProfile grid = mActivity.getDeviceProfile();
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.folderChildTextSizePx);
|
||||
setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx);
|
||||
defaultIconSize = grid.folderChildIconSizePx;
|
||||
} else {
|
||||
// widget_selection or shortcut_popup
|
||||
defaultIconSize = mActivity.getDeviceProfile().iconSizePx;
|
||||
defaultIconSize = grid.iconSizePx;
|
||||
}
|
||||
|
||||
mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false);
|
||||
|
||||
@@ -59,14 +59,12 @@ import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DraggableView;
|
||||
import com.android.launcher3.folder.PreviewBackground;
|
||||
import com.android.launcher3.graphics.DragPreviewProvider;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.util.CellAndSpan;
|
||||
import com.android.launcher3.util.GridOccupancy;
|
||||
import com.android.launcher3.util.ParcelableSparseArray;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.launcher3.views.Transposable;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetHostView;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -77,7 +75,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Stack;
|
||||
|
||||
public class CellLayout extends ViewGroup implements Transposable {
|
||||
public class CellLayout extends ViewGroup {
|
||||
private static final String TAG = "CellLayout";
|
||||
private static final boolean LOGD = false;
|
||||
|
||||
@@ -184,7 +182,6 @@ public class CellLayout extends ViewGroup implements Transposable {
|
||||
|
||||
// Related to accessible drag and drop
|
||||
private boolean mUseTouchHelper = false;
|
||||
private RotationMode mRotationMode = RotationMode.NORMAL;
|
||||
|
||||
public CellLayout(Context context) {
|
||||
this(context, null);
|
||||
@@ -206,7 +203,7 @@ public class CellLayout extends ViewGroup implements Transposable {
|
||||
setClipToPadding(false);
|
||||
mActivity = ActivityContext.lookupContext(context);
|
||||
|
||||
DeviceProfile grid = mActivity.getWallpaperDeviceProfile();
|
||||
DeviceProfile grid = mActivity.getDeviceProfile();
|
||||
|
||||
mCellWidth = mCellHeight = -1;
|
||||
mFixedCellWidth = mFixedCellHeight = -1;
|
||||
@@ -314,24 +311,6 @@ public class CellLayout extends ViewGroup implements Transposable {
|
||||
}
|
||||
}
|
||||
|
||||
public void setRotationMode(RotationMode mode) {
|
||||
if (mRotationMode != mode) {
|
||||
mRotationMode = mode;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RotationMode getRotationMode() {
|
||||
return mRotationMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPadding(int left, int top, int right, int bottom) {
|
||||
mRotationMode.mapRect(left, top, right, bottom, mTempRect);
|
||||
super.setPadding(mTempRect.left, mTempRect.top, mTempRect.right, mTempRect.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (mUseTouchHelper ||
|
||||
@@ -789,13 +768,6 @@ public class CellLayout extends ViewGroup implements Transposable {
|
||||
int childWidthSize = widthSize - (getPaddingLeft() + getPaddingRight());
|
||||
int childHeightSize = heightSize - (getPaddingTop() + getPaddingBottom());
|
||||
|
||||
mShortcutsAndWidgets.setRotation(mRotationMode.surfaceRotation);
|
||||
if (mRotationMode.isTransposed) {
|
||||
int tmp = childWidthSize;
|
||||
childWidthSize = childHeightSize;
|
||||
childHeightSize = tmp;
|
||||
}
|
||||
|
||||
if (mFixedCellWidth < 0 || mFixedCellHeight < 0) {
|
||||
int cw = DeviceProfile.calculateCellWidth(childWidthSize, mCountX);
|
||||
int ch = DeviceProfile.calculateCellHeight(childHeightSize, mCountY);
|
||||
@@ -846,15 +818,7 @@ public class CellLayout extends ViewGroup implements Transposable {
|
||||
right + mTempRect.right + getPaddingRight(),
|
||||
bottom + mTempRect.bottom + getPaddingBottom());
|
||||
|
||||
if (mRotationMode.isTransposed) {
|
||||
int halfW = mShortcutsAndWidgets.getMeasuredWidth() / 2;
|
||||
int halfH = mShortcutsAndWidgets.getMeasuredHeight() / 2;
|
||||
int cX = (left + right) / 2;
|
||||
int cY = (top + bottom) / 2;
|
||||
mShortcutsAndWidgets.layout(cX - halfW, cY - halfH, cX + halfW, cY + halfH);
|
||||
} else {
|
||||
mShortcutsAndWidgets.layout(left, top, right, bottom);
|
||||
}
|
||||
mShortcutsAndWidgets.layout(left, top, right, bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -863,8 +827,7 @@ public class CellLayout extends ViewGroup implements Transposable {
|
||||
* width in {@link DeviceProfile#calculateCellWidth(int, int)}.
|
||||
*/
|
||||
public int getUnusedHorizontalSpace() {
|
||||
return (mRotationMode.isTransposed ? getMeasuredHeight() : getMeasuredWidth())
|
||||
- getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth);
|
||||
return getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth);
|
||||
}
|
||||
|
||||
public Drawable getScrimBackground() {
|
||||
|
||||
@@ -27,15 +27,13 @@ import android.view.ViewDebug;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.logging.StatsLogUtils.LogContainerProvider;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
import com.android.launcher3.views.Transposable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Hotseat extends CellLayout implements LogContainerProvider, Insettable, Transposable {
|
||||
public class Hotseat extends CellLayout implements LogContainerProvider, Insettable {
|
||||
|
||||
@ViewDebug.ExportedProperty(category = "launcher")
|
||||
private boolean mHasVerticalHotseat;
|
||||
@@ -89,7 +87,7 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta
|
||||
@Override
|
||||
public void setInsets(Rect insets) {
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
|
||||
DeviceProfile grid = mActivity.getWallpaperDeviceProfile();
|
||||
DeviceProfile grid = mActivity.getDeviceProfile();
|
||||
insets = grid.getInsets();
|
||||
|
||||
if (grid.isVerticalBarLayout()) {
|
||||
@@ -117,9 +115,4 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return event.getY() > getCellHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RotationMode getRotationMode() {
|
||||
return Launcher.getLauncher(getContext()).getRotationMode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
@@ -102,7 +101,6 @@ import com.android.launcher3.dragndrop.DragView;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.folder.FolderGridOrganizer;
|
||||
import com.android.launcher3.folder.FolderIcon;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.keyboard.CustomActionsPopup;
|
||||
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
|
||||
@@ -317,9 +315,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
private float mCurrentAssistantVisibility = 0f;
|
||||
|
||||
private DeviceProfile mStableDeviceProfile;
|
||||
private RotationMode mRotationMode = RotationMode.NORMAL;
|
||||
|
||||
protected LauncherOverlayManager mOverlayManager;
|
||||
// If true, overlay callbacks are deferred
|
||||
private boolean mDeferOverlayCallbacks;
|
||||
@@ -503,24 +498,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
onIdpChanged(mDeviceProfile.inv);
|
||||
}
|
||||
|
||||
private boolean supportsFakeLandscapeUI() {
|
||||
return FeatureFlags.FAKE_LANDSCAPE_UI.get() && !mRotationHelper.homeScreenCanRotate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reapplyUi() {
|
||||
reapplyUi(true /* cancelCurrentAnimation */);
|
||||
}
|
||||
|
||||
public void reapplyUi(boolean cancelCurrentAnimation) {
|
||||
if (supportsFakeLandscapeUI()) {
|
||||
mRotationMode = mStableDeviceProfile == null
|
||||
? RotationMode.NORMAL : getFakeRotationMode(mDeviceProfile);
|
||||
}
|
||||
getRootView().dispatchInsets();
|
||||
getStateManager().reapplyState(cancelCurrentAnimation);
|
||||
}
|
||||
@@ -533,7 +516,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
private void onIdpChanged(InvariantDeviceProfile idp) {
|
||||
mUserEventDispatcher = null;
|
||||
|
||||
DeviceProfile oldWallpaperProfile = getWallpaperDeviceProfile();
|
||||
initDeviceProfile(idp);
|
||||
dispatchDeviceProfileChanged();
|
||||
reapplyUi();
|
||||
@@ -542,9 +524,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
// Calling onSaveInstanceState ensures that static cache used by listWidgets is
|
||||
// initialized properly.
|
||||
onSaveInstanceState(new Bundle());
|
||||
if (oldWallpaperProfile != getWallpaperDeviceProfile()) {
|
||||
mModel.rebindCallbacks();
|
||||
}
|
||||
mModel.rebindCallbacks();
|
||||
}
|
||||
|
||||
public void onAssistantVisibilityChanged(float visibility) {
|
||||
@@ -571,41 +551,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize);
|
||||
}
|
||||
|
||||
if (supportsFakeLandscapeUI() && mDeviceProfile.isVerticalBarLayout()) {
|
||||
mStableDeviceProfile = mDeviceProfile.inv.portraitProfile;
|
||||
mRotationMode = getFakeRotationMode(mDeviceProfile);
|
||||
} else {
|
||||
mStableDeviceProfile = null;
|
||||
mRotationMode = RotationMode.NORMAL;
|
||||
}
|
||||
|
||||
mRotationHelper.updateRotationAnimation();
|
||||
onDeviceProfileInitiated();
|
||||
mModelWriter = mModel.getWriter(getWallpaperDeviceProfile().isVerticalBarLayout(), true);
|
||||
}
|
||||
|
||||
public void updateInsets(Rect insets) {
|
||||
mDeviceProfile.updateInsets(insets);
|
||||
if (mStableDeviceProfile != null) {
|
||||
Rect r = mStableDeviceProfile.getInsets();
|
||||
mRotationMode.mapInsets(this, insets, r);
|
||||
mStableDeviceProfile.updateInsets(r);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RotationMode getRotationMode() {
|
||||
return mRotationMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Device profile to be used by UI elements which are shown directly on top of the wallpaper
|
||||
* and whose presentation is tied to the wallpaper (and physical device) and not the activity
|
||||
* configuration.
|
||||
*/
|
||||
@Override
|
||||
public DeviceProfile getWallpaperDeviceProfile() {
|
||||
return mStableDeviceProfile == null ? mDeviceProfile : mStableDeviceProfile;
|
||||
mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true);
|
||||
}
|
||||
|
||||
public RotationHelper getRotationHelper() {
|
||||
@@ -2049,7 +1996,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
mAppWidgetHost.clearViews();
|
||||
|
||||
if (mHotseat != null) {
|
||||
mHotseat.resetLayout(getWallpaperDeviceProfile().isVerticalBarLayout());
|
||||
mHotseat.resetLayout(getDeviceProfile().isVerticalBarLayout());
|
||||
}
|
||||
TraceHelper.INSTANCE.endSection(traceToken);
|
||||
}
|
||||
@@ -2724,10 +2671,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
return new TouchController[] {getDragController(), new AllAppsSwipeController(this)};
|
||||
}
|
||||
|
||||
protected RotationMode getFakeRotationMode(DeviceProfile deviceProfile) {
|
||||
return RotationMode.NORMAL;
|
||||
}
|
||||
|
||||
protected ScaleAndTranslation getOverviewScaleAndTranslationForNormalState() {
|
||||
return new ScaleAndTranslation(1.1f, 0f, 0f);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
UI_STATE_ROOT_VIEW, drawInsetBar ? FLAG_DARK_NAV : 0);
|
||||
|
||||
// Update device profile before notifying th children.
|
||||
mLauncher.updateInsets(insets);
|
||||
mLauncher.getDeviceProfile().updateInsets(insets);
|
||||
boolean resetState = !insets.equals(mInsets);
|
||||
setInsets(insets);
|
||||
|
||||
@@ -127,7 +127,7 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
}
|
||||
|
||||
public void dispatchInsets() {
|
||||
mLauncher.updateInsets(mInsets);
|
||||
mLauncher.getDeviceProfile().updateInsets(mInsets);
|
||||
super.setInsets(mInsets);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
|
||||
public void setupLp(View child) {
|
||||
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
|
||||
if (child instanceof LauncherAppWidgetHostView) {
|
||||
DeviceProfile profile = mActivity.getWallpaperDeviceProfile();
|
||||
DeviceProfile profile = mActivity.getDeviceProfile();
|
||||
lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX,
|
||||
profile.appWidgetScale.x, profile.appWidgetScale.y);
|
||||
} else {
|
||||
@@ -108,12 +108,12 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
|
||||
|
||||
public int getCellContentHeight() {
|
||||
return Math.min(getMeasuredHeight(),
|
||||
mActivity.getWallpaperDeviceProfile().getCellHeight(mContainerType));
|
||||
mActivity.getDeviceProfile().getCellHeight(mContainerType));
|
||||
}
|
||||
|
||||
public void measureChild(View child) {
|
||||
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
|
||||
final DeviceProfile profile = mActivity.getWallpaperDeviceProfile();
|
||||
final DeviceProfile profile = mActivity.getDeviceProfile();
|
||||
|
||||
if (child instanceof LauncherAppWidgetHostView) {
|
||||
lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX,
|
||||
|
||||
@@ -62,7 +62,6 @@ import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.graphics.TintedDrawableSpan;
|
||||
import com.android.launcher3.icons.IconProvider;
|
||||
import com.android.launcher3.icons.LauncherIcons;
|
||||
@@ -72,7 +71,6 @@ import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.views.Transposable;
|
||||
import com.android.launcher3.widget.PendingAddShortcutInfo;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -165,7 +163,7 @@ public final class Utilities {
|
||||
public static float getDescendantCoordRelativeToAncestor(
|
||||
View descendant, View ancestor, float[] coord, boolean includeRootScroll) {
|
||||
return getDescendantCoordRelativeToAncestor(descendant, ancestor, coord, includeRootScroll,
|
||||
false, null);
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,15 +176,12 @@ public final class Utilities {
|
||||
* @param includeRootScroll Whether or not to account for the scroll of the descendant:
|
||||
* sometimes this is relevant as in a child's coordinates within the descendant.
|
||||
* @param ignoreTransform If true, view transform is ignored
|
||||
* @param outRotation If not null, and {@param ignoreTransform} is true, this is set to the
|
||||
* overall rotation of the view in degrees.
|
||||
* @return The factor by which this descendant is scaled relative to this DragLayer. Caution
|
||||
* this scale factor is assumed to be equal in X and Y, and so if at any point this
|
||||
* assumption fails, we will need to return a pair of scale factors.
|
||||
*/
|
||||
public static float getDescendantCoordRelativeToAncestor(View descendant, View ancestor,
|
||||
float[] coord, boolean includeRootScroll, boolean ignoreTransform,
|
||||
float[] outRotation) {
|
||||
float[] coord, boolean includeRootScroll, boolean ignoreTransform) {
|
||||
float scale = 1.0f;
|
||||
View v = descendant;
|
||||
while(v != ancestor && v != null) {
|
||||
@@ -196,19 +191,7 @@ public final class Utilities {
|
||||
offsetPoints(coord, -v.getScrollX(), -v.getScrollY());
|
||||
}
|
||||
|
||||
if (ignoreTransform) {
|
||||
if (v instanceof Transposable) {
|
||||
RotationMode m = ((Transposable) v).getRotationMode();
|
||||
if (m.isTransposed) {
|
||||
sMatrix.setRotate(m.surfaceRotation, v.getPivotX(), v.getPivotY());
|
||||
sMatrix.mapPoints(coord);
|
||||
|
||||
if (outRotation != null) {
|
||||
outRotation[0] += m.surfaceRotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!ignoreTransform) {
|
||||
v.getMatrix().mapPoints(coord);
|
||||
}
|
||||
offsetPoints(coord, v.getLeft(), v.getTop());
|
||||
|
||||
@@ -75,7 +75,6 @@ import com.android.launcher3.folder.FolderIcon;
|
||||
import com.android.launcher3.folder.PreviewBackground;
|
||||
import com.android.launcher3.graphics.DragPreviewProvider;
|
||||
import com.android.launcher3.graphics.PreloadIconDrawable;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.icons.BitmapRenderer;
|
||||
import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
|
||||
@@ -276,20 +275,13 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
@Override
|
||||
public void setInsets(Rect insets) {
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
DeviceProfile stableGrid = mLauncher.getWallpaperDeviceProfile();
|
||||
|
||||
mMaxDistanceForFolderCreation = stableGrid.isTablet
|
||||
? 0.75f * stableGrid.iconSizePx
|
||||
: 0.55f * stableGrid.iconSizePx;
|
||||
mMaxDistanceForFolderCreation = grid.isTablet
|
||||
? 0.75f * grid.iconSizePx : 0.55f * grid.iconSizePx;
|
||||
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
|
||||
|
||||
Rect padding = stableGrid.workspacePadding;
|
||||
|
||||
RotationMode rotationMode = mLauncher.getRotationMode();
|
||||
|
||||
rotationMode.mapRect(padding, mTempRect);
|
||||
setPadding(mTempRect.left, mTempRect.top, mTempRect.right, mTempRect.bottom);
|
||||
rotationMode.mapRect(stableGrid.getInsets(), mInsets);
|
||||
Rect padding = grid.workspacePadding;
|
||||
setPadding(padding.left, padding.top, padding.right, padding.bottom);
|
||||
|
||||
if (mWorkspaceFadeInAdjacentScreens) {
|
||||
// In landscape mode the page spacing is set to the default.
|
||||
@@ -302,12 +294,11 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
}
|
||||
|
||||
|
||||
int paddingLeftRight = stableGrid.cellLayoutPaddingLeftRightPx;
|
||||
int paddingBottom = stableGrid.cellLayoutBottomPaddingPx;
|
||||
int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
|
||||
int paddingBottom = grid.cellLayoutBottomPaddingPx;
|
||||
for (int i = mWorkspaceScreens.size() - 1; i >= 0; i--) {
|
||||
CellLayout page = mWorkspaceScreens.valueAt(i);
|
||||
page.setRotationMode(rotationMode);
|
||||
page.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
|
||||
mWorkspaceScreens.valueAt(i)
|
||||
.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +318,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
float scale = 1;
|
||||
if (isWidget) {
|
||||
DeviceProfile profile = mLauncher.getWallpaperDeviceProfile();
|
||||
DeviceProfile profile = mLauncher.getDeviceProfile();
|
||||
scale = Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
|
||||
}
|
||||
size[0] = r.width();
|
||||
@@ -555,10 +546,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
// created CellLayout.
|
||||
CellLayout newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
|
||||
R.layout.workspace_screen, this, false /* attachToRoot */);
|
||||
DeviceProfile grid = mLauncher.getWallpaperDeviceProfile();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
|
||||
int paddingBottom = grid.cellLayoutBottomPaddingPx;
|
||||
newScreen.setRotationMode(mLauncher.getRotationMode());
|
||||
newScreen.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
|
||||
|
||||
mWorkspaceScreens.put(screenId, newScreen);
|
||||
|
||||
@@ -104,10 +104,8 @@ public class WorkspaceStateTransitionAnimation {
|
||||
Interpolator scaleInterpolator = config.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
|
||||
propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
|
||||
|
||||
if (!hotseat.getRotationMode().isTransposed) {
|
||||
setPivotToScaleWithWorkspace(hotseat);
|
||||
setPivotToScaleWithWorkspace(qsbScaleView);
|
||||
}
|
||||
setPivotToScaleWithWorkspace(hotseat);
|
||||
setPivotToScaleWithWorkspace(qsbScaleView);
|
||||
float hotseatScale = hotseatScaleAndTranslation.scale;
|
||||
Interpolator hotseatScaleInterpolator = config.getInterpolator(ANIM_HOTSEAT_SCALE,
|
||||
scaleInterpolator);
|
||||
|
||||
@@ -95,9 +95,6 @@ public final class FeatureFlags {
|
||||
public static final BooleanFlag ENABLE_HINTS_IN_OVERVIEW = getDebugFlag(
|
||||
"ENABLE_HINTS_IN_OVERVIEW", false, "Show chip hints and gleams on the overview screen");
|
||||
|
||||
public static final BooleanFlag FAKE_LANDSCAPE_UI = getDebugFlag(
|
||||
"FAKE_LANDSCAPE_UI", false, "Rotate launcher UI instead of using transposed layout");
|
||||
|
||||
public static final BooleanFlag FOLDER_NAME_SUGGEST = new DeviceFlag(
|
||||
"FOLDER_NAME_SUGGEST", true,
|
||||
"Suggests folder names instead of blank text.");
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
|
||||
package com.android.launcher3.dragndrop;
|
||||
|
||||
import static android.view.View.MeasureSpec.EXACTLY;
|
||||
import static android.view.View.MeasureSpec.getMode;
|
||||
import static android.view.View.MeasureSpec.getSize;
|
||||
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5;
|
||||
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
|
||||
|
||||
@@ -34,14 +30,12 @@ import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.CellLayout;
|
||||
@@ -52,12 +46,10 @@ import com.android.launcher3.ShortcutAndWidgetContainer;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.graphics.OverviewScrim;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.graphics.WorkspaceAndHotseatScrim;
|
||||
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.launcher3.views.Transposable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -560,145 +552,4 @@ public class DragLayer extends BaseDragLayer<Launcher> {
|
||||
public OverviewScrim getOverviewScrim() {
|
||||
return mOverviewScrim;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
RotationMode rotation = mActivity.getRotationMode();
|
||||
int count = getChildCount();
|
||||
|
||||
if (!rotation.isTransposed
|
||||
|| getMode(widthMeasureSpec) != EXACTLY
|
||||
|| getMode(heightMeasureSpec) != EXACTLY) {
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
child.setRotation(rotation.surfaceRotation);
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
if (!(child instanceof Transposable)) {
|
||||
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
||||
} else {
|
||||
measureChildWithMargins(child, heightMeasureSpec, 0, widthMeasureSpec, 0);
|
||||
|
||||
child.setPivotX(child.getMeasuredWidth() / 2);
|
||||
child.setPivotY(child.getMeasuredHeight() / 2);
|
||||
child.setRotation(rotation.surfaceRotation);
|
||||
}
|
||||
}
|
||||
setMeasuredDimension(getSize(widthMeasureSpec), getSize(heightMeasureSpec));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
RotationMode rotation = mActivity.getRotationMode();
|
||||
if (!rotation.isTransposed) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
return;
|
||||
}
|
||||
|
||||
final int count = getChildCount();
|
||||
|
||||
final int parentWidth = right - left;
|
||||
final int parentHeight = bottom - top;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) child.getLayoutParams();
|
||||
|
||||
if (lp instanceof LayoutParams) {
|
||||
final LayoutParams dlp = (LayoutParams) lp;
|
||||
if (dlp.customPosition) {
|
||||
child.layout(dlp.x, dlp.y, dlp.x + dlp.width, dlp.y + dlp.height);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final int width = child.getMeasuredWidth();
|
||||
final int height = child.getMeasuredHeight();
|
||||
|
||||
int childLeft;
|
||||
int childTop;
|
||||
|
||||
int gravity = lp.gravity;
|
||||
if (gravity == -1) {
|
||||
gravity = Gravity.TOP | Gravity.START;
|
||||
}
|
||||
|
||||
final int layoutDirection = getLayoutDirection();
|
||||
|
||||
int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection);
|
||||
|
||||
if (child instanceof Transposable) {
|
||||
absoluteGravity = rotation.toNaturalGravity(absoluteGravity);
|
||||
|
||||
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
||||
case Gravity.CENTER_HORIZONTAL:
|
||||
childTop = (parentHeight - height) / 2 +
|
||||
lp.topMargin - lp.bottomMargin;
|
||||
break;
|
||||
case Gravity.RIGHT:
|
||||
childTop = width / 2 + lp.rightMargin - height / 2;
|
||||
break;
|
||||
case Gravity.LEFT:
|
||||
default:
|
||||
childTop = parentHeight - lp.leftMargin - width / 2 - height / 2;
|
||||
}
|
||||
|
||||
switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) {
|
||||
case Gravity.CENTER_VERTICAL:
|
||||
childLeft = (parentWidth - width) / 2 +
|
||||
lp.leftMargin - lp.rightMargin;
|
||||
break;
|
||||
case Gravity.BOTTOM:
|
||||
childLeft = parentWidth - width / 2 - height / 2 - lp.bottomMargin;
|
||||
break;
|
||||
case Gravity.TOP:
|
||||
default:
|
||||
childLeft = height / 2 - width / 2 + lp.topMargin;
|
||||
}
|
||||
} else {
|
||||
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
||||
case Gravity.CENTER_HORIZONTAL:
|
||||
childLeft = (parentWidth - width) / 2 +
|
||||
lp.leftMargin - lp.rightMargin;
|
||||
break;
|
||||
case Gravity.RIGHT:
|
||||
childLeft = parentWidth - width - lp.rightMargin;
|
||||
break;
|
||||
case Gravity.LEFT:
|
||||
default:
|
||||
childLeft = lp.leftMargin;
|
||||
}
|
||||
|
||||
switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) {
|
||||
case Gravity.TOP:
|
||||
childTop = lp.topMargin;
|
||||
break;
|
||||
case Gravity.CENTER_VERTICAL:
|
||||
childTop = (parentHeight - height) / 2 +
|
||||
lp.topMargin - lp.bottomMargin;
|
||||
break;
|
||||
case Gravity.BOTTOM:
|
||||
childTop = parentHeight - height - lp.bottomMargin;
|
||||
break;
|
||||
default:
|
||||
childTop = lp.topMargin;
|
||||
}
|
||||
}
|
||||
|
||||
child.layout(childLeft, childTop, childLeft + width, childTop + height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||
"is dependent on this");
|
||||
}
|
||||
|
||||
DeviceProfile grid = activity.getWallpaperDeviceProfile();
|
||||
DeviceProfile grid = activity.getDeviceProfile();
|
||||
FolderIcon icon = (FolderIcon) LayoutInflater.from(group.getContext())
|
||||
.inflate(resId, group, false);
|
||||
|
||||
@@ -570,8 +570,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||
public void drawDot(Canvas canvas) {
|
||||
if (!mForceHideDot && ((mDotInfo != null && mDotInfo.hasDot()) || mDotScale > 0)) {
|
||||
Rect iconBounds = mDotParams.iconBounds;
|
||||
BubbleTextView.getIconBounds(this, iconBounds,
|
||||
mActivity.getWallpaperDeviceProfile().iconSizePx);
|
||||
BubbleTextView.getIconBounds(this, iconBounds, mActivity.getDeviceProfile().iconSizePx);
|
||||
float iconScale = (float) mBackground.previewSize / iconBounds.width();
|
||||
Utilities.scaleRectAboutCenter(iconBounds, iconScale);
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
mBgColor = ta.getColor(R.styleable.FolderIconPreview_folderFillColor, 0);
|
||||
ta.recycle();
|
||||
|
||||
DeviceProfile grid = activity.getWallpaperDeviceProfile();
|
||||
DeviceProfile grid = activity.getDeviceProfile();
|
||||
previewSize = grid.folderIconSizePx;
|
||||
|
||||
basePreviewOffsetX = (availableSpaceX - previewSize) / 2;
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3.graphics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
|
||||
public abstract class RotationMode {
|
||||
|
||||
public static final RotationMode NORMAL = new RotationMode(0) { };
|
||||
|
||||
public final float surfaceRotation;
|
||||
public final boolean isTransposed;
|
||||
|
||||
public RotationMode(float surfaceRotation) {
|
||||
this.surfaceRotation = surfaceRotation;
|
||||
isTransposed = surfaceRotation != 0;
|
||||
}
|
||||
|
||||
public final void mapRect(Rect rect, Rect out) {
|
||||
mapRect(rect.left, rect.top, rect.right, rect.bottom, out);
|
||||
}
|
||||
|
||||
public void mapRect(int left, int top, int right, int bottom, Rect out) {
|
||||
out.set(left, top, right, bottom);
|
||||
}
|
||||
|
||||
public void mapInsets(Context context, Rect insets, Rect out) {
|
||||
out.set(insets);
|
||||
}
|
||||
|
||||
public int toNaturalGravity(int absoluteGravity) {
|
||||
return absoluteGravity;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE;
|
||||
import static com.android.launcher3.config.FeatureFlags.FLAG_ENABLE_FIXED_ROTATION_TRANSFORM;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
@@ -36,12 +37,9 @@ import android.graphics.RectF;
|
||||
import android.provider.Settings;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.util.UiThreadHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -77,7 +75,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
public static final int REQUEST_ROTATE = 1;
|
||||
public static final int REQUEST_LOCK = 2;
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private final Activity mActivity;
|
||||
private final SharedPreferences mSharedPrefs;
|
||||
private final SharedPreferences mFeatureFlagsPrefs;
|
||||
|
||||
@@ -104,17 +102,16 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
// This is used to defer setting rotation flags until the activity is being created
|
||||
private boolean mInitialized;
|
||||
private boolean mDestroyed;
|
||||
private boolean mRotationHasDifferentUI;
|
||||
|
||||
private int mLastActivityFlags = -1;
|
||||
|
||||
public RotationHelper(Launcher launcher) {
|
||||
mLauncher = launcher;
|
||||
public RotationHelper(Activity activity) {
|
||||
mActivity = activity;
|
||||
|
||||
// On large devices we do not handle auto-rotate differently.
|
||||
mIgnoreAutoRotateSettings = mLauncher.getResources().getBoolean(R.bool.allow_rotation);
|
||||
mIgnoreAutoRotateSettings = mActivity.getResources().getBoolean(R.bool.allow_rotation);
|
||||
if (!mIgnoreAutoRotateSettings) {
|
||||
mSharedPrefs = Utilities.getPrefs(mLauncher);
|
||||
mSharedPrefs = Utilities.getPrefs(mActivity);
|
||||
mSharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||
mAutoRotateEnabled = mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
|
||||
getAllowRotationDefaultValue());
|
||||
@@ -122,8 +119,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
mSharedPrefs = null;
|
||||
}
|
||||
|
||||
mContentResolver = launcher.getContentResolver();
|
||||
mFeatureFlagsPrefs = Utilities.getFeatureFlagsPrefs(mLauncher);
|
||||
mContentResolver = activity.getContentResolver();
|
||||
mFeatureFlagsPrefs = Utilities.getFeatureFlagsPrefs(mActivity);
|
||||
mFeatureFlagsPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||
updateForcedRotation(true);
|
||||
}
|
||||
@@ -144,7 +141,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
mForcedRotation = isForcedRotation;
|
||||
}
|
||||
UI_HELPER_EXECUTOR.execute(() -> {
|
||||
if (mLauncher.checkSelfPermission(WRITE_SECURE_SETTINGS) == PERMISSION_GRANTED) {
|
||||
if (mActivity.checkSelfPermission(WRITE_SECURE_SETTINGS) == PERMISSION_GRANTED) {
|
||||
Settings.Global.putInt(mContentResolver, FIXED_ROTATION_TRANSFORM_SETTING_NAME,
|
||||
mForcedRotation ? 1 : 0);
|
||||
}
|
||||
@@ -165,29 +162,6 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
mForcedRotationChangedListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void setRotationHadDifferentUI(boolean rotationHasDifferentUI) {
|
||||
mRotationHasDifferentUI = rotationHasDifferentUI;
|
||||
}
|
||||
|
||||
public boolean homeScreenCanRotate() {
|
||||
return mRotationHasDifferentUI || mIgnoreAutoRotateSettings || mAutoRotateEnabled
|
||||
|| mStateHandlerRequest != REQUEST_NONE
|
||||
|| mLauncher.getDeviceProfile().isMultiWindowMode;
|
||||
}
|
||||
|
||||
public void updateRotationAnimation() {
|
||||
if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) {
|
||||
WindowManager.LayoutParams lp = mLauncher.getWindow().getAttributes();
|
||||
int oldAnim = lp.rotationAnimation;
|
||||
lp.rotationAnimation = homeScreenCanRotate()
|
||||
? WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE
|
||||
: WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
|
||||
if (oldAnim != lp.rotationAnimation) {
|
||||
mLauncher.getWindow().setAttributes(lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
|
||||
if (FLAG_ENABLE_FIXED_ROTATION_TRANSFORM.equals(s)) {
|
||||
@@ -199,17 +173,13 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
mAutoRotateEnabled = mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
|
||||
getAllowRotationDefaultValue());
|
||||
if (mAutoRotateEnabled != wasRotationEnabled) {
|
||||
|
||||
notifyChange();
|
||||
updateRotationAnimation();
|
||||
mLauncher.reapplyUi();
|
||||
}
|
||||
}
|
||||
|
||||
public void setStateHandlerRequest(int request) {
|
||||
if (mStateHandlerRequest != request) {
|
||||
mStateHandlerRequest = request;
|
||||
updateRotationAnimation();
|
||||
notifyChange();
|
||||
}
|
||||
}
|
||||
@@ -231,7 +201,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
// Used by tests only.
|
||||
public void forceAllowRotationForTesting(boolean allowRotation) {
|
||||
mIgnoreAutoRotateSettings =
|
||||
allowRotation || mLauncher.getResources().getBoolean(R.bool.allow_rotation);
|
||||
allowRotation || mActivity.getResources().getBoolean(R.bool.allow_rotation);
|
||||
// TODO(b/150214193) Tests currently expect launcher to be able to be rotated
|
||||
// Modify tests for this new behavior
|
||||
mForcedRotation = !allowRotation;
|
||||
@@ -243,7 +213,6 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
if (!mInitialized) {
|
||||
mInitialized = true;
|
||||
notifyChange();
|
||||
updateRotationAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +254,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
|
||||
}
|
||||
if (activityFlags != mLastActivityFlags) {
|
||||
mLastActivityFlags = activityFlags;
|
||||
UiThreadHelper.setOrientationAsync(mLauncher, activityFlags);
|
||||
UiThreadHelper.setOrientationAsync(mActivity, activityFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.view.View.AccessibilityDelegate;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.dot.DotInfo;
|
||||
|
||||
/**
|
||||
@@ -57,19 +56,6 @@ public interface ActivityContext {
|
||||
|
||||
DeviceProfile getDeviceProfile();
|
||||
|
||||
/**
|
||||
* Device profile to be used by UI elements which are shown directly on top of the wallpaper
|
||||
* and whose presentation is tied to the wallpaper (and physical device) and not the activity
|
||||
* configuration.
|
||||
*/
|
||||
default DeviceProfile getWallpaperDeviceProfile() {
|
||||
return getDeviceProfile();
|
||||
}
|
||||
|
||||
default RotationMode getRotationMode() {
|
||||
return RotationMode.NORMAL;
|
||||
}
|
||||
|
||||
static ActivityContext lookupContext(Context context) {
|
||||
if (context instanceof ActivityContext) {
|
||||
return (ActivityContext) context;
|
||||
|
||||
@@ -92,8 +92,6 @@ public class FloatingIconView extends FrameLayout implements
|
||||
private ClipIconView mClipIconView;
|
||||
private @Nullable Drawable mBadge;
|
||||
|
||||
private float mRotation;
|
||||
|
||||
private View mOriginalIcon;
|
||||
private RectF mPositionOut;
|
||||
private Runnable mOnTargetChangeRunnable;
|
||||
@@ -194,18 +192,17 @@ public class FloatingIconView extends FrameLayout implements
|
||||
* @param positionOut Rect that will hold the size and position of v.
|
||||
*/
|
||||
private void matchPositionOf(Launcher launcher, View v, boolean isOpening, RectF positionOut) {
|
||||
float rotation = getLocationBoundsForView(launcher, v, isOpening, positionOut);
|
||||
getLocationBoundsForView(launcher, v, isOpening, positionOut);
|
||||
final InsettableFrameLayout.LayoutParams lp = new InsettableFrameLayout.LayoutParams(
|
||||
Math.round(positionOut.width()),
|
||||
Math.round(positionOut.height()));
|
||||
updatePosition(rotation, positionOut, lp);
|
||||
updatePosition(positionOut, lp);
|
||||
setLayoutParams(lp);
|
||||
|
||||
mClipIconView.setLayoutParams(new FrameLayout.LayoutParams(lp.width, lp.height));
|
||||
}
|
||||
|
||||
private void updatePosition(float rotation, RectF pos, InsettableFrameLayout.LayoutParams lp) {
|
||||
mRotation = rotation;
|
||||
private void updatePosition(RectF pos, InsettableFrameLayout.LayoutParams lp) {
|
||||
mPositionOut.set(pos);
|
||||
lp.ignoreInsets = true;
|
||||
// Position the floating view exactly on top of the original
|
||||
@@ -228,7 +225,7 @@ public class FloatingIconView extends FrameLayout implements
|
||||
* - For DeepShortcutView, we return the bounds of the icon view.
|
||||
* - For BubbleTextView, we return the icon bounds.
|
||||
*/
|
||||
private static float getLocationBoundsForView(Launcher launcher, View v, boolean isOpening,
|
||||
private static void getLocationBoundsForView(Launcher launcher, View v, boolean isOpening,
|
||||
RectF outRect) {
|
||||
boolean ignoreTransform = !isOpening;
|
||||
if (v instanceof DeepShortcutView) {
|
||||
@@ -239,7 +236,7 @@ public class FloatingIconView extends FrameLayout implements
|
||||
ignoreTransform = false;
|
||||
}
|
||||
if (v == null) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Rect iconBounds = new Rect();
|
||||
@@ -253,15 +250,13 @@ public class FloatingIconView extends FrameLayout implements
|
||||
|
||||
float[] points = new float[] {iconBounds.left, iconBounds.top, iconBounds.right,
|
||||
iconBounds.bottom};
|
||||
float[] rotation = new float[] {0};
|
||||
Utilities.getDescendantCoordRelativeToAncestor(v, launcher.getDragLayer(), points,
|
||||
false, ignoreTransform, rotation);
|
||||
false, ignoreTransform);
|
||||
outRect.set(
|
||||
Math.min(points[0], points[2]),
|
||||
Math.min(points[1], points[3]),
|
||||
Math.max(points[0], points[2]),
|
||||
Math.max(points[1], points[3]));
|
||||
return rotation[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,14 +438,10 @@ public class FloatingIconView extends FrameLayout implements
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
int count = canvas.save();
|
||||
canvas.rotate(mRotation,
|
||||
mFinalDrawableBounds.exactCenterX(), mFinalDrawableBounds.exactCenterY());
|
||||
super.dispatchDraw(canvas);
|
||||
if (mBadge != null) {
|
||||
mBadge.draw(canvas);
|
||||
}
|
||||
canvas.restoreToCount(count);
|
||||
}
|
||||
|
||||
public void fastFinish() {
|
||||
@@ -487,11 +478,10 @@ public class FloatingIconView extends FrameLayout implements
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if (mOriginalIcon.isAttachedToWindow() && mPositionOut != null) {
|
||||
float rotation = getLocationBoundsForView(mLauncher, mOriginalIcon, mIsOpening,
|
||||
getLocationBoundsForView(mLauncher, mOriginalIcon, mIsOpening,
|
||||
sTmpRectF);
|
||||
if (rotation != mRotation || !sTmpRectF.equals(mPositionOut)) {
|
||||
updatePosition(rotation, sTmpRectF,
|
||||
(InsettableFrameLayout.LayoutParams) getLayoutParams());
|
||||
if (!sTmpRectF.equals(mPositionOut)) {
|
||||
updatePosition(sTmpRectF, (InsettableFrameLayout.LayoutParams) getLayoutParams());
|
||||
if (mOnTargetChangeRunnable != null) {
|
||||
mOnTargetChangeRunnable.run();
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3.views;
|
||||
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
|
||||
/**
|
||||
* Indicates that a view can be transposed.
|
||||
*/
|
||||
public interface Transposable {
|
||||
|
||||
RotationMode getRotationMode();
|
||||
}
|
||||
Reference in New Issue
Block a user