diff options
Diffstat (limited to 'src/com/android')
27 files changed, 251 insertions, 165 deletions
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java index c75509eab..daf20323d 100644 --- a/src/com/android/launcher3/AbstractFloatingView.java +++ b/src/com/android/launcher3/AbstractFloatingView.java @@ -51,6 +51,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch TYPE_WIDGET_RESIZE_FRAME, TYPE_WIDGETS_FULL_SHEET, TYPE_ON_BOARD_POPUP, + TYPE_DISCOVERY_BOUNCE, TYPE_QUICKSTEP_PREVIEW, TYPE_TASK_MENU, @@ -64,6 +65,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch public static final int TYPE_WIDGET_RESIZE_FRAME = 1 << 3; public static final int TYPE_WIDGETS_FULL_SHEET = 1 << 4; public static final int TYPE_ON_BOARD_POPUP = 1 << 5; + public static final int TYPE_DISCOVERY_BOUNCE = 1 << 6; // Popups related to quickstep UI public static final int TYPE_QUICKSTEP_PREVIEW = 1 << 6; @@ -72,14 +74,17 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET - | TYPE_QUICKSTEP_PREVIEW | TYPE_ON_BOARD_POPUP | TYPE_TASK_MENU | TYPE_OPTIONS_POPUP; + | TYPE_QUICKSTEP_PREVIEW | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE | TYPE_TASK_MENU + | TYPE_OPTIONS_POPUP; // Type of popups which should be kept open during launcher rebind public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET - | TYPE_QUICKSTEP_PREVIEW | TYPE_ON_BOARD_POPUP; + | TYPE_QUICKSTEP_PREVIEW | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE; // Usually we show the back button when a floating view is open. Instead, hide for these types. - public static final int TYPE_HIDE_BACK_BUTTON = TYPE_ON_BOARD_POPUP; + public static final int TYPE_HIDE_BACK_BUTTON = TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE; + + public static final int TYPE_ACCESSIBLE = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE; protected boolean mIsOpen; diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index 421966755..e117deb81 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -30,7 +30,9 @@ import android.view.View.AccessibilityDelegate; import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener; import com.android.launcher3.logging.UserEventDispatcher; +import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate; import com.android.launcher3.uioverrides.UiFactory; +import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.util.SystemUiController; import java.io.FileDescriptor; @@ -38,7 +40,7 @@ import java.io.PrintWriter; import java.lang.annotation.Retention; import java.util.ArrayList; -public abstract class BaseActivity extends Activity { +public abstract class BaseActivity extends Activity implements UserEventDelegate{ public static final int INVISIBLE_BY_STATE_HANDLER = 1 << 0; public static final int INVISIBLE_BY_APP_TRANSITIONS = 1 << 1; @@ -89,9 +91,11 @@ public abstract class BaseActivity extends Activity { return null; } + public void modifyUserEvent(LauncherLogProto.LauncherEvent event) {} + public final UserEventDispatcher getUserEventDispatcher() { if (mUserEventDispatcher == null) { - mUserEventDispatcher = UserEventDispatcher.newInstance(this, mDeviceProfile); + mUserEventDispatcher = UserEventDispatcher.newInstance(this, mDeviceProfile, this); } return mUserEventDispatcher; } diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index e47dbe535..8af9acc24 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -90,11 +90,11 @@ public abstract class BaseDraggingActivity extends BaseActivity protected int getThemeRes(WallpaperColorInfo wallpaperColorInfo) { if (wallpaperColorInfo.isDark()) { - return R.style.LauncherThemeDark; - } else if (wallpaperColorInfo.supportsDarkText()) { - return R.style.LauncherThemeDarkText; + return wallpaperColorInfo.supportsDarkText() ? + R.style.LauncherThemeDark_DarKText : R.style.LauncherThemeDark; } else { - return R.style.LauncherTheme; + return wallpaperColorInfo.supportsDarkText() ? + R.style.LauncherTheme_DarkText : R.style.LauncherTheme; } } @@ -141,13 +141,12 @@ public abstract class BaseDraggingActivity extends BaseActivity return new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()); } - public final Bundle getActivityLaunchOptionsAsBundle(View v, boolean useDefaultLaunchOptions) { - ActivityOptions activityOptions = getActivityLaunchOptions(v, useDefaultLaunchOptions); + public final Bundle getActivityLaunchOptionsAsBundle(View v) { + ActivityOptions activityOptions = getActivityLaunchOptions(v); return activityOptions == null ? null : activityOptions.toBundle(); } - public abstract ActivityOptions getActivityLaunchOptions( - View v, boolean useDefaultLaunchOptions); + public abstract ActivityOptions getActivityLaunchOptions(View v); public boolean startActivitySafely(View v, Intent intent, ItemInfo item) { if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) { @@ -160,7 +159,7 @@ public abstract class BaseDraggingActivity extends BaseActivity boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION); Bundle optsBundle = useLaunchAnimation - ? getActivityLaunchOptionsAsBundle(v, isInMultiWindowModeCompat()) + ? getActivityLaunchOptionsAsBundle(v) : null; UserHandle user = item == null ? null : item.user; diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java index 1f18ea1ac..466b7b242 100644 --- a/src/com/android/launcher3/FocusHelper.java +++ b/src/com/android/launcher3/FocusHelper.java @@ -65,6 +65,9 @@ class FullscreenKeyEventListener implements View.OnKeyListener { } } +/** + * TODO: Reevaluate if this is still required + */ public class FocusHelper { private static final String TAG = "FocusHelper"; diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index c6025fe5f..ee4b1130d 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -112,7 +112,6 @@ public class Hotseat extends FrameLayout implements LogContainerProvider, Insett allAppsButton.setCompoundDrawables(null, d, null, null); allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label)); - allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener()); if (mLauncher != null) { allAppsButton.setOnClickListener((v) -> { if (!mLauncher.isInState(ALL_APPS)) { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 14390ec02..3eaead11a 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -24,6 +24,7 @@ import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD; import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; +import static com.android.launcher3.logging.LoggerUtils.newTarget; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -91,6 +92,7 @@ import com.android.launcher3.keyboard.CustomActionsPopup; import com.android.launcher3.keyboard.ViewGroupFocusHelper; import com.android.launcher3.logging.FileLog; import com.android.launcher3.logging.UserEventDispatcher; +import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate; import com.android.launcher3.model.ModelWriter; import com.android.launcher3.notification.NotificationListener; import com.android.launcher3.popup.PopupContainerWithArrow; @@ -100,6 +102,7 @@ import com.android.launcher3.states.InternalStateHandler; import com.android.launcher3.states.RotationHelper; import com.android.launcher3.touch.ItemClickHandler; import com.android.launcher3.uioverrides.UiFactory; +import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; @@ -140,8 +143,8 @@ import java.util.Set; /** * Default launcher application. */ -public class Launcher extends BaseDraggingActivity - implements LauncherExterns, LauncherModel.Callbacks, LauncherProviderChangeListener { +public class Launcher extends BaseDraggingActivity implements LauncherExterns, + LauncherModel.Callbacks, LauncherProviderChangeListener, UserEventDelegate{ public static final String TAG = "Launcher"; static final boolean LOGD = false; @@ -1614,10 +1617,8 @@ public class Launcher extends BaseDraggingActivity @TargetApi(Build.VERSION_CODES.M) @Override - public ActivityOptions getActivityLaunchOptions(View v, boolean useDefaultLaunchOptions) { - return useDefaultLaunchOptions - ? mAppTransitionManager.getDefaultActivityLaunchOptions(this, v) - : mAppTransitionManager.getActivityLaunchOptions(this, v); + public ActivityOptions getActivityLaunchOptions(View v) { + return mAppTransitionManager.getActivityLaunchOptions(this, v); } public LauncherAppTransitionManager getAppTransitionManager() { @@ -1645,6 +1646,24 @@ public class Launcher extends BaseDraggingActivity } } + @Override + public void modifyUserEvent(LauncherLogProto.LauncherEvent event) { + if (event.srcTarget != null && event.srcTarget.length > 0 && + event.srcTarget[1].containerType == ContainerType.PREDICTION) { + Target[] targets = new Target[3]; + targets[0] = event.srcTarget[0]; + targets[1] = event.srcTarget[1]; + targets[2] = newTarget(Target.Type.CONTAINER); + event.srcTarget = targets; + LauncherState state = mStateManager.getState(); + if (state == LauncherState.ALL_APPS) { + event.srcTarget[2].containerType = ContainerType.ALLAPPS; + } else if (state == LauncherState.OVERVIEW) { + event.srcTarget[2].containerType = ContainerType.TASKSWITCHER; + } + } + } + public boolean startActivitySafely(View v, Intent intent, ItemInfo item) { boolean success = super.startActivitySafely(v, intent, item); if (success && v instanceof BubbleTextView) { diff --git a/src/com/android/launcher3/LauncherAppTransitionManager.java b/src/com/android/launcher3/LauncherAppTransitionManager.java index 04f9b3aff..4037a23ff 100644 --- a/src/com/android/launcher3/LauncherAppTransitionManager.java +++ b/src/com/android/launcher3/LauncherAppTransitionManager.java @@ -33,7 +33,7 @@ public class LauncherAppTransitionManager { context, R.string.app_transition_manager_class); } - public ActivityOptions getDefaultActivityLaunchOptions(Launcher launcher, View v) { + public ActivityOptions getActivityLaunchOptions(Launcher launcher, View v) { if (Utilities.ATLEAST_MARSHMALLOW) { int left = 0, top = 0; int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); @@ -58,8 +58,4 @@ public class LauncherAppTransitionManager { } return null; } - - public ActivityOptions getActivityLaunchOptions(Launcher launcher, View v) { - return getDefaultActivityLaunchOptions(launcher, v); - } } diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index fbe27b0ac..5b010dc2d 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -18,11 +18,11 @@ package com.android.launcher3; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; + import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.states.RotationHelper.REQUEST_NONE; import android.graphics.Rect; -import android.view.View; import android.view.animation.Interpolator; import com.android.launcher3.states.SpringLoadedState; @@ -51,6 +51,7 @@ public class LauncherState { public static final int ALL_APPS_HEADER = 1 << 2; public static final int ALL_APPS_HEADER_EXTRA = 1 << 3; // e.g. app predictions public static final int ALL_APPS_CONTENT = 1 << 4; + public static final int VERTICAL_SWIPE_INDICATOR = 1 << 5; protected static final int FLAG_MULTI_PAGE = 1 << 0; protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 1; @@ -195,15 +196,11 @@ public class LauncherState { public void onStateDisabled(Launcher launcher) { } - public View getFinalFocus(Launcher launcher) { - return launcher.getWorkspace(); - } - public int getVisibleElements(Launcher launcher) { if (launcher.getDeviceProfile().isVerticalBarLayout()) { - return HOTSEAT_ICONS; + return HOTSEAT_ICONS | VERTICAL_SWIPE_INDICATOR; } - return HOTSEAT_ICONS | HOTSEAT_SEARCH_BOX; + return HOTSEAT_ICONS | HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR; } /** diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java index e6fc4c6d4..b5eef8bd3 100644 --- a/src/com/android/launcher3/LauncherStateManager.java +++ b/src/com/android/launcher3/LauncherStateManager.java @@ -17,6 +17,7 @@ package com.android.launcher3; import static android.view.View.VISIBLE; + import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; @@ -35,7 +36,6 @@ import android.animation.AnimatorSet; import android.os.Handler; import android.os.Looper; import android.support.annotation.IntDef; -import android.view.View; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; @@ -251,7 +251,7 @@ public class LauncherStateManager { prepareForAtomicAnimation(mState, state, builder); AnimatorSet animation = createAnimationToNewWorkspaceInternal( state, builder, onCompleteRunnable); - Runnable runnable = new StartAnimRunnable(animation, state.getFinalFocus(mLauncher)); + Runnable runnable = new StartAnimRunnable(animation); if (delay > 0) { mUiHandler.postDelayed(runnable, delay); } else { @@ -348,20 +348,15 @@ public class LauncherStateManager { } @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - for (int i = mListeners.size() - 1; i >= 0; i--) { - mListeners.get(i).onStateTransitionComplete(state); - } - } - - @Override public void onAnimationSuccess(Animator animator) { // Run any queued runnables if (onCompleteRunnable != null) { onCompleteRunnable.run(); } onStateTransitionEnd(state); + for (int i = mListeners.size() - 1; i >= 0; i--) { + mListeners.get(i).onStateTransitionComplete(state); + } } }); mConfig.setAnimation(animation, state); @@ -396,8 +391,9 @@ public class LauncherStateManager { setRestState(null); } - UiFactory.onLauncherStateOrFocusChanged(mLauncher); UiFactory.onLauncherStateOrResumeChanged(mLauncher); + + mLauncher.getDragLayer().requestFocus(); } public void onWindowFocusChanged() { @@ -481,11 +477,9 @@ public class LauncherStateManager { private class StartAnimRunnable implements Runnable { private final AnimatorSet mAnim; - private final View mViewToFocus; - public StartAnimRunnable(AnimatorSet anim, View viewToFocus) { + public StartAnimRunnable(AnimatorSet anim) { mAnim = anim; - mViewToFocus = viewToFocus; } @Override @@ -493,9 +487,6 @@ public class LauncherStateManager { if (mConfig.mCurrentAnimation != mAnim) { return; } - if (mViewToFocus != null) { - mViewToFocus.requestFocus(); - } mAnim.start(); } } diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index efbd00489..5cc2e8fc5 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -440,9 +440,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou if (getUnboundedScrollX() != mScroller.getCurrX() || getScrollY() != mScroller.getCurrY() || mOverScrollX != mScroller.getCurrX()) { - float scaleX = mFreeScroll ? getScaleX() : 1f; - int scrollX = (int) (mScroller.getCurrX() * (1 / scaleX)); - scrollTo(scrollX, mScroller.getCurrY()); + scrollTo(mScroller.getCurrX(), mScroller.getCurrY()); } if (shouldInvalidate) { invalidate(); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 6631f771c..06eb82e3e 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -881,7 +881,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); - child.setOnKeyListener(new HotseatIconKeyEventListener()); // Hide folder title in the hotseat if (child instanceof FolderIcon) { @@ -893,7 +892,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> ((FolderIcon) child).setTextVisible(true); } layout = getScreenWithId(screenId); - child.setOnKeyListener(new IconKeyEventListener()); } ViewGroup.LayoutParams genericLp = child.getLayoutParams(); @@ -1554,6 +1552,14 @@ public class Workspace extends PagedView<WorkspacePageIndicator> public DragView beginDragShared(View child, DragSource source, ItemInfo dragObject, DragPreviewProvider previewProvider, DragOptions dragOptions) { + float iconScale = 1f; + if (child instanceof BubbleTextView) { + Drawable icon = ((BubbleTextView) child).getIcon(); + if (icon instanceof FastBitmapDrawable) { + iconScale = ((FastBitmapDrawable) icon).getAnimatedScale(); + } + } + child.clearFocus(); child.setPressed(false); mOutlineProvider = previewProvider; @@ -1605,7 +1611,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> } DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, - dragObject, dragVisualizeOffset, dragRect, scale, dragOptions); + dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions); dv.setIntrinsicIconScaleFactor(dragOptions.intrinsicIconScaleFactor); return dv; } diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index f8648bba0..68ad6e346 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -15,12 +15,14 @@ */ package com.android.launcher3.allapps; +import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.os.Process; +import android.support.animation.DynamicAnimation; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; @@ -61,6 +63,10 @@ import com.android.launcher3.views.SpringRelativeLayout; public class AllAppsContainerView extends SpringRelativeLayout implements DragSource, Insettable, OnDeviceProfileChangeListener { + private static final float FLING_VELOCITY_MULTIPLIER = 135f; + // Starts the springs after at least 55% of the animation has passed. + private static final float FLING_ANIMATION_THRESHOLD = 0.55f; + private final Launcher mLauncher; private final AdapterHolder[] mAH; private final ItemInfoMatcher mPersonalMatcher = ItemInfoMatcher.ofUser(Process.myUserHandle()); @@ -455,6 +461,32 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo } } + /** + * Adds an update listener to {@param animator} that adds springs to the animation. + */ + public void addSpringFromFlingUpdateListener(ValueAnimator animator, float velocity) { + animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator valueAnimator) { + if (valueAnimator.getAnimatedFraction() >= FLING_ANIMATION_THRESHOLD) { + int searchViewId = getSearchView().getId(); + addSpringView(searchViewId); + + finishWithShiftAndVelocity(1, velocity * FLING_VELOCITY_MULTIPLIER, + new DynamicAnimation.OnAnimationEndListener() { + @Override + public void onAnimationEnd(DynamicAnimation animation, + boolean canceled, float value, float velocity) { + removeSpringView(searchViewId); + } + }); + + animator.removeUpdateListener(this); + } + } + }); + } + public class AdapterHolder { public static final int MAIN = 0; public static final int WORK = 1; diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index b5c821ac2..ccd55863c 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -4,6 +4,7 @@ import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT; import static com.android.launcher3.LauncherState.ALL_APPS_HEADER; import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA; import static com.android.launcher3.LauncherState.OVERVIEW; +import static com.android.launcher3.LauncherState.VERTICAL_SWIPE_INDICATOR; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; @@ -25,11 +26,9 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager.AnimationConfig; import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.PropertySetter; -import com.android.launcher3.uioverrides.UiFactory; import com.android.launcher3.util.Themes; import com.android.launcher3.views.ScrimView; @@ -184,13 +183,6 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil anim.setDuration(config.duration); anim.setInterpolator(builder.getInterpolator(ANIM_VERTICAL_PROGRESS, interpolator)); anim.addListener(getProgressAnimatorListener()); - if (toState.hideBackButton) { - anim.addUpdateListener(animation -> { - final float alpha = (float) animation.getAnimatedValue(); - UiFactory.setBackButtonAlpha(mLauncher, 1 - Utilities.boundToRange(alpha, 0, 1), - false /* animate */); - }); - } builder.play(anim); @@ -207,6 +199,9 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil setter.setViewAlpha(mAppsView.getContentView(), hasContent ? 1 : 0, LINEAR); setter.setViewAlpha(mAppsView.getScrollBar(), hasContent ? 1 : 0, LINEAR); mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra, hasContent, setter); + + setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA, + (visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, LINEAR); } public AnimatorListenerAdapter getProgressAnimatorListener() { diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java index e1cd06a8b..3c3c4066d 100644 --- a/src/com/android/launcher3/allapps/DiscoveryBounce.java +++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java @@ -24,14 +24,9 @@ import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerTyp import android.animation.Animator; import android.animation.AnimatorInflater; import android.animation.AnimatorListenerAdapter; -import android.animation.Keyframe; -import android.animation.ObjectAnimator; -import android.animation.PropertyValuesHolder; -import android.animation.TimeInterpolator; import android.app.ActivityManager; import android.os.Handler; import android.view.MotionEvent; -import android.view.animation.PathInterpolator; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; @@ -52,21 +47,21 @@ public class DiscoveryBounce extends AbstractFloatingView { private final Launcher mLauncher; private final Animator mDiscoBounceAnimation; - public DiscoveryBounce(Launcher launcher, Animator animator) { + public DiscoveryBounce(Launcher launcher, float delta) { super(launcher, null); mLauncher = launcher; - - mDiscoBounceAnimation = animator; AllAppsTransitionController controller = mLauncher.getAllAppsController(); - mDiscoBounceAnimation.setTarget(controller); - mDiscoBounceAnimation.addListener(controller.getProgressAnimatorListener()); + mDiscoBounceAnimation = + AnimatorInflater.loadAnimator(launcher, R.animator.discovery_bounce); + mDiscoBounceAnimation.setTarget(new VerticalProgressWrapper(controller, delta)); mDiscoBounceAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { handleClose(false); } }); + mDiscoBounceAnimation.addListener(controller.getProgressAnimatorListener()); } @Override @@ -102,6 +97,9 @@ public class DiscoveryBounce extends AbstractFloatingView { if (mIsOpen) { mIsOpen = false; mLauncher.getDragLayer().removeView(this); + // Reset the all-apps progress to what ever it was previously. + mLauncher.getAllAppsController().setProgress(mLauncher.getStateManager() + .getState().getVerticalProgress(mLauncher)); } } @@ -112,7 +110,13 @@ public class DiscoveryBounce extends AbstractFloatingView { @Override protected boolean isOfType(int type) { - return (type & TYPE_ON_BOARD_POPUP) != 0; + return (type & TYPE_DISCOVERY_BOUNCE) != 0; + } + + private void show(int containerType) { + mIsOpen = true; + mLauncher.getDragLayer().addView(this); + mLauncher.getUserEventDispatcher().logActionBounceTip(containerType); } public static void showForHomeIfNeeded(Launcher launcher) { @@ -133,11 +137,7 @@ public class DiscoveryBounce extends AbstractFloatingView { return; } - DiscoveryBounce view = new DiscoveryBounce(launcher, - AnimatorInflater.loadAnimator(launcher, R.animator.discovery_bounce)); - view.mIsOpen = true; - launcher.getDragLayer().addView(view); - launcher.getUserEventDispatcher().logActionBounceTip(HOTSEAT); + new DiscoveryBounce(launcher, 0).show(HOTSEAT); } public static void showForOverviewIfNeeded(Launcher launcher) { @@ -164,26 +164,29 @@ public class DiscoveryBounce extends AbstractFloatingView { return; } - float verticalProgress = OVERVIEW.getVerticalProgress(launcher); - - TimeInterpolator pathInterpolator = new PathInterpolator(0.35f, 0, 0.5f, 1); - Keyframe keyframe3 = Keyframe.ofFloat(0.423f, verticalProgress - (1 - 0.9738f)); - keyframe3.setInterpolator(pathInterpolator); - Keyframe keyframe4 = Keyframe.ofFloat(0.754f, verticalProgress); - keyframe4.setInterpolator(pathInterpolator); - - PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe("progress", - Keyframe.ofFloat(0, verticalProgress), - Keyframe.ofFloat(0.246f, verticalProgress), keyframe3, keyframe4, - Keyframe.ofFloat(1f, verticalProgress)); - ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(null, - new PropertyValuesHolder[]{propertyValuesHolder}); - animator.setDuration(2166); - animator.setRepeatCount(5); - - DiscoveryBounce view = new DiscoveryBounce(launcher, animator); - view.mIsOpen = true; - launcher.getDragLayer().addView(view); - launcher.getUserEventDispatcher().logActionBounceTip(PREDICTION); + new DiscoveryBounce(launcher, (1 - OVERVIEW.getVerticalProgress(launcher))) + .show(PREDICTION); + } + + /** + * A wrapper around {@link AllAppsTransitionController} allowing a fixed shift in the value. + */ + public static class VerticalProgressWrapper { + + private final float mDelta; + private final AllAppsTransitionController mController; + + private VerticalProgressWrapper(AllAppsTransitionController controller, float delta) { + mController = controller; + mDelta = delta; + } + + public float getProgress() { + return mController.getProgress() + mDelta; + } + + public void setProgress(float progress) { + mController.setProgress(progress - mDelta); + } } } diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index 5c6946c47..8a216fc17 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -138,7 +138,7 @@ public class DragController implements DragDriver.EventListener, TouchController */ public DragView startDrag(Bitmap b, int dragLayerX, int dragLayerY, DragSource source, ItemInfo dragInfo, Point dragOffset, Rect dragRegion, - float initialDragViewScale, DragOptions options) { + float initialDragViewScale, float dragViewScaleOnDrop, DragOptions options) { if (PROFILE_DRAWING_DURING_DRAG) { android.os.Debug.startMethodTracing("Launcher"); } @@ -169,7 +169,7 @@ public class DragController implements DragDriver.EventListener, TouchController final float scaleDps = mIsInPreDrag ? res.getDimensionPixelSize(R.dimen.pre_drag_view_scale) : 0f; final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX, - registrationY, initialDragViewScale, scaleDps); + registrationY, initialDragViewScale, dragViewScaleOnDrop, scaleDps); dragView.setItemInfo(dragInfo); mDragObject.dragComplete = false; if (mOptions.isAccessibleDrag) { diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 53e9e2dac..6d2d3cb44 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -218,7 +218,8 @@ public class DragLayer extends BaseDragLayer<Launcher> { @Override public void addChildrenForAccessibility(ArrayList<View> childrenForAccessibility) { - View topView = AbstractFloatingView.getTopOpenView(mActivity); + View topView = AbstractFloatingView.getTopOpenViewWithType(mActivity, + AbstractFloatingView.TYPE_ACCESSIBLE); if (topView != null) { addAccessibleChildToList(topView, childrenForAccessibility); if (isInAccessibleDrag()) { diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index 1e5f8545b..551567ae7 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -89,6 +89,7 @@ public class DragView extends View { private final int mRegistrationX; private final int mRegistrationY; private final float mInitialScale; + private final float mScaleOnDrop; private final int[] mTempLoc = new int[2]; private Point mDragVisualizeOffset = null; @@ -131,7 +132,7 @@ public class DragView extends View { * @param registrationY The y coordinate of the registration point. */ public DragView(Launcher launcher, Bitmap bitmap, int registrationX, int registrationY, - final float initialScale, final float finalScaleDps) { + final float initialScale, final float scaleOnDrop, final float finalScaleDps) { super(launcher); mLauncher = launcher; mDragLayer = launcher.getDragLayer(); @@ -180,6 +181,7 @@ public class DragView extends View { mRegistrationY = registrationY; mInitialScale = initialScale; + mScaleOnDrop = scaleOnDrop; // Force a measure, because Workspace uses getMeasuredHeight() before the layout pass int ms = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); @@ -596,7 +598,7 @@ public class DragView extends View { public void animateTo(int toTouchX, int toTouchY, Runnable onCompleteRunnable, int duration) { mTempLoc[0] = toTouchX - mRegistrationX; mTempLoc[1] = toTouchY - mRegistrationY; - mDragLayer.animateViewIntoPosition(this, mTempLoc, 1f, mInitialScale, mInitialScale, + mDragLayer.animateViewIntoPosition(this, mTempLoc, 1f, mScaleOnDrop, mScaleOnDrop, DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration); } diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java index fa7565adb..9be71f95c 100644 --- a/src/com/android/launcher3/folder/FolderPagedView.java +++ b/src/com/android/launcher3/folder/FolderPagedView.java @@ -31,7 +31,6 @@ import android.view.ViewDebug; import com.android.launcher3.BubbleTextView; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; -import com.android.launcher3.FocusHelper.PagedFolderKeyEventListener; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; @@ -88,7 +87,6 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> { private int mGridCountY; private Folder mFolder; - private PagedFolderKeyEventListener mKeyListener; public FolderPagedView(Context context, AttributeSet attrs) { super(context, attrs); @@ -108,7 +106,6 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> { public void setFolder(Folder folder) { mFolder = folder; - mKeyListener = new PagedFolderKeyEventListener(folder); mPageIndicator = folder.findViewById(R.id.folder_page_indicator); initParentViews(folder); } @@ -241,7 +238,6 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> { textView.setOnClickListener(ItemClickHandler.INSTANCE); textView.setOnLongClickListener(mFolder); textView.setOnFocusChangeListener(mFocusIndicatorHelper); - textView.setOnKeyListener(mKeyListener); textView.setLayoutParams(new CellLayout.LayoutParams( item.cellX, item.cellY, item.spanX, item.spanY)); diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java index 3b5585bcf..f020d2d7c 100644 --- a/src/com/android/launcher3/graphics/LauncherIcons.java +++ b/src/com/android/launcher3/graphics/LauncherIcons.java @@ -360,16 +360,18 @@ public class LauncherIcons implements AutoCloseable { .getShortcutIconDrawable(shortcutInfo, mFillResIconDpi); IconCache cache = LauncherAppState.getInstance(mContext).getIconCache(); - Bitmap unbadgedBitmap = null; + final Bitmap unbadgedBitmap; if (unbadgedDrawable != null) { unbadgedBitmap = createScaledBitmapWithoutShadow(unbadgedDrawable, 0); } else { if (fallbackIconProvider != null) { - unbadgedBitmap = fallbackIconProvider.get(); - } - if (unbadgedBitmap == null) { - unbadgedBitmap = cache.getDefaultIcon(Process.myUserHandle()).icon; + // Fallback icons are already badged and with appropriate shadow + Bitmap fullIcon = fallbackIconProvider.get(); + if (fullIcon != null) { + return createIconBitmap(fullIcon); + } } + unbadgedBitmap = cache.getDefaultIcon(Process.myUserHandle()).icon; } BitmapInfo result = new BitmapInfo(); diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index 1842e19a4..d1e1051ee 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -70,7 +70,8 @@ public class UserEventDispatcher { FeatureFlags.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT); private static final String UUID_STORAGE = "uuid"; - public static UserEventDispatcher newInstance(Context context, DeviceProfile dp) { + public static UserEventDispatcher newInstance(Context context, DeviceProfile dp, + UserEventDelegate delegate) { SharedPreferences sharedPrefs = Utilities.getDevicePrefs(context); String uuidStr = sharedPrefs.getString(UUID_STORAGE, null); if (uuidStr == null) { @@ -79,6 +80,7 @@ public class UserEventDispatcher { } UserEventDispatcher ued = Utilities.getOverrideObject(UserEventDispatcher.class, context.getApplicationContext(), R.string.user_event_dispatcher_class); + ued.mDelegate = delegate; ued.mIsInLandscapeMode = dp.isVerticalBarLayout(); ued.mIsInMultiWindowMode = dp.isMultiWindowMode; ued.mUuidStr = uuidStr; @@ -86,6 +88,14 @@ public class UserEventDispatcher { return ued; } + public static UserEventDispatcher newInstance(Context context, DeviceProfile dp) { + return newInstance(context, dp, null); + } + + public interface UserEventDelegate { + void modifyUserEvent(LauncherEvent event); + } + /** * Implemented by containers to provide a container source for a given child. */ @@ -134,6 +144,7 @@ public class UserEventDispatcher { private String mUuidStr; protected InstantAppResolver mInstantAppResolver; private boolean mAppOrTaskLaunch; + private UserEventDelegate mDelegate; // APP_ICON SHORTCUT WIDGET // -------------------------------------------------------------- @@ -162,6 +173,9 @@ public class UserEventDispatcher { newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER)); if (fillInLogContainerData(event, v)) { + if (mDelegate != null) { + mDelegate.modifyUserEvent(event); + } fillIntentInfo(event.srcTarget[0], intent); } dispatchUserEvent(event, intent); diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index a20149e1c..3c1cc9057 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -76,7 +76,7 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite BaseDraggingActivity activity, ItemInfo itemInfo) { return (view) -> { Rect sourceBounds = activity.getViewBounds(view); - Bundle opts = activity.getActivityLaunchOptionsAsBundle(view, false); + Bundle opts = activity.getActivityLaunchOptionsAsBundle(view); new PackageManagerHelper(activity).startDetailsActivityForInfo( itemInfo, sourceBounds, opts); activity.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP, diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java index aa7d0d5a3..35f7f8831 100644 --- a/src/com/android/launcher3/states/SpringLoadedState.java +++ b/src/com/android/launcher3/states/SpringLoadedState.java @@ -19,7 +19,6 @@ import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_M import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK; import android.graphics.Rect; -import android.view.View; import com.android.launcher3.DeviceProfile; import com.android.launcher3.InstallShortcutReceiver; @@ -98,9 +97,4 @@ public class SpringLoadedState extends LauncherState { InstallShortcutReceiver.disableAndFlushInstallQueue( InstallShortcutReceiver.FLAG_DRAG_AND_DROP, launcher); } - - @Override - public View getFinalFocus(Launcher launcher) { - return null; - } } diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 0e6853869..453810c06 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -42,10 +42,9 @@ import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorSetBuilder; -import com.android.launcher3.uioverrides.UiFactory; +import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; -import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.FlingBlockCheck; import com.android.launcher3.util.PendingAnimation; import com.android.launcher3.util.TouchController; @@ -73,6 +72,7 @@ public abstract class AbstractStateChangeTouchController private boolean mNoIntercept; protected int mStartContainerType; + protected LauncherState mStartState; protected LauncherState mFromState; protected LauncherState mToState; protected AnimatorPlaybackController mCurrentAnimation; @@ -181,17 +181,6 @@ public abstract class AbstractStateChangeTouchController return false; } - if (reachedToState) { - logReachedState(Touch.SWIPE); - } - if (newFromState == ALL_APPS) { - mStartContainerType = ContainerType.ALLAPPS; - } else if (newFromState == NORMAL) { - mStartContainerType = getLogContainerTypeForNormalState(); - } else if (newFromState == OVERVIEW){ - mStartContainerType = ContainerType.TASKSWITCHER; - } - mFromState = newFromState; mToState = newToState; @@ -224,8 +213,6 @@ public abstract class AbstractStateChangeTouchController cancelAtomicComponentsController(); } mProgressMultiplier = initCurrentAnimation(animComponents); - mCurrentAnimation.getAnimationPlayer().addUpdateListener(animation -> - setBackButtonAlphaWithProgress((float) animation.getAnimatedValue())); mCurrentAnimation.dispatchOnStart(); return true; } @@ -238,8 +225,17 @@ public abstract class AbstractStateChangeTouchController @Override public void onDragStart(boolean start) { + mStartState = mLauncher.getStateManager().getState(); + if (mStartState == ALL_APPS) { + mStartContainerType = LauncherLogProto.ContainerType.ALLAPPS; + } else if (mStartState == NORMAL) { + mStartContainerType = getLogContainerTypeForNormalState(); + } else if (mStartState == OVERVIEW){ + mStartContainerType = LauncherLogProto.ContainerType.TASKSWITCHER; + } if (mCurrentAnimation == null) { - mFromState = mToState = null; + mFromState = mStartState; + mToState = null; mAtomicComponentsController = null; reinitCurrentAnimation(false, mDetector.wasInitialTouchPositive()); mDisplacementShift = 0; @@ -284,7 +280,6 @@ public abstract class AbstractStateChangeTouchController mAtomicComponentsController.setPlayFraction(fraction - mAtomicComponentsStartProgress); } maybeUpdateAtomicAnim(mFromState, mToState, fraction); - setBackButtonAlphaWithProgress(fraction); } /** @@ -333,23 +328,21 @@ public abstract class AbstractStateChangeTouchController @Override public void onDragEnd(float velocity, boolean fling) { - final int logAction; - final LauncherState targetState; - final float progress = mCurrentAnimation.getProgressFraction(); + final int logAction = fling ? Touch.FLING : Touch.SWIPE; boolean blockedFling = fling && mFlingBlockCheck.isBlocked(); if (blockedFling) { fling = false; } + final LauncherState targetState; + final float progress = mCurrentAnimation.getProgressFraction(); if (fling) { - logAction = Touch.FLING; targetState = Float.compare(Math.signum(velocity), Math.signum(mProgressMultiplier)) == 0 ? mToState : mFromState; // snap to top or bottom using the release velocity } else { - logAction = Touch.SWIPE; float successProgress = mToState == ALL_APPS ? MIN_PROGRESS_TO_ALL_APPS : SUCCESS_TRANSITION_PROGRESS; targetState = (progress > successProgress) ? mToState : mFromState; @@ -400,6 +393,9 @@ public abstract class AbstractStateChangeTouchController updateSwipeCompleteAnimation(anim, Math.max(duration, getRemainingAtomicDuration()), targetState, velocity, fling); mCurrentAnimation.dispatchOnStart(); + if (fling && targetState == LauncherState.ALL_APPS) { + mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity); + } anim.start(); if (mAtomicAnim == null) { startAtomicComponentsAnim(endProgress, anim.getDuration()); @@ -470,28 +466,20 @@ public abstract class AbstractStateChangeTouchController shouldGoToTargetState = !reachedTarget; } if (shouldGoToTargetState) { - if (targetState != mFromState) { - logReachedState(logAction); + if (targetState != mStartState) { + logReachedState(logAction, targetState); } mLauncher.getStateManager().goToState(targetState, false /* animated */); } } - private void setBackButtonAlphaWithProgress(float progress) { - if (mFromState.hideBackButton ^ mToState.hideBackButton) { - progress = Utilities.boundToRange(progress, 0, 1); - final float alpha = mToState.hideBackButton ? 1 - progress : progress; - UiFactory.setBackButtonAlpha(mLauncher, alpha, false /* animate */); - } - } - - private void logReachedState(int logAction) { + private void logReachedState(int logAction, LauncherState targetState) { // Transition complete. log the action mLauncher.getUserEventDispatcher().logStateChangeAction(logAction, getDirectionForLog(), mStartContainerType, - mFromState.containerType, - mToState.containerType, + mStartState.containerType, + targetState.containerType, mLauncher.getWorkspace().getCurrentPage()); } diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index 2f142acc9..8457b2bcd 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -16,6 +16,8 @@ package com.android.launcher3.views; +import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; + import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; @@ -36,8 +38,6 @@ import com.android.launcher3.util.TouchController; import java.util.ArrayList; -import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; - /** * A viewgroup with utility methods for drag-n-drop and touch interception */ @@ -100,7 +100,8 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse @Override public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { // Shortcuts can appear above folder - View topView = AbstractFloatingView.getTopOpenView(mActivity); + View topView = AbstractFloatingView.getTopOpenViewWithType(mActivity, + AbstractFloatingView.TYPE_ACCESSIBLE); if (topView != null) { if (child == topView) { return super.onRequestSendAccessibilityEvent(child, event); @@ -114,7 +115,8 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse @Override public void addChildrenForAccessibility(ArrayList<View> childrenForAccessibility) { - View topView = AbstractFloatingView.getTopOpenView(mActivity); + View topView = AbstractFloatingView.getTopOpenViewWithType(mActivity, + AbstractFloatingView.TYPE_ACCESSIBLE); if (topView != null) { // Only add the top view as a child for accessibility when it is open addAccessibleChildToList(topView, childrenForAccessibility); diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java index 6bbce00fe..6e3ef0705 100644 --- a/src/com/android/launcher3/views/ScrimView.java +++ b/src/com/android/launcher3/views/ScrimView.java @@ -45,6 +45,7 @@ import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat; import android.support.v4.widget.ExploreByTouchHelper; import android.util.AttributeSet; +import android.util.Property; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -73,6 +74,19 @@ import java.util.List; public class ScrimView extends View implements Insettable, OnChangeListener, AccessibilityStateChangeListener, StateListener { + public static final Property<ScrimView, Integer> DRAG_HANDLE_ALPHA = + new Property<ScrimView, Integer>(Integer.TYPE, "dragHandleAlpha") { + + @Override + public Integer get(ScrimView scrimView) { + return scrimView.mDragHandleAlpha; + } + + @Override + public void set(ScrimView scrimView, Integer value) { + scrimView.setDragHandleAlpha(value); + } + }; private static final int WALLPAPERS = R.string.wallpaper_button_text; private static final int WIDGETS = R.string.widget_button_text; private static final int SETTINGS = R.string.settings_button_text; @@ -102,6 +116,8 @@ public class ScrimView extends View implements Insettable, OnChangeListener, @Nullable protected Drawable mDragHandle; + private int mDragHandleAlpha = 255; + public ScrimView(Context context, AttributeSet attrs) { super(context, attrs); mLauncher = Launcher.getLauncher(context); @@ -118,6 +134,7 @@ public class ScrimView extends View implements Insettable, OnChangeListener, ViewCompat.setAccessibilityDelegate(this, mAccessibilityHelper); mAM = (AccessibilityManager) context.getSystemService(ACCESSIBILITY_SERVICE); + setFocusable(false); } @NonNull @@ -187,7 +204,17 @@ public class ScrimView extends View implements Insettable, OnChangeListener, protected void updateDragHandleAlpha() { if (mDragHandle != null) { - mDragHandle.setAlpha(Math.round(255 * Utilities.boundToRange(mProgress, 0, 1))); + mDragHandle.setAlpha(mDragHandleAlpha); + } + } + + private void setDragHandleAlpha(int alpha) { + if (alpha != mDragHandleAlpha) { + mDragHandleAlpha = alpha; + if (mDragHandle != null) { + mDragHandle.setAlpha(mDragHandleAlpha); + invalidate(); + } } } diff --git a/src/com/android/launcher3/views/SpringRelativeLayout.java b/src/com/android/launcher3/views/SpringRelativeLayout.java index 598738b9f..5022d65a3 100644 --- a/src/com/android/launcher3/views/SpringRelativeLayout.java +++ b/src/com/android/launcher3/views/SpringRelativeLayout.java @@ -17,6 +17,7 @@ package com.android.launcher3.views; import android.content.Context; import android.graphics.Canvas; +import android.support.animation.DynamicAnimation; import android.support.animation.FloatPropertyCompat; import android.support.animation.SpringAnimation; import android.support.animation.SpringForce; @@ -79,6 +80,11 @@ public class SpringRelativeLayout extends RelativeLayout { mSpringViews.put(id, true); } + public void removeSpringView(int id) { + mSpringViews.delete(id); + invalidate(); + } + @Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { if (mDampedScrollShift != 0 && mSpringViews.get(child.getId())) { @@ -110,6 +116,13 @@ public class SpringRelativeLayout extends RelativeLayout { mSpring.start(); } + protected void finishWithShiftAndVelocity(float shift, float velocity, + DynamicAnimation.OnAnimationEndListener listener) { + setDampedScrollShift(shift); + mSpring.addEndListener(listener); + finishScrollWithVelocity(velocity); + } + public EdgeEffectFactory createEdgeEffectFactory() { return new SpringEdgeEffectFactory(); } diff --git a/src/com/android/launcher3/widget/PendingItemDragHelper.java b/src/com/android/launcher3/widget/PendingItemDragHelper.java index aa5b7855c..74ab14f55 100644 --- a/src/com/android/launcher3/widget/PendingItemDragHelper.java +++ b/src/com/android/launcher3/widget/PendingItemDragHelper.java @@ -149,7 +149,7 @@ public class PendingItemDragHelper extends DragPreviewProvider { // Start the drag launcher.getDragController().startDrag(preview, dragLayerX, dragLayerY, source, mAddInfo, - dragOffset, dragRegion, scale, options); + dragOffset, dragRegion, scale, scale, options); } @Override |