Merge "Use split thumbnail width/height directly" into sc-v2-dev
diff --git a/Android.bp b/Android.bp
index 8b7eb54..60ef5b1 100644
--- a/Android.bp
+++ b/Android.bp
@@ -204,6 +204,7 @@
],
static_libs: [
"Launcher3ResLib",
+ "lottie",
"SystemUISharedLib",
"SystemUI-statsd",
],
diff --git a/build.gradle b/build.gradle
index 617738a..683a4cf 100644
--- a/build.gradle
+++ b/build.gradle
@@ -163,6 +163,8 @@
androidTestImplementation 'com.android.support.test:rules:1.0.0'
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}"
+
+ api 'com.airbnb.android:lottie:3.3.0'
}
protobuf {
diff --git a/quickstep/res/layout/activity_allset.xml b/quickstep/res/layout/activity_allset.xml
index b4ee482..9ad10dc 100644
--- a/quickstep/res/layout/activity_allset.xml
+++ b/quickstep/res/layout/activity_allset.xml
@@ -25,82 +25,100 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginStart="@dimen/allset_page_margin_horizontal"
- android:layout_marginEnd="@dimen/allset_page_margin_horizontal"
- android:layoutDirection="locale"
- android:textDirection="locale"
android:id="@+id/content_view"
- android:forceHasOverlappingRendering="false"
- android:fitsSystemWindows="true" >
+ android:fitsSystemWindows="true">
- <ImageView
- android:id="@+id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/allset_title_icon_margin_top"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- android:src="@drawable/ic_all_set"/>
-
- <TextView
- android:id="@+id/title"
- style="@style/TextAppearance.GestureTutorial.Feedback.Title"
+ <com.airbnb.lottie.LottieAnimationView
+ android:id="@+id/animated_background"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/allset_title_margin_top"
- app:layout_constraintTop_toBottomOf="@id/icon"
- app:layout_constraintStart_toStartOf="parent"
- android:gravity="start"
- android:text="@string/allset_title"/>
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:scaleType="centerCrop"
- <TextView
- android:id="@+id/subtitle"
- style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/allset_subtitle_margin_top"
- app:layout_constraintTop_toBottomOf="@id/title"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintWidth_max="@dimen/allset_subtitle_width_max"
- android:gravity="start"
- android:text="@string/allset_description"/>
+ app:lottie_rawRes="@raw/all_set_page_bg"
+ app:lottie_autoPlay="true"
+ app:lottie_loop="true" />
- <androidx.constraintlayout.widget.Guideline
- android:id="@+id/navigation_settings_guideline_bottom"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- app:layout_constraintGuide_percent="0.83" />
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginStart="@dimen/allset_page_margin_horizontal"
+ android:layout_marginEnd="@dimen/allset_page_margin_horizontal"
+ android:layoutDirection="locale"
+ android:textDirection="locale"
+ android:forceHasOverlappingRendering="false"
+ android:fitsSystemWindows="true" >
- <TextView
- android:id="@+id/navigation_settings"
- style="@style/TextAppearance.GestureTutorial.LinkText"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintBottom_toBottomOf="@id/navigation_settings_guideline_bottom"
- android:minHeight="48dp"
- android:background="?android:attr/selectableItemBackground"
- android:text="@string/allset_navigation_settings" />
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/allset_title_icon_margin_top"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ android:src="@drawable/ic_all_set"/>
- <androidx.constraintlayout.widget.Guideline
- android:id="@+id/hint_guideline_bottom"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- app:layout_constraintGuide_percent="0.94" />
+ <TextView
+ android:id="@+id/title"
+ style="@style/TextAppearance.GestureTutorial.Feedback.Title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/allset_title_margin_top"
+ app:layout_constraintTop_toBottomOf="@id/icon"
+ app:layout_constraintStart_toStartOf="parent"
+ android:gravity="start"
+ android:text="@string/allset_title"/>
- <TextView
- android:id="@+id/hint"
- style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
- android:textSize="14sp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintBottom_toBottomOf="@id/hint_guideline_bottom"
- android:text="@string/allset_hint"/>
+ <TextView
+ android:id="@+id/subtitle"
+ style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/allset_subtitle_margin_top"
+ app:layout_constraintTop_toBottomOf="@id/title"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintWidth_max="@dimen/allset_subtitle_width_max"
+ android:gravity="start"
+ android:text="@string/allset_description"/>
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/navigation_settings_guideline_bottom"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ app:layout_constraintGuide_percent="0.83" />
+
+ <TextView
+ android:id="@+id/navigation_settings"
+ style="@style/TextAppearance.GestureTutorial.LinkText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintBottom_toBottomOf="@id/navigation_settings_guideline_bottom"
+ android:minHeight="48dp"
+ android:background="?android:attr/selectableItemBackground"
+ android:text="@string/allset_navigation_settings" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/hint_guideline_bottom"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ app:layout_constraintGuide_percent="0.94" />
+
+ <TextView
+ android:id="@+id/hint"
+ style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
+ android:textSize="14sp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintBottom_toBottomOf="@id/hint_guideline_bottom"
+ android:text="@string/allset_hint"/>
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
index 8c6185c..81039d4 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
@@ -143,8 +143,7 @@
// Let touches pass through us.
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
} else if (mControllers.navbarButtonsViewController.isImeVisible()) {
- insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_CONTENT);
- insetsIsTouchableRegion = false;
+ insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
} else if (!mControllers.uiController.isTaskbarTouchable()) {
// Let touches pass through us.
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index ae3cc50..6addfe3 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -32,7 +32,6 @@
import static com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR;
-import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR_ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.clampToProgress;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.statehandlers.DepthController.DEPTH;
@@ -193,7 +192,6 @@
boolean showAsGrid = dp.overviewShowAsGrid;
boolean parallaxCenterAndAdjacentTask =
taskIndex != recentsView.getCurrentPage() && !showAsGrid;
- float gridTranslationSecondary = recentsView.getGridTranslationSecondary(taskIndex);
int startScroll = recentsView.getScrollOffset(taskIndex);
RemoteTargetHandle[] topMostSimulators = null;
@@ -211,11 +209,9 @@
tvsLocal.fullScreenProgress.value = 0;
tvsLocal.recentsViewScale.value = 1;
- if (showAsGrid) {
- tvsLocal.taskSecondaryTranslation.value = gridTranslationSecondary;
- }
tvsLocal.setScroll(startScroll);
tvsLocal.setIsGridTask(v.isGridTask());
+ tvsLocal.setGridTranslationY(v.getGridTranslationY());
// Fade in the task during the initial 20% of the animation
out.addFloat(targetHandle.getTransformParams(), TransformParams.TARGET_ALPHA, 0, 1,
@@ -230,10 +226,6 @@
out.setFloat(tvsLocal.recentsViewScale,
AnimatedFloat.VALUE, tvsLocal.getFullScreenScale(),
TOUCH_RESPONSE_INTERPOLATOR);
- if (showAsGrid) {
- out.setFloat(tvsLocal.taskSecondaryTranslation, AnimatedFloat.VALUE, 0,
- TOUCH_RESPONSE_INTERPOLATOR_ACCEL_DEACCEL);
- }
out.setFloat(tvsLocal.recentsViewScroll, AnimatedFloat.VALUE, 0,
TOUCH_RESPONSE_INTERPOLATOR);
diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
index 965c1bc..1c3e784 100644
--- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
@@ -19,6 +19,7 @@
import static com.android.launcher3.Utilities.mapRange;
import static com.android.launcher3.anim.Interpolators.LINEAR;
+import android.animation.Animator;
import android.app.Activity;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
@@ -38,6 +39,8 @@
import android.graphics.Shader.TileMode;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.VibrationEffect;
+import android.os.Vibrator;
import android.util.Log;
import android.view.View;
import android.view.View.AccessibilityDelegate;
@@ -56,6 +59,8 @@
import com.android.quickstep.TouchInteractionService.TISBinder;
import com.android.quickstep.util.TISBindHelper;
+import com.airbnb.lottie.LottieAnimationView;
+
import java.net.URISyntaxException;
/**
@@ -80,6 +85,10 @@
private View mContentView;
private float mSwipeUpShift;
+ @Nullable private Vibrator mVibrator;
+ private LottieAnimationView mAnimatedBackground;
+ private Animator.AnimatorListener mBackgroundAnimatorListener;
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -115,6 +124,52 @@
findViewById(R.id.hint).setAccessibilityDelegate(new SkipButtonAccessibilityDelegate());
mTISBindHelper = new TISBindHelper(this, this::onTISConnected);
+
+ mVibrator = getSystemService(Vibrator.class);
+ mAnimatedBackground = findViewById(R.id.animated_background);
+ startBackgroundAnimation();
+ }
+
+ private void startBackgroundAnimation() {
+ if (Utilities.ATLEAST_S && mVibrator != null && mVibrator.areAllPrimitivesSupported(
+ VibrationEffect.Composition.PRIMITIVE_THUD)) {
+ if (mBackgroundAnimatorListener == null) {
+ mBackgroundAnimatorListener =
+ new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mVibrator.vibrate(getVibrationEffect());
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ mVibrator.vibrate(getVibrationEffect());
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mVibrator.cancel();
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ mVibrator.cancel();
+ }
+ };
+ }
+ mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener);
+ }
+ mAnimatedBackground.playAnimation();
+ }
+
+ /**
+ * Sets up the vibration effect for the next round of animation. The parameters vary between
+ * different illustrations.
+ */
+ private VibrationEffect getVibrationEffect() {
+ return VibrationEffect.startComposition()
+ .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 50)
+ .compose();
}
@Override
@@ -153,6 +208,9 @@
super.onDestroy();
mTISBindHelper.onDestroy();
clearBinderOverride();
+ if (mBackgroundAnimatorListener != null) {
+ mAnimatedBackground.removeAnimatorListener(mBackgroundAnimatorListener);
+ }
}
private AnimatedFloat createSwipeUpProxy(GestureState state) {
@@ -173,6 +231,12 @@
1, 0, LINEAR);
mContentView.setAlpha(alpha);
mContentView.setTranslationY((alpha - 1) * mSwipeUpShift);
+
+ if (alpha == 0f) {
+ mAnimatedBackground.pauseAnimation();
+ } else if (!mAnimatedBackground.isAnimating()) {
+ mAnimatedBackground.resumeAnimation();
+ }
}
/**
diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
index 146d235..7d396ba 100644
--- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
+++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
@@ -102,6 +102,7 @@
private StagedSplitBounds mStagedSplitBounds;
private boolean mDrawsBelowRecents;
private boolean mIsGridTask;
+ private float mGridTranslationY;
public TaskViewSimulator(Context context, BaseActivityInterface sizeStrategy) {
mContext = context;
@@ -156,9 +157,15 @@
fullTaskSize = new Rect(mTaskRect);
mOrientationState.getOrientationHandler()
.setSplitTaskSwipeRect(mDp, mTaskRect, mStagedSplitBounds, mStagePosition);
+ if (mIsGridTask) {
+ mTaskRect.offset(0, (int) mGridTranslationY);
+ }
} else {
fullTaskSize = mTaskRect;
}
+ if (mIsGridTask) {
+ fullTaskSize.offset(0, (int) mGridTranslationY);
+ }
return mOrientationState.getFullScreenScaleAndPivot(fullTaskSize, mDp, mPivot);
}
@@ -218,6 +225,13 @@
}
/**
+ * Sets the y-translation when overview is in grid.
+ */
+ public void setGridTranslationY(float gridTranslationY) {
+ mGridTranslationY = gridTranslationY;
+ }
+
+ /**
* Adds animation for all the components corresponding to transition from an app to overview.
*/
public void addAppToOverviewAnim(PendingAnimation pa, TimeInterpolator interpolator) {
@@ -320,14 +334,12 @@
mMatrix.postTranslate(insets.left, insets.top);
mMatrix.postScale(scale, scale);
- // Apply TaskView matrix: translate, scroll
+ // Apply TaskView matrix: taskRect, translate
mMatrix.postTranslate(mTaskRect.left, mTaskRect.top);
mOrientationState.getOrientationHandler().set(mMatrix, MATRIX_POST_TRANSLATE,
taskPrimaryTranslation.value);
mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE,
taskSecondaryTranslation.value);
- mOrientationState.getOrientationHandler().set(
- mMatrix, MATRIX_POST_TRANSLATE, recentsViewScroll.value);
// Apply RecentsView matrix
mMatrix.postScale(recentsViewScale.value, recentsViewScale.value, mPivot.x, mPivot.y);
@@ -335,6 +347,8 @@
recentsViewSecondaryTranslation.value);
mOrientationState.getOrientationHandler().set(mMatrix, MATRIX_POST_TRANSLATE,
recentsViewPrimaryTranslation.value);
+ mOrientationState.getOrientationHandler().set(
+ mMatrix, MATRIX_POST_TRANSLATE, recentsViewScroll.value);
applyWindowToHomeRotation(mMatrix);
// Crop rect is the inverse of thumbnail matrix
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index aa5fde8..7b5a6b9 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -4679,20 +4679,6 @@
return position != -1 ? position : bottomRowIdArray.indexOf(taskView.getTaskViewId());
}
- /**
- * Returns how many pixels the task is offset on the currently laid out secondary axis
- * according to {@link #mGridProgress}.
- */
- public float getGridTranslationSecondary(int pageIndex) {
- TaskView taskView = getTaskViewAt(pageIndex);
- if (taskView == null) {
- return 0;
- }
-
- return mOrientationHandler.getSecondaryValue(taskView.getGridTranslationX(),
- taskView.getGridTranslationY());
- }
-
public Consumer<MotionEvent> getEventDispatcher(float navbarRotation) {
float degreesRotated;
if (navbarRotation == 0) {
diff --git a/res/raw/all_set_page_bg.json b/res/raw/all_set_page_bg.json
new file mode 100644
index 0000000..9705837
--- /dev/null
+++ b/res/raw/all_set_page_bg.json
@@ -0,0 +1 @@
+{"v":"5.7.8","fr":24,"ip":0,"op":72,"w":2472,"h":5352,"nm":"3Second_MAIN_Welcome","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":3,"nm":"Null 60","sr":1,"ks":{"o":{"a":0,"k":0,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[1508,1364,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":240,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"PinkFlower","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":72,"s":[56]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.07,"y":0.986},"o":{"x":0.167,"y":0.167},"t":0,"s":[1505.832,1379.455,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.773,"y":0.01},"t":38,"s":[1505.832,575,0],"to":[0,0,0],"ti":[0,0,0]},{"t":72,"s":[1505.832,1379.455,0]}],"ix":2,"l":2},"a":{"a":0,"k":[-3514.717,-358.642,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[75.615,-96.908],[89.338,-70.276],[111.99,-50.668],[111.764,-20.709],[122.709,7.18],[108.586,33.602],[105.316,63.383],[80.533,80.216],[63.797,105.066],[34.03,108.453],[7.663,122.679],[-20.269,111.845],[-50.226,112.189],[-69.924,89.614],[-96.61,75.997],[-103.56,46.854],[-120.861,22.395],[-113.472,-6.639],[-117.425,-36.337],[-97.389,-58.612],[-87.087,-86.745],[-58.996,-97.158],[-36.8,-117.281],[-7.086,-113.445],[21.918,-120.948],[46.446,-103.744]],"o":[[-75.615,96.909],[-89.338,70.276],[-111.99,50.668],[-111.764,20.709],[-122.709,-7.18],[-108.586,-33.602],[-105.316,-63.383],[-80.533,-80.216],[-63.797,-105.066],[-34.03,-108.453],[-7.663,-122.679],[20.269,-111.845],[50.226,-112.188],[69.924,-89.614],[96.61,-75.997],[103.56,-46.854],[120.861,-22.395],[113.472,6.64],[117.425,36.337],[97.389,58.612],[87.088,86.745],[58.995,97.158],[36.8,117.281],[7.087,113.445],[-21.918,120.948],[-46.446,103.744]],"v":[[733.209,572.105],[531.711,675.932],[383.354,847.313],[156.685,845.606],[-54.323,928.412],[-254.235,821.562],[-479.555,796.823],[-606.913,609.309],[-794.927,482.691],[-820.554,257.47],[-928.191,57.981],[-846.217,-153.353],[-848.817,-380.013],[-678.021,-529.044],[-574.99,-730.949],[-354.499,-783.537],[-169.439,-914.435],[50.234,-858.532],[274.928,-888.434],[443.46,-736.847],[656.313,-658.903],[735.094,-446.359],[887.344,-278.426],[858.327,-53.616],[915.095,165.835],[784.928,351.409]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.839215686275,0.439215686275,0.388235294118,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":4,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.839215746113,0.439215716194,0.388235324037,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":true},{"ty":"tr","p":{"a":0,"k":[-3509.952,-363.731],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Polystar 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":288,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Ellipse_Bottom","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.07],"y":[1.248]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[-56]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.719],"y":[0.172]},"t":38,"s":[-38]},{"t":72,"s":[-56]}],"ix":10},"p":{"s":true,"x":{"a":1,"k":[{"i":{"x":[0.07],"y":[1.032]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[1720]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.719],"y":[0.022]},"t":38,"s":[1544]},{"t":72,"s":[1720]}],"ix":3},"y":{"a":1,"k":[{"i":{"x":[0.07],"y":[1.034]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[4069]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.719],"y":[0.024]},"t":38,"s":[3872]},{"t":72,"s":[4069]}],"ix":4}},"a":{"a":0,"k":[164.438,1433.781,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[3079.125,4685.989],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.305882352941,0.309803921569,0.321568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":4,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.882353001015,0.894118006089,0.886274988511,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":true},{"ty":"tr","p":{"a":0,"k":[164.438,1481.781],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":240,"st":0,"bm":0}],"markers":[]}
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 02eb1de..adb1613 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -19,6 +19,8 @@
import static android.animation.ValueAnimator.areAnimatorsEnabled;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5;
+import static com.android.launcher3.dragndrop.DraggableView.DRAGGABLE_ICON;
+import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -37,7 +39,6 @@
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
import android.util.ArrayMap;
@@ -61,6 +62,7 @@
import com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.dragndrop.DraggableView;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.CellAndSpan;
@@ -442,18 +444,43 @@
}
if (DEBUG_VISUALIZE_OCCUPIED) {
- int[] pt = new int[2];
- ColorDrawable cd = new ColorDrawable(Color.RED);
- cd.setBounds(0, 0, mCellWidth, mCellHeight);
- for (int i = 0; i < mCountX; i++) {
- for (int j = 0; j < mCountY; j++) {
- if (mOccupied.cells[i][j]) {
- cellToPoint(i, j, pt);
- canvas.save();
- canvas.translate(pt[0], pt[1]);
- cd.draw(canvas);
- canvas.restore();
+ Rect cellBounds = new Rect();
+ // Will contain the bounds of the cell including spacing between cells.
+ Rect cellBoundsWithSpacing = new Rect();
+ int[] targetCell = new int[2];
+ int[] cellCenter = new int[2];
+ Paint debugPaint = new Paint();
+ debugPaint.setStrokeWidth(Utilities.dpToPx(1));
+ for (int x = 0; x < mCountX; x++) {
+ for (int y = 0; y < mCountY; y++) {
+ if (!mOccupied.cells[x][y]) {
+ continue;
}
+ targetCell[0] = x;
+ targetCell[1] = y;
+
+ boolean canCreateFolder = canCreateFolder(getChildAt(x, y));
+ cellToRect(x, y, 1, 1, cellBounds);
+ cellBoundsWithSpacing.set(cellBounds);
+ cellBoundsWithSpacing.inset(-mBorderSpace.x / 2, -mBorderSpace.y / 2);
+ getWorkspaceCellVisualCenter(x, y, cellCenter);
+
+ canvas.save();
+ canvas.clipRect(cellBoundsWithSpacing);
+
+ // Draw reorder drag target.
+ debugPaint.setColor(Color.RED);
+ canvas.drawCircle(cellCenter[0], cellCenter[1], getReorderRadius(targetCell),
+ debugPaint);
+
+ // Draw folder creation drag target.
+ if (canCreateFolder) {
+ debugPaint.setColor(Color.GREEN);
+ canvas.drawCircle(cellCenter[0], cellCenter[1],
+ getFolderCreationRadius(targetCell), debugPaint);
+ }
+
+ canvas.restore();
}
}
}
@@ -482,6 +509,14 @@
}
/**
+ * Returns whether dropping an icon on the given View can create (or add to) a folder.
+ */
+ private boolean canCreateFolder(View child) {
+ return child instanceof DraggableView
+ && ((DraggableView) child).getViewType() == DRAGGABLE_ICON;
+ }
+
+ /**
* Indicates the progress of the Workspace entering the SpringLoaded state; allows the
* CellLayout to update various visuals for this state.
*
@@ -817,7 +852,7 @@
}
/**
- * Given a cell coordinate and span return the point that represents the center of the regio
+ * Given a cell coordinate and span return the point that represents the center of the region
*
* @param cellX X coordinate of the cell
* @param cellY Y coordinate of the cell
@@ -830,11 +865,65 @@
result[1] = mTempRect.centerY();
}
- public float getDistanceFromCell(float x, float y, int[] cell) {
- cellToCenterPoint(cell[0], cell[1], mTmpPoint);
+ /**
+ * Returns the distance between the given coordinate and the visual center of the given cell.
+ */
+ public float getDistanceFromWorkspaceCellVisualCenter(float x, float y, int[] cell) {
+ getWorkspaceCellVisualCenter(cell[0], cell[1], mTmpPoint);
return (float) Math.hypot(x - mTmpPoint[0], y - mTmpPoint[1]);
}
+ private void getWorkspaceCellVisualCenter(int cellX, int cellY, int[] outPoint) {
+ View child = getChildAt(cellX, cellY);
+ if (child instanceof DraggableView) {
+ DraggableView draggableChild = (DraggableView) child;
+ if (draggableChild.getViewType() == DRAGGABLE_ICON) {
+ cellToPoint(cellX, cellY, outPoint);
+ draggableChild.getWorkspaceVisualDragBounds(mTempRect);
+ mTempRect.offset(outPoint[0], outPoint[1]);
+ outPoint[0] = mTempRect.centerX();
+ outPoint[1] = mTempRect.centerY();
+ return;
+ }
+ }
+ cellToCenterPoint(cellX, cellY, outPoint);
+ }
+
+ /**
+ * Returns the max distance from the center of a cell that can accept a drop to create a folder.
+ */
+ public float getFolderCreationRadius(int[] targetCell) {
+ DeviceProfile grid = mActivity.getDeviceProfile();
+ float iconVisibleRadius = ICON_VISIBLE_AREA_FACTOR * grid.iconSizePx / 2;
+ // Halfway between reorder radius and icon.
+ return (getReorderRadius(targetCell) + iconVisibleRadius) / 2;
+ }
+
+ /**
+ * Returns the max distance from the center of a cell that will start to reorder on drag over.
+ */
+ public float getReorderRadius(int[] targetCell) {
+ int[] centerPoint = mTmpPoint;
+ getWorkspaceCellVisualCenter(targetCell[0], targetCell[1], centerPoint);
+
+ Rect cellBoundsWithSpacing = mTempRect;
+ cellToRect(targetCell[0], targetCell[1], 1, 1, cellBoundsWithSpacing);
+ cellBoundsWithSpacing.inset(-mBorderSpace.x / 2, -mBorderSpace.y / 2);
+
+ if (canCreateFolder(getChildAt(targetCell[0], targetCell[1]))) {
+ // Take only the circle in the smaller dimension, to ensure we don't start reordering
+ // too soon before accepting a folder drop.
+ int minRadius = centerPoint[0] - cellBoundsWithSpacing.left;
+ minRadius = Math.min(minRadius, centerPoint[1] - cellBoundsWithSpacing.top);
+ minRadius = Math.min(minRadius, cellBoundsWithSpacing.right - centerPoint[0]);
+ minRadius = Math.min(minRadius, cellBoundsWithSpacing.bottom - centerPoint[1]);
+ return minRadius;
+ }
+ // Take up the entire cell, including space between this cell and the adjacent ones.
+ return (float) Math.hypot(cellBoundsWithSpacing.width() / 2f,
+ cellBoundsWithSpacing.height() / 2f);
+ }
+
public int getCellWidth() {
return mCellWidth;
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 131fbfb..203df0a 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -220,7 +220,6 @@
private FolderIcon mDragOverFolderIcon = null;
private boolean mCreateUserFolderOnDrop = false;
private boolean mAddToExistingFolderOnDrop = false;
- private float mMaxDistanceForFolderCreation;
// Variables relating to touch disambiguation (scrolling workspace vs. scrolling a widget)
private float mXDown;
@@ -308,8 +307,6 @@
public void setInsets(Rect insets) {
DeviceProfile grid = mLauncher.getDeviceProfile();
- mMaxDistanceForFolderCreation = grid.isTablet
- ? 0.75f * grid.iconSizePx : 0.55f * grid.iconSizePx;
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
Rect padding = grid.workspacePadding;
@@ -1774,8 +1771,8 @@
mTargetCell = findNearestArea((int) mDragViewVisualCenter[0],
(int) mDragViewVisualCenter[1], minSpanX, minSpanY, dropTargetLayout,
mTargetCell);
- float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
- mDragViewVisualCenter[1], mTargetCell);
+ float distance = dropTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
+ mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
if (mCreateUserFolderOnDrop && willCreateUserFolder(d.dragInfo,
dropTargetLayout, mTargetCell, distance, true)) {
return true;
@@ -1809,7 +1806,7 @@
boolean willCreateUserFolder(ItemInfo info, CellLayout target, int[] targetCell,
float distance, boolean considerTimeout) {
- if (distance > mMaxDistanceForFolderCreation) return false;
+ if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
return willCreateUserFolder(info, dropOverView, considerTimeout);
}
@@ -1844,7 +1841,7 @@
boolean willAddToExistingUserFolder(ItemInfo dragInfo, CellLayout target, int[] targetCell,
float distance) {
- if (distance > mMaxDistanceForFolderCreation) return false;
+ if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
return willAddToExistingUserFolder(dragInfo, dropOverView);
@@ -1868,7 +1865,7 @@
boolean createUserFolderIfNecessary(View newView, int container, CellLayout target,
int[] targetCell, float distance, boolean external, DragObject d) {
- if (distance > mMaxDistanceForFolderCreation) return false;
+ if (distance > target.getFolderCreationRadius(targetCell)) return false;
View v = target.getChildAt(targetCell[0], targetCell[1]);
boolean hasntMoved = false;
@@ -1925,7 +1922,7 @@
boolean addToExistingFolderIfNecessary(View newView, CellLayout target, int[] targetCell,
float distance, DragObject d, boolean external) {
- if (distance > mMaxDistanceForFolderCreation) return false;
+ if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
if (!mAddToExistingFolderOnDrop) return false;
@@ -1989,8 +1986,8 @@
mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], (int)
mDragViewVisualCenter[1], spanX, spanY, dropTargetLayout, mTargetCell);
- float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
- mDragViewVisualCenter[1], mTargetCell);
+ float distance = dropTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
+ mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
// If the item being dropped is a shortcut and the nearest drop
// cell also contains a shortcut, then create a folder with the two shortcuts.
@@ -2418,7 +2415,7 @@
setCurrentDropOverCell(mTargetCell[0], mTargetCell[1]);
- float targetCellDistance = mDragTargetLayout.getDistanceFromCell(
+ float targetCellDistance = mDragTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
manageFolderFeedback(targetCellDistance, d);
@@ -2431,8 +2428,9 @@
mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1],
item.spanX, item.spanY, d);
} else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER)
- && !mReorderAlarm.alarmPending() && (mLastReorderX != reorderX ||
- mLastReorderY != reorderY)) {
+ && !mReorderAlarm.alarmPending()
+ && (mLastReorderX != reorderX || mLastReorderY != reorderY)
+ && targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell)) {
int[] resultSpan = new int[2];
mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0],
@@ -2529,7 +2527,7 @@
}
private void manageFolderFeedback(float distance, DragObject dragObject) {
- if (distance > mMaxDistanceForFolderCreation) {
+ if (distance > mDragTargetLayout.getFolderCreationRadius(mTargetCell)) {
if ((mDragMode == DRAG_MODE_ADD_TO_FOLDER
|| mDragMode == DRAG_MODE_CREATE_FOLDER)) {
setDragMode(DRAG_MODE_NONE);
@@ -2674,8 +2672,8 @@
if (pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
mTargetCell = findNearestArea(touchXY[0], touchXY[1], spanX, spanY,
cellLayout, mTargetCell);
- float distance = cellLayout.getDistanceFromCell(mDragViewVisualCenter[0],
- mDragViewVisualCenter[1], mTargetCell);
+ float distance = cellLayout.getDistanceFromWorkspaceCellVisualCenter(
+ mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
if (willCreateUserFolder(d.dragInfo, cellLayout, mTargetCell, distance, true)
|| willAddToExistingUserFolder(
d.dragInfo, cellLayout, mTargetCell, distance)) {
@@ -2774,8 +2772,8 @@
if (touchXY != null) {
mTargetCell = findNearestArea(touchXY[0], touchXY[1], spanX, spanY,
cellLayout, mTargetCell);
- float distance = cellLayout.getDistanceFromCell(mDragViewVisualCenter[0],
- mDragViewVisualCenter[1], mTargetCell);
+ float distance = cellLayout.getDistanceFromWorkspaceCellVisualCenter(
+ mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
if (createUserFolderIfNecessary(view, container, cellLayout, mTargetCell, distance,
true, d)) {
return;