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

Commit 076f5448 authored by Sergey Ten's avatar Sergey Ten
Browse files

Add support for theme appearance name.

CR:JoshG.
parent d4d397f3
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -32642,6 +32642,16 @@
 visibility="public"
>
</field>
<field name="themeStyleName"
 type="java.lang.String"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="thumbnail"
 type="int"
 transient="false"
@@ -35976,6 +35986,8 @@
>
<parameter name="parser" type="org.xmlpull.v1.XmlPullParser">
</parameter>
<parameter name="res" type="android.content.res.Resources">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
@@ -36009,6 +36021,8 @@
>
<parameter name="parser" type="org.xmlpull.v1.XmlPullParser">
</parameter>
<parameter name="res" type="android.content.res.Resources">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
+21 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@ package android.content.pm;
import android.os.Parcelable;
import android.os.Parcel;
import android.util.Log;
import android.util.AttributeSet;
import android.content.res.Resources;

public class BaseThemeInfo implements Parcelable {

@@ -129,6 +131,14 @@ public class BaseThemeInfo implements Parcelable {
    // This flag is set to true iff any media resource is DRM protected
    public boolean isDrmProtected = false;

    /**
     * The name of the "main" theme style (as displayed by UI).
     *
     * @see themeStyleName attribute
     *
     */
    public String themeStyleName;

    /**
     * {@hide}
     */
@@ -192,6 +202,7 @@ public class BaseThemeInfo implements Parcelable {
        dest.writeString(copyright);
        dest.writeInt(isDrmProtected? 1 : 0);
        dest.writeString(soundPackName);
        dest.writeString(themeStyleName);
    }

    /** @hide */
@@ -206,6 +217,15 @@ public class BaseThemeInfo implements Parcelable {
        }
    };

    /** @hide */
    public final String getResolvedString(Resources res, AttributeSet attrs, int index) {
        int resId = attrs.getAttributeResourceValue(index, 0);
        if (resId !=0 ) {
            return res.getString(resId);
        }
        return attrs.getAttributeValue(index);
    }

    protected BaseThemeInfo() {
    }

@@ -226,6 +246,7 @@ public class BaseThemeInfo implements Parcelable {
        copyright = source.readString();
        isDrmProtected = (source.readInt() != 0);
        soundPackName = source.readString();
        themeStyleName = source.readString();
    }

