Merge "Moving Pause button to the left of the context menu header" into ub-launcher3-master
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index 5810e8b..1af9e8d 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index c712703..08132aa 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -26,6 +26,8 @@
<string name="recent_task_option_split_screen">Split screen</string>
<!-- Title for an option to keep an app pinned to the screen until it is unpinned -->
<string name="recent_task_option_pin">Pin</string>
+ <!-- Title for an option to enter freeform mode for a given app -->
+ <string name="recent_task_option_freeform">Freeform</string>
<!-- Content description for the recent apps panel (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_recent_apps">Overview</string>
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index ef735e1..9d01f74 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -44,7 +44,6 @@
import com.android.launcher3.LauncherAnimationRunner;
import com.android.launcher3.R;
import com.android.launcher3.anim.Interpolators;
-import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
@@ -156,11 +155,6 @@
}
@Override
- public BadgeInfo getBadgeInfoForItem(ItemInfo info) {
- return null;
- }
-
- @Override
public ActivityOptions getActivityLaunchOptions(final View v) {
if (!(v instanceof TaskView)) {
return null;
@@ -211,9 +205,6 @@
}
@Override
- public void invalidateParent(ItemInfo info) { }
-
- @Override
protected void onStart() {
// Set the alpha to 1 before calling super, as it may get set back to 0 due to
// onActivityStart callback.
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index 59a937f..cb214af 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -46,6 +46,7 @@
new TaskSystemShortcut.SplitScreen(),
new TaskSystemShortcut.Pin(),
new TaskSystemShortcut.Install(),
+ new TaskSystemShortcut.Freeform()
};
public static TaskOverlayFactory get(Context context) {
diff --git a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
index a8eb321..8b01e59 100644
--- a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
+++ b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
@@ -18,6 +18,7 @@
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP;
+import android.app.ActivityOptions;
import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -33,6 +34,8 @@
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ItemInfo;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.popup.SystemShortcut;
@@ -102,19 +105,23 @@
}
}
- public static class SplitScreen extends TaskSystemShortcut {
+ public static abstract class MultiWindow extends TaskSystemShortcut {
private Handler mHandler;
- public SplitScreen() {
- super(R.drawable.ic_split_screen, R.string.recent_task_option_split_screen);
+ public MultiWindow(int iconRes, int textRes) {
+ super(iconRes, textRes);
mHandler = new Handler(Looper.getMainLooper());
}
+ protected abstract boolean isAvailable(BaseDraggingActivity activity);
+ protected abstract ActivityOptions makeLaunchOptions();
+ protected abstract boolean onActivityStarted(BaseDraggingActivity activity);
+
@Override
public View.OnClickListener getOnClickListener(
BaseDraggingActivity activity, TaskView taskView) {
- if (activity.getDeviceProfile().isMultiWindowMode) {
+ if (!isAvailable(activity)) {
return null;
}
final Task task = taskView.getTask();
@@ -153,22 +160,13 @@
dismissTaskMenuView(activity);
- final int navBarPosition = WindowManagerWrapper.getInstance().getNavBarPosition();
- if (navBarPosition == WindowManagerWrapper.NAV_BAR_POS_INVALID) {
- return;
- }
- boolean dockTopOrLeft = navBarPosition != WindowManagerWrapper.NAV_BAR_POS_LEFT;
- if (ActivityManagerWrapper.getInstance().startActivityFromRecents(taskId,
- ActivityOptionsCompat.makeSplitScreenOptions(dockTopOrLeft))) {
- ISystemUiProxy sysUiProxy = RecentsModel.INSTANCE.get(activity).getSystemUiProxy();
- try {
- sysUiProxy.onSplitScreenInvoked();
- } catch (RemoteException e) {
- Log.w(TAG, "Failed to notify SysUI of split screen: ", e);
+ ActivityOptions options = makeLaunchOptions();
+ if (options != null
+ && ActivityManagerWrapper.getInstance().startActivityFromRecents(taskId,
+ options)) {
+ if (!onActivityStarted(activity)) {
return;
}
- activity.getUserEventDispatcher().logActionOnControl(TAP,
- LauncherLogProto.ControlType.SPLIT_SCREEN_TARGET);
// Add a device profile change listener to kick off animating the side tasks
// once we enter multiwindow mode and relayout
activity.addOnDeviceProfileChangeListener(onDeviceProfileChangeListener);
@@ -211,6 +209,64 @@
}
}
+ public static class SplitScreen extends MultiWindow {
+ public SplitScreen() {
+ super(R.drawable.ic_split_screen, R.string.recent_task_option_split_screen);
+ }
+
+ @Override
+ protected boolean isAvailable(BaseDraggingActivity activity) {
+ // Don't show menu-item if already in multi-window
+ return !activity.getDeviceProfile().isMultiWindowMode;
+ }
+
+ @Override
+ protected ActivityOptions makeLaunchOptions() {
+ final int navBarPosition = WindowManagerWrapper.getInstance().getNavBarPosition();
+ if (navBarPosition == WindowManagerWrapper.NAV_BAR_POS_INVALID) {
+ return null;
+ }
+ boolean dockTopOrLeft = navBarPosition != WindowManagerWrapper.NAV_BAR_POS_LEFT;
+ return ActivityOptionsCompat.makeSplitScreenOptions(dockTopOrLeft);
+ }
+
+ @Override
+ protected boolean onActivityStarted(BaseDraggingActivity activity) {
+ ISystemUiProxy sysUiProxy = RecentsModel.INSTANCE.get(activity).getSystemUiProxy();
+ try {
+ sysUiProxy.onSplitScreenInvoked();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to notify SysUI of split screen: ", e);
+ return false;
+ }
+ activity.getUserEventDispatcher().logActionOnControl(TAP,
+ LauncherLogProto.ControlType.SPLIT_SCREEN_TARGET);
+ return true;
+ }
+ }
+
+ public static class Freeform extends MultiWindow {
+ public Freeform() {
+ super(R.drawable.ic_split_screen, R.string.recent_task_option_freeform);
+ }
+
+ @Override
+ protected boolean isAvailable(BaseDraggingActivity activity) {
+ return ActivityManagerWrapper.getInstance().supportsFreeformMultiWindow(activity);
+ }
+
+ @Override
+ protected ActivityOptions makeLaunchOptions() {
+ return ActivityOptionsCompat.makeFreeformOptions();
+ }
+
+ @Override
+ protected boolean onActivityStarted(BaseDraggingActivity activity) {
+ Launcher.getLauncher(activity).getStateManager().goToState(LauncherState.NORMAL);
+ return true;
+ }
+ }
+
public static class Pin extends TaskSystemShortcut {
private static final String TAG = Pin.class.getSimpleName();
diff --git a/robolectric_tests/config/robolectric.properties b/robolectric_tests/config/robolectric.properties
index 782b8cb..e0d6e53 100644
--- a/robolectric_tests/config/robolectric.properties
+++ b/robolectric_tests/config/robolectric.properties
@@ -1,2 +1,2 @@
manifest=packages/apps/Launcher3/AndroidManifest.xml
-sdk=28
\ No newline at end of file
+sdk=26
diff --git a/robolectric_tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java b/robolectric_tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
index f17eac7..2334993 100644
--- a/robolectric_tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
+++ b/robolectric_tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
@@ -11,6 +11,7 @@
import com.android.launcher3.ShortcutInfo;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -40,6 +41,7 @@
}
@Test
+ @Ignore("This test fails with resource errors")
public void testCacheUpdate_update_apps() throws Exception {
// Clear all icons from apps list so that its easy to check what was updated
for (AppInfo info : allAppsList.data) {
@@ -64,6 +66,7 @@
}
@Test
+ @Ignore("This test fails with resource errors")
public void testSessionUpdate_ignores_normal_apps() throws Exception {
executeTaskForTest(newTask(CacheDataUpdatedTask.OP_SESSION_UPDATE, "app1"));
@@ -72,6 +75,7 @@
}
@Test
+ @Ignore("This test fails with resource errors")
public void testSessionUpdate_updates_pending_apps() throws Exception {
executeTaskForTest(newTask(CacheDataUpdatedTask.OP_SESSION_UPDATE, "app3"));
diff --git a/robolectric_tests/src/com/android/launcher3/util/IntSetTest.java b/robolectric_tests/src/com/android/launcher3/util/IntSetTest.java
index 8513353..f846de5 100644
--- a/robolectric_tests/src/com/android/launcher3/util/IntSetTest.java
+++ b/robolectric_tests/src/com/android/launcher3/util/IntSetTest.java
@@ -21,6 +21,7 @@
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index 77b6010..1b953d4 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -36,6 +36,7 @@
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.SystemUiController;
+import com.android.launcher3.views.ActivityContext;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -44,7 +45,8 @@
import androidx.annotation.IntDef;
-public abstract class BaseActivity extends Activity implements UserEventDelegate, LogStateProvider{
+public abstract class BaseActivity extends Activity
+ implements UserEventDelegate, LogStateProvider, ActivityContext {
public static final int INVISIBLE_BY_STATE_HANDLER = 1 << 0;
public static final int INVISIBLE_BY_APP_TRANSITIONS = 1 << 1;
@@ -100,14 +102,11 @@
// animation
@InvisibilityFlags private int mForceInvisible;
+ @Override
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
}
- public AccessibilityDelegate getAccessibilityDelegate() {
- return null;
- }
-
public int getCurrentState() { return StatsLogUtils.LAUNCHER_STATE_BACKGROUND; }
public void modifyUserEvent(LauncherLogProto.LauncherEvent event) {}
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 152dc84..25ee61e 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -44,7 +44,7 @@
* Extension of BaseActivity allowing support for drag-n-drop
*/
public abstract class BaseDraggingActivity extends BaseActivity
- implements WallpaperColorInfo.OnChangeListener, ActivityContext {
+ implements WallpaperColorInfo.OnChangeListener {
private static final String TAG = "BaseDraggingActivity";
@@ -139,16 +139,10 @@
return false;
}
- public abstract BaseDragLayer getDragLayer();
-
public abstract <T extends View> T getOverviewPanel();
public abstract View getRootView();
- public abstract BadgeInfo getBadgeInfoForItem(ItemInfo info);
-
- public abstract void invalidateParent(ItemInfo info);
-
public Rect getViewBounds(View v) {
int[] pos = new int[2];
v.getLocationOnScreen(pos);
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 455fd18..f20ded3 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -42,8 +42,6 @@
import android.view.ViewDebug;
import android.widget.TextView;
-import com.android.launcher3.icons.IconCache.IconLoadRequest;
-import com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver;
import com.android.launcher3.Launcher.OnResumeCallback;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.badge.BadgeRenderer;
@@ -51,7 +49,10 @@
import com.android.launcher3.graphics.DrawableFactory;
import com.android.launcher3.graphics.IconPalette;
import com.android.launcher3.graphics.PreloadIconDrawable;
+import com.android.launcher3.icons.IconCache.IconLoadRequest;
+import com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver;
import com.android.launcher3.model.PackageItemInfo;
+import com.android.launcher3.views.ActivityContext;
import java.text.NumberFormat;
@@ -96,7 +97,7 @@
}
};
- private final BaseDraggingActivity mActivity;
+ private final ActivityContext mActivity;
private Drawable mIcon;
private final boolean mCenterVertically;
@@ -144,7 +145,7 @@
public BubbleTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mActivity = BaseDraggingActivity.fromContext(context);
+ mActivity = ActivityContext.lookupContext(context);
DeviceProfile grid = mActivity.getDeviceProfile();
mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 92404d4..a117cfd 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -62,6 +62,7 @@
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 @@
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 @@
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 @@
// 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 @@
mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context, mContainerType);
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mCountX, mCountY);
-
- mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
addView(mShortcutsAndWidgets);
}
@@ -337,20 +335,6 @@
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 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 @@
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 @@
.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 @@
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 @@
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 6b5db30..cbd3fc0 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -20,7 +20,6 @@
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 @@
public class Hotseat extends CellLayout implements LogContainerProvider, Insettable {
- private final Launcher mLauncher;
-
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mHasVerticalHotseat;
@@ -47,7 +44,6 @@
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 @@
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 @@
}
@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 @@
@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 36967cd..b6fa071 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -122,6 +122,7 @@
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 @@
mDropTargetBar.setup(mDragController);
mAllAppsController.setupViews(mAppsView);
+ mHotseat.setOnInterceptTouchListener(mWorkspace::onInterceptHotseatTouch);
}
/**
@@ -2392,6 +2394,13 @@
}
/**
+ * 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 baf6d87..30f418d 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -26,6 +26,7 @@
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 @@
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 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 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 @@
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 96df810..c8e660b 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -475,6 +475,13 @@
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 @@
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/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 3d15c75..86b96b4 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -304,6 +304,8 @@
mNavBarScrimHeight = insets.bottom;
InsettableFrameLayout.dispatchInsets(this, insets);
+ mLauncher.getAllAppsController()
+ .setScrollRangeDelta(mSearchUiManager.getScrollRangeDelta(insets));
}
@Override
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 2d6be7b..ffbf34c 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -221,7 +221,7 @@
/**
* Updates the total scroll range but does not update the UI.
*/
- public void setScrollRangeDelta(float delta) {
+ void setScrollRangeDelta(float delta) {
mScrollRangeDelta = delta;
mShiftRange = mLauncher.getDeviceProfile().heightPx - mScrollRangeDelta;
diff --git a/src/com/android/launcher3/allapps/SearchUiManager.java b/src/com/android/launcher3/allapps/SearchUiManager.java
index 51b90f7..cf9a088 100644
--- a/src/com/android/launcher3/allapps/SearchUiManager.java
+++ b/src/com/android/launcher3/allapps/SearchUiManager.java
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.allapps;
+import android.graphics.Rect;
import android.view.KeyEvent;
import android.view.animation.Interpolator;
@@ -42,6 +43,11 @@
void preDispatchKeyEvent(KeyEvent keyEvent);
/**
+ * Returns the vertical shift for the all-apps view, so that it aligns with the hotseat.
+ */
+ float getScrollRangeDelta(Rect insets);
+
+ /**
* Called as part of state transition to update the content UI
*/
void setContentVisibility(int visibleElements, PropertySetter setter,
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
index b1e23d4..1ff484b 100644
--- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
+++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
@@ -208,13 +208,16 @@
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
mlp.topMargin = Math.round(Math.max(-mFixedTranslationY, insets.top - mMarginTopAdjusting));
requestLayout();
+ }
- DeviceProfile dp = mLauncher.getDeviceProfile();
- if (dp.isVerticalBarLayout()) {
- mLauncher.getAllAppsController().setScrollRangeDelta(0);
+ @Override
+ public float getScrollRangeDelta(Rect insets) {
+ if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
+ return 0;
} else {
- mLauncher.getAllAppsController().setScrollRangeDelta(
- insets.bottom + mlp.topMargin + mFixedTranslationY);
+ int topMargin = Math.round(Math.max(
+ -mFixedTranslationY, insets.top - mMarginTopAdjusting));
+ return insets.bottom + topMargin + mFixedTranslationY;
}
}
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 1ec7eec..8de352e 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -87,7 +87,7 @@
public static final boolean OVERVIEW_USE_SCREENSHOT_ORIENTATION = true;
public static final ToggleableGlobalSettingsFlag QUICK_SWITCH
- = new ToggleableGlobalSettingsFlag("navbar_quick_switch_enabled", false,
+ = new ToggleableGlobalSettingsFlag("QUICK_SWITCH", false,
"Swiping right on the nav bar while in an app switches to the previous app");
/**
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java
index daf7dc6..79819cc 100644
--- a/src/com/android/launcher3/dragndrop/AddItemActivity.java
+++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java
@@ -58,6 +58,7 @@
import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.util.LooperExecutor;
import com.android.launcher3.util.Provider;
+import com.android.launcher3.views.BaseDragLayer;
import com.android.launcher3.widget.PendingAddShortcutInfo;
import com.android.launcher3.widget.PendingAddWidgetInfo;
import com.android.launcher3.widget.WidgetHostViewLoader;
@@ -314,6 +315,11 @@
.getInt(STATE_EXTRA_WIDGET_ID, mPendingBindWidgetId);
}
+ @Override
+ public BaseDragLayer getDragLayer() {
+ throw new UnsupportedOperationException();
+ }
+
private void logCommand(int command) {
getUserEventDispatcher().dispatchUserEvent(newLauncherEvent(
newCommandAction(command),
diff --git a/src/com/android/launcher3/folder/PreviewBackground.java b/src/com/android/launcher3/folder/PreviewBackground.java
index f2683a5..3c9e2dc 100644
--- a/src/com/android/launcher3/folder/PreviewBackground.java
+++ b/src/com/android/launcher3/folder/PreviewBackground.java
@@ -23,6 +23,7 @@
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.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 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 0004e1e..af98680 100644
--- a/src/com/android/launcher3/folder/PreviewItemManager.java
+++ b/src/com/android/launcher3/folder/PreviewItemManager.java
@@ -107,7 +107,8 @@
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()));
diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java
index 04100af..cee7eee 100644
--- a/src/com/android/launcher3/views/ActivityContext.java
+++ b/src/com/android/launcher3/views/ActivityContext.java
@@ -18,10 +18,15 @@
import android.content.Context;
import android.content.ContextWrapper;
import android.view.ContextThemeWrapper;
+import android.view.View.AccessibilityDelegate;
+
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.ItemInfo;
+import com.android.launcher3.badge.BadgeInfo;
/**
- * An interface to be used along with a context. This allows a generic class to depend on Context
- * subclass instead of an Activity.
+ * An interface to be used along with a context for various activities in Launcher. This allows a
+ * generic class to depend on Context subclass instead of an Activity.
*/
public interface ActivityContext {
@@ -29,8 +34,28 @@
return false;
}
+ default BadgeInfo getBadgeInfoForItem(ItemInfo info) {
+ return null;
+ }
+
+ /**
+ * For items with tree hierarchy, notifies the activity to invalidate the parent when a root
+ * is invalidated
+ * @param info info associated with a root node.
+ */
+ default void invalidateParent(ItemInfo info) { }
+
+ default AccessibilityDelegate getAccessibilityDelegate() {
+ return null;
+ }
+
+ /**
+ * The root view to support drag-and-drop and popup support.
+ */
BaseDragLayer getDragLayer();
+ DeviceProfile getDeviceProfile();
+
static ActivityContext lookupContext(Context context) {
if (context instanceof ActivityContext) {
return (ActivityContext) context;