Merge "Fix animations home" into ub-launcher3-master
diff --git a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
index 2626e7c..0e3d2a4 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
@@ -88,10 +88,10 @@
}
@Override
- public float[] getOverviewTranslationFactor(Launcher launcher) {
- // Keep the same translation as in overview, so that we don't slide around when
+ public float[] getOverviewScaleAndTranslationYFactor(Launcher launcher) {
+ // Keep the same transition properties as overview, so that we don't move around when
// transitioning to All Apps.
- return LauncherState.OVERVIEW.getOverviewTranslationFactor(launcher);
+ return LauncherState.OVERVIEW.getOverviewScaleAndTranslationYFactor(launcher);
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
index 99bf264..f98f7a5 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
@@ -50,7 +50,7 @@
}
@Override
- public float[] getOverviewTranslationFactor(Launcher launcher) {
- return new float[] {0f, 0.5f};
+ public float[] getOverviewScaleAndTranslationYFactor(Launcher launcher) {
+ return new float[] {1f, 0.5f};
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
index 4b2763b..d97b7b2 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -58,8 +58,8 @@
}
@Override
- public float[] getOverviewTranslationFactor(Launcher launcher) {
- return new float[] {0f, 0f};
+ public float[] getOverviewScaleAndTranslationYFactor(Launcher launcher) {
+ return new float[] {1f, 0f};
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
index 0c34b45..1b65ca0 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
@@ -61,9 +61,6 @@
private InterpolatorWrapper mAllAppsInterpolatorWrapper = new InterpolatorWrapper();
- // If > 0, the animation progress is clamped at that value as long as user is dragging.
- private float mClampProgressUpdate = -1;
-
// If true, we will finish the current animation instantly on second touch.
private boolean mFinishFastOnSecondTouch;
@@ -166,15 +163,6 @@
}
@Override
- protected void updateProgress(float fraction) {
- if (mClampProgressUpdate > 0) {
- mCurrentAnimation.setPlayFraction(Math.min(fraction, mClampProgressUpdate));
- } else {
- super.updateProgress(fraction);
- }
- }
-
- @Override
protected float initCurrentAnimation() {
float range = getShiftRange();
long maxAccuracy = (long) (2 * range);
@@ -189,10 +177,8 @@
if (mFromState == NORMAL && mToState == OVERVIEW && totalShift != 0) {
builder = getNormalToOverviewAnimation();
totalShift = totalShift * TOTAL_DISTANCE_MULTIPLIER;
- mClampProgressUpdate = MAXIMUM_DISTANCE_FACTOR;
} else {
builder = new AnimatorSetBuilder();
- mClampProgressUpdate = -1;
}
if (mPendingAnimation != null) {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index 9f7fef3..124ec20 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -15,11 +15,11 @@
*/
package com.android.launcher3.uioverrides;
-import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATION;
+import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
-import static com.android.quickstep.views.LauncherRecentsView.TRANSLATION_X_FACTOR;
import static com.android.quickstep.views.LauncherRecentsView.TRANSLATION_Y_FACTOR;
+import static com.android.quickstep.views.RecentsView.ADJACENT_SCALE;
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import android.animation.ValueAnimator;
@@ -30,7 +30,6 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.LauncherStateManager.StateHandler;
-import com.android.launcher3.PagedView;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.PropertySetter;
import com.android.quickstep.views.LauncherRecentsView;
@@ -49,9 +48,9 @@
@Override
public void setState(LauncherState state) {
mRecentsView.setContentAlpha(state.overviewUi ? 1 : 0);
- float[] translationFactor = state.getOverviewTranslationFactor(mLauncher);
- mRecentsView.setTranslationXFactor(translationFactor[0]);
- mRecentsView.setTranslationYFactor(translationFactor[1]);
+ float[] scaleTranslationYFactor = state.getOverviewScaleAndTranslationYFactor(mLauncher);
+ mRecentsView.setAdjacentScale(scaleTranslationYFactor[0]);
+ mRecentsView.setTranslationYFactor(scaleTranslationYFactor[1]);
if (state.overviewUi) {
mRecentsView.updateEmptyMessage();
mRecentsView.resetTaskVisuals();
@@ -61,28 +60,18 @@
@Override
public void setStateWithAnimation(final LauncherState toState,
AnimatorSetBuilder builder, AnimationConfig config) {
-
- // Scroll to the workspace card before changing to the NORMAL state.
- LauncherState fromState = mLauncher.getStateManager().getState();
- int currPage = mRecentsView.getCurrentPage();
- if (fromState.overviewUi && toState == NORMAL && currPage != 0 && !config.userControlled) {
- int maxSnapDuration = PagedView.SLOW_PAGE_SNAP_ANIMATION_DURATION;
- int durationPerPage = maxSnapDuration / 10;
- int snapDuration = Math.min(maxSnapDuration, durationPerPage * currPage);
- mRecentsView.snapToPage(0, snapDuration);
- // Let the snapping animation play for a bit before we translate off screen.
- builder.setStartDelay(snapDuration / 4);
- }
-
PropertySetter setter = config.getProperSetter(builder);
- float[] translationFactor = toState.getOverviewTranslationFactor(mLauncher);
- setter.setFloat(mRecentsView, TRANSLATION_X_FACTOR,
- translationFactor[0],
+ float[] scaleTranslationYFactor = toState.getOverviewScaleAndTranslationYFactor(mLauncher);
+ setter.setFloat(mRecentsView, ADJACENT_SCALE, scaleTranslationYFactor[0],
builder.getInterpolator(ANIM_OVERVIEW_TRANSLATION, LINEAR));
- setter.setFloat(mRecentsView, TRANSLATION_Y_FACTOR,
- translationFactor[1],
+ setter.setFloat(mRecentsView, TRANSLATION_Y_FACTOR, scaleTranslationYFactor[1],
builder.getInterpolator(ANIM_OVERVIEW_TRANSLATION, LINEAR));
- setter.setFloat(mRecentsView, CONTENT_ALPHA, toState.overviewUi ? 1 : 0, LINEAR);
+ setter.setFloat(mRecentsView, CONTENT_ALPHA, toState.overviewUi ? 1 : 0,
+ AGGRESSIVE_EASE_IN_OUT);
+
+ if (!toState.overviewUi) {
+ builder.addOnFinishRunnable(mRecentsView::resetTaskVisuals);
+ }
if (toState.overviewUi) {
ValueAnimator updateAnim = ValueAnimator.ofFloat(0, 1);
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index d428f23..6788827 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -20,7 +20,6 @@
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
-import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
@@ -45,20 +44,6 @@
@TargetApi(Build.VERSION_CODES.O)
public class LauncherRecentsView extends RecentsView<Launcher> implements Insettable {
- public static final FloatProperty<LauncherRecentsView> TRANSLATION_X_FACTOR =
- new FloatProperty<LauncherRecentsView>("translationXFactor") {
-
- @Override
- public void setValue(LauncherRecentsView view, float v) {
- view.setTranslationXFactor(v);
- }
-
- @Override
- public Float get(LauncherRecentsView view) {
- return view.mTranslationXFactor;
- }
- };
-
public static final FloatProperty<LauncherRecentsView> TRANSLATION_Y_FACTOR =
new FloatProperty<LauncherRecentsView>("translationYFactor") {
@@ -74,8 +59,6 @@
};
@ViewDebug.ExportedProperty(category = "launcher")
- private float mTranslationXFactor;
- @ViewDebug.ExportedProperty(category = "launcher")
private float mTranslationYFactor;
private Rect mPagePadding = new Rect();
@@ -114,11 +97,6 @@
setTranslationYFactor(mTranslationYFactor);
}
- public void setTranslationXFactor(float translationFactor) {
- mTranslationXFactor = translationFactor;
- invalidate();
- }
-
public void setTranslationYFactor(float translationFactor) {
mTranslationYFactor = translationFactor;
setTranslationY(mTranslationYFactor * (mPagePadding.bottom - mPagePadding.top));
@@ -127,10 +105,7 @@
@Override
public void draw(Canvas canvas) {
maybeDrawEmptyMessage(canvas);
- int count = canvas.save();
- canvas.translate(mTranslationXFactor * (mIsRtl ? -getWidth() : getWidth()), 0);
super.draw(canvas);
- canvas.restoreToCount(count);
}
@Override
diff --git a/quickstep/src/com/android/quickstep/views/QuickstepDragIndicator.java b/quickstep/src/com/android/quickstep/views/QuickstepDragIndicator.java
index 82ec84e..5e9cd6e 100644
--- a/quickstep/src/com/android/quickstep/views/QuickstepDragIndicator.java
+++ b/quickstep/src/com/android/quickstep/views/QuickstepDragIndicator.java
@@ -50,9 +50,7 @@
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
- if (isInOverview()) {
- info.setContentDescription(getContext().getString(R.string.all_apps_button_label));
- }
+ info.setContentDescription(getContext().getString(R.string.all_apps_button_label));
}
@Override
@@ -64,15 +62,9 @@
@Override
public void onClick(View view) {
- if (isInOverview()) {
- mLauncher.getUserEventDispatcher().logActionOnControl(
- Action.Touch.TAP, ControlType.ALL_APPS_BUTTON, ContainerType.TASKSWITCHER);
- mLauncher.getStateManager().goToState(ALL_APPS);
- super.onClick(view);
- } else {
- mLauncher.getUserEventDispatcher().logActionOnControl(
- Action.Touch.TAP, ControlType.ALL_APPS_BUTTON, ContainerType.WORKSPACE);
- mLauncher.getStateManager().goToState(OVERVIEW);
- }
+ mLauncher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
+ ControlType.ALL_APPS_BUTTON,
+ isInOverview() ? ContainerType.TASKSWITCHER : ContainerType.WORKSPACE);
+ mLauncher.getStateManager().goToState(ALL_APPS);
}
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 592dc2d..d95619c 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -59,8 +59,8 @@
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.config.FeatureFlags;
-import com.android.launcher3.util.Themes;
import com.android.launcher3.util.PendingAnimation;
+import com.android.launcher3.util.Themes;
import com.android.quickstep.QuickScrubController;
import com.android.quickstep.RecentsAnimationInterpolator;
import com.android.quickstep.RecentsAnimationInterpolator.TaskWindowBounds;
@@ -85,8 +85,6 @@
public static final FloatProperty<RecentsView> CONTENT_ALPHA =
new FloatProperty<RecentsView>("contentAlpha") {
-
-
@Override
public void setValue(RecentsView recentsView, float v) {
recentsView.setContentAlpha(v);
@@ -98,6 +96,20 @@
}
};
+
+
+ public static final FloatProperty<RecentsView> ADJACENT_SCALE =
+ new FloatProperty<RecentsView>("adjacentScale") {
+ @Override
+ public void setValue(RecentsView recentsView, float v) {
+ recentsView.setAdjacentScale(v);
+ }
+
+ @Override
+ public Float get(RecentsView recentsView) {
+ return recentsView.mAdjacentScale;
+ }
+ };
private static final String PREF_FLIP_RECENTS = "pref_flip_recents";
private static final int DISMISS_TASK_DURATION = 300;
@@ -165,6 +177,8 @@
@ViewDebug.ExportedProperty(category = "launcher")
private float mContentAlpha = 1;
+ @ViewDebug.ExportedProperty(category = "launcher")
+ private float mAdjacentScale = 1;
// Keeps track of task views whose visual state should not be reset
private ArraySet<TaskView> mIgnoreResetTaskViews = new ArraySet<>();
@@ -840,10 +854,58 @@
setVisibility(alpha > 0 ? VISIBLE : GONE);
}
+ public void setAdjacentScale(float adjacentScale) {
+ if (mAdjacentScale == adjacentScale) {
+ return;
+ }
+ mAdjacentScale = adjacentScale;
+ TaskView currTask = getPageAt(mCurrentPage);
+ if (currTask == null) {
+ return;
+ }
+ currTask.setScaleX(mAdjacentScale);
+ currTask.setScaleY(mAdjacentScale);
+
+ if (mCurrentPage - 1 >= 0) {
+ TaskView adjacentTask = getPageAt(mCurrentPage - 1);
+ float[] scaleAndTranslation = getAdjacentScaleAndTranslation(currTask, adjacentTask,
+ mAdjacentScale, 0);
+ adjacentTask.setScaleX(scaleAndTranslation[0]);
+ adjacentTask.setScaleY(scaleAndTranslation[0]);
+ adjacentTask.setTranslationX(-scaleAndTranslation[1]);
+ adjacentTask.setTranslationY(scaleAndTranslation[2]);
+ }
+ if (mCurrentPage + 1 < getChildCount()) {
+ TaskView adjacentTask = getPageAt(mCurrentPage + 1);
+ float[] scaleAndTranslation = getAdjacentScaleAndTranslation(currTask, adjacentTask,
+ mAdjacentScale, 0);
+ adjacentTask.setScaleX(scaleAndTranslation[0]);
+ adjacentTask.setScaleY(scaleAndTranslation[0]);
+ adjacentTask.setTranslationX(scaleAndTranslation[1]);
+ adjacentTask.setTranslationY(scaleAndTranslation[2]);
+ }
+ }
+
+ private float[] getAdjacentScaleAndTranslation(TaskView currTask, TaskView adjacentTask,
+ float currTaskToScale, float currTaskToTranslationY) {
+ float displacement = currTask.getWidth() * (currTaskToScale - currTask.getCurveScale());
+ return new float[] {
+ currTaskToScale * adjacentTask.getCurveScale(),
+ mIsRtl ? -displacement : displacement,
+ currTaskToTranslationY
+ };
+ }
+
@Override
public void onViewAdded(View child) {
super.onViewAdded(child);
child.setAlpha(mContentAlpha);
+ setAdjacentScale(mAdjacentScale);
+ }
+
+ @Override
+ public TaskView getPageAt(int index) {
+ return (TaskView) getChildAt(index);
}
public void updateEmptyMessage() {
@@ -921,18 +983,24 @@
float toScale = endInterpolation.taskScale;
float toTranslationY = endInterpolation.taskY;
- float displacementX = tv.getWidth() * (toScale - tv.getScaleX());
if (launchingCenterTask) {
+ TaskView centerTask = getPageAt(centerTaskIndex);
if (taskIndex - 1 >= 0) {
- anim.play(createAnimForChild(
- taskIndex - 1, toScale, displacementX, toTranslationY));
+ TaskView adjacentTask = getPageAt(taskIndex - 1);
+ float[] scaleAndTranslation = getAdjacentScaleAndTranslation(centerTask,
+ adjacentTask, toScale, toTranslationY);
+ scaleAndTranslation[1] = -scaleAndTranslation[1];
+ anim.play(createAnimForChild(adjacentTask, scaleAndTranslation));
}
if (taskIndex + 1 < getPageCount()) {
- anim.play(createAnimForChild(
- taskIndex + 1, toScale, -displacementX, toTranslationY));
+ TaskView adjacentTask = getPageAt(taskIndex + 1);
+ float[] scaleAndTranslation = getAdjacentScaleAndTranslation(centerTask,
+ adjacentTask, toScale, toTranslationY);
+ anim.play(createAnimForChild(adjacentTask, scaleAndTranslation));
}
} else {
// We are launching an adjacent task, so parallax the center and other adjacent task.
+ float displacementX = tv.getWidth() * (toScale - tv.getCurveScale());
anim.play(ObjectAnimator.ofFloat(getPageAt(centerTaskIndex), TRANSLATION_X,
mIsRtl ? -displacementX : displacementX));
@@ -948,13 +1016,12 @@
return anim;
}
- private ObjectAnimator createAnimForChild(int childIndex, float toScale, float tx, float ty) {
- View child = getChildAt(childIndex);
+ private ObjectAnimator createAnimForChild(View child, float[] toScaleAndTranslation) {
return ObjectAnimator.ofPropertyValuesHolder(child,
new PropertyListBuilder()
- .scale(child.getScaleX() * toScale)
- .translationY(ty)
- .translationX(mIsRtl ? tx : -tx)
+ .scale(child.getScaleX() * toScaleAndTranslation[0])
+ .translationX(toScaleAndTranslation[1])
+ .translationY(toScaleAndTranslation[2])
.build());
}
@@ -999,4 +1066,9 @@
super.notifyPageSwitchListener(prevPage);
getChildAt(mCurrentPage).sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
}
+
+ @Override
+ protected String getCurrentPageDescription() {
+ return "";
+ }
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 57516b0..42da472 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -70,6 +70,7 @@
private Task mTask;
private TaskThumbnailView mSnapshotView;
private ImageView mIconView;
+ private float mCurveScale;
public TaskView(Context context) {
this(context, null);
@@ -178,9 +179,13 @@
mSnapshotView.setDimAlpha(1 - curveInterpolation * MAX_PAGE_SCRIM_ALPHA);
- float scale = 1 - curveInterpolation * EDGE_SCALE_DOWN_FACTOR;
- setScaleX(scale);
- setScaleY(scale);
+ mCurveScale = 1 - curveInterpolation * EDGE_SCALE_DOWN_FACTOR;
+ setScaleX(mCurveScale);
+ setScaleY(mCurveScale);
+ }
+
+ public float getCurveScale() {
+ return mCurveScale;
}
@Override
diff --git a/res/layout/launcher_preference.xml b/res/layout/launcher_preference.xml
deleted file mode 100644
index ed0ea7c..0000000
--- a/res/layout/launcher_preference.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<com.android.launcher3.views.HighlightableListView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:cacheColorHint="@android:color/transparent"
- android:clipToPadding="false"
- android:drawSelectorOnTop="false"
- android:orientation="vertical"
- android:scrollbarAlwaysDrawVerticalTrack="true"
- android:scrollbarStyle="outsideOverlay" />
\ No newline at end of file
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ccc774a..b410f4f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -357,11 +357,6 @@
if ((diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0) {
mUserEventDispatcher = null;
initDeviceProfile(mDeviceProfile.inv);
- FileLog.d(TAG, "Config changed, my orientation=" +
- getResources().getConfiguration().orientation +
- ", new orientation=" + newConfig.orientation +
- ", old orientation=" + mOldConfig.orientation +
- ", isTransposed=" + mDeviceProfile.isVerticalBarLayout());
dispatchDeviceProfileChanged();
getRootView().dispatchInsets();
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 8b7ba20..7d208d4 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -34,7 +34,6 @@
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.database.sqlite.SQLiteStatement;
import android.net.Uri;
@@ -56,7 +55,6 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.model.DbDowngradeHelper;
-import com.android.launcher3.model.ModelWriter;
import com.android.launcher3.provider.LauncherDbUtils;
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
import com.android.launcher3.provider.RestoreDbTask;
@@ -320,11 +318,6 @@
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
- if (ModelWriter.DEBUG_DELETE) {
- String args = selectionArgs == null ? null : TextUtils.join(",", selectionArgs);
- FileLog.d(TAG, "Delete uri=" + uri + ", selection=" + selection
- + ", selectionArgs=" + args, new Exception());
- }
createDbIfNotExists();
SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index fdb6f48..4697b82 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -181,12 +181,12 @@
}
/**
- * Returns 2 floats designating how much to translate overview:
- * X factor is based on width, e.g. 0 is fully onscreen and 1 is fully offscreen
- * Y factor is based on padding, e.g. 0 is top aligned and 0.5 is centered vertically
+ * Returns 2 floats designating how to transition overview:
+ * scale for the current and adjacent pages
+ * translationY factor where 0 is top aligned and 0.5 is centered vertically
*/
- public float[] getOverviewTranslationFactor(Launcher launcher) {
- return new float[] {1f, 0f};
+ public float[] getOverviewScaleAndTranslationYFactor(Launcher launcher) {
+ return new float[] {1.2f, 0.2f};
}
public void onStateEnabled(Launcher launcher) {
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 1e761e4..79993c1 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -41,6 +41,7 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
+import android.widget.ScrollView;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.pageindicators.PageIndicator;
@@ -1467,6 +1468,13 @@
if (getNextPage() < getChildCount() -1) snapToPage(getNextPage() + 1);
}
+ @Override
+ public CharSequence getAccessibilityClassName() {
+ // Some accessibility services have special logic for ScrollView. Since we provide same
+ // accessibility info as ScrollView, inform the service to handle use the same way.
+ return ScrollView.class.getName();
+ }
+
/* Accessibility */
@SuppressWarnings("deprecation")
@Override
@@ -1479,7 +1487,6 @@
if (getCurrentPage() > 0) {
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
}
- info.setClassName(getClass().getName());
// Accessibility-wise, PagedView doesn't support long click, so disabling it.
// Besides disabling the accessibility long-click, this also prevents this view from getting
diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java
index 7fa0e52..c9bd32b 100644
--- a/src/com/android/launcher3/SettingsActivity.java
+++ b/src/com/android/launcher3/SettingsActivity.java
@@ -16,6 +16,7 @@
package com.android.launcher3;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -26,22 +27,25 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.TextUtils;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.Adapter;
+import android.widget.ListView;
import com.android.launcher3.graphics.IconShapeOverride;
import com.android.launcher3.notification.NotificationListener;
+import com.android.launcher3.util.ListViewHighlighter;
import com.android.launcher3.util.SettingsObserver;
import com.android.launcher3.views.ButtonPreference;
-import com.android.launcher3.views.HighlightableListView;
+
+import java.util.Objects;
/**
* Settings activity for Launcher. Currently implements the following setting: Allow rotation
@@ -85,12 +89,6 @@
private boolean mPreferenceHighlighted = false;
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- return inflater.inflate(R.layout.launcher_preference, container, false);
- }
-
- @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
@@ -145,12 +143,25 @@
}
private void highlightPreference() {
- HighlightableListView list = getView().findViewById(android.R.id.list);
Preference pref = findPreference(mPreferenceKey);
- Adapter adapter = list.getAdapter();
- if (adapter == null) {
+ if (pref == null || getPreferenceScreen() == null) {
return;
}
+ PreferenceScreen screen = getPreferenceScreen();
+ if (Utilities.ATLEAST_OREO) {
+ screen = selectPreferenceRecursive(pref, screen);
+ }
+ if (screen == null) {
+ return;
+ }
+
+ View root = screen.getDialog() != null
+ ? screen.getDialog().getWindow().getDecorView() : getView();
+ ListView list = root.findViewById(android.R.id.list);
+ if (list == null || list.getAdapter() == null) {
+ return;
+ }
+ Adapter adapter = list.getAdapter();
// Find the position
int position = -1;
@@ -160,7 +171,7 @@
break;
}
}
- list.highlightPosition(position);
+ new ListViewHighlighter(list, position);
mPreferenceHighlighted = true;
}
@@ -172,6 +183,25 @@
}
super.onDestroy();
}
+
+ @TargetApi(Build.VERSION_CODES.O)
+ private PreferenceScreen selectPreferenceRecursive(
+ Preference pref, PreferenceScreen topParent) {
+ if (!(pref.getParent() instanceof PreferenceScreen)) {
+ return null;
+ }
+
+ PreferenceScreen parent = (PreferenceScreen) pref.getParent();
+ if (Objects.equals(parent.getKey(), topParent.getKey())) {
+ return parent;
+ } else if (selectPreferenceRecursive(parent, topParent) != null) {
+ ((PreferenceScreen) parent.getParent())
+ .onItemClick(null, null, parent.getOrder(), 0);
+ return parent;
+ } else {
+ return null;
+ }
+ }
}
/**
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index fa86906..420a7c4 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -31,7 +31,6 @@
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.graphics.ViewScrim;
-import com.android.launcher3.uioverrides.UiFactory;
/**
* Manages the animations between each of the workspace states.
@@ -74,11 +73,11 @@
propertySetter);
}
- propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, Interpolators.ZOOM_IN);
+ propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, Interpolators.ZOOM_OUT);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_X,
- scaleAndTranslation[1], Interpolators.ZOOM_IN);
+ scaleAndTranslation[1], Interpolators.ZOOM_OUT);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
- scaleAndTranslation[2], Interpolators.ZOOM_IN);
+ scaleAndTranslation[2], Interpolators.ZOOM_OUT);
int elements = state.getVisibleElements(mLauncher);
float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
@@ -113,7 +112,7 @@
int drawableAlpha = Math.round(pageAlpha * (state.hasWorkspacePageBackground ? 255 : 0));
propertySetter.setInt(cl.getScrimBackground(),
- DRAWABLE_ALPHA, drawableAlpha, Interpolators.ZOOM_IN);
+ DRAWABLE_ALPHA, drawableAlpha, Interpolators.ZOOM_OUT);
propertySetter.setFloat(cl.getShortcutsAndWidgets(), View.ALPHA,
pageAlpha, pageAlphaProvider.interpolator);
}
diff --git a/src/com/android/launcher3/anim/AnimatorSetBuilder.java b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
index 9191048..b209a2d 100644
--- a/src/com/android/launcher3/anim/AnimatorSetBuilder.java
+++ b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
@@ -16,6 +16,7 @@
package com.android.launcher3.anim;
import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.util.SparseArray;
import android.view.animation.Interpolator;
@@ -23,6 +24,7 @@
import com.android.launcher3.LauncherAnimUtils;
import java.util.ArrayList;
+import java.util.List;
/**
* Utility class for building animator set
@@ -35,7 +37,7 @@
protected final ArrayList<Animator> mAnims = new ArrayList<>();
private final SparseArray<Interpolator> mInterpolators = new SparseArray<>();
- private long mStartDelay = 0;
+ private List<Runnable> mOnFinishRunnables = new ArrayList<>();
/**
* Associates a tag with all the animations added after this call.
@@ -46,14 +48,24 @@
mAnims.add(anim);
}
- public void setStartDelay(long startDelay) {
- mStartDelay = startDelay;
+ public void addOnFinishRunnable(Runnable onFinishRunnable) {
+ mOnFinishRunnables.add(onFinishRunnable);
}
public AnimatorSet build() {
AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
anim.playTogether(mAnims);
- anim.setStartDelay(mStartDelay);
+ if (!mOnFinishRunnables.isEmpty()) {
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ for (Runnable onFinishRunnable : mOnFinishRunnables) {
+ onFinishRunnable.run();
+ }
+ mOnFinishRunnables.clear();
+ }
+ });
+ }
return anim;
}
diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java
index 6078776..06ddf22 100644
--- a/src/com/android/launcher3/anim/Interpolators.java
+++ b/src/com/android/launcher3/anim/Interpolators.java
@@ -65,15 +65,22 @@
new PathInterpolator(0.3f, 0f, 0.1f, 1f);
/**
- * Inversion of zInterpolate, compounded with an ease-out.
+ * Inversion of ZOOM_OUT, compounded with an ease-out.
*/
public static final Interpolator ZOOM_IN = new Interpolator() {
+ @Override
+ public float getInterpolation(float v) {
+ return DEACCEL_3.getInterpolation(1 - ZOOM_OUT.getInterpolation(1 - v));
+ }
+ };
+
+ public static final Interpolator ZOOM_OUT = new Interpolator() {
private static final float FOCAL_LENGTH = 0.35f;
@Override
public float getInterpolation(float v) {
- return DEACCEL_3.getInterpolation(1 - zInterpolate(1 - v));
+ return zInterpolate(v);
}
/**
diff --git a/src/com/android/launcher3/model/ModelWriter.java b/src/com/android/launcher3/model/ModelWriter.java
index 72c703b..eba7515 100644
--- a/src/com/android/launcher3/model/ModelWriter.java
+++ b/src/com/android/launcher3/model/ModelWriter.java
@@ -50,7 +50,6 @@
public class ModelWriter {
private static final String TAG = "ModelWriter";
- public static final boolean DEBUG_DELETE = true;
private final Context mContext;
private final LauncherModel mModel;
@@ -257,14 +256,6 @@
* Removes the specified items from the database
*/
public void deleteItemsFromDatabase(final Iterable<? extends ItemInfo> items) {
- if (DEBUG_DELETE) {
- // Log it on the colling thread to get the proper stack trace
- FileLog.d(TAG, "Starting item deletion", new Exception());
- for (ItemInfo item : items) {
- FileLog.d(TAG, "deleting item " + item);
- }
- FileLog.d(TAG, "Finished deleting items");
- }
ModelVerifier verifier = new ModelVerifier();
mWorkerExecutor.execute(() -> {
@@ -282,11 +273,6 @@
* Remove the specified folder and all its contents from the database.
*/
public void deleteFolderAndContentsFromDatabase(final FolderInfo info) {
- if (DEBUG_DELETE) {
- // Log it on the colling thread to get the proper stack trace
- FileLog.d(TAG, "Deleting folder " + info, new Exception());
- }
-
ModelVerifier verifier = new ModelVerifier();
mWorkerExecutor.execute(() -> {
diff --git a/src/com/android/launcher3/util/ListViewHighlighter.java b/src/com/android/launcher3/util/ListViewHighlighter.java
new file mode 100644
index 0000000..ecad2af
--- /dev/null
+++ b/src/com/android/launcher3/util/ListViewHighlighter.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.util;
+
+import android.animation.ArgbEvaluator;
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.support.v4.graphics.ColorUtils;
+import android.view.View;
+import android.view.View.OnLayoutChangeListener;
+import android.widget.AbsListView;
+import android.widget.AbsListView.OnScrollListener;
+import android.widget.AbsListView.RecyclerListener;
+import android.widget.ListView;
+
+import com.android.launcher3.R;
+
+/**
+ * Utility class to scroll and highlight a list view item
+ */
+public class ListViewHighlighter implements OnScrollListener, RecyclerListener,
+ OnLayoutChangeListener {
+
+ private final ListView mListView;
+ private int mPosHighlight;
+
+ private boolean mColorAnimated = false;
+
+ public ListViewHighlighter(ListView listView, int posHighlight) {
+ mListView = listView;
+ mPosHighlight = posHighlight;
+ mListView.setOnScrollListener(this);
+ mListView.setRecyclerListener(this);
+ mListView.addOnLayoutChangeListener(this);
+
+ mListView.post(this::tryHighlight);
+ }
+
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ mListView.post(this::tryHighlight);
+ }
+
+ private void tryHighlight() {
+ if (mPosHighlight < 0 || mListView.getChildCount() == 0) {
+ return;
+ }
+ if (!highlightIfVisible(mListView.getFirstVisiblePosition(),
+ mListView.getLastVisiblePosition())) {
+ mListView.smoothScrollToPosition(mPosHighlight);
+ }
+ }
+
+ @Override
+ public void onScrollStateChanged(AbsListView absListView, int i) { }
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem,
+ int visibleItemCount, int totalItemCount) {
+ highlightIfVisible(firstVisibleItem, firstVisibleItem + visibleItemCount);
+ }
+
+ private boolean highlightIfVisible(int start, int end) {
+ if (mPosHighlight < 0 || mListView.getChildCount() == 0) {
+ return false;
+ }
+ if (start > mPosHighlight || mPosHighlight > end) {
+ return false;
+ }
+ highlightView(mListView.getChildAt(mPosHighlight - start));
+
+ // finish highlight
+ mListView.setOnScrollListener(null);
+ mListView.removeOnLayoutChangeListener(this);
+
+ mPosHighlight = -1;
+ return true;
+ }
+
+ @Override
+ public void onMovedToScrapHeap(View view) {
+ unhighlightView(view);
+ }
+
+ private void highlightView(View view) {
+ if (Boolean.TRUE.equals(view.getTag(R.id.view_highlighted))) {
+ // already highlighted
+ } else {
+ view.setTag(R.id.view_highlighted, true);
+ view.setTag(R.id.view_unhighlight_background, view.getBackground());
+ view.setBackground(getHighlightBackground());
+ view.postDelayed(() -> {
+ unhighlightView(view);
+ }, 15000L);
+ }
+ }
+
+ private void unhighlightView(View view) {
+ if (Boolean.TRUE.equals(view.getTag(R.id.view_highlighted))) {
+ Object background = view.getTag(R.id.view_unhighlight_background);
+ if (background instanceof Drawable) {
+ view.setBackground((Drawable) background);
+ }
+ view.setTag(R.id.view_unhighlight_background, null);
+ view.setTag(R.id.view_highlighted, false);
+ }
+ }
+
+ private ColorDrawable getHighlightBackground() {
+ int color = ColorUtils.setAlphaComponent(Themes.getColorAccent(mListView.getContext()), 26);
+ if (mColorAnimated) {
+ return new ColorDrawable(color);
+ }
+ mColorAnimated = true;
+ ColorDrawable bg = new ColorDrawable(Color.WHITE);
+ ObjectAnimator anim = ObjectAnimator.ofInt(bg, "color", Color.WHITE, color);
+ anim.setEvaluator(new ArgbEvaluator());
+ anim.setDuration(200L);
+ anim.setRepeatMode(ValueAnimator.REVERSE);
+ anim.setRepeatCount(4);
+ anim.start();
+ return bg;
+ }
+}
diff --git a/src/com/android/launcher3/util/TraceHelper.java b/src/com/android/launcher3/util/TraceHelper.java
index ac381cc..4aa2f37 100644
--- a/src/com/android/launcher3/util/TraceHelper.java
+++ b/src/com/android/launcher3/util/TraceHelper.java
@@ -24,7 +24,6 @@
import android.util.Log;
import android.util.MutableLong;
-import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
/**
@@ -35,8 +34,7 @@
*/
public class TraceHelper {
- private static final boolean FORCE_LOG = Utilities.IS_DEBUG_DEVICE;
- private static final boolean ENABLED = FORCE_LOG || FeatureFlags.IS_DOGFOOD_BUILD;
+ private static final boolean ENABLED = FeatureFlags.IS_DOGFOOD_BUILD;
private static final boolean SYSTEM_TRACE = false;
private static final ArrayMap<String, MutableLong> sUpTimes = ENABLED ? new ArrayMap<>() : null;
@@ -45,7 +43,7 @@
if (ENABLED) {
MutableLong time = sUpTimes.get(sectionName);
if (time == null) {
- time = new MutableLong((FORCE_LOG || isLoggable(sectionName, VERBOSE)) ? 0 : -1);
+ time = new MutableLong(isLoggable(sectionName, VERBOSE) ? 0 : -1);
sUpTimes.put(sectionName, time);
}
if (time.value >= 0) {
diff --git a/src/com/android/launcher3/views/HighlightableListView.java b/src/com/android/launcher3/views/HighlightableListView.java
deleted file mode 100644
index 7da979f..0000000
--- a/src/com/android/launcher3/views/HighlightableListView.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.views;
-
-import android.animation.ArgbEvaluator;
-import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
-import android.content.Context;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-import android.support.v4.graphics.ColorUtils;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.HeaderViewListAdapter;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-
-import com.android.launcher3.R;
-import com.android.launcher3.util.Themes;
-
-import java.util.ArrayList;
-
-/**
- * Extension of list view with support for element highlighting.
- */
-public class HighlightableListView extends ListView {
-
- private int mPosHighlight = -1;
- private boolean mColorAnimated = false;
-
- public HighlightableListView(Context context) {
- super(context);
- }
-
- public HighlightableListView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public HighlightableListView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- @Override
- public void setAdapter(ListAdapter adapter) {
- super.setAdapter(new HighLightAdapter(adapter));
- }
-
- public void highlightPosition(int pos) {
- if (mPosHighlight == pos) {
- return;
- }
-
- mColorAnimated = false;
- mPosHighlight = pos;
- setSelection(mPosHighlight);
-
- int start = getFirstVisiblePosition();
- int end = getLastVisiblePosition();
- if (start <= mPosHighlight && mPosHighlight <= end) {
- highlightView(getChildAt(mPosHighlight - start));
- }
- }
-
- private void highlightView(View view) {
- if (Boolean.TRUE.equals(view.getTag(R.id.view_highlighted))) {
- // already highlighted
- } else {
- view.setTag(R.id.view_highlighted, true);
- view.setTag(R.id.view_unhighlight_background, view.getBackground());
- view.setBackground(getHighlightBackground());
- view.postDelayed(() -> {
- mPosHighlight = -1;
- unhighlightView(view);
- }, 15000L);
- }
- }
-
- private void unhighlightView(View view) {
- if (Boolean.TRUE.equals(view.getTag(R.id.view_highlighted))) {
- Object background = view.getTag(R.id.view_unhighlight_background);
- if (background instanceof Drawable) {
- view.setBackground((Drawable) background);
- }
- view.setTag(R.id.view_unhighlight_background, null);
- view.setTag(R.id.view_highlighted, false);
- }
- }
-
- private class HighLightAdapter extends HeaderViewListAdapter {
- public HighLightAdapter(ListAdapter adapter) {
- super(new ArrayList<>(), new ArrayList<>(), adapter);
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View view = super.getView(position, convertView, parent);
-
- if (position == mPosHighlight) {
- highlightView(view);
- } else {
- unhighlightView(view);
- }
- return view;
- }
- }
-
- private ColorDrawable getHighlightBackground() {
- int color = ColorUtils.setAlphaComponent(Themes.getColorAccent(getContext()), 26);
- if (mColorAnimated) {
- return new ColorDrawable(color);
- }
- mColorAnimated = true;
- ColorDrawable bg = new ColorDrawable(Color.WHITE);
- ObjectAnimator anim = ObjectAnimator.ofInt(bg, "color", Color.WHITE, color);
- anim.setEvaluator(new ArgbEvaluator());
- anim.setDuration(200L);
- anim.setRepeatMode(ValueAnimator.REVERSE);
- anim.setRepeatCount(4);
- anim.start();
- return bg;
- }
-}