Disabled app icon Visuals
Bug: 154855908
Test: Manual
Change-Id: I58c75ed51426ceb4a09b608ee77636c803955025
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index f96aafa..d3b86de 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -36,6 +36,7 @@
import com.android.launcher3.graphics.PlaceHolderIconDrawable;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
+import com.android.launcher3.util.Themes;
public class FastBitmapDrawable extends Drawable {
@@ -44,7 +45,6 @@
private static final float DISABLED_DESATURATION = 1f;
private static final float DISABLED_BRIGHTNESS = 0.5f;
- private static final float DISABLED_ALPHA = 0.54f;
public static final int CLICK_FEEDBACK_DURATION = 200;
@@ -56,6 +56,7 @@
private boolean mIsPressed;
private boolean mIsDisabled;
+ private float mDisabledAlpha = 1f;
// Animator and properties for the fast bitmap drawable's scale
private static final Property<FastBitmapDrawable, Float> SCALE
@@ -253,7 +254,7 @@
mat[4] = brightnessI;
mat[9] = brightnessI;
mat[14] = brightnessI;
- mat[18] = DISABLED_ALPHA;
+ mat[18] = mDisabledAlpha;
tempFilterMatrix.preConcat(tempBrightnessMatrix);
sDisabledFColorFilter = new ColorMatrixColorFilter(tempFilterMatrix);
}
@@ -319,12 +320,15 @@
* Creates a drawable for the provided BitmapInfo
*/
public static FastBitmapDrawable newIcon(Context context, BitmapInfo info) {
+ final FastBitmapDrawable drawable;
if (info instanceof Factory) {
- return ((Factory) info).newDrawable();
+ drawable = ((Factory) info).newDrawable();
} else if (info.isLowRes()) {
- return new PlaceHolderIconDrawable(info, context);
+ drawable = new PlaceHolderIconDrawable(info, context);
} else {
- return new FastBitmapDrawable(info);
+ drawable = new FastBitmapDrawable(info);
}
+ drawable.mDisabledAlpha = Themes.getFloat(context, R.attr.disabledIconAlpha, 1f);
+ return drawable;
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index a45c96c..e375bdd 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -277,6 +277,10 @@
}
}
+ public LayoutInflater getLayoutInflater() {
+ return LayoutInflater.from(getContext());
+ }
+
/**
* Resets the state of AllApps.
*/
@@ -444,7 +448,7 @@
int index = indexOfChild(oldView);
removeView(oldView);
int layout = showTabs ? R.layout.all_apps_tabs : R.layout.all_apps_rv_layout;
- View newView = LayoutInflater.from(getContext()).inflate(layout, this, false);
+ View newView = getLayoutInflater().inflate(layout, this, false);
addView(newView, index);
if (showTabs) {
mViewPager = (AllAppsPagedView) newView;
@@ -617,7 +621,7 @@
AdapterHolder(boolean isWork) {
mIsWork = isWork;
appsList = new AlphabeticalAppsList(mLauncher, mAllAppsStore, isWork);
- adapter = new AllAppsGridAdapter(mLauncher, appsList);
+ adapter = new AllAppsGridAdapter(mLauncher, getLayoutInflater(), appsList);
appsList.setAdapter(adapter);
layoutManager = adapter.getLayoutManager();
}
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 3afa756..8ec4d27 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -188,7 +188,8 @@
// The intent to send off to the market app, updated each time the search query changes.
private Intent mMarketSearchIntent;
- public AllAppsGridAdapter(BaseDraggingActivity launcher, AlphabeticalAppsList apps) {
+ public AllAppsGridAdapter(BaseDraggingActivity launcher, LayoutInflater inflater,
+ AlphabeticalAppsList apps) {
Resources res = launcher.getResources();
mLauncher = launcher;
mApps = apps;
@@ -196,7 +197,7 @@
mGridSizer = new GridSpanSizer();
mGridLayoutMgr = new AppsGridLayoutManager(launcher);
mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
- mLayoutInflater = LayoutInflater.from(launcher);
+ mLayoutInflater = inflater;
mOnIconClickListener = launcher.getItemOnClickListener();
diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java
index da59afe..b74686f 100644
--- a/src/com/android/launcher3/util/Themes.java
+++ b/src/com/android/launcher3/util/Themes.java
@@ -113,10 +113,17 @@
* Returns the alpha corresponding to the theme attribute {@param attr}, in the range [0, 255].
*/
public static int getAlpha(Context context, int attr) {
+ return (int) (255 * getFloat(context, attr, 0) + 0.5f);
+ }
+
+ /**
+ * Returns the alpha corresponding to the theme attribute {@param attr}
+ */
+ public static float getFloat(Context context, int attr, float defValue) {
TypedArray ta = context.obtainStyledAttributes(new int[]{attr});
- float alpha = ta.getFloat(0, 0);
+ float value = ta.getFloat(0, defValue);
ta.recycle();
- return (int) (255 * alpha + 0.5f);
+ return value;
}
/**