diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-05-12 22:11:59 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-12 22:12:00 +0000 |
commit | 07b75b85c20530cf7c66a1f5b5cba5437ba127f6 (patch) | |
tree | a394270ba968d9d687439cd225e97eacd4bc8aa5 /src | |
parent | 19e4d9db28ee6487428879aacd053c319771b51c (diff) | |
parent | 0e08f166fafd5e2a0d32e27ea510516e3f762221 (diff) | |
download | android_packages_apps_Trebuchet-07b75b85c20530cf7c66a1f5b5cba5437ba127f6.tar.gz android_packages_apps_Trebuchet-07b75b85c20530cf7c66a1f5b5cba5437ba127f6.tar.bz2 android_packages_apps_Trebuchet-07b75b85c20530cf7c66a1f5b5cba5437ba127f6.zip |
Merge "Using BubbleTextView for widget section headers" into ub-launcher3-burnaby
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 29 | ||||
-rw-r--r-- | src/com/android/launcher3/IconCache.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/widget/WidgetsListAdapter.java | 17 |
3 files changed, 30 insertions, 19 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); + } } } } diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java index 0596fbe16..fff07c6ed 100644 --- a/src/com/android/launcher3/IconCache.java +++ b/src/com/android/launcher3/IconCache.java @@ -374,6 +374,9 @@ public class IconCache { getTitleAndIcon(st, st.promisedIntent != null ? st.promisedIntent : st.intent, st.user, false); + } else if (info instanceof PackageItemInfo) { + PackageItemInfo pti = (PackageItemInfo) info; + getTitleAndIconForApp(pti.packageName, pti.user, false, pti); } mMainThreadExecutor.execute(new Runnable() { diff --git a/src/com/android/launcher3/widget/WidgetsListAdapter.java b/src/com/android/launcher3/widget/WidgetsListAdapter.java index 8b0a43b2f..d114883ad 100644 --- a/src/com/android/launcher3/widget/WidgetsListAdapter.java +++ b/src/com/android/launcher3/widget/WidgetsListAdapter.java @@ -17,22 +17,21 @@ package com.android.launcher3.widget; import android.content.Context; import android.content.pm.ResolveInfo; +import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.Adapter; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.TextView; +import com.android.launcher3.BubbleTextView; import com.android.launcher3.IconCache; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherAppWidgetProviderInfo; import com.android.launcher3.R; import com.android.launcher3.WidgetPreviewLoader; -import com.android.launcher3.compat.UserHandleCompat; import java.util.List; @@ -120,16 +119,8 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> { // Bind the views in the application info section. PackageItemInfo infoOut = mWidgetsModel.getPackageItemInfo(pos); - if (infoOut.usingLowResIcon) { - // TODO(hyunyoungs): call this in none UI thread in the same way as BubbleTextView. - mIconCache.getTitleAndIconForApp(infoOut.packageName, - UserHandleCompat.myUserHandle(), false /* useLowResIcon */, infoOut); - } - - TextView tv = ((TextView) holder.getContent().findViewById(R.id.section)); - tv.setText(infoOut.title); - ImageView iv = (ImageView) holder.getContent().findViewById(R.id.section_image); - iv.setImageBitmap(infoOut.iconBitmap); + BubbleTextView tv = ((BubbleTextView) holder.getContent().findViewById(R.id.section)); + tv.applyFromPackageItemInfo(infoOut); // Bind the view in the widget horizontal tray region. for (int i=0; i < infoList.size(); i++) { |