Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2974809 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #2116977: buttons are huge and bent

Now that we are using preloaded drawables in compatibilty mode, when
constructing them from their constant state we need to set the new
drawable's target density appropriately.

Change-Id: I3665cbea09d38b9ac5f45f8c380dc8641f86b266
parent e7f47f50
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -63348,6 +63348,16 @@
<parameter name="bitmap" type="android.graphics.Bitmap">
</parameter>
</constructor>
<constructor name="BitmapDrawable"
 type="android.graphics.drawable.BitmapDrawable"
 static="false"
 final="false"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="filepath" type="java.lang.String">
</parameter>
</constructor>
<constructor name="BitmapDrawable"
 type="android.graphics.drawable.BitmapDrawable"
 static="false"
@@ -63355,9 +63365,21 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="res" type="android.content.res.Resources">
</parameter>
<parameter name="filepath" type="java.lang.String">
</parameter>
</constructor>
<constructor name="BitmapDrawable"
 type="android.graphics.drawable.BitmapDrawable"
 static="false"
 final="false"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="is" type="java.io.InputStream">
</parameter>
</constructor>
<constructor name="BitmapDrawable"
 type="android.graphics.drawable.BitmapDrawable"
 static="false"
@@ -63365,6 +63387,8 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="res" type="android.content.res.Resources">
</parameter>
<parameter name="is" type="java.io.InputStream">
</parameter>
</constructor>
@@ -64543,6 +64567,19 @@
 visibility="public"
>
</method>
<method name="newDrawable"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="res" type="android.content.res.Resources">
</parameter>
</method>
</class>
<class name="DrawableContainer"
 extends="android.graphics.drawable.Drawable"
+3 −3
Original line number Diff line number Diff line
@@ -395,7 +395,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
            Drawable.ConstantState cachedBg = mBackgroundsCache.get(backgroundColor);
            if (cachedBg != null) {
                if (DBG) Log.d(LOG_TAG, "Background cache hit for color " + backgroundColor);
                return cachedBg.newDrawable();
                return cachedBg.newDrawable(mProviderContext.getResources());
            }
            if (DBG) Log.d(LOG_TAG, "Creating new background for color " + backgroundColor);
            ColorDrawable transparent = new ColorDrawable(0);
@@ -572,7 +572,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
        Drawable.ConstantState cached = mOutsideDrawablesCache.get(drawableId);
        if (cached != null) {
            if (DBG) Log.d(LOG_TAG, "Found icon in cache: " + drawableId);
            return cached.newDrawable();
            return cached.newDrawable(mProviderContext.getResources());
        }

        Drawable drawable = null;
@@ -663,7 +663,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
        // Using containsKey() since we also store null values.
        if (mOutsideDrawablesCache.containsKey(componentIconKey)) {
            Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey);
            return cached == null ? null : cached.newDrawable();
            return cached == null ? null : cached.newDrawable(mProviderContext.getResources());
        }
        // Then try the activity or application icon
        Drawable drawable = getActivityIcon(component);
+2 −2
Original line number Diff line number Diff line
@@ -1662,7 +1662,7 @@ public class Resources {

        Drawable.ConstantState cs = sPreloadedDrawables.get(key);
        if (cs != null) {
            dr = cs.newDrawable();
            dr = cs.newDrawable(this);
        } else {
            if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT &&
                    value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
@@ -1743,7 +1743,7 @@ public class Resources {
                    //Log.i(TAG, "Returning cached drawable @ #" +
                    //        Integer.toHexString(((Integer)key).intValue())
                    //        + " in " + this + ": " + entry);
                    return entry.newDrawable();
                    return entry.newDrawable(this);
                }
                else {  // our entry has been purged
                    mDrawableCache.delete(key);
+3 −1
Original line number Diff line number Diff line
@@ -282,7 +282,9 @@ public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuVi
        itemView.setIconMenuView(this);
        
        // Apply the background to the item view
        itemView.setBackgroundDrawable(mItemBackground.getConstantState().newDrawable());
        itemView.setBackgroundDrawable(
                mItemBackground.getConstantState().newDrawable(
                        getContext().getResources()));

        // This class is the invoker for all its item views 
        itemView.setItemInvoker(this);
+16 −6
Original line number Diff line number Diff line
@@ -45,11 +45,11 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
    private boolean mRunning;

    public AnimatedRotateDrawable() {
        this(null);
        this(null, null);
    }

    private AnimatedRotateDrawable(AnimatedRotateState rotateState) {
        mState = new AnimatedRotateState(rotateState, this);
    private AnimatedRotateDrawable(AnimatedRotateState rotateState, Resources res) {
        mState = new AnimatedRotateState(rotateState, this, res);
        init();
    }

@@ -296,9 +296,14 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
        private boolean mCanConstantState;
        private boolean mCheckedConstantState;        

        public AnimatedRotateState(AnimatedRotateState source, AnimatedRotateDrawable owner) {
        public AnimatedRotateState(AnimatedRotateState source, AnimatedRotateDrawable owner,
                Resources res) {
            if (source != null) {
                if (res != null) {
                    mDrawable = source.mDrawable.getConstantState().newDrawable(res);
                } else {
                    mDrawable = source.mDrawable.getConstantState().newDrawable();
                }
                mDrawable.setCallback(owner);
                mPivotXRel = source.mPivotXRel;
                mPivotX = source.mPivotX;
@@ -312,7 +317,12 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac

        @Override
        public Drawable newDrawable() {
            return new AnimatedRotateDrawable(this);
            return new AnimatedRotateDrawable(this, null);
        }
        
        @Override
        public Drawable newDrawable(Resources res) {
            return new AnimatedRotateDrawable(this, res);
        }
        
        @Override
Loading