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

Commit 6796d78d authored by Sergey Ten's avatar Sergey Ten Committed by Josh Guilfoyle
Browse files

This check in adds support for isThemeable attribute for applications and...

This check in adds support for isThemeable attribute for applications and activities. The idea is that theme engine will be able to use isThemeable value to decide whether particular application/activity should be left alone or should be themed.
parent eb851dc3
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -31595,6 +31595,17 @@
 visibility="public"
>
</field>
<field name="PLUTO_ISTHEMEABLE_ATTRIBUTE_NAME"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;isThemeable&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="className"
 type="java.lang.String"
 transient="false"
@@ -35086,6 +35097,8 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="parser" type="org.xmlpull.v1.XmlPullParser">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
@@ -35235,6 +35248,8 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="parser" type="org.xmlpull.v1.XmlPullParser">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
+43 −1
Original line number Diff line number Diff line
@@ -272,6 +272,44 @@ public class ActivityInfo extends ComponentInfo
     */
    public int softInputMode;

    /**
     * isThemeable flag is not explicitly set - use isThemeable value from ApllicationInfo.
     */
    private static final int ISTHEMEABLE_INHERITED = 0;

    /**
     * isThemeable flag is explicitly set to false.
     */
    private static final int ISTHEMEABLE_FALSE = 1;

    /**
     * isThemeable flag is explicitly set to true.
     */
    private static final int ISTHEMEABLE_TRUE = 2;

    /**
     * Is given activity theme agnostic, i.e. behaves properly when default theme is changed.
     *  {@hide}
     */
    private int isThemeable = ISTHEMEABLE_INHERITED;

    /**
     *  {@hide}
     */
    public boolean getIsThemeable() {
        if (isThemeable == ISTHEMEABLE_INHERITED) {
            return applicationInfo != null && applicationInfo.isThemeable;
        }
        return isThemeable != ISTHEMEABLE_FALSE;
    }

    /**
     *  {@hide}
     */
    public void setIsThemeable(boolean value) {
        isThemeable = value? ISTHEMEABLE_TRUE : ISTHEMEABLE_FALSE;
    }

    public ActivityInfo() {
    }

@@ -286,6 +324,7 @@ public class ActivityInfo extends ComponentInfo
        screenOrientation = orig.screenOrientation;
        configChanges = orig.configChanges;
        softInputMode = orig.softInputMode;
        isThemeable = orig.isThemeable;
    }
    
    /**
@@ -310,6 +349,7 @@ public class ActivityInfo extends ComponentInfo
        pw.println(prefix + "screenOrientation=" + screenOrientation
                + " configChanges=0x" + Integer.toHexString(configChanges)
                + " softInputMode=0x" + Integer.toHexString(softInputMode));
        pw.println(prefix + "isThemeable=" + isThemeable);
        super.dumpBack(pw, prefix);
    }
    
@@ -334,6 +374,7 @@ public class ActivityInfo extends ComponentInfo
        dest.writeInt(screenOrientation);
        dest.writeInt(configChanges);
        dest.writeInt(softInputMode);
        dest.writeInt(isThemeable);
    }

    public static final Parcelable.Creator<ActivityInfo> CREATOR
@@ -357,5 +398,6 @@ public class ActivityInfo extends ComponentInfo
        screenOrientation = source.readInt();
        configChanges = source.readInt();
        softInputMode = source.readInt();
        isThemeable = source.readInt();
    }
}
+21 −0
Original line number Diff line number Diff line
@@ -167,6 +167,24 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public boolean enabled = true;

    /**
     * Is given application theme agnostic, i.e. behaves properly when default theme is changed.
     *  {@hide}
     */
    public boolean isThemeable = false;

    private static final String PLUTO_SCHEMA = "http://www.w3.org/2001/pluto.html";

    public static final String PLUTO_ISTHEMEABLE_ATTRIBUTE_NAME = "isThemeable";

    /**
     *
     *  @hide
     */
    public static boolean isPlutoNamespace(String namespace) {
        return namespace != null && namespace.equalsIgnoreCase(PLUTO_SCHEMA);
    }

    public void dump(Printer pw, String prefix) {
        super.dumpFront(pw, prefix);
        pw.println(prefix + "className=" + className);
@@ -228,6 +246,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        enabled = orig.enabled;
        manageSpaceActivityName = orig.manageSpaceActivityName;
        descriptionRes = orig.descriptionRes;
        isThemeable = orig.isThemeable;
    }


