Merge "NPE fix"
diff --git a/res/drawable-xlarge-nodpi/city.jpg b/res/drawable-xlarge-nodpi/city.jpg
index 57a3223..72beb6b 100644
--- a/res/drawable-xlarge-nodpi/city.jpg
+++ b/res/drawable-xlarge-nodpi/city.jpg
Binary files differ
diff --git a/res/drawable-xlarge-nodpi/glowy_hex.jpg b/res/drawable-xlarge-nodpi/glowy_hex.jpg
index 8729fe1..7d7cdbb 100644
--- a/res/drawable-xlarge-nodpi/glowy_hex.jpg
+++ b/res/drawable-xlarge-nodpi/glowy_hex.jpg
Binary files differ
diff --git a/res/drawable-xlarge-nodpi/glowy_hex_small.jpg b/res/drawable-xlarge-nodpi/glowy_hex_small.jpg
index 6ac58bd..bde365d 100644
--- a/res/drawable-xlarge-nodpi/glowy_hex_small.jpg
+++ b/res/drawable-xlarge-nodpi/glowy_hex_small.jpg
Binary files differ
diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml
index 957327e..590787f 100644
--- a/res/layout-xlarge-land/launcher.xml
+++ b/res/layout-xlarge-land/launcher.xml
@@ -113,7 +113,6 @@
android:paddingBottom="@dimen/toolbar_button_vertical_padding"
android:background="@drawable/button_bg"
- android:onClick="onClickConfigureButton"
android:focusable="true"
android:clickable="true" />
<ImageView
@@ -125,7 +124,6 @@
android:paddingTop="@dimen/toolbar_button_vertical_padding"
android:paddingBottom="@dimen/toolbar_button_vertical_padding"
- android:onClick="onClickAllAppsButton"
android:focusable="false"
android:clickable="true" />
<TextView
@@ -151,7 +149,6 @@
android:shadowDy="0.0"
android:shadowRadius="2.5"
- android:onClick="onClickAllAppsButton"
android:focusable="true"
android:clickable="true" />
<ImageView
diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml
index a8087f4..4c83fda 100644
--- a/res/layout-xlarge-port/launcher.xml
+++ b/res/layout-xlarge-port/launcher.xml
@@ -113,7 +113,6 @@
android:paddingBottom="@dimen/toolbar_button_vertical_padding"
android:background="@drawable/button_bg"
- android:onClick="onClickConfigureButton"
android:focusable="true"
android:clickable="true" />
<ImageView
@@ -125,7 +124,6 @@
android:paddingTop="@dimen/toolbar_button_vertical_padding"
android:paddingBottom="@dimen/toolbar_button_vertical_padding"
- android:onClick="onClickAllAppsButton"
android:focusable="false"
android:clickable="true" />
<TextView
@@ -151,7 +149,6 @@
android:shadowDy="0.0"
android:shadowRadius="2.5"
- android:onClick="onClickAllAppsButton"
android:focusable="true"
android:clickable="true" />
<ImageView
diff --git a/res/values-xlarge/config.xml b/res/values-xlarge/config.xml
index d5da593..1c9d5a6 100644
--- a/res/values-xlarge/config.xml
+++ b/res/values-xlarge/config.xml
@@ -9,7 +9,7 @@
<!-- Duration in milliseconds of the all apps / configuration zoom-in animation. -->
<!-- NB: This should be less than the workspaceShrinkTime as they happen together. -->
- <integer name="config_allAppsZoomInTime">900</integer>
+ <integer name="config_allAppsZoomInTime">1450</integer>
<!-- Duration in milliseconds of the transition between tabs in the all apps/customize
tray -->
@@ -17,10 +17,10 @@
<!-- Duration in milliseconds of the all apps zoom-out animation -->
<!-- NB: This should be less than the workspaceUnshrinkTime as they happen together. -->
- <integer name="config_allAppsZoomOutTime">1400</integer>
+ <integer name="config_allAppsZoomOutTime">1200</integer>
<!-- Scaling factor used in the all apps zooming animations -->
- <integer name="config_allAppsZoomScaleFactor">10</integer>
+ <integer name="config_allAppsZoomScaleFactor">20</integer>
<!-- Duration in milliseconds of the all apps / configuration zoom-in animation. -->
<!-- NB: This should be less than the workspaceShrinkTime as they happen together. -->
@@ -36,16 +36,16 @@
<!-- Duration in milliseconds of the animations between all apps, customize, & home.
NOTE: If these are changed, the toolbar animation times below should also be. -->
<integer name="config_allAppsCameraPanTime">700</integer>
- <integer name="config_allAppsFadeOutTime">400</integer>
+ <integer name="config_allAppsFadeOutTime">500</integer>
<integer name="config_customizeWorkspaceShrinkTime">800</integer>
- <integer name="config_allAppsWorkspaceShrinkTime">950</integer>
- <integer name="config_workspaceUnshrinkTime">450</integer>
+ <integer name="config_allAppsWorkspaceShrinkTime">1450</integer>
+ <integer name="config_workspaceUnshrinkTime">650</integer>
<!-- Duration in milliseconds toolbar fade in and fade out animations.
NOTE: Fade in and fade out time should together be less the transition
animations between all apps, customize, & the workspace. -->
- <integer name="config_toolbarButtonFadeInTime">100</integer>
- <integer name="config_toolbarButtonFadeOutTime">100</integer>
+ <integer name="config_toolbarButtonFadeInTime">350</integer>
+ <integer name="config_toolbarButtonFadeOutTime">200</integer>
<!-- When dragging items on the workspace, how much bigger (in pixels) the dragged view
should be, as compared to the original view. If 0, it will not be scaled at all.
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index a0f1f6e..daa5d64 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -425,6 +425,7 @@
// add any necessary pages
for (int i = curNumPages; i < numPages; ++i) {
PagedViewCellLayout layout = new PagedViewCellLayout(getContext());
+ layout.enableHardwareLayers();
layout.setCellCount(mCellCountX, mCellCountY);
layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index d02f597..ad01fac 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -283,7 +283,7 @@
super.draw(canvas);
canvas.save(Canvas.CLIP_SAVE_FLAG);
canvas.clipRect(mScrollX, mScrollY + getExtendedPaddingTop(), mScrollX + getWidth(),
- mScrollY + getHeight(), Region.Op.REPLACE);
+ mScrollY + getHeight(), Region.Op.INTERSECT);
getPaint().setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR);
super.draw(canvas);
canvas.restore();
diff --git a/src/com/android/launcher2/CachedTextView.java b/src/com/android/launcher2/CachedTextView.java
index eaa6636..403d856 100644
--- a/src/com/android/launcher2/CachedTextView.java
+++ b/src/com/android/launcher2/CachedTextView.java
@@ -47,6 +47,7 @@
private float mPaddingH = 0;
private float mPaddingV = 0;
private CharSequence mText;
+ private boolean mEnabled = true;
public CachedTextView(Context context) {
super(context);
@@ -73,6 +74,10 @@
return 0;
}
+ public void disableCache() {
+ mEnabled = false;
+ }
+
public void setText(CharSequence text, BufferType type) {
super.setText(text, type);
mIsTextCacheDirty = true;
@@ -138,7 +143,7 @@
}
public void draw(Canvas canvas) {
- if (mIsTextCacheDirty && !mIsBuildingCache) {
+ if (mEnabled && mIsTextCacheDirty && !mIsBuildingCache) {
buildAndUpdateCache();
mIsTextCacheDirty = false;
}
diff --git a/src/com/android/launcher2/CellLayoutChildren.java b/src/com/android/launcher2/CellLayoutChildren.java
index 76a6900..0d0a339 100644
--- a/src/com/android/launcher2/CellLayoutChildren.java
+++ b/src/com/android/launcher2/CellLayoutChildren.java
@@ -45,6 +45,9 @@
super(context);
mWallpaperManager = WallpaperManager.getInstance(context);
setLayerType(LAYER_TYPE_HARDWARE, null);
+
+ // Disable multitouch for the workspace
+ setMotionEventSplittingEnabled(false);
}
public void setCellDimensions(int cellWidth, int cellHeight,
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index b418a79..a9dd7e3 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -40,6 +40,9 @@
*/
public DragLayer(Context context, AttributeSet attrs) {
super(context, attrs);
+
+ // Disable multitouch across the workspace/all apps/customize tray
+ setMotionEventSplittingEnabled(false);
}
public void setDragController(DragController controller) {
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 745ae2e..9a939e4 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -88,6 +88,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.DecelerateInterpolator;
@@ -217,6 +218,11 @@
private TabHost mHomeCustomizationDrawer;
private boolean mAutoAdvanceRunning = false;
+ private View mButtonCluster;
+ private View mAllAppsButton;
+ private View mDivider;
+ private View mConfigureButton;
+
private AllAppsPagedView mAllAppsPagedView = null;
private CustomizePagedView mCustomizePagedView = null;
@@ -1043,6 +1049,36 @@
if (allAppsDeleteZone != null) {
dragController.addDropTarget(allAppsDeleteZone);
}
+ mButtonCluster = findViewById(R.id.all_apps_button_cluster);
+
+ mAllAppsButton = findViewById(R.id.all_apps_button);
+ mDivider = findViewById(R.id.divider);
+ mConfigureButton = findViewById(R.id.configure_button);
+
+ // We had previously set these click handlers in XML, but the first time we launched
+ // Configure or All Apps we had an extra 50ms of delay while the java reflection methods
+ // found the right handler. Setting the handlers directly here eliminates that cost.
+ if (mConfigureButton != null) {
+ mConfigureButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ onClickConfigureButton(v);
+ }
+ });
+ }
+ if (mDivider != null) {
+ mDivider.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ onClickAllAppsButton(v);
+ }
+ });
+ }
+ if (mAllAppsButton != null) {
+ mAllAppsButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ onClickAllAppsButton(v);
+ }
+ });
+ }
}
@SuppressWarnings({"UnusedDeclaration"})
@@ -2539,7 +2575,6 @@
}
private void showToolbarButton(View button) {
- button.setAlpha(1.0f);
button.setVisibility(View.VISIBLE);
button.setFocusable(true);
button.setClickable(true);
@@ -2570,8 +2605,13 @@
getResources().getInteger(R.integer.config_toolbarButtonFadeOutTime);
if (seq != null) {
- Animator anim = ObjectAnimator.ofFloat(view, "alpha", show ? 1.0f : 0.0f);
+ ValueAnimator anim = ValueAnimator.ofFloat(view.getAlpha(), show ? 1.0f : 0.0f);
anim.setDuration(duration);
+ anim.addUpdateListener(new AnimatorUpdateListener() {
+ public void onAnimationUpdate(ValueAnimator animation) {
+ view.setAlpha((Float) animation.getAnimatedValue());
+ }
+ });
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
@@ -2586,6 +2626,7 @@
} else {
if (showing) {
showToolbarButton(view);
+ view.setAlpha(1f);
} else {
hideToolbarButton(view);
}
@@ -2601,26 +2642,21 @@
* @param hideSeq AnimatorSet in which to put "hide" animations, or null.
*/
private void hideAndShowToolbarButtons(State newState, AnimatorSet showSeq, AnimatorSet hideSeq) {
- final View buttonCluster = findViewById(R.id.all_apps_button_cluster);
-
- final View allAppsButton = findViewById(R.id.all_apps_button);
- final View divider = findViewById(R.id.divider);
- final View configureButton = findViewById(R.id.configure_button);
-
switch (newState) {
case WORKSPACE:
- hideOrShowToolbarButton(true, buttonCluster, showSeq);
- mDeleteZone.setOverlappingViews(new View[] { allAppsButton, divider, configureButton });
+ hideOrShowToolbarButton(true, mButtonCluster, showSeq);
+ mDeleteZone.setOverlappingViews(
+ new View[] { mAllAppsButton, mDivider, mConfigureButton });
mDeleteZone.setDragAndDropEnabled(true);
mDeleteZone.setText(getResources().getString(R.string.delete_zone_label_workspace));
break;
case ALL_APPS:
- hideOrShowToolbarButton(false, buttonCluster, hideSeq);
+ hideOrShowToolbarButton(false, mButtonCluster, hideSeq);
mDeleteZone.setDragAndDropEnabled(false);
mDeleteZone.setText(getResources().getString(R.string.delete_zone_label_all_apps));
break;
case CUSTOMIZE:
- hideOrShowToolbarButton(false, buttonCluster, hideSeq);
+ hideOrShowToolbarButton(false, mButtonCluster, hideSeq);
mDeleteZone.setDragAndDropEnabled(false);
break;
}
@@ -2640,7 +2676,7 @@
// visible. Modifying initialHeightFactor changes how much of the view is
// initially showing, and hence the perceived angle from which the view enters.
if (state == State.ALL_APPS) {
- final float initialHeightFactor = 0.165f;
+ final float initialHeightFactor = 0.175f;
view.setPivotY((1 - initialHeightFactor) * height);
} else {
final float initialHeightFactor = 0.2f;
@@ -2677,9 +2713,6 @@
}
if (animated) {
- final float oldScaleX = toView.getScaleX();
- final float oldScaleY = toView.getScaleY();
-
ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
scaleAnim.setInterpolator(new Workspace.ZoomOutInterpolator());
scaleAnim.addUpdateListener(new AnimatorUpdateListener() {
@@ -2687,15 +2720,15 @@
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
((View) toView.getParent()).fastInvalidate();
- toView.setFastScaleX(a * oldScaleX + b * 1f);
- toView.setFastScaleY(a * oldScaleY + b * 1f);
+ toView.setFastScaleX(a * scale + b * 1f);
+ toView.setFastScaleY(a * scale + b * 1f);
}
});
if (toAllApps) {
toView.setAlpha(0f);
ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
- alphaAnim.setInterpolator(new DecelerateInterpolator(1.0f));
+ alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f));
alphaAnim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
final float b = (Float) animation.getAnimatedValue();
@@ -2812,7 +2845,7 @@
});
ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f);
alphaAnim.setDuration(res.getInteger(R.integer.config_allAppsFadeOutTime));
- alphaAnim.setInterpolator(new DecelerateInterpolator(2.0f));
+ alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f));
alphaAnim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
final float b = (Float) animation.getAnimatedValue();
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 96b0551..e4cdd59 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -544,9 +544,9 @@
alpha = 1.0f;
}
- if (Float.compare(alpha, layout.getAlpha()) != 0) {
+ //if (Float.compare(alpha, layout.getAlpha()) != 0) {
layout.setAlpha(alpha);
- }
+ //}
}
mDirtyPageAlpha = false;
}
@@ -596,7 +596,21 @@
canvas.clipRect(mScrollX, mScrollY, mScrollX + mRight - mLeft,
mScrollY + mBottom - mTop);
+ for (int i = 0; i < pageCount; i++) {
+ View child = getChildAt(i);
+ if (child != null && child instanceof PagedViewCellLayout) {
+ boolean willBeDrawn = i >= leftScreen && i <= rightScreen;
+ if (!willBeDrawn) {
+ ((PagedViewCellLayout)child).destroyHardwareLayers();
+ }
+ }
+ }
+
for (int i = leftScreen; i <= rightScreen; i++) {
+ View child = getChildAt(i);
+ if (child != null && child instanceof PagedViewCellLayout) {
+ ((PagedViewCellLayout)child).createHardwareLayers();
+ }
drawChild(canvas, getChildAt(i), drawingTime);
}
canvas.restore();
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index 6d1fb55..d64f3c9 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -40,6 +40,7 @@
private static int sDefaultCellDimensions = 96;
protected PagedViewCellLayoutChildren mChildren;
private PagedViewCellLayoutChildren mHolographicChildren;
+ private boolean mUseHardwareLayers = false;
public PagedViewCellLayout(Context context) {
this(context, null);
@@ -73,12 +74,29 @@
addView(mHolographicChildren);
}
+ public void enableHardwareLayers() {
+ mUseHardwareLayers = true;
+ }
+
@Override
public void setAlpha(float alpha) {
mChildren.setAlpha(alpha);
mHolographicChildren.setAlpha(1.0f - alpha);
}
+ void destroyHardwareLayers() {
+ if (mUseHardwareLayers) {
+ mChildren.destroyHardwareLayer();
+ mHolographicChildren.destroyHardwareLayer();
+ }
+ }
+ void createHardwareLayers() {
+ if (mUseHardwareLayers) {
+ mChildren.createHardwareLayer();
+ mHolographicChildren.createHardwareLayer();
+ }
+ }
+
@Override
public void cancelLongPress() {
super.cancelLongPress();
@@ -109,6 +127,9 @@
if (child instanceof PagedViewIcon) {
PagedViewIcon pagedViewIcon = (PagedViewIcon) child;
+ if (mUseHardwareLayers) {
+ pagedViewIcon.disableCache();
+ }
mHolographicChildren.addView(pagedViewIcon.getHolographicOutlineView(), index, lp);
}
return true;
diff --git a/src/com/android/launcher2/PagedViewCellLayoutChildren.java b/src/com/android/launcher2/PagedViewCellLayoutChildren.java
index 1359a43..27da02a 100644
--- a/src/com/android/launcher2/PagedViewCellLayoutChildren.java
+++ b/src/com/android/launcher2/PagedViewCellLayoutChildren.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.graphics.Rect;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -39,7 +38,6 @@
public PagedViewCellLayoutChildren(Context context) {
super(context);
- setLayerType(LAYER_TYPE_HARDWARE, null);
}
@Override
@@ -140,6 +138,17 @@
}
}
+ void destroyHardwareLayer() {
+ if (getLayerType() == LAYER_TYPE_HARDWARE) {
+ setLayerType(LAYER_TYPE_NONE, null);
+ }
+ }
+ void createHardwareLayer() {
+ if (getLayerType() == LAYER_TYPE_NONE) {
+ setLayerType(LAYER_TYPE_HARDWARE, null);
+ }
+ }
+
public void enableCenteredContent(boolean enabled) {
mCenterContent = enabled;
}
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index ca67d2f..1366619 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -40,7 +40,7 @@
* An icon on a PagedView, specifically for items in the launcher's paged view (with compound
* drawables on the top).
*/
-public class PagedViewIcon extends TextView implements Checkable {
+public class PagedViewIcon extends CachedTextView implements Checkable {
private static final String TAG = "PagedViewIcon";
// holographic outline
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 42a746a..2ea4931 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -108,8 +108,8 @@
private float mChildrenOutlineAlpha = 0;
// These properties refer to the background protection gradient used for AllApps and Customize
- private ObjectAnimator mBackgroundFadeInAnimation;
- private ObjectAnimator mBackgroundFadeOutAnimation;
+ private ValueAnimator mBackgroundFadeInAnimation;
+ private ValueAnimator mBackgroundFadeOutAnimation;
private Drawable mBackground;
private Drawable mCustomizeTrayBackground;
private boolean mDrawCustomizeTrayBackground;
@@ -224,6 +224,9 @@
final static float MAX_SWIPE_ANGLE = (float) Math.PI / 3;
final static float TOUCH_SLOP_DAMPING_FACTOR = 4;
+ int mSpringLoadedDropX;
+ int mSpringLoadedDropY;
+
/**
* Used to inflate the Workspace from XML.
*
@@ -568,33 +571,35 @@
@Override
protected void determineScrollingStart(MotionEvent ev) {
- float deltaX = Math.abs(ev.getX() - mXDown);
- float deltaY = Math.abs(ev.getY() - mYDown);
+ if (!mIsSmall && !mIsInUnshrinkAnimation) {
+ float deltaX = Math.abs(ev.getX() - mXDown);
+ float deltaY = Math.abs(ev.getY() - mYDown);
- if (Float.compare(deltaX, 0f) == 0) return;
+ if (Float.compare(deltaX, 0f) == 0) return;
- float slope = deltaY / deltaX;
- float theta = (float) Math.atan(slope);
+ float slope = deltaY / deltaX;
+ float theta = (float) Math.atan(slope);
- if (deltaX > mTouchSlop || deltaY > mTouchSlop) {
- cancelCurrentPageLongPress();
- }
+ if (deltaX > mTouchSlop || deltaY > mTouchSlop) {
+ cancelCurrentPageLongPress();
+ }
- if (theta > MAX_SWIPE_ANGLE) {
- // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the workspace
- return;
- } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) {
- // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, we want to increase
- // the touch slop to make it harder to begin scrolling the workspace. This results
- // in vertically scrolling widgets to more easily. The higher the angle, the
- // more we increase touch slop.
- theta -= START_DAMPING_TOUCH_SLOP_ANGLE;
- float extraRatio = (float)
- Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE)));
- super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio);
- } else {
- // Below START_DAMPING_TOUCH_SLOP_ANGLE, we don't do anything special
- super.determineScrollingStart(ev);
+ if (theta > MAX_SWIPE_ANGLE) {
+ // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the workspace
+ return;
+ } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) {
+ // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, we want to
+ // increase the touch slop to make it harder to begin scrolling the workspace. This
+ // results in vertically scrolling widgets to more easily. The higher the angle, the
+ // more we increase touch slop.
+ theta -= START_DAMPING_TOUCH_SLOP_ANGLE;
+ float extraRatio = (float)
+ Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE)));
+ super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio);
+ } else {
+ // Below START_DAMPING_TOUCH_SLOP_ANGLE, we don't do anything special
+ super.determineScrollingStart(ev);
+ }
}
}
@@ -933,7 +938,12 @@
if (mBackground == null) return;
if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
- mBackgroundFadeInAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 1.0f);
+ mBackgroundFadeInAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), 1f);
+ mBackgroundFadeInAnimation.addUpdateListener(new AnimatorUpdateListener() {
+ public void onAnimationUpdate(ValueAnimator animation) {
+ setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue());
+ }
+ });
mBackgroundFadeInAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
mBackgroundFadeInAnimation.setDuration(BACKGROUND_FADE_IN_DURATION);
mBackgroundFadeInAnimation.start();
@@ -943,7 +953,12 @@
if (mBackground == null) return;
if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
- mBackgroundFadeOutAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 0.0f);
+ mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), 0f);
+ mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() {
+ public void onAnimationUpdate(ValueAnimator animation) {
+ setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue());
+ }
+ });
mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION);
mBackgroundFadeOutAnimation.start();
@@ -1314,6 +1329,14 @@
// we use this to shrink the workspace for the all apps view and the customize view
public void shrink(ShrinkState shrinkState, boolean animated) {
+ // In the launcher interaction model, we're never in the state where we're shrunken and
+ // visible in the bottom of the screen, and then want to fade to being invisible.
+ // After spring loaded mode ends, this method was getting called twice, the first time
+ // with BOTTOM_VISIBLE (what we want) and a second time with BOTTOM_INVISIBLE (not
+ // what we want). As a temporary solution, we just change the second call to BOTTOM_VISIBLE
+ if (mIsSmall && mShrinkState == ShrinkState.BOTTOM_VISIBLE) {
+ shrinkState = ShrinkState.BOTTOM_VISIBLE;
+ }
if (mFirstLayout) {
// (mFirstLayout == "first layout has not happened yet")
// if we get a call to shrink() as part of our initialization (for example, if
@@ -1433,7 +1456,7 @@
oldAlphas[i] = cl.getAlpha();
newAlphas[i] = finalAlpha;
- if (animated && !(oldAlphas[i] == 0f && newAlphas[i] == 0f)) {
+ if (animated) {
oldXs[i] = cl.getX();
oldYs[i] = cl.getY();
oldScaleXs[i] = cl.getScaleX();
@@ -1454,7 +1477,7 @@
cl.setBackgroundAlpha(finalAlpha);
cl.setAlpha(finalAlpha);
cl.setRotationY(rotation);
- if (!animated) mShrinkAnimationListener.onAnimationEnd(null);
+ mShrinkAnimationListener.onAnimationEnd(null);
}
// increment newX for the next screen
x += scaledPageWidth + extraScaledSpacing;
@@ -1512,7 +1535,6 @@
setVerticalWallpaperOffset(
a * oldVerticalWallpaperOffset + b * newVerticalWallpaperOffset);
for (int i = 0; i < screenCount; i++) {
- if (oldAlphas[i] == 0f && newAlphas[i] == 0f) continue;
final CellLayout cl = (CellLayout) getChildAt(i);
cl.fastInvalidate();
cl.setFastX(a * oldXs[i] + b * newXs[i]);
@@ -1580,7 +1602,7 @@
*/
static class ZoomOutInterpolator implements TimeInterpolator {
private final ZInterpolator zInterpolator = new ZInterpolator(0.2f);
- private final DecelerateInterpolator decelerate = new DecelerateInterpolator(1.5f);
+ private final DecelerateInterpolator decelerate = new DecelerateInterpolator(1.8f);
public float getInterpolation(float input) {
return decelerate.getInterpolation(zInterpolator.getInterpolation(input));
@@ -1622,6 +1644,9 @@
case BOTTOM_HIDDEN:
case BOTTOM_VISIBLE:
case SPRING_LOADED:
+ if (state != ShrinkState.TOP) {
+ cl.setIsDefaultDropTarget(false);
+ }
if (!isDragHappening) {
// even if a drag isn't happening, we don't want to show a screen as
// accepting drops if it doesn't have at least one free cell
@@ -1763,7 +1788,7 @@
oldAlphas[i] = cl.getAlpha();
newAlphas[i] = finalAlphaValue;
- if (animated && !(oldAlphas[i] == 0f && newAlphas[i] == 0f)) {
+ if (animated) {
oldTranslationXs[i] = cl.getTranslationX();
oldTranslationYs[i] = cl.getTranslationY();
oldScaleXs[i] = cl.getScaleX();
@@ -1788,7 +1813,7 @@
cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue);
cl.setAlpha(finalAlphaValue);
cl.setRotationY(rotation);
- if (!animated) mUnshrinkAnimationListener.onAnimationEnd(null);
+ mUnshrinkAnimationListener.onAnimationEnd(null);
}
}
Display display = mLauncher.getWindowManager().getDefaultDisplay();
@@ -1815,8 +1840,8 @@
case BOTTOM_VISIBLE:
// all apps
if (animated) {
- mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.49f : 0.46f);
- mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.49f : 0.46f);
+ mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.65f : 0.65f);
+ mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.65f : 0.65f);
mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
}
break;
@@ -1840,7 +1865,6 @@
setVerticalWallpaperOffset(
a * oldVerticalWallpaperOffset + b * newVerticalWallpaperOffset);
for (int i = 0; i < screenCount; i++) {
- if (oldAlphas[i] == 0f && newAlphas[i] == 0f) continue;
final CellLayout cl = (CellLayout) getChildAt(i);
cl.fastInvalidate();
cl.setFastTranslationX(
@@ -1867,7 +1891,6 @@
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
for (int i = 0; i < screenCount; i++) {
- if (oldAlphas[i] == 0f && newAlphas[i] == 0f) continue;
final CellLayout cl = (CellLayout) getChildAt(i);
cl.setFastRotationY(a * oldRotationYs[i] + b * newRotationYs[i]);
}
@@ -2180,11 +2203,13 @@
originY = (int)mTempOriginXY[1];
}
- // When you drag to a particular screen, make that the new current/default screen, so any
- // subsequent taps add items to that screen
- int dragTargetIndex = indexOfChild(mDragTargetLayout);
- if (mCurrentPage != dragTargetIndex && (mIsSmall || mIsInUnshrinkAnimation)) {
- scrollToNewPageWithoutMovingPages(dragTargetIndex);
+ // When you are in customization mode and drag to a particular screen, make that the
+ // new current/default screen, so any subsequent taps add items to that screen
+ if (!mLauncher.isAllAppsVisible()) {
+ int dragTargetIndex = indexOfChild(mDragTargetLayout);
+ if (mCurrentPage != dragTargetIndex && (mIsSmall || mIsInUnshrinkAnimation)) {
+ scrollToNewPageWithoutMovingPages(dragTargetIndex);
+ }
}
if (source != this) {
@@ -2666,6 +2691,8 @@
final View child = (mDragInfo == null) ? null : mDragInfo.cell;
float[] localOrigin = { originX, originY };
mapPointFromSelfToChild(mDragTargetLayout, localOrigin, null);
+ mSpringLoadedDropX = (int) localOrigin[0];
+ mSpringLoadedDropY = (int) localOrigin[1];
mDragTargetLayout.visualizeDropLocation(child, mDragOutline,
(int) localOrigin[0], (int) localOrigin[1], item.spanX, item.spanY);
}
@@ -2730,8 +2757,8 @@
// widgets/shortcuts/folders in a slightly different way
// Only set touchXY if you are supporting spring loaded adding of items
int[] touchXY = new int[2];
- touchXY[0] = x;
- touchXY[1] = y;
+ touchXY[0] = mSpringLoadedDropX;
+ touchXY[1] = mSpringLoadedDropY;
switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
mLauncher.addAppWidgetFromDrop((PendingAddWidgetInfo) info, screen, touchXY);
@@ -2772,7 +2799,12 @@
mTargetCell = new int[2];
if (x != -1 && y != -1) {
// when dragging and dropping, just find the closest free spot
- cellLayout.findNearestVacantArea(x, y, 1, 1, mTargetCell);
+
+ // When we get a drop in Spring Loaded mode, at this point we've already called
+ // onDragExit, which starts us shrinking again and screws up the transforms we
+ // need to get the right value. Instead, as a temporary solution, we've saved the
+ // proper point, mSpringLoadedDropX/Y, from the last onDragOver
+ cellLayout.findNearestVacantArea(mSpringLoadedDropX, mSpringLoadedDropY, 1, 1, mTargetCell);
} else {
cellLayout.findCellForSpan(mTargetCell, 1, 1);
}
diff --git a/src/com/android/launcher2/allapps.rs b/src/com/android/launcher2/allapps.rs
index bebc04d..4ea1aee 100644
--- a/src/com/android/launcher2/allapps.rs
+++ b/src/com/android/launcher2/allapps.rs
@@ -298,7 +298,7 @@
vpConstants->ImgSize.y = rsAllocationGetDimY(gSelectedIconTexture);
vpConstants->Position.y = y - (rsAllocationGetDimY(gSelectedIconTexture)
- rsAllocationGetDimY(gIcons[iconNum])) * 0.5f;
- rsAllocationMarkDirty(g_VPConstAlloc);
+ rsgAllocationSyncAll(g_VPConstAlloc);
rsgDrawMesh(gSMCell);
}
@@ -306,7 +306,7 @@
vpConstants->ImgSize.x = rsAllocationGetDimX(gIcons[iconNum]);
vpConstants->ImgSize.y = rsAllocationGetDimY(gIcons[iconNum]);
vpConstants->Position.y = y - 0.2f;
- rsAllocationMarkDirty(g_VPConstAlloc);
+ rsgAllocationSyncAll(g_VPConstAlloc);
rsgBindTexture(gPFTexMip, 0, gIcons[iconNum]);
rsgDrawMesh(gSMCell);
@@ -314,7 +314,7 @@
vpConstants->ImgSize.x = rsAllocationGetDimX(gLabels[iconNum]);
vpConstants->ImgSize.y = rsAllocationGetDimY(gLabels[iconNum]);
vpConstants->Position.y = y - 64.f - 0.2f;
- rsAllocationMarkDirty(g_VPConstAlloc);
+ rsgAllocationSyncAll(g_VPConstAlloc);
rsgBindTexture(gPFTexMipAlpha, 0, gLabels[iconNum]);
rsgDrawMesh(gSMCell);
}