1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.preference.cts;
17 
18 import android.content.Context;
19 import android.content.res.TypedArray;
20 import android.os.Parcelable;
21 import android.preference.Preference;
22 import android.preference.PreferenceManager;
23 import android.util.AttributeSet;
24 import android.view.View;
25 import android.view.ViewGroup;
26 
27 public class CustomPreference extends Preference {
28     protected boolean mOnPrepareCalled;
29 
CustomPreference(Context context, AttributeSet attrs)30     public CustomPreference(Context context, AttributeSet attrs) {
31         super(context, attrs);
32         init(attrs);
33     }
34 
CustomPreference(Context context)35     public CustomPreference(Context context) {
36         this(context, null, 0);
37     }
38 
CustomPreference(Context context, AttributeSet attrs, int defStyle)39     public CustomPreference(Context context, AttributeSet attrs, int defStyle) {
40         super(context, attrs, defStyle);
41         init(attrs);
42     }
43 
init(AttributeSet attrs)44     private void init(AttributeSet attrs) {
45         TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustPref);
46         setTitle(a.getString(R.styleable.CustPref_title));
47         setIcon(a.getDrawable(R.styleable.CustPref_icon));
48     }
49 
50     @Override
callChangeListener(Object newValue)51     protected boolean callChangeListener(Object newValue) {
52         return super.callChangeListener(newValue);
53     }
54 
55     @Override
findPreferenceInHierarchy(String key)56     protected Preference findPreferenceInHierarchy(String key) {
57         return super.findPreferenceInHierarchy(key);
58     }
59 
60     @Override
getPersistedBoolean(boolean defaultReturnValue)61     protected boolean getPersistedBoolean(boolean defaultReturnValue) {
62         return super.getPersistedBoolean(defaultReturnValue);
63     }
64 
65     @Override
getPersistedFloat(float defaultReturnValue)66     protected float getPersistedFloat(float defaultReturnValue) {
67         return super.getPersistedFloat(defaultReturnValue);
68     }
69 
70     @Override
getPersistedInt(int defaultReturnValue)71     protected int getPersistedInt(int defaultReturnValue) {
72         return super.getPersistedInt(defaultReturnValue);
73     }
74 
75     @Override
getPersistedLong(long defaultReturnValue)76     protected long getPersistedLong(long defaultReturnValue) {
77         return super.getPersistedLong(defaultReturnValue);
78     }
79 
80     @Override
getPersistedString(String defaultReturnValue)81     protected String getPersistedString(String defaultReturnValue) {
82         return super.getPersistedString(defaultReturnValue);
83     }
84 
85     @Override
notifyChanged()86     protected void notifyChanged() {
87         super.notifyChanged();
88     }
89 
90     @Override
notifyHierarchyChanged()91     protected void notifyHierarchyChanged() {
92         super.notifyHierarchyChanged();
93     }
94 
95     @Override
onAttachedToActivity()96     protected void onAttachedToActivity() {
97         super.onAttachedToActivity();
98     }
99 
100     @Override
onAttachedToHierarchy(PreferenceManager preferenceManager)101     protected void onAttachedToHierarchy(PreferenceManager preferenceManager) {
102         super.onAttachedToHierarchy(preferenceManager);
103     }
104 
105     @Override
onBindView(View view)106     protected void onBindView(View view) {
107         super.onBindView(view);
108     }
109 
110     @Override
onClick()111     protected void onClick() {
112         super.onClick();
113     }
114 
115     @Override
onCreateView(ViewGroup parent)116     protected View onCreateView(ViewGroup parent) {
117         return super.onCreateView(parent);
118     }
119 
120     @Override
onGetDefaultValue(TypedArray a, int index)121     protected Object onGetDefaultValue(TypedArray a, int index) {
122         return super.onGetDefaultValue(a, index);
123     }
124 
125     @Override
onPrepareForRemoval()126     protected void onPrepareForRemoval() {
127         super.onPrepareForRemoval();
128     }
129 
130     @Override
onRestoreInstanceState(Parcelable state)131     protected void onRestoreInstanceState(Parcelable state) {
132 
133         super.onRestoreInstanceState(state);
134     }
135 
136     @Override
onSaveInstanceState()137     protected Parcelable onSaveInstanceState() {
138         return super.onSaveInstanceState();
139     }
140 
141     @Override
onSetInitialValue(boolean restorePersistedValue, Object defaultValue)142     protected void onSetInitialValue(boolean restorePersistedValue,
143             Object defaultValue) {
144         super.onSetInitialValue(restorePersistedValue, defaultValue);
145     }
146 
147     @Override
persistBoolean(boolean value)148     protected boolean persistBoolean(boolean value) {
149         return super.persistBoolean(value);
150     }
151 
152     @Override
persistFloat(float value)153     protected boolean persistFloat(float value) {
154         return super.persistFloat(value);
155     }
156 
157     @Override
persistInt(int value)158     protected boolean persistInt(int value) {
159         return super.persistInt(value);
160     }
161 
162     @Override
persistLong(long value)163     protected boolean persistLong(long value) {
164         return super.persistLong(value);
165     }
166 
167     @Override
persistString(String value)168     protected boolean persistString(String value) {
169         return super.persistString(value);
170     }
171 
172     @Override
shouldPersist()173     protected boolean shouldPersist() {
174         return super.shouldPersist();
175     }
176 }
177 
178