@@ -257,6 +276,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeInt(enabled ? 1 : 0);
        dest.writeString(manageSpaceActivityName);
        dest.writeInt(descriptionRes);
        dest.writeInt(isThemeable? 1 : 0);
    }

    public static final Parcelable.Creator<ApplicationInfo> CREATOR
@@ -285,6 +305,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        enabled = source.readInt() != 0;
        manageSpaceActivityName = source.readString();
        descriptionRes = source.readInt();
        isThemeable = source.readInt() != 0;
    }
    
    /**
+30 −2
Original line number Diff line number Diff line
@@ -743,11 +743,11 @@ public class PackageParser {
            } else if (tagName.equals("theme")) {
                // this is a theme apk.
                pkg.mIsThemeApk = true;
                pkg.mThemeInfos.add(new ThemeInfo(attrs));
                pkg.mThemeInfos.add(new ThemeInfo(parser, attrs));
            } else if (tagName.equals("sounds")) {
                // this is a theme apk.
                pkg.mIsThemeApk = true;
                pkg.mSoundInfos.add(new SoundsInfo(attrs));
                pkg.mSoundInfos.add(new SoundsInfo(parser, attrs));
            } else if (RIGID_PARSER) {
                outError[0] = "Bad element under <manifest>: "
                    + parser.getName();
@@ -1041,12 +1041,26 @@ public class PackageParser {
        return a;
    }

    private void setIsThemeable(XmlPullParser parser, AttributeSet attrs, ApplicationInfo ai) {
        for (int i = 0; i < attrs.getAttributeCount(); i++) {
            if (!ApplicationInfo.isPlutoNamespace(parser.getAttributeNamespace(i))) {
                continue;
            }
            if (attrs.getAttributeName(i).equalsIgnoreCase(ApplicationInfo.PLUTO_ISTHEMEABLE_ATTRIBUTE_NAME)) {
                ai.isThemeable = attrs.getAttributeBooleanValue(i, false);
                return;
            }
        }
    }

    private boolean parseApplication(Package owner, Resources res,
            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
        throws XmlPullParserException, IOException {
        final ApplicationInfo ai = owner.applicationInfo;
        final String pkgName = owner.applicationInfo.packageName;

        setIsThemeable(parser, attrs, ai);

        TypedArray sa = res.obtainAttributes(attrs,
                com.android.internal.R.styleable.AndroidManifestApplication);

@@ -1285,6 +1299,18 @@ public class PackageParser {
        return outError[0] == null;
    }

    private void setIsThemeableForActivity(XmlPullParser parser, AttributeSet attrs, ActivityInfo ai) {
        for (int i = 0; i < attrs.getAttributeCount(); i++) {
            if (!ApplicationInfo.isPlutoNamespace(parser.getAttributeNamespace(i))) {
                continue;
            }
            if (attrs.getAttributeName(i).equalsIgnoreCase(ApplicationInfo.PLUTO_ISTHEMEABLE_ATTRIBUTE_NAME)) {
                ai.setIsThemeable(attrs.getAttributeBooleanValue(i, false));
                return;
            }
        }
    }

    private Activity parseActivity(Package owner, Resources res,
            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError,
            boolean receiver) throws XmlPullParserException, IOException {
@@ -1293,6 +1319,8 @@ public class PackageParser {

        Activity a = new Activity(owner);

        setIsThemeableForActivity(parser, attrs, a.info);

        if (!parseComponentInfo(owner, flags, a.info, outError,
                receiver ? "<receiver>" : "<activity>", sa,
                com.android.internal.R.styleable.AndroidManifestActivity_name,
+5 −1
Original line number Diff line number Diff line
package android.content.pm;

import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParser;

import android.os.Parcelable;
import android.os.Parcel;
@@ -95,12 +96,15 @@ public class SoundsInfo extends BaseThemeInfo {
    private static final int COPYRIGHT_INDEX = 7;


    public SoundsInfo(AttributeSet attrs) throws XmlPullParserException {
    public SoundsInfo(XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException {
        super();

        type = InfoObjectType.TYPE_SOUNDPACK;
        Map<String, Integer> tempMap = new HashMap<String, Integer>(attributesLookupTable);
        for (int i = 0; i < attrs.getAttributeCount(); i++) {
            if (!ApplicationInfo.isPlutoNamespace(parser.getAttributeNamespace(i))) {
                continue;
            }
            String key = attrs.getAttributeName(i);
            if (tempMap.containsKey(key)) {
                int index = tempMap.get(key);
Loading