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

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

Fix animations for app QS tiles. am: d2274f84

am: 46f24b67

Change-Id: Ibf818c7f003a9f79483b09b6b0e2f3756e0e563b
parents 082a27eb 46f24b67
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
@@ -474,10 +474,19 @@ public abstract class QSTile<TState extends State> {
        public Drawable getDrawable(Context context) {
        public Drawable getDrawable(Context context) {
            return mDrawable;
            return mDrawable;
        }
        }
    }

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

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


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


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


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


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


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