summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-07-27 17:46:20 -0700
committerWinson Chung <winsonc@google.com>2011-07-29 11:34:23 -0700
commit4afe9b31f51022538b30646fe83780e83bf22490 (patch)
tree24d7c49cb86a062f7a430166a3f7416565896ee8 /src
parentfec9786f2e7171f6616b8258a8dee8be2d5f1fd4 (diff)
downloadandroid_packages_apps_Trebuchet-4afe9b31f51022538b30646fe83780e83bf22490.tar.gz
android_packages_apps_Trebuchet-4afe9b31f51022538b30646fe83780e83bf22490.tar.bz2
android_packages_apps_Trebuchet-4afe9b31f51022538b30646fe83780e83bf22490.zip
Adding ability to add to hotseat from spring loaded mode (5064141).
- Fixing regression where folder items had no text in tablet ui and assets - Fixing spring loaded frame sizing (5067335) - Making the cells 80x80 for testing again on the phone ui (5085986) Change-Id: I52a0f5eaf2dcf4adaf57c5a71da3903892c490a8
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java6
-rw-r--r--src/com/android/launcher2/CellLayout.java5
-rw-r--r--src/com/android/launcher2/Launcher.java4
-rw-r--r--src/com/android/launcher2/LauncherApplication.java6
-rw-r--r--src/com/android/launcher2/PagedView.java14
-rw-r--r--src/com/android/launcher2/Workspace.java65
6 files changed, 70 insertions, 30 deletions
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index c2d13410d..b6bc5dc52 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -183,7 +183,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(android.animation.Animator animation) {
- mAppsCustomizePane.flashScrollingIndicator();
+ if (!LauncherApplication.isScreenLarge()) {
+ mAppsCustomizePane.flashScrollingIndicator();
+ }
}
});
anim.start();
@@ -250,7 +252,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
setLayerType(LAYER_TYPE_NONE, null);
}
- if (!toWorkspace) {
+ if (!toWorkspace && !LauncherApplication.isScreenLarge()) {
mAppsCustomizePane.flashScrollingIndicator();
}
}
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 518c79fc2..9440b89d3 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -906,11 +906,6 @@ public class CellLayout extends ViewGroup {
int vFreeSpace = vSpace - (mCountY * mOriginalCellHeight);
mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
- int remainingHSpace = hFreeSpace - (numWidthGaps * mWidthGap);
- int remainingVSpace = vFreeSpace - (numHeightGaps * mHeightGap);
- mCellWidth = mOriginalCellWidth + remainingHSpace / mCountX;
- mCellHeight = mOriginalCellHeight + remainingVSpace / mCountY;
-
mChildren.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
} else {
mWidthGap = mOriginalWidthGap;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index cd62ee1f3..400c8813a 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2040,6 +2040,7 @@ public final class Launcher extends Activity
// Shrink workspaces away if going to AppsCustomize from workspace
mWorkspace.shrink(Workspace.State.SMALL, animated);
+ hideHotseat(animated);
if (animated) {
final ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
@@ -2141,6 +2142,7 @@ public final class Launcher extends Activity
if (!springLoaded) {
mWorkspace.unshrink(animated);
}
+ showHotseat(animated);
if (animated) {
if (mStateAnimation != null) mStateAnimation.cancel();
mStateAnimation = new AnimatorSet();
@@ -2297,7 +2299,6 @@ public final class Launcher extends Activity
// Hide the search bar and hotseat
mSearchDeleteBar.hideSearchBar(animated);
- hideHotseat(animated);
// Change the state *after* we've called all the transition code
mState = State.APPS_CUSTOMIZE;
@@ -2357,7 +2358,6 @@ public final class Launcher extends Activity
// Show the search bar and hotseat
mSearchDeleteBar.showSearchBar(animated);
- showHotseat(animated);
// Set focus to the AppsCustomize button
if (mAllAppsButton != null) {
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index 94163acc6..9b2458758 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -19,6 +19,7 @@ package com.android.launcher2;
import android.app.Application;
import android.app.SearchManager;
import android.content.ContentResolver;
+import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
@@ -116,6 +117,11 @@ public class LauncherApplication extends Application {
return sIsScreenLarge;
}
+ public static boolean isScreenLandscape(Context context) {
+ return context.getResources().getConfiguration().orientation ==
+ Configuration.ORIENTATION_LANDSCAPE;
+ }
+
public static float getScreenDensity() {
return sScreenDensity;
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 292ccd740..48360feb1 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -578,9 +578,9 @@ public abstract class PagedView extends ViewGroup {
protected void updateAdjacentPagesAlpha() {
if (mFadeInAdjacentScreens) {
if (mDirtyPageAlpha || (mTouchState == TOUCH_STATE_SCROLLING) || !mScroller.isFinished()) {
- int screenWidth = getMeasuredWidth();
+ int screenWidth = getMeasuredWidth() - mPaddingLeft - mPaddingRight;
int halfScreenSize = screenWidth / 2;
- int screenCenter = mScrollX + halfScreenSize;
+ int screenCenter = mScrollX + halfScreenSize + mPaddingLeft;
final int childCount = getChildCount();
for (int i = 0; i < childCount; ++i) {
View layout = (View) getChildAt(i);
@@ -1265,11 +1265,13 @@ public abstract class PagedView extends ViewGroup {
}
protected int getRelativeChildOffset(int index) {
- return (getMeasuredWidth() - getChildWidth(index)) / 2;
+ int padding = mPaddingLeft + mPaddingRight;
+ return mPaddingLeft + (getMeasuredWidth() - padding - getChildWidth(index)) / 2;
}
-
protected int getScaledRelativeChildOffset(int index) {
- return (getMeasuredWidth() - getScaledMeasuredWidth(getChildAt(index))) / 2;
+ int padding = mPaddingLeft + mPaddingRight;
+ return mPaddingLeft + (getMeasuredWidth() - padding -
+ getScaledMeasuredWidth(getChildAt(index))) / 2;
}
protected int getChildOffset(int index) {
@@ -1762,7 +1764,7 @@ public abstract class PagedView extends ViewGroup {
int numPages = getChildCount();
int pageWidth = getMeasuredWidth();
- int maxPageWidth = (numPages * getMeasuredWidth()) + ((numPages - 1) * mPageSpacing);
+ int maxPageWidth = (numPages * getChildWidth(0)) + ((numPages - 1) * mPageSpacing);
int trackWidth = pageWidth - mScrollIndicatorPaddingLeft - mScrollIndicatorPaddingRight;
int indicatorWidth = mScrollIndicator.getMeasuredWidth() -
mScrollIndicator.getPaddingLeft() - mScrollIndicator.getPaddingRight();
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 10b218a31..ecc548397 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -261,7 +261,10 @@ public class Workspace extends SmoothPagedView
setDataIsReady();
if (!LauncherApplication.isScreenLarge()) {
- mFadeInAdjacentScreens = false;
+ mCenterPagesVertically = false;
+ if (!LauncherApplication.isScreenLandscape(context)) {
+ mFadeInAdjacentScreens = false;
+ }
}
mWallpaperManager = WallpaperManager.getInstance(context);
@@ -1335,7 +1338,7 @@ public class Workspace extends SmoothPagedView
}
// we use this to shrink the workspace for the all apps view and the customize view
- public void shrink(State shrinkState, boolean animated) {
+ public void shrink(final State shrinkState, boolean animated) {
if (mFirstLayout) {
// (mFirstLayout == "first layout has not happened yet")
// if we get a call to shrink() as part of our initialization (for example, if
@@ -1527,6 +1530,14 @@ public class Workspace extends SmoothPagedView
cl.setFastAlpha(a * mOldAlphas[i] + b * mNewAlphas[i]);
cl.setFastRotationY(a * mOldRotationYs[i] + b * mNewRotationYs[i]);
}
+
+ // Shrink the hotset the same amount we are shrinking the screens
+ if (shrinkState == State.SPRING_LOADED && mLauncher.getHotseat() != null) {
+ View hotseat = mLauncher.getHotseat().getLayout();
+ hotseat.fastInvalidate();
+ hotseat.setFastScaleX(a * mOldScaleXs[0] + b * mNewScaleXs[0]);
+ hotseat.setFastScaleY(a * mOldScaleXs[0] + b * mNewScaleXs[0]);
+ }
}
});
mAnimator.playTogether(animWithInterpolator);
@@ -1705,7 +1716,7 @@ public class Workspace extends SmoothPagedView
mNewRotationYs = new float[childCount];
}
- void unshrink(boolean animated, boolean springLoaded) {
+ void unshrink(boolean animated, final boolean springLoaded) {
if (mFirstLayout) {
// (mFirstLayout == "first layout has not happened yet")
// cancel any pending shrinks that were set earlier
@@ -1742,18 +1753,22 @@ public class Workspace extends SmoothPagedView
final CellLayout cl = (CellLayout)getChildAt(i);
float finalAlphaValue = 0f;
float rotation = 0f;
- if (LauncherApplication.isScreenLarge()) {
- finalAlphaValue = (i == mCurrentPage) ? 1.0f : 0.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) {
+ finalAlphaValue = (i == mCurrentPage) ? 1f : 0f;
+ } else {
+ finalAlphaValue = 1f;
+ }
+
+ if (LauncherApplication.isScreenLarge()) {
if (i < mCurrentPage) {
rotation = WORKSPACE_ROTATION;
} else if (i > mCurrentPage) {
rotation = -WORKSPACE_ROTATION;
}
- } else {
- // Don't hide the side panes on the phone if we don't also update the side pages
- // alpha. See screenScrolled().
- finalAlphaValue = 1f;
}
float finalAlphaMultiplierValue = 1f;
@@ -1864,6 +1879,14 @@ public class Workspace extends SmoothPagedView
b * mNewBackgroundAlphaMultipliers[i]);
cl.setFastAlpha(a * mOldAlphas[i] + b * mNewAlphas[i]);
}
+
+ // Unshrink the hotset the same amount we are unshrinking the screens
+ if (mLauncher.getHotseat() != null) {
+ View hotseat = mLauncher.getHotseat().getLayout();
+ hotseat.fastInvalidate();
+ hotseat.setFastScaleX(a * mOldScaleXs[0] + b * mNewScaleXs[0]);
+ hotseat.setFastScaleY(a * mOldScaleXs[0] + b * mNewScaleXs[0]);
+ }
}
});
@@ -2259,7 +2282,8 @@ public class Workspace extends SmoothPagedView
// new current/default screen, so any subsequent taps add items to that screen
if (!mLauncher.isAllAppsVisible()) {
int dragTargetIndex = indexOfChild(mDragTargetLayout);
- if (mCurrentPage != dragTargetIndex && (isSmall() || mIsSwitchingState)) {
+ if (dragTargetIndex > -1 && mCurrentPage != dragTargetIndex &&
+ (isSmall() || mIsSwitchingState)) {
scrollToNewPageWithoutMovingPages(dragTargetIndex);
}
}
@@ -2767,19 +2791,27 @@ public class Workspace extends SmoothPagedView
if (mInScrollArea) return;
if (mIsSwitchingState) return;
+ Rect r = new Rect();
CellLayout layout = null;
ItemInfo item = (ItemInfo) d.dragInfo;
// Ensure that we have proper spans for the item that we are dropping
if (item.spanX < 0 || item.spanY < 0) throw new RuntimeException("Improper spans found");
-
mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset,
- d.dragView, mDragViewVisualCenter);
+ d.dragView, mDragViewVisualCenter);
// Identify whether we have dragged over a side page
if (isSmall()) {
- layout = findMatchingPageForDragOver(d.dragView, mDragViewVisualCenter[0],
+ if (mLauncher.getHotseat() != null) {
+ mLauncher.getHotseat().getHitRect(r);
+ if (r.contains(d.x, d.y)) {
+ layout = mLauncher.getHotseat().getLayout();
+ }
+ }
+ if (layout == null) {
+ layout = findMatchingPageForDragOver(d.dragView, mDragViewVisualCenter[0],
mDragViewVisualCenter[1], true);
+ }
if (layout != mDragTargetLayout) {
// Cancel all intermediate folder states
cleanupFolderCreation(d);
@@ -2798,12 +2830,15 @@ public class Workspace extends SmoothPagedView
boolean isInSpringLoadedMode = (mState == State.SPRING_LOADED);
if (isInSpringLoadedMode) {
- mSpringLoadedDragController.setAlarm(mDragTargetLayout);
+ if (mLauncher.isHotseatLayout(layout)) {
+ mSpringLoadedDragController.cancel();
+ } else {
+ mSpringLoadedDragController.setAlarm(mDragTargetLayout);
+ }
}
}
} else {
// Test to see if we are over the hotseat otherwise just use the current page
- Rect r = new Rect();
if (mLauncher.getHotseat() != null) {
mLauncher.getHotseat().getHitRect(r);
if (r.contains(d.x, d.y)) {