Merge "Replacing some method definitions with default platform implementations" into ub-launcher3-master
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index b59e4ee..530d757 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -17,7 +17,6 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
@@ -27,6 +26,7 @@
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.anim.AnimationSuccessListener;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsView;
@@ -55,17 +55,17 @@
@Override
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
- AnimatorSet anim, AnimationConfig config) {
+ AnimatorSetBuilder builder, AnimationConfig config) {
ObjectAnimator progressAnim =
mTransitionProgress.animateToValue(toState == LauncherState.OVERVIEW ? 1 : 0);
progressAnim.setDuration(config.duration);
progressAnim.setInterpolator(Interpolators.LINEAR);
- anim.play(progressAnim);
+ builder.play(progressAnim);
ObjectAnimator visibilityAnim = animateVisibility(toState == LauncherState.OVERVIEW);
visibilityAnim.setDuration(config.duration);
visibilityAnim.setInterpolator(Interpolators.LINEAR);
- anim.play(visibilityAnim);
+ builder.play(visibilityAnim);
}
public void setVisibility(boolean isVisible) {
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 6e91095..be509ed 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -48,12 +48,16 @@
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
+ android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:layout_alignBottom="@+id/tabs" />
<com.android.launcher3.views.SlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_header_tab_height"
+ android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
+ android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:layout_below="@id/header_content"
android:orientation="horizontal" >
<Button
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e7f45c2..e22c7c2 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -96,6 +96,7 @@
<dimen name="all_apps_prediction_row_divider_height">17dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_bottom_padding">20dp</dimen>
+ <dimen name="all_apps_tabs_side_padding">12dp</dimen>
<!-- Search bar in All Apps -->
<dimen name="all_apps_header_max_elevation">3dp</dimen>
diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java
index bce0e2e..76c7845 100644
--- a/src/com/android/launcher3/BaseRecyclerView.java
+++ b/src/com/android/launcher3/BaseRecyclerView.java
@@ -17,13 +17,11 @@
package com.android.launcher3;
import android.content.Context;
-import android.graphics.Canvas;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.TextView;
import com.android.launcher3.views.RecyclerViewFastScroller;
@@ -91,8 +89,10 @@
*/
private boolean handleTouchEvent(MotionEvent ev) {
// Move to mScrollbar's coordinate system.
- int left = getLeft() - mScrollbar.getLeft();
- int top = getTop() - mScrollbar.getTop();
+ // We need to take parent into account (view pager's location)
+ ViewGroup parent = (ViewGroup) getParent();
+ int left = parent.getLeft() + getLeft() - mScrollbar.getLeft();
+ int top = parent.getTop() + getTop() - mScrollbar.getTop() - getScrollBarTop();
ev.offsetLocation(left, top);
try {
return mScrollbar.handleTouchEvent(ev);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index f60bed8..0c573ac 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1380,7 +1380,6 @@
} catch (NullPointerException ex) {
Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex);
}
- mAppWidgetHost = null;
TextKeyListener.getInstance().release();
WallpaperColorInfo.getInstance(this).setOnThemeChangeListener(null);
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 2cad95e..de21c7f 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -28,6 +28,7 @@
import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.uioverrides.UiFactory;
/**
@@ -178,7 +179,8 @@
// transition plays in reverse and use the same duration as previous state.
mConfig.duration = state == NORMAL ? mState.transitionDuration : state.transitionDuration;
- AnimatorSet animation = createAnimationToNewWorkspaceInternal(state, onCompleteRunnable);
+ AnimatorSet animation = createAnimationToNewWorkspaceInternal(
+ state, new AnimatorSetBuilder(), onCompleteRunnable);
Runnable runnable = new StartAnimRunnable(animation, state.getFinalFocus(mLauncher));
if (delay > 0) {
mUiHandler.postDelayed(runnable, delay);
@@ -196,21 +198,28 @@
*/
public AnimatorPlaybackController createAnimationToNewWorkspace(
LauncherState state, long duration) {
+ return createAnimationToNewWorkspace(state, new AnimatorSetBuilder(), duration);
+ }
+
+ public AnimatorPlaybackController createAnimationToNewWorkspace(
+ LauncherState state, AnimatorSetBuilder builder, long duration) {
mConfig.reset();
mConfig.userControlled = true;
mConfig.duration = duration;
return AnimatorPlaybackController.wrap(
- createAnimationToNewWorkspaceInternal(state, null), duration);
+ createAnimationToNewWorkspaceInternal(state, builder, null), duration);
}
protected AnimatorSet createAnimationToNewWorkspaceInternal(final LauncherState state,
- final Runnable onCompleteRunnable) {
- final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
+ AnimatorSetBuilder builder, final Runnable onCompleteRunnable) {
final AnimationLayerSet layerViews = new AnimationLayerSet();
for (StateHandler handler : getStateHandlers()) {
- handler.setStateWithAnimation(state, layerViews, animation, mConfig);
+ builder.startTag(handler);
+ handler.setStateWithAnimation(state, layerViews, builder, mConfig);
}
+
+ final AnimatorSet animation = builder.build();
animation.addListener(layerViews);
animation.addListener(new AnimationSuccessListener() {
@@ -331,7 +340,7 @@
* Sets the UI to {@param state} by animating any changes.
*/
void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
- AnimatorSet anim, AnimationConfig config);
+ AnimatorSetBuilder builder, AnimationConfig config);
}
public interface StateListener {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 3d59bad..a67b92a 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -26,7 +26,6 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
@@ -64,6 +63,7 @@
import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate;
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
import com.android.launcher3.anim.AnimationLayerSet;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.badge.FolderBadgeInfo;
import com.android.launcher3.compat.AppWidgetManagerCompat;
@@ -1548,9 +1548,9 @@
*/
@Override
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
- AnimatorSet anim, AnimationConfig config) {
+ AnimatorSetBuilder builder, AnimationConfig config) {
StateTransitionListener listener = new StateTransitionListener(toState);
- mStateTransitionAnimation.setStateWithAnimation(toState, anim, layerViews, config);
+ mStateTransitionAnimation.setStateWithAnimation(toState, builder, layerViews, config);
// Invalidate the pages now, so that we have the visible pages before the
// animation is started
@@ -1562,8 +1562,8 @@
ValueAnimator stepAnimator = ValueAnimator.ofFloat(0, 1);
stepAnimator.addUpdateListener(listener);
stepAnimator.setDuration(config.duration);
- anim.play(stepAnimator);
- anim.addListener(listener);
+ stepAnimator.addListener(listener);
+ builder.play(stepAnimator);
}
public void updateAccessibilityFlags() {
@@ -3502,17 +3502,17 @@
mRefreshPending = false;
- mapOverItems(MAP_NO_RECURSE, new ItemOperator() {
- @Override
- public boolean evaluate(ItemInfo info, View view) {
- if (view instanceof PendingAppWidgetHostView && mInfos.contains(info)) {
- mLauncher.removeItem(view, info, false /* deleteFromDb */);
- mLauncher.bindAppWidget((LauncherAppWidgetInfo) info);
- }
- // process all the shortcuts
- return false;
+ ArrayList<PendingAppWidgetHostView> views = new ArrayList<>(mInfos.size());
+ mapOverItems(MAP_NO_RECURSE, (info, view) -> {
+ if (view instanceof PendingAppWidgetHostView && mInfos.contains(info)) {
+ views.add((PendingAppWidgetHostView) view);
}
+ // process all children
+ return false;
});
+ for (PendingAppWidgetHostView view : views) {
+ view.reinflate();
+ }
}
@Override
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index edf5ada..0ec3142 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -33,6 +33,7 @@
import com.android.launcher3.LauncherState.PageAlphaProvider;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.anim.AnimationLayerSet;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
/**
@@ -110,10 +111,10 @@
setWorkspaceProperty(toState, NO_ANIM_PROPERTY_SETTER);
}
- public void setStateWithAnimation(LauncherState toState, AnimatorSet anim,
+ public void setStateWithAnimation(LauncherState toState, AnimatorSetBuilder builder,
AnimationLayerSet layerViews, AnimationConfig config) {
AnimatedPropertySetter propertySetter =
- new AnimatedPropertySetter(config.duration, layerViews, anim);
+ new AnimatedPropertySetter(config.duration, layerViews, builder);
setWorkspaceProperty(toState, propertySetter);
}
@@ -190,13 +191,13 @@
private final long mDuration;
private final AnimationLayerSet mLayerViews;
- private final AnimatorSet mStateAnimator;
+ private final AnimatorSetBuilder mStateAnimator;
public AnimatedPropertySetter(
- long duration, AnimationLayerSet layerView, AnimatorSet anim) {
+ long duration, AnimationLayerSet layerView, AnimatorSetBuilder builder) {
mDuration = duration;
mLayerViews = layerView;
- mStateAnimator = anim;
+ mStateAnimator = builder;
}
@Override
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 0c992ba..d67fb5d 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -261,9 +261,6 @@
if (mLauncher.getDragLayer().isEventOverView(mSearchContainer, ev)) {
return true;
}
- if (mUsingTabs && mLauncher.getDragLayer().isEventOverView(mHeader, ev)) {
- return true;
- }
AllAppsRecyclerView rv = getActiveRecyclerView();
return rv == null || rv.shouldContainerScroll(ev, mLauncher.getDragLayer());
}
@@ -555,20 +552,9 @@
return;
}
mHeader.setVisibility(View.VISIBLE);
+ mHeader.setup(mAH, mComponentToAppMap, mNumPredictedAppsPerRow);
- boolean usePredictionRow = mHasPredictions && !mSearchModeWhileUsingTabs;
- int contentHeight = usePredictionRow ? mLauncher.getDeviceProfile().allAppsCellHeightPx : 0;;
- if (usePredictionRow && !mUsingTabs) {
- contentHeight += getResources()
- .getDimensionPixelSize(R.dimen.all_apps_prediction_row_divider_height);
- }
- AllAppsRecyclerView mainRV = mAH[AdapterHolder.MAIN].recyclerView;
- AllAppsRecyclerView workRV = mAH[AdapterHolder.WORK].recyclerView;
- mHeader.setup(mainRV, workRV, contentHeight);
- mHeader.getPredictionRow().setup(mAH[AdapterHolder.MAIN].adapter,
- mComponentToAppMap, mNumPredictedAppsPerRow);
-
- int padding = contentHeight;
+ int padding = mHeader.getPredictionRow().getExpectedHeight();
if (mHasPredictions && !mUsingTabs) {
padding += mHeader.getPaddingTop() + mHeader.getPaddingBottom();
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 7ce032f..14ad97b 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -5,7 +5,6 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.util.Property;
import android.view.View;
@@ -21,6 +20,7 @@
import com.android.launcher3.Workspace;
import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.anim.AnimationSuccessListener;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.graphics.GradientView;
import com.android.launcher3.util.SystemUiController;
@@ -122,7 +122,7 @@
* @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace
*
* @see #setState(LauncherState)
- * @see #setStateWithAnimation(LauncherState, AnimationLayerSet, AnimatorSet, AnimationConfig)
+ * @see #setStateWithAnimation(LauncherState, AnimationLayerSet, AnimatorSetBuilder, AnimationConfig)
*/
public void setProgress(float progress) {
mProgress = progress;
@@ -168,7 +168,7 @@
*/
@Override
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
- AnimatorSet animationOut, AnimationConfig config) {
+ AnimatorSetBuilder builder, AnimationConfig config) {
if (Float.compare(mProgress, toState.verticalProgress) == 0) {
// Fail fast
onProgressAnimationEnd();
@@ -182,7 +182,7 @@
anim.setInterpolator(interpolator);
anim.addListener(getProgressAnimatorListener());
- animationOut.play(anim);
+ builder.play(anim);
}
public AnimatorListenerAdapter getProgressAnimatorListener() {
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index 39e6818..dc3afb5 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -19,43 +19,38 @@
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Point;
import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
+import com.android.launcher3.AppInfo;
import com.android.launcher3.R;
+import com.android.launcher3.util.ComponentKey;
+
+import java.util.HashMap;
public class FloatingHeaderView extends RelativeLayout implements
ValueAnimator.AnimatorUpdateListener {
- private static final boolean SHOW_PREDICTIONS_ONLY_ON_TOP = true;
private final Rect mClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
private final ValueAnimator mAnimator = ValueAnimator.ofInt(0, 0);
+ private final Point mTempOffset = new Point();
private final RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
- if (SHOW_PREDICTIONS_ONLY_ON_TOP) {
- return;
- }
- if (!mTopOnlyMode && newState == RecyclerView.SCROLL_STATE_IDLE
- && mTranslationY != -mMaxTranslation && mTranslationY != 0) {
- float scroll = Math.abs(getCurrentScroll());
- boolean expand = scroll > mMaxTranslation
- ? Math.abs(mTranslationY) < mMaxTranslation / 2 : true;
- setExpanded(expand);
- }
}
@Override
public void onScrolled(RecyclerView rv, int dx, int dy) {
- boolean isMainRV = rv == mMainRV;
- if (isMainRV != mMainRVActive) {
+ if (rv != mCurrentRV) {
return;
}
@@ -63,9 +58,7 @@
mAnimator.cancel();
}
- int current = - (isMainRV
- ? mMainRV.getCurrentScrollY()
- : mWorkRV.getCurrentScrollY());
+ int current = -mCurrentRV.getCurrentScrollY();
moved(current);
apply();
}
@@ -76,14 +69,14 @@
private View mDivider;
private AllAppsRecyclerView mMainRV;
private AllAppsRecyclerView mWorkRV;
- private boolean mTopOnlyMode;
- private boolean mHeaderHidden;
+ private AllAppsRecyclerView mCurrentRV;
+ private ViewGroup mParent;
+ private boolean mTabsHidden;
+ private boolean mHeaderCollapsed;
private int mMaxTranslation;
private int mSnappedScrolledY;
private int mTranslationY;
- private int mMainScrolledY;
- private int mWorkScrolledY;
- private boolean mMainRVActive;
+ private boolean mForwardToRecyclerView;
public FloatingHeaderView(@NonNull Context context) {
this(context, null);
@@ -101,14 +94,18 @@
mPredictionRow = findViewById(R.id.header_content);
}
- public void setup(@NonNull AllAppsRecyclerView personalRV, @Nullable AllAppsRecyclerView workRV,
- int predictionRowHeight) {
- mTopOnlyMode = workRV == null;
- mTabLayout.setVisibility(mTopOnlyMode ? View.GONE : View.VISIBLE);
- mPredictionRow.getLayoutParams().height = predictionRowHeight;
- mMaxTranslation = predictionRowHeight;
- mMainRV = setupRV(mMainRV, personalRV);
- mWorkRV = setupRV(mWorkRV, workRV);
+ public void setup(AllAppsContainerView.AdapterHolder[] mAH,
+ HashMap<ComponentKey, AppInfo> componentToAppMap, int numPredictedAppsPerRow) {
+ mTabsHidden = mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView == null;
+ mTabLayout.setVisibility(mTabsHidden ? View.GONE : View.VISIBLE);
+ mPredictionRow.setPadding(0, 0, 0, mTabsHidden ? getResources()
+ .getDimensionPixelSize(R.dimen.all_apps_prediction_row_divider_height) : 0);
+ mPredictionRow.setup(mAH[AllAppsContainerView.AdapterHolder.MAIN].adapter,
+ componentToAppMap, numPredictedAppsPerRow);
+ mMaxTranslation = mPredictionRow.getExpectedHeight();
+ mMainRV = setupRV(mMainRV, mAH[AllAppsContainerView.AdapterHolder.MAIN].recyclerView);
+ mWorkRV = setupRV(mWorkRV, mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView);
+ mParent = (ViewGroup) mMainRV.getParent();
setMainActive(true);
setupDivider();
}
@@ -124,16 +121,16 @@
Resources res = getResources();
int verticalGap = res.getDimensionPixelSize(R.dimen.all_apps_divider_margin_vertical);
int sideGap = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
- mDivider.setPadding(sideGap, verticalGap,sideGap, mTopOnlyMode ? verticalGap : 0);
+ mDivider.setPadding(sideGap, verticalGap,sideGap, mTabsHidden ? verticalGap : 0);
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mDivider.getLayoutParams();
lp.removeRule(RelativeLayout.ALIGN_BOTTOM);
- lp.addRule(RelativeLayout.ALIGN_BOTTOM, mTopOnlyMode ? R.id.header_content : R.id.tabs);
+ lp.addRule(RelativeLayout.ALIGN_BOTTOM, mTabsHidden ? R.id.header_content : R.id.tabs);
mDivider.setLayoutParams(lp);
}
public void setMainActive(boolean active) {
- mMainRVActive = active;
- mSnappedScrolledY = getCurrentScroll() - mMaxTranslation;
+ mCurrentRV = active ? mMainRV : mWorkRV;
+ mSnappedScrolledY = mCurrentRV.getCurrentScrollY() - mMaxTranslation;
setExpanded(true);
}
@@ -141,36 +138,29 @@
return mPredictionRow;
}
- public ViewGroup getTabLayout() {
- return mTabLayout;
- }
-
public View getDivider() {
return mDivider;
}
public void reset() {
- mMainScrolledY = 0;
- mWorkScrolledY = 0;
setExpanded(true);
}
private boolean canSnapAt(int currentScrollY) {
- boolean snapOnlyOnTop = SHOW_PREDICTIONS_ONLY_ON_TOP || mTopOnlyMode;
- return !snapOnlyOnTop || Math.abs(currentScrollY) <= mPredictionRow.getHeight();
+ return Math.abs(currentScrollY) <= mPredictionRow.getHeight();
}
private void moved(final int currentScrollY) {
- if (mHeaderHidden) {
+ if (mHeaderCollapsed) {
if (currentScrollY <= mSnappedScrolledY) {
if (canSnapAt(currentScrollY)) {
mSnappedScrolledY = currentScrollY;
}
} else {
- mHeaderHidden = false;
+ mHeaderCollapsed = false;
}
mTranslationY = currentScrollY;
- } else if (!mHeaderHidden) {
+ } else if (!mHeaderCollapsed) {
mTranslationY = currentScrollY - mSnappedScrolledY - mMaxTranslation;
// update state vars
@@ -178,7 +168,7 @@
mTranslationY = 0;
mSnappedScrolledY = currentScrollY - mMaxTranslation;
} else if (mTranslationY <= -mMaxTranslation) { // hide or stay hidden
- mHeaderHidden = true;
+ mHeaderCollapsed = true;
mSnappedScrolledY = currentScrollY;
}
}
@@ -195,7 +185,7 @@
mPredictionRow.setTranslationY(uncappedTranslationY);
}
mTabLayout.setTranslationY(mTranslationY);
- mDivider.setTranslationY(mTopOnlyMode ? uncappedTranslationY : mTranslationY);
+ mDivider.setTranslationY(mTabsHidden ? uncappedTranslationY : mTranslationY);
mClip.top = mMaxTranslation + mTranslationY;
// clipping on a draw might cause additional redraw
mMainRV.setClipBounds(mClip);
@@ -210,16 +200,14 @@
mAnimator.addUpdateListener(this);
mAnimator.setDuration(150);
mAnimator.start();
- mHeaderHidden = !expand;
- mSnappedScrolledY = expand ? getCurrentScroll() - mMaxTranslation : getCurrentScroll();
+ mHeaderCollapsed = !expand;
+ mSnappedScrolledY = expand
+ ? mCurrentRV.getCurrentScrollY() - mMaxTranslation
+ : mCurrentRV.getCurrentScrollY();
}
public boolean isExpanded() {
- return !mHeaderHidden;
- }
-
- private int getCurrentScroll() {
- return mMainRVActive ? mMainScrolledY : mWorkScrolledY;
+ return !mHeaderCollapsed;
}
@Override
@@ -228,6 +216,36 @@
apply();
}
+ @Override
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ calcOffset(mTempOffset);
+ ev.offsetLocation(mTempOffset.x, mTempOffset.y);
+ mForwardToRecyclerView = mCurrentRV.onInterceptTouchEvent(ev);
+ ev.offsetLocation(-mTempOffset.x, -mTempOffset.y);
+ return mForwardToRecyclerView || super.onInterceptTouchEvent(ev);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (mForwardToRecyclerView) {
+ // take this view's and parent view's (view pager) location into account
+ calcOffset(mTempOffset);
+ event.offsetLocation(mTempOffset.x, mTempOffset.y);
+ try {
+ return mCurrentRV.onTouchEvent(event);
+ } finally {
+ event.offsetLocation(-mTempOffset.x, -mTempOffset.y);
+ }
+ } else {
+ return super.onTouchEvent(event);
+ }
+ }
+
+ private void calcOffset(Point p) {
+ p.x = getLeft() - mCurrentRV.getLeft() - mParent.getLeft();
+ p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
+ }
+
}
diff --git a/src/com/android/launcher3/allapps/PredictionRowView.java b/src/com/android/launcher3/allapps/PredictionRowView.java
index ea91770..30c30c8 100644
--- a/src/com/android/launcher3/allapps/PredictionRowView.java
+++ b/src/com/android/launcher3/allapps/PredictionRowView.java
@@ -26,6 +26,7 @@
import com.android.launcher3.AppInfo;
import com.android.launcher3.BubbleTextView;
+import com.android.launcher3.Launcher;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ComponentKeyMapper;
@@ -57,11 +58,28 @@
setOrientation(LinearLayout.HORIZONTAL);
}
- public void setup(AllAppsGridAdapter adapter,
- HashMap<ComponentKey, AppInfo> componentToAppMap, int numPredictedAppsPerRow) {
+ public void setup(AllAppsGridAdapter adapter, HashMap<ComponentKey, AppInfo> componentToAppMap,
+ int numPredictedAppsPerRow) {
mAdapter = adapter;
mComponentToAppMap = componentToAppMap;
mNumPredictedAppsPerRow = numPredictedAppsPerRow;
+ setVisibility(mPredictedAppComponents.isEmpty() ? View.GONE : View.VISIBLE);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(getExpectedHeight(),
+ MeasureSpec.EXACTLY));
+ }
+
+ public int getExpectedHeight() {
+ int height = 0;
+ if (!mPredictedAppComponents.isEmpty()) {
+ height += Launcher.getLauncher(getContext())
+ .getDeviceProfile().allAppsCellHeightPx;
+ height += getPaddingTop() + getPaddingBottom();
+ }
+ return height;
}
/**
diff --git a/src/com/android/launcher3/anim/AnimatorSetBuilder.java b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
new file mode 100644
index 0000000..0e44b73
--- /dev/null
+++ b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.anim;
+
+import android.animation.Animator;
+import android.animation.AnimatorSet;
+
+import com.android.launcher3.LauncherAnimUtils;
+
+import java.util.ArrayList;
+
+/**
+ * Utility class for building animator set
+ */
+public class AnimatorSetBuilder {
+
+ protected final ArrayList<Animator> mAnims = new ArrayList<>();
+
+ public void startTag(Object obj) { }
+
+ public void play(Animator anim) {
+ mAnims.add(anim);
+ }
+
+ public AnimatorSet build() {
+ AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
+ anim.playTogether(mAnims);
+ return anim;
+ }
+}
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 7cf3da0..0d92d45 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -60,7 +60,7 @@
public static final boolean GO_DISABLE_WIDGETS = false;
// When enabled shows a work profile tab in all apps
- public static final boolean ALL_APPS_TABS_ENABLED = false;
+ public static final boolean ALL_APPS_TABS_ENABLED = true;
// When enabled prediction row is rendered as it's own custom view
- public static final boolean ALL_APPS_PREDICTION_ROW_VIEW = false;
+ public static final boolean ALL_APPS_PREDICTION_ROW_VIEW = true;
}
diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
index b36a0ff..fc121d3 100644
--- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java
+++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
@@ -322,7 +322,7 @@
* Returns whether the specified point is inside the thumb bounds.
*/
private boolean isNearThumb(int x, int y) {
- int offset = y - mRv.getScrollBarTop() - mThumbOffsetY;
+ int offset = y - mThumbOffsetY;
return x >= 0 && x < getWidth() && offset >= 0 && offset <= mThumbHeight;
}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
index 3ce1014..1ba8cd6 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
@@ -17,7 +17,6 @@
import static com.android.launcher3.WorkspaceStateTransitionAnimation.NO_ANIM_PROPERTY_SETTER;
-import android.animation.AnimatorSet;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@@ -38,6 +37,7 @@
import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
import com.android.launcher3.anim.AnimationLayerSet;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.widget.WidgetsFullSheet;
@@ -169,8 +169,8 @@
@Override
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
- AnimatorSet anim, AnimationConfig config) {
- setState(toState, new AnimatedPropertySetter(config.duration, layerViews, anim));
+ AnimatorSetBuilder builder, AnimationConfig config) {
+ setState(toState, new AnimatedPropertySetter(config.duration, layerViews, builder));
}
private void setState(LauncherState state, PropertySetter setter) {