diff options
author | Andrew Flynn <flynn@google.com> | 2012-03-06 11:39:49 -0800 |
---|---|---|
committer | Andrew Flynn <flynn@google.com> | 2012-03-06 13:31:44 -0800 |
commit | bc239a15464f543a41b960b946aa77258454efaf (patch) | |
tree | 00885d354285fe7f7c73f9f8d439ea27d299d7c9 /src/com/android | |
parent | 9d852533dedb556bd3072b4af5d4ccf6828de63b (diff) | |
download | android_packages_apps_Trebuchet-bc239a15464f543a41b960b946aa77258454efaf.tar.gz android_packages_apps_Trebuchet-bc239a15464f543a41b960b946aa77258454efaf.tar.bz2 android_packages_apps_Trebuchet-bc239a15464f543a41b960b946aa77258454efaf.zip |
Scale icons down for sw600dp-land mode.
Cached icons are statically all the same size, so we need to do
it on the fly.
Change-Id: Iae294ff4668f987db8fe5127bae724bf08363542
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher2/BubbleTextView.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 67 |
2 files changed, 42 insertions, 27 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java index ad3954124..a140b3375 100644 --- a/src/com/android/launcher2/BubbleTextView.java +++ b/src/com/android/launcher2/BubbleTextView.java @@ -289,7 +289,7 @@ public class BubbleTextView extends TextView { } // If text is transparent, don't draw any shadow - if (getCurrentTextColor() == android.R.color.transparent) { + if (getCurrentTextColor() == getResources().getColor(android.R.color.transparent)) { getPaint().clearShadowLayer(); super.draw(canvas); return; diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index a6c2c5f75..08dc866ed 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -138,6 +138,7 @@ public class CellLayout extends ViewGroup { private boolean mIsHotseat = false; private final int mBubbleScalePercent; + private final int mBubbleHotseatScalePercent; public CellLayout(Context context) { this(context, null); @@ -184,7 +185,8 @@ public class CellLayout extends ViewGroup { mNormalBackground.setFilterBitmap(true); mActiveGlowBackground.setFilterBitmap(true); - mBubbleScalePercent = res.getInteger(R.integer.app_icon_hotseat_scale_percent); + mBubbleScalePercent = res.getInteger(R.integer.app_icon_scale_percent); + mBubbleHotseatScalePercent = res.getInteger(R.integer.app_icon_hotseat_scale_percent); // Initialize the data structures used for the drag visualization. @@ -588,6 +590,34 @@ public class CellLayout extends ViewGroup { return addViewToCellLayout(child, index, childId, params, markCells, false); } + private void scaleChild(BubbleTextView bubbleChild, float pivot, int scalePercent) { + // If we haven't measured the child yet, do it now + // (this happens if we're being dropped from all-apps + if (bubbleChild.getLayoutParams() instanceof LayoutParams && + (bubbleChild.getMeasuredWidth() | bubbleChild.getMeasuredHeight()) == 0) { + getChildrenLayout().measureChild(bubbleChild); + } + int measuredWidth = bubbleChild.getMeasuredWidth(); + int measuredHeight = bubbleChild.getMeasuredHeight(); + + float scale = scalePercent / 100f; + bubbleChild.setPivotX(pivot); + bubbleChild.setPivotY(pivot); + bubbleChild.setScaleX(scale); + bubbleChild.setScaleY(scale); + bubbleChild.setTranslationX(measuredWidth * (1 - scale) / 2); + bubbleChild.setTranslationY(measuredHeight * (1 - scale) / 2); + } + + private void resetChild(BubbleTextView bubbleChild) { + bubbleChild.setScaleX(1f); + bubbleChild.setScaleY(1f); + bubbleChild.setTranslationX(0f); + bubbleChild.setTranslationY(0f); + + bubbleChild.setTextColor(getResources().getColor(R.color.workspace_icon_text_color)); + } + public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params, boolean markCells, boolean allApps) { final LayoutParams lp = params; @@ -599,32 +629,17 @@ public class CellLayout extends ViewGroup { 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); + // Start the child with 100% scale and visible text + resetChild(bubbleChild); + + if (mIsHotseat && !allApps && mBubbleHotseatScalePercent >= 0) { + // Scale/make transparent for a hotseat + scaleChild(bubbleChild, 0f, mBubbleHotseatScalePercent); - bubbleChild.setTextColor( - getResources().getColor(R.color.workspace_icon_text_color)); + bubbleChild.setTextColor(getResources().getColor(android.R.color.transparent)); + } else if (mBubbleScalePercent >= 0) { + // Else possibly still scale it if we need to for smaller icons + scaleChild(bubbleChild, 0f, mBubbleScalePercent); } } |