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

Unverified Commit 1a635fd0 authored by Steve Kondik's avatar Steve Kondik Committed by Michael Bestas
Browse files

themes: Import ThemeConfig, ThemeInfo, and ThemeVersion

 * These are CMSDK dependencies and required for themes support.

Change-Id: I5784f6d6b16313dbdbfb88090d3059bfbadaba06
parent 1c03376c
Loading
Loading
Loading
Loading
+75 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.content;

/**
 * Warning: Careful moving/refactoring this class as our SDK references it.
 * ThemeVersion 1 = CM11
 * ThemeVersion 2 = CM12/CM12.1 First Release
 * ThemeVersion 3 = CM12.1 W/ Wallpaper Packs
 * @hide
 */
public class ThemeVersion {
    /**
     *  Increment this anytime changes are made to:
     *  1) Changes to ThemesContract
     *  2) Changes to ThemeService API
     *  3) Changes to ThemeManager API
     */
    public static int THEME_VERSION = 3;

    /**
     * Change this if a change to the contract or service would break compatibility.
     * Example: A client app like chooser might be outdated from the framework.
     * It could then query the FW for this value and determine whether its safe to proceed.
     */
    public static int MIN_SUPPORTED_THEME_VERSION = 2;

    /**
     * Do not change the order of this. See SDK.
     * Increment the minSupportedVersion when the fw can no longer support a theme's apk structure
     * Increment currentVersion when a change to the theme's apk structure is changed
     * For example, CM11 to CM12 introduces new resources to overlay, so the overlays
     * version should change. Because the changes are not compatible with CM11, the minVersion
     * must change as well.
     *
     * If a new feature is added to a component (ex rotations in icon packs), the current version
     * for the ICON component would be incremented. If a new component is created, then add it
     * to the enum list.
     *
     * Wallpaper Version 2: Multi wallpaper ability
     *
     */
    public static enum ComponentVersion {
        OVERLAY(0, 2, 2),
        BOOT_ANIM(1, 1, 1),
        WALLPAPER(2, 1, 2),
        LOCKSCREEN(3, 1, 1),
        FONT(4, 1, 2),
        ICON(5, 1, 1),
        SOUNDS(6, 1, 1);

        public int id;
        public int minSupportedVersion;
        public int currentVersion;

        private ComponentVersion(int id, int minSupportedVersion, int currentVersion) {
            this.id = id;
            this.minSupportedVersion = minSupportedVersion;
            this.currentVersion = currentVersion;
        }
    }
}
+111 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010, T-Mobile USA, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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;

/**
 * @hide
 */
public class BaseThemeInfo implements Parcelable {
    /**
     * The theme id, which does not change when the theme is modified.
     * Specifies an Android UI Style using style name.
     *
     * @see themeId attribute
     *
     */
    public String themeId;

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

    /**
     * The author name of the theme package.
     *
     * @see author attribute
     *
     */
    public String author;

    /*
     * Describe the kinds of special objects contained in this Parcelable's
     * marshalled representation.
     *
     * @return a bitmask indicating the set of special object types marshalled
     * by the Parcelable.
     *
     * @see android.os.Parcelable#describeContents()
     */
    public int describeContents() {
        return 0;
    }

    /*
     * Flatten this object in to a Parcel.
     *
     * @param dest The Parcel in which the object should be written.
     * @param flags Additional flags about how the object should be written.
     * May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
     *
     * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
     */
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(themeId);
        dest.writeString(name);
        dest.writeString(author);
    }

    /** @hide */
    public static final Parcelable.Creator<BaseThemeInfo> CREATOR
            = new Parcelable.Creator<BaseThemeInfo>() {
        public BaseThemeInfo createFromParcel(Parcel source) {
            return new BaseThemeInfo(source);
        }

        public BaseThemeInfo[] newArray(int size) {
            return new BaseThemeInfo[size];
        }
    };

    /** @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() {
    }

    protected BaseThemeInfo(Parcel source) {
        themeId = source.readString();
        name = source.readString();
        author = source.readString();
    }
}
+3 −0
Original line number Diff line number Diff line
package android.content.pm;

parcelable ThemeInfo;
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010, T-Mobile USA, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.content.pm;

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

import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.content.res.Resources;

/**
 * Overall information about "theme" package.  This corresponds
 * to the information collected from AndroidManifest.xml
 *
 * Below is an example of the manifest:
 *
 * <meta-data android:name="org.cyanogenmod.theme.name" android:value="Foobar's Theme"/>
 * <meta-data android:name="org.cyanogenmod.theme.author" android:value="Mr.Foo" />
 *
 * @hide
 */
public final class ThemeInfo extends BaseThemeInfo {

    public static final String META_TAG_NAME = "org.cyanogenmod.theme.name";
    public static final String META_TAG_AUTHOR = "org.cyanogenmod.theme.author";

    public ThemeInfo(Bundle bundle) {
        super();
        name = bundle.getString(META_TAG_NAME);
        themeId = name;
        author = bundle.getString(META_TAG_AUTHOR);
    }

    public static final Parcelable.Creator<ThemeInfo> CREATOR
            = new Parcelable.Creator<ThemeInfo>() {
        public ThemeInfo createFromParcel(Parcel source) {
            return new ThemeInfo(source);
        }

        public ThemeInfo[] newArray(int size) {
            return new ThemeInfo[size];
        }
    };

    private ThemeInfo(Parcel source) {
        super(source);
    }
}
+608 −0

File added.

Preview size limit exceeded, changes collapsed.