summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-10-12 21:22:05 (GMT)
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-10-12 21:22:05 (GMT)
commitcf6195268d3c1f190318b3220d321fb910349e51 (patch)
tree326eb9ceccc784ef6aafd49c78a7a02bc207519d
parent3f8864069be20d14debacddee610062f3feae5a1 (diff)
parent2fd020860533e18c64a93d14d11cb2d34bc9cbaf (diff)
downloadandroid_packages_apps_Trebuchet-cf6195268d3c1f190318b3220d321fb910349e51.zip
android_packages_apps_Trebuchet-cf6195268d3c1f190318b3220d321fb910349e51.tar.gz
android_packages_apps_Trebuchet-cf6195268d3c1f190318b3220d321fb910349e51.tar.bz2
Merge "Use Launcher.getLauncher(Context) instead of type-casting." into ub-launcher3-calgary-polish
-rw-r--r--src/com/android/launcher3/AppWidgetResizeFrame.java2
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java2
-rw-r--r--src/com/android/launcher3/CellLayout.java2
-rw-r--r--src/com/android/launcher3/FocusHelper.java4
-rw-r--r--src/com/android/launcher3/Hotseat.java2
-rw-r--r--src/com/android/launcher3/LauncherModel.java11
-rw-r--r--src/com/android/launcher3/PagedView.java2
-rw-r--r--src/com/android/launcher3/QsbContainerView.java7
-rw-r--r--src/com/android/launcher3/ShortcutAndWidgetContainer.java2
-rw-r--r--src/com/android/launcher3/Workspace.java2
-rw-r--r--src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java2
-rw-r--r--src/com/android/launcher3/accessibility/OverviewAccessibilityDelegate.java2
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java2
-rw-r--r--src/com/android/launcher3/allapps/AllAppsRecyclerViewContainerView.java2
-rw-r--r--src/com/android/launcher3/allapps/AlphabeticalAppsList.java2
-rw-r--r--src/com/android/launcher3/folder/Folder.java2
-rw-r--r--src/com/android/launcher3/folder/FolderPagedView.java2
-rw-r--r--src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java2
-rw-r--r--src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java2
19 files changed, 29 insertions, 25 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index daeca3b..cd27b4c 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -80,7 +80,7 @@ public class AppWidgetResizeFrame extends FrameLayout implements View.OnKeyListe
LauncherAppWidgetHostView widgetView, CellLayout cellLayout, DragLayer dragLayer) {
super(context);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mCellLayout = cellLayout;
mWidgetView = widgetView;
LauncherAppWidgetProviderInfo info = (LauncherAppWidgetProviderInfo)
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index cf8abae..60a2cc3 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -83,7 +83,7 @@ public abstract class ButtonDropTarget extends TextView
public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
Resources resources = getResources();
mBottomDragPadding = resources.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 6714d9f..57fd0e7 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -196,7 +196,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
// the user where a dragged item will land when dropped.
setWillNotDraw(false);
setClipToPadding(false);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
DeviceProfile grid = mLauncher.getDeviceProfile();
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index c73ceea..789c3f9 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -204,7 +204,7 @@ public class FocusHelper {
return consume;
}
- final Launcher launcher = (Launcher) v.getContext();
+ final Launcher launcher = Launcher.getLauncher(v.getContext());
final DeviceProfile profile = launcher.getDeviceProfile();
if (DEBUG) {
@@ -341,7 +341,7 @@ public class FocusHelper {
return consume;
}
- Launcher launcher = (Launcher) v.getContext();
+ Launcher launcher = Launcher.getLauncher(v.getContext());
DeviceProfile profile = launcher.getDeviceProfile();
if (DEBUG) {
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index f9424d4..0fbbc19 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -67,7 +67,7 @@ public class Hotseat extends FrameLayout
public Hotseat(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
mBackgroundColor = ColorUtils.setAlphaComponent(
ContextCompat.getColor(context, R.color.all_apps_container_color), 0);
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index d66ce6b..3ac9773 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -728,7 +728,8 @@ public class LauncherModel extends BroadcastReceiver
// in the hotseat
if (context instanceof Launcher && screenId < 0 &&
container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
- item.screenId = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
+ item.screenId = Launcher.getLauncher(context).getHotseat()
+ .getOrderInHotseat(cellX, cellY);
} else {
item.screenId = screenId;
}
@@ -761,7 +762,7 @@ public class LauncherModel extends BroadcastReceiver
// in the hotseat
if (context instanceof Launcher && screen < 0 &&
container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
- item.screenId = ((Launcher) context).getHotseat().getOrderInHotseat(item.cellX,
+ item.screenId = Launcher.getLauncher(context).getHotseat().getOrderInHotseat(item.cellX,
item.cellY);
} else {
item.screenId = screen;
@@ -794,7 +795,8 @@ public class LauncherModel extends BroadcastReceiver
// in the hotseat
if (context instanceof Launcher && screenId < 0 &&
container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
- item.screenId = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
+ item.screenId = Launcher.getLauncher(context).getHotseat()
+ .getOrderInHotseat(cellX, cellY);
} else {
item.screenId = screenId;
}
@@ -887,7 +889,8 @@ public class LauncherModel extends BroadcastReceiver
// in the hotseat
if (context instanceof Launcher && screenId < 0 &&
container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
- item.screenId = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
+ item.screenId = Launcher.getLauncher(context).getHotseat()
+ .getOrderInHotseat(cellX, cellY);
} else {
item.screenId = screenId;
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index bea55d2..e380e26 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1834,7 +1834,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
protected void onUnhandledTap(MotionEvent ev) {
- ((Launcher) getContext()).onClick(this);
+ Launcher.getLauncher(getContext()).onClick(this);
}
@Override
diff --git a/src/com/android/launcher3/QsbContainerView.java b/src/com/android/launcher3/QsbContainerView.java
index 7d939a0..02d8a13 100644
--- a/src/com/android/launcher3/QsbContainerView.java
+++ b/src/com/android/launcher3/QsbContainerView.java
@@ -104,7 +104,7 @@ public class QsbContainerView extends FrameLayout {
}
private View createQsb(LayoutInflater inflater, ViewGroup container) {
- Launcher launcher = (Launcher) getActivity();
+ Launcher launcher = Launcher.getLauncher(getActivity());
mWidgetInfo = getSearchWidgetProvider(launcher);
if (mWidgetInfo == null) {
// There is no search provider, just show the default widget.
@@ -168,7 +168,7 @@ public class QsbContainerView extends FrameLayout {
getActivity().startSearch("", false, null, true);
} else if (view.getId() == R.id.btn_qsb_setup) {
// Allocate a new widget id for QSB
- sSavedWidgetId = ((Launcher) getActivity())
+ sSavedWidgetId = Launcher.getLauncher(getActivity())
.getAppWidgetHost().allocateAppWidgetId();
// Start intent for bind the widget
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
@@ -194,7 +194,8 @@ public class QsbContainerView extends FrameLayout {
sSavedWidgetId = -1;
rebindFragment();
} else if (sSavedWidgetId != -1) {
- ((Launcher) getActivity()).getAppWidgetHost().deleteAppWidgetId(sSavedWidgetId);
+ Launcher.getLauncher(getActivity()).getAppWidgetHost()
+ .deleteAppWidgetId(sSavedWidgetId);
sSavedWidgetId = -1;
}
}
diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
index d98734b..37cbf98 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -48,7 +48,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
public ShortcutAndWidgetContainer(Context context) {
super(context);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mWallpaperManager = WallpaperManager.getInstance(context);
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index e891b16..340177d 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -338,7 +338,7 @@ public class Workspace extends PagedView
public Workspace(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this);
final Resources res = getResources();
DeviceProfile grid = mLauncher.getDeviceProfile();
diff --git a/src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java
index 4efe445..bd3bb4d 100644
--- a/src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java
@@ -50,7 +50,7 @@ public abstract class DragAndDropAccessibilityDelegate extends ExploreByTouchHel
super(forView);
mView = forView;
mContext = mView.getContext();
- mDelegate = ((Launcher) mContext).getAccessibilityDelegate();
+ mDelegate = Launcher.getLauncher(mContext).getAccessibilityDelegate();
}
@Override
diff --git a/src/com/android/launcher3/accessibility/OverviewAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/OverviewAccessibilityDelegate.java
index 64559f2..385a766 100644
--- a/src/com/android/launcher3/accessibility/OverviewAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/OverviewAccessibilityDelegate.java
@@ -53,7 +53,7 @@ public class OverviewAccessibilityDelegate extends AccessibilityDelegate {
@Override
public boolean performAccessibilityAction(View host, int action, Bundle args) {
- Launcher launcher = (Launcher) host.getContext();
+ Launcher launcher = Launcher.getLauncher(host.getContext());
if (action == OVERVIEW) {
launcher.showOverviewMode(true);
return true;
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 5892787..77ef642 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -696,7 +696,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
float distance = (float) Math.hypot(dx, dy);
if (distance < viewConfig.getScaledTouchSlop()) {
// The background was clicked, so just go home
- Launcher launcher = (Launcher) getContext();
+ Launcher launcher = Launcher.getLauncher(getContext());
launcher.showWorkspace(true);
return true;
}
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerViewContainerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerViewContainerView.java
index 1d5b209..b5afb2b 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerViewContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerViewContainerView.java
@@ -49,7 +49,7 @@ public class AllAppsRecyclerViewContainerView extends FrameLayout
public AllAppsRecyclerViewContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- Launcher launcher = (Launcher) context;
+ Launcher launcher = Launcher.getLauncher(context);
DeviceProfile grid = launcher.getDeviceProfile();
mTouchFeedbackView = new ClickShadowView(context);
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 7127ec4..173065b 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -209,7 +209,7 @@ public class AlphabeticalAppsList {
private int mNumAppRowsInAdapter;
public AlphabeticalAppsList(Context context) {
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mIndexer = new AlphabeticIndexCompat(context);
mAppNameComparator = new AppNameComparator(context);
}
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 0ae3a62..698e5aa 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -212,7 +212,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
if (sHintText == null) {
sHintText = res.getString(R.string.folder_hint_text);
}
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
// We need this view to be focusable in touch mode so that when text editing of the folder
// name is complete, we have something to focus on, thus hiding the cursor and giving
// reliable behavior when clicking the text field (since it will always gain focus on click).
diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java
index c6b0671..7e7ee34 100644
--- a/src/com/android/launcher3/folder/FolderPagedView.java
+++ b/src/com/android/launcher3/folder/FolderPagedView.java
@@ -252,7 +252,7 @@ public class FolderPagedView extends PagedView {
}
private CellLayout createAndAddNewPage() {
- DeviceProfile grid = ((Launcher) getContext()).getDeviceProfile();
+ DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
CellLayout page = new CellLayout(getContext());
page.setCellDimensions(grid.folderCellWidthPx, grid.folderCellHeightPx);
page.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java b/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java
index fea47a9..aedf283 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java
@@ -49,7 +49,7 @@ public class PageIndicatorCaretLandscape extends PageIndicator {
caretDrawable.setBounds(0, 0, caretSize, caretSize);
setCaretDrawable(caretDrawable);
- Launcher l = (Launcher) context;
+ Launcher l = Launcher.getLauncher(context);
setOnTouchListener(l.getHapticFeedbackTouchListener());
setOnClickListener(l);
setOnLongClickListener(l);
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
index 0e1a708..3ceba84 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
@@ -125,7 +125,7 @@ public class PageIndicatorLineCaret extends PageIndicator {
mLinePaint = new Paint();
mLinePaint.setAlpha(0);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mLineHeight = res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_line_height);
setCaretDrawable(new CaretDrawable(context));
}