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

Commit 46f24b67 authored by Jason Monk's avatar Jason Monk Committed by android-build-merger
Browse files

Fix animations for app QS tiles.

am: d2274f84

Change-Id: I32fdb2e9047e402650e374024fcc7cb39b2a83f9
parents c07e5b5d d2274f84
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -486,10 +486,19 @@ public abstract class QSTile<TState extends State> {
        public Drawable getDrawable(Context context) {
            return mDrawable;
        }
    }

    public static class DrawableIconWithRes extends DrawableIcon {
        private final int mId;

        public DrawableIconWithRes(Drawable drawable, int id) {
            super(drawable);
            mId = id;
        }

        @Override
        public Drawable getInvisibleDrawable(Context context) {
            return mDrawable;
        public boolean equals(Object o) {
            return o instanceof DrawableIconWithRes && ((DrawableIconWithRes) o).mId == mId;
        }
    }

+15 −3
Original line number Diff line number Diff line
@@ -17,11 +17,14 @@ package com.android.systemui.qs.external;

import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Binder;
import android.os.IBinder;
@@ -60,6 +63,7 @@ public class CustomTile extends QSTile<QSTile.State> implements TileChangeListen
    private final IQSTileService mService;
    private final TileServiceManager mServiceManager;
    private final int mUser;
    private Context mAppContext;
    private android.graphics.drawable.Icon mDefaultIcon;

    private boolean mListening;
@@ -77,6 +81,10 @@ public class CustomTile extends QSTile<QSTile.State> implements TileChangeListen
        mService = mServiceManager.getTileService();
        mServiceManager.setTileChangeListener(this);
        mUser = ActivityManager.getCurrentUser();
        try {
            mAppContext = mContext.createPackageContext(mComponent.getPackageName(), 0);
        } catch (NameNotFoundException e) {
        }
    }

    private void setTileIcon() {
@@ -280,16 +288,20 @@ public class CustomTile extends QSTile<QSTile.State> implements TileChangeListen
            tileState = Tile.STATE_UNAVAILABLE;
        }
        Drawable drawable;
        boolean mHasRes = false;
        android.graphics.drawable.Icon icon = mTile.getIcon();
        try {
            drawable = mTile.getIcon().loadDrawable(mContext);
            drawable = icon.loadDrawable(mAppContext);
            mHasRes = icon.getType() == android.graphics.drawable.Icon.TYPE_RESOURCE;
        } catch (Exception e) {
            Log.w(TAG, "Invalid icon, forcing into unavailable state");
            tileState = Tile.STATE_UNAVAILABLE;
            drawable = mDefaultIcon.loadDrawable(mContext);
            drawable = mDefaultIcon.loadDrawable(mAppContext);
        }
        int color = mContext.getColor(getColor(tileState));
        drawable.setTint(color);
        state.icon = new DrawableIcon(drawable);
        state.icon = mHasRes ? new DrawableIconWithRes(drawable, icon.getResId())
                : new DrawableIcon(drawable);
        state.label = mTile.getLabel();
        if (tileState == Tile.STATE_UNAVAILABLE) {
            state.label = new SpannableStringBuilder().append(state.label,