diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-05-12 11:32:39 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-05-12 11:40:24 -0700 |
commit | 0e08f166fafd5e2a0d32e27ea510516e3f762221 (patch) | |
tree | eb68c01e22903219000183b648efd10c8844692d /src/com/android/launcher3/BubbleTextView.java | |
parent | 44d0aacd5f44623ba87f1c8b3693d74df69d50e5 (diff) | |
download | android_packages_apps_Trebuchet-0e08f166fafd5e2a0d32e27ea510516e3f762221.tar.gz android_packages_apps_Trebuchet-0e08f166fafd5e2a0d32e27ea510516e3f762221.tar.bz2 android_packages_apps_Trebuchet-0e08f166fafd5e2a0d32e27ea510516e3f762221.zip |
Using BubbleTextView for widget section headers
> Loading highres icons on the worker thread.
Change-Id: I5b68a86820aa4c132c156339e497354cf57f0fca
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 46caf4ab9..d32c91919 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -28,13 +28,13 @@ import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.SparseArray; import android.util.TypedValue; -import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ViewConfiguration; import android.widget.TextView; import com.android.launcher3.IconCache.IconLoadRequest; +import com.android.launcher3.widget.PackageItemInfo; /** * TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan @@ -119,11 +119,6 @@ public class BubbleTextView extends TextView { mBackground = null; } - // If we are laying out horizontal, then center the text vertically - if (mLayoutHorizontal) { - setGravity(Gravity.CENTER_VERTICAL); - } - mLongPressHelper = new CheckLongPressHelper(this); mOutlineHelper = HolographicOutlineHelper.obtain(getContext()); @@ -170,6 +165,20 @@ public class BubbleTextView extends TextView { verifyHighRes(); } + public void applyFromPackageItemInfo(PackageItemInfo info) { + setIcon(Utilities.createIconDrawable(info.iconBitmap), mIconSize); + setText(info.title); + if (info.contentDescription != null) { + setContentDescription(info.contentDescription); + } + // We don't need to check the info since it's not a ShortcutInfo + super.setTag(info); + + // Verify high res immediately + verifyHighRes(); + } + + @Override protected boolean setFrame(int left, int top, int right, int bottom) { if (getLeft() != left || getRight() != right || getTop() != top || getBottom() != bottom) { @@ -459,6 +468,8 @@ public class BubbleTextView extends TextView { } else if (info instanceof ShortcutInfo) { applyFromShortcutInfo((ShortcutInfo) info, LauncherAppState.getInstance().getIconCache()); + } else if (info instanceof PackageItemInfo) { + applyFromPackageItemInfo((PackageItemInfo) info); } } } @@ -483,6 +494,12 @@ public class BubbleTextView extends TextView { mIconLoadRequest = LauncherAppState.getInstance().getIconCache() .updateIconInBackground(BubbleTextView.this, info); } + } else if (getTag() instanceof PackageItemInfo) { + PackageItemInfo info = (PackageItemInfo) getTag(); + if (info.usingLowResIcon) { + mIconLoadRequest = LauncherAppState.getInstance().getIconCache() + .updateIconInBackground(BubbleTextView.this, info); + } } } } |