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

Commit 8fd86318 authored by Sergey Ten's avatar Sergey Ten Committed by Josh Guilfoyle
Browse files

Make colors theme'able

parent 4d6b7693
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import android.content.Context;

import java.io.IOException;
import java.io.InputStream;
@@ -82,6 +83,8 @@ public class Resources {
    /*package*/ final DisplayMetrics mMetrics = new DisplayMetrics();
    PluralRules mPluralRule;

    private Context context;

    /**
     * This exception is thrown by the resource APIs when a requested resource
     * can not be found.
@@ -877,6 +880,20 @@ public class Resources {
        throw new NotFoundException("String resource name " + name);
    }

    /**
     * @hide
     */
    public Context getContext() {
        return context;
    }

    /**
     * @hide
     */
    public void setContext(Context _context) {
        context = _context;
    }

    /**
     * This class holds the current attribute values for a particular theme.
     * In other words, a Theme is a set of values for resource attributes;
+6 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.content.Context;
import com.android.internal.util.XmlUtils;

import java.util.Arrays;
@@ -268,6 +269,9 @@ public class TypedArray {
                return csl.getDefaultColor();
            }
            return defValue;
        } else if (type == TypedValue.TYPE_ATTRIBUTE && mResources.getContext() != null) {
            mResources.getContext().getTheme().resolveAttribute(data[index+AssetManager.STYLE_DATA], mValue, true);
            return mValue.data;
        }

        throw new UnsupportedOperationException("Can't convert to color: type=0x"
+2 −0
Original line number Diff line number Diff line
@@ -1722,7 +1722,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
            int attr = a.getIndex(i);
            switch (attr) {
                case com.android.internal.R.styleable.View_background:
                    a.getResources().setContext(context);
                    background = a.getDrawable(attr);
                    a.getResources().setContext(null);
                    break;
                case com.android.internal.R.styleable.View_padding:
                    padding = a.getDimensionPixelSize(attr, -1);