Merge "Adding opacity to drag views. (5064535)"
diff --git a/res/values-large/styles.xml b/res/values-large/styles.xml
index 41bd9cd..265eff8 100644
--- a/res/values-large/styles.xml
+++ b/res/values-large/styles.xml
@@ -20,7 +20,7 @@
<resources>
<!-- Workspace -->
<style name="WorkspaceIcon.Portrait">
- <item name="android:drawablePadding">4dp</item>
+ <item name="android:drawablePadding">0dp</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
<item name="android:paddingTop">4dp</item>
@@ -35,7 +35,7 @@
<item name="android:textSize">13dip</item>
</style>
<style name="WorkspaceIcon.Landscape">
- <item name="android:drawablePadding">4dp</item>
+ <item name="android:drawablePadding">0dp</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
<item name="android:paddingTop">4dp</item>
@@ -49,10 +49,6 @@
<item name="android:paddingBottom">0dp</item>
<item name="android:textSize">13dip</item>
</style>
- <style name="WorkspaceIcon.AppsCustomize">
- <item name="android:drawablePadding">2dp</item>
- <item name="android:textSize">13dip</item>
- </style>
<style name="Theme" parent="android:Theme.Holo.Wallpaper.NoTitleBar">
<item name="android:windowActionModeOverlay">true</item>
@@ -62,6 +58,24 @@
<item name="android:screenOrientation">unspecified</item>
</style>
+ <style name="WorkspaceIcon.Portrait.AppsCustomize">
+ <item name="android:background">@null</item>
+ <item name="android:paddingTop">4dp</item>
+ <item name="android:paddingBottom">0dp</item>
+ <item name="android:paddingLeft">0dp</item>
+ <item name="android:paddingRight">0dp</item>
+ <item name="android:drawablePadding">4dp</item>
+ <item name="android:includeFontPadding">false</item>
+ <item name="android:textSize">13dip</item>
+ </style>
+ <style name="WorkspaceIcon.Landscape.AppsCustomize">
+ <item name="android:background">@null</item>
+ <item name="android:paddingTop">4dp</item>
+ <item name="android:paddingBottom">0dp</item>
+ <item name="android:drawablePadding">4dp</item>
+ <item name="android:includeFontPadding">false</item>
+ <item name="android:textSize">13dip</item>
+ </style>
<style name="TabIndicator.AppsCustomize">
<item name="android:paddingLeft">40dp</item>
<item name="android:paddingRight">40dp</item>
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 8aa7c59..25001b1 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -237,6 +237,9 @@
// blip early in the animation
buildLayer();
}
+ if (!toWorkspace && !LauncherApplication.isScreenLarge()) {
+ mAppsCustomizePane.showScrollingIndicator(false);
+ }
}
@Override
@@ -246,7 +249,7 @@
}
if (!toWorkspace && !LauncherApplication.isScreenLarge()) {
- mAppsCustomizePane.flashScrollingIndicator();
+ mAppsCustomizePane.hideScrollingIndicator(false);
}
}
}
diff --git a/src/com/android/launcher2/IconCache.java b/src/com/android/launcher2/IconCache.java
index 1fdafc8..b2ebe2a 100644
--- a/src/com/android/launcher2/IconCache.java
+++ b/src/com/android/launcher2/IconCache.java
@@ -44,7 +44,6 @@
private final Bitmap mDefaultIcon;
private final LauncherApplication mContext;
private final PackageManager mPackageManager;
- private final Utilities.BubbleText mBubble;
private final HashMap<ComponentName, CacheEntry> mCache =
new HashMap<ComponentName, CacheEntry>(INITIAL_ICON_CACHE_CAPACITY);
private int mIconDpi;
@@ -52,7 +51,6 @@
public IconCache(LauncherApplication context) {
mContext = context;
mPackageManager = context.getPackageManager();
- mBubble = new Utilities.BubbleText(context);
int density = context.getResources().getDisplayMetrics().densityDpi;
if (LauncherApplication.isScreenLarge()) {
if (density == DisplayMetrics.DENSITY_LOW) {
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index bb7bdf5..1b105d2 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2119,6 +2119,7 @@
if (!springLoaded) {
mWorkspace.showDockDivider(false);
}
+ mWorkspace.showScrollingIndicator(false);
}
@Override
public void onAnimationEnd(Animator animation) {
@@ -2126,7 +2127,7 @@
if (fromView instanceof LauncherTransitionable) {
((LauncherTransitionable) fromView).onLauncherTransitionEnd(alphaAnim,true);
}
- mWorkspace.flashScrollingIndicator();
+ mWorkspace.hideScrollingIndicator(false);
}
});
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 24feb41..d228fef 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -131,7 +131,7 @@
private PageSwitchListener mPageSwitchListener;
private ArrayList<Boolean> mDirtyPageContent;
- private boolean mDirtyPageAlpha;
+ private boolean mDirtyPageAlpha = true;
// choice modes
protected static final int CHOICE_MODE_NONE = 0;
@@ -323,7 +323,7 @@
// a method that subclasses can override to add behavior
protected void onPageBeginMoving() {
- showScrollingIndicator();
+ showScrollingIndicator(false);
}
// a method that subclasses can override to add behavior
@@ -478,6 +478,8 @@
mMaxScrollX = 0;
}
+ updateScrollingIndicatorPosition();
+
setMeasuredDimension(widthSize, heightSize);
}
@@ -1685,11 +1687,11 @@
};
protected void flashScrollingIndicator() {
removeCallbacks(hideScrollingIndicatorRunnable);
- showScrollingIndicator();
+ showScrollingIndicator(false);
postDelayed(hideScrollingIndicatorRunnable, sScrollIndicatorFlashDuration);
}
- protected void showScrollingIndicator() {
+ protected void showScrollingIndicator(boolean immediately) {
if (getChildCount() <= 1) return;
if (!isScrollingIndicatorEnabled()) return;
@@ -1701,9 +1703,13 @@
if (mScrollIndicatorAnimator != null) {
mScrollIndicatorAnimator.cancel();
}
- mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 1f);
- mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeInDuration);
- mScrollIndicatorAnimator.start();
+ if (immediately) {
+ mScrollIndicator.setAlpha(1f);
+ } else {
+ mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 1f);
+ mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeInDuration);
+ mScrollIndicatorAnimator.start();
+ }
}
}
@@ -1762,7 +1768,7 @@
private void updateScrollingIndicatorPosition() {
if (!isScrollingIndicatorEnabled()) return;
-
+ if (mScrollIndicator == null) return;
int numPages = getChildCount();
int pageWidth = getMeasuredWidth();
int maxPageWidth = (numPages * getChildWidth(0)) + ((numPages - 1) * mPageSpacing);
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index b537f7a..1175fad 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -265,120 +265,6 @@
sDisabledPaint.setAlpha(0x88);
}
- static class BubbleText {
- private static final int MAX_LINES = 2;
-
- private final TextPaint mTextPaint;
-
- private final RectF mBubbleRect = new RectF();
-
- private final float mTextWidth;
- private final int mLeading;
- private final int mFirstLineY;
- private final int mLineHeight;
-
- private final int mBitmapWidth;
- private final int mBitmapHeight;
- private final int mDensity;
-
- BubbleText(Context context) {
- final Resources resources = context.getResources();
-
- final DisplayMetrics metrics = resources.getDisplayMetrics();
- final float scale = metrics.density;
- mDensity = metrics.densityDpi;
-
- final float paddingLeft = 2.0f * scale;
- final float paddingRight = 2.0f * scale;
- final float cellWidth = resources.getDimension(R.dimen.title_texture_width);
-
- RectF bubbleRect = mBubbleRect;
- bubbleRect.left = 0;
- bubbleRect.top = 0;
- bubbleRect.right = (int) cellWidth;
-
- mTextWidth = cellWidth - paddingLeft - paddingRight;
-
- TextPaint textPaint = mTextPaint = new TextPaint();
- textPaint.setTypeface(Typeface.DEFAULT);
- textPaint.setTextSize(13*scale);
- textPaint.setColor(0xffffffff);
- textPaint.setAntiAlias(true);
- if (TEXT_BURN) {
- textPaint.setShadowLayer(8, 0, 0, 0xff000000);
- }
-
- float ascent = -textPaint.ascent();
- float descent = textPaint.descent();
- float leading = 0.0f;//(ascent+descent) * 0.1f;
- mLeading = (int)(leading + 0.5f);
- mFirstLineY = (int)(leading + ascent + 0.5f);
- mLineHeight = (int)(leading + ascent + descent + 0.5f);
-
- mBitmapWidth = (int)(mBubbleRect.width() + 0.5f);
- mBitmapHeight = roundToPow2((int)((MAX_LINES * mLineHeight) + leading + 0.5f));
-
- mBubbleRect.offsetTo((mBitmapWidth-mBubbleRect.width())/2, 0);
-
- if (false) {
- Log.d(TAG, "mBitmapWidth=" + mBitmapWidth + " mBitmapHeight="
- + mBitmapHeight + " w=" + ((int)(mBubbleRect.width() + 0.5f))
- + " h=" + ((int)((MAX_LINES * mLineHeight) + leading + 0.5f)));
- }
- }
-
- /** You own the bitmap after this and you must call recycle on it. */
- Bitmap createTextBitmap(String text) {
- Bitmap b = Bitmap.createBitmap(mBitmapWidth, mBitmapHeight, Bitmap.Config.ALPHA_8);
- b.setDensity(mDensity);
- Canvas c = new Canvas(b);
-
- StaticLayout layout = new StaticLayout(text, mTextPaint, (int)mTextWidth,
- Alignment.ALIGN_CENTER, 1, 0, true);
- int lineCount = layout.getLineCount();
- if (lineCount > MAX_LINES) {
- lineCount = MAX_LINES;
- }
- //if (!TEXT_BURN && lineCount > 0) {
- //RectF bubbleRect = mBubbleRect;
- //bubbleRect.bottom = height(lineCount);
- //c.drawRoundRect(bubbleRect, mCornerRadius, mCornerRadius, mRectPaint);
- //}
- for (int i=0; i<lineCount; i++) {
- //int x = (int)((mBubbleRect.width() - layout.getLineMax(i)) / 2.0f);
- //int y = mFirstLineY + (i * mLineHeight);
- final String lineText = text.substring(layout.getLineStart(i), layout.getLineEnd(i));
- int x = (int)(mBubbleRect.left
- + ((mBubbleRect.width() - mTextPaint.measureText(lineText)) * 0.5f));
- int y = mFirstLineY + (i * mLineHeight);
- c.drawText(lineText, x, y, mTextPaint);
- }
-
- c.setBitmap(null);
- return b;
- }
-
- private int height(int lineCount) {
- return (int)((lineCount * mLineHeight) + mLeading + mLeading + 0.0f);
- }
-
- int getBubbleWidth() {
- return (int)(mBubbleRect.width() + 0.5f);
- }
-
- int getMaxBubbleHeight() {
- return height(MAX_LINES);
- }
-
- int getBitmapWidth() {
- return mBitmapWidth;
- }
-
- int getBitmapHeight() {
- return mBitmapHeight;
- }
- }
-
/** Only works for positive numbers. */
static int roundToPow2(int n) {
int orig = n;