62
62
import com .android .launcher3 .util .ParcelableSparseArray ;
63
63
import com .android .launcher3 .util .Themes ;
64
64
import com .android .launcher3 .util .Thunk ;
65
+ import com .android .launcher3 .views .ActivityContext ;
65
66
import com .android .launcher3 .widget .LauncherAppWidgetHostView ;
66
67
67
68
import java .lang .annotation .Retention ;
@@ -82,7 +83,7 @@ public class CellLayout extends ViewGroup {
82
83
private static final String TAG = "CellLayout" ;
83
84
private static final boolean LOGD = false ;
84
85
85
- private final Launcher mLauncher ;
86
+ protected final ActivityContext mActivity ;
86
87
@ ViewDebug .ExportedProperty (category = "launcher" )
87
88
@ Thunk int mCellWidth ;
88
89
@ ViewDebug .ExportedProperty (category = "launcher" )
@@ -106,7 +107,6 @@ public class CellLayout extends ViewGroup {
106
107
private GridOccupancy mTmpOccupied ;
107
108
108
109
private OnTouchListener mInterceptTouchListener ;
109
- private final StylusEventHelper mStylusEventHelper ;
110
110
111
111
private final ArrayList <PreviewBackground > mFolderBackgrounds = new ArrayList <>();
112
112
final PreviewBackground mFolderLeaveBehind = new PreviewBackground ();
@@ -201,9 +201,9 @@ public CellLayout(Context context, AttributeSet attrs, int defStyle) {
201
201
// the user where a dragged item will land when dropped.
202
202
setWillNotDraw (false );
203
203
setClipToPadding (false );
204
- mLauncher = Launcher . getLauncher (context );
204
+ mActivity = ActivityContext . lookupContext (context );
205
205
206
- DeviceProfile grid = mLauncher .getDeviceProfile ();
206
+ DeviceProfile grid = mActivity .getDeviceProfile ();
207
207
208
208
mCellWidth = mCellHeight = -1 ;
209
209
mFixedCellWidth = mFixedCellHeight = -1 ;
@@ -286,8 +286,6 @@ public void onAnimationEnd(Animator animation) {
286
286
287
287
mShortcutsAndWidgets = new ShortcutAndWidgetContainer (context , mContainerType );
288
288
mShortcutsAndWidgets .setCellDimensions (mCellWidth , mCellHeight , mCountX , mCountY );
289
-
290
- mStylusEventHelper = new StylusEventHelper (new SimpleOnStylusPressListener (this ), this );
291
289
addView (mShortcutsAndWidgets );
292
290
}
293
291
@@ -337,20 +335,6 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
337
335
return false ;
338
336
}
339
337
340
- @ Override
341
- public boolean onTouchEvent (MotionEvent ev ) {
342
- boolean handled = super .onTouchEvent (ev );
343
- // Stylus button press on a home screen should not switch between overview mode and
344
- // the home screen mode, however, once in overview mode stylus button press should be
345
- // enabled to allow rearranging the different home screens. So check what mode
346
- // the workspace is in, and only perform stylus button presses while in overview mode.
347
- if (mLauncher .isInState (LauncherState .OVERVIEW )
348
- && mStylusEventHelper .onMotionEvent (ev )) {
349
- return true ;
350
- }
351
- return handled ;
352
- }
353
-
354
338
public void enableHardwareLayer (boolean hasLayer ) {
355
339
mShortcutsAndWidgets .setLayerType (hasLayer ? LAYER_TYPE_HARDWARE : LAYER_TYPE_NONE , sPaint );
356
340
}
@@ -504,7 +488,7 @@ public void removeFolderBackground(PreviewBackground bg) {
504
488
505
489
public void setFolderLeaveBehindCell (int x , int y ) {
506
490
View child = getChildAt (x , y );
507
- mFolderLeaveBehind .setup (mLauncher , null ,
491
+ mFolderLeaveBehind .setup (getContext (), mActivity , null ,
508
492
child .getMeasuredWidth (), child .getPaddingTop ());
509
493
510
494
mFolderLeaveBehind .delegateCellX = x ;
@@ -945,7 +929,7 @@ void visualizeDropLocation(View v, DragPreviewProvider outlineProvider, int cell
945
929
if (resize ) {
946
930
cellToRect (cellX , cellY , spanX , spanY , r );
947
931
if (v instanceof LauncherAppWidgetHostView ) {
948
- DeviceProfile profile = mLauncher .getDeviceProfile ();
932
+ DeviceProfile profile = mActivity .getDeviceProfile ();
949
933
Utilities .shrinkRect (r , profile .appWidgetScale .x , profile .appWidgetScale .y );
950
934
}
951
935
} else {
@@ -2047,7 +2031,7 @@ private void cancel() {
2047
2031
.translationY (initDeltaY )
2048
2032
.build (child )
2049
2033
.setDuration (REORDER_ANIMATION_DURATION );
2050
- mLauncher .getDragController ().addFirstFrameAnimationHelper (a );
2034
+ Launcher . cast ( mActivity ) .getDragController ().addFirstFrameAnimationHelper (a );
2051
2035
a .setInterpolator (DEACCEL_1_5 );
2052
2036
a .start ();
2053
2037
}
@@ -2063,7 +2047,7 @@ private void completeAndClearReorderPreviewAnimations() {
2063
2047
private void commitTempPlacement () {
2064
2048
mTmpOccupied .copyTo (mOccupied );
2065
2049
2066
- int screenId = mLauncher .getWorkspace ().getIdForScreen (this );
2050
+ int screenId = Launcher . cast ( mActivity ) .getWorkspace ().getIdForScreen (this );
2067
2051
int container = Favorites .CONTAINER_DESKTOP ;
2068
2052
2069
2053
if (mContainerType == HOTSEAT ) {
@@ -2089,8 +2073,8 @@ private void commitTempPlacement() {
2089
2073
info .spanY = lp .cellVSpan ;
2090
2074
2091
2075
if (requiresDbUpdate ) {
2092
- mLauncher . getModelWriter ().modifyItemInDatabase (info , container , screenId ,
2093
- info .cellX , info .cellY , info .spanX , info .spanY );
2076
+ Launcher . cast ( mActivity ). getModelWriter ().modifyItemInDatabase (info , container ,
2077
+ screenId , info .cellX , info .cellY , info .spanX , info .spanY );
2094
2078
}
2095
2079
}
2096
2080
}
0 commit comments