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

Commit d8984e69 authored by Clark Scheff's avatar Clark Scheff
Browse files

Use systemui's applied theme for notifications.

Notifications contain RemoteViews which are inflated using the
application's context for which this notification belongs to.  This
can look out of place if SystemUI is using a different theme than the
rest of the system.

This patch will use SystemUIs theme when inflating the RemoteViews,
giving us a more consistent look in the notification drawer.

Change-Id: I9514ce7fcc4858bad3d3c4190f55c1f5a1441d7c
parent 8b6001e1
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -2402,11 +2402,17 @@ public class RemoteViews implements Parcelable, Filter {

    /** @hide */
    public View apply(Context context, ViewGroup parent, OnClickHandler handler) {
        return apply(context, parent, handler, null);
    }

    /** @hide */
    public View apply(Context context, ViewGroup parent, OnClickHandler handler,
            String themePackageName) {
        RemoteViews rvToApply = getRemoteViewsToApply(context);

        View result;

        Context c = prepareContext(context);
        Context c = prepareContext(context, themePackageName);

        LayoutInflater inflater = (LayoutInflater)
                c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -2447,7 +2453,7 @@ public class RemoteViews implements Parcelable, Filter {
            }
        }

        prepareContext(context);
        prepareContext(context, null);
        rvToApply.performApply(v, (ViewGroup) v.getParent(), handler);
    }

@@ -2462,14 +2468,14 @@ public class RemoteViews implements Parcelable, Filter {
        }
    }

    private Context prepareContext(Context context) {
    private Context prepareContext(Context context, String themePackageName) {
        Context c;
        String packageName = mPackage;

        if (packageName != null) {
            try {
                c = context.createPackageContextAsUser(
                        packageName, Context.CONTEXT_RESTRICTED, mUser);
                c = context.createPackageContextAsUser(packageName, themePackageName,
                        Context.CONTEXT_RESTRICTED, mUser);
            } catch (NameNotFoundException e) {
                Log.e(LOG_TAG, "Package name " + packageName + " not found");
                c = context;
+8 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.content.pm.IPackageDataObserver;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.ThemeConfig;
import android.database.ContentObserver;
import android.graphics.Rect;
import android.net.Uri;
@@ -784,10 +785,15 @@ public abstract class BaseStatusBar extends SystemUI implements

        View contentViewLocal = null;
        View bigContentViewLocal = null;
        final ThemeConfig themeConfig = mContext.getResources().getConfiguration().themeConfig;
        String themePackageName = themeConfig != null ?
                themeConfig.getOverlayPkgNameForApp(mContext.getPackageName()) : null;
        try {
            contentViewLocal = contentView.apply(mContext, adaptive, mOnClickHandler);
            contentViewLocal = contentView.apply(mContext, adaptive, mOnClickHandler,
                    themePackageName);
            if (bigContentView != null) {
                bigContentViewLocal = bigContentView.apply(mContext, adaptive, mOnClickHandler);
                bigContentViewLocal = bigContentView.apply(mContext, adaptive, mOnClickHandler,
                        themePackageName);
            }
        }
        catch (RuntimeException e) {
+5 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Notification;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.ThemeConfig;
import android.database.ContentObserver;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -194,8 +195,10 @@ public class StatusBarIconView extends AnimatedImageView {
                if (userId == UserHandle.USER_ALL) {
                    userId = UserHandle.USER_OWNER;
                }
                r = context.getPackageManager()
                        .getResourcesForApplicationAsUser(icon.iconPackage, userId);
                PackageManager pm = context.getPackageManager();
                final ThemeConfig config = context.getResources().getConfiguration().themeConfig;
                final String pkgName = config.getOverlayPkgNameForApp(context.getPackageName());
                r = pm.getThemedResourcesForApplicationAsUser(icon.iconPackage, pkgName, userId);
            } catch (PackageManager.NameNotFoundException ex) {
                Log.e(TAG, "Icon package not found: " + icon.iconPackage);
                return null;