    protected void changeDrmFlagIfNeeded(String resourcePath) {
+2 −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(parser, attrs));
                pkg.mThemeInfos.add(new ThemeInfo(parser, res, attrs));
            } else if (tagName.equals("sounds")) {
                // this is a theme apk.
                pkg.mIsThemeApk = true;
                pkg.mSoundInfos.add(new SoundsInfo(parser, attrs));
                pkg.mSoundInfos.add(new SoundsInfo(parser, res, attrs));
            } else if (RIGID_PARSER) {
                outError[0] = "Bad element under <manifest>: "
                    + parser.getName();
+5 −4
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import org.xmlpull.v1.XmlPullParser;
import android.os.Parcelable;
import android.os.Parcel;
import android.util.AttributeSet;
import android.content.res.Resources;

import java.util.Map;
import java.util.HashMap;
@@ -96,7 +97,7 @@ public class SoundsInfo extends BaseThemeInfo {
    private static final int COPYRIGHT_INDEX = 7;


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

        type = InfoObjectType.TYPE_SOUNDPACK;
@@ -112,7 +113,7 @@ public class SoundsInfo extends BaseThemeInfo {

                switch (index) {
                    case NAME_INDEX:
                        name = attrs.getAttributeValue(i);
                        name = getResolvedString(res, attrs, i);
                        break;

                    case THUMBNAIL_INDEX:
@@ -120,7 +121,7 @@ public class SoundsInfo extends BaseThemeInfo {
                        break;

                    case AUTHOR_INDEX:
                        author = attrs.getAttributeValue(i);
                        author = getResolvedString(res, attrs, i);
                        break;

                    case RINGTONE_FILE_NAME_INDEX:
@@ -141,7 +142,7 @@ public class SoundsInfo extends BaseThemeInfo {
                        notificationRingtoneName = attrs.getAttributeValue(i);

                    case COPYRIGHT_INDEX:
                        copyright = attrs.getAttributeValue(i);
                        copyright = getResolvedString(res, attrs, i);
                        break;
                }
            }
+26 −14
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ import org.xmlpull.v1.XmlPullParser;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.content.res.Resources;

/**
 * Overall information about "theme" package.  This corresponds
@@ -57,65 +58,71 @@ public final class ThemeInfo extends BaseThemeInfo {
     */
    private static final int THEME_INDEX = 3;

    /**
     * {@link #themeStyleName}
     *
     */
    private static final int THEME_STYLE_NAME_INDEX = 4;

    /**
     * {@link #ringtoneName}
     *
     */
    private static final int RINGTONE_FILE_NAME_INDEX = 4;
    private static final int RINGTONE_FILE_NAME_INDEX = 5;

    /**
     * {@link #notificationRingtoneName}
     *
     */
    private static final int NOTIFICATION_RINGTONE_FILE_NAME_INDEX = 5;
    private static final int NOTIFICATION_RINGTONE_FILE_NAME_INDEX = 6;

    /**
     * {@link #favesImageName}
     *
     */
    private static final int FAVES_IMAGE_NAME_INDEX = 6;
    private static final int FAVES_IMAGE_NAME_INDEX = 7;

    /**
     * {@link #favesAppImageName}
     *
     */
    private static final int FAVES_APP_IMAGE_NAME_INDEX = 7;
    private static final int FAVES_APP_IMAGE_NAME_INDEX = 8;

    /**
     * {@link #wallpaperImageName}
     *
     */
    private static final int WALLPAPER_IMAGE_NAME_INDEX = 8;
    private static final int WALLPAPER_IMAGE_NAME_INDEX = 9;

    /**
     * {@link #copyright}
     *
     */
    private static final int COPYRIGHT_INDEX = 9;
    private static final int COPYRIGHT_INDEX = 10;

    /**
     * {@link #ringtoneName}
     *
     */
    private static final int RINGTONE_NAME_INDEX = 10;
    private static final int RINGTONE_NAME_INDEX = 11;

    /**
     * {@link #notificationRingtoneName}
     *
     */
    private static final int NOTIFICATION_RINGTONE_NAME_INDEX = 11;
    private static final int NOTIFICATION_RINGTONE_NAME_INDEX = 12;

    /**
     * {@link #soundPackName}
     *
     */
    private static final int SOUNDPACK_NAME_INDEX = 12;
    private static final int SOUNDPACK_NAME_INDEX = 13;

    /**
     * {@link #styleResourceId}
     *
     */
    private static final int STYLE_INDEX = 13;
    private static final int STYLE_INDEX = 14;


    private static final String [] compulsoryAttributes = new String [] {
@@ -123,6 +130,7 @@ public final class ThemeInfo extends BaseThemeInfo {
        "thumbnail",
        "author",
        "themeId",
        "styleName",
    };

    private static final String [] optionalAttributes = new String [] {
@@ -151,7 +159,7 @@ public final class ThemeInfo extends BaseThemeInfo {
        }
    }

    public ThemeInfo(XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException {
    public ThemeInfo(XmlPullParser parser, Resources res, AttributeSet attrs) throws XmlPullParserException {
        super();

        type = InfoObjectType.TYPE_THEME;
@@ -172,7 +180,7 @@ public final class ThemeInfo extends BaseThemeInfo {
                switch (index) {
                    case THEME_PACKAGE_INDEX:
                        // theme name
                        name = attrs.getAttributeValue(i);
                        name = getResolvedString(res, attrs, i);
                        break;

                    case THUMBNAIL_INDEX:
@@ -182,7 +190,7 @@ public final class ThemeInfo extends BaseThemeInfo {

                    case AUTHOR_INDEX:
                        // theme author
                        author = attrs.getAttributeValue(i);
                        author = getResolvedString(res, attrs, i);
                        break;

                    case THEME_INDEX:
@@ -190,6 +198,10 @@ public final class ThemeInfo extends BaseThemeInfo {
                        themeId = attrs.getAttributeValue(i);
                        break;

                    case THEME_STYLE_NAME_INDEX:
                        themeStyleName = getResolvedString(res, attrs, i);
                        break;

                    case RINGTONE_FILE_NAME_INDEX:
                        // ringtone
                        ringtoneFileName = attrs.getAttributeValue(i);
@@ -222,7 +234,7 @@ public final class ThemeInfo extends BaseThemeInfo {

                    case COPYRIGHT_INDEX:
                        // themeCopyright attribute
                        copyright = attrs.getAttributeValue(i);
                        copyright = getResolvedString(res, attrs, i);
                        break;

                    case RINGTONE_NAME_INDEX: