Merge changes from topic 'am-8d8ca114-e86f-43c6-8613-588414d352dc' into ub-launcher3-master
* changes:
Using common fling detection logic for notification and all-apps am: b72d8b2c8b
Using common fling detection logic for notification and all-apps
diff --git a/Android.mk b/Android.mk
index c8a53d2..0543b42 100644
--- a/Android.mk
+++ b/Android.mk
@@ -33,7 +33,8 @@
$(call all-java-files-under, src) \
$(call all-java-files-under, src_config) \
$(call all-java-files-under, src_flags) \
- $(call all-proto-files-under, protos)
+ $(call all-proto-files-under, protos) \
+ $(call all-proto-files-under, proto_overrides)
LOCAL_RESOURCE_DIR := \
$(LOCAL_PATH)/res \
@@ -42,7 +43,7 @@
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
-LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
+LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/ --proto_path=$(LOCAL_PATH)/proto_overrides/
LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java
LOCAL_AAPT_FLAGS := \
@@ -66,10 +67,10 @@
#
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-proto-files-under, protos)
+LOCAL_SRC_FILES := $(call all-proto-files-under, protos) $(call all-proto-files-under, proto_overrides)
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
-LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
+LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/ --proto_path=$(LOCAL_PATH)/proto_overrides/
LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java
LOCAL_MODULE_TAGS := optional
diff --git a/build.gradle b/build.gradle
index c23a299..79ee111 100644
--- a/build.gradle
+++ b/build.gradle
@@ -41,7 +41,10 @@
res.srcDirs = ['res']
java.srcDirs = ['src', 'src_flags']
manifest.srcFile 'AndroidManifest-common.xml'
- proto.srcDirs 'protos/'
+ proto {
+ srcDir 'protos/'
+ srcDir 'proto_overrides/'
+ }
}
androidTest {
@@ -92,6 +95,7 @@
task.builtins {
remove java
javanano {
+ option "java_package=launcher_log_extension.proto|com.android.launcher3.userevent.nano"
option "java_package=launcher_log.proto|com.android.launcher3.userevent.nano"
option "java_package=launcher_dump.proto|com.android.launcher3.model.nano"
option "enum_style=java"
diff --git a/proto_overrides/launcher_log_extension.proto b/proto_overrides/launcher_log_extension.proto
new file mode 100644
index 0000000..2995aa2
--- /dev/null
+++ b/proto_overrides/launcher_log_extension.proto
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+syntax = "proto2";
+
+option java_package = "com.android.launcher3.userevent";
+option java_outer_classname = "LauncherLogExtensions";
+
+package userevent;
+
+//
+// Use this to add any app specific extensions to the proto.
+//
+message LauncherEventExtension {
+}
+
+message TargetExtension {
+}
diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto
index 93e09ae..0bbec18 100644
--- a/protos/launcher_log.proto
+++ b/protos/launcher_log.proto
@@ -15,6 +15,8 @@
*/
syntax = "proto2";
+import "launcher_log_extension.proto";
+
option java_package = "com.android.launcher3.userevent";
option java_outer_classname = "LauncherLogProto";
@@ -52,6 +54,7 @@
optional int32 span_x = 13 [default = 1];// Used for ItemType.WIDGET
optional int32 span_y = 14 [default = 1];// Used for ItemType.WIDGET
optional int32 predictedRank = 15;
+ optional TargetExtension extension = 16;
}
// Used to define what type of item a Target would represent.
@@ -144,7 +147,6 @@
// Action (Touch) + Target + Target
//
message LauncherEvent {
-
required Action action = 1;
// List of targets that touch actions can be operated on.
@@ -157,4 +159,6 @@
optional bool is_in_multi_window_mode = 7;
optional bool is_in_landscape_mode = 8;
+
+ optional LauncherEventExtension extension = 9;
}
diff --git a/res/layout/folder_application.xml b/res/layout/folder_application.xml
index de861a0..9d4af0d 100644
--- a/res/layout/folder_application.xml
+++ b/res/layout/folder_application.xml
@@ -19,4 +19,9 @@
xmlns:launcher="http://schemas.android.com/apk/res-auto"
style="@style/BaseIcon"
android:includeFontPadding="false"
- launcher:iconDisplay="folder" />
+ android:paddingLeft="@dimen/folder_cell_x_padding"
+ android:paddingTop="@dimen/folder_cell_y_padding"
+ android:paddingRight="@dimen/folder_cell_x_padding"
+ android:paddingBottom="@dimen/folder_cell_y_padding"
+ launcher:centerVertically="true"
+ launcher:iconDisplay="folder"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 356de78..0eb3982 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -138,10 +138,11 @@
<dimen name="folder_preview_padding">10dp</dimen>
<dimen name="page_indicator_dot_size">8dp</dimen>
- <dimen name="folder_cell_x_padding">9dp</dimen>
- <dimen name="folder_cell_y_padding">6dp</dimen>
+ <dimen name="folder_cell_x_padding">8dp</dimen>
+ <dimen name="folder_cell_y_padding">8dp</dimen>
<dimen name="folder_child_text_size">13sp</dimen>
- <dimen name="folder_label_padding_top">4dp</dimen>
+ <dimen name="folder_child_icon_drawable_padding">8dp</dimen>
+ <dimen name="folder_label_padding_top">12dp</dimen>
<dimen name="folder_label_padding_bottom">12dp</dimen>
<dimen name="folder_label_text_size">14sp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9929671..1197b1c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -59,11 +59,11 @@
<!-- All Apps -->
<!-- Search bar text in the apps view. [CHAR_LIMIT=50] -->
- <string name="all_apps_search_bar_hint">Search Apps</string>
+ <string name="all_apps_search_bar_hint">Search apps</string>
<!-- Loading apps text. [CHAR_LIMIT=50] -->
- <string name="all_apps_loading_message">Loading Apps…</string>
+ <string name="all_apps_loading_message">Loading apps…</string>
<!-- No-search-results text. [CHAR_LIMIT=50] -->
- <string name="all_apps_no_search_results">No Apps found matching \"<xliff:g id="query" example="Android">%1$s</xliff:g>\"</string>
+ <string name="all_apps_no_search_results">No apps found matching \"<xliff:g id="query" example="Android">%1$s</xliff:g>\"</string>
<!-- Label for the button which allows the user to get app search results. [CHAR_LIMIT=50] -->
<string name="all_apps_search_market_message">Search for more apps</string>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 2d5f8d0..38011ea 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -108,6 +108,7 @@
public int folderChildIconSizePx;
public int folderChildTextSizePx;
public int folderChildDrawablePaddingPx;
+ public final int folderChildDrawablePaddingOriginalPx;
// Hotseat
public int hotseatCellHeightPx;
@@ -220,6 +221,9 @@
hotseatLandRightNavBarGutterPx = res.getDimensionPixelSize(
R.dimen.dynamic_grid_hotseat_land_right_nav_bar_gutter_width);
+ folderChildDrawablePaddingOriginalPx =
+ res.getDimensionPixelSize(R.dimen.folder_child_icon_drawable_padding);
+
// Determine sizes.
widthPx = width;
heightPx = height;
@@ -390,15 +394,15 @@
folderChildIconSizePx = (int) (Utilities.pxFromDp(inv.iconSize, dm) * scale);
folderChildTextSizePx =
(int) (res.getDimensionPixelSize(R.dimen.folder_child_text_size) * scale);
+ folderChildDrawablePaddingPx = (int) (folderChildDrawablePaddingOriginalPx * scale);
int textHeight = Utilities.calculateTextHeight(folderChildTextSizePx);
int cellPaddingX = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_x_padding) * scale);
int cellPaddingY = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_y_padding) * scale);
folderCellWidthPx = folderChildIconSizePx + 2 * cellPaddingX;
- folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight;
- folderChildDrawablePaddingPx = Math.max(0,
- (folderCellHeightPx - folderChildIconSizePx - textHeight) / 3);
+ folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight
+ + folderChildDrawablePaddingPx;
}
public void updateInsets(Rect insets) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index c2bddd5..7b7177e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -274,6 +274,7 @@
private boolean mHasFocus = false;
private ObjectAnimator mScrimAnimator;
+ private boolean mShouldFadeInScrim;
private PopupDataProvider mPopupDataProvider;
@@ -467,8 +468,12 @@
mLauncherCallbacks.onCreate(savedInstanceState);
}
- // Listen for broadcasts screen off
- registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
+ // Listen for broadcasts
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_SCREEN_OFF);
+ filter.addAction(Intent.ACTION_USER_PRESENT); // When the device wakes up + keyguard is gone
+ registerReceiver(mReceiver, filter);
+ mShouldFadeInScrim = true;
getSystemUiController().updateUiState(SystemUiController.UI_STATE_BASE_WINDOW,
Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText));
@@ -906,7 +911,7 @@
NotificationListener.setNotificationsChangedListener(mPopupDataProvider);
}
- if (mIsResumeFromActionScreenOff && mDragLayer.getBackground() != null) {
+ if (mShouldFadeInScrim && mDragLayer.getBackground() != null) {
if (mScrimAnimator != null) {
mScrimAnimator.cancel();
}
@@ -923,6 +928,7 @@
mScrimAnimator.setStartDelay(getWindow().getTransitionBackgroundFadeDuration());
mScrimAnimator.start();
}
+ mShouldFadeInScrim = false;
}
@Override
@@ -1534,6 +1540,11 @@
}
}
mIsResumeFromActionScreenOff = true;
+ mShouldFadeInScrim = true;
+ } else if (Intent.ACTION_USER_PRESENT.equals(action)) {
+ // ACTION_USER_PRESENT is sent after onStart/onResume. This covers the case where
+ // the user unlocked and the Launcher is not in the foreground.
+ mShouldFadeInScrim = false;
}
}
};
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index 09cfc1e..c11287a 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -16,23 +16,18 @@
package com.android.launcher3.dragndrop;
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.FloatArrayEvaluator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
-import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.pm.LauncherActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
-import android.graphics.ColorFilter;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
-import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
@@ -44,13 +39,11 @@
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
-import android.support.animation.DynamicAnimation;
+import android.support.animation.FloatPropertyCompat;
import android.support.animation.SpringAnimation;
import android.support.animation.SpringForce;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
import com.android.launcher3.FastBitmapDrawable;
import com.android.launcher3.ItemInfo;
@@ -76,7 +69,10 @@
import java.util.Arrays;
import java.util.List;
-public class DragView extends FrameLayout {
+public class DragView extends View {
+ private static final ColorMatrix sTempMatrix1 = new ColorMatrix();
+ private static final ColorMatrix sTempMatrix2 = new ColorMatrix();
+
public static final int COLOR_CHANGE_DURATION = 120;
public static final int VIEW_ZOOM_DURATION = 150;
@@ -114,16 +110,11 @@
private int mAnimatedShiftY;
// Below variable only needed IF FeatureFlags.LAUNCHER3_SPRING_ICONS is {@code true}
- private SpringAnimation mSpringX, mSpringY;
- private ImageView mFgImageView, mBgImageView;
+ private Drawable mBgSpringDrawable, mFgSpringDrawable;
+ private SpringFloatValue mTranslateX, mTranslateY;
private Path mScaledMaskPath;
private Drawable mBadge;
-
- // Following three values are fine tuned with motion ux designer
- private final static int STIFFNESS = 4000;
- private final static float DAMPENING_RATIO = 1f;
- private final static int PARALLAX_MAX_IN_DP = 8;
- private final int mDelta;
+ private ColorMatrixColorFilter mBaseFilter;
/**
* Construct the drag view.
@@ -193,8 +184,6 @@
mBlurSizeOutline = getResources().getDimensionPixelSize(R.dimen.blur_size_medium_outline);
setElevation(getResources().getDimension(R.dimen.drag_elevation));
- setWillNotDraw(false);
- mDelta = (int)(getResources().getDisplayMetrics().density * PARALLAX_MAX_IN_DP);
}
/**
@@ -221,46 +210,89 @@
if (dr instanceof AdaptiveIconDrawable) {
int w = mBitmap.getWidth();
int h = mBitmap.getHeight();
- AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) dr;
- float blurSizeOutline = mLauncher.getResources()
- .getDimension(R.dimen.blur_size_medium_outline);
- float normalizationScale = IconNormalizer.getInstance(mLauncher)
- .getScale(adaptiveIcon, null, null, null) * ((w - blurSizeOutline) / w);
- adaptiveIcon.setBounds(0, 0, w, h);
+ int blurMargin = (int) mLauncher.getResources()
+ .getDimension(R.dimen.blur_size_medium_outline) / 2;
- final Path mask = getMaskPath(adaptiveIcon, normalizationScale);
- mFgImageView = setupImageView(adaptiveIcon.getForeground(), normalizationScale);
- mBgImageView = setupImageView(adaptiveIcon.getBackground(), normalizationScale);
- mSpringX = setupSpringAnimation(-w/4, w/4, DynamicAnimation.TRANSLATION_X);
- mSpringY = setupSpringAnimation(-h/4, h/4, DynamicAnimation.TRANSLATION_Y);
+ Rect bounds = new Rect(0, 0, w, h);
+ bounds.inset(blurMargin, blurMargin);
+ Utilities.scaleRectAboutCenter(bounds,
+ IconNormalizer.getInstance(mLauncher).getScale(dr, null, null, null));
+ AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) dr;
+
+ // Shrink very tiny bit so that the clip path is smaller than the original bitmap
+ // that has anti aliased edges and shadows.
+ Rect shrunkBounds = new Rect(bounds);
+ Utilities.scaleRectAboutCenter(shrunkBounds, 0.98f);
+ adaptiveIcon.setBounds(shrunkBounds);
+ final Path mask = adaptiveIcon.getIconMask();
+
+ mTranslateX = new SpringFloatValue(DragView.this,
+ w * AdaptiveIconDrawable.getExtraInsetFraction());
+ mTranslateY = new SpringFloatValue(DragView.this,
+ h * AdaptiveIconDrawable.getExtraInsetFraction());
mBadge = getBadge(info, appState, outObj[0]);
- int blurMargin = (int) blurSizeOutline / 2;
- mBadge.setBounds(blurMargin, blurMargin, w - blurMargin, h - blurMargin);
+ mBadge.setBounds(bounds);
+
+ bounds.inset(
+ (int) (-bounds.width() * AdaptiveIconDrawable.getExtraInsetFraction()),
+ (int) (-bounds.height() * AdaptiveIconDrawable.getExtraInsetFraction())
+ );
+ mBgSpringDrawable = adaptiveIcon.getBackground();
+ mBgSpringDrawable.setBounds(bounds);
+ mFgSpringDrawable = adaptiveIcon.getForeground();
+ mFgSpringDrawable.setBounds(bounds);
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
// Assign the variable on the UI thread to avoid race conditions.
mScaledMaskPath = mask;
- addView(mBgImageView);
- addView(mFgImageView);
- setWillNotDraw(true);
if (info.isDisabled()) {
FastBitmapDrawable d = new FastBitmapDrawable(null);
d.setIsDisabled(true);
- ColorFilter cf = d.getColorFilter();
- mBgImageView.setColorFilter(cf);
- mFgImageView.setColorFilter(cf);
- mBadge.setColorFilter(cf);
+ mBaseFilter = (ColorMatrixColorFilter) d.getColorFilter();
}
+ updateColorFilter();
}
});
}
}});
}
+ @TargetApi(Build.VERSION_CODES.O)
+ private void updateColorFilter() {
+ if (mCurrentFilter == null) {
+ mPaint.setColorFilter(null);
+
+ if (mScaledMaskPath != null) {
+ mBgSpringDrawable.setColorFilter(mBaseFilter);
+ mBgSpringDrawable.setColorFilter(mBaseFilter);
+ mBadge.setColorFilter(mBaseFilter);
+ }
+ } else {
+ ColorMatrixColorFilter currentFilter = new ColorMatrixColorFilter(mCurrentFilter);
+ mPaint.setColorFilter(currentFilter);
+
+ if (mScaledMaskPath != null) {
+ if (mBaseFilter != null) {
+ mBaseFilter.getColorMatrix(sTempMatrix1);
+ sTempMatrix2.set(mCurrentFilter);
+ sTempMatrix1.postConcat(sTempMatrix2);
+
+ currentFilter = new ColorMatrixColorFilter(sTempMatrix1);
+ }
+
+ mBgSpringDrawable.setColorFilter(currentFilter);
+ mFgSpringDrawable.setColorFilter(currentFilter);
+ mBadge.setColorFilter(currentFilter);
+ }
+ }
+
+ invalidate();
+ }
+
/**
* Returns the full drawable for {@param info}.
* @param outObj this is set to the internal data associated with {@param info},
@@ -324,78 +356,9 @@
}
}
- private ImageView setupImageView(Drawable drawable, float normalizationScale) {
- FrameLayout.LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
- ImageView imageViewOut = new ImageView(getContext());
- imageViewOut.setLayoutParams(params);
- imageViewOut.setScaleType(ImageView.ScaleType.FIT_XY);
- imageViewOut.setScaleX(normalizationScale);
- imageViewOut.setScaleY(normalizationScale);
- imageViewOut.setImageDrawable(drawable);
- return imageViewOut;
- }
-
- private SpringAnimation setupSpringAnimation(int minValue, int maxValue,
- DynamicAnimation.ViewProperty property) {
- SpringAnimation s = new SpringAnimation(mFgImageView, property, 0);
- s.setMinValue(minValue).setMaxValue(maxValue);
- s.setSpring(new SpringForce(0)
- .setDampingRatio(DAMPENING_RATIO)
- .setStiffness(STIFFNESS));
- return s;
- }
-
- @TargetApi(Build.VERSION_CODES.O)
- private Path getMaskPath(AdaptiveIconDrawable dr, float normalizationScale) {
- Matrix m = new Matrix();
- // Shrink very tiny bit so that the clip path is smaller than the original bitmap
- // that has anti aliased edges and shadows.
- float s = normalizationScale * .97f;
- m.setScale(s, s, dr.getBounds().centerX(), dr.getBounds().centerY());
- Path p = new Path();
- dr.getIconMask().transform(m, p);
- return p;
- }
-
- private void applySpring(int x, int y) {
- if (mSpringX == null || mSpringY == null) {
- return;
- }
- mSpringX.animateToFinalPosition(Utilities.boundToRange(x, -mDelta, mDelta));
- mSpringY.animateToFinalPosition(Utilities.boundToRange(y, -mDelta, mDelta));
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- int w = right - left;
- int h = bottom - top;
- for (int i = 0; i < getChildCount(); i++) {
- getChildAt(i).layout(-w / 4, -h / 4, w + w / 4, h + h / 4);
- }
- }
-
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int w = mBitmap.getWidth();
- int h = mBitmap.getHeight();
- setMeasuredDimension(w, h);
- for (int i = 0; i < getChildCount(); i++) {
- getChildAt(i).measure(w, h);
- }
- }
-
- @Override
- protected void dispatchDraw(Canvas canvas) {
- if (mScaledMaskPath != null) {
- int cnt = canvas.save();
- canvas.drawBitmap(mBitmap, 0.0f, 0.0f, mPaint);
- canvas.clipPath(mScaledMaskPath);
- super.dispatchDraw(canvas);
- canvas.restoreToCount(cnt);
- mBadge.draw(canvas);
- } else {
- super.dispatchDraw(canvas);
- }
+ setMeasuredDimension(mBitmap.getWidth(), mBitmap.getHeight());
}
/** Sets the scale of the view over the normal workspace icon size. */
@@ -439,29 +402,10 @@
return mDragRegion;
}
- // Draws drag shadow for system DND.
- @SuppressLint("WrongCall")
- public void drawDragShadow(Canvas canvas) {
- final int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
- canvas.scale(getScaleX(), getScaleY());
- onDraw(canvas);
- canvas.restoreToCount(saveCount);
- }
-
- // Provides drag shadow metrics for system DND.
- public void provideDragShadowMetrics(Point size, Point touch) {
- size.set((int)(mBitmap.getWidth() * getScaleX()), (int)(mBitmap.getHeight() * getScaleY()));
-
- final float xGrowth = mBitmap.getWidth() * (getScaleX() - 1);
- final float yGrowth = mBitmap.getHeight() * (getScaleY() - 1);
- touch.set(
- mRegistrationX + (int)Math.round(xGrowth / 2),
- mRegistrationY + (int)Math.round(yGrowth / 2));
- }
-
@Override
protected void onDraw(Canvas canvas) {
mHasDrawn = true;
+ // Always draw the bitmap to mask anti aliasing due to clipPath
boolean crossFade = mCrossFadeProgress > 0 && mCrossFadeBitmap != null;
if (crossFade) {
int alpha = crossFade ? (int) (255 * (1 - mCrossFadeProgress)) : 255;
@@ -477,6 +421,16 @@
canvas.drawBitmap(mCrossFadeBitmap, 0.0f, 0.0f, mPaint);
canvas.restoreToCount(saveCount);
}
+
+ if (mScaledMaskPath != null) {
+ int cnt = canvas.save();
+ canvas.clipPath(mScaledMaskPath);
+ mBgSpringDrawable.draw(canvas);
+ canvas.translate(mTranslateX.mValue, mTranslateY.mValue);
+ mFgSpringDrawable.draw(canvas);
+ canvas.restoreToCount(cnt);
+ mBadge.draw(canvas);
+ }
}
public void setCrossFadeBitmap(Bitmap crossFadeBitmap) {
@@ -512,8 +466,7 @@
animateFilterTo(m1.getArray());
} else {
if (mCurrentFilter == null) {
- mPaint.setColorFilter(null);
- invalidate();
+ updateColorFilter();
} else {
animateFilterTo(new ColorMatrix().getArray());
}
@@ -534,8 +487,7 @@
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- mPaint.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
- invalidate();
+ updateColorFilter();
}
});
mFilterAnimator.start();
@@ -590,8 +542,10 @@
* @param touchY the y coordinate the user touched in DragLayer coordinates
*/
public void move(int touchX, int touchY) {
- if (touchX > 0 && touchY > 0 && mLastTouchX > 0 && mLastTouchY > 0) {
- applySpring(mLastTouchX - touchX, mLastTouchY - touchY);
+ if (touchX > 0 && touchY > 0 && mLastTouchX > 0 && mLastTouchY > 0
+ && mScaledMaskPath != null) {
+ mTranslateX.animateToPos(mLastTouchX - touchX);
+ mTranslateY.animateToPos(mLastTouchY - touchY);
}
mLastTouchX = touchX;
mLastTouchY = touchY;
@@ -642,6 +596,48 @@
return mInitialScale;
}
+ private static class SpringFloatValue {
+
+ private static final FloatPropertyCompat<SpringFloatValue> VALUE =
+ new FloatPropertyCompat<SpringFloatValue>("value") {
+ @Override
+ public float getValue(SpringFloatValue object) {
+ return object.mValue;
+ }
+
+ @Override
+ public void setValue(SpringFloatValue object, float value) {
+ object.mValue = value;
+ object.mView.invalidate();
+ }
+ };
+
+ // Following three values are fine tuned with motion ux designer
+ private final static int STIFFNESS = 4000;
+ private final static float DAMPENING_RATIO = 1f;
+ private final static int PARALLAX_MAX_IN_DP = 8;
+
+ private final View mView;
+ private final SpringAnimation mSpring;
+ private final float mDelta;
+
+ private float mValue;
+
+ public SpringFloatValue(View view, float range) {
+ mView = view;
+ mSpring = new SpringAnimation(this, VALUE, 0)
+ .setMinValue(-range).setMaxValue(range)
+ .setSpring(new SpringForce(0)
+ .setDampingRatio(DAMPENING_RATIO)
+ .setStiffness(STIFFNESS));
+ mDelta = view.getResources().getDisplayMetrics().density * PARALLAX_MAX_IN_DP;
+ }
+
+ public void animateToPos(float value) {
+ mSpring.animateToFinalPosition(Utilities.boundToRange(value, -mDelta, mDelta));
+ }
+ }
+
private static class FixedSizeEmptyDrawable extends ColorDrawable {
private final int mSize;
diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java
index 69705d5..d7f5c2b 100644
--- a/src/com/android/launcher3/folder/FolderAnimationManager.java
+++ b/src/com/android/launcher3/folder/FolderAnimationManager.java
@@ -120,6 +120,7 @@
final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) mFolder.getLayoutParams();
FolderIcon.PreviewLayoutRule rule = mFolderIcon.getLayoutRule();
final List<BubbleTextView> itemsInPreview = mFolderIcon.getPreviewItems();
+ BubbleTextView btv = itemsInPreview.get(0);
// Match position of the FolderIcon
final Rect folderIconPos = new Rect();
@@ -131,7 +132,7 @@
// Match size/scale of icons in the preview
float previewScale = rule.scaleForItem(0, itemsInPreview.size());
float previewSize = rule.getIconSize() * previewScale;
- float initialScale = previewSize / itemsInPreview.get(0).getIconSize()
+ float initialScale = previewSize / btv.getIconSize()
* scaleRelativeToDragLayer;
final float finalScale = 1f;
float scale = mIsOpening ? initialScale : finalScale;
@@ -148,10 +149,12 @@
previewItemOffsetX = (int) (lp.width * initialScale - initialSize - previewItemOffsetX);
}
+ // Note that we do not include btv.getPaddingLeft() in the calculation, since it is
+ // handled in addPreviewItemAnimators as part of iconOffsetX.
final int paddingOffsetX = (int) ((mFolder.getPaddingLeft() + mContent.getPaddingLeft())
* initialScale);
- final int paddingOffsetY = (int) ((mFolder.getPaddingTop() + mContent.getPaddingTop())
- * initialScale);
+ final int paddingOffsetY = (int) ((mFolder.getPaddingTop() + mContent.getPaddingTop()
+ + btv.getPaddingTop()) * initialScale);
int initialX = folderIconPos.left + mPreviewBackground.getOffsetX() - paddingOffsetX
- previewItemOffsetX;
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java
index 72a083b..ebb69c4 100644
--- a/src/com/android/launcher3/logging/LoggerUtils.java
+++ b/src/com/android/launcher3/logging/LoggerUtils.java
@@ -25,6 +25,7 @@
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.UninstallDropTarget;
+import com.android.launcher3.userevent.nano.LauncherLogExtensions.TargetExtension;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
@@ -159,6 +160,13 @@
return t;
}
+ public static Target newTarget(int targetType, TargetExtension extension) {
+ Target t = new Target();
+ t.type = targetType;
+ t.extension = extension;
+ return t;
+ }
+
public static Target newTarget(int targetType) {
Target t = new Target();
t.type = targetType;