summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/CellLayout.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2018-11-14 15:17:26 -0800
committerSunny Goyal <sunnygoyal@google.com>2018-11-20 17:11:13 -0800
commitab770a10b9d0d81d7753db1690ce9e592bdbeed8 (patch)
tree3dd423c1c37888999a10de322bc3474fabd217a1 /src/com/android/launcher3/CellLayout.java
parent373e2534d3434d95fac56c95668b3f2daa982f39 (diff)
downloadpackages_apps_Trebuchet-ab770a10b9d0d81d7753db1690ce9e592bdbeed8.tar.gz
packages_apps_Trebuchet-ab770a10b9d0d81d7753db1690ce9e592bdbeed8.tar.bz2
packages_apps_Trebuchet-ab770a10b9d0d81d7753db1690ce9e592bdbeed8.zip
Making CellLayout inflatable without LauncherActivtiy
This will allow creating cellLayout with a different device profile or a different activtiy which can be used when displaying multiple activities in multi-display or generating a preview for changing display properties. Change-Id: I386731d95e33c48bdef270ce9c0d3e9feefb6262
Diffstat (limited to 'src/com/android/launcher3/CellLayout.java')
-rw-r--r--src/com/android/launcher3/CellLayout.java36
1 files changed, 10 insertions, 26 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);
}
}
}