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

Commit 86be4a4d authored by Adnan Begovic's avatar Adnan Begovic
Browse files

SystemUI: Add support for external bitmap icons.

Change-Id: Ib7340fa3f616a28a4d12bc7585f80cdf794d5893
parent 8c415695
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.qs;
package com.android.systemui.qs;


import android.content.Context;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Log;
@@ -112,6 +113,7 @@ public class QSDetailItemsGrid extends PseudoGridView {
                    mContext, convertView, parent);
                    mContext, convertView, parent);
            CustomTile.ExpandedItem item = getItem(i);
            CustomTile.ExpandedItem item = getItem(i);
            Drawable d = null;
            Drawable d = null;
            if (item.itemDrawableResourceId != 0 && item.itemBitmapResource == null) {
                try {
                try {
                    d = getPackageContext(mPkg, mContext).getResources()
                    d = getPackageContext(mPkg, mContext).getResources()
                            .getDrawable(item.itemDrawableResourceId);
                            .getDrawable(item.itemDrawableResourceId);
@@ -119,6 +121,9 @@ public class QSDetailItemsGrid extends PseudoGridView {
                    Log.w(TAG, "Error creating package context" + mPkg +
                    Log.w(TAG, "Error creating package context" + mPkg +
                            " id=" + item.itemDrawableResourceId, t);
                            " id=" + item.itemDrawableResourceId, t);
                }
                }
            } else {
                d = new BitmapDrawable(mContext.getResources(), item.itemBitmapResource);
            }
            if (v != convertView) {
            if (v != convertView) {
                v.setOnClickListener(this);
                v.setOnClickListener(this);
            }
            }
+11 −6
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.qs;
package com.android.systemui.qs;


import android.content.Context;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.AttributeSet;
@@ -116,6 +117,7 @@ public class QSDetailItemsList extends LinearLayout {


            final CustomTile.ExpandedItem item = getItem(position);
            final CustomTile.ExpandedItem item = getItem(position);
            Drawable d = null;
            Drawable d = null;
            if (item.itemDrawableResourceId != 0 && item.itemBitmapResource == null) {
                try {
                try {
                    d = getPackageContext(mPackage, getContext()).getResources()
                    d = getPackageContext(mPackage, getContext()).getResources()
                            .getDrawable(item.itemDrawableResourceId);
                            .getDrawable(item.itemDrawableResourceId);
@@ -123,6 +125,9 @@ public class QSDetailItemsList extends LinearLayout {
                    Log.w(TAG, "Error creating package context" + mPackage +
                    Log.w(TAG, "Error creating package context" + mPackage +
                            " id=" + item.itemDrawableResourceId, t);
                            " id=" + item.itemDrawableResourceId, t);
                }
                }
            } else {
                d = new BitmapDrawable(getContext().getResources(), item.itemBitmapResource);
            }
            final ImageView iv = (ImageView) view.findViewById(android.R.id.icon);
            final ImageView iv = (ImageView) view.findViewById(android.R.id.icon);
            iv.setImageDrawable(d);
            iv.setImageDrawable(d);
            iv.getOverlay().clear();
            iv.getOverlay().clear();
+17 −0
Original line number Original line Diff line number Diff line
@@ -18,7 +18,9 @@ package com.android.systemui.qs;


import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
@@ -395,6 +397,21 @@ public abstract class QSTile<TState extends State> implements Listenable {
        }
        }
    }
    }


    protected class ExternalBitmapIcon extends Icon {
        private Bitmap mBitmap;

        public ExternalBitmapIcon(Bitmap bitmap) {
            mBitmap = bitmap;
        }

        @Override
        public Drawable getDrawable(Context context) {
            // This is gross
            BitmapDrawable bitmapDrawable = new BitmapDrawable(context.getResources(), mBitmap);
            return bitmapDrawable;
        }
    }

    protected class AnimationIcon extends ResourceIcon {
    protected class AnimationIcon extends ResourceIcon {
        private boolean mAllowAnimation;
        private boolean mAllowAnimation;


+3 −1
Original line number Original line Diff line number Diff line
@@ -123,13 +123,15 @@ public class CustomQSTile extends QSTile<QSTile.State> {
        state.iconId = 0;
        state.iconId = 0;
        state.visible = true;
        state.visible = true;
        final int iconId = customTile.icon;
        final int iconId = customTile.icon;
        if (iconId != 0) {
        if (iconId != 0 && (customTile.remoteIcon == null)) {
            final String iconPackage = mTile.getResPkg();
            final String iconPackage = mTile.getResPkg();
            if (!TextUtils.isEmpty(iconPackage)) {
            if (!TextUtils.isEmpty(iconPackage)) {
                state.icon = new ExternalIcon(iconPackage, iconId);
                state.icon = new ExternalIcon(iconPackage, iconId);
            } else {
            } else {
                state.iconId = iconId;
                state.iconId = iconId;
            }
            }
        } else {
            state.icon = new ExternalBitmapIcon(customTile.remoteIcon);
        }
        }
        mOnClick = customTile.onClick;
        mOnClick = customTile.onClick;
        mOnClickUri = customTile.onClickUri;
        mOnClickUri = customTile.onClickUri;