Merge "Adding a DB update path to handle the QSB position change" into ub-launcher3-calgary
diff --git a/res/drawable/ic_allapps_caret.xml b/res/drawable/ic_allapps_caret.xml
new file mode 100644
index 0000000..34d1882
--- /dev/null
+++ b/res/drawable/ic_allapps_caret.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2016 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:height="24dp"
+ android:viewportHeight="48.0"
+ android:viewportWidth="48.0"
+ android:width="24dp" >
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M14.83,30.83L24,21.66l9.17,9.17L36,28 24,16 12,28z"/>
+</vector>
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index d193e2f..8ebc303 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -53,6 +53,12 @@
android:id="@+id/overview_panel"
android:visibility="gone" />
+ <com.android.launcher3.pageindicators.PageIndicatorCaretLandscape
+ android:id="@+id/page_indicator"
+ android:layout_width="48dp"
+ android:layout_height="@dimen/dynamic_grid_page_indicator_height"
+ android:layout_gravity="bottom|left"/>
+
<include layout="@layout/widgets_view"
android:id="@+id/widgets_view"
android:layout_width="match_parent"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 527ed54..6b5bf63 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -52,7 +52,7 @@
<!-- Keep these behind the workspace so that they are not visible when
we go into AllApps -->
- <com.android.launcher3.pageindicators.PageIndicatorLine
+ <com.android.launcher3.pageindicators.PageIndicatorLineCaret
android:id="@+id/page_indicator"
android:layout_width="match_parent"
android:layout_height="@dimen/dynamic_grid_page_indicator_height" />
@@ -71,7 +71,8 @@
android:id="@+id/apps_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="invisible" />
+ android:visibility="invisible"
+ launcher:layout_ignoreInsets="true" />
</com.android.launcher3.dragndrop.DragLayer>
</com.android.launcher3.LauncherRootView>
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index 184e688..33ad323 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -55,7 +55,7 @@
<!-- Keep these behind the workspace so that they are not visible when
we go into AllApps -->
- <com.android.launcher3.pageindicators.PageIndicatorLine
+ <com.android.launcher3.pageindicators.PageIndicatorLineCaret
android:id="@+id/page_indicator"
android:layout_width="match_parent"
android:layout_height="@dimen/dynamic_grid_page_indicator_height" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 64868f2..cda8c05 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -17,7 +17,9 @@
<resources>
<!-- Dynamic Grid -->
<dimen name="dynamic_grid_edge_margin">6dp</dimen>
- <dimen name="dynamic_grid_page_indicator_height">1dp</dimen>
+ <dimen name="dynamic_grid_page_indicator_height">24dp</dimen>
+ <dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen>
+ <dimen name="dynamic_grid_page_indicator_extra_touch_height">12dp</dimen>
<dimen name="dynamic_grid_icon_drawable_padding">4dp</dimen>
<dimen name="dynamic_grid_workspace_page_spacing">8dp</dimen>
<dimen name="dynamic_grid_overview_min_icon_zone_height">80dp</dimen>
diff --git a/src/com/android/launcher3/BaseContainerView.java b/src/com/android/launcher3/BaseContainerView.java
index a9ef43d..7c7cb0b 100644
--- a/src/com/android/launcher3/BaseContainerView.java
+++ b/src/com/android/launcher3/BaseContainerView.java
@@ -51,7 +51,9 @@
super(context, attrs, defStyleAttr);
int width = ((Launcher) context).getDeviceProfile().availableWidthPx;
- if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && (this instanceof AllAppsContainerView)) {
+ if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP &&
+ this instanceof AllAppsContainerView &&
+ !((Launcher) context).getDeviceProfile().isLandscape) {
mHorizontalPadding = 0;
} else {
mHorizontalPadding = DeviceProfile.getContainerPadding(context, width);
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 4a550ed..86f22d5 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -457,17 +457,14 @@
// Layout the page indicators
View pageIndicator = launcher.findViewById(R.id.page_indicator);
if (pageIndicator != null) {
- if (hasVerticalBarLayout) {
- // Hide the page indicators when we have vertical search/hotseat
- pageIndicator.setVisibility(View.GONE);
- } else {
+ lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams();
+ if (!hasVerticalBarLayout) {
// Put the page indicators above the hotseat
- lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams();
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
lp.width = LayoutParams.WRAP_CONTENT;
lp.bottomMargin = hotseatBarHeightPx;
- pageIndicator.setLayoutParams(lp);
}
+ pageIndicator.setLayoutParams(lp);
}
// Layout the Overview Mode
diff --git a/src/com/android/launcher3/InsettableFrameLayout.java b/src/com/android/launcher3/InsettableFrameLayout.java
index 61edc0f..db4d855 100644
--- a/src/com/android/launcher3/InsettableFrameLayout.java
+++ b/src/com/android/launcher3/InsettableFrameLayout.java
@@ -18,6 +18,10 @@
@ViewDebug.ExportedProperty(category = "launcher")
protected Rect mInsets = new Rect();
+ public Rect getInsets() {
+ return mInsets;
+ }
+
public InsettableFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
setOnHierarchyChangeListener(this);
@@ -34,9 +38,6 @@
lp.rightMargin += (newInsets.right - oldInsets.right);
lp.bottomMargin += (newInsets.bottom - oldInsets.bottom);
}
- if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && child instanceof AllAppsContainerView) {
- lp.setMargins(0, 0, 0, lp.bottomMargin);
- }
child.setLayoutParams(lp);
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 705cb58..c1c41a8 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -113,7 +113,7 @@
import com.android.launcher3.logging.LoggerUtils;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.model.WidgetsModel;
-import com.android.launcher3.pageindicators.PageIndicatorLine;
+import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.PackageManagerHelper;
@@ -233,7 +233,7 @@
@Thunk Workspace mWorkspace;
private View mLauncherView;
- private PageIndicatorLine mPageIndicator;
+ private PageIndicator mPageIndicator;
@Thunk DragLayer mDragLayer;
private DragController mDragController;
@@ -1346,7 +1346,7 @@
mFocusHandler = mDragLayer.getFocusIndicatorHelper();
mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
- mPageIndicator = (PageIndicatorLine) mDragLayer.findViewById(R.id.page_indicator);
+ mPageIndicator = (PageIndicator) mDragLayer.findViewById(R.id.page_indicator);
mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
@@ -2491,7 +2491,7 @@
if (v instanceof FolderIcon) {
onClickFolderIcon(v);
}
- } else if (v == mAllAppsButton) {
+ } else if (v instanceof PageIndicator || v == mAllAppsButton) {
onClickAllAppsButton(v);
} else if (tag instanceof AppInfo) {
startAppShortcutOrInfoActivity(v);
@@ -3447,7 +3447,7 @@
* Updates the set of predicted apps if it hasn't been updated since the last time Launcher was
* resumed.
*/
- private void tryAndUpdatePredictedApps() {
+ public void tryAndUpdatePredictedApps() {
if (mLauncherCallbacks != null) {
List<ComponentKey> apps = mLauncherCallbacks.getPredictedApps();
if (apps != null) {
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index d62c629..bdd026d 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -249,10 +249,9 @@
cancelAnimation();
final View contentView = toView.getContentView();
-
+ playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
+ animated, initialized, animation, revealDuration, layerViews);
if (!animated || !initialized) {
- playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
- animated, initialized, animation, revealDuration, layerViews);
toView.setTranslationX(0.0f);
toView.setTranslationY(0.0f);
@@ -276,9 +275,6 @@
return null;
}
if (animType == CIRCULAR_REVEAL) {
- playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
- animated, initialized, animation, revealDuration, layerViews);
-
// Setup the reveal view animation
final View revealView = toView.getRevealView();
@@ -425,8 +421,6 @@
}
});
mAllAppsController.animateToAllApps(animation, revealDuration);
- playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
- animated, initialized, animation, revealDuration, layerViews);
dispatchOnLauncherTransitionPrepare(fromView, animated, false);
dispatchOnLauncherTransitionPrepare(toView, animated, false);
@@ -675,9 +669,9 @@
boolean multiplePagesVisible = toWorkspaceState.hasMultipleVisiblePages;
+ playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
+ animated, initialized, animation, revealDuration, layerViews);
if (!animated || !initialized) {
- playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
- animated, initialized, animation, revealDuration, layerViews);
if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
mAllAppsController.finishPullDown();
}
@@ -694,12 +688,9 @@
if (onCompleteRunnable != null) {
onCompleteRunnable.run();
}
-
return null;
}
if (animType == CIRCULAR_REVEAL) {
- playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
- animated, initialized, animation, revealDuration, layerViews);
final View revealView = fromView.getRevealView();
final View contentView = fromView.getContentView();
@@ -880,8 +871,6 @@
});
mAllAppsController.animateToWorkspace(animation, revealDuration);
- playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
- animated, initialized, animation, revealDuration, layerViews);
// Dispatch the prepare transition signal
dispatchOnLauncherTransitionPrepare(fromView, animated, false);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 60a1c9d..ca46d74 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -75,7 +75,7 @@
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logging.UserEventDispatcher;
-import com.android.launcher3.pageindicators.PageIndicatorLine;
+import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.LongArrayMap;
@@ -2100,9 +2100,9 @@
@Override
public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) {
- if (mPageIndicator instanceof PageIndicatorLine) {
+ if (mPageIndicator instanceof PageIndicator) {
boolean isNewStateSpringLoaded = mState == State.SPRING_LOADED;
- ((PageIndicatorLine) mPageIndicator).setShouldAutoHide(!isNewStateSpringLoaded);
+ mPageIndicator.setShouldAutoHide(!isNewStateSpringLoaded);
if (isNewStateSpringLoaded) {
// Show the page indicator at the same time as the rest of the transition.
showPageIndicatorAtCurrentScroll();
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 0f437c1..d59058b 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -490,7 +490,8 @@
final DragLayer dragLayer = mLauncher.getDragLayer();
final float startAlpha = dragLayer.getBackgroundAlpha();
- float finalAlpha = states.stateIsNormal ? 0 : mWorkspaceScrimAlpha;
+ float finalAlpha = states.stateIsNormal || states.stateIsNormalHidden ?
+ 0 : mWorkspaceScrimAlpha;
if (finalAlpha != startAlpha) {
if (animated) {
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index a74c4c5..b5dc0c0 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -185,7 +185,8 @@
mApps.setAdapter(mAdapter);
mLayoutManager = mAdapter.getLayoutManager();
mItemDecoration = mAdapter.getItemDecoration();
- if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
+ DeviceProfile grid = mLauncher.getDeviceProfile();
+ if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && !grid.isLandscape) {
mRecyclerViewTopBottomPadding = 0;
setPadding(0, 0, 0, 0);
} else {
@@ -350,7 +351,12 @@
mAppsRecyclerView.setPremeasuredIconHeights(predIcon.getMeasuredHeight(),
icon.getMeasuredHeight());
- updatePaddingsAndMargins();
+ // TODO(hyunyoungs): clean up setting the content and the reveal view.
+ if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
+ getContentView().setBackground(null);
+ getRevealView().setVisibility(View.VISIBLE);
+ getRevealView().setAlpha(AllAppsTransitionController.ALL_APPS_FINAL_ALPHA);
+ }
}
@Override
@@ -358,6 +364,7 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ updatePaddingsAndMargins();
mContentBounds.set(mHorizontalPadding, 0,
MeasureSpec.getSize(widthMeasureSpec) - mHorizontalPadding,
MeasureSpec.getSize(heightMeasureSpec));
@@ -366,6 +373,7 @@
int availableWidth = (!mContentBounds.isEmpty() ? mContentBounds.width() :
MeasureSpec.getSize(widthMeasureSpec))
- 2 * mAppsRecyclerView.getMaxScrollbarWidth();
+ grid.updateAppsViewNumCols(getResources(), availableWidth);
if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
if (mNumAppsPerRow != grid.inv.numColumns ||
mNumPredictedAppsPerRow != grid.inv.numColumns) {
@@ -378,6 +386,7 @@
if (mNumAppsPerRow > 0) {
int iconSize = availableWidth / mNumAppsPerRow;
int iconSpacing = (iconSize - grid.allAppsIconSizePx) / 2;
+ mSearchInput.setPaddingRelative(iconSpacing, 0, iconSpacing, 0);
}
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
@@ -450,23 +459,25 @@
lp.leftMargin = bgPadding.left;
lp.rightMargin = bgPadding.right;
+ DeviceProfile grid = mLauncher.getDeviceProfile();
if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
- MarginLayoutParams mlp = (MarginLayoutParams) mAppsRecyclerView.getLayoutParams();
+ if (!grid.isLandscape) {
+ MarginLayoutParams mlp = (MarginLayoutParams) mAppsRecyclerView.getLayoutParams();
- int navBarHeight = 84; /* replace with mInset.height() in dragLayer */
- DeviceProfile grid = mLauncher.getDeviceProfile();
- int height = navBarHeight + grid.hotseatCellHeightPx;
+ int navBarHeight = mLauncher.getDragLayer().getInsets().top;
+ int height = navBarHeight + grid.hotseatCellHeightPx;
- mlp.topMargin = height;
- mAppsRecyclerView.setLayoutParams(mlp);
+ mlp.topMargin = height;
+ mAppsRecyclerView.setLayoutParams(mlp);
- LinearLayout.LayoutParams llp =
- (LinearLayout.LayoutParams) mSearchInput.getLayoutParams();
- llp.topMargin = navBarHeight;
- mSearchInput.setLayoutParams(llp);
+ LinearLayout.LayoutParams llp =
+ (LinearLayout.LayoutParams) mSearchInput.getLayoutParams();
+ llp.topMargin = navBarHeight;
+ mSearchInput.setLayoutParams(llp);
- lp.height = height;
- mSearchContainer.setBackground(null);
+ lp.height = height;
+ }
+ mSearchContainer.getBackground().setAlpha(0);
}
mSearchContainer.setLayoutParams(lp);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 7f047d5..c443b1e 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -8,10 +8,13 @@
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;
import com.android.launcher3.CellLayout;
+import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
@@ -34,16 +37,21 @@
private static final String TAG = "AllAppsTrans";
private static final boolean DBG = false;
- private final Interpolator mAccelInterpolator = new AccelerateInterpolator(1f);
+ 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;
- private static final float FINAL_ALPHA = .65f;
+ public static final float ALL_APPS_FINAL_ALPHA = .8f;
+
+ private static final float PARALLAX_COEFFICIENT = .125f;
private AllAppsContainerView mAppsView;
private Workspace mWorkspace;
private Hotseat mHotseat;
private Drawable mHotseatBackground;
private float mHotseatAlpha;
+ private float mStatusBarHeight;
private final Launcher mLauncher;
private final VerticalPullDetector mDetector;
@@ -56,12 +64,21 @@
private static final float RECATCH_REJECTION_FRACTION = .0875f;
+ // Used in landscape.
+ private static final float BAZEL_PULL_UP_HEIGHT = 60;
+
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);
@@ -78,6 +95,8 @@
} else if (mLauncher.isAllAppsVisible() &&
!mAppsView.shouldContainerScroll(ev.getX(), ev.getY())) {
mNoIntercept = true;
+ } else if (!mLauncher.isAllAppsVisible() && !shouldPossiblyIntercept(ev)) {
+ mNoIntercept = true;
} else {
mDetector.setDetectableScrollConditions(mLauncher.isAllAppsVisible() /* down */,
isInDisallowRecatchTopZone(), isInDisallowRecatchBottomZone());
@@ -90,6 +109,22 @@
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;
+ }
+ return false;
+ } else {
+ return true;
+ }
+ }
+
@Override
public boolean onTouchEvent(MotionEvent ev) {
return mDetector.onTouchEvent(ev);
@@ -111,6 +146,7 @@
mHotseat = mLauncher.getHotseat();
mWorkspace = mLauncher.getWorkspace();
+ mStatusBarHeight = mLauncher.getDragLayer().getInsets().height();
if (mHotseatBackground == null) {
mHotseatBackground = mHotseat.getBackground();
mHotseatAlpha = mHotseatBackground.getAlpha() / 255f;
@@ -119,6 +155,7 @@
@Override
public void onScrollStart(boolean start) {
+ init();
cancelAnimation();
mCurrentAnimation = LauncherAnimUtils.createAnimatorSet();
preparePull(start);
@@ -133,18 +170,21 @@
mHotseat.bringToFront();
if (start) {
if (!mLauncher.isAllAppsVisible()) {
+ mLauncher.tryAndUpdatePredictedApps();
mHotseat.setBackground(null);
mAppsView.setVisibility(View.VISIBLE);
mAppsView.getContentView().setVisibility(View.VISIBLE);
mAppsView.getContentView().setBackground(null);
mAppsView.getRevealView().setVisibility(View.VISIBLE);
mAppsView.getRevealView().setAlpha(mHotseatAlpha);
- mAppsView.setSearchBarVisible(false);
- if (mTranslation < 0) {
+ DeviceProfile grid= mLauncher.getDeviceProfile();
+ if (!grid.isLandscape) {
mTranslation = mHotseat.getTop();
- setProgress(mTranslation);
+ } else {
+ mTranslation = mHotseat.getBottom();
}
+ setProgress(mTranslation);
} else {
// TODO: get rid of this workaround to override state change by workspace transition
mWorkspace.onLauncherTransitionPrepare(mLauncher, false, false);
@@ -152,14 +192,16 @@
.getShortcutsAndWidgets();
child.setVisibility(View.VISIBLE);
child.setAlpha(1f);
-
- mAppsView.setSearchBarVisible(false);
- setLightStatusBar(false);
}
}
}
- private void setLightStatusBar(boolean enable) {
+ private void updateLightStatusBar(float progress) {
+ boolean enable = (progress < mStatusBarHeight / 2);
+ // Already set correctly
+ if (mLightStatusBar == enable) {
+ return;
+ }
int systemUiFlags = mLauncher.getWindow().getDecorView().getSystemUiVisibility();
if (enable) {
mLauncher.getWindow().getDecorView().setSystemUiVisibility(systemUiFlags
@@ -170,6 +212,7 @@
& ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
+ mLightStatusBar = enable;
}
@Override
@@ -187,17 +230,20 @@
* @param progress y value of the border between hotseat and all apps
*/
public void setProgress(float progress) {
+ updateLightStatusBar(progress);
mProgressTransY = progress;
float alpha = calcAlphaAllApps(progress);
float workspaceHotseatAlpha = 1 - alpha;
- mAppsView.getRevealView().setAlpha(Math.min(FINAL_ALPHA, Math.max(mHotseatAlpha, alpha)));
+ mAppsView.getRevealView().setAlpha(Math.min(ALL_APPS_FINAL_ALPHA, Math.max(mHotseatAlpha,
+ mDecelInterpolator.getInterpolation(alpha))));
mAppsView.getContentView().setAlpha(alpha);
mAppsView.setTranslationY(progress);
- mWorkspace.setWorkspaceTranslation(View.TRANSLATION_Y, -mTranslation + progress,
+ mWorkspace.setWorkspaceTranslation(View.TRANSLATION_Y,
+ PARALLAX_COEFFICIENT *(-mTranslation + progress),
mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
- mWorkspace.setHotseatTranslation(
- View.TRANSLATION_Y, -mTranslation + progress, workspaceHotseatAlpha);
+ mWorkspace.setHotseatTranslation(View.TRANSLATION_Y, -mTranslation + progress,
+ mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
}
public float getProgress() {
@@ -217,26 +263,27 @@
if (fling) {
if (velocity < 0) {
calculateDuration(velocity, mAppsView.getTranslationY());
- showAppsView(); // Flinging in UP direction
+ animateToAllApps(mCurrentAnimation, mAnimationDuration);
} else {
calculateDuration(velocity, Math.abs(mTranslation - mAppsView.getTranslationY()));
- showWorkspace(); // Flinging in DOWN direction
+ 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()));
- showWorkspace(); // Released in the bottom half
+ animateToWorkspace(mCurrentAnimation, mAnimationDuration);
} else {
calculateDuration(velocity, Math.abs(mAppsView.getTranslationY()));
- showAppsView(); // Released in the top half
+ animateToAllApps(mCurrentAnimation, mAnimationDuration);
}
}
+ mCurrentAnimation.start();
}
private void calculateDuration(float velocity, float disp) {
// TODO: make these values constants after tuning.
- float velocityDivisor = Math.max(1.5f, Math.abs(0.25f * velocity));
+ float velocityDivisor = Math.max(1.5f, Math.abs(0.5f * velocity));
float travelDistance = Math.max(0.2f, disp / mTranslation);
mAnimationDuration = (long) Math.max(100, ANIMATION_DURATION / velocityDivisor * travelDistance);
if (DBG) {
@@ -244,35 +291,6 @@
}
}
- /**
- * Depending on the current state of the launcher, either just
- * 1) animate
- * 2) animate and do all the state updates.
- */
- private void showAppsView() {
- if (mLauncher.isAllAppsVisible()) {
- animateToAllApps(mCurrentAnimation, mAnimationDuration);
- mCurrentAnimation.start();
- } else {
- mLauncher.showAppsView(true /* animated */, true /* resetListToTop */,
- true /* updatePredictedApps */, false /* focusSearchBar */);
- }
- }
-
- /**
- * Depending on the current state of the launcher, either just
- * 1) animate
- * 2) animate and do all the state updates.
- */
- private void showWorkspace() {
- if (mLauncher.isAllAppsVisible()) {
- mLauncher.showWorkspace(true /* animated */);
- } else {
- animateToWorkspace(mCurrentAnimation, mAnimationDuration);
- mCurrentAnimation.start();
- }
- }
-
public void animateToAllApps(AnimatorSet animationOut, long duration) {
if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
return;
@@ -280,6 +298,7 @@
if (mDetector.isRestingState()) {
preparePull(true);
mAnimationDuration = duration;
+ mStateAlreadyChanged = true;
}
mCurY = mAppsView.getTranslationY();
final float fromAllAppsTop = mAppsView.getTranslationY();
@@ -310,13 +329,6 @@
mCurrentAnimation = animationOut;
}
- private void finishPullUp() {
- mAppsView.setSearchBarVisible(true);
- mHotseat.setVisibility(View.INVISIBLE);
- setProgress(0f);
- setLightStatusBar(true);
- }
-
public void animateToWorkspace(AnimatorSet animationOut, long duration) {
if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
return;
@@ -324,6 +336,7 @@
if(mDetector.isRestingState()) {
preparePull(true);
mAnimationDuration = duration;
+ mStateAlreadyChanged = true;
}
final float fromAllAppsTop = mAppsView.getTranslationY();
final float toAllAppsTop = mTranslation;
@@ -354,12 +367,28 @@
mCurrentAnimation = animationOut;
}
+ 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() {
+ if (mHotseat.getBackground() != null) {
+ return;
+ }
mAppsView.setVisibility(View.INVISIBLE);
mHotseat.setBackground(mHotseatBackground);
mHotseat.setVisibility(View.VISIBLE);
setProgress(mTranslation);
- setLightStatusBar(false);
+ if (!mStateAlreadyChanged) {
+ mLauncher.showWorkspace(false);
+ }
+ mStateAlreadyChanged = false;
}
private void cancelAnimation() {
diff --git a/src/com/android/launcher3/allapps/VerticalPullDetector.java b/src/com/android/launcher3/allapps/VerticalPullDetector.java
index 7df63e0..9304aac 100644
--- a/src/com/android/launcher3/allapps/VerticalPullDetector.java
+++ b/src/com/android/launcher3/allapps/VerticalPullDetector.java
@@ -135,7 +135,7 @@
mDisplacementY = ev.getY() - mDownY;
mVelocity = computeVelocity(ev, mVelocity);
- if (mState == State.SCROLLING && shouldRecatchScrollStart()){
+ if (mState == State.SCROLLING && Math.abs(mDisplacementY) > mTouchSlop ){
setState(State.DRAG);
reportScrollStart(true /* recatch */);
}
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 5d212d8..c62353d 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -187,6 +187,11 @@
removeView(mOverlayView);
}
+ public boolean isEventOverHotseat(MotionEvent ev) {
+ getDescendantRectRelativeToSelf(mLauncher.getHotseat(), mHitRect);
+ return mHitRect.contains((int) ev.getX(), (int) ev.getY());
+ }
+
private boolean isEventOverFolderTextRegion(Folder folder, MotionEvent ev) {
getDescendantRectRelativeToSelf(folder.getEditTextRegion(), mHitRect);
return mHitRect.contains((int) ev.getX(), (int) ev.getY());
diff --git a/src/com/android/launcher3/pageindicators/PageIndicator.java b/src/com/android/launcher3/pageindicators/PageIndicator.java
index 7c59495..2209bb8 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicator.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicator.java
@@ -1,9 +1,26 @@
+/*
+ * Copyright (C) 2016 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.pageindicators;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
+import com.android.launcher3.dynamicui.ExtractedColors;
+
/**
* Base class for a page indicator.
*/
@@ -15,9 +32,9 @@
super(context, attrs, defStyleAttr);
}
- public abstract void setScroll(int currentScroll, int totalScroll);
+ public void setScroll(int currentScroll, int totalScroll) {}
- public abstract void setActiveMarker(int activePage);
+ public void setActiveMarker(int activePage) {}
public void addMarker() {
mNumPages++;
@@ -33,5 +50,9 @@
onPageCountChanged();
}
- protected abstract void onPageCountChanged();
+ protected void onPageCountChanged() { }
+
+ public void setShouldAutoHide(boolean shouldAutoHide) {}
+
+ public void updateColor(ExtractedColors extractedColors) {}
}
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java b/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java
new file mode 100644
index 0000000..0f9145d
--- /dev/null
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 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.pageindicators;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
+import com.android.launcher3.dynamicui.ExtractedColors;
+
+/**
+ * Simply draws the caret drawable in the center. Used for the landscape layout.
+ */
+public class PageIndicatorCaretLandscape extends PageIndicator {
+ // all apps pull up handle drawable.
+ private final Drawable caretDrawable;
+
+ public PageIndicatorCaretLandscape(Context context) {
+ this(context, null);
+ }
+
+ public PageIndicatorCaretLandscape(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public PageIndicatorCaretLandscape(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ Resources res = context.getResources();
+ caretDrawable = res.getDrawable(R.drawable.ic_allapps_caret);
+ Launcher l = (Launcher) context;
+ setOnTouchListener(l.getHapticFeedbackTouchListener());
+ setOnClickListener(l);
+ setOnFocusChangeListener(l.mFocusHandler);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ int size = bottom - top;
+ int l = (right - left) / 2 - size / 2;
+ caretDrawable.setBounds(l, 0, l + size, size);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ caretDrawable.draw(canvas);
+ }
+}
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLine.java b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
similarity index 68%
rename from src/com/android/launcher3/pageindicators/PageIndicatorLine.java
rename to src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
index aec708c..2c157b4 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorLine.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
@@ -5,17 +5,24 @@
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Property;
+import android.view.TouchDelegate;
+import android.view.View;
import android.view.ViewConfiguration;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dynamicui.ExtractedColors;
@@ -24,9 +31,11 @@
*
* The fraction is 1 / number of pages and the position is based on the progress of the page scroll.
*/
-public class PageIndicatorLine extends PageIndicator {
+public class PageIndicatorLineCaret extends PageIndicator {
private static final String TAG = "PageIndicatorLine";
+ private static final int[] sTempCoords = new int[2];
+
private static final int LINE_ANIMATE_DURATION = ViewConfiguration.getScrollBarFadeDuration();
private static final int LINE_FADE_DELAY = ViewConfiguration.getScrollDefaultDelay();
public static final int WHITE_ALPHA = (int) (0.70f * 255);
@@ -51,44 +60,50 @@
private int mCurrentScroll;
private int mTotalScroll;
private Paint mLinePaint;
+ private Launcher mLauncher;
+ // all apps pull up handle drawable.
+ private final Drawable caretDrawable;
+ private final int mLineHeight;
+ private final Rect mTouchHitRect = new Rect();
+ private final int mTouchExtensionHeight;
- private static final Property<PageIndicatorLine, Integer> PAINT_ALPHA
- = new Property<PageIndicatorLine, Integer>(Integer.class, "paint_alpha") {
+ private static final Property<PageIndicatorLineCaret, Integer> PAINT_ALPHA
+ = new Property<PageIndicatorLineCaret, Integer>(Integer.class, "paint_alpha") {
@Override
- public Integer get(PageIndicatorLine obj) {
+ public Integer get(PageIndicatorLineCaret obj) {
return obj.mLinePaint.getAlpha();
}
@Override
- public void set(PageIndicatorLine obj, Integer alpha) {
+ public void set(PageIndicatorLineCaret obj, Integer alpha) {
obj.mLinePaint.setAlpha(alpha);
obj.invalidate();
}
};
- private static final Property<PageIndicatorLine, Float> NUM_PAGES
- = new Property<PageIndicatorLine, Float>(Float.class, "num_pages") {
+ private static final Property<PageIndicatorLineCaret, Float> NUM_PAGES
+ = new Property<PageIndicatorLineCaret, Float>(Float.class, "num_pages") {
@Override
- public Float get(PageIndicatorLine obj) {
+ public Float get(PageIndicatorLineCaret obj) {
return obj.mNumPagesFloat;
}
@Override
- public void set(PageIndicatorLine obj, Float numPages) {
+ public void set(PageIndicatorLineCaret obj, Float numPages) {
obj.mNumPagesFloat = numPages;
obj.invalidate();
}
};
- private static final Property<PageIndicatorLine, Integer> TOTAL_SCROLL
- = new Property<PageIndicatorLine, Integer>(Integer.class, "total_scroll") {
+ private static final Property<PageIndicatorLineCaret, Integer> TOTAL_SCROLL
+ = new Property<PageIndicatorLineCaret, Integer>(Integer.class, "total_scroll") {
@Override
- public Integer get(PageIndicatorLine obj) {
+ public Integer get(PageIndicatorLineCaret obj) {
return obj.mTotalScroll;
}
@Override
- public void set(PageIndicatorLine obj, Integer totalScroll) {
+ public void set(PageIndicatorLineCaret obj, Integer totalScroll) {
obj.mTotalScroll = totalScroll;
obj.invalidate();
}
@@ -101,22 +116,50 @@
}
};
- public PageIndicatorLine(Context context) {
+ public PageIndicatorLineCaret(Context context) {
this(context, null);
}
- public PageIndicatorLine(Context context, AttributeSet attrs) {
+ public PageIndicatorLineCaret(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- public PageIndicatorLine(Context context, AttributeSet attrs, int defStyle) {
+ public PageIndicatorLineCaret(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mLinePaint = new Paint();
mLinePaint.setAlpha(0);
+
+ mLauncher = (Launcher) context;
+ setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
+ setOnClickListener(mLauncher);
+ setOnFocusChangeListener(mLauncher.mFocusHandler);
+ Resources res = context.getResources();
+ caretDrawable = res.getDrawable(R.drawable.ic_allapps_caret);
+ mLineHeight = res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_line_height);
+ mTouchExtensionHeight = res.getDimensionPixelSize(
+ R.dimen.dynamic_grid_page_indicator_extra_touch_height);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ int size = bottom - top;
+ int l = (right - left) / 2 - size / 2;
+ caretDrawable.setBounds(l, 0, l+ size, size);
+
+ // The touch area is expanded below this view by #mTouchExtensionHeight
+ // which extends to the top of the hotseat.
+ View parent = mLauncher.getDragLayer();
+ sTempCoords[0] = sTempCoords[1] = 0;
+ Utilities.getDescendantCoordRelativeToAncestor(this, parent, sTempCoords, true);
+ mTouchHitRect.set(sTempCoords[0], sTempCoords[1], sTempCoords[0] + this.getWidth(),
+ sTempCoords[1] + getHeight() + mTouchExtensionHeight);
+ parent.setTouchDelegate(new TouchDelegate(mTouchHitRect, this));
}
@Override
protected void onDraw(Canvas canvas) {
+ caretDrawable.draw(canvas);
if (mTotalScroll == 0 || mNumPagesFloat == 0) {
return;
}
@@ -127,7 +170,8 @@
int lineWidth = (int) (availableWidth / mNumPagesFloat);
int lineLeft = (int) (progress * (availableWidth - lineWidth));
int lineRight = lineLeft + lineWidth;
- canvas.drawRect(lineLeft, 0, lineRight, canvas.getHeight(), mLinePaint);
+ canvas.drawRect(lineLeft, canvas.getHeight() + mLineHeight, lineRight, canvas.getHeight(),
+ mLinePaint);
}
@Override