Fields Summary |
---|
public static final int | TYPE_NULLA type of restriction. Use this type for information that needs to be transferred across
but shouldn't be presented to the user in the UI. Stores a single String value. |
public static final int | TYPE_BOOLEANA type of restriction. Use this for storing a boolean value, typically presented as
a checkbox in the UI. |
public static final int | TYPE_CHOICEA type of restriction. Use this for storing a string value, typically presented as
a single-select list. Call {@link #setChoiceEntries(String[])} and
{@link #setChoiceValues(String[])} to set the localized list entries to present to the user
and the corresponding values, respectively. |
public static final int | TYPE_CHOICE_LEVELA type of restriction. Use this for storing a string value, typically presented as
a single-select list. Call {@link #setChoiceEntries(String[])} and
{@link #setChoiceValues(String[])} to set the localized list entries to present to the user
and the corresponding values, respectively.
The presentation could imply that values in lower array indices are included when a
particular value is chosen. |
public static final int | TYPE_MULTI_SELECTA type of restriction. Use this for presenting a multi-select list where more than one
entry can be selected, such as for choosing specific titles to white-list.
Call {@link #setChoiceEntries(String[])} and
{@link #setChoiceValues(String[])} to set the localized list entries to present to the user
and the corresponding values, respectively.
Use {@link #getAllSelectedStrings()} and {@link #setAllSelectedStrings(String[])} to
manipulate the selections. |
public static final int | TYPE_INTEGERA type of restriction. Use this for storing an integer value. The range of values
is from {@link Integer#MIN_VALUE} to {@link Integer#MAX_VALUE}. |
public static final int | TYPE_STRINGA type of restriction. Use this for storing a string value. |
private int | mTypeThe type of restriction. |
private String | mKeyThe unique key that identifies the restriction. |
private String | mTitleThe user-visible title of the restriction. |
private String | mDescriptionThe user-visible secondary description of the restriction. |
private String[] | mChoiceEntriesThe user-visible set of choices used for single-select and multi-select lists. |
private String[] | mChoiceValuesThe values corresponding to the user-visible choices. The value(s) of this entry will
one or more of these, returned by {@link #getAllSelectedStrings()} and
{@link #getSelectedString()}. |
private String | mCurrentValue |
private String[] | mCurrentValues |
public static final Creator | CREATOR |
Constructors Summary |
---|
public RestrictionEntry(int type, String key)Constructor for specifying the type and key, with no initial value;
mType = type;
mKey = key;
|
public RestrictionEntry(String key, String selectedString)Constructor for {@link #TYPE_CHOICE} type.
this.mKey = key;
this.mType = TYPE_CHOICE;
this.mCurrentValue = selectedString;
|
public RestrictionEntry(String key, boolean selectedState)Constructor for {@link #TYPE_BOOLEAN} type.
this.mKey = key;
this.mType = TYPE_BOOLEAN;
setSelectedState(selectedState);
|
public RestrictionEntry(android.os.Parcel in)
mType = in.readInt();
mKey = in.readString();
mTitle = in.readString();
mDescription = in.readString();
mChoiceEntries = readArray(in);
mChoiceValues = readArray(in);
mCurrentValue = in.readString();
mCurrentValues = readArray(in);
|
public RestrictionEntry(String key, String[] selectedStrings)Constructor for {@link #TYPE_MULTI_SELECT} type.
this.mKey = key;
this.mType = TYPE_MULTI_SELECT;
this.mCurrentValues = selectedStrings;
|
public RestrictionEntry(String key, int selectedInt)Constructor for {@link #TYPE_INTEGER} type.
mKey = key;
mType = TYPE_INTEGER;
setIntValue(selectedInt);
|
Methods Summary |
---|
public int | describeContents()
return 0;
|
private boolean | equalArrays(java.lang.String[] one, java.lang.String[] other)
if (one.length != other.length) return false;
for (int i = 0; i < one.length; i++) {
if (!one[i].equals(other[i])) return false;
}
return true;
|
public boolean | equals(java.lang.Object o)
if (o == this) return true;
if (!(o instanceof RestrictionEntry)) return false;
final RestrictionEntry other = (RestrictionEntry) o;
// Make sure that either currentValue matches or currentValues matches.
return mType == other.mType && mKey.equals(other.mKey)
&&
((mCurrentValues == null && other.mCurrentValues == null
&& mCurrentValue != null && mCurrentValue.equals(other.mCurrentValue))
||
(mCurrentValue == null && other.mCurrentValue == null
&& mCurrentValues != null && equalArrays(mCurrentValues, other.mCurrentValues)));
|
public java.lang.String[] | getAllSelectedStrings()Returns the list of currently selected values.
return mCurrentValues;
|
public java.lang.String[] | getChoiceEntries()Returns the list of strings, set earlier, that will be presented as choices to the user.
return mChoiceEntries;
|
public java.lang.String[] | getChoiceValues()Returns the list of possible string values set earlier.
return mChoiceValues;
|
public java.lang.String | getDescription()Returns the provided user-visible description of the entry, if any.
return mDescription;
|
public int | getIntValue()Returns the value of the entry as an integer when the type is {@link #TYPE_INTEGER}.
return Integer.parseInt(mCurrentValue);
|
public java.lang.String | getKey()This is the unique key for the restriction entry.
return mKey;
|
public boolean | getSelectedState()Returns the current selected state for an entry of type {@link #TYPE_BOOLEAN}.
return Boolean.parseBoolean(mCurrentValue);
|
public java.lang.String | getSelectedString()Returns the currently selected string value.
return mCurrentValue;
|
public java.lang.String | getTitle()Returns the user-visible title for the entry, if any.
return mTitle;
|
public int | getType()Returns the type for this restriction.
return mType;
|
public int | hashCode()
int result = 17;
result = 31 * result + mKey.hashCode();
if (mCurrentValue != null) {
result = 31 * result + mCurrentValue.hashCode();
} else if (mCurrentValues != null) {
for (String value : mCurrentValues) {
if (value != null) {
result = 31 * result + value.hashCode();
}
}
}
return result;
|
private java.lang.String[] | readArray(android.os.Parcel in)
int count = in.readInt();
String[] values = new String[count];
for (int i = 0; i < count; i++) {
values[i] = in.readString();
}
return values;
|
public void | setAllSelectedStrings(java.lang.String[] allSelectedStrings)Sets the current list of selected values for an entry of type {@link #TYPE_MULTI_SELECT}.
These values will be persisted by the system for later use by the application.
mCurrentValues = allSelectedStrings;
|
public void | setChoiceEntries(java.lang.String[] choiceEntries)Sets a list of strings that will be presented as choices to the user. When the
user selects one or more of these choices, the corresponding value from the possible values
are stored as the selected strings. The size of this array must match the size of the array
set in {@link #setChoiceValues(String[])}. This method is not relevant for types other
than {@link #TYPE_CHOICE}, and {@link #TYPE_MULTI_SELECT}.
mChoiceEntries = choiceEntries;
|
public void | setChoiceEntries(Context context, int stringArrayResId)Sets a list of strings that will be presented as choices to the user. This is similar to
{@link #setChoiceEntries(String[])}.
mChoiceEntries = context.getResources().getStringArray(stringArrayResId);
|
public void | setChoiceValues(java.lang.String[] choiceValues)Sets a list of string values that can be selected by the user. If no user-visible entries
are set by a call to {@link #setChoiceEntries(String[])}, these values will be the ones
shown to the user. Values will be chosen from this list as the user's selection and the
selected values can be retrieved by a call to {@link #getAllSelectedStrings()}, or
{@link #getSelectedString()}, depending on whether it is a multi-select type or choice type.
This method is not relevant for types other than
{@link #TYPE_CHOICE}, and {@link #TYPE_MULTI_SELECT}.
mChoiceValues = choiceValues;
|
public void | setChoiceValues(Context context, int stringArrayResId)Sets a list of string values that can be selected by the user, similar to
{@link #setChoiceValues(String[])}.
mChoiceValues = context.getResources().getStringArray(stringArrayResId);
|
public void | setDescription(java.lang.String description)Sets the user-visible description of the entry, as a possible sub-text for the title.
You can use this to describe the entry in more detail or to display the current state of
the restriction.
this.mDescription = description;
|
public void | setIntValue(int value)Sets the integer value of the entry when the type is {@link #TYPE_INTEGER}.
mCurrentValue = Integer.toString(value);
|
public void | setSelectedState(boolean state)Sets the current selected state for an entry of type {@link #TYPE_BOOLEAN}. This value will
be persisted by the system for later use by the application.
mCurrentValue = Boolean.toString(state);
|
public void | setSelectedString(java.lang.String selectedString)Sets the string value to use as the selected value for this restriction. This value will
be persisted by the system for later use by the application.
mCurrentValue = selectedString;
|
public void | setTitle(java.lang.String title)Sets the user-visible title for the entry.
this.mTitle = title;
|
public void | setType(int type)Sets the type for this restriction.
this.mType = type;
|
public java.lang.String | toString()
return "RestrictionsEntry {type=" + mType + ", key=" + mKey + ", value=" + mCurrentValue + "}";
|
private void | writeArray(android.os.Parcel dest, java.lang.String[] values)
if (values == null) {
dest.writeInt(0);
} else {
dest.writeInt(values.length);
for (int i = 0; i < values.length; i++) {
dest.writeString(values[i]);
}
}
|
public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(mType);
dest.writeString(mKey);
dest.writeString(mTitle);
dest.writeString(mDescription);
writeArray(dest, mChoiceEntries);
writeArray(dest, mChoiceValues);
dest.writeString(mCurrentValue);
writeArray(dest, mCurrentValues);
|