summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/CellLayout.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-08-24 13:05:25 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-24 13:05:26 -0700
commit1dc3b9abd5ab0a39bab7694669d6784b89d362ef (patch)
tree130a48dc5c90c2bb9c780080e763570e316be8a0 /src/com/android/launcher2/CellLayout.java
parent05ee3cfffe4e5cf752e6072bcd2819faac121617 (diff)
parent307fe23f125cbbd5512ad8d4660025f2ab68f30b (diff)
downloadandroid_packages_apps_Trebuchet-1dc3b9abd5ab0a39bab7694669d6784b89d362ef.tar.gz
android_packages_apps_Trebuchet-1dc3b9abd5ab0a39bab7694669d6784b89d362ef.tar.bz2
android_packages_apps_Trebuchet-1dc3b9abd5ab0a39bab7694669d6784b89d362ef.zip
Merge "Adding the ability to scale the hotseat or items in the hotseat" into jb-mr1-dev
Diffstat (limited to 'src/com/android/launcher2/CellLayout.java')
-rw-r--r--src/com/android/launcher2/CellLayout.java42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 44944fe83..4f4ef4e25 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -137,6 +137,7 @@ public class CellLayout extends ViewGroup {
private ShortcutAndWidgetContainer mShortcutsAndWidgets;
private boolean mIsHotseat = false;
+ private float mHotseatScale = 1f;
public static final int MODE_DRAG_OVER = 0;
public static final int MODE_ON_DROP = 1;
@@ -199,6 +200,7 @@ public class CellLayout extends ViewGroup {
setAlwaysDrawnWithCacheEnabled(false);
final Resources res = getResources();
+ mHotseatScale = (res.getInteger(R.integer.hotseat_item_scale_percentage) / 100f);
mNormalBackground = res.getDrawable(R.drawable.homescreen_blue_normal_holo);
mActiveGlowBackground = res.getDrawable(R.drawable.homescreen_blue_strong_holo);
@@ -316,6 +318,10 @@ public class CellLayout extends ViewGroup {
mShortcutsAndWidgets.buildLayer();
}
+ public float getChildrenScale() {
+ return mIsHotseat ? mHotseatScale : 1.0f;
+ }
+
public void setGridSize(int x, int y) {
mCountX = x;
mCountY = y;
@@ -386,6 +392,25 @@ public class CellLayout extends ViewGroup {
}
}
+ public void scaleRect(Rect r, float scale) {
+ if (scale != 1.0f) {
+ r.left = (int) (r.left * scale + 0.5f);
+ r.top = (int) (r.top * scale + 0.5f);
+ r.right = (int) (r.right * scale + 0.5f);
+ r.bottom = (int) (r.bottom * scale + 0.5f);
+ }
+ }
+
+ Rect temp = new Rect();
+ void scaleRectAboutCenter(Rect in, Rect out, float scale) {
+ int cx = in.centerX();
+ int cy = in.centerY();
+ out.set(in);
+ out.offset(-cx, -cy);
+ scaleRect(out, scale);
+ out.offset(cx, cy);
+ }
+
@Override
protected void onDraw(Canvas canvas) {
// When we're large, we are either drawn in a "hover" state (ie when dragging an item to
@@ -413,9 +438,10 @@ public class CellLayout extends ViewGroup {
final float alpha = mDragOutlineAlphas[i];
if (alpha > 0) {
final Rect r = mDragOutlines[i];
+ scaleRectAboutCenter(r, temp, getChildrenScale());
final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag();
paint.setAlpha((int)(alpha + .5f));
- canvas.drawBitmap(b, null, r, paint);
+ canvas.drawBitmap(b, null, temp, paint);
}
}
@@ -590,6 +616,9 @@ public class CellLayout extends ViewGroup {
}
}
+ child.setScaleX(getChildrenScale());
+ child.setScaleY(getChildrenScale());
+
// 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) {
@@ -2071,11 +2100,8 @@ public class CellLayout extends ViewGroup {
}
initDeltaX = child.getTranslationX();
initDeltaY = child.getTranslationY();
- finalScale = 1.0f - 4.0f / child.getWidth();
+ finalScale = getChildrenScale() - 4.0f / child.getWidth();
initScale = child.getScaleX();
-
- child.setPivotY(child.getMeasuredHeight() * 0.5f);
- child.setPivotX(child.getMeasuredWidth() * 0.5f);
this.child = child;
}
@@ -2116,7 +2142,7 @@ public class CellLayout extends ViewGroup {
// We make sure to end only after a full period
initDeltaX = 0;
initDeltaY = 0;
- initScale = 1.0f;
+ initScale = getChildrenScale();
}
});
mShakeAnimators.put(child, this);
@@ -2137,8 +2163,8 @@ public class CellLayout extends ViewGroup {
AnimatorSet s = LauncherAnimUtils.createAnimatorSet();
a = s;
s.playTogether(
- LauncherAnimUtils.ofFloat(child, "scaleX", 1f),
- LauncherAnimUtils.ofFloat(child, "scaleY", 1f),
+ LauncherAnimUtils.ofFloat(child, "scaleX", getChildrenScale()),
+ LauncherAnimUtils.ofFloat(child, "scaleY", getChildrenScale()),
LauncherAnimUtils.ofFloat(child, "translationX", 0f),
LauncherAnimUtils.ofFloat(child, "translationY", 0f)
);