summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java16
-rw-r--r--src/com/android/launcher2/Launcher.java3
-rw-r--r--src/com/android/launcher2/LauncherModel.java11
-rw-r--r--src/com/android/launcher2/PagedView.java14
-rw-r--r--src/com/android/launcher2/SearchDropTargetBar.java19
-rw-r--r--src/com/android/launcher2/Workspace.java101
6 files changed, 114 insertions, 50 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index d8ff73c04..f5142bfa6 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -31,11 +31,11 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.graphics.Bitmap.Config;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Process;
@@ -47,6 +47,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
+import android.view.animation.DecelerateInterpolator;
+import android.view.animation.Interpolator;
import android.widget.GridLayout;
import android.widget.ImageView;
import android.widget.Toast;
@@ -218,6 +220,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private static float TRANSITION_MAX_ROTATION = 22;
private static final boolean PERFORM_OVERSCROLL_ROTATION = true;
private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
+ private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
// Previews & outlines
ArrayList<AppsCustomizeAsyncTask> mRunningTasks;
@@ -262,7 +265,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// (top + bottom)
mWidgetPreviewIconPaddedDimension =
(int) (mAppIconSize * (1 + (2 * sWidgetPreviewIconPaddingPercentage)));
- mFadeInAdjacentScreens = LauncherApplication.isScreenLarge();
+ mFadeInAdjacentScreens = false;
}
@Override
@@ -1218,8 +1221,15 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
interpolatedProgress * TRANSITION_SCALE_FACTOR;
float translationX = Math.min(0, scrollProgress) * v.getMeasuredWidth();
- float alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(
+ float alpha;
+
+ if (!LauncherApplication.isScreenLarge() || scrollProgress < 0) {
+ alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(
1 - Math.abs(scrollProgress)) : 1.0f;
+ } else {
+ // On large screens we need to fade the page as it nears its leftmost position
+ alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
+ }
v.setCameraDistance(mDensity * CAMERA_DISTANCE);
int pageWidth = v.getMeasuredWidth();
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 02f19ac09..6d2ec3a05 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1322,11 +1322,12 @@ public final class Launcher extends Activity
appSearchData = new Bundle();
appSearchData.putString(Search.SOURCE, "launcher-search");
}
+ Rect sourceBounds = mSearchDropTargetBar.getSearchBarBounds();
final SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchManager.startSearch(initialQuery, selectInitialQuery, getComponentName(),
- appSearchData, globalSearch);
+ appSearchData, globalSearch, sourceBounds);
}
@Override
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 3ee273214..c06bc0c31 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -121,7 +121,7 @@ public class LauncherModel extends BroadcastReceiver {
private static int mCellCountX;
private static int mCellCountY;
- protected Configuration mPreviousConfig;
+ protected int mPreviousConfigMcc;
public interface Callbacks {
public boolean setLoadOnResume();
@@ -152,7 +152,8 @@ public class LauncherModel extends BroadcastReceiver {
final Resources res = app.getResources();
mAllAppsLoadDelay = res.getInteger(R.integer.config_allAppsBatchLoadDelay);
mBatchSize = res.getInteger(R.integer.config_allAppsBatchSize);
- mPreviousConfig = res.getConfiguration();
+ Configuration config = res.getConfiguration();
+ mPreviousConfigMcc = config.mcc;
}
public Bitmap getFallbackIcon() {
@@ -623,13 +624,13 @@ public class LauncherModel extends BroadcastReceiver {
// and we would need to clear out the labels in all apps/workspace. Same handling as
// above for ACTION_LOCALE_CHANGED
Configuration currentConfig = context.getResources().getConfiguration();
- if((mPreviousConfig.diff(currentConfig) & ActivityInfo.CONFIG_MCC) != 0){
+ if (mPreviousConfigMcc != currentConfig.mcc) {
Log.d(TAG, "Reload apps on config change. curr_mcc:"
- + currentConfig.mcc + " prevmcc:" + mPreviousConfig.mcc);
+ + currentConfig.mcc + " prevmcc:" + mPreviousConfigMcc);
forceReload();
}
// Update previousConfig
- mPreviousConfig = currentConfig;
+ mPreviousConfigMcc = currentConfig.mcc;
} else if (SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action) ||
SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED.equals(action)) {
if (mCallbacks != null) {
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 7be19bf23..3d2deb8f1 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -102,6 +102,7 @@ public abstract class PagedView extends ViewGroup {
protected final static float ALPHA_QUANTIZE_LEVEL = 0.0001f;
protected int mTouchState = TOUCH_STATE_REST;
+ protected boolean mForceScreenScrolled = false;
protected OnLongClickListener mLongClickListener;
@@ -672,14 +673,25 @@ public abstract class PagedView extends ViewGroup {
}
@Override
+ protected void onViewAdded(View child) {
+ super.onViewAdded(child);
+
+ // This ensures that when children are added, they get the correct transforms / alphas
+ // in accordance with any scroll effects.
+ mForceScreenScrolled = true;
+ invalidate();
+ }
+
+ @Override
protected void dispatchDraw(Canvas canvas) {
int halfScreenSize = getMeasuredWidth() / 2;
int screenCenter = mScrollX + halfScreenSize;
- if (screenCenter != mLastScreenCenter) {
+ if (screenCenter != mLastScreenCenter || mForceScreenScrolled) {
screenScrolled(screenCenter);
updateAdjacentPagesAlpha();
mLastScreenCenter = screenCenter;
+ mForceScreenScrolled = false;
}
// Find out which screens are visible; as an optimization we only call draw on them
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index b4a9fc9c0..e90406e48 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
+import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
@@ -229,4 +230,22 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
}
}
}
+
+ public Rect getSearchBarBounds() {
+ if (mQSBSearchBar != null) {
+ final float appScale = mQSBSearchBar.getContext().getResources()
+ .getCompatibilityInfo().applicationScale;
+ final int[] pos = new int[2];
+ mQSBSearchBar.getLocationOnScreen(pos);
+
+ final Rect rect = new Rect();
+ rect.left = (int) (pos[0] * appScale + 0.5f);
+ rect.top = (int) (pos[1] * appScale + 0.5f);
+ rect.right = (int) ((pos[0] + mQSBSearchBar.getWidth()) * appScale + 0.5f);
+ rect.bottom = (int) ((pos[1] + mQSBSearchBar.getHeight()) * appScale + 0.5f);
+ return rect;
+ } else {
+ return null;
+ }
+ }
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index e4f1fe8e0..bf8907865 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1529,27 +1529,34 @@ public class Workspace extends SmoothPagedView
return;
}
- if (mAnimator != null) {
- mAnimator.cancel();
- }
+ // Initialize animation arrays for the first time if necessary
+ initAnimationArrays();
+
+ // Cancel any running transition animations
+ if (mAnimator != null) mAnimator.cancel();
+ mAnimator = new AnimatorSet();
// Stop any scrolling, move to the current page right away
setCurrentPage((mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage);
- float finalScaleFactor = 1.0f;
- float finalBackgroundAlpha = (state == State.SPRING_LOADED) ? 1.0f : 0f;
- boolean normalState = false;
- State oldState = mState;
+ final State oldState = mState;
+ final boolean oldStateIsNormal = (oldState == State.NORMAL);
+ final boolean oldStateIsSpringLoaded = (oldState == State.SPRING_LOADED);
+ final boolean oldStateIsSmall = (oldState == State.SMALL);
mState = state;
+ final boolean stateIsNormal = (state == State.NORMAL);
+ final boolean stateIsSpringLoaded = (state == State.SPRING_LOADED);
+ final boolean stateIsSmall = (state == State.SMALL);
+ float finalScaleFactor = 1.0f;
+ float finalBackgroundAlpha = stateIsSpringLoaded ? 1.0f : 0f;
+ float translationX = 0;
+ float translationY = 0;
boolean zoomIn = true;
if (state != State.NORMAL) {
- finalScaleFactor = mSpringLoadedShrinkFactor - (state == State.SMALL ? 0.1f : 0);
- if (oldState == State.NORMAL && state == State.SMALL) {
+ finalScaleFactor = mSpringLoadedShrinkFactor - (stateIsSmall ? 0.1f : 0);
+ if (oldStateIsNormal && stateIsSmall) {
zoomIn = false;
- if (animated) {
- hideScrollingIndicator(true);
- }
setLayoutScale(finalScaleFactor);
updateChildrenLayersEnabled();
} else {
@@ -1558,34 +1565,34 @@ public class Workspace extends SmoothPagedView
}
} else {
setLayoutScale(1.0f);
- normalState = true;
}
- float translationX = 0;
- float translationY = 0;
-
- mAnimator = new AnimatorSet();
-
- final int screenCount = getChildCount();
- initAnimationArrays();
-
final int duration = zoomIn ?
getResources().getInteger(R.integer.config_workspaceUnshrinkTime) :
getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime);
- for (int i = 0; i < screenCount; i++) {
- final CellLayout cl = (CellLayout)getChildAt(i);
- float finalAlphaValue = 0f;
+ for (int i = 0; i < getChildCount(); i++) {
+ final CellLayout cl = (CellLayout) getChildAt(i);
float rotation = 0f;
-
- // Set the final alpha depending on whether we are fading side pages. On phone ui,
- // we don't do any of the rotation, or the fading alpha in portrait. See the
- // ctor and screenScrolled().
- if (mFadeInAdjacentScreens && normalState) {
- finalAlphaValue = (i == mCurrentPage) ? 1f : 0f;
- } else {
- finalAlphaValue = 1f;
+ float initialAlpha = cl.getAlpha();
+ float finalAlphaMultiplierValue = 1f;
+ float finalAlpha = (!mFadeInAdjacentScreens || stateIsSpringLoaded ||
+ (i == mCurrentPage)) ? 1f : 0f;
+
+ // Determine the pages alpha during the state transition
+ if ((oldStateIsSmall && stateIsNormal) ||
+ (oldStateIsNormal && stateIsSmall)) {
+ // To/from workspace - only show the current page unless the transition is not
+ // animated and the animation end callback below doesn't run
+ if (i == mCurrentPage || !animated) {
+ finalAlpha = 1f;
+ finalAlphaMultiplierValue = 0f;
+ } else {
+ initialAlpha = 0f;
+ finalAlpha = 0f;
+ }
}
+ // Update the rotation of the screen (don't apply rotation on Phone UI)
if (LauncherApplication.isScreenLarge()) {
if (i < mCurrentPage) {
rotation = WORKSPACE_ROTATION;
@@ -1594,7 +1601,6 @@ public class Workspace extends SmoothPagedView
}
}
- float finalAlphaMultiplierValue = 1f;
// If the screen is not xlarge, then don't rotate the CellLayouts
// NOTE: If we don't update the side pages alpha, then we should not hide the side
// pages. see unshrink().
@@ -1602,8 +1608,8 @@ public class Workspace extends SmoothPagedView
translationX = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
}
- mOldAlphas[i] = cl.getAlpha();
- mNewAlphas[i] = finalAlphaValue;
+ mOldAlphas[i] = initialAlpha;
+ mNewAlphas[i] = finalAlpha;
if (animated) {
mOldTranslationXs[i] = cl.getTranslationX();
mOldTranslationYs[i] = cl.getTranslationY();
@@ -1625,9 +1631,9 @@ public class Workspace extends SmoothPagedView
cl.setTranslationY(translationY);
cl.setScaleX(finalScaleFactor);
cl.setScaleY(finalScaleFactor);
- cl.setBackgroundAlpha(0.0f);
+ cl.setBackgroundAlpha(finalBackgroundAlpha);
cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue);
- cl.setAlpha(finalAlphaValue);
+ cl.setAlpha(finalAlpha);
cl.setRotationY(rotation);
mChangeStateAnimationListener.onAnimationEnd(null);
}
@@ -1641,6 +1647,21 @@ public class Workspace extends SmoothPagedView
animWithInterpolator.setInterpolator(mZoomInInterpolator);
}
+ animWithInterpolator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(android.animation.Animator animation) {
+ // The above code to determine initialAlpha and finalAlpha will ensure that only
+ // the current page is visible during (and subsequently, after) the transition
+ // animation. If fade adjacent pages is disabled, then re-enable the page
+ // visibility after the transition animation.
+ if (!mFadeInAdjacentScreens && stateIsNormal && oldStateIsSmall) {
+ for (int i = 0; i < getChildCount(); i++) {
+ final CellLayout cl = (CellLayout) getChildAt(i);
+ cl.setAlpha(1f);
+ }
+ }
+ }
+ });
animWithInterpolator.addUpdateListener(new LauncherAnimatorUpdateListener() {
public void onAnimationUpdate(float a, float b) {
mTransitionProgress = b;
@@ -1649,7 +1670,7 @@ public class Workspace extends SmoothPagedView
return;
}
invalidate();
- for (int i = 0; i < screenCount; i++) {
+ for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.fastInvalidate();
cl.setFastTranslationX(a * mOldTranslationXs[i] + b * mNewTranslationXs[i]);
@@ -1674,7 +1695,7 @@ public class Workspace extends SmoothPagedView
// an optimization, but not required
return;
}
- for (int i = 0; i < screenCount; i++) {
+ for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.setFastRotationY(a * mOldRotationYs[i] + b * mNewRotationYs[i]);
}
@@ -1689,7 +1710,7 @@ public class Workspace extends SmoothPagedView
mAnimator.start();
}
- if (state == State.SPRING_LOADED) {
+ if (stateIsSpringLoaded) {
// Right now we're covered by Apps Customize
// Show the background gradient immediately, so the gradient will
// be showing once AppsCustomize disappears