summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/CellLayout.java36
-rw-r--r--src/com/android/launcher3/Hotseat.java19
-rw-r--r--src/com/android/launcher3/Launcher.java9
-rw-r--r--src/com/android/launcher3/ShortcutAndWidgetContainer.java13
-rw-r--r--src/com/android/launcher3/Workspace.java9
-rw-r--r--src/com/android/launcher3/folder/PreviewBackground.java12
-rw-r--r--src/com/android/launcher3/folder/PreviewItemManager.java3
7 files changed, 46 insertions, 55 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 92404d4cd..a117cfd15 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -62,6 +62,7 @@ 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.widget.LauncherAppWidgetHostView;
import java.lang.annotation.Retention;
@@ -82,7 +83,7 @@ public class CellLayout extends ViewGroup {
private static final String TAG = "CellLayout";
private static final boolean LOGD = false;
- private final Launcher mLauncher;
+ protected final ActivityContext mActivity;
@ViewDebug.ExportedProperty(category = "launcher")
@Thunk int mCellWidth;
@ViewDebug.ExportedProperty(category = "launcher")
@@ -106,7 +107,6 @@ public class CellLayout extends ViewGroup {
private GridOccupancy mTmpOccupied;
private OnTouchListener mInterceptTouchListener;
- private final StylusEventHelper mStylusEventHelper;
private final ArrayList<PreviewBackground> mFolderBackgrounds = new ArrayList<>();
final PreviewBackground mFolderLeaveBehind = new PreviewBackground();
@@ -201,9 +201,9 @@ public class CellLayout extends ViewGroup {
// the user where a dragged item will land when dropped.
setWillNotDraw(false);
setClipToPadding(false);
- mLauncher = Launcher.getLauncher(context);
+ mActivity = ActivityContext.lookupContext(context);
- DeviceProfile grid = mLauncher.getDeviceProfile();
+ DeviceProfile grid = mActivity.getDeviceProfile();
mCellWidth = mCellHeight = -1;
mFixedCellWidth = mFixedCellHeight = -1;
@@ -286,8 +286,6 @@ public class CellLayout extends ViewGroup {
mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context, mContainerType);
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mCountX, mCountY);
-
- mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
addView(mShortcutsAndWidgets);
}
@@ -337,20 +335,6 @@ public class CellLayout extends ViewGroup {
return false;
}
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- boolean handled = super.onTouchEvent(ev);
- // Stylus button press on a home screen should not switch between overview mode and
- // the home screen mode, however, once in overview mode stylus button press should be
- // enabled to allow rearranging the different home screens. So check what mode
- // the workspace is in, and only perform stylus button presses while in overview mode.
- if (mLauncher.isInState(LauncherState.OVERVIEW)
- && mStylusEventHelper.onMotionEvent(ev)) {
- return true;
- }
- return handled;
- }
-
public void enableHardwareLayer(boolean hasLayer) {
mShortcutsAndWidgets.setLayerType(hasLayer ? LAYER_TYPE_HARDWARE : LAYER_TYPE_NONE, sPaint);
}
@@ -504,7 +488,7 @@ public class CellLayout extends ViewGroup {
public void setFolderLeaveBehindCell(int x, int y) {
View child = getChildAt(x, y);
- mFolderLeaveBehind.setup(mLauncher, null,
+ mFolderLeaveBehind.setup(getContext(), mActivity, null,
child.getMeasuredWidth(), child.getPaddingTop());
mFolderLeaveBehind.delegateCellX = x;
@@ -945,7 +929,7 @@ public class CellLayout extends ViewGroup {
if (resize) {
cellToRect(cellX, cellY, spanX, spanY, r);
if (v instanceof LauncherAppWidgetHostView) {
- DeviceProfile profile = mLauncher.getDeviceProfile();
+ DeviceProfile profile = mActivity.getDeviceProfile();
Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
}
} else {
@@ -2047,7 +2031,7 @@ public class CellLayout extends ViewGroup {
.translationY(initDeltaY)
.build(child)
.setDuration(REORDER_ANIMATION_DURATION);
- mLauncher.getDragController().addFirstFrameAnimationHelper(a);
+ Launcher.cast(mActivity).getDragController().addFirstFrameAnimationHelper(a);
a.setInterpolator(DEACCEL_1_5);
a.start();
}
@@ -2063,7 +2047,7 @@ public class CellLayout extends ViewGroup {
private void commitTempPlacement() {
mTmpOccupied.copyTo(mOccupied);
- int screenId = mLauncher.getWorkspace().getIdForScreen(this);
+ int screenId = Launcher.cast(mActivity).getWorkspace().getIdForScreen(this);
int container = Favorites.CONTAINER_DESKTOP;
if (mContainerType == HOTSEAT) {
@@ -2089,8 +2073,8 @@ public class CellLayout extends ViewGroup {
info.spanY = lp.cellVSpan;
if (requiresDbUpdate) {
- mLauncher.getModelWriter().modifyItemInDatabase(info, container, screenId,
- info.cellX, info.cellY, info.spanX, info.spanY);
+ Launcher.cast(mActivity).getModelWriter().modifyItemInDatabase(info, container,
+ screenId, info.cellX, info.cellY, info.spanX, info.spanY);
}
}
}
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 6b5db307b..cbd3fc034 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -20,7 +20,6 @@ import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.Gravity;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
@@ -32,8 +31,6 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
public class Hotseat extends CellLayout implements LogContainerProvider, Insettable {
- private final Launcher mLauncher;
-
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mHasVerticalHotseat;
@@ -47,7 +44,6 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta
public Hotseat(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mLauncher = Launcher.getLauncher(context);
}
/* Get the orientation specific coordinates given an invariant order in the hotseat. */
@@ -59,10 +55,10 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta
return mHasVerticalHotseat ? (getCountY() - (rank + 1)) : 0;
}
- void resetLayout(boolean hasVerticalHotseat) {
+ public void resetLayout(boolean hasVerticalHotseat) {
removeAllViewsInLayout();
mHasVerticalHotseat = hasVerticalHotseat;
- InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
+ InvariantDeviceProfile idp = mActivity.getDeviceProfile().inv;
if (hasVerticalHotseat) {
setGridSize(1, idp.numHotseatIcons);
} else {
@@ -71,15 +67,6 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta
}
@Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- // We don't want any clicks to go through to the hotseat unless the workspace is in
- // the normal state or an accessible drag is in progress.
- return (!mLauncher.getWorkspace().workspaceIconsCanBeDragged()
- && !mLauncher.getAccessibilityDelegate().isInAccessibleDrag())
- || super.onInterceptTouchEvent(ev);
- }
-
- @Override
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
target.gridX = info.cellX;
target.gridY = info.cellY;
@@ -89,7 +76,7 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta
@Override
public void setInsets(Rect insets) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
- DeviceProfile grid = mLauncher.getDeviceProfile();
+ DeviceProfile grid = mActivity.getDeviceProfile();
if (grid.isVerticalBarLayout()) {
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 36967cd4e..b6fa0718b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -122,6 +122,7 @@ import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.UiThreadHelper;
import com.android.launcher3.util.ViewOnDrawExecutor;
+import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.OptionsPopupView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.PendingAddShortcutInfo;
@@ -940,6 +941,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
mDropTargetBar.setup(mDragController);
mAllAppsController.setupViews(mAppsView);
+ mHotseat.setOnInterceptTouchListener(mWorkspace::onInterceptHotseatTouch);
}
/**
@@ -2392,6 +2394,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
}
/**
+ * Just a wrapper around the type cast to allow easier tracking of calls.
+ */
+ public static <T extends Launcher> T cast(ActivityContext activityContext) {
+ return (T) activityContext;
+ }
+
+ /**
* Callback for listening for onResume
*/
public interface OnResumeCallback {
diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
index baf6d876b..30f418d02 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -26,6 +26,7 @@ import android.view.View;
import android.view.ViewGroup;
import com.android.launcher3.CellLayout.ContainerType;
+import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
public class ShortcutAndWidgetContainer extends ViewGroup {
@@ -43,12 +44,12 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
private int mCountX;
- private Launcher mLauncher;
+ private ActivityContext mActivity;
private boolean mInvertIfRtl = false;
public ShortcutAndWidgetContainer(Context context, @ContainerType int containerType) {
super(context);
- mLauncher = Launcher.getLauncher(context);
+ mActivity = ActivityContext.lookupContext(context);
mWallpaperManager = WallpaperManager.getInstance(context);
mContainerType = containerType;
}
@@ -92,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 = mLauncher.getDeviceProfile();
+ DeviceProfile profile = mActivity.getDeviceProfile();
lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX,
profile.appWidgetScale.x, profile.appWidgetScale.y);
} else {
@@ -107,12 +108,12 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
public int getCellContentHeight() {
return Math.min(getMeasuredHeight(),
- mLauncher.getDeviceProfile().getCellHeight(mContainerType));
+ mActivity.getDeviceProfile().getCellHeight(mContainerType));
}
public void measureChild(View child) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
- final DeviceProfile profile = mLauncher.getDeviceProfile();
+ final DeviceProfile profile = mActivity.getDeviceProfile();
if (child instanceof LauncherAppWidgetHostView) {
lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX,
@@ -149,7 +150,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) child;
// Scale and center the widget to fit within its cells.
- DeviceProfile profile = mLauncher.getDeviceProfile();
+ DeviceProfile profile = mActivity.getDeviceProfile();
float scaleX = profile.appWidgetScale.x;
float scaleY = profile.appWidgetScale.y;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 96df81032..c8e660b92 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -475,6 +475,13 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
super.onViewAdded(child);
}
+ protected boolean onInterceptHotseatTouch(View v, MotionEvent ev) {
+ // We don't want any clicks to go through to the hotseat unless the workspace is in
+ // the normal state or an accessible drag is in progress.
+ return !workspaceIconsCanBeDragged()
+ && !mLauncher.getAccessibilityDelegate().isInAccessibleDrag();
+ }
+
/**
* Initializes and binds the first page
* @param qsb an existing qsb to recycle or null.
@@ -2442,7 +2449,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
this.cellY = cellY;
BubbleTextView cell = (BubbleTextView) layout.getChildAt(cellX, cellY);
- bg.setup(mLauncher, null, cell.getMeasuredWidth(), cell.getPaddingTop());
+ bg.setup(mLauncher, mLauncher, null, cell.getMeasuredWidth(), cell.getPaddingTop());
// The full preview background should appear behind the icon
bg.isClipping = false;
diff --git a/src/com/android/launcher3/folder/PreviewBackground.java b/src/com/android/launcher3/folder/PreviewBackground.java
index f2683a5f9..3c9e2dc20 100644
--- a/src/com/android/launcher3/folder/PreviewBackground.java
+++ b/src/com/android/launcher3/folder/PreviewBackground.java
@@ -23,6 +23,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
+import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
@@ -41,6 +42,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.util.Themes;
+import com.android.launcher3.views.ActivityContext;
/**
* This object represents a FolderIcon preview background. It stores drawing / measurement
@@ -121,20 +123,20 @@ public class PreviewBackground {
}
};
- public void setup(Launcher launcher, View invalidateDelegate,
+ public void setup(Context context, ActivityContext activity, View invalidateDelegate,
int availableSpaceX, int topPadding) {
mInvalidateDelegate = invalidateDelegate;
- mBgColor = Themes.getAttrColor(launcher, android.R.attr.colorPrimary);
- mBadgeColor = Themes.getAttrColor(launcher, R.attr.folderBadgeColor);
+ mBgColor = Themes.getAttrColor(context, android.R.attr.colorPrimary);
+ mBadgeColor = Themes.getAttrColor(context, R.attr.folderBadgeColor);
- DeviceProfile grid = launcher.getDeviceProfile();
+ DeviceProfile grid = activity.getDeviceProfile();
previewSize = grid.folderIconSizePx;
basePreviewOffsetX = (availableSpaceX - previewSize) / 2;
basePreviewOffsetY = topPadding + grid.folderIconOffsetYPx;
// Stroke width is 1dp
- mStrokeWidth = launcher.getResources().getDisplayMetrics().density;
+ mStrokeWidth = context.getResources().getDisplayMetrics().density;
float radius = getScaledRadius();
float shadowRadius = radius + mStrokeWidth;
diff --git a/src/com/android/launcher3/folder/PreviewItemManager.java b/src/com/android/launcher3/folder/PreviewItemManager.java
index 0004e1e40..af98680ea 100644
--- a/src/com/android/launcher3/folder/PreviewItemManager.java
+++ b/src/com/android/launcher3/folder/PreviewItemManager.java
@@ -107,7 +107,8 @@ public class PreviewItemManager {
mTotalWidth = totalSize;
mPrevTopPadding = mIcon.getPaddingTop();
- mIcon.mBackground.setup(mIcon.mLauncher, mIcon, mTotalWidth, mIcon.getPaddingTop());
+ mIcon.mBackground.setup(mIcon.mLauncher, mIcon.mLauncher, mIcon, mTotalWidth,
+ mIcon.getPaddingTop());
mIcon.mPreviewLayoutRule.init(mIcon.mBackground.previewSize, mIntrinsicIconSize,
Utilities.isRtl(mIcon.getResources()));