Merge "Check for permission before registering remote animations to prevent crash." into ub-launcher3-master
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 9cc7973..bdc7c36 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -37,6 +37,4 @@
<!-- Launcher app transition -->
<dimen name="content_trans_y">25dp</dimen>
<dimen name="workspace_trans_y">80dp</dimen>
-
- <dimen name="shelf_min_value">-2.857dp</dimen>
</resources>
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
index 256e926..47179c5 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
@@ -16,7 +16,7 @@
package com.android.launcher3;
-import static com.android.launcher3.views.AllAppsScrim.SCRIM_PROGRESS;
+import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.systemui.shared.recents.utilities.Utilities.getNextFrameNumber;
import static com.android.systemui.shared.recents.utilities.Utilities.getSurface;
import static com.android.systemui.shared.recents.utilities.Utilities.postAtFrontOfQueueAsynchronously;
@@ -40,9 +40,9 @@
import android.widget.ImageView;
import com.android.launcher3.InsettableFrameLayout.LayoutParams;
+import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragLayer;
-import com.android.launcher3.views.AllAppsScrim;
import com.android.systemui.shared.system.ActivityCompat;
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
@@ -62,14 +62,16 @@
private static final int CLOSING_TRANSITION_DURATION_MS = 350;
+ // Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
+ private static final float ALL_APPS_PROGRESS_START = 1.3059858f;
+ private static final float ALL_APPS_PROGRESS_SLIDE_END = 0.99581414f;
+
private final DragLayer mDragLayer;
private final Launcher mLauncher;
private final DeviceProfile mDeviceProfile;
private final float mContentTransY;
private final float mWorkspaceTransY;
- // The smallest y-value the shelf will reach on screen, before overshooting back down to 0.
- private final float mShelfMinValue;
private ImageView mFloatingView;
private boolean mIsRtl;
@@ -84,7 +86,6 @@
Resources res = launcher.getResources();
mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y);
mWorkspaceTransY = res.getDimensionPixelSize(R.dimen.workspace_trans_y);
- mShelfMinValue = res.getDimensionPixelSize(R.dimen.shelf_min_value);
}
/**
@@ -477,31 +478,29 @@
workspaceAnimator.setDuration(333);
workspaceAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
- // Animate the shelf
- AllAppsScrim allAppsScrim = mLauncher.findViewById(R.id.all_apps_scrim);
- View hotseat = mLauncher.getHotseat();
- final float endY = mShelfMinValue;
- int startY = hotseat.getMeasuredHeight()
- + (allAppsScrim.getShadowBitmap().getHeight() / 2);
- hotseat.setTranslationY(startY);
- allAppsScrim.setTranslationY(startY);
+ // Animate the shelf in two parts: slide in, and overeshoot.
+ AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
+ // The shelf will start offscreen
+ final float startY = ALL_APPS_PROGRESS_START;
+ // And will end slightly pulled up, so that there is something to overshoot back to 1f.
+ final float slideEnd = ALL_APPS_PROGRESS_SLIDE_END;
- AnimatorSet hotseatSlideIn = new AnimatorSet();
- hotseatSlideIn.play(ObjectAnimator.ofFloat(hotseat, View.TRANSLATION_Y, startY, endY));
- hotseatSlideIn.play(ObjectAnimator.ofFloat(allAppsScrim, SCRIM_PROGRESS, startY, endY));
- hotseatSlideIn.setStartDelay(150);
- hotseatSlideIn.setDuration(317);
- hotseatSlideIn.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+ allAppsController.setProgress(startY);
- AnimatorSet hotseatOvershoot = new AnimatorSet();
- hotseatOvershoot.play(ObjectAnimator.ofFloat(hotseat, View.TRANSLATION_Y, endY, 0));
- hotseatOvershoot.play(ObjectAnimator.ofFloat(allAppsScrim, SCRIM_PROGRESS, endY, 0));
- hotseatOvershoot.setDuration(153);
- hotseatOvershoot.setInterpolator(Interpolators.OVERSHOOT_0);
+ Animator allAppsSlideIn =
+ ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, startY, slideEnd);
+ allAppsSlideIn.setStartDelay(150);
+ allAppsSlideIn.setDuration(317);
+ allAppsSlideIn.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+
+ Animator allAppsOvershoot =
+ ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, slideEnd, 1f);
+ allAppsOvershoot.setDuration(153);
+ allAppsOvershoot.setInterpolator(Interpolators.OVERSHOOT_0);
AnimatorSet resumeLauncherAnimation = new AnimatorSet();
resumeLauncherAnimation.play(workspaceAnimator);
- resumeLauncherAnimation.playSequentially(hotseatSlideIn, hotseatOvershoot);
+ resumeLauncherAnimation.playSequentially(allAppsSlideIn, allAppsOvershoot);
return resumeLauncherAnimation;
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java b/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java
new file mode 100644
index 0000000..92aa1fd
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package com.android.launcher3.uioverrides;
+
+import android.view.MotionEvent;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.util.TouchController;
+import com.android.quickstep.QuickScrubController;
+import com.android.quickstep.RecentsView;
+
+/**
+ * Consumes touches when quick scrub is enabled.
+ */
+public class IgnoreTouchesInQuickScrub implements TouchController {
+
+ private QuickScrubController mQuickScrubController;
+
+ public IgnoreTouchesInQuickScrub(Launcher l) {
+ mQuickScrubController = ((RecentsView) l.getOverviewPanel()).getQuickScrubController();
+ }
+
+ @Override
+ public boolean onControllerTouchEvent(MotionEvent ev) {
+ return true;
+ }
+
+ @Override
+ public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+ return mQuickScrubController.isQuickScrubEnabled();
+ }
+}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index 8a7b257..1c92f2c 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -42,12 +42,14 @@
public static TouchController[] createTouchControllers(Launcher launcher) {
if (FeatureFlags.ENABLE_TWO_SWIPE_TARGETS) {
- return new TouchController[]{
+ return new TouchController[] {
+ new IgnoreTouchesInQuickScrub(launcher),
new EdgeSwipeController(launcher),
new TwoStepSwipeController(launcher),
new OverviewSwipeController(launcher)};
} else {
- return new TouchController[]{
+ return new TouchController[] {
+ new IgnoreTouchesInQuickScrub(launcher),
new TwoStepSwipeController(launcher),
new OverviewSwipeController(launcher)};
}
diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
index eb5195c..b295df0 100644
--- a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
+++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
@@ -15,6 +15,11 @@
*/
package com.android.quickstep;
+import static com.android.quickstep.TouchInteractionService.INTERACTION_NORMAL;
+import static com.android.quickstep.TouchInteractionService.INTERACTION_QUICK_SCRUB;
+import static com.android.quickstep.TouchInteractionService.INTERACTION_QUICK_SWITCH;
+import static com.android.quickstep.TouchInteractionService.isInteractionQuick;
+
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.RectEvaluator;
@@ -44,8 +49,9 @@
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.states.InternalStateHandler;
-import com.android.launcher3.uioverrides.RecentsViewStateController;
+import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.TraceHelper;
+import com.android.quickstep.TouchInteractionService.InteractionType;
import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task.TaskKey;
@@ -93,20 +99,22 @@
private Launcher mLauncher;
private SnapshotDragView mDragView;
private RecentsView mRecentsView;
- private RecentsViewStateController mStateController;
private QuickScrubController mQuickScrubController;
private Hotseat mHotseat;
+ private boolean mWasLauncherAlreadyVisible;
+
private boolean mLauncherReady;
private boolean mTouchEndHandled;
private float mCurrentDisplacement;
- private @TouchInteractionService.InteractionType int mInteractionType;
+
+ private @InteractionType int mInteractionType;
private boolean mStartedQuickScrubFromHome;
private Bitmap mTaskSnapshot;
NavBarSwipeInteractionHandler(RunningTaskInfo runningTaskInfo, Context context,
- @TouchInteractionService.InteractionType int interactionType) {
+ @InteractionType int interactionType) {
// TODO: We need a better way for this
TaskKey taskKey = new TaskKey(runningTaskInfo.id, 0, null, UserHandle.myUserId(), 0);
mRunningTask = new Task(taskKey, null, null, "", "", Color.BLACK, Color.BLACK,
@@ -183,8 +191,8 @@
mLauncher = launcher;
mRecentsView = launcher.getOverviewPanel();
mRecentsView.showTask(mRunningTask);
- mStateController = mRecentsView.getStateController();
mHotseat = mLauncher.getHotseat();
+ mWasLauncherAlreadyVisible = alreadyOnHome;
AbstractFloatingView.closeAllOpenViews(mLauncher, alreadyOnHome);
mLauncher.getStateManager().goToState(LauncherState.OVERVIEW, alreadyOnHome);
@@ -194,17 +202,8 @@
mDragView.setPivotX(0);
mDragView.setPivotY(0);
- boolean interactionIsQuick
- = mInteractionType == TouchInteractionService.INTERACTION_QUICK_SCRUB
- || mInteractionType == TouchInteractionService.INTERACTION_QUICK_SWITCH;
- mStartedQuickScrubFromHome = alreadyOnHome && interactionIsQuick;
- if (interactionIsQuick) {
- mQuickScrubController = mRecentsView.getQuickScrubController();
- mQuickScrubController.onQuickScrubStart(mStartedQuickScrubFromHome);
- animateToProgress(1f, MAX_SWIPE_DURATION);
- if (mStartedQuickScrubFromHome) {
- mDragView.setVisibility(View.INVISIBLE);
- }
+ if (isInteractionQuick(mInteractionType)) {
+ updateUiForQuickScrub();
}
// Optimization
@@ -215,6 +214,34 @@
TraceHelper.partitionSection("TouchInt", "Launcher on new intent");
}
+
+ public void updateInteractionType(@InteractionType int interactionType) {
+ Preconditions.assertUIThread();
+ if (mInteractionType != INTERACTION_NORMAL) {
+ throw new IllegalArgumentException(
+ "Can't change interaction type from " + mInteractionType);
+ }
+ if (!isInteractionQuick(interactionType)) {
+ throw new IllegalArgumentException(
+ "Can't change interaction type to " + interactionType);
+ }
+ mInteractionType = interactionType;
+
+ if (mLauncher != null) {
+ updateUiForQuickScrub();
+ }
+ }
+
+ private void updateUiForQuickScrub() {
+ mStartedQuickScrubFromHome = mWasLauncherAlreadyVisible;
+ mQuickScrubController = mRecentsView.getQuickScrubController();
+ mQuickScrubController.onQuickScrubStart(mStartedQuickScrubFromHome);
+ animateToProgress(1f, MAX_SWIPE_DURATION);
+ if (mStartedQuickScrubFromHome) {
+ mDragView.setVisibility(View.INVISIBLE);
+ }
+ }
+
@UiThread
public void updateDisplacement(float displacement) {
mCurrentDisplacement = displacement;
@@ -334,7 +361,7 @@
if (currentRecentsPage instanceof TaskView) {
((TaskView) currentRecentsPage).animateIconToScale(1f);
}
- if (mInteractionType == TouchInteractionService.INTERACTION_QUICK_SWITCH) {
+ if (mInteractionType == INTERACTION_QUICK_SWITCH) {
for (int i = mRecentsView.getFirstTaskIndex(); i < mRecentsView.getPageCount(); i++) {
TaskView taskView = (TaskView) mRecentsView.getPageAt(i);
// TODO: Match the keys directly
@@ -345,7 +372,7 @@
break;
}
}
- } else if (mInteractionType == TouchInteractionService.INTERACTION_QUICK_SCRUB) {
+ } else if (mInteractionType == INTERACTION_QUICK_SCRUB) {
if (mQuickScrubController != null) {
mQuickScrubController.snapToPageForCurrentQuickScrubSection();
}
@@ -355,12 +382,16 @@
public void onQuickScrubEnd() {
if (mQuickScrubController != null) {
mQuickScrubController.onQuickScrubEnd();
+ } else {
+ // TODO:
}
}
public void onQuickScrubProgress(float progress) {
if (mQuickScrubController != null) {
mQuickScrubController.onQuickScrubProgress(progress);
+ } else {
+ // TODO:
}
}
}
diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java
index f4c2055..d656f8a 100644
--- a/quickstep/src/com/android/quickstep/QuickScrubController.java
+++ b/quickstep/src/com/android/quickstep/QuickScrubController.java
@@ -40,6 +40,7 @@
private int mQuickScrubSection;
private int mStartPage;
+ private boolean mQuickScrubEnabled;
public QuickScrubController(Launcher launcher) {
mLauncher = launcher;
@@ -51,11 +52,14 @@
mRecentsView = mLauncher.getOverviewPanel();
mStartPage = startingFromHome ? 0 : mRecentsView.getFirstTaskIndex();
mQuickScrubSection = 0;
+ mQuickScrubEnabled = true;
}
public void onQuickScrubEnd() {
mAutoAdvanceAlarm.cancelAlarm();
- if (mRecentsView != null) {
+ if (mRecentsView == null) {
+ mQuickScrubEnabled = false;
+ } else {
int page = mRecentsView.getNextPage();
// Settle on the page then launch it.
int snapDuration = Math.abs(page - mRecentsView.getPageNearestToCenterOfScreen())
@@ -67,10 +71,15 @@
} else {
((TaskView) mRecentsView.getPageAt(page)).launchTask(true);
}
+ mQuickScrubEnabled = false;
}, snapDuration);
}
}
+ public boolean isQuickScrubEnabled() {
+ return mQuickScrubEnabled;
+ }
+
public void onQuickScrubProgress(float progress) {
int quickScrubSection = Math.round(progress * NUM_QUICK_SCRUB_SECTIONS);
if (quickScrubSection != mQuickScrubSection) {
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index c35ffee..9b31c14 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -52,6 +52,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.util.TraceHelper;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
@@ -99,6 +100,7 @@
@Override
public void onQuickSwitch() {
startTouchTracking(INTERACTION_QUICK_SWITCH);
+ mInteractionHandler = null;
}
@Override
@@ -110,6 +112,7 @@
public void onQuickScrubEnd() {
if (mInteractionHandler != null) {
mInteractionHandler.onQuickScrubEnd();
+ mInteractionHandler = null;
}
}
@@ -137,6 +140,7 @@
private Intent mHomeIntent;
private ComponentName mLauncher;
private MotionEventQueue mEventQueue;
+ private MainThreadExecutor mMainThreadExecutor;
private final PointF mDownPos = new PointF();
private final PointF mLastPos = new PointF();
@@ -156,6 +160,7 @@
super.onCreate();
mAM = ActivityManagerWrapper.getInstance();
mRecentsModel = RecentsModel.getInstance(this);
+ mMainThreadExecutor = new MainThreadExecutor();
mHomeIntent = new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
@@ -284,7 +289,17 @@
return mDisplayRotation == Surface.ROTATION_270 && mStableInsets.left > 0;
}
+
private void startTouchTracking(@InteractionType int interactionType) {
+ if (isInteractionQuick(interactionType)) {
+ // TODO: Send action cancel if its the Launcher consumer
+ }
+ if (mInteractionHandler != null) {
+ final NavBarSwipeInteractionHandler handler = mInteractionHandler;
+ mMainThreadExecutor.execute(() -> handler.updateInteractionType(interactionType));
+ return;
+ }
+
// Create the shared handler
final NavBarSwipeInteractionHandler handler =
new NavBarSwipeInteractionHandler(mRunningTask, this, interactionType);
@@ -430,4 +445,9 @@
ev.setEdgeFlags(flags);
}
}
+
+ public static boolean isInteractionQuick(@InteractionType int interactionType) {
+ return interactionType == INTERACTION_QUICK_SCRUB ||
+ interactionType == INTERACTION_QUICK_SWITCH;
+ }
}
diff --git a/res/drawable/ic_star_rating.xml b/res/drawable/ic_star_rating.xml
deleted file mode 100644
index 4e34fa3..0000000
--- a/res/drawable/ic_star_rating.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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="12dp"
- android:height="12dp"
- android:viewportWidth="12"
- android:viewportHeight="12">
-
- <path
- android:fillColor="#FB8C00"
- android:fillType="evenOdd"
- android:strokeWidth="1"
- android:pathData="M 9.76511755 11.9348136 L 8.33665684 7.16088817 L 12.080006 4.41656311 L 7.49967039 4.41856896 L 6.03138903 0 L 4.57932894 4.41856896 L -1.34115008e-16 4.41656311 L 3.72612122 7.16088817 L 2.29967385 11.9348136 L 6.03138903 8.82574452 Z" />
-</vector>
\ No newline at end of file
diff --git a/res/layout/all_apps_discovery_item.xml b/res/layout/all_apps_discovery_item.xml
deleted file mode 100644
index 728283f..0000000
--- a/res/layout/all_apps_discovery_item.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<com.android.launcher3.discovery.AppDiscoveryItemView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:clickable="true"
- android:background="?android:selectableItemBackground">
-
- <ImageView
- android:id="@+id/image"
- android:layout_width="56dp"
- android:layout_height="56dp"
- android:padding="8dp"
- android:scaleType="fitCenter"
- android:focusable="false"
- android:importantForAccessibility="no"/>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_centerVertical="true"
- android:layout_toRightOf="@id/image">
-
- <TextView
- android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="?android:textColorSecondary"
- android:textSize="15sp"/>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
- <TextView
- android:id="@+id/rating"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="?android:textColorSecondary"
- android:textSize="14sp"
- android:layout_gravity="center_vertical"
- android:includeFontPadding="false"/>
-
- <com.android.launcher3.discovery.RatingView
- android:id="@+id/rating_view"
- android:layout_width="70dp"
- android:layout_height="16dp"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:layout_gravity="center_vertical"/>
-
- <TextView
- android:id="@+id/review_count"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5dp"
- android:textColor="?android:textColorHint"
- android:textSize="14sp"
- android:layout_gravity="center_vertical"/>
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1"/>
-
- <TextView
- android:id="@+id/price"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="?android:textColorHint"
- android:textSize="14sp"
- android:layout_marginRight="12dp"
- android:textAllCaps="true"/>
- </LinearLayout>
- </LinearLayout>
-
- <ImageView
- android:importantForAccessibility="no"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:paddingLeft="@dimen/dynamic_grid_edge_margin"
- android:paddingRight="@dimen/dynamic_grid_edge_margin"
- android:src="@drawable/all_apps_divider"
- android:scaleType="fitXY"
- android:focusable="false" />
-</com.android.launcher3.discovery.AppDiscoveryItemView>
\ No newline at end of file
diff --git a/res/layout/all_apps_discovery_loading_divider.xml b/res/layout/all_apps_discovery_loading_divider.xml
deleted file mode 100644
index 005847c..0000000
--- a/res/layout/all_apps_discovery_loading_divider.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="6dp"
- android:paddingLeft="@dimen/dynamic_grid_edge_margin"
- android:paddingRight="@dimen/dynamic_grid_edge_margin">
-
- <ProgressBar
- android:id="@+id/loadingProgressBar"
- style="@android:style/Widget.Material.ProgressBar.Horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="6dp"
- android:maxHeight="6dp"
- android:indeterminate="true"
- android:layout_gravity="center"/>
-
- <View
- android:id="@+id/loadedDivider"
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="@drawable/all_apps_divider"
- android:layout_gravity="bottom"
- android:visibility="invisible"/>
-
-</FrameLayout>
\ No newline at end of file
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 769f9ba..2103106 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -43,8 +43,6 @@
import com.android.launcher3.anim.SpringAnimationHandler;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
-import com.android.launcher3.discovery.AppDiscoveryAppInfo;
-import com.android.launcher3.discovery.AppDiscoveryItemView;
import com.android.launcher3.util.PackageManagerHelper;
import java.util.List;
@@ -72,17 +70,13 @@
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_APPS_LOADING_DIVIDER = 1 << 7;
- public static final int VIEW_TYPE_DISCOVERY_ITEM = 1 << 8;
- public static final int VIEW_TYPE_WORK_TAB_FOOTER = 1 << 9;
+ public static final int VIEW_TYPE_WORK_TAB_FOOTER = 1 << 7;
// 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_CONTENT = VIEW_TYPE_MASK_ICON
- | VIEW_TYPE_DISCOVERY_ITEM;
public static final int VIEW_TYPE_MASK_HAS_SPRINGS = VIEW_TYPE_MASK_ICON
| VIEW_TYPE_PREDICTION_DIVIDER;
@@ -161,7 +155,7 @@
adapterPosition = Math.max(adapterPosition, mApps.getAdapterItems().size() - 1);
int extraRows = 0;
for (int i = 0; i <= adapterPosition; i++) {
- if (!isViewType(items.get(i).viewType, VIEW_TYPE_MASK_CONTENT)) {
+ if (!isViewType(items.get(i).viewType, VIEW_TYPE_MASK_ICON)) {
extraRows++;
}
}
@@ -301,12 +295,6 @@
// Ensure the all apps icon height matches the workspace icons in portrait mode.
icon.getLayoutParams().height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
return new ViewHolder(icon);
- case VIEW_TYPE_DISCOVERY_ITEM:
- AppDiscoveryItemView appDiscoveryItemView = (AppDiscoveryItemView) mLayoutInflater
- .inflate(R.layout.all_apps_discovery_item, parent, false);
- appDiscoveryItemView.init(mIconClickListener, mLauncher.getAccessibilityDelegate(),
- mIconLongClickListener);
- return new ViewHolder(appDiscoveryItemView);
case VIEW_TYPE_EMPTY_SEARCH:
return new ViewHolder(mLayoutInflater.inflate(R.layout.all_apps_empty_search,
parent, false));
@@ -320,10 +308,6 @@
}
});
return new ViewHolder(searchMarketView);
- case VIEW_TYPE_APPS_LOADING_DIVIDER:
- View loadingDividerView = mLayoutInflater.inflate(
- R.layout.all_apps_discovery_loading_divider, parent, false);
- return new ViewHolder(loadingDividerView);
case VIEW_TYPE_PREDICTION_DIVIDER:
case VIEW_TYPE_ALL_APPS_DIVIDER:
return new ViewHolder(mLayoutInflater.inflate(
@@ -346,12 +330,6 @@
icon.reset();
icon.applyFromApplicationInfo(info);
break;
- case VIEW_TYPE_DISCOVERY_ITEM:
- AppDiscoveryAppInfo appDiscoveryAppInfo = (AppDiscoveryAppInfo)
- mApps.getAdapterItems().get(position).appInfo;
- AppDiscoveryItemView view = (AppDiscoveryItemView) holder.itemView;
- view.apply(appDiscoveryAppInfo);
- break;
case VIEW_TYPE_EMPTY_SEARCH:
TextView emptyViewText = (TextView) holder.itemView;
emptyViewText.setText(mEmptySearchMessage);
@@ -366,12 +344,6 @@
searchView.setVisibility(View.GONE);
}
break;
- case VIEW_TYPE_APPS_LOADING_DIVIDER:
- int visLoading = mApps.isAppDiscoveryRunning() ? View.VISIBLE : View.GONE;
- int visLoaded = !mApps.isAppDiscoveryRunning() ? View.VISIBLE : View.GONE;
- holder.itemView.findViewById(R.id.loadingProgressBar).setVisibility(visLoading);
- holder.itemView.findViewById(R.id.loadedDivider).setVisibility(visLoaded);
- break;
case VIEW_TYPE_ALL_APPS_DIVIDER:
// nothing to do
break;
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 4f931ca..4792cc2 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -170,12 +170,6 @@
AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH);
putSameHeightFor(adapter, widthMeasureSpec, heightMeasureSpec,
AllAppsGridAdapter.VIEW_TYPE_WORK_TAB_FOOTER);
- if (FeatureFlags.DISCOVERY_ENABLED) {
- putSameHeightFor(adapter, widthMeasureSpec, heightMeasureSpec,
- AllAppsGridAdapter.VIEW_TYPE_APPS_LOADING_DIVIDER);
- putSameHeightFor(adapter, widthMeasureSpec, heightMeasureSpec,
- AllAppsGridAdapter.VIEW_TYPE_DISCOVERY_ITEM);
- }
}
private void putSameHeightFor(AllAppsGridAdapter adapter, int w, int h, int... viewTypes) {
@@ -263,7 +257,7 @@
// Always scroll the view to the top so the user can see the changed results
scrollToTop();
- if (mApps.shouldShowEmptySearch()) {
+ if (mApps.hasNoFilteredResults()) {
if (mEmptySearchBackground == null) {
mEmptySearchBackground = DrawableFactory.get(getContext())
.getAllAppsBackground(getContext());
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index c02f2df..dadc6cd 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -37,8 +37,8 @@
public class AllAppsTransitionController
implements SearchUiManager.OnScrollRangeChangeListener, LauncherStateManager.StateHandler {
- private static final Property<AllAppsTransitionController, Float> PROGRESS =
- new Property<AllAppsTransitionController, Float>(Float.class, "progress") {
+ public static final Property<AllAppsTransitionController, Float> ALL_APPS_PROGRESS =
+ new Property<AllAppsTransitionController, Float>(Float.class, "allAppsProgress") {
@Override
public Float get(AllAppsTransitionController controller) {
@@ -164,7 +164,8 @@
}
Interpolator interpolator = config.userControlled ? LINEAR : FAST_OUT_SLOW_IN;
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, PROGRESS, mProgress, targetProgress);
+ ObjectAnimator anim =
+ ObjectAnimator.ofFloat(this, ALL_APPS_PROGRESS, mProgress, targetProgress);
anim.setDuration(config.duration);
anim.setInterpolator(interpolator);
anim.addListener(getProgressAnimatorListener());
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index eecd009..76828de 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -27,9 +27,6 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AlphabeticIndexCompat;
import com.android.launcher3.config.FeatureFlags;
-import com.android.launcher3.discovery.AppDiscoveryAppInfo;
-import com.android.launcher3.discovery.AppDiscoveryItem;
-import com.android.launcher3.discovery.AppDiscoveryUpdateState;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ComponentKeyMapper;
@@ -58,8 +55,6 @@
private final int mFastScrollDistributionMode = FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS;
- private AppDiscoveryUpdateState mAppDiscoveryUpdateState;
-
/**
* Info about a fast scroller section, depending if sections are merged, the fast scroller
* sections will not be the same set as the section headers.
@@ -118,17 +113,6 @@
return item;
}
- public static AdapterItem asDiscoveryItem(int pos, String sectionName, AppInfo appInfo,
- int appIndex) {
- AdapterItem item = new AdapterItem();
- item.viewType = AllAppsGridAdapter.VIEW_TYPE_DISCOVERY_ITEM;
- item.position = pos;
- item.sectionName = sectionName;
- item.appInfo = appInfo;
- item.appIndex = appIndex;
- return item;
- }
-
public static AdapterItem asEmptySearch(int pos) {
AdapterItem item = new AdapterItem();
item.viewType = AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH;
@@ -150,13 +134,6 @@
return item;
}
- public static AdapterItem asLoadingDivider(int pos) {
- AdapterItem item = new AdapterItem();
- item.viewType = AllAppsGridAdapter.VIEW_TYPE_APPS_LOADING_DIVIDER;
- item.position = pos;
- return item;
- }
-
public static AdapterItem asMarketSearch(int pos) {
AdapterItem item = new AdapterItem();
item.viewType = AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET;
@@ -188,7 +165,6 @@
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<>();
- private final List<AppDiscoveryAppInfo> mDiscoveredApps = new ArrayList<>();
// Is it the work profile app list.
private final boolean mIsWork;
@@ -293,10 +269,6 @@
return (mSearchResults != null) && mFilteredApps.isEmpty();
}
- boolean shouldShowEmptySearch() {
- return hasNoFilteredResults() && !isAppDiscoveryRunning() && mDiscoveredApps.isEmpty();
- }
-
/**
* Sets the sorted list of filtered components.
*/
@@ -310,20 +282,6 @@
return false;
}
- public void onAppDiscoverySearchUpdate(@Nullable AppDiscoveryItem app,
- @NonNull AppDiscoveryUpdateState state) {
- mAppDiscoveryUpdateState = state;
- switch (state) {
- case START:
- mDiscoveredApps.clear();
- break;
- case UPDATE:
- mDiscoveredApps.add(new AppDiscoveryAppInfo(app));
- break;
- }
- updateAdapterItems();
- }
-
private List<AppInfo> processPredictedAppComponents(List<ComponentKeyMapper<AppInfo>> components) {
if (mComponentToAppMap.isEmpty()) {
// Apps have not been bound yet.
@@ -540,32 +498,13 @@
}
if (hasFilter()) {
- if (isAppDiscoveryRunning() || mDiscoveredApps.size() > 0) {
- mAdapterItems.add(AdapterItem.asLoadingDivider(position++));
- // Append all app discovery results
- for (int i = 0; i < mDiscoveredApps.size(); i++) {
- AppDiscoveryAppInfo appDiscoveryAppInfo = mDiscoveredApps.get(i);
- if (appDiscoveryAppInfo.isRecent) {
- // already handled in getFilteredAppInfos()
- continue;
- }
- AdapterItem item = AdapterItem.asDiscoveryItem(position++,
- "", appDiscoveryAppInfo, appIndex++);
- mAdapterItems.add(item);
- }
-
- if (!isAppDiscoveryRunning()) {
- mAdapterItems.add(AdapterItem.asMarketSearch(position++));
- }
+ // Append the search market item
+ if (hasNoFilteredResults()) {
+ mAdapterItems.add(AdapterItem.asEmptySearch(position++));
} else {
- // Append the search market item
- if (hasNoFilteredResults()) {
- mAdapterItems.add(AdapterItem.asEmptySearch(position++));
- } else {
- mAdapterItems.add(AdapterItem.asAllAppsDivider(position++));
- }
- mAdapterItems.add(AdapterItem.asMarketSearch(position++));
+ mAdapterItems.add(AdapterItem.asAllAppsDivider(position++));
}
+ mAdapterItems.add(AdapterItem.asMarketSearch(position++));
}
if (mNumAppsPerRow != 0) {
@@ -635,11 +574,6 @@
== PackageManager.PERMISSION_GRANTED);
}
- public boolean isAppDiscoveryRunning() {
- return mAppDiscoveryUpdateState == AppDiscoveryUpdateState.START
- || mAppDiscoveryUpdateState == AppDiscoveryUpdateState.UPDATE;
- }
-
private List<AppInfo> getFiltersAppInfos() {
if (mSearchResults == null) {
return mApps;
@@ -651,17 +585,6 @@
result.add(match);
}
}
-
- // adding recently used instant apps
- if (mDiscoveredApps.size() > 0) {
- for (int i = 0; i < mDiscoveredApps.size(); i++) {
- AppDiscoveryAppInfo discoveryAppInfo = mDiscoveredApps.get(i);
- if (discoveryAppInfo.isRecent) {
- result.add(discoveryAppInfo);
- }
- }
- Collections.sort(result, mAppNameComparator);
- }
return result;
}
diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
index bf03a0e..e83904f 100644
--- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
@@ -28,8 +28,6 @@
import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.Launcher;
import com.android.launcher3.Utilities;
-import com.android.launcher3.discovery.AppDiscoveryItem;
-import com.android.launcher3.discovery.AppDiscoveryUpdateState;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.PackageManagerHelper;
@@ -164,18 +162,6 @@
* Called when the search results should be cleared.
*/
void clearSearchResult();
-
- /**
- * Called when the app discovery is providing an update of search, which can either be
- * START for starting a new discovery,
- * UPDATE for providing a new search result, can be called multiple times,
- * END for indicating the end of results.
- *
- * @param app result item if UPDATE, else null
- * @param app the update state, START, UPDATE or END
- */
- void onAppDiscoverySearchUpdate(@Nullable AppDiscoveryItem app,
- @NonNull AppDiscoveryUpdateState state);
}
}
\ No newline at end of file
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
index ed41f13..6f07eeb 100644
--- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
+++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
@@ -39,8 +39,6 @@
import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AlphabeticalAppsList;
import com.android.launcher3.allapps.SearchUiManager;
-import com.android.launcher3.discovery.AppDiscoveryItem;
-import com.android.launcher3.discovery.AppDiscoveryUpdateState;
import com.android.launcher3.graphics.TintedDrawableSpan;
import com.android.launcher3.util.ComponentKey;
@@ -187,15 +185,6 @@
mAppsView.onClearSearchResult();
}
- @Override
- public void onAppDiscoverySearchUpdate(
- @Nullable AppDiscoveryItem app, @NonNull AppDiscoveryUpdateState state) {
- if (!mLauncher.isDestroyed()) {
- mApps.onAppDiscoverySearchUpdate(app, state);
- notifyResultChanged();
- }
- }
-
private void notifyResultChanged() {
mElevationController.reset();
mAppsView.onSearchResultsChanged();
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 2d0e630..059b04e 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -44,8 +44,6 @@
public static final boolean QSB_ON_FIRST_SCREEN = true;
// When enabled the all-apps icon is not added to the hotseat.
public static final boolean NO_ALL_APPS_ICON = true;
- // When enabled, app discovery will be enabled if service is implemented
- public static final boolean DISCOVERY_ENABLED = false;
// When true, custom widgets are loaded using CustomWidgetParser.
public static final boolean ENABLE_CUSTOM_WIDGETS = false;
diff --git a/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java b/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java
deleted file mode 100644
index 26e5066..0000000
--- a/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.launcher3.discovery;
-
-import android.content.ComponentName;
-import android.content.Intent;
-import android.graphics.Color;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import com.android.launcher3.AppInfo;
-import com.android.launcher3.LauncherSettings;
-import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.graphics.ColorExtractor;
-
-public class AppDiscoveryAppInfo extends AppInfo {
-
- public final boolean showAsDiscoveryItem;
- public final boolean isInstantApp;
- public final boolean isRecent;
- public final float rating;
- public final long reviewCount;
- public final @NonNull String publisher;
- public final @NonNull Intent installIntent;
- public final @NonNull Intent launchIntent;
- public final @Nullable String priceFormatted;
-
- public AppDiscoveryAppInfo(AppDiscoveryItem item) {
- this.intent = item.isInstantApp ? item.launchIntent : item.installIntent;
- this.title = item.title;
- this.iconBitmap = item.bitmap;
- this.iconColor = iconBitmap == null ? Color.TRANSPARENT :
- ColorExtractor.findDominantColorByHue(item.bitmap);
- this.usingLowResIcon = false;
- this.isInstantApp = item.isInstantApp;
- this.isRecent = item.isRecent;
- this.rating = item.starRating;
- this.showAsDiscoveryItem = true;
- this.publisher = item.publisher != null ? item.publisher : "";
- this.priceFormatted = item.price;
- this.componentName = new ComponentName(item.packageName, "");
- this.installIntent = item.installIntent;
- this.launchIntent = item.launchIntent;
- this.reviewCount = item.reviewCount;
- this.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
- }
-
- @Override
- public ShortcutInfo makeShortcut() {
- if (!isDragAndDropSupported()) {
- throw new RuntimeException("DnD is currently not supported for discovered store apps");
- }
- return super.makeShortcut();
- }
-
- public boolean isDragAndDropSupported() {
- return isInstantApp;
- }
-
-}
diff --git a/src/com/android/launcher3/discovery/AppDiscoveryItem.java b/src/com/android/launcher3/discovery/AppDiscoveryItem.java
deleted file mode 100644
index 2e48b25..0000000
--- a/src/com/android/launcher3/discovery/AppDiscoveryItem.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.launcher3.discovery;
-
-import android.content.Intent;
-import android.graphics.Bitmap;
-
-/**
- * This class represents the model for a discovered app via app discovery.
- * It holds all information for one result retrieved from an app discovery service.
- */
-public class AppDiscoveryItem {
-
- public final String packageName;
- public final boolean isInstantApp;
- public final boolean isRecent;
- public final float starRating;
- public final long reviewCount;
- public final Intent launchIntent;
- public final Intent installIntent;
- public final CharSequence title;
- public final String publisher;
- public final String price;
- public final Bitmap bitmap;
-
- public AppDiscoveryItem(String packageName,
- boolean isInstantApp,
- boolean isRecent,
- float starRating,
- long reviewCount,
- CharSequence title,
- String publisher,
- Bitmap bitmap,
- String price,
- Intent launchIntent,
- Intent installIntent) {
- this.packageName = packageName;
- this.isInstantApp = isInstantApp;
- this.isRecent = isRecent;
- this.starRating = starRating;
- this.reviewCount = reviewCount;
- this.launchIntent = launchIntent;
- this.installIntent = installIntent;
- this.title = title;
- this.publisher = publisher;
- this.price = price;
- this.bitmap = bitmap;
- }
-
-}
diff --git a/src/com/android/launcher3/discovery/AppDiscoveryItemView.java b/src/com/android/launcher3/discovery/AppDiscoveryItemView.java
deleted file mode 100644
index 809d724..0000000
--- a/src/com/android/launcher3/discovery/AppDiscoveryItemView.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.launcher3.discovery;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.android.launcher3.R;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-
-public class AppDiscoveryItemView extends RelativeLayout {
-
- private static boolean SHOW_REVIEW_COUNT = false;
-
- private ImageView mImage;
- private TextView mTitle;
- private TextView mRatingText;
- private RatingView mRatingView;
- private TextView mReviewCount;
- private TextView mPrice;
- private OnLongClickListener mOnLongClickListener;
-
- public AppDiscoveryItemView(Context context) {
- this(context, null);
- }
-
- public AppDiscoveryItemView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public AppDiscoveryItemView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- this.mImage = (ImageView) findViewById(R.id.image);
- this.mTitle = (TextView) findViewById(R.id.title);
- this.mRatingText = (TextView) findViewById(R.id.rating);
- this.mRatingView = (RatingView) findViewById(R.id.rating_view);
- this.mPrice = (TextView) findViewById(R.id.price);
- this.mReviewCount = (TextView) findViewById(R.id.review_count);
- }
-
- public void init(OnClickListener clickListener,
- AccessibilityDelegate accessibilityDelegate,
- OnLongClickListener onLongClickListener) {
- setOnClickListener(clickListener);
- mImage.setOnClickListener(clickListener);
- setAccessibilityDelegate(accessibilityDelegate);
- mOnLongClickListener = onLongClickListener;
- }
-
- public void apply(@NonNull AppDiscoveryAppInfo info) {
- setTag(info);
- mImage.setTag(info);
- mImage.setImageBitmap(info.iconBitmap);
- mImage.setOnLongClickListener(info.isDragAndDropSupported() ? mOnLongClickListener : null);
- mTitle.setText(info.title);
- mPrice.setText(info.priceFormatted != null ? info.priceFormatted : "");
- mReviewCount.setVisibility(SHOW_REVIEW_COUNT ? View.VISIBLE : View.GONE);
- if (info.rating >= 0) {
- mRatingText.setText(new DecimalFormat("#.0").format(info.rating));
- mRatingView.setRating(info.rating);
- mRatingView.setVisibility(View.VISIBLE);
- String reviewCountFormatted = NumberFormat.getInstance().format(info.reviewCount);
- mReviewCount.setText("(" + reviewCountFormatted + ")");
- } else {
- // if we don't have a rating
- mRatingView.setVisibility(View.GONE);
- mRatingText.setText("");
- mReviewCount.setText("");
- }
- }
-}
diff --git a/src/com/android/launcher3/discovery/AppDiscoveryUpdateState.java b/src/com/android/launcher3/discovery/AppDiscoveryUpdateState.java
deleted file mode 100644
index 0700a10..0000000
--- a/src/com/android/launcher3/discovery/AppDiscoveryUpdateState.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.launcher3.discovery;
-
-public enum AppDiscoveryUpdateState {
- START, UPDATE, END
-}
diff --git a/src/com/android/launcher3/discovery/RatingView.java b/src/com/android/launcher3/discovery/RatingView.java
deleted file mode 100644
index 8fe63d6..0000000
--- a/src/com/android/launcher3/discovery/RatingView.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.launcher3.discovery;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.drawable.ClipDrawable;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-
-import com.android.launcher3.R;
-
-/**
- * A simple rating view that shows stars with a rating from 0-5.
- */
-public class RatingView extends View {
-
- private static final float WIDTH_FACTOR = 0.9f;
- private static final int MAX_LEVEL = 10000;
- private static final int MAX_STARS = 5;
-
- private final Drawable mStarDrawable;
- private final int mColorGray;
- private final int mColorHighlight;
-
- private float rating;
-
- public RatingView(Context context) {
- this(context, null);
- }
-
- public RatingView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public RatingView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mStarDrawable = getResources().getDrawable(R.drawable.ic_star_rating, null);
- mColorGray = 0x1E000000;
- mColorHighlight = 0x8A000000;
- }
-
- public void setRating(float rating) {
- this.rating = Math.min(Math.max(rating, 0), MAX_STARS);
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- drawStars(canvas, MAX_STARS, mColorGray);
- drawStars(canvas, rating, mColorHighlight);
- }
-
- private void drawStars(Canvas canvas, float stars, int color) {
- int fullWidth = getLayoutParams().width;
- int cellWidth = fullWidth / MAX_STARS;
- int starWidth = (int) (cellWidth * WIDTH_FACTOR);
- int padding = cellWidth - starWidth;
- int fullStars = (int) stars;
- float partialStarFactor = stars - fullStars;
-
- for (int i = 0; i < fullStars; i++) {
- int x = i * cellWidth + padding;
- Drawable star = mStarDrawable.getConstantState().newDrawable().mutate();
- star.setTint(color);
- star.setBounds(x, padding, x + starWidth, padding + starWidth);
- star.draw(canvas);
- }
- if (partialStarFactor > 0f) {
- int x = fullStars * cellWidth + padding;
- ClipDrawable star = new ClipDrawable(mStarDrawable,
- Gravity.LEFT, ClipDrawable.HORIZONTAL);
- star.setTint(color);
- star.setLevel((int) (MAX_LEVEL * partialStarFactor));
- star.setBounds(x, padding, x + starWidth, padding + starWidth);
- star.draw(canvas);
- }
- }
-}
diff --git a/src/com/android/launcher3/views/AllAppsScrim.java b/src/com/android/launcher3/views/AllAppsScrim.java
index 6cd40fd..662f99c 100644
--- a/src/com/android/launcher3/views/AllAppsScrim.java
+++ b/src/com/android/launcher3/views/AllAppsScrim.java
@@ -61,25 +61,11 @@
private final NinePatchDrawHelper mShadowHelper = new NinePatchDrawHelper();
- private float mProgress;
private int mFillAlpha;
private float mDrawHeight;
private float mDrawOffsetY;
- public static final Property<AllAppsScrim, Float> SCRIM_PROGRESS =
- new Property<AllAppsScrim, Float>(Float.class, "allAppsScrimProgress") {
- @Override
- public Float get(AllAppsScrim allAppsScrim) {
- return allAppsScrim.getProgress();
- }
-
- @Override
- public void set(AllAppsScrim allAppsScrim, Float progress) {
- allAppsScrim.setProgress(progress);
- }
- };
-
public AllAppsScrim(Context context) {
this(context, null);
}
@@ -174,23 +160,17 @@
public void setProgress(float translateY, float alpha) {
int newAlpha = Math.round(alpha * mAlphaRange + mMinAlpha);
- if (newAlpha != mFillAlpha) {
- mFillAlpha = newAlpha;
- mFillPaint.setAlpha(mFillAlpha);
- invalidateDrawRect();
- }
-
- setProgress(translateY);
- }
-
- public void setProgress(float translateY) {
// Negative translation means the scrim is moving up. For negative translation, we change
// draw offset as it requires redraw (since more area of the scrim needs to be shown). For
// position translation, we simply translate the scrim down as it avoids invalidate and
// hence could be optimized by the platform.
float drawOffsetY = Math.min(translateY, 0);
- if (drawOffsetY != mDrawOffsetY) {
+ if (newAlpha != mFillAlpha || drawOffsetY != mDrawOffsetY) {
+ invalidateDrawRect();
+
+ mFillAlpha = newAlpha;
+ mFillPaint.setAlpha(mFillAlpha);
mDrawOffsetY = drawOffsetY;
invalidateDrawRect();
}
@@ -198,10 +178,6 @@
setTranslationY(Math.max(translateY, 0));
}
- public float getProgress() {
- return mProgress;
- }
-
private void invalidateDrawRect() {
mDrawRect.top = (int) (getHeight()
+ mDrawOffsetY - mDrawHeight + mPadding.top - mShadowBlur - 0.5f);