summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-09-30 23:04:10 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-30 23:04:10 +0000
commit81d5a2227bd0aaf359e72c45a54c5f3d9c9bda27 (patch)
treebac94875546acb8a746620af8c54969902465340
parentd48ddd62d65baa6a2f2c1ba8e39ed070c59977e5 (diff)
parent2c4d2ccd90e60541efffb980b70270d0bfe4e585 (diff)
downloadandroid_packages_apps_Trebuchet-81d5a2227bd0aaf359e72c45a54c5f3d9c9bda27.tar.gz
android_packages_apps_Trebuchet-81d5a2227bd0aaf359e72c45a54c5f3d9c9bda27.tar.bz2
android_packages_apps_Trebuchet-81d5a2227bd0aaf359e72c45a54c5f3d9c9bda27.zip
am 2c4d2ccd: Merge "Don’t create dummy app info." into ub-launcher3-burnaby-polish
* commit '2c4d2ccd90e60541efffb980b70270d0bfe4e585': Don’t create dummy app info.
-rw-r--r--src/com/android/launcher3/BubbleTextView.java11
-rw-r--r--src/com/android/launcher3/Launcher.java15
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java13
3 files changed, 21 insertions, 18 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index db1e4f5c4..e7157aac5 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -25,6 +25,8 @@ import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Region;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
@@ -188,6 +190,15 @@ public class BubbleTextView extends TextView
}
/**
+ * Used for measurement only, sets some dummy values on this view.
+ */
+ public void applyDummyInfo() {
+ ColorDrawable d = new ColorDrawable();
+ setIcon(mLauncher.resizeIconDrawable(d), mIconSize);
+ setText("");
+ }
+
+ /**
* Overrides the default long press timeout.
*/
public void setLongPressTimeout(int longPressTimeout) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 143d19b9b..d223f3e74 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -4574,18 +4574,6 @@ public class Launcher extends Activity
UserHandleCompat.myUserHandle());
}
- /**
- * Generates a dummy AppInfo for us to use to calculate BubbleTextView sizes.
- */
- public AppInfo createDummyAppInfo() {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(this, Launcher.class));
- PackageManager pm = getPackageManager();
- ResolveInfo info = pm.resolveActivity(intent, 0);
- return new AppInfo(this, LauncherActivityInfoCompat.fromResolveInfo(info, this),
- UserHandleCompat.myUserHandle(), mIconCache);
- }
-
// TODO: This method should be a part of LauncherSearchCallback
public void startDrag(View dragView, ItemInfo dragInfo, DragSource source) {
dragView.setTag(dragInfo);
@@ -4617,8 +4605,9 @@ public class Launcher extends Activity
/**
* Resizes an icon drawable to the correct icon size.
*/
- public void resizeIconDrawable(Drawable icon) {
+ public Drawable resizeIconDrawable(Drawable icon) {
icon.setBounds(0, 0, mDeviceProfile.iconSizePx, mDeviceProfile.iconSizePx);
+ return icon;
}
/**
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index c26463e5b..13f83a743 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -336,15 +336,18 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
// Precalculate the prediction icon and normal icon sizes
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
- BubbleTextView icon = (BubbleTextView) layoutInflater.inflate(R.layout.all_apps_icon, this, false);
- icon.applyFromApplicationInfo(mLauncher.createDummyAppInfo());
+ BubbleTextView icon = (BubbleTextView) layoutInflater.inflate(
+ R.layout.all_apps_icon, this, false);
+ icon.applyDummyInfo();
icon.measure(MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE, MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE, MeasureSpec.AT_MOST));
- BubbleTextView predIcon = (BubbleTextView) layoutInflater.inflate(R.layout.all_apps_prediction_bar_icon, this, false);
- predIcon.applyFromApplicationInfo(mLauncher.createDummyAppInfo());
+ BubbleTextView predIcon = (BubbleTextView) layoutInflater.inflate(
+ R.layout.all_apps_prediction_bar_icon, this, false);
+ predIcon.applyDummyInfo();
predIcon.measure(MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE, MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE, MeasureSpec.AT_MOST));
- mAppsRecyclerView.setPremeasuredIconHeights(predIcon.getMeasuredHeight(), icon.getMeasuredHeight());
+ mAppsRecyclerView.setPremeasuredIconHeights(predIcon.getMeasuredHeight(),
+ icon.getMeasuredHeight());
updateBackgroundAndPaddings();
}