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

Commit 962378f4 authored by d34d's avatar d34d Committed by Clark Scheff
Browse files

Get themed resources in KeyButtonView

When saving a customized button layout for the navigation bar, the
buttons load resources from the theme applied to systemui, regardless
if the navigation bar is being themed by a different package.  This
is not correct behavior.

Change-Id: I4e44ef517c2ea9ac3828e790f6a4b850726bc840
REF: NIGHTLIES-1377
parent 738f5a87
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ package com.android.systemui.statusbar.policy;

import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.ThemeConfig;
import android.content.res.TypedArray;
import android.hardware.input.InputManager;
import android.media.AudioManager;
@@ -126,6 +129,27 @@ public class KeyButtonView extends ImageView {
        return super.performAccessibilityActionInternal(action, arguments);
    }

    @Override
    public Resources getResources() {
        ThemeConfig themeConfig = mContext.getResources().getConfiguration().themeConfig;
        Resources res = null;
        if (themeConfig != null) {
            try {
                final String navbarThemePkgName = themeConfig.getOverlayForNavBar();
                final String sysuiThemePkgName = themeConfig.getOverlayForStatusBar();
                // Check if the same theme is applied for systemui, if so we can skip this
                if (navbarThemePkgName != null && !navbarThemePkgName.equals(sysuiThemePkgName)) {
                    res = mContext.getPackageManager().getThemedResourcesForApplication(
                            mContext.getPackageName(), navbarThemePkgName);
                }
            } catch (PackageManager.NameNotFoundException e) {
                // don't care since we'll handle res being null below
            }
        }

        return res != null ? res : super.getResources();
    }

    public boolean onTouchEvent(MotionEvent ev) {
        final int action = ev.getAction();
        int x, y;