public class

UserStyleSettingWireFormat

extends java.lang.Object

implements VersionedParcelable

 java.lang.Object

↳androidx.wear.watchface.style.data.UserStyleSettingWireFormat

Subclasses:

CustomValueUserStyleSettingWireFormat, ListUserStyleSettingWireFormat, BooleanUserStyleSettingWireFormat, CustomValueUserStyleSetting2WireFormat, LongRangeUserStyleSettingWireFormat, DoubleRangeUserStyleSettingWireFormat, ComplicationsUserStyleSettingWireFormat

Gradle dependencies

compile group: 'androidx.wear.watchface', name: 'watchface-data', version: '1.3.0-alpha03'

  • groupId: androidx.wear.watchface
  • artifactId: watchface-data
  • version: 1.3.0-alpha03

Artifact androidx.wear.watchface:watchface-data:1.3.0-alpha03 it located at Google repository (https://maven.google.com/)

Overview

Wire format for .

Summary

Fields
public static final <any>CREATOR

public java.util.List<java.lang.Integer>mAffectsLayers

Used by the style configuration UI.

public intmDefaultOptionIndex

The default option index, used if nothing has been selected within the options list.

public java.lang.CharSequencemDescription

Localized description string displayed under the displayName.

public java.lang.CharSequencemDisplayName

Localized human readable name for the element, used in the userStyle selection UI.

public IconmIcon

Icon for use in the style selection UI.

public java.lang.StringmId

Identifier for the element, must be unique.

public BundlemOnWatchFaceEditorBundle

Contains OnWatchFaceData.

public java.util.List<java.lang.Integer>mOptionChildIndices

Flattened list of child settings for each option.

public java.util.List<OptionWireFormat>mOptions

List of options for this UserStyleCategory.

public java.util.List<Bundle>mPerOptionOnWatchFaceEditorBundles

Per option OnWatchFaceData.

Constructors
publicUserStyleSettingWireFormat(java.lang.String id, java.lang.CharSequence displayName, java.lang.CharSequence description, Icon icon, java.util.List<OptionWireFormat> options, int defaultOptionIndex, java.util.List<java.lang.Integer> affectsLayers)

publicUserStyleSettingWireFormat(java.lang.String id, java.lang.CharSequence displayName, java.lang.CharSequence description, Icon icon, java.util.List<OptionWireFormat> options, int defaultOptionIndex, java.util.List<java.lang.Integer> affectsLayers, Bundle onWatchFaceEditorBundle, java.util.List<Bundle> perOptionOnWatchFaceEditorBundles)

Methods
public intdescribeContents()

public voidwriteToParcel(Parcel parcel, int flags)

Serializes this UserStyleCategoryWireFormat to the specified .

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public java.lang.String mId

Identifier for the element, must be unique.

public java.lang.CharSequence mDisplayName

Localized human readable name for the element, used in the userStyle selection UI.

public java.lang.CharSequence mDescription

Localized description string displayed under the displayName.

public Icon mIcon

Icon for use in the style selection UI.

public int mDefaultOptionIndex

The default option index, used if nothing has been selected within the options list.

public java.util.List<java.lang.Integer> mAffectsLayers

Used by the style configuration UI. Describes which rendering layers this style affects.

public java.util.List<OptionWireFormat> mOptions

List of options for this UserStyleCategory. Depending on the type of UserStyleCategory this may be an exhaustive list, or just examples to populate a ListView in case the UserStyleCategory isn't supported by the UI (e.g. a new WatchFace with an old Companion).

OptionWireFormat can't change because VersionedParcelable has a design flaw, if the format changes the reader can't determine the correct size of the list and data afterwards (including elements of this list) will get corrupted.

public java.util.List<java.lang.Integer> mOptionChildIndices

Flattened list of child settings for each option. Note this ID must always be a list of Integers.

public Bundle mOnWatchFaceEditorBundle

Contains OnWatchFaceData.

public java.util.List<Bundle> mPerOptionOnWatchFaceEditorBundles

Per option OnWatchFaceData. Ideally this would be in OptionWireFormat, but VersionedParcellable doesn't support us adding that in a backwards compatible way.

public static final <any> CREATOR

Constructors

public UserStyleSettingWireFormat(java.lang.String id, java.lang.CharSequence displayName, java.lang.CharSequence description, Icon icon, java.util.List<OptionWireFormat> options, int defaultOptionIndex, java.util.List<java.lang.Integer> affectsLayers)

Deprecated: use a constructor with List perOptionOnWatchFaceEditorBundles.

public UserStyleSettingWireFormat(java.lang.String id, java.lang.CharSequence displayName, java.lang.CharSequence description, Icon icon, java.util.List<OptionWireFormat> options, int defaultOptionIndex, java.util.List<java.lang.Integer> affectsLayers, Bundle onWatchFaceEditorBundle, java.util.List<Bundle> perOptionOnWatchFaceEditorBundles)

Methods

public void writeToParcel(Parcel parcel, int flags)

Serializes this UserStyleCategoryWireFormat to the specified .

public int describeContents()

Source

/*
 * Copyright 2020 The Android Open Source 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 androidx.wear.watchface.style.data;

import android.annotation.SuppressLint;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;

import java.util.ArrayList;
import java.util.List;

/**
 * Wire format for {@link androidx.wear.watchface.style.UserStyleSetting}.
 *
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@VersionedParcelize
@SuppressLint("BanParcelableUsage") // TODO(b/169214666): Remove Parcelable
public class UserStyleSettingWireFormat implements VersionedParcelable, Parcelable {
    /** Identifier for the element, must be unique. */
    @ParcelField(1)
    @NonNull
    public String mId = "";

    /** Localized human readable name for the element, used in the userStyle selection UI. */
    @ParcelField(2)
    @NonNull
    public CharSequence mDisplayName = "";

    /** Localized description string displayed under the displayName. */
    @ParcelField(3)
    @NonNull
    public CharSequence mDescription = "";

    /** Icon for use in the style selection UI. */
    @ParcelField(4)
    @Nullable
    public Icon mIcon = null;

    /** The default option index, used if nothing has been selected within the options list. */
    @ParcelField(5)
    public int mDefaultOptionIndex;

    /** Used by the style configuration UI. Describes which rendering layers this style affects. */
    @ParcelField(6)
    @NonNull
    public List<Integer> mAffectsLayers;

    /**
     * List of options for this UserStyleCategory. Depending on the type of UserStyleCategory this
     * may be an exhaustive list, or just examples to populate a ListView in case the
     * UserStyleCategory isn't supported by the UI (e.g. a new WatchFace with an old Companion).
     *
     * <p>OptionWireFormat can't change because VersionedParcelable has a design flaw, if the format
     * changes the reader can't determine the correct size of the list and data afterwards
     * (including elements of this list) will get corrupted.
     */
    @ParcelField(100)
    @NonNull
    public List<OptionWireFormat> mOptions = new ArrayList<>();

    /**
     * Flattened list of child settings for each option. Note this ID must always be a list of
     * Integers.
     */
    @Nullable
    @ParcelField(101)
    public List<Integer> mOptionChildIndices = null;

    /** Contains OnWatchFaceData. */
    @Nullable
    @ParcelField(102)
    public Bundle mOnWatchFaceEditorBundle = null;

    /**
     * Per option OnWatchFaceData. Ideally this would be in OptionWireFormat, but
     * VersionedParcellable doesn't support us adding that in a backwards compatible way.
     */
    @Nullable
    @ParcelField(103)
    public List<Bundle> mPerOptionOnWatchFaceEditorBundles = new ArrayList<>();

    // Field 104 is reserved.

    UserStyleSettingWireFormat() {}

    /**
     * @deprecated use a constructor with List<Bundle> perOptionOnWatchFaceEditorBundles.
     */
    @Deprecated
    public UserStyleSettingWireFormat(
            @NonNull String id,
            @NonNull CharSequence displayName,
            @NonNull CharSequence description,
            @Nullable Icon icon,
            @NonNull List<OptionWireFormat> options,
            int defaultOptionIndex,
            @NonNull List<Integer> affectsLayers) {
        mId = id;
        mDisplayName = displayName;
        mDescription = description;
        mIcon = icon;
        mOptions = options;
        mDefaultOptionIndex = defaultOptionIndex;
        mAffectsLayers = affectsLayers;
    }

    public UserStyleSettingWireFormat(
            @NonNull String id,
            @NonNull CharSequence displayName,
            @NonNull CharSequence description,
            @Nullable Icon icon,
            @NonNull List<OptionWireFormat> options,
            int defaultOptionIndex,
            @NonNull List<Integer> affectsLayers,
            @Nullable Bundle onWatchFaceEditorBundle,
            @Nullable List<Bundle> perOptionOnWatchFaceEditorBundles) {
        mId = id;
        mDisplayName = displayName;
        mDescription = description;
        mIcon = icon;
        mOptions = options;
        mDefaultOptionIndex = defaultOptionIndex;
        mAffectsLayers = affectsLayers;
        mOnWatchFaceEditorBundle = onWatchFaceEditorBundle;
        mPerOptionOnWatchFaceEditorBundles = perOptionOnWatchFaceEditorBundles;
    }

    /** Serializes this UserStyleCategoryWireFormat to the specified {@link Parcel}. */
    @Override
    public void writeToParcel(@NonNull Parcel parcel, int flags) {
        parcel.writeParcelable(ParcelUtils.toParcelable(this), flags);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Parcelable.Creator<UserStyleSettingWireFormat> CREATOR =
            new Parcelable.Creator<UserStyleSettingWireFormat>() {
                @SuppressWarnings("deprecation")
                @Override
                public UserStyleSettingWireFormat createFromParcel(Parcel source) {
                    return ParcelUtils.fromParcelable(
                            source.readParcelable(getClass().getClassLoader()));
                }

                @Override
                public UserStyleSettingWireFormat[] newArray(int size) {
                    return new UserStyleSettingWireFormat[size];
                }
            };
}