Merge "Add support for launcher shortcuts." into ub-launcher3-calgary
diff --git a/res/drawable-ldrtl/container_fastscroll_popup_bg.xml b/res/drawable-ldrtl/container_fastscroll_popup_bg.xml
index d790968..2bbf5cd 100644
--- a/res/drawable-ldrtl/container_fastscroll_popup_bg.xml
+++ b/res/drawable-ldrtl/container_fastscroll_popup_bg.xml
@@ -16,7 +16,7 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
- <solid android:color="@color/container_fastscroll_thumb_active_color" />
+ <solid android:color="?android:attr/colorAccent" />
<size
android:width="64dp"
android:height="64dp" />
diff --git a/res/drawable/container_fastscroll_popup_bg.xml b/res/drawable/container_fastscroll_popup_bg.xml
index 2ef07ab..3dc7680 100644
--- a/res/drawable/container_fastscroll_popup_bg.xml
+++ b/res/drawable/container_fastscroll_popup_bg.xml
@@ -16,7 +16,7 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
- <solid android:color="@color/container_fastscroll_thumb_active_color" />
+ <solid android:color="?android:attr/colorAccent" />
<size
android:width="64dp"
android:height="64dp" />
diff --git a/res/layout/all_apps_search_market.xml b/res/layout/all_apps_search_market.xml
index 4bdca99..741c96a 100644
--- a/res/layout/all_apps_search_market.xml
+++ b/res/layout/all_apps_search_market.xml
@@ -23,7 +23,7 @@
android:paddingRight="16dp"
android:fontFamily="sans-serif-medium"
android:textSize="14sp"
- android:textColor="@color/launcher_accent_color"
+ android:textColor="?android:attr/colorAccent"
android:text="@string/all_apps_search_market_message"
android:textAllCaps="true"
android:focusable="true"
diff --git a/res/layout/widget_cell.xml b/res/layout/widget_cell.xml
index 7fefeba..15f369f 100644
--- a/res/layout/widget_cell.xml
+++ b/res/layout/widget_cell.xml
@@ -21,7 +21,7 @@
android:layout_weight="1"
android:orientation="vertical"
android:focusable="true"
- android:background="@color/widgets_cell_color"
+ android:background="?android:attr/colorPrimary"
android:gravity="center_horizontal">
<LinearLayout
diff --git a/res/layout/widgets_list_row_view.xml b/res/layout/widgets_list_row_view.xml
index b7f76a6..c0219b9 100644
--- a/res/layout/widgets_list_row_view.xml
+++ b/res/layout/widgets_list_row_view.xml
@@ -19,7 +19,7 @@
android:id="@+id/widgets_cell_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@color/widgets_cell_color"
+ android:background="?android:attr/colorPrimary"
android:orientation="vertical"
android:focusable="true"
android:descendantFocusability="afterDescendants">
diff --git a/res/layout/widgets_view.xml b/res/layout/widgets_view.xml
index 0503466..e9bbd37 100644
--- a/res/layout/widgets_view.xml
+++ b/res/layout/widgets_view.xml
@@ -25,7 +25,8 @@
android:paddingTop="@dimen/container_bounds_inset"
android:paddingBottom="@dimen/container_bounds_inset"
android:descendantFocusability="afterDescendants"
- launcher:revealBackground="@drawable/quantum_panel_shape_dark">
+ launcher:revealBackground="@drawable/quantum_panel_shape_dark"
+ android:theme="@android:style/Theme.DeviceDefault.Settings">
<View
android:id="@+id/reveal_view"
diff --git a/res/values-v21/styles.xml b/res/values-v21/styles.xml
index aa5d0a6..8d3de01 100644
--- a/res/values-v21/styles.xml
+++ b/res/values-v21/styles.xml
@@ -24,8 +24,5 @@
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#00000000</item>
<item name="android:navigationBarColor">#00000000</item>
- <item name="android:colorControlActivated">@color/launcher_accent_color</item>
- <item name="android:colorAccent">@color/launcher_accent_color</item>
- <item name="android:colorPrimary">@color/launcher_accent_color</item>
</style>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 1329535..44e77e2 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -22,7 +22,6 @@
over the delete target or the info target -->
<color name="delete_target_hover_tint">#FFC1C1C1</color>
<color name="uninstall_target_hover_tint">#FFF0592B</color>
- <color name="info_target_hover_tint">#FF009688</color>
<color name="cling_scrim_background">#80000000</color>
<color name="focused_background">#80c6c5c5</color>
@@ -38,20 +37,11 @@
<color name="quantum_panel_bg_color_dark">#FF374248</color>
<color name="outline_color">#FFFFFFFF</color>
- <color name="launcher_accent_color">#ff009688</color>
<color name="spring_loaded_panel_color">#40FFFFFF</color>
<color name="spring_loaded_highlighted_panel_border_color">#FFF</color>
- <!-- Containers -->
- <color name="container_fastscroll_thumb_inactive_color">#009688</color>
- <color name="container_fastscroll_thumb_active_color">#009688</color>
-
- <!-- All Apps -->
- <color name="all_apps_grid_section_text_color">#009688</color>
-
<!-- Widgets view -->
<color name="widgets_view_section_text_color">#FFFFFF</color>
<color name="widgets_view_item_text_color">#C4C4C4</color>
- <color name="widgets_cell_color">#263238</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index cda8c05..02c6c70 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -88,6 +88,7 @@
<dimen name="all_apps_search_bar_bg_overflow">-6dp</dimen>
<dimen name="all_apps_search_bar_divider_width">1dp</dimen>
+ <dimen name="all_apps_bezel_swipe_height">24dp</dimen>
<!-- Widget tray -->
<dimen name="widget_preview_label_vertical_padding">8dp</dimen>
<dimen name="widget_preview_label_horizontal_padding">8dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 1b7072d..0bfd0a0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -31,7 +31,7 @@
<style name="Theme" parent="@style/LauncherTheme"></style>
<!-- Overscroll effect -->
- <style name="CustomOverscroll.Light" parent="@android:style/Theme.DeviceDefault">
+ <style name="CustomOverscroll.Light" parent="@android:style/Theme.DeviceDefault.Light">
<item name="android:colorEdgeEffect">@color/folder_edge_effect_color</item>
</style>
diff --git a/src/com/android/launcher3/BaseContainerView.java b/src/com/android/launcher3/BaseContainerView.java
index 7c7cb0b..84bd88d 100644
--- a/src/com/android/launcher3/BaseContainerView.java
+++ b/src/com/android/launcher3/BaseContainerView.java
@@ -50,10 +50,10 @@
public BaseContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- int width = ((Launcher) context).getDeviceProfile().availableWidthPx;
+ Launcher launcher = Launcher.getLauncher(context);
+ int width = launcher.getDeviceProfile().availableWidthPx;
if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP &&
- this instanceof AllAppsContainerView &&
- !((Launcher) context).getDeviceProfile().isLandscape) {
+ this instanceof AllAppsContainerView && !launcher.getDeviceProfile().isLandscape) {
mHorizontalPadding = 0;
} else {
mHorizontalPadding = DeviceProfile.getContainerPadding(context, width);
@@ -89,4 +89,4 @@
public final View getRevealView() {
return mRevealView;
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
index fd0045e..4ab0ea3 100644
--- a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
+++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
@@ -81,9 +81,7 @@
mTrackPaint = new Paint();
mTrackPaint.setColor(rv.getFastScrollerTrackColor(Color.BLACK));
mTrackPaint.setAlpha(MAX_TRACK_ALPHA);
- mThumbInactiveColor = rv.getFastScrollerThumbInactiveColor(
- res.getColor(R.color.container_fastscroll_thumb_inactive_color));
- mThumbActiveColor = res.getColor(R.color.container_fastscroll_thumb_active_color);
+ mThumbActiveColor = mThumbInactiveColor = Utilities.getColorAccent(rv.getContext());
mThumbPaint = new Paint();
mThumbPaint.setAntiAlias(true);
mThumbPaint.setColor(mThumbInactiveColor);
diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java
index ebaba18..baf96fe 100644
--- a/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java
+++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java
@@ -53,7 +53,7 @@
mRes = res;
mRv = rv;
mBgOriginalSize = res.getDimensionPixelSize(R.dimen.container_fastscroll_popup_size);
- mBg = res.getDrawable(R.drawable.container_fastscroll_popup_bg);
+ mBg = rv.getContext().getDrawable(R.drawable.container_fastscroll_popup_bg);
mBg.setBounds(0, 0, mBgOriginalSize, mBgOriginalSize);
mTextPaint = new Paint();
mTextPaint.setColor(Color.WHITE);
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 97515a8..1762ca4 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -103,7 +103,7 @@
public BubbleTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
DeviceProfile grid = mLauncher.getDeviceProfile();
TypedArray a = context.obtainStyledAttributes(attrs,
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 9f86a0b..5245509 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -218,4 +218,13 @@
mBackgroundColor = color;
}
}
+
+ public void setBackgroundTransparent(boolean enable) {
+ // This causes re-layout. Should replace the logic with simply setting the background alpha
+ if (enable) {
+ setBackground(null);
+ } else {
+ setBackground(mBackground);
+ }
+ }
}
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java
index 259370c..e136bcd 100644
--- a/src/com/android/launcher3/InfoDropTarget.java
+++ b/src/com/android/launcher3/InfoDropTarget.java
@@ -43,7 +43,7 @@
protected void onFinishInflate() {
super.onFinishInflate();
// Get the hover color
- mHoverColor = getResources().getColor(R.color.info_target_hover_tint);
+ mHoverColor = Utilities.getColorAccent(getContext());
setDrawable(R.drawable.ic_info_launcher);
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index cc31de2..c0c04a1 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -38,6 +38,7 @@
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
+import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
@@ -63,6 +64,7 @@
import android.os.Message;
import android.os.StrictMode;
import android.os.SystemClock;
+import android.os.Trace;
import android.os.UserHandle;
import android.text.Selection;
import android.text.SpannableStringBuilder;
@@ -146,11 +148,9 @@
public static final String TAG = "Launcher";
static final boolean LOGD = false;
- static final boolean PROFILE_STARTUP = false;
static final boolean DEBUG_WIDGETS = false;
static final boolean DEBUG_STRICT_MODE = false;
static final boolean DEBUG_RESUME_TIME = false;
- static final boolean DEBUG_LOGGING = false;
private static final int REQUEST_CREATE_SHORTCUT = 1;
private static final int REQUEST_CREATE_APPWIDGET = 5;
@@ -401,6 +401,9 @@
.penaltyDeath()
.build());
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Launcher-onCreate");
+ }
if (mLauncherCallbacks != null) {
mLauncherCallbacks.preOnCreate();
@@ -436,11 +439,6 @@
// LauncherModel load.
mPaused = false;
- if (PROFILE_STARTUP) {
- android.os.Debug.startMethodTracing(
- Environment.getExternalStorageDirectory() + "/launcher");
- }
-
setContentView(R.layout.launcher);
setupViews();
@@ -456,8 +454,8 @@
mSavedState = savedInstanceState;
restoreState(mSavedState);
- if (PROFILE_STARTUP) {
- android.os.Debug.stopMethodTracing();
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
}
if (!mRestoring) {
@@ -631,29 +629,6 @@
}
}
- /**
- * Logger object is a singleton and does not have to be coupled with the foreground activity.
- * Since most user event logging is done on the UI, the object is retrieved from the
- * callback for convenience.
- */
- private UserEventDispatcher createUserEventDispatcher() {
- return new UserEventDispatcher() {
- @Override
- public void dispatchUserEvent(LauncherLogProto.LauncherEvent ev, Intent intent) {
- if (!DEBUG_LOGGING) {
- return;
- }
- Log.d("UserEvent", String.format(Locale.US,
- "action:%s\nchild:%s\nparent:%s\nelapsed container %d ms session %d ms",
- LoggerUtils.getActionStr(ev.action),
- LoggerUtils.getTargetStr(ev.srcTarget[0]),
- LoggerUtils.getTargetStr(ev.srcTarget[1]),
- ev.elapsedContainerMillis,
- ev.elapsedSessionMillis));
- }
- };
- }
-
public UserEventDispatcher getUserEventDispatcher() {
if (mLauncherCallbacks != null) {
UserEventDispatcher dispatcher = mLauncherCallbacks.getUserEventDispatcher();
@@ -662,8 +637,11 @@
}
}
+ // Logger object is a singleton and does not have to be coupled with the foreground
+ // activity. Since most user event logging is done on the UI, the object is retrieved
+ // from the callback for convenience.
if (mUserEventDispatcher == null) {
- mUserEventDispatcher = createUserEventDispatcher();
+ mUserEventDispatcher = new UserEventDispatcher();
}
return mUserEventDispatcher;
}
@@ -1399,6 +1377,8 @@
mDragController.addDropTarget(mWorkspace);
mDropTargetBar.setup(mDragController);
+ mAllAppsController.setupViews(mAppsView, mHotseat, mWorkspace);
+
if (TestingUtils.MEMORY_DUMP_ENABLED) {
TestingUtils.addWeightWatcher(this);
}
@@ -3596,6 +3576,9 @@
* Implementation of the method from LauncherModel.Callbacks.
*/
public void startBinding() {
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Starting page bind");
+ }
setWorkspaceLoading(true);
// Clear the workspace because it's going to be rebound
@@ -3606,6 +3589,9 @@
if (mHotseat != null) {
mHotseat.resetLayout();
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
+ }
}
@Override
@@ -3972,6 +3958,9 @@
if (waitUntilResume(r)) {
return;
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Page bind completed");
+ }
if (mSavedState != null) {
if (!mWorkspace.hasFocus()) {
mWorkspace.getChildAt(mWorkspace.getCurrentPage()).requestFocus();
@@ -4006,6 +3995,9 @@
if (mLauncherCallbacks != null) {
mLauncherCallbacks.finishBindingItems(false);
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
+ }
}
private boolean canRunNewAppsAnimation() {
@@ -4546,6 +4538,13 @@
}
}
+ public static Launcher getLauncher(Context context) {
+ if (context instanceof Launcher) {
+ return (Launcher) context;
+ }
+ return ((Launcher) ((ContextWrapper) context).getBaseContext());
+ }
+
private class RotationPrefChangeHandler implements OnSharedPreferenceChangeListener, Runnable {
@Override
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 2ba4982..4bc76fb 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -25,6 +25,7 @@
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.dynamicui.ExtractionUtils;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.shortcuts.DeepShortcutManager;
@@ -37,6 +38,8 @@
public class LauncherAppState {
+ public static final boolean PROFILE_STARTUP = ProviderConfig.IS_DOGFOOD_BUILD;
+
private final AppFilter mAppFilter;
@Thunk final LauncherModel mModel;
private final IconCache mIconCache;
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 9e87660..8e404a7 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -37,6 +37,7 @@
import android.os.Parcelable;
import android.os.Process;
import android.os.SystemClock;
+import android.os.Trace;
import android.provider.BaseColumns;
import android.text.TextUtils;
import android.util.Log;
@@ -1627,6 +1628,9 @@
}
private void loadWorkspace() {
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Loading Workspace");
+ }
final long t = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
final Context context = mContext;
@@ -2290,6 +2294,9 @@
}
}
}
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
+ }
}
/**
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 4e7d57b..f5b32ed 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -44,6 +44,7 @@
import android.os.Handler;
import android.os.Message;
import android.os.Process;
+import android.os.Trace;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;
@@ -86,6 +87,9 @@
@Override
public boolean onCreate() {
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
+ Log.d(TAG, "Launcher process started");
+ }
mListenerHandler = new Handler(mListenerWrapper);
LauncherAppState.setLauncherProvider(this);
@@ -115,6 +119,9 @@
*/
protected synchronized void createDbIfNotExists() {
if (mOpenHelper == null) {
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.beginSection("Opening workspace DB");
+ }
mOpenHelper = new DatabaseHelper(getContext(), mListenerHandler);
if (RestoreDbTask.isPending(getContext())) {
@@ -125,6 +132,10 @@
// executed again.
RestoreDbTask.setPending(getContext(), false);
}
+
+ if (LauncherAppState.PROFILE_STARTUP) {
+ Trace.endSection();
+ }
}
}
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index fd4aff9..e94153d 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -420,7 +420,7 @@
pCb.onTransitionComplete();
}
});
- mAllAppsController.animateToAllApps(animation, revealDuration);
+ mAllAppsController.animateToAllApps(animation, revealDuration, false);
dispatchOnLauncherTransitionPrepare(fromView, animated, false);
dispatchOnLauncherTransitionPrepare(toView, animated, false);
@@ -861,37 +861,31 @@
return animation;
} else if (animType == PULLUP) {
animation.addListener(new AnimatorListenerAdapter() {
+ boolean canceled = false;
@Override
- public void onAnimationEnd(Animator animation) {
- dispatchOnLauncherTransitionEnd(fromView, animated, false);
- dispatchOnLauncherTransitionEnd(toView, animated, false);
- cleanupAnimation();
- pCb.onTransitionComplete();
+ public void onAnimationCancel(Animator animation) {
+ canceled = true;
}
- });
- mAllAppsController.animateToWorkspace(animation, revealDuration);
-
- // Dispatch the prepare transition signal
- dispatchOnLauncherTransitionPrepare(fromView, animated, false);
- dispatchOnLauncherTransitionPrepare(toView, animated, false);
-
- animation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- dispatchOnLauncherTransitionEnd(fromView, animated, true);
- dispatchOnLauncherTransitionEnd(toView, animated, true);
-
+ if (canceled) return;
+ dispatchOnLauncherTransitionEnd(fromView, animated, false);
+ dispatchOnLauncherTransitionEnd(toView, animated, false);
// Run any queued runnables
if (onCompleteRunnable != null) {
onCompleteRunnable.run();
}
-
- // This can hold unnecessary references to views.
cleanupAnimation();
pCb.onTransitionComplete();
}
+
});
+ mAllAppsController.animateToWorkspace(animation, revealDuration, false);
+
+ // Dispatch the prepare transition signal
+ dispatchOnLauncherTransitionPrepare(fromView, animated, false);
+ dispatchOnLauncherTransitionPrepare(toView, animated, false);
final AnimatorSet stateAnimation = animation;
final Runnable startAnimRunnable = new Runnable() {
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 3511375..0306d57 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -30,6 +30,7 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -839,4 +840,11 @@
return getBitmap().getWidth();
}
}
+
+ public static int getColorAccent(Context context) {
+ TypedArray ta = context.obtainStyledAttributes(new int[]{android.R.attr.colorAccent});
+ int colorAccent = ta.getColor(0, 0);
+ ta.recycle();
+ return colorAccent;
+ }
}
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java
index d9bd782..45e65b5 100644
--- a/src/com/android/launcher3/WidgetPreviewLoader.java
+++ b/src/com/android/launcher3/WidgetPreviewLoader.java
@@ -584,7 +584,7 @@
// which would gets re-written next time.
mVersions = getPackageVersion(mKey.componentName.getPackageName());
- Launcher launcher = (Launcher) mCaller.getContext();
+ Launcher launcher = Launcher.getLauncher(mCaller.getContext());
// it's not in the db... we need to generate it
preview = generatePreview(launcher, mInfo, unusedBitmap, mPreviewWidth, mPreviewHeight);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 47cf123..1e28785 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -198,6 +198,21 @@
}
}
+ // Direction used for moving the workspace and hotseat UI
+ public enum Direction {
+ X (TRANSLATION_X),
+ Y (TRANSLATION_Y);
+
+ private final Property<View, Float> viewProperty;
+
+ Direction(Property<View, Float> viewProperty) {
+ this.viewProperty = viewProperty;
+ }
+ }
+
+ private float[] mPageAlpha = new float[] {1, 1};
+ private float[] mHotseatAlpha = new float[] {1, 1};
+
@ViewDebug.ExportedProperty(category = "launcher")
private State mState = State.NORMAL;
private boolean mIsSwitchingState = false;
@@ -1387,50 +1402,56 @@
// TODO(adamcohen): figure out a final effect here. We may need to recommend
// different effects based on device performance. On at least one relatively high-end
// device I've tried, translating the launcher causes things to get quite laggy.
- setWorkspaceTranslation(TRANSLATION_X, transX, alpha);
- setHotseatTranslation(TRANSLATION_X, transX, alpha);
+ setWorkspaceTranslation(Direction.X, transX, alpha);
+ setHotseatTranslation(Direction.X, transX, alpha);
}
/**
* Moves the workspace UI in the provided direction.
- * @param direction either {@link #TRANSLATION_X} or {@link #TRANSLATION_Y}
- * @param translation the amound of shift.
+ * @param direction the direction to move the workspace
+ * @param translation the amount of shift.
* @param alpha the alpha for the workspace page
*/
- public void setWorkspaceTranslation(
- Property<View, Float> direction, float translation, float alpha) {
+ public void setWorkspaceTranslation(Direction direction, float translation, float alpha) {
+ Property<View, Float> property = direction.viewProperty;
+ mPageAlpha[direction.ordinal()] = alpha;
+ float finalAlpha = mPageAlpha[0] * mPageAlpha[1];
+
View currentChild = getChildAt(getCurrentPage());
if (currentChild != null) {
- direction.set(currentChild, translation);
- currentChild.setAlpha(alpha);
+ property.set(currentChild, translation);
+ currentChild.setAlpha(finalAlpha);
}
// When the animation finishes, reset all pages, just in case we missed a page.
if (Float.compare(translation, 0) == 0) {
for (int i = getChildCount() - 1; i >= 0; i--) {
View child = getChildAt(i);
- direction.set(child, translation);
- child.setAlpha(alpha);
+ property.set(child, translation);
+ child.setAlpha(finalAlpha);
}
}
}
/**
* Moves the Hotseat UI in the provided direction.
- * @param direction either {@link #TRANSLATION_X} or {@link #TRANSLATION_Y}
+ * @param direction the direction to move the workspace
* @param translation the amound of shift.
* @param alpha the alpha for the hotseat page
*/
- public void setHotseatTranslation(
- Property<View, Float> direction, float translation, float alpha) {
+ public void setHotseatTranslation(Direction direction, float translation, float alpha) {
+ Property<View, Float> property = direction.viewProperty;
+ mHotseatAlpha[direction.ordinal()] = alpha;
+ float finalAlpha = mHotseatAlpha[0] * mHotseatAlpha[1];
+
View pageIndicator = getPageIndicator();
if (pageIndicator != null) {
- direction.set(pageIndicator, translation);
- pageIndicator.setAlpha(alpha);
+ property.set(pageIndicator, translation);
+ pageIndicator.setAlpha(finalAlpha);
}
- direction.set(mLauncher.getHotseat(), translation);
- mLauncher.getHotseat().setAlpha(alpha);
+ property.set(mLauncher.getHotseat(), translation);
+ mLauncher.getHotseat().setAlpha(finalAlpha);
}
@Override
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index d59058b..888cc57 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -30,6 +30,7 @@
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.DecelerateInterpolator;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.util.Thunk;
@@ -43,6 +44,7 @@
private View mView;
private boolean mAccessibilityEnabled;
+ private boolean mCanceled = false;
public AlphaUpdateListener(View v, boolean accessibilityEnabled) {
mView = v;
@@ -67,7 +69,13 @@
}
@Override
+ public void onAnimationCancel(Animator animation) {
+ mCanceled = true;
+ }
+
+ @Override
public void onAnimationEnd(Animator arg0) {
+ if (mCanceled) return;
updateVisibility(mView, mAccessibilityEnabled);
}
@@ -164,7 +172,7 @@
workspaceToAllApps = (oldStateIsNormal && stateIsNormalHidden);
overviewToWorkspace = (oldStateIsOverview && stateIsNormal);
overviewToAllApps = (oldStateIsOverview && stateIsOverviewHidden);
- allAppsToWorkspace = (stateIsNormalHidden && stateIsNormal);
+ allAppsToWorkspace = (oldStateIsNormalHidden && stateIsNormal);
}
}
@@ -322,8 +330,10 @@
boolean isCurrentPage = (i == toPage);
float initialAlpha = cl.getShortcutsAndWidgets().getAlpha();
float finalAlpha;
- if (states.stateIsNormalHidden || states.stateIsOverviewHidden) {
+ if (states.stateIsOverviewHidden) {
finalAlpha = 0f;
+ } else if(states.stateIsNormalHidden) {
+ finalAlpha = FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP ? 1 : 0;
} else if (states.stateIsNormal && mWorkspaceFadeInAdjacentScreens) {
finalAlpha = (i == toPage || i < customPageCount) ? 1f : 0f;
} else {
@@ -447,10 +457,16 @@
mStateAnimator.play(hotseatAlpha);
mStateAnimator.play(pageIndicatorAlpha);
mStateAnimator.addListener(new AnimatorListenerAdapter() {
+ boolean canceled = false;
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ canceled = true;
+ }
+
@Override
public void onAnimationEnd(Animator animation) {
mStateAnimator = null;
-
+ if (canceled) return;
if (accessibilityEnabled && overviewPanel.getVisibility() == View.VISIBLE) {
overviewPanel.getChildAt(0).performAccessibilityAction(
AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index b5dc0c0..cd7d3e3 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -178,7 +178,7 @@
super(context, attrs, defStyleAttr);
Resources res = context.getResources();
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
mApps = new AlphabeticalAppsList(context);
mAdapter = new AllAppsGridAdapter(mLauncher, mApps, this, mLauncher, this);
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index c68356e..ca2556e 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -378,7 +378,7 @@
mSectionTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mSectionTextPaint.setTextSize(res.getDimensionPixelSize(
R.dimen.all_apps_grid_section_text_size));
- mSectionTextPaint.setColor(res.getColor(R.color.all_apps_grid_section_text_color));
+ mSectionTextPaint.setColor(Utilities.getColorAccent(launcher));
mPredictedAppsDividerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics()));
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index c443b1e..3157c13 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -4,11 +4,9 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
-import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
-import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
@@ -19,7 +17,9 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.PagedView;
+import com.android.launcher3.R;
import com.android.launcher3.Workspace;
+import com.android.launcher3.Workspace.Direction;
import com.android.launcher3.util.TouchController;
/**
@@ -39,55 +39,54 @@
private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f);
private final Interpolator mDecelInterpolator = new DecelerateInterpolator(1f);
- private final Interpolator mAccelDecelInterpolator = new AccelerateDecelerateInterpolator();
- private static final float ANIMATION_DURATION = 2000;
- public static final float ALL_APPS_FINAL_ALPHA = .8f;
+ private static final float ANIMATION_DURATION = 1200;
+ public static final float ALL_APPS_FINAL_ALPHA = .9f;
private static final float PARALLAX_COEFFICIENT = .125f;
private AllAppsContainerView mAppsView;
private Workspace mWorkspace;
private Hotseat mHotseat;
- private Drawable mHotseatBackground;
- private float mHotseatAlpha;
+ private float mHotseatBackgroundAlpha;
+
private float mStatusBarHeight;
private final Launcher mLauncher;
private final VerticalPullDetector mDetector;
- // Animation in this class is controlled by a single variable {@link mProgressTransY}.
+ // Animation in this class is controlled by a single variable {@link mShiftCurrent}.
// Visually, it represents top y coordinate of the all apps container. Using the
- // {@link mTranslation} as the denominator, this fraction value ranges in [0, 1].
- private float mProgressTransY; // numerator
- private float mTranslation = -1; // denominator
+ // {@link mShiftRange} as the denominator, this fraction value ranges in [0, 1].
+ //
+ // When {@link mShiftCurrent} is 0, all apps container is pulled up.
+ // When {@link mShiftCurrent} is {@link mShirtRange}, all apps container is pulled down.
+ private float mShiftStart; // [0, mShiftRange]
+ private float mShiftCurrent; // [0, mShiftRange]
+ private float mShiftRange; // changes depending on the orientation
+
private static final float RECATCH_REJECTION_FRACTION = .0875f;
- // Used in landscape.
- private static final float BAZEL_PULL_UP_HEIGHT = 60;
-
+ private int mBezelSwipeUpHeight;
private long mAnimationDuration;
- private float mCurY;
+
private AnimatorSet mCurrentAnimation;
private boolean mNoIntercept;
private boolean mLightStatusBar;
- // At the end of scroll settling, this class also sets the state of the launcher.
- // If it's already set,do not call the #mLauncher.setXXX method.
- private boolean mStateAlreadyChanged;
-
public AllAppsTransitionController(Launcher launcher) {
mLauncher = launcher;
mDetector = new VerticalPullDetector(launcher);
mDetector.setListener(this);
+ mBezelSwipeUpHeight = launcher.getResources().getDimensionPixelSize(
+ R.dimen.all_apps_bezel_swipe_height);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
- init();
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mNoIntercept = false;
if (mLauncher.getWorkspace().isInOverviewMode() || mLauncher.isWidgetsViewVisible()) {
@@ -98,26 +97,49 @@
} else if (!mLauncher.isAllAppsVisible() && !shouldPossiblyIntercept(ev)) {
mNoIntercept = true;
} else {
- mDetector.setDetectableScrollConditions(mLauncher.isAllAppsVisible() /* down */,
- isInDisallowRecatchTopZone(), isInDisallowRecatchBottomZone());
+ // Now figure out which direction scroll events the controller will start
+ // calling the callbacks.
+ int conditionsToReportScroll = 0;
+
+ if (mDetector.isRestingState()) {
+ if (mLauncher.isAllAppsVisible()) {
+ conditionsToReportScroll |= VerticalPullDetector.THRESHOLD_DOWN;
+ } else {
+ conditionsToReportScroll |= VerticalPullDetector.THRESHOLD_UP;
+ }
+ } else {
+ if (isInDisallowRecatchBottomZone()) {
+ conditionsToReportScroll |= VerticalPullDetector.THRESHOLD_UP;
+ } else if (isInDisallowRecatchTopZone()) {
+ conditionsToReportScroll |= VerticalPullDetector.THRESHOLD_DOWN;
+ } else {
+ conditionsToReportScroll |= VerticalPullDetector.THRESHOLD_ONLY;
+ }
+ }
+ mDetector.setDetectableScrollConditions(conditionsToReportScroll);
}
}
if (mNoIntercept) {
return false;
}
mDetector.onTouchEvent(ev);
+ if (mDetector.isScrollingState() && (isInDisallowRecatchBottomZone() || isInDisallowRecatchTopZone())) {
+ return false;
+ }
return mDetector.shouldIntercept();
}
private boolean shouldPossiblyIntercept(MotionEvent ev) {
DeviceProfile grid = mLauncher.getDeviceProfile();
if (mDetector.isRestingState()) {
- if (mLauncher.getDragLayer().isEventOverHotseat(ev) && !grid.isLandscape) {
- return true;
- }
- if (ev.getY() > mLauncher.getDeviceProfile().heightPx - BAZEL_PULL_UP_HEIGHT &&
- grid.isLandscape) {
- return true;
+ if (grid.isVerticalBarLayout()) {
+ if (ev.getY() > mLauncher.getDeviceProfile().heightPx - mBezelSwipeUpHeight) {
+ return true;
+ }
+ } else {
+ if (mLauncher.getDragLayer().isEventOverHotseat(ev) && !grid.isVerticalBarLayout()) {
+ return true;
+ }
}
return false;
} else {
@@ -131,60 +153,108 @@
}
private boolean isInDisallowRecatchTopZone() {
- return mProgressTransY / mTranslation < RECATCH_REJECTION_FRACTION;
+ return mShiftCurrent / mShiftRange < RECATCH_REJECTION_FRACTION;
}
private boolean isInDisallowRecatchBottomZone() {
- return mProgressTransY / mTranslation > 1 - RECATCH_REJECTION_FRACTION;
- }
-
- private void init() {
- if (mAppsView != null) {
- return;
- }
- mAppsView = mLauncher.getAppsView();
- mHotseat = mLauncher.getHotseat();
- mWorkspace = mLauncher.getWorkspace();
-
- mStatusBarHeight = mLauncher.getDragLayer().getInsets().height();
- if (mHotseatBackground == null) {
- mHotseatBackground = mHotseat.getBackground();
- mHotseatAlpha = mHotseatBackground.getAlpha() / 255f;
- }
+ return mShiftCurrent / mShiftRange > 1 - RECATCH_REJECTION_FRACTION;
}
@Override
public void onScrollStart(boolean start) {
- init();
cancelAnimation();
mCurrentAnimation = LauncherAnimUtils.createAnimatorSet();
+ mShiftStart = mAppsView.getTranslationY();
preparePull(start);
- mCurY = mAppsView.getTranslationY();
}
+ @Override
+ public boolean onScroll(float displacement, float velocity) {
+ if (mAppsView == null) {
+ return false; // early termination.
+ }
+ if (0 <= mShiftStart + displacement && mShiftStart + displacement < mShiftRange) {
+ setProgress(mShiftStart + displacement);
+ }
+ return true;
+ }
+
+ @Override
+ public void onScrollEnd(float velocity, boolean fling) {
+ if (mAppsView == null) {
+ return; // early termination.
+ }
+
+ if (fling) {
+ if (velocity < 0) {
+ calculateDuration(velocity, mAppsView.getTranslationY());
+
+ if (!mLauncher.isAllAppsVisible()) {
+ mLauncher.showAppsView(true, true, false, false);
+ } else {
+ animateToAllApps(mCurrentAnimation, mAnimationDuration, true);
+ }
+ } else {
+ calculateDuration(velocity, Math.abs(mShiftRange - mAppsView.getTranslationY()));
+ if (mLauncher.isAllAppsVisible()) {
+ mLauncher.showWorkspace(true);
+ } else {
+ animateToWorkspace(mCurrentAnimation, mAnimationDuration, true);
+ }
+ }
+ // snap to top or bottom using the release velocity
+ } else {
+ if (mAppsView.getTranslationY() > mShiftRange / 2) {
+ calculateDuration(velocity, Math.abs(mShiftRange - mAppsView.getTranslationY()));
+ if (mLauncher.isAllAppsVisible()) {
+ mLauncher.showWorkspace(true);
+ } else {
+ animateToWorkspace(mCurrentAnimation, mAnimationDuration, true);
+ }
+ } else {
+ calculateDuration(velocity, Math.abs(mAppsView.getTranslationY()));
+ if (!mLauncher.isAllAppsVisible()) {
+ mLauncher.showAppsView(true, true, false, false);
+ } else {
+ animateToAllApps(mCurrentAnimation, mAnimationDuration, true);
+ }
+
+ }
+ }
+ }
/**
* @param start {@code true} if start of new drag.
*/
public void preparePull(boolean start) {
- mHotseat.setVisibility(View.VISIBLE);
- mHotseat.bringToFront();
if (start) {
+ // Initialize values that should not change until #onScrollEnd
+ mStatusBarHeight = mLauncher.getDragLayer().getInsets().top;
+ mHotseat.setVisibility(View.VISIBLE);
+ mHotseat.bringToFront();
+ if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
+ mShiftRange = mHotseat.getTop();
+ } else {
+ mShiftRange = mHotseat.getBottom();
+ }
if (!mLauncher.isAllAppsVisible()) {
mLauncher.tryAndUpdatePredictedApps();
- mHotseat.setBackground(null);
+
+ mHotseatBackgroundAlpha = mHotseat.getBackground().getAlpha() / 255f;
+ mHotseat.setBackgroundTransparent(true /* transparent */);
mAppsView.setVisibility(View.VISIBLE);
mAppsView.getContentView().setVisibility(View.VISIBLE);
mAppsView.getContentView().setBackground(null);
mAppsView.getRevealView().setVisibility(View.VISIBLE);
- mAppsView.getRevealView().setAlpha(mHotseatAlpha);
+ mAppsView.getRevealView().setAlpha(mHotseatBackgroundAlpha);
DeviceProfile grid= mLauncher.getDeviceProfile();
- if (!grid.isLandscape) {
- mTranslation = mHotseat.getTop();
+ if (!grid.isVerticalBarLayout()) {
+ mShiftRange = mHotseat.getTop();
} else {
- mTranslation = mHotseat.getBottom();
+ mShiftRange = mHotseat.getBottom();
}
- setProgress(mTranslation);
+ mAppsView.getRevealView().setAlpha(mHotseatBackgroundAlpha);
+ setProgress(mShiftRange);
} else {
// TODO: get rid of this workaround to override state change by workspace transition
mWorkspace.onLauncherTransitionPrepare(mLauncher, false, false);
@@ -193,6 +263,8 @@
child.setVisibility(View.VISIBLE);
child.setAlpha(1f);
}
+ } else {
+ setProgress(mShiftCurrent);
}
}
@@ -215,92 +287,59 @@
mLightStatusBar = enable;
}
- @Override
- public boolean onScroll(float displacement, float velocity) {
- if (mAppsView == null) {
- return false; // early termination.
- }
- if (0 <= mCurY + displacement && mCurY + displacement < mTranslation) {
- setProgress(mCurY + displacement);
- }
- return true;
- }
-
/**
* @param progress y value of the border between hotseat and all apps
*/
public void setProgress(float progress) {
updateLightStatusBar(progress);
- mProgressTransY = progress;
+ mShiftCurrent = progress;
float alpha = calcAlphaAllApps(progress);
float workspaceHotseatAlpha = 1 - alpha;
- mAppsView.getRevealView().setAlpha(Math.min(ALL_APPS_FINAL_ALPHA, Math.max(mHotseatAlpha,
+ mAppsView.getRevealView().setAlpha(Math.min(ALL_APPS_FINAL_ALPHA, Math.max(mHotseatBackgroundAlpha,
mDecelInterpolator.getInterpolation(alpha))));
mAppsView.getContentView().setAlpha(alpha);
mAppsView.setTranslationY(progress);
- mWorkspace.setWorkspaceTranslation(View.TRANSLATION_Y,
- PARALLAX_COEFFICIENT *(-mTranslation + progress),
+ mWorkspace.setWorkspaceTranslation(Direction.Y,
+ PARALLAX_COEFFICIENT * (-mShiftRange + progress),
mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
- mWorkspace.setHotseatTranslation(View.TRANSLATION_Y, -mTranslation + progress,
- mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
+ if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
+ mWorkspace.setHotseatTranslation(Direction.Y, -mShiftRange + progress,
+ mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
+ } else {
+ mWorkspace.setHotseatTranslation(Direction.Y,
+ PARALLAX_COEFFICIENT * (-mShiftRange + progress),
+ mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
+ }
}
public float getProgress() {
- return mProgressTransY;
+ return mShiftCurrent;
}
private float calcAlphaAllApps(float progress) {
- return ((mTranslation - progress)/mTranslation);
- }
-
- @Override
- public void onScrollEnd(float velocity, boolean fling) {
- if (mAppsView == null) {
- return; // early termination.
- }
-
- if (fling) {
- if (velocity < 0) {
- calculateDuration(velocity, mAppsView.getTranslationY());
- animateToAllApps(mCurrentAnimation, mAnimationDuration);
- } else {
- calculateDuration(velocity, Math.abs(mTranslation - mAppsView.getTranslationY()));
- animateToWorkspace(mCurrentAnimation, mAnimationDuration);
- }
- // snap to top or bottom using the release velocity
- } else {
- if (mAppsView.getTranslationY() > mTranslation / 2) {
- calculateDuration(velocity, Math.abs(mTranslation - mAppsView.getTranslationY()));
- animateToWorkspace(mCurrentAnimation, mAnimationDuration);
- } else {
- calculateDuration(velocity, Math.abs(mAppsView.getTranslationY()));
- animateToAllApps(mCurrentAnimation, mAnimationDuration);
- }
- }
- mCurrentAnimation.start();
+ return ((mShiftRange - progress)/ mShiftRange);
}
private void calculateDuration(float velocity, float disp) {
// TODO: make these values constants after tuning.
float velocityDivisor = Math.max(1.5f, Math.abs(0.5f * velocity));
- float travelDistance = Math.max(0.2f, disp / mTranslation);
+ float travelDistance = Math.max(0.2f, disp / mShiftRange);
mAnimationDuration = (long) Math.max(100, ANIMATION_DURATION / velocityDivisor * travelDistance);
if (DBG) {
Log.d(TAG, String.format("calculateDuration=%d, v=%f, d=%f", mAnimationDuration, velocity, disp));
}
}
- public void animateToAllApps(AnimatorSet animationOut, long duration) {
- if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
+ public void animateToAllApps(AnimatorSet animationOut, long duration, boolean start) {
+ if (animationOut == null){
return;
}
if (mDetector.isRestingState()) {
preparePull(true);
mAnimationDuration = duration;
- mStateAlreadyChanged = true;
+ mShiftStart = mAppsView.getTranslationY();
}
- mCurY = mAppsView.getTranslationY();
final float fromAllAppsTop = mAppsView.getTranslationY();
final float toAllAppsTop = 0;
@@ -327,19 +366,22 @@
}
}});
mCurrentAnimation = animationOut;
+ if (start) {
+ mCurrentAnimation.start();
+ }
}
- public void animateToWorkspace(AnimatorSet animationOut, long duration) {
- if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
+ public void animateToWorkspace(AnimatorSet animationOut, long duration, boolean start) {
+ if (animationOut == null){
return;
}
if(mDetector.isRestingState()) {
preparePull(true);
mAnimationDuration = duration;
- mStateAlreadyChanged = true;
+ mShiftStart = mAppsView.getTranslationY();
}
final float fromAllAppsTop = mAppsView.getTranslationY();
- final float toAllAppsTop = mTranslation;
+ final float toAllAppsTop = mShiftRange;
ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress",
fromAllAppsTop, toAllAppsTop);
@@ -352,6 +394,7 @@
@Override
public void onAnimationCancel(Animator animation) {
canceled = true;
+ setProgress(mShiftCurrent);
}
@Override
@@ -365,16 +408,14 @@
}
}});
mCurrentAnimation = animationOut;
+ if (start) {
+ mCurrentAnimation.start();
+ }
}
private void finishPullUp() {
mHotseat.setVisibility(View.INVISIBLE);
setProgress(0f);
- if (!mStateAlreadyChanged) {
- mLauncher.showAppsView(false /* animated */, true /* resetListToTop */,
- false /* updatePredictedApps */, false /* focusSearchBar */);
- }
- mStateAlreadyChanged = false;
}
public void finishPullDown() {
@@ -382,17 +423,14 @@
return;
}
mAppsView.setVisibility(View.INVISIBLE);
- mHotseat.setBackground(mHotseatBackground);
+ mHotseat.setBackgroundTransparent(false /* transparent */);
mHotseat.setVisibility(View.VISIBLE);
- setProgress(mTranslation);
- if (!mStateAlreadyChanged) {
- mLauncher.showWorkspace(false);
- }
- mStateAlreadyChanged = false;
+ setProgress(mShiftRange);
}
private void cancelAnimation() {
if (mCurrentAnimation != null) {
+ mCurrentAnimation.setDuration(0);
mCurrentAnimation.cancel();
mCurrentAnimation = null;
}
@@ -401,4 +439,10 @@
private void cleanUpAnimation() {
mCurrentAnimation = null;
}
+
+ public void setupViews(AllAppsContainerView appsView, Hotseat hotseat, Workspace workspace) {
+ mAppsView = appsView;
+ mHotseat = hotseat;
+ mWorkspace = workspace;
+ }
}
diff --git a/src/com/android/launcher3/allapps/VerticalPullDetector.java b/src/com/android/launcher3/allapps/VerticalPullDetector.java
index 9304aac..b54cb00 100644
--- a/src/com/android/launcher3/allapps/VerticalPullDetector.java
+++ b/src/com/android/launcher3/allapps/VerticalPullDetector.java
@@ -7,16 +7,22 @@
/**
* One dimensional scroll gesture detector for all apps container pull up interaction.
+ * Client (e.g., AllAppsTransitionController) of this class can register a listener.
+ *
+ * Features that this gesture detector can support.
*/
public class VerticalPullDetector {
- private static final String TAG = "ScrollGesture";
private static final boolean DBG = false;
+ private static final String TAG = "VerticalPullDetector";
private float mTouchSlop;
- private boolean mScrollDown; // if false, only scroll up will be reported.
- private boolean mDisallowRecatchFromTop;
- private boolean mDisallowRecatchFromBottom;
+
+ private int mScrollDirections;
+ public static final int THRESHOLD_UP = 1 << 0;
+ public static final int THRESHOLD_DOWN = 1 << 1;
+ public static final int THRESHOLD_ONLY = THRESHOLD_DOWN | THRESHOLD_UP;
+
/**
* The minimum release velocity in pixels per millisecond that triggers fling..
@@ -31,23 +37,43 @@
/* Scroll state, this is set to true during dragging and animation. */
private State mState = State.NONE;
- enum State {NONE, DRAG, SCROLLING};
+
+ enum State {
+ NONE,
+ CATCH, // onScrollStart
+ DRAG, // onScrollStart, onScroll
+ SCROLLING // onScrollEnd
+ };
+
+ //------------------- State transition diagram -----------------------------------
+ //
+ // NONE -> (mDisplacement > mTouchSlop) -> DRAG
+ // DRAG -> (MotionEvent#ACTION_UP, MotionEvent#ACTION_CANCEL) -> SCROLLING
+ // SCROLLING -> (MotionEvent#ACTION_DOWN) && (mDisplacement > mTouchSlop) -> CATCH
+ // SCROLLING -> (View settled) -> NONE
private void setState(State newState) {
if (DBG) {
- Log.d(TAG, mState + "->" + newState);
+ Log.d(TAG, "setState:" + mState + "->" + newState);
}
mState = newState;
}
public boolean shouldIntercept() {
- return mState == State.DRAG;
+ return mState == State.DRAG || mState == State.SCROLLING || mState == State.CATCH;
}
+ /**
+ * There's no touch and there's no animation.
+ */
public boolean isRestingState() {
return mState == State.NONE;
}
+ public boolean isScrollingState() {
+ return mState == State.SCROLLING;
+ }
+
private float mDownX;
private float mDownY;
private float mDownMillis;
@@ -60,8 +86,7 @@
private float mDisplacementY;
private float mDisplacementX;
- /* scroll started during previous animation */
- private boolean mSubtractSlop = true;
+ private float mSubtractDisplacement;
/* Client of this gesture detector can register a callback. */
Listener mListener;
@@ -80,39 +105,25 @@
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
- public void setDetectableScrollConditions(boolean scrollDown, boolean disallowRecatchFromTop,
- boolean disallowRecatchFromBottom) {
- mScrollDown = scrollDown;
- mDisallowRecatchFromTop = disallowRecatchFromTop;
- mDisallowRecatchFromBottom = disallowRecatchFromBottom;
+ public void setDetectableScrollConditions(int scrollDirectionFlags) {
+ mScrollDirections = scrollDirectionFlags;
}
private boolean shouldScrollStart() {
+ // reject cases where the slop condition is not met.
+ if (Math.abs(mDisplacementY) < mTouchSlop) {
+ return false;
+ }
+
+ // reject cases where the angle condition is not met.
float deltaY = Math.abs(mDisplacementY);
float deltaX = Math.max(Math.abs(mDisplacementX), 1);
- if (mScrollDown && mDisplacementY > mTouchSlop) {
- if (deltaY > deltaX) {
- return true;
- }
+ if (deltaX > deltaY) {
+ return false;
}
- if (!mScrollDown && mDisplacementY < -mTouchSlop) {
- if (deltaY > deltaX) {
- return true;
- }
- }
- return false;
- }
-
- private boolean shouldRecatchScrollStart() {
- if (!mDisallowRecatchFromBottom && !mDisallowRecatchFromTop) {
- return true;
- }
- if (mDisallowRecatchFromTop && mDisplacementY > mTouchSlop) {
- mDisallowRecatchFromTop = false;
- return true;
- }
- if (mDisallowRecatchFromBottom && mDisplacementY < -mTouchSlop) {
- mDisallowRecatchFromBottom = false;
+ // Check if the client is interested in scroll in current direction.
+ if (((mScrollDirections & THRESHOLD_DOWN) > 0 && mDisplacementY > 0) ||
+ ((mScrollDirections & THRESHOLD_UP) > 0 && mDisplacementY < 0)) {
return true;
}
return false;
@@ -126,8 +137,11 @@
mDownY = ev.getY();
mLastDisplacement = 0;
mVelocity = 0;
- if (mState == State.SCROLLING && shouldRecatchScrollStart()){
+
+ // handle state and listener calls.
+ if (mState == State.SCROLLING && shouldScrollStart()){
reportScrollStart(true /* recatch */);
+ setState(State.CATCH);
}
break;
case MotionEvent.ACTION_MOVE:
@@ -135,23 +149,23 @@
mDisplacementY = ev.getY() - mDownY;
mVelocity = computeVelocity(ev, mVelocity);
- if (mState == State.SCROLLING && Math.abs(mDisplacementY) > mTouchSlop ){
+ // handle state and listener calls.
+ if (shouldScrollStart() && mState != State.DRAG) {
+ if (mState == State.NONE) {
+ reportScrollStart(false /* recatch */);
+ }
setState(State.DRAG);
- reportScrollStart(true /* recatch */);
}
- if (mState == State.NONE && shouldScrollStart()) {
- setState(State.DRAG);
- reportScrollStart(false /* recatch */);
- }
- if (mState == State.DRAG && mListener != null) {
+ if (mState == State.DRAG) {
reportScroll();
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
// These are synthetic events and there is no need to update internal values.
- if (mState == State.DRAG && mListener != null) {
+ if (mState == State.DRAG || mState == State.CATCH) {
reportScrollEnd();
+ setState(State.SCROLLING);
}
break;
default:
@@ -173,7 +187,11 @@
private boolean reportScrollStart(boolean recatch) {
mListener.onScrollStart(!recatch);
- mSubtractSlop = !recatch;
+ if (mDisplacementY > 0) {
+ mSubtractDisplacement = mTouchSlop;
+ } else {
+ mSubtractDisplacement = -mTouchSlop;
+ }
if (DBG) {
Log.d(TAG, "onScrollStart recatch:" + recatch);
}
@@ -187,15 +205,8 @@
Log.d(TAG, String.format("onScroll disp=%.1f, velocity=%.1f",
mDisplacementY, mVelocity));
}
- float subtractDisplacement = 0f;
- if (mSubtractSlop) {
- if (mDisplacementY > 0) {
- subtractDisplacement = mTouchSlop;
- } else {
- subtractDisplacement = -mTouchSlop;
- }
- }
- return mListener.onScroll(mDisplacementY - subtractDisplacement, mVelocity);
+
+ return mListener.onScroll(mDisplacementY - mSubtractDisplacement, mVelocity);
}
return true;
}
@@ -206,7 +217,7 @@
mDisplacementY, mVelocity));
}
mListener.onScrollEnd(mVelocity, Math.abs(mVelocity) > RELEASE_VELOCITY_PX_MS);
- setState(State.SCROLLING);
+
}
/**
* Computes the damped velocity using the two motion events and the previous velocity.
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index e9a897e..0deee57 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -18,6 +18,7 @@
import android.content.ComponentName;
import android.content.Intent;
+import android.util.Log;
import android.view.View;
import android.view.ViewParent;
@@ -28,11 +29,14 @@
import com.android.launcher3.util.ComponentKey;
import java.util.List;
+import java.util.Locale;
/**
* Manages the creation of {@link LauncherEvent}.
*/
-public abstract class UserEventDispatcher {
+public class UserEventDispatcher {
+
+ private static final boolean DEBUG_LOGGING = false;
private final static int MAXIMUM_VIEW_HIERARCHY_LEVEL = 5;
/**
@@ -155,7 +159,17 @@
mActionDurationMillis = System.currentTimeMillis();
}
- public abstract void dispatchUserEvent(LauncherEvent ev, Intent intent);
+ public void dispatchUserEvent(LauncherEvent ev, Intent intent) {
+ if (DEBUG_LOGGING) {
+ Log.d("UserEvent", String.format(Locale.US,
+ "action:%s\nchild:%s\nparent:%s\nelapsed container %d ms session %d ms",
+ LoggerUtils.getActionStr(ev.action),
+ LoggerUtils.getTargetStr(ev.srcTarget[0]),
+ LoggerUtils.getTargetStr(ev.srcTarget[1]),
+ ev.elapsedContainerMillis,
+ ev.elapsedSessionMillis));
+ }
+ }
public int getPredictedRank(ComponentKey key) {
if (mPredictedApps == null) return -1;
diff --git a/src/com/android/launcher3/model/GridSizeMigrationTask.java b/src/com/android/launcher3/model/GridSizeMigrationTask.java
index 9d3399f..cb1acaa 100644
--- a/src/com/android/launcher3/model/GridSizeMigrationTask.java
+++ b/src/com/android/launcher3/model/GridSizeMigrationTask.java
@@ -150,7 +150,7 @@
protected boolean migrateHotseat() throws Exception {
ArrayList<DbEntry> items = loadHotseatEntries();
- int requiredCount = mDestHotseatSize - 1;
+ int requiredCount = FeatureFlags.NO_ALL_APPS_ICON ? mDestHotseatSize : mDestHotseatSize - 1;
while (items.size() > requiredCount) {
// Pick the center item by default.
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index 99af93b..747c21b 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -123,7 +123,7 @@
mDotRadius = getResources().getDimension(R.dimen.page_indicator_dot_size) / 2;
setOutlineProvider(new MyOutlineProver());
- mActiveColor = getResources().getColor(R.color.launcher_accent_color);
+ mActiveColor = Utilities.getColorAccent(context);
mInActiveColor = getResources().getColor(R.color.page_indicator_dot_color);
mIsRtl = Utilities.isRtl(getResources());
diff --git a/src/com/android/launcher3/util/CachedPackageTracker.java b/src/com/android/launcher3/util/CachedPackageTracker.java
index d55d573..293714e 100644
--- a/src/com/android/launcher3/util/CachedPackageTracker.java
+++ b/src/com/android/launcher3/util/CachedPackageTracker.java
@@ -170,7 +170,7 @@
*/
protected abstract void onLauncherPackageRemoved(String packageName, UserHandleCompat user);
- protected static class LauncherActivityInstallInfo
+ public static class LauncherActivityInstallInfo
implements Comparable<LauncherActivityInstallInfo> {
public final LauncherActivityInfoCompat info;
public final long installTime;
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index ad32f92..97877fd 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -88,7 +88,7 @@
super(context, attrs, defStyle);
final Resources r = context.getResources();
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
setContainerWidth();
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index a76f0af..8a58d34 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -82,9 +82,9 @@
public WidgetsContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- mLauncher = (Launcher) context;
+ mLauncher = Launcher.getLauncher(context);
mDragController = mLauncher.getDragController();
- mAdapter = new WidgetsListAdapter(this, this, mLauncher);
+ mAdapter = new WidgetsListAdapter(this, this, context);
mIconCache = (LauncherAppState.getInstance()).getIconCache();
if (LOGD) {
Log.d(TAG, "WidgetsContainerView constructor");
diff --git a/src/com/android/launcher3/widget/WidgetsListAdapter.java b/src/com/android/launcher3/widget/WidgetsListAdapter.java
index e68450d..6b8ea49 100644
--- a/src/com/android/launcher3/widget/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/WidgetsListAdapter.java
@@ -16,6 +16,7 @@
package com.android.launcher3.widget;
import android.annotation.TargetApi;
+import android.content.Context;
import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
@@ -27,7 +28,6 @@
import android.widget.LinearLayout;
import com.android.launcher3.BubbleTextView;
-import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -63,13 +63,13 @@
public WidgetsListAdapter(View.OnClickListener iconClickListener,
View.OnLongClickListener iconLongClickListener,
- Launcher launcher) {
- mLayoutInflater = launcher.getLayoutInflater();
+ Context context) {
+ mLayoutInflater = LayoutInflater.from(context);
mWidgetPreviewLoader = LauncherAppState.getInstance().getWidgetCache();
mIconClickListener = iconClickListener;
mIconLongClickListener = iconLongClickListener;
- mIndent = launcher.getResources().getDimensionPixelSize(R.dimen.widget_section_indent);
+ mIndent = context.getResources().getDimensionPixelSize(R.dimen.widget_section_indent);
}
public void setWidgetsModel(WidgetsModel w) {
diff --git a/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java b/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
index 08a81f0..c250cb2 100644
--- a/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
+++ b/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
@@ -10,6 +10,7 @@
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.TestLauncherProvider;
@@ -61,8 +62,13 @@
mIdp.numHotseatIcons = 3;
new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, 5, 3)
.migrateHotseat();
- // First & last items are dropped as they have the least weight.
- verifyHotseat(hotseatItems[1], -1, hotseatItems[3]);
+ if (FeatureFlags.NO_ALL_APPS_ICON) {
+ // First item is dropped as it has the least weight.
+ verifyHotseat(hotseatItems[1], hotseatItems[3], hotseatItems[4]);
+ } else {
+ // First & last items are dropped as they have the least weight.
+ verifyHotseat(hotseatItems[1], -1, hotseatItems[3]);
+ }
}
public void testHotseatMigration_shortcuts_dropped() throws Exception {
@@ -77,8 +83,13 @@
mIdp.numHotseatIcons = 3;
new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, 5, 3)
.migrateHotseat();
- // First & third items are dropped as they have the least weight.
- verifyHotseat(hotseatItems[1], -1, hotseatItems[4]);
+ if (FeatureFlags.NO_ALL_APPS_ICON) {
+ // First item is dropped as it has the least weight.
+ verifyHotseat(hotseatItems[1], hotseatItems[3], hotseatItems[4]);
+ } else {
+ // First & third items are dropped as they have the least weight.
+ verifyHotseat(hotseatItems[1], -1, hotseatItems[4]);
+ }
}
private void verifyHotseat(long... sortedIds) {
diff --git a/tests/src/com/android/launcher3/ui/LauncherInstrumentationTestCase.java b/tests/src/com/android/launcher3/ui/LauncherInstrumentationTestCase.java
index a59f0ff..e858d17 100644
--- a/tests/src/com/android/launcher3/ui/LauncherInstrumentationTestCase.java
+++ b/tests/src/com/android/launcher3/ui/LauncherInstrumentationTestCase.java
@@ -28,6 +28,7 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.ManagedProfileHeuristic;
import java.io.FileInputStream;
@@ -101,8 +102,14 @@
* Opens all apps and returns the recycler view
*/
protected UiObject2 openAllApps() {
- mDevice.wait(Until.findObject(
- By.desc(mTargetContext.getString(R.string.all_apps_button_label))), DEFAULT_UI_TIMEOUT).click();
+ if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
+ // clicking on the page indicator brings up all apps tray on non tablets.
+ findViewById(R.id.page_indicator).click();
+ } else {
+ mDevice.wait(Until.findObject(
+ By.desc(mTargetContext.getString(R.string.all_apps_button_label))),
+ DEFAULT_UI_TIMEOUT).click();
+ }
return findViewById(R.id.apps_list_view);
}