1df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani/*
2df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * Copyright (C) 2013 The Android Open Source Project
3df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani *
4df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * Licensed under the Apache License, Version 2.0 (the "License");
5df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * you may not use this file except in compliance with the License.
6df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * You may obtain a copy of the License at
7df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani *
8df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani *      http://www.apache.org/licenses/LICENSE-2.0
9df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani *
10df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * Unless required by applicable law or agreed to in writing, software
11df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * distributed under the License is distributed on an "AS IS" BASIS,
12df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * See the License for the specific language governing permissions and
14df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * limitations under the License.
15df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani */
16df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
17df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasanipackage android.content;
18df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
19df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasaniimport android.os.Parcel;
20df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasaniimport android.os.Parcelable;
21df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
22df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani/**
23df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * Applications can expose restrictions for a restricted user on a
24df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * multiuser device. The administrator can configure these restrictions that will then be
25df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * applied to the restricted user. Each RestrictionsEntry is one configurable restriction.
26df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * <p/>
27df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * Any application that chooses to expose such restrictions does so by implementing a
281eab5f26939748dea5e94bf019804a68d2a2b161Amith Yamasani * receiver that handles the {@link Intent#ACTION_GET_RESTRICTION_ENTRIES} action.
29df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * The receiver then returns a result bundle that contains an entry called "restrictions", whose
30df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * value is an ArrayList<RestrictionsEntry>.
31df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani */
32df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasanipublic class RestrictionEntry implements Parcelable {
33df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
34df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
3586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * A type of restriction. Use this type for information that needs to be transferred across
3686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * but shouldn't be presented to the user in the UI. Stores a single String value.
37df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
38df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public static final int TYPE_NULL         = 0;
3986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
40df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
4186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * A type of restriction. Use this for storing a boolean value, typically presented as
42df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * a checkbox in the UI.
43df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
44df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public static final int TYPE_BOOLEAN      = 1;
4586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
46df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
47df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * A type of restriction. Use this for storing a string value, typically presented as
4886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * a single-select list. Call {@link #setChoiceEntries(String[])} and
4986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * {@link #setChoiceValues(String[])} to set the localized list entries to present to the user
5086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * and the corresponding values, respectively.
51df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
52df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public static final int TYPE_CHOICE       = 2;
5386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
54df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
55df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * A type of restriction. Use this for storing a string value, typically presented as
5686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * a single-select list. Call {@link #setChoiceEntries(String[])} and
5786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * {@link #setChoiceValues(String[])} to set the localized list entries to present to the user
5886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * and the corresponding values, respectively.
59df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * The presentation could imply that values in lower array indices are included when a
60df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * particular value is chosen.
61d5e946a52c5095c05a4621073f428649ad626430Amith Yamasani     * @hide
62df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
63df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public static final int TYPE_CHOICE_LEVEL = 3;
6486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
65df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
66df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * A type of restriction. Use this for presenting a multi-select list where more than one
67df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * entry can be selected, such as for choosing specific titles to white-list.
6886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Call {@link #setChoiceEntries(String[])} and
6986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * {@link #setChoiceValues(String[])} to set the localized list entries to present to the user
7086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * and the corresponding values, respectively.
7186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Use {@link #getAllSelectedStrings()} and {@link #setAllSelectedStrings(String[])} to
7286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * manipulate the selections.
73df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
74df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public static final int TYPE_MULTI_SELECT = 4;
75df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
76f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    /**
77f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * A type of restriction. Use this for storing an integer value. The range of values
78f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * is from {@link Integer#MIN_VALUE} to {@link Integer#MAX_VALUE}.
79f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     */
80f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    public static final int TYPE_INTEGER = 5;
81f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani
82c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani    /**
83c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     * A type of restriction. Use this for storing a string value.
84c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     * @see #setSelectedString
85c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     * @see #getSelectedString
86c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     */
87c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani    public static final int TYPE_STRING = 6;
88c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani
89df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /** The type of restriction. */
90f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    private int mType;
91df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
92df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /** The unique key that identifies the restriction. */
93f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    private String mKey;
94df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
95df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /** The user-visible title of the restriction. */
96f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    private String mTitle;
97df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
98df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /** The user-visible secondary description of the restriction. */
99f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    private String mDescription;
100df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
101df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /** The user-visible set of choices used for single-select and multi-select lists. */
102f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    private String [] mChoiceEntries;
103df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
104df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /** The values corresponding to the user-visible choices. The value(s) of this entry will
10586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * one or more of these, returned by {@link #getAllSelectedStrings()} and
10686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * {@link #getSelectedString()}.
107df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
108f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    private String [] mChoiceValues;
109df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
110df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /* The chosen value, whose content depends on the type of the restriction. */
111f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    private String mCurrentValue;
11286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
113df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /* List of selected choices in the multi-select case. */
114f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    private String[] mCurrentValues;
115df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
116df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
117c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     * Constructor for specifying the type and key, with no initial value;
118c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     *
119c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     * @param type the restriction type.
120c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     * @param key the unique key for this restriction
121c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani     */
122c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani    public RestrictionEntry(int type, String key) {
123c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani        mType = type;
124c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani        mKey = key;
125c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani    }
126c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani
127c8c8425b51a4f68fae993e68b357679ca27d155dAmith Yamasani    /**
128d5e946a52c5095c05a4621073f428649ad626430Amith Yamasani     * Constructor for {@link #TYPE_CHOICE} type.
129df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * @param key the unique key for this restriction
13086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param selectedString the current value
131df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
13286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public RestrictionEntry(String key, String selectedString) {
133f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mKey = key;
134f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mType = TYPE_CHOICE;
135f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mCurrentValue = selectedString;
136df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
137df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
138df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
139df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * Constructor for {@link #TYPE_BOOLEAN} type.
140df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * @param key the unique key for this restriction
14186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param selectedState whether this restriction is selected or not
142df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
14386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public RestrictionEntry(String key, boolean selectedState) {
144f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mKey = key;
145f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mType = TYPE_BOOLEAN;
14686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani        setSelectedState(selectedState);
147df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
148df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
149df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
150df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * Constructor for {@link #TYPE_MULTI_SELECT} type.
151df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     * @param key the unique key for this restriction
15286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param selectedStrings the list of values that are currently selected
153df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
15486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public RestrictionEntry(String key, String[] selectedStrings) {
155f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mKey = key;
156f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mType = TYPE_MULTI_SELECT;
157f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mCurrentValues = selectedStrings;
158f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    }
159f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani
160f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    /**
161f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * Constructor for {@link #TYPE_INTEGER} type.
162f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * @param key the unique key for this restriction
163f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * @param selectedInt the integer value of the restriction
164f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     */
165f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    public RestrictionEntry(String key, int selectedInt) {
166f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mKey = key;
167f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mType = TYPE_INTEGER;
168f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        setIntValue(selectedInt);
16986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
17086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
17186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
17286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets the type for this restriction.
17386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param type the type for this restriction.
17486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
17586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setType(int type) {
176f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mType = type;
177df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
178df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
179df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
18086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Returns the type for this restriction.
18186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the type for this restriction
182df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
18386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public int getType() {
184f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mType;
18586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
18686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
18786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
18886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Returns the currently selected string value.
18986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the currently selected value, which can be null for types that aren't for holding
19086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * single string values.
19186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
19286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public String getSelectedString() {
193f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mCurrentValue;
194df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
195df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
196df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
19786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Returns the list of currently selected values.
19886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the list of current selections, if type is {@link #TYPE_MULTI_SELECT},
19986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     *  null otherwise.
200df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
20186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public String[] getAllSelectedStrings() {
202f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mCurrentValues;
203df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
204df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
205df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
20686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Returns the current selected state for an entry of type {@link #TYPE_BOOLEAN}.
20786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the current selected state of the entry.
208df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
20986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public boolean getSelectedState() {
210f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return Boolean.parseBoolean(mCurrentValue);
211f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    }
212f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani
213f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    /**
214f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * Returns the value of the entry as an integer when the type is {@link #TYPE_INTEGER}.
215f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * @return the integer value of the entry.
216f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     */
217f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    public int getIntValue() {
218f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return Integer.parseInt(mCurrentValue);
219f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    }
220f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani
221f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    /**
222f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * Sets the integer value of the entry when the type is {@link #TYPE_INTEGER}.
223f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     * @param value the integer value to set.
224f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani     */
225f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani    public void setIntValue(int value) {
226f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mCurrentValue = Integer.toString(value);
227df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
228df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
229df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
23086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets the string value to use as the selected value for this restriction. This value will
23186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * be persisted by the system for later use by the application.
23286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param selectedString the string value to select.
23386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
23486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setSelectedString(String selectedString) {
235f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mCurrentValue = selectedString;
23686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
23786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
23886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
23986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets the current selected state for an entry of type {@link #TYPE_BOOLEAN}. This value will
24086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * be persisted by the system for later use by the application.
24186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param state the current selected state
24286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
24386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setSelectedState(boolean state) {
244f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mCurrentValue = Boolean.toString(state);
24586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
24686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
24786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
24886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets the current list of selected values for an entry of type {@link #TYPE_MULTI_SELECT}.
24986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * These values will be persisted by the system for later use by the application.
25086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param allSelectedStrings the current list of selected values.
25186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
25286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setAllSelectedStrings(String[] allSelectedStrings) {
253f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mCurrentValues = allSelectedStrings;
25486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
25586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
25686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
25786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets a list of string values that can be selected by the user. If no user-visible entries
25886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * are set by a call to {@link #setChoiceEntries(String[])}, these values will be the ones
25986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * shown to the user. Values will be chosen from this list as the user's selection and the
26086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * selected values can be retrieved by a call to {@link #getAllSelectedStrings()}, or
26186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * {@link #getSelectedString()}, depending on whether it is a multi-select type or choice type.
262d5e946a52c5095c05a4621073f428649ad626430Amith Yamasani     * This method is not relevant for types other than
26386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * {@link #TYPE_CHOICE}, and {@link #TYPE_MULTI_SELECT}.
26486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param choiceValues an array of Strings which will be the selected values for the user's
26586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * selections.
26686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @see #getChoiceValues()
26786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @see #getAllSelectedStrings()
26886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
26986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setChoiceValues(String[] choiceValues) {
270f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mChoiceValues = choiceValues;
27186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
27286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
27386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
27486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets a list of string values that can be selected by the user, similar to
27586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * {@link #setChoiceValues(String[])}.
27686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param context the application context for retrieving the resources.
27786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param stringArrayResId the resource id for a string array containing the possible values.
27886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @see #setChoiceValues(String[])
27986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
28086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setChoiceValues(Context context, int stringArrayResId) {
281f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mChoiceValues = context.getResources().getStringArray(stringArrayResId);
28286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
28386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
28486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
28586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Returns the list of possible string values set earlier.
28686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the list of possible values.
28786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
28886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public String[] getChoiceValues() {
289f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mChoiceValues;
29086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
29186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
29286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
29386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets a list of strings that will be presented as choices to the user. When the
29486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * user selects one or more of these choices, the corresponding value from the possible values
29586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * are stored as the selected strings. The size of this array must match the size of the array
29686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * set in {@link #setChoiceValues(String[])}. This method is not relevant for types other
297d5e946a52c5095c05a4621073f428649ad626430Amith Yamasani     * than {@link #TYPE_CHOICE}, and {@link #TYPE_MULTI_SELECT}.
29886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param choiceEntries the list of user-visible choices.
29986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @see #setChoiceValues(String[])
30086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
30186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setChoiceEntries(String[] choiceEntries) {
302f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mChoiceEntries = choiceEntries;
30386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
30486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
30586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /** Sets a list of strings that will be presented as choices to the user. This is similar to
30686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * {@link #setChoiceEntries(String[])}.
30786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param context the application context, used for retrieving the resources.
30886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param stringArrayResId the resource id of a string array containing the possible entries.
30986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
31086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setChoiceEntries(Context context, int stringArrayResId) {
311f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mChoiceEntries = context.getResources().getStringArray(stringArrayResId);
31286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
31386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
31486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
31586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Returns the list of strings, set earlier, that will be presented as choices to the user.
31686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the list of choices presented to the user.
31786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
31886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public String[] getChoiceEntries() {
319f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mChoiceEntries;
32086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
32186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
32286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
32386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Returns the provided user-visible description of the entry, if any.
32486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the user-visible description, null if none was set earlier.
32586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
32686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public String getDescription() {
327f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mDescription;
32886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
32986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
33086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
33186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets the user-visible description of the entry, as a possible sub-text for the title.
33286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * You can use this to describe the entry in more detail or to display the current state of
33386118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * the restriction.
33486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param description the user-visible description string.
33586118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     */
33686118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setDescription(String description) {
337f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mDescription = description;
33886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    }
33986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani
34086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    /**
34186118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * This is the unique key for the restriction entry.
34286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the key for the restriction.
343df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
34486118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public String getKey() {
345f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mKey;
346df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
347df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
348df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
34986118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Returns the user-visible title for the entry, if any.
35086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @return the user-visible title for the entry, null if none was set earlier.
351df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
35286118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public String getTitle() {
353f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mTitle;
354df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
355df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
356df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    /**
35786118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * Sets the user-visible title for the entry.
35886118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani     * @param title the user-visible title for the entry.
359df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani     */
36086118baa4fef80c485ba51c6985a6fa082b7310cAmith Yamasani    public void setTitle(String title) {
361f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        this.mTitle = title;
362df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
363df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
364df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    private boolean equalArrays(String[] one, String[] other) {
365df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        if (one.length != other.length) return false;
366df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        for (int i = 0; i < one.length; i++) {
367df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            if (!one[i].equals(other[i])) return false;
368df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        }
369df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        return true;
370df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
371df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
372df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    @Override
373df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public boolean equals(Object o) {
374df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        if (o == this) return true;
375df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        if (!(o instanceof RestrictionEntry)) return false;
376df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        final RestrictionEntry other = (RestrictionEntry) o;
377df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        // Make sure that either currentValue matches or currentValues matches.
378f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return mType == other.mType && mKey.equals(other.mKey)
379df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani                &&
380f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani                ((mCurrentValues == null && other.mCurrentValues == null
381f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani                  && mCurrentValue != null && mCurrentValue.equals(other.mCurrentValue))
382df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani                 ||
383f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani                 (mCurrentValue == null && other.mCurrentValue == null
384f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani                  && mCurrentValues != null && equalArrays(mCurrentValues, other.mCurrentValues)));
385df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
386df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
387df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    @Override
388df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public int hashCode() {
389df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        int result = 17;
390f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        result = 31 * result + mKey.hashCode();
391f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        if (mCurrentValue != null) {
392f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani            result = 31 * result + mCurrentValue.hashCode();
393f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        } else if (mCurrentValues != null) {
394f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani            for (String value : mCurrentValues) {
395df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani                if (value != null) {
396df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani                    result = 31 * result + value.hashCode();
397df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani                }
398df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            }
399df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        }
400df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        return result;
401df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
402df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
403df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    private String[] readArray(Parcel in) {
404df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        int count = in.readInt();
405df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        String[] values = new String[count];
406df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        for (int i = 0; i < count; i++) {
407df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            values[i] = in.readString();
408df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        }
409df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        return values;
410df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
411df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
412df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public RestrictionEntry(Parcel in) {
413f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mType = in.readInt();
414f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mKey = in.readString();
415f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mTitle = in.readString();
416f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mDescription = in.readString();
417f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mChoiceEntries = readArray(in);
418f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mChoiceValues = readArray(in);
419f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mCurrentValue = in.readString();
420f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        mCurrentValues = readArray(in);
421df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
422df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
423df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    @Override
424df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public int describeContents() {
425df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        return 0;
426df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
427df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
428df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    private void writeArray(Parcel dest, String[] values) {
429df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        if (values == null) {
430df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            dest.writeInt(0);
431df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        } else {
432df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            dest.writeInt(values.length);
433df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            for (int i = 0; i < values.length; i++) {
434df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani                dest.writeString(values[i]);
435df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            }
436df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        }
437df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
438df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
439df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    @Override
440df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public void writeToParcel(Parcel dest, int flags) {
441f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        dest.writeInt(mType);
442f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        dest.writeString(mKey);
443f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        dest.writeString(mTitle);
444f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        dest.writeString(mDescription);
445f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        writeArray(dest, mChoiceEntries);
446f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        writeArray(dest, mChoiceValues);
447f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        dest.writeString(mCurrentValue);
448f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        writeArray(dest, mCurrentValues);
449df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
450df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
451df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public static final Creator<RestrictionEntry> CREATOR = new Creator<RestrictionEntry>() {
452df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        public RestrictionEntry createFromParcel(Parcel source) {
453df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            return new RestrictionEntry(source);
454df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        }
455df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
456df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        public RestrictionEntry[] newArray(int size) {
457df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani            return new RestrictionEntry[size];
458df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani        }
459df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    };
460df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani
461df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    @Override
462df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    public String toString() {
463f20d640fa2b155a971ddfe0965fc803a73b5e53cAmith Yamasani        return "RestrictionsEntry {type=" + mType + ", key=" + mKey + ", value=" + mCurrentValue + "}";
464df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani    }
465df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani}
466