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

Commit 913f22a7 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by android-build-merger
Browse files

Merge "Update DecorContext's Resource cache when calling getResources." into pi-dev am: 33cb3b72

am: a4a5070d

Change-Id: I1c9dc4fd0ea55ffdb33fd0d0190cb1fae9964dce
parents 02995ec8 a4a5070d
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.view.ContextThemeWrapper;
import android.view.WindowManager;
import android.view.WindowManagerImpl;

import java.lang.ref.WeakReference;

/**
 * Context for decor views which can be seeded with pure application context and not depend on the
 * activity, but still provide some of the facilities that Activity has,
@@ -35,9 +37,12 @@ class DecorContext extends ContextThemeWrapper {
    private WindowManager mWindowManager;
    private Resources mActivityResources;

    public DecorContext(Context context, Resources activityResources) {
    private WeakReference<Context> mActivityContext;

    public DecorContext(Context context, Context activityContext) {
        super(context, null);
        mActivityResources = activityResources;
        mActivityContext = new WeakReference<>(activityContext);
        mActivityResources = activityContext.getResources();
    }

    void setPhoneWindow(PhoneWindow phoneWindow) {
@@ -60,6 +65,13 @@ class DecorContext extends ContextThemeWrapper {

    @Override
    public Resources getResources() {
        Context activityContext = mActivityContext.get();
        // Attempt to update the local cached Resources from the activity context. If the activity
        // is no longer around, return the old cached values.
        if (activityContext != null) {
            mActivityResources = activityContext.getResources();
        }

        return mActivityResources;
    }

+7 −0
Original line number Diff line number Diff line
@@ -1848,6 +1848,13 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        }
    }

    @Override
    public Resources getResources() {
        // Make sure the Resources object is propogated from the Context since it can be updated in
        // the Context object.
        return getContext().getResources();
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
+1 −1
Original line number Diff line number Diff line
@@ -2298,7 +2298,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            if (applicationContext == null) {
                context = getContext();
            } else {
                context = new DecorContext(applicationContext, getContext().getResources());
                context = new DecorContext(applicationContext, getContext());
                if (mTheme != -1) {
                    context.setTheme(mTheme);
                }