summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Flynn <flynn@google.com>2012-03-01 16:26:50 -0800
committerAndrew Flynn <flynn@google.com>2012-03-01 16:26:50 -0800
commit826a661d5bae6a5e2e3bd8fa46a1cae9e68fe2ec (patch)
tree1ba6f2151cba45b5e7d07cd61a44f6b59a3f828f /src
parentca83eeb0919b690350d86a9562f58a5a56d196bf (diff)
parenta3e22d6a362260d5b81feefbc91e4757e3d58958 (diff)
downloadandroid_packages_apps_Trebuchet-826a661d5bae6a5e2e3bd8fa46a1cae9e68fe2ec.tar.gz
android_packages_apps_Trebuchet-826a661d5bae6a5e2e3bd8fa46a1cae9e68fe2ec.tar.bz2
android_packages_apps_Trebuchet-826a661d5bae6a5e2e3bd8fa46a1cae9e68fe2ec.zip
resolved conflicts for merge of a3e22d6a to master
Change-Id: I8770574acf86e280a9d15d4309686111260e09d9
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/BubbleTextView.java9
-rw-r--r--src/com/android/launcher2/CellLayout.java70
-rw-r--r--src/com/android/launcher2/Hotseat.java14
-rw-r--r--src/com/android/launcher2/Launcher.java4
-rw-r--r--src/com/android/launcher2/LauncherApplication.java7
-rw-r--r--src/com/android/launcher2/LauncherModel.java3
-rw-r--r--src/com/android/launcher2/LauncherProvider.java6
-rw-r--r--src/com/android/launcher2/Utilities.java1
-rw-r--r--src/com/android/launcher2/Workspace.java7
9 files changed, 104 insertions, 17 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index 6227611d8..b41a02e1e 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -178,6 +178,7 @@ public class BubbleTextView extends TextView {
// The translate of scrollX and scrollY is necessary when drawing TextViews, because
// they set scrollX and scrollY to large values to achieve centered text
destCanvas.save();
+ destCanvas.scale(getScaleX(), getScaleY(), getWidth() / 2, getHeight() / 2);
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
draw(destCanvas);
@@ -292,6 +293,14 @@ public class BubbleTextView extends TextView {
canvas.translate(-scrollX, -scrollY);
}
}
+
+ // If text is transparent, don't draw any shadow
+ if (getCurrentTextColor() == android.R.color.transparent) {
+ getPaint().clearShadowLayer();
+ super.draw(canvas);
+ return;
+ }
+
// We enhance the shadow by drawing the shadow twice
getPaint().setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR);
super.draw(canvas);
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 37328ef2e..bbb0d7f9f 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -28,6 +28,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PointF;
@@ -135,6 +136,9 @@ public class CellLayout extends ViewGroup {
private TimeInterpolator mEaseOutInterpolator;
private CellLayoutChildren mChildren;
+ private boolean mIsHotseat = false;
+ private final int mBubbleScalePercent;
+
public CellLayout(Context context) {
this(context, null);
}
@@ -180,6 +184,8 @@ public class CellLayout extends ViewGroup {
mNormalBackground.setFilterBitmap(true);
mActiveGlowBackground.setFilterBitmap(true);
+ mBubbleScalePercent = res.getInteger(R.integer.app_icon_hotseat_scale_percent);
+
// Initialize the data structures used for the drag visualization.
mCrosshairsDrawable = res.getDrawable(R.drawable.gardening_crosshairs);
@@ -489,6 +495,25 @@ public class CellLayout extends ViewGroup {
@Override
protected void dispatchDraw(Canvas canvas) {
+ // Debug drawing for hit space
+ if (false) {
+ final Rect frame = mRect;
+ for (int i = mChildren.getChildCount() - 1; i >= 0; i--) {
+ final View child = mChildren.getChildAt(i);
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+
+ if ((child.getVisibility() == VISIBLE || child.getAnimation() != null) &&
+ lp.isLockedToGrid) {
+ child.getHitRect(frame);
+ frame.offset(mPaddingLeft, mPaddingTop);
+
+ Paint p = new Paint();
+ p.setColor(Color.GREEN);
+ canvas.drawRect(frame, p);
+ }
+ }
+ }
+
super.dispatchDraw(canvas);
if (mForegroundAlpha > 0) {
mOverScrollForegroundDrawable.setBounds(mForegroundRect);
@@ -551,10 +576,55 @@ public class CellLayout extends ViewGroup {
return mCountY;
}
+ public void setIsHotseat(boolean isHotseat) {
+ mIsHotseat = isHotseat;
+ }
+
public boolean addViewToCellLayout(
View child, int index, int childId, LayoutParams params, boolean markCells) {
+ return addViewToCellLayout(child, index, childId, params, markCells, false);
+ }
+
+ public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params,
+ boolean markCells, boolean allApps) {
final LayoutParams lp = params;
+ // Hotseat icons - scale down and remove text
+ // Don't scale the all apps button
+ // scale percent set to -1 means do not scale
+ // Only scale BubbleTextViews
+ if (child instanceof BubbleTextView) {
+ BubbleTextView bubbleChild = (BubbleTextView) child;
+
+ if (mIsHotseat && !allApps && mBubbleScalePercent >= 0) {
+ // If we haven't measured the child yet, do it now
+ // (this happens if we're being dropped from all-apps
+ if ((bubbleChild.getMeasuredWidth() | bubbleChild.getMeasuredHeight()) == 0) {
+ getChildrenLayout().measureChild(bubbleChild);
+ }
+ int measuredWidth = bubbleChild.getMeasuredWidth();
+ int measuredHeight = bubbleChild.getMeasuredHeight();
+
+ float bubbleScale = mBubbleScalePercent / 100f;
+ bubbleChild.setPivotX(0);
+ bubbleChild.setPivotY(0);
+ bubbleChild.setScaleX(bubbleScale);
+ bubbleChild.setScaleY(bubbleScale);
+ bubbleChild.setTranslationX(measuredWidth * (1 - bubbleScale) / 2);
+ bubbleChild.setTranslationY(measuredHeight * (1 - bubbleScale) / 2);
+
+ bubbleChild.setTextColor(android.R.color.transparent);
+ } else {
+ bubbleChild.setScaleX(1f);
+ bubbleChild.setScaleY(1f);
+ bubbleChild.setTranslationX(0f);
+ bubbleChild.setTranslationY(0f);
+
+ bubbleChild.setTextColor(
+ getResources().getColor(R.color.workspace_icon_text_color));
+ }
+ }
+
// Generate an id for each view, this assumes we have at most 256x256 cells
// per workspace screen
if (lp.cellX >= 0 && lp.cellX <= mCountX - 1 && lp.cellY >= 0 && lp.cellY <= mCountY - 1) {
diff --git a/src/com/android/launcher2/Hotseat.java b/src/com/android/launcher2/Hotseat.java
index f7fa38007..add62c004 100644
--- a/src/com/android/launcher2/Hotseat.java
+++ b/src/com/android/launcher2/Hotseat.java
@@ -29,13 +29,13 @@ import com.android.launcher.R;
public class Hotseat extends FrameLayout {
private static final String TAG = "Hotseat";
- private static final int sAllAppsButtonRank = 2; // In the middle of the dock
private Launcher mLauncher;
private CellLayout mContent;
private int mCellCountX;
private int mCellCountY;
+ private int mAllAppsButtonRank;
private boolean mIsLandscape;
public Hotseat(Context context) {
@@ -53,6 +53,7 @@ public class Hotseat extends FrameLayout {
R.styleable.Hotseat, defStyle, 0);
mCellCountX = a.getInt(R.styleable.Hotseat_cellCountX, -1);
mCellCountY = a.getInt(R.styleable.Hotseat_cellCountY, -1);
+ mAllAppsButtonRank = context.getResources().getInteger(R.integer.hotseat_all_apps_index);
mIsLandscape = context.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE;
}
@@ -77,8 +78,8 @@ public class Hotseat extends FrameLayout {
int getCellYFromOrder(int rank) {
return mIsLandscape ? (mContent.getCountY() - (rank + 1)) : 0;
}
- public static boolean isAllAppsButtonRank(int rank) {
- return rank == sAllAppsButtonRank;
+ public boolean isAllAppsButtonRank(int rank) {
+ return rank == mAllAppsButtonRank;
}
@Override
@@ -88,6 +89,7 @@ public class Hotseat extends FrameLayout {
if (mCellCountY < 0) mCellCountY = LauncherModel.getCellCountY();
mContent = (CellLayout) findViewById(R.id.layout);
mContent.setGridSize(mCellCountX, mCellCountY);
+ mContent.setIsHotseat(true);
resetLayout();
}
@@ -126,9 +128,9 @@ public class Hotseat extends FrameLayout {
// Note: We do this to ensure that the hotseat is always laid out in the orientation of
// the hotseat in order regardless of which orientation they were added
- int x = getCellXFromOrder(sAllAppsButtonRank);
- int y = getCellYFromOrder(sAllAppsButtonRank);
+ int x = getCellXFromOrder(mAllAppsButtonRank);
+ int y = getCellYFromOrder(mAllAppsButtonRank);
mContent.addViewToCellLayout(allAppsButton, -1, 0, new CellLayout.LayoutParams(x,y,1,1),
- true);
+ true, true);
}
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index e80f9a64f..d8a43845c 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2213,6 +2213,10 @@ public final class Launcher extends Activity
return (mState == State.APPS_CUSTOMIZE);
}
+ public boolean isAllAppsButtonRank(int rank) {
+ return mHotseat.isAllAppsButtonRank(rank);
+ }
+
// AllAppsView.Watcher
public void zoomed(float zoom) {
if (zoom == 1.0f) {
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index e69c5ab0b..47ce0b722 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -27,6 +27,8 @@ import android.database.ContentObserver;
import android.os.Handler;
import android.view.MotionEvent;
+import com.android.launcher.R;
+
import java.lang.ref.WeakReference;
public class LauncherApplication extends Application {
@@ -42,10 +44,7 @@ public class LauncherApplication extends Application {
super.onCreate();
// set sIsScreenXLarge and sScreenDensity *before* creating icon cache
- final int screenSize = getResources().getConfiguration().screenLayout &
- Configuration.SCREENLAYOUT_SIZE_MASK;
- sIsScreenLarge = screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE ||
- screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE;
+ sIsScreenLarge = getResources().getBoolean(R.bool.is_large_screen);
sScreenDensity = getResources().getDisplayMetrics().density;
mIconCache = new IconCache(this);
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 7da55db6d..159ddb016 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -138,6 +138,7 @@ public class LauncherModel extends BroadcastReceiver {
public void bindAppsRemoved(ArrayList<ApplicationInfo> apps, boolean permanent);
public void bindPackagesUpdated();
public boolean isAllAppsVisible();
+ public boolean isAllAppsButtonRank(int rank);
public void bindSearchablesChanged();
}
@@ -920,7 +921,7 @@ public class LauncherModel extends BroadcastReceiver {
int containerIndex = item.screen;
if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
// Return early if we detect that an item is under the hotseat button
- if (Hotseat.isAllAppsButtonRank(item.screen)) {
+ if (mCallbacks == null || mCallbacks.get().isAllAppsButtonRank(item.screen)) {
return false;
}
diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java
index a01cc479b..de9a9b2de 100644
--- a/src/com/android/launcher2/LauncherProvider.java
+++ b/src/com/android/launcher2/LauncherProvider.java
@@ -706,6 +706,8 @@ public class LauncherProvider extends ContentProvider {
ContentValues values = new ContentValues();
PackageManager packageManager = mContext.getPackageManager();
+ int allAppsButtonRank =
+ mContext.getResources().getInteger(R.integer.hotseat_all_apps_index);
int i = 0;
try {
XmlResourceParser parser = mContext.getResources().getXml(workspaceResourceId);
@@ -739,8 +741,8 @@ public class LauncherProvider extends ContentProvider {
// If we are adding to the hotseat, the screen is used as the position in the
// hotseat. This screen can't be at position 0 because AllApps is in the
// zeroth position.
- if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
- Hotseat.isAllAppsButtonRank(Integer.valueOf(screen))) {
+ if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT
+ && Integer.valueOf(screen) == allAppsButtonRank) {
throw new RuntimeException("Invalid screen position for hotseat item");
}
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index d7562a947..0387011a4 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -113,7 +113,6 @@ final class Utilities {
}
int sourceWidth = icon.getIntrinsicWidth();
int sourceHeight = icon.getIntrinsicHeight();
-
if (sourceWidth > 0 && sourceHeight > 0) {
// There are intrinsic sizes.
if (width < sourceWidth || height < sourceHeight) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 0624d7491..dffaf896c 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1429,7 +1429,7 @@ public class Workspace extends SmoothPagedView
* This interpolator emulates the rate at which the perceived scale of an object changes
* as its distance from a camera increases. When this interpolator is applied to a scale
* animation on a view, it evokes the sense that the object is shrinking due to moving away
- * from the camera.
+ * from the camera.
*/
static class ZInterpolator implements TimeInterpolator {
private float focalLength;
@@ -1588,7 +1588,7 @@ public class Workspace extends SmoothPagedView
setLayoutScale(1.0f);
}
- final int duration = zoomIn ?
+ final int duration = zoomIn ?
getResources().getInteger(R.integer.config_workspaceUnshrinkTime) :
getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime);
for (int i = 0; i < getChildCount(); i++) {
@@ -2042,7 +2042,7 @@ public class Workspace extends SmoothPagedView
// is full
if (mTargetCell != null && mLauncher.isHotseatLayout(mDragTargetLayout)) {
Hotseat hotseat = mLauncher.getHotseat();
- if (Hotseat.isAllAppsButtonRank(
+ if (hotseat.isAllAppsButtonRank(
hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) {
return false;
}
@@ -3077,6 +3077,7 @@ public class Workspace extends SmoothPagedView
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
cellLayout.getChildrenLayout().measureChild(view);
+
LauncherModel.addOrMoveItemInDatabase(mLauncher, info, container, screen,
lp.cellX, lp.cellY);