Merge "Fix bug where Cancel/Remove drop target text was not being updated." into ub-launcher3-master
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index 62e76d8..1fb2f79 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -33,7 +33,6 @@
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Rect;
-import android.media.midi.MidiManager.OnDeviceOpenedListener;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -118,6 +117,14 @@
mCurrentAnimator = animator;
}
+ @Override
+ public void finishAnimation() {
+ if (mCurrentAnimator != null && mCurrentAnimator.isRunning()) {
+ mCurrentAnimator.end();
+ }
+ mCurrentAnimator = null;
+ }
+
/**
* @return A Bundle with remote animations that controls how the window of the opening
* targets are displayed.
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
index 777bcd3..5706d32 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -36,7 +36,8 @@
*/
public class OverviewState extends LauncherState {
- private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED;
+ private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED
+ | FLAG_DISABLE_RESTORE;
public OverviewState(int id) {
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
diff --git a/quickstep/src/com/android/quickstep/LauncherLayoutListener.java b/quickstep/src/com/android/quickstep/LauncherLayoutListener.java
index 40cd3e6..2a7e5c4 100644
--- a/quickstep/src/com/android/quickstep/LauncherLayoutListener.java
+++ b/quickstep/src/com/android/quickstep/LauncherLayoutListener.java
@@ -60,11 +60,21 @@
@Override
protected void handleClose(boolean animate) {
- // We dont suupport animate.
- mLauncher.getDragLayer().removeView(this);
+ if (mIsOpen) {
+ mIsOpen = false;
+ // We don't support animate.
+ mLauncher.getDragLayer().removeView(this);
- if (mHandler != null) {
- mHandler.layoutListenerClosed();
+ if (mHandler != null) {
+ mHandler.layoutListenerClosed();
+ }
+ }
+ }
+
+ public void open() {
+ if (!mIsOpen) {
+ mLauncher.getDragLayer().addView(this);
+ mIsOpen = true;
}
}
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index fbb6d74..551ed29 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -16,6 +16,7 @@
package com.android.quickstep;
import static com.android.launcher3.LauncherState.OVERVIEW;
+import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
@@ -42,9 +43,9 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.LauncherState;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -65,7 +66,7 @@
public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {
// Launcher UI related states
- private static final int STATE_LAUNCHER_READY = 1 << 0;
+ private static final int STATE_LAUNCHER_PRESENT = 1 << 0;
private static final int STATE_LAUNCHER_DRAWN = 1 << 1;
private static final int STATE_ACTIVITY_MULTIPLIER_COMPLETE = 1 << 2;
@@ -73,11 +74,13 @@
private static final int STATE_APP_CONTROLLER_RECEIVED = 1 << 3;
// Interaction finish states
- private static final int STATE_SCALED_SNAPSHOT_RECENTS = 1 << 4;
- private static final int STATE_SCALED_SNAPSHOT_APP = 1 << 5;
+ private static final int STATE_SCALED_CONTROLLER_RECENTS = 1 << 4;
+ private static final int STATE_SCALED_CONTROLLER_APP = 1 << 5;
+
+ private static final int STATE_HANDLER_INVALIDATED = 1 << 6;
private static final int LAUNCHER_UI_STATES =
- STATE_LAUNCHER_READY | STATE_LAUNCHER_DRAWN | STATE_ACTIVITY_MULTIPLIER_COMPLETE;
+ STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_ACTIVITY_MULTIPLIER_COMPLETE;
private static final long MAX_SWIPE_DURATION = 200;
private static final long MIN_SWIPE_DURATION = 80;
@@ -144,22 +147,29 @@
private void initStateCallbacks() {
mStateCallback = new MultiStateCallback();
- mStateCallback.addCallback(STATE_SCALED_SNAPSHOT_APP | STATE_APP_CONTROLLER_RECEIVED,
+ mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN,
+ this::launcherFrameDrawn);
+
+ mStateCallback.addCallback(STATE_SCALED_CONTROLLER_APP | STATE_APP_CONTROLLER_RECEIVED,
this::resumeLastTask);
- mStateCallback.addCallback(STATE_SCALED_SNAPSHOT_RECENTS
+
+ mStateCallback.addCallback(STATE_SCALED_CONTROLLER_RECENTS
| STATE_ACTIVITY_MULTIPLIER_COMPLETE
| STATE_APP_CONTROLLER_RECEIVED,
this::switchToScreenshot);
- mStateCallback.addCallback(STATE_SCALED_SNAPSHOT_RECENTS
- | STATE_ACTIVITY_MULTIPLIER_COMPLETE,
- this::animateFirstTaskIcon);
- mStateCallback.addCallback(STATE_LAUNCHER_READY | STATE_SCALED_SNAPSHOT_APP,
+ mStateCallback.addCallback(STATE_SCALED_CONTROLLER_RECENTS
+ | STATE_ACTIVITY_MULTIPLIER_COMPLETE,
+ this::setupLauncherUiAfterSwipeUpAnimation);
+
+ mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_SCALED_CONTROLLER_APP,
this::reset);
- mStateCallback.addCallback(STATE_LAUNCHER_READY | STATE_SCALED_SNAPSHOT_RECENTS,
+ mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_SCALED_CONTROLLER_RECENTS,
this::reset);
- mStateCallback.addCallback(STATE_LAUNCHER_READY | STATE_LAUNCHER_DRAWN,
- this::launcherFrameDrawn);
+
+ mStateCallback.addCallback(STATE_HANDLER_INVALIDATED, this::invalidateHandler);
+ mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED,
+ this::invalidateHandlerWithLauncher);
}
private void setStateOnUiThread(int stateFlag) {
@@ -203,6 +213,12 @@
}
mLauncher = launcher;
+ LauncherState startState = mLauncher.getStateManager().getState();
+ if (startState.disableRestore) {
+ startState = mLauncher.getStateManager().getRestState();
+ }
+ mLauncher.getStateManager().setRestState(startState);
+
AbstractFloatingView.closeAllOpenViews(launcher, alreadyOnHome);
mWasLauncherAlreadyVisible = alreadyOnHome;
@@ -219,7 +235,7 @@
mLauncherTransitionController.setPlayFraction(mCurrentShift.value);
state = STATE_ACTIVITY_MULTIPLIER_COMPLETE | STATE_LAUNCHER_DRAWN
- | STATE_LAUNCHER_READY;
+ | STATE_LAUNCHER_PRESENT;
} else {
TraceHelper.beginSection("WTS-init");
launcher.getStateManager().goToState(OVERVIEW, false);
@@ -242,11 +258,11 @@
mStateCallback.setState(STATE_LAUNCHER_DRAWN);
}
});
- state = STATE_LAUNCHER_READY;
+ state = STATE_LAUNCHER_PRESENT;
}
mRecentsView.showTask(mRunningTaskId);
- mLauncher.getDragLayer().addView(mLauncherLayoutListener);
+ mLauncherLayoutListener.open();
// Optimization
// We are using the internal device profile as launcher may not have got the insets yet.
@@ -324,37 +340,24 @@
* Called by {@link #mLauncherLayoutListener} when launcher layout changes
*/
public void onLauncherLayoutChanged() {
- Hotseat hotseat = mLauncher.getHotseat();
-
WindowManagerWrapper.getInstance().getStableInsets(mStableInsets);
initTransitionEndpoints(mLauncher.getDeviceProfile());
if (!mWasLauncherAlreadyVisible) {
- AnimatorSet anim = new AnimatorSet();
+ float startProgress;
+ AllAppsTransitionController controller = mLauncher.getAllAppsController();
+
if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
- mLauncher.getAllAppsController().setProgress(1);
- ObjectAnimator shiftAnim = ObjectAnimator.ofFloat(mLauncher.getAllAppsController(),
- AllAppsTransitionController.ALL_APPS_PROGRESS,
- 1, OVERVIEW.getVerticalProgress(mLauncher));
- shiftAnim.setInterpolator(LINEAR);
- anim.play(shiftAnim);
-
- hotseat.setAlpha(0);
- ObjectAnimator fadeAnim = ObjectAnimator.ofFloat(hotseat, View.ALPHA, 1);
- fadeAnim.setInterpolator(LINEAR);
- anim.play(fadeAnim);
+ startProgress = 1;
} else {
- hotseat.setTranslationY(mTransitionDragLength);
- ObjectAnimator hotseatAnim = ObjectAnimator.ofFloat(hotseat, View.TRANSLATION_Y, 0);
- hotseatAnim.setInterpolator(LINEAR);
- anim.play(hotseatAnim);
-
- View scrim = mLauncher.findViewById(R.id.all_apps_scrim);
- scrim.setTranslationY(mTransitionDragLength);
- ObjectAnimator scrimAnim = ObjectAnimator.ofFloat(scrim, View.TRANSLATION_Y, 0);
- scrimAnim.setInterpolator(LINEAR);
- anim.play(scrimAnim);
+ float scrollRange = Math.max(controller.getShiftRange(), 1);
+ startProgress = (mTransitionDragLength / scrollRange) + 1;
}
+ AnimatorSet anim = new AnimatorSet();
+ ObjectAnimator shiftAnim = ObjectAnimator.ofFloat(controller, ALL_APPS_PROGRESS,
+ startProgress, OVERVIEW.getVerticalProgress(mLauncher));
+ shiftAnim.setInterpolator(LINEAR);
+ anim.play(shiftAnim);
// TODO: Link this animation to state animation, so that it is cancelled
// automatically on state change
@@ -452,7 +455,7 @@
@Override
public void onAnimationSuccess(Animator animator) {
setStateOnUiThread((Float.compare(mCurrentShift.value, 0) == 0)
- ? STATE_SCALED_SNAPSHOT_APP : STATE_SCALED_SNAPSHOT_RECENTS);
+ ? STATE_SCALED_CONTROLLER_APP : STATE_SCALED_CONTROLLER_RECENTS);
}
});
anim.start();
@@ -464,36 +467,32 @@
}
public void reset() {
+ setStateOnUiThread(STATE_HANDLER_INVALIDATED);
+ }
+
+ private void invalidateHandler() {
mCurrentShift.cancelAnimation();
if (mGestureEndCallback != null) {
mGestureEndCallback.run();
}
- if (mLauncher != null) {
- // TODO: These should be done as part of ActivityOptions#OnAnimationStarted
- mLauncher.getStateManager().reapplyState();
- mLauncher.setOnResumeCallback(() -> mLauncherLayoutListener.close(false));
-
- if (mLauncherTransitionController != null) {
- mLauncherTransitionController.setPlayFraction(1);
- }
- }
clearReference();
}
+ private void invalidateHandlerWithLauncher() {
+ mLauncherTransitionController = null;
+ mLauncherLayoutListener.setHandler(null);
+ mLauncherLayoutListener.close(false);
+ }
+
public void layoutListenerClosed() {
- if (mWasLauncherAlreadyVisible) {
+ if (mWasLauncherAlreadyVisible && mLauncherTransitionController != null) {
mLauncherTransitionController.setPlayFraction(1);
}
}
private void switchToScreenshot() {
- mLauncherLayoutListener.close(false);
- View currentRecentsPage = mRecentsView.getPageAt(mRecentsView.getCurrentPage());
- if (currentRecentsPage instanceof TaskView) {
- ((TaskView) currentRecentsPage).animateIconToScale(1f);
- }
if (mInteractionType == INTERACTION_QUICK_SWITCH) {
for (int i = mRecentsView.getFirstTaskIndex(); i < mRecentsView.getPageCount(); i++) {
TaskView taskView = (TaskView) mRecentsView.getPageAt(i);
@@ -527,7 +526,12 @@
}
}
- private void animateFirstTaskIcon() {
+ private void setupLauncherUiAfterSwipeUpAnimation() {
+ // Re apply state in case we did something funky during the transition.
+ mLauncher.getStateManager().reapplyState();
+
+
+ // Animate ui the first icon.
View currentRecentsPage = mRecentsView.getPageAt(mRecentsView.getCurrentPage());
if (currentRecentsPage instanceof TaskView) {
((TaskView) currentRecentsPage).animateIconToScale(1f);
diff --git a/res/drawable/ic_close.xml b/res/drawable/ic_close.xml
new file mode 100644
index 0000000..fc9ed49
--- /dev/null
+++ b/res/drawable/ic_close.xml
@@ -0,0 +1,23 @@
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout/hotseat.xml b/res/layout/hotseat.xml
index 582a83f..73c0e52 100644
--- a/res/layout/hotseat.xml
+++ b/res/layout/hotseat.xml
@@ -22,5 +22,6 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
- launcher:containerType="hotseat" />
+ launcher:containerType="hotseat"
+ android:importantForAccessibility="no" />
</com.android.launcher3.Hotseat>
diff --git a/res/layout/work_tab_bottom_user_education_view.xml b/res/layout/work_tab_bottom_user_education_view.xml
index 2a4ba5d..dc6854e 100644
--- a/res/layout/work_tab_bottom_user_education_view.xml
+++ b/res/layout/work_tab_bottom_user_education_view.xml
@@ -20,38 +20,48 @@
android:layout_gravity="bottom"
android:background="?android:attr/colorAccent"
android:elevation="2dp"
- android:orientation="horizontal"
- android:paddingLeft="20dp"
- android:paddingRight="20dp">
+ android:orientation="horizontal">
+
+ <ImageView
+ android:layout_width="134dp"
+ android:layout_height="134dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="20dp"
+ android:src="@drawable/work_tab_user_education"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="24dp"
+ android:orientation="vertical">
<ImageView
- android:layout_width="134dp"
- android:layout_height="134dp"
- android:layout_gravity="center_vertical"
- android:src="@drawable/work_tab_user_education"/>
+ android:id="@+id/close_bottom_user_tip"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginTop="12dp"
+ android:layout_marginEnd="12dp"
+ android:layout_gravity="right"
+ android:src="@drawable/ic_close"/>
- <LinearLayout
- android:layout_width="match_parent"
+ <TextView
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingBottom="12dp"
- android:paddingStart="24dp"
- android:paddingTop="12dp">
+ android:layout_marginTop="4dp"
+ android:layout_marginEnd="24dp"
+ android:fontFamily="roboto-medium"
+ android:text="@string/bottom_work_tab_user_education_title"
+ android:textColor="@android:color/white"
+ android:textSize="20sp"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:fontFamily="roboto-medium"
- android:text="@string/bottom_work_tab_user_education_title"
- android:textColor="@android:color/white"
- android:textSize="20sp"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="24dp"
+ android:text="@string/bottom_work_tab_user_education_body"
+ android:textColor="@android:color/white"
+ android:textSize="14sp"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/bottom_work_tab_user_education_body"
- android:textColor="@android:color/white"
- android:textSize="14sp"/>
- </LinearLayout>
+ </LinearLayout>
</com.android.launcher3.views.BottomUserEducationView>
\ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 2033d46..1351dfa 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -101,8 +101,6 @@
<!-- numFolderRows & numFolderColumns defaults to numRows & numColumns, if not specified -->
<attr name="numFolderRows" format="integer" />
<attr name="numFolderColumns" format="integer" />
- <!-- minAllAppsPredictionColumns defaults to numColumns, if not specified -->
- <attr name="minAllAppsPredictionColumns" format="integer" />
<!-- numHotseatIcons defaults to numColumns, if not specified -->
<attr name="numHotseatIcons" format="integer" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2aff936..1f46844 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -87,7 +87,6 @@
<dimen name="all_apps_header_tab_height">50dp</dimen>
<dimen name="all_apps_tabs_indicator_height">2dp</dimen>
<dimen name="all_apps_header_top_padding">36dp</dimen>
- <dimen name="all_apps_prediction_row_divider_height">17dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_bottom_padding">20dp</dimen>
<dimen name="all_apps_tabs_side_padding">12dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ee09946..2318e9e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -132,6 +132,11 @@
<!-- Accessibility -->
<!-- The format string for when an app is temporarily disabled. -->
<string name="disabled_app_label">Disabled <xliff:g id="app_name" example="Messenger">%1$s</xliff:g></string>
+ <!-- The format string for when an app has a notification dot (meaning it has associated notifications). -->
+ <plurals name="badged_app_label">
+ <item quantity="one"><xliff:g id="app_name" example="Messenger">%1$s</xliff:g>, has <xliff:g id="notification_count" example="1">%2$d</xliff:g> notification</item>
+ <item quantity="other"><xliff:g id="app_name" example="Messenger">%1$s</xliff:g>, has <xliff:g id="notification_count" example="3">%2$d</xliff:g> notifications</item>
+ </plurals>
<skip />
<!-- The format string for default page scroll text [CHAR_LIMIT=none] -->
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
index 30c1c54..a34f225 100644
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -25,7 +25,6 @@
launcher:numColumns="3"
launcher:numFolderRows="2"
launcher:numFolderColumns="3"
- launcher:minAllAppsPredictionColumns="3"
launcher:iconSize="48"
launcher:iconTextSize="13.0"
launcher:numHotseatIcons="3"
@@ -40,7 +39,6 @@
launcher:numColumns="3"
launcher:numFolderRows="3"
launcher:numFolderColumns="3"
- launcher:minAllAppsPredictionColumns="3"
launcher:iconSize="48"
launcher:iconTextSize="13.0"
launcher:numHotseatIcons="3"
@@ -55,7 +53,6 @@
launcher:numColumns="4"
launcher:numFolderRows="3"
launcher:numFolderColumns="4"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="48"
launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5"
@@ -70,7 +67,6 @@
launcher:numColumns="4"
launcher:numFolderRows="3"
launcher:numFolderColumns="4"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="48"
launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5"
@@ -85,7 +81,6 @@
launcher:numColumns="4"
launcher:numFolderRows="4"
launcher:numFolderColumns="4"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="48"
launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5"
@@ -100,7 +95,6 @@
launcher:numColumns="4"
launcher:numFolderRows="4"
launcher:numFolderColumns="4"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="54"
launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5"
@@ -115,7 +109,6 @@
launcher:numColumns="4"
launcher:numFolderRows="4"
launcher:numFolderColumns="4"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="54"
launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5"
@@ -130,7 +123,6 @@
launcher:numColumns="5"
launcher:numFolderRows="4"
launcher:numFolderColumns="4"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="56"
launcher:iconTextSize="14.4"
launcher:numHotseatIcons="5"
@@ -145,7 +137,6 @@
launcher:numColumns="6"
launcher:numFolderRows="4"
launcher:numFolderColumns="5"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="64"
launcher:iconTextSize="14.4"
launcher:numHotseatIcons="7"
@@ -160,7 +151,6 @@
launcher:numColumns="6"
launcher:numFolderRows="4"
launcher:numFolderColumns="5"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="76"
launcher:iconTextSize="14.4"
launcher:numHotseatIcons="7"
@@ -175,7 +165,6 @@
launcher:numColumns="7"
launcher:numFolderRows="6"
launcher:numFolderColumns="6"
- launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="100"
launcher:iconTextSize="20.0"
launcher:numHotseatIcons="7"
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 46d7227..dbdb2dc 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -560,6 +560,15 @@
invalidate();
}
}
+ if (itemInfo.contentDescription != null) {
+ if (hasBadge()) {
+ int count = mBadgeInfo.getNotificationCount();
+ setContentDescription(getContext().getResources().getQuantityString(
+ R.plurals.badged_app_label, count, itemInfo.contentDescription, count));
+ } else {
+ setContentDescription(itemInfo.contentDescription);
+ }
+ }
}
}
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 7a43198..246fa74 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -65,12 +65,6 @@
public int numColumns;
/**
- * The minimum number of predicted apps in all apps.
- */
- @Deprecated
- int minAllAppsPredictionColumns;
-
- /**
* Number of icons per row and column in the folder.
*/
public int numFolderRows;
@@ -99,12 +93,12 @@
public InvariantDeviceProfile(InvariantDeviceProfile p) {
this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns,
- p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns,
+ p.numFolderRows, p.numFolderColumns,
p.iconSize, p.landscapeIconSize, p.iconTextSize, p.numHotseatIcons,
p.defaultLayoutId, p.demoModeLayoutId);
}
- InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, int maapc,
+ InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc,
float is, float lis, float its, int hs, int dlId, int dmlId) {
name = n;
minWidthDps = w;
@@ -113,7 +107,6 @@
numColumns = c;
numFolderRows = fr;
numFolderColumns = fc;
- minAllAppsPredictionColumns = maapc;
iconSize = is;
landscapeIconSize = lis;
iconTextSize = its;
@@ -150,7 +143,6 @@
demoModeLayoutId = closestProfile.demoModeLayoutId;
numFolderRows = closestProfile.numFolderRows;
numFolderColumns = closestProfile.numFolderColumns;
- minAllAppsPredictionColumns = closestProfile.minAllAppsPredictionColumns;
iconSize = interpolatedDeviceProfileOut.iconSize;
landscapeIconSize = interpolatedDeviceProfileOut.landscapeIconSize;
@@ -207,7 +199,6 @@
numColumns,
a.getInt(R.styleable.InvariantDeviceProfile_numFolderRows, numRows),
a.getInt(R.styleable.InvariantDeviceProfile_numFolderColumns, numColumns),
- a.getInt(R.styleable.InvariantDeviceProfile_minAllAppsPredictionColumns, numColumns),
iconSize,
a.getFloat(R.styleable.InvariantDeviceProfile_landscapeIconSize, iconSize),
a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0),
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index fcf36ca..5da4944 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -20,7 +20,6 @@
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
-
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_BY_PUBLISHER;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_QUIET_USER;
@@ -40,7 +39,6 @@
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
-import android.app.ActivityOptions;
import android.app.AlertDialog;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager;
@@ -55,14 +53,12 @@
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@@ -450,6 +446,10 @@
return mStateManager;
}
+ public LauncherAppTransitionManager getAppTransitionManager() {
+ return mAppTransitionManager;
+ }
+
protected void overrideTheme(boolean isDark, boolean supportsDarkText) {
if (isDark) {
setTheme(R.style.LauncherThemeDark);
@@ -788,6 +788,7 @@
mStateManager.getState().containerType);
}
NotificationListener.removeNotificationsChangedListener();
+ getStateManager().moveToRestState();
}
@Override
@@ -2810,6 +2811,26 @@
return super.onKeyShortcut(keyCode, event);
}
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_MENU) {
+ // KEYCODE_MENU is sent by some tests, for example
+ // LauncherJankTests#testWidgetsContainerFling. Don't just remove its handling.
+ if (!mDragController.isDragging() && !mWorkspace.isSwitchingState() &&
+ isInState(NORMAL)) {
+ // Close any open floating views.
+ AbstractFloatingView.closeAllOpenViews(this);
+
+ // Setting the touch point to (-1, -1) will show the options popup in the center of
+ // the screen.
+ mLastDispatchTouchEvent.set(-1, -1);
+ UiFactory.onWorkspaceLongPress(this, mLastDispatchTouchEvent);
+ }
+ return true;
+ }
+ return super.onKeyUp(keyCode, event);
+ }
+
public static Launcher getLauncher(Context context) {
if (context instanceof Launcher) {
return (Launcher) context;
diff --git a/src/com/android/launcher3/LauncherAppTransitionManager.java b/src/com/android/launcher3/LauncherAppTransitionManager.java
index be2dc54..c0d52c1 100644
--- a/src/com/android/launcher3/LauncherAppTransitionManager.java
+++ b/src/com/android/launcher3/LauncherAppTransitionManager.java
@@ -64,4 +64,8 @@
public Bundle getActivityLaunchOptions(Launcher launcher, View v) {
return getDefaultActivityLaunchOptions(launcher, v);
}
+
+ /** Cancels the current transition animation */
+ public void finishAnimation() {
+ }
}
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 8eeeec3..4aed520 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -85,6 +85,8 @@
private LauncherState mLastStableState = NORMAL;
private LauncherState mCurrentStableState = NORMAL;
+ private LauncherState mRestState;
+
private StateListener mStateListener;
public LauncherStateManager(Launcher l) {
@@ -269,6 +271,13 @@
// Only disable clipping if needed, otherwise leave it as previous value.
mLauncher.getWorkspace().setClipChildren(false);
}
+
+ // If we are still animating to launcher from an app,
+ // finish it and let this state animation take over.
+ LauncherAppTransitionManager transitionManager = mLauncher.getAppTransitionManager();
+ if (transitionManager != null) {
+ transitionManager.finishAnimation();
+ }
}
private void onStateTransitionEnd(LauncherState state) {
@@ -282,12 +291,32 @@
mLauncher.getWorkspace().setClipChildren(!state.disablePageClipping);
mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
mLauncher.finishAutoCancelActionMode();
+
+ if (state == NORMAL) {
+ setRestState(null);
+ }
}
public LauncherState getLastState() {
return mLastStableState;
}
+ public void moveToRestState() {
+ if (mState.disableRestore) {
+ goToState(getRestState());
+ // Reset history
+ mLastStableState = NORMAL;
+ }
+ }
+
+ public LauncherState getRestState() {
+ return mRestState == null ? NORMAL : mRestState;
+ }
+
+ public void setRestState(LauncherState restState) {
+ mRestState = restState;
+ }
+
/**
* Cancels the current animation.
*/
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index b5c9af2..98b32f8 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -58,7 +58,6 @@
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
-import com.android.launcher3.util.ComponentKeyMapper;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.views.BottomUserEducationView;
@@ -87,11 +86,7 @@
private SpannableStringBuilder mSearchQueryBuilder = null;
- private int mNumAppsPerRow;
- private int mNumPredictedAppsPerRow;
-
private boolean mUsingTabs;
- private boolean mHasPredictions = false;
private boolean mSearchModeWhileUsingTabs = false;
public AllAppsContainerView(Context context) {
@@ -253,21 +248,6 @@
}
@Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- DeviceProfile grid = mLauncher.getDeviceProfile();
-
- if (mNumAppsPerRow != grid.inv.numColumns ||
- mNumPredictedAppsPerRow != grid.inv.numColumns) {
- mNumAppsPerRow = grid.inv.numColumns;
- mNumPredictedAppsPerRow = grid.inv.numColumns;
- for (int i = 0; i < mAH.length; i++) {
- mAH[i].applyNumsPerRow();
- }
- }
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
-
- @Override
public boolean dispatchKeyEvent(KeyEvent event) {
mSearchUiManager.preDispatchKeyEvent(event);
return super.dispatchKeyEvent(event);
@@ -378,17 +358,12 @@
mAH[AdapterHolder.MAIN].setup(mViewPager.getChildAt(0), mPersonalMatcher);
mAH[AdapterHolder.WORK].setup(mViewPager.getChildAt(1), mWorkMatcher);
setupWorkProfileTabs();
- setupHeader();
} else {
mTabsPagerAdapter = null;
mAH[AdapterHolder.MAIN].setup(findViewById(R.id.apps_list_view), null);
mAH[AdapterHolder.WORK].recyclerView = null;
- if (FeatureFlags.ALL_APPS_PREDICTION_ROW_VIEW) {
- setupHeader();
- } else {
- mHeader.setVisibility(View.GONE);
- }
}
+ setupHeader();
mAllAppsStore.registerIconContainer(mAH[AdapterHolder.MAIN].recyclerView);
mAllAppsStore.registerIconContainer(mAH[AdapterHolder.WORK].recyclerView);
@@ -465,46 +440,21 @@
.setOnClickListener((View view) -> mViewPager.setCurrentItem(1));
}
- public void setPredictedApps(List<ComponentKeyMapper<AppInfo>> apps) {
- mAH[AdapterHolder.MAIN].appsList.setPredictedApps(apps);
- boolean hasPredictions = !apps.isEmpty();
- if (mHasPredictions != hasPredictions) {
- mHasPredictions = hasPredictions;
- if (FeatureFlags.ALL_APPS_PREDICTION_ROW_VIEW) {
- setupHeader();
- }
- }
- }
-
- public AppInfo findApp(ComponentKeyMapper<AppInfo> mapper) {
- return mAllAppsStore.getApp(mapper);
- }
-
public AlphabeticalAppsList getApps() {
return mAH[AdapterHolder.MAIN].appsList;
}
- public boolean isUsingTabs() {
- return mUsingTabs;
- }
-
public FloatingHeaderView getFloatingHeaderView() {
return mHeader;
}
public void setupHeader() {
- if (mHeader == null) {
- return;
- }
mHeader.setVisibility(View.VISIBLE);
mHeader.setup(mAH, mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView == null);
int padding = mHeader.getMaxTranslation();
- if (mHasPredictions && !mUsingTabs) {
- padding += mHeader.getPaddingTop() + mHeader.getPaddingBottom();
- }
for (int i = 0; i < mAH.length; i++) {
- mAH[i].paddingTopForTabs = padding;
+ mAH[i].padding.top = padding;
mAH[i].applyPadding();
}
}
@@ -534,13 +484,6 @@
}
}
- public void setRecyclerViewPaddingTop(int top) {
- for (int i = 0; i < mAH.length; i++) {
- mAH[i].padding.top = top;
- mAH[i].applyPadding();
- }
- }
-
public void setRecyclerViewVerticalFadingEdgeEnabled(boolean enabled) {
for (int i = 0; i < mAH.length; i++) {
mAH[i].applyVerticalFadingEdgeEnabled(enabled);
@@ -572,7 +515,6 @@
final SpringAnimationHandler animationHandler;
final AlphabeticalAppsList appsList;
final Rect padding = new Rect();
- int paddingTopForTabs;
AllAppsRecyclerView recyclerView;
boolean verticalFadingEdge;
@@ -603,24 +545,11 @@
adapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
applyVerticalFadingEdgeEnabled(verticalFadingEdge);
applyPadding();
- applyNumsPerRow();
}
void applyPadding() {
if (recyclerView != null) {
- int paddingTop = mUsingTabs || FeatureFlags.ALL_APPS_PREDICTION_ROW_VIEW
- ? paddingTopForTabs : padding.top;
- recyclerView.setPadding(padding.left, paddingTop, padding.right, padding.bottom);
- }
- }
-
- void applyNumsPerRow() {
- if (mNumAppsPerRow > 0) {
- if (recyclerView != null) {
- recyclerView.setNumAppsPerRow(mLauncher.getDeviceProfile(), mNumAppsPerRow);
- }
- adapter.setNumAppsPerRow(mNumAppsPerRow);
- appsList.setNumAppsPerRow(mNumAppsPerRow, mNumPredictedAppsPerRow);
+ recyclerView.setPadding(padding.left, padding.top, padding.right, padding.bottom);
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 2103106..a61521c 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -56,29 +56,22 @@
// A normal icon
public static final int VIEW_TYPE_ICON = 1 << 1;
- // A prediction icon
- public static final int VIEW_TYPE_PREDICTION_ICON = 1 << 2;
// The message shown when there are no filtered results
- public static final int VIEW_TYPE_EMPTY_SEARCH = 1 << 3;
+ public static final int VIEW_TYPE_EMPTY_SEARCH = 1 << 2;
// The message to continue to a market search when there are no filtered results
- public static final int VIEW_TYPE_SEARCH_MARKET = 1 << 4;
+ public static final int VIEW_TYPE_SEARCH_MARKET = 1 << 3;
// We use various dividers for various purposes. They share enough attributes to reuse layouts,
// but differ in enough attributes to require different view types
// A divider that separates the apps list and the search market button
- public static final int VIEW_TYPE_ALL_APPS_DIVIDER = 1 << 5;
- // The divider that separates prediction icons from the app list
- public static final int VIEW_TYPE_PREDICTION_DIVIDER = 1 << 6;
- public static final int VIEW_TYPE_WORK_TAB_FOOTER = 1 << 7;
+ public static final int VIEW_TYPE_ALL_APPS_DIVIDER = 1 << 4;
+ public static final int VIEW_TYPE_WORK_TAB_FOOTER = 1 << 5;
// Common view type masks
- public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER
- | VIEW_TYPE_PREDICTION_DIVIDER;
- public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON
- | VIEW_TYPE_PREDICTION_ICON;
- public static final int VIEW_TYPE_MASK_HAS_SPRINGS = VIEW_TYPE_MASK_ICON
- | VIEW_TYPE_PREDICTION_DIVIDER;
+ public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER;
+ public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON;
+ public static final int VIEW_TYPE_MASK_HAS_SPRINGS = VIEW_TYPE_MASK_ICON;
public interface BindViewCallback {
@@ -192,7 +185,7 @@
private final View.OnClickListener mIconClickListener;
private final View.OnLongClickListener mIconLongClickListener;
- private int mAppsPerRow;
+ private final int mAppsPerRow;
private BindViewCallback mBindViewCallback;
private OnFocusChangeListener mIconFocusListener;
@@ -222,6 +215,9 @@
} else {
mSpringAnimationHandler = null;
}
+
+ mAppsPerRow = mLauncher.getDeviceProfile().inv.numColumns;
+ mGridLayoutMgr.setSpanCount(mAppsPerRow);
}
public SpringAnimationHandler getSpringAnimationHandler() {
@@ -240,18 +236,6 @@
return (viewType & viewTypeMask) != 0;
}
- /**
- * Sets the number of apps per row.
- */
- public void setNumAppsPerRow(int appsPerRow) {
- mAppsPerRow = appsPerRow;
- mGridLayoutMgr.setSpanCount(appsPerRow);
- }
-
- public int getNumAppsPerRow() {
- return mAppsPerRow;
- }
-
public void setIconFocusListener(OnFocusChangeListener focusListener) {
mIconFocusListener = focusListener;
}
@@ -284,7 +268,6 @@
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case VIEW_TYPE_ICON:
- case VIEW_TYPE_PREDICTION_ICON:
BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate(
R.layout.all_apps_icon, parent, false);
icon.setOnClickListener(mIconClickListener);
@@ -308,7 +291,6 @@
}
});
return new ViewHolder(searchMarketView);
- case VIEW_TYPE_PREDICTION_DIVIDER:
case VIEW_TYPE_ALL_APPS_DIVIDER:
return new ViewHolder(mLayoutInflater.inflate(
R.layout.all_apps_divider, parent, false));
@@ -324,7 +306,6 @@
public void onBindViewHolder(ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case VIEW_TYPE_ICON:
- case VIEW_TYPE_PREDICTION_ICON:
AppInfo info = mApps.getAdapterItems().get(position).appInfo;
BubbleTextView icon = (BubbleTextView) holder.itemView;
icon.reset();
@@ -427,10 +408,7 @@
*/
@Override
public void update(SpringAnimation spring, ViewHolder vh) {
- int numPredictedApps = Math.min(mAppsPerRow, mApps.getPredictedApps().size());
- int appPosition = getAppPosition(vh.getAdapterPosition(), numPredictedApps,
- mAppsPerRow);
-
+ int appPosition = vh.getAdapterPosition();
int col = appPosition % mAppsPerRow;
int row = appPosition / mAppsPerRow;
@@ -473,31 +451,6 @@
}
/**
- * @return The app position is the position of the app in the Adapter if we ignored all
- * other view types.
- *
- * The first app is at position 0, and the first app each following row is at a
- * position that is a multiple of {@param appsPerRow}.
- *
- * ie. If there are 5 apps per row, and there are two rows of apps:
- * 0 1 2 3 4
- * 5 6 7 8 9
- */
- private int getAppPosition(int position, int numPredictedApps, int appsPerRow) {
- if (position < numPredictedApps) {
- // Predicted apps are first in the adapter.
- return position;
- }
-
- // There is at most 1 divider view between the predicted apps and the alphabetical apps.
- int numDividerViews = numPredictedApps == 0 ? 0 : 1;
-
- // This offset takes into consideration an incomplete row of predicted apps.
- int numPredictedAppsOffset = appsPerRow - numPredictedApps;
- return position + numPredictedAppsOffset - numDividerViews;
- }
-
- /**
* Increase the column factor as the distance increases between the column and the center
* column(s).
*/
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 4792cc2..a16d00b 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -28,9 +28,10 @@
import android.view.View;
import com.android.launcher3.BaseRecyclerView;
-import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ItemInfo;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.anim.SpringAnimationHandler;
import com.android.launcher3.config.FeatureFlags;
@@ -51,7 +52,7 @@
private AlphabeticalAppsList mApps;
private AllAppsFastScrollHelper mFastScrollHelper;
- private int mNumAppsPerRow;
+ private final int mNumAppsPerRow;
// The specific view heights that we use to calculate scroll
private SparseIntArray mViewHeights = new SparseIntArray();
@@ -101,6 +102,8 @@
mOverScrollHelper = new OverScrollHelper();
mPullDetector = new SwipeDetector(getContext(), mOverScrollHelper, SwipeDetector.VERTICAL);
mPullDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, true);
+
+ mNumAppsPerRow = LauncherAppState.getIDP(context).numColumns;
}
public void setSpringAnimationHandler(SpringAnimationHandler springAnimationHandler) {
@@ -131,19 +134,14 @@
return mApps;
}
- /**
- * Sets the number of apps per row in this recycler view.
- */
- public void setNumAppsPerRow(DeviceProfile grid, int numAppsPerRow) {
- mNumAppsPerRow = numAppsPerRow;
+ private void updatePoolSize() {
+ DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, approxRows * mNumAppsPerRow);
- pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON, mNumAppsPerRow);
- pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER, 1);
}
/**
@@ -154,7 +152,6 @@
View icon = adapter.onCreateViewHolder(this, AllAppsGridAdapter.VIEW_TYPE_ICON).itemView;
final int iconHeight = icon.getLayoutParams().height;
mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_ICON, iconHeight);
- mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON, iconHeight);
final int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(
getResources().getDisplayMetrics().widthPixels, View.MeasureSpec.AT_MOST);
@@ -162,7 +159,6 @@
getResources().getDisplayMetrics().heightPixels, View.MeasureSpec.AT_MOST);
putSameHeightFor(adapter, widthMeasureSpec, heightMeasureSpec,
- AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER,
AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER);
putSameHeightFor(adapter, widthMeasureSpec, heightMeasureSpec,
AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET);
@@ -229,6 +225,7 @@
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
updateEmptySearchBackgroundBounds();
+ updatePoolSize();
}
@Override
@@ -236,19 +233,6 @@
if (mApps.hasFilter()) {
targetParent.containerType = ContainerType.SEARCHRESULT;
} else {
- if (v instanceof BubbleTextView) {
- BubbleTextView icon = (BubbleTextView) v;
- int position = getChildPosition(icon);
- if (position != NO_POSITION) {
- List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
- AlphabeticalAppsList.AdapterItem item = items.get(position);
- if (item.viewType == AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON) {
- targetParent.containerType = ContainerType.PREDICTION;
- target.predictedRank = item.rowAppIndex;
- return;
- }
- }
- }
targetParent.containerType = ContainerType.ALLAPPS;
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java
index 17f1c89..846b6a9 100644
--- a/src/com/android/launcher3/allapps/AllAppsStore.java
+++ b/src/com/android/launcher3/allapps/AllAppsStore.java
@@ -21,7 +21,6 @@
import com.android.launcher3.AppInfo;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.util.ComponentKey;
-import com.android.launcher3.util.ComponentKeyMapper;
import java.util.ArrayList;
import java.util.Collection;
@@ -53,10 +52,6 @@
return mComponentToAppMap.get(key);
}
- public AppInfo getApp(ComponentKeyMapper<AppInfo> mapper) {
- return mapper.getItem(mComponentToAppMap);
- }
-
/**
* Adds or updates existing apps in the list
*/
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 29b32b0..434918d 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -17,19 +17,13 @@
import android.content.Context;
import android.content.pm.PackageManager;
-import android.os.Process;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.util.Log;
import com.android.launcher3.AppInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AlphabeticIndexCompat;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.util.ComponentKey;
-import com.android.launcher3.util.ComponentKeyMapper;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LabelComparator;
@@ -47,8 +41,6 @@
public class AlphabeticalAppsList implements AllAppsStore.OnUpdateListener {
public static final String TAG = "AlphabeticalAppsList";
- private static final boolean DEBUG = false;
- private static final boolean DEBUG_PREDICTIONS = false;
private static final int FAST_SCROLL_FRACTION_DISTRIBUTE_BY_ROWS_FRACTION = 0;
private static final int FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS = 1;
@@ -95,13 +87,6 @@
// The index of this app not including sections
public int appIndex = -1;
- public static AdapterItem asPredictedApp(int pos, String sectionName, AppInfo appInfo,
- int appIndex) {
- AdapterItem item = asApp(pos, sectionName, appInfo, appIndex);
- item.viewType = AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON;
- return item;
- }
-
public static AdapterItem asApp(int pos, String sectionName, AppInfo appInfo,
int appIndex) {
AdapterItem item = new AdapterItem();
@@ -120,13 +105,6 @@
return item;
}
- public static AdapterItem asPredictionDivider(int pos) {
- AdapterItem item = new AdapterItem();
- item.viewType = AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER;
- item.position = pos;
- return item;
- }
-
public static AdapterItem asAllAppsDivider(int pos) {
AdapterItem item = new AdapterItem();
item.viewType = AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER;
@@ -151,7 +129,7 @@
private final Launcher mLauncher;
- // The set of apps from the system not including predictions
+ // The set of apps from the system
private final List<AppInfo> mApps = new ArrayList<>();
private final AllAppsStore mAllAppsStore;
@@ -161,10 +139,6 @@
private final ArrayList<AdapterItem> mAdapterItems = new ArrayList<>();
// The set of sections that we allow fast-scrolling to (includes non-merged sections)
private final List<FastScrollSectionInfo> mFastScrollerSections = new ArrayList<>();
- // The set of predicted app component names
- private final List<ComponentKeyMapper<AppInfo>> mPredictedAppComponents = new ArrayList<>();
- // The set of predicted apps resolved from the component names and the current set of apps
- private final List<AppInfo> mPredictedApps = new ArrayList<>();
// Is it the work profile app list.
private final boolean mIsWork;
@@ -174,8 +148,7 @@
private AllAppsGridAdapter mAdapter;
private AlphabeticIndexCompat mIndexer;
private AppInfoComparator mAppNameComparator;
- private int mNumAppsPerRow;
- private int mNumPredictedAppsPerRow;
+ private final int mNumAppsPerRow;
private int mNumAppRowsInAdapter;
private ItemInfoMatcher mItemFilter;
@@ -185,6 +158,7 @@
mIndexer = new AlphabeticIndexCompat(context);
mAppNameComparator = new AppInfoComparator(context);
mIsWork = isWork;
+ mNumAppsPerRow = mLauncher.getDeviceProfile().inv.numColumns;
mAllAppsStore.addUpdateListener(this);
}
@@ -194,16 +168,6 @@
}
/**
- * Sets the number of apps per row.
- */
- public void setNumAppsPerRow(int numAppsPerRow, int numPredictedAppsPerRow) {
- mNumAppsPerRow = numAppsPerRow;
- mNumPredictedAppsPerRow = numPredictedAppsPerRow;
-
- updateAdapterItems();
- }
-
- /**
* Sets the adapter to notify when this dataset changes.
*/
public void setAdapter(AllAppsGridAdapter adapter) {
@@ -218,13 +182,6 @@
}
/**
- * Returns the predicted apps.
- */
- public List<AppInfo> getPredictedApps() {
- return mPredictedApps;
- }
-
- /**
* Returns fast scroller sections of all the current filtered applications.
*/
public List<FastScrollSectionInfo> getFastScrollerSections() {
@@ -239,7 +196,7 @@
}
/**
- * Returns the number of rows of applications (not including predictions)
+ * Returns the number of rows of applications
*/
public int getNumAppRows() {
return mNumAppRowsInAdapter;
@@ -279,80 +236,6 @@
return false;
}
- private List<AppInfo> processPredictedAppComponents(List<ComponentKeyMapper<AppInfo>> components) {
- if (mAllAppsStore.getApps().isEmpty()) {
- // Apps have not been bound yet.
- return Collections.emptyList();
- }
-
- List<AppInfo> predictedApps = new ArrayList<>();
- for (ComponentKeyMapper<AppInfo> mapper : components) {
- AppInfo info = mAllAppsStore.getApp(mapper);
- if (info != null) {
- predictedApps.add(info);
- } else {
- if (FeatureFlags.IS_DOGFOOD_BUILD) {
- Log.e(TAG, "Predicted app not found: " + mapper);
- }
- }
- // Stop at the number of predicted apps
- if (predictedApps.size() == mNumPredictedAppsPerRow) {
- break;
- }
- }
- return predictedApps;
- }
-
- /**
- * Sets the current set of predicted apps.
- *
- * This can be called before we get the full set of applications, we should merge the results
- * only in onAppsUpdated() which is idempotent.
- *
- * If the number of predicted apps is the same as the previous list of predicted apps,
- * we can optimize by swapping them in place.
- */
- public void setPredictedApps(List<ComponentKeyMapper<AppInfo>> apps) {
- mPredictedAppComponents.clear();
- mPredictedAppComponents.addAll(apps);
-
- List<AppInfo> newPredictedApps = processPredictedAppComponents(apps);
- // We only need to do work if any of the visible predicted apps have changed.
- if (!newPredictedApps.equals(mPredictedApps)) {
- if (newPredictedApps.size() == mPredictedApps.size()) {
- swapInNewPredictedApps(newPredictedApps);
- } else {
- // We need to update the appIndex of all the items.
- onAppsUpdated();
- }
- }
- }
-
- /**
- * Swaps out the old predicted apps with the new predicted apps, in place. This optimization
- * allows us to skip an entire relayout that would otherwise be called by notifyDataSetChanged.
- *
- * Note: This should only be called if the # of predicted apps is the same.
- * This method assumes that predicted apps are the first items in the adapter.
- */
- private void swapInNewPredictedApps(List<AppInfo> apps) {
- mPredictedApps.clear();
- mPredictedApps.addAll(apps);
-
- int size = apps.size();
- for (int i = 0; i < size; ++i) {
- AppInfo info = apps.get(i);
- AdapterItem orgItem = mAdapterItems.get(i);
- AdapterItem newItem = AdapterItem.asPredictedApp(orgItem.position, "", info,
- orgItem.appIndex);
- newItem.rowAppIndex = orgItem.rowAppIndex;
-
- mAdapterItems.set(i, newItem);
- mFilteredApps.set(i, info);
- mAdapter.notifyItemChanged(i);
- }
- }
-
/**
* Updates internals when the set of apps are updated.
*/
@@ -433,47 +316,6 @@
mFastScrollerSections.clear();
mAdapterItems.clear();
- if (!FeatureFlags.ALL_APPS_PREDICTION_ROW_VIEW) {
- if (DEBUG_PREDICTIONS) {
- if (mPredictedAppComponents.isEmpty() && !mApps.isEmpty()) {
- mPredictedAppComponents.add(new ComponentKeyMapper<AppInfo>(new ComponentKey(mApps.get(0).componentName,
- Process.myUserHandle())));
- mPredictedAppComponents.add(new ComponentKeyMapper<AppInfo>(new ComponentKey(mApps.get(0).componentName,
- Process.myUserHandle())));
- mPredictedAppComponents.add(new ComponentKeyMapper<AppInfo>(new ComponentKey(mApps.get(0).componentName,
- Process.myUserHandle())));
- mPredictedAppComponents.add(new ComponentKeyMapper<AppInfo>(new ComponentKey(mApps.get(0).componentName,
- Process.myUserHandle())));
- }
- }
-
- // Process the predicted app components
- mPredictedApps.clear();
- if (mPredictedAppComponents != null && !mPredictedAppComponents.isEmpty() && !hasFilter()) {
- mPredictedApps.addAll(processPredictedAppComponents(mPredictedAppComponents));
-
- if (!mPredictedApps.isEmpty()) {
- // Add a section for the predictions
- lastFastScrollerSectionInfo = new FastScrollSectionInfo("");
- mFastScrollerSections.add(lastFastScrollerSectionInfo);
-
- // Add the predicted app items
- for (AppInfo info : mPredictedApps) {
- AdapterItem appItem = AdapterItem.asPredictedApp(position++, "", info,
- appIndex++);
- if (lastFastScrollerSectionInfo.fastScrollToItem == null) {
- lastFastScrollerSectionInfo.fastScrollToItem = appItem;
- }
- mAdapterItems.add(appItem);
- mFilteredApps.add(info);
- }
-
- mAdapterItems.add(AdapterItem.asPredictionDivider(position++));
- }
- }
-
- }
-
// Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
// ordered set of sections
for (AppInfo info : getFiltersAppInfos()) {
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 059b04e..e494bea 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -53,8 +53,6 @@
// When enabled shows a work profile tab in all apps
public static final boolean ALL_APPS_TABS_ENABLED = true;
- // When enabled prediction row is rendered as it's own custom view
- public static final boolean ALL_APPS_PREDICTION_ROW_VIEW = true;
public static final boolean ENABLE_TWO_SWIPE_TARGETS = true;
}
diff --git a/src/com/android/launcher3/util/ComponentKeyMapper.java b/src/com/android/launcher3/util/ComponentKeyMapper.java
deleted file mode 100644
index a7f0d76..0000000
--- a/src/com/android/launcher3/util/ComponentKeyMapper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.android.launcher3.util;
-
-/**
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import android.support.annotation.Nullable;
-
-import java.util.Map;
-
-public class ComponentKeyMapper<T> {
-
- protected final ComponentKey mComponentKey;
-
- public ComponentKeyMapper(ComponentKey key) {
- this.mComponentKey = key;
- }
-
- public @Nullable T getItem(Map<ComponentKey, T> map) {
- return map.get(mComponentKey);
- }
-
- public String getPackage() {
- return mComponentKey.componentName.getPackageName();
- }
-
- public String getComponentClass() {
- return mComponentKey.componentName.getClassName();
- }
-
- @Override
- public String toString() {
- return mComponentKey.toString();
- }
-
-}
diff --git a/src/com/android/launcher3/views/BottomUserEducationView.java b/src/com/android/launcher3/views/BottomUserEducationView.java
index d79d0ce..ba78cf6 100644
--- a/src/com/android/launcher3/views/BottomUserEducationView.java
+++ b/src/com/android/launcher3/views/BottomUserEducationView.java
@@ -20,7 +20,8 @@
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.LayoutInflater;
-
+import android.view.TouchDelegate;
+import android.view.View;
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
@@ -34,6 +35,8 @@
private final Rect mInsets = new Rect();
+ private View mCloseButton;
+
public BottomUserEducationView(Context context, AttributeSet attr) {
this(context, attr, 0);
}
@@ -45,9 +48,17 @@
}
@Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mCloseButton = findViewById(R.id.close_bottom_user_tip);
+ mCloseButton.setOnClickListener(view -> handleClose(true));
+ }
+
+ @Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
setTranslationShift(mTranslationShift);
+ expandTouchAreaOfCloseButton();
}
@Override
@@ -110,4 +121,15 @@
launcher.getDragLayer().addView(bottomUserEducationView);
bottomUserEducationView.open(true);
}
+
+ private void expandTouchAreaOfCloseButton() {
+ Rect hitRect = new Rect();
+ mCloseButton.getHitRect(hitRect);
+ hitRect.left -= mCloseButton.getWidth();
+ hitRect.top -= mCloseButton.getHeight();
+ hitRect.right += mCloseButton.getWidth();
+ hitRect.bottom += mCloseButton.getHeight();
+ View parent = (View) mCloseButton.getParent();
+ parent.setTouchDelegate(new TouchDelegate(hitRect, mCloseButton));
+ }
}