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.preference2.cts;
17 
18 import android.preference2.cts.R;
19 
20 import android.content.Context;
21 import android.content.res.TypedArray;
22 import android.graphics.drawable.Drawable;
23 import android.os.Parcelable;
24 import android.preference.Preference;
25 import android.preference.PreferenceManager;
26 import android.util.AttributeSet;
27 import android.view.View;
28 import android.view.ViewGroup;
29 
30 public class CustomPreference extends Preference {
31     protected boolean mOnPrepareCalled;
32 
CustomPreference(Context context, AttributeSet attrs)33     public CustomPreference(Context context, AttributeSet attrs) {
34         super(context, attrs);
35         init(attrs);
36     }
37 
CustomPreference(Context context)38     public CustomPreference(Context context) {
39         this(context, null, 0);
40     }
41 
CustomPreference(Context context, AttributeSet attrs, int defStyle)42     public CustomPreference(Context context, AttributeSet attrs, int defStyle) {
43         super(context, attrs, defStyle);
44         init(attrs);
45     }
46 
init(AttributeSet attrs)47     private void init(AttributeSet attrs) {
48         TypedArray a = getContext().obtainStyledAttributes(attrs,R.styleable.CustPref);
49         setTitle(a.getString(R.styleable.CustPref_title));
50         setIcon(a.getDrawable(R.styleable.CustPref_icon));
51     }
52 
53     @Override
callChangeListener(Object newValue)54     protected boolean callChangeListener(Object newValue) {
55         return super.callChangeListener(newValue);
56     }
57 
58     @Override
findPreferenceInHierarchy(String key)59     protected Preference findPreferenceInHierarchy(String key) {
60         return super.findPreferenceInHierarchy(key);
61     }
62 
63     @Override
getPersistedBoolean(boolean defaultReturnValue)64     protected boolean getPersistedBoolean(boolean defaultReturnValue) {
65         return super.getPersistedBoolean(defaultReturnValue);
66     }
67 
68     @Override
getPersistedFloat(float defaultReturnValue)69     protected float getPersistedFloat(float defaultReturnValue) {
70         return super.getPersistedFloat(defaultReturnValue);
71     }
72 
73     @Override
getPersistedInt(int defaultReturnValue)74     protected int getPersistedInt(int defaultReturnValue) {
75         return super.getPersistedInt(defaultReturnValue);
76     }
77 
78     @Override
getPersistedLong(long defaultReturnValue)79     protected long getPersistedLong(long defaultReturnValue) {
80         return super.getPersistedLong(defaultReturnValue);
81     }
82 
83     @Override
getPersistedString(String defaultReturnValue)84     protected String getPersistedString(String defaultReturnValue) {
85         return super.getPersistedString(defaultReturnValue);
86     }
87 
88     @Override
notifyChanged()89     protected void notifyChanged() {
90         super.notifyChanged();
91     }
92 
93     @Override
notifyHierarchyChanged()94     protected void notifyHierarchyChanged() {
95         super.notifyHierarchyChanged();
96     }
97 
98     @Override
onAttachedToActivity()99     protected void onAttachedToActivity() {
100         super.onAttachedToActivity();
101     }
102 
103     @Override
onAttachedToHierarchy(PreferenceManager preferenceManager)104     protected void onAttachedToHierarchy(PreferenceManager preferenceManager) {
105         super.onAttachedToHierarchy(preferenceManager);
106     }
107 
108     @Override
onBindView(View view)109     protected void onBindView(View view) {
110         super.onBindView(view);
111     }
112 
113     @Override
onClick()114     protected void onClick() {
115         super.onClick();
116     }
117 
118     @Override
onCreateView(ViewGroup parent)119     protected View onCreateView(ViewGroup parent) {
120         return super.onCreateView(parent);
121     }
122 
123     @Override
onGetDefaultValue(TypedArray a, int index)124     protected Object onGetDefaultValue(TypedArray a, int index) {
125         return super.onGetDefaultValue(a, index);
126     }
127 
128     @Override
onPrepareForRemoval()129     protected void onPrepareForRemoval() {
130         super.onPrepareForRemoval();
131     }
132 
133     @Override
onRestoreInstanceState(Parcelable state)134     protected void onRestoreInstanceState(Parcelable state) {
135 
136         super.onRestoreInstanceState(state);
137     }
138 
139     @Override
onSaveInstanceState()140     protected Parcelable onSaveInstanceState() {
141         return super.onSaveInstanceState();
142     }
143 
144     @Override
onSetInitialValue(boolean restorePersistedValue, Object defaultValue)145     protected void onSetInitialValue(boolean restorePersistedValue,
146             Object defaultValue) {
147         super.onSetInitialValue(restorePersistedValue, defaultValue);
148     }
149 
150     @Override
persistBoolean(boolean value)151     protected boolean persistBoolean(boolean value) {
152         return super.persistBoolean(value);
153     }
154 
155     @Override
persistFloat(float value)156     protected boolean persistFloat(float value) {
157         return super.persistFloat(value);
158     }
159 
160     @Override
persistInt(int value)161     protected boolean persistInt(int value) {
162         return super.persistInt(value);
163     }
164 
165     @Override
persistLong(long value)166     protected boolean persistLong(long value) {
167         return super.persistLong(value);
168     }
169 
170     @Override
persistString(String value)171     protected boolean persistString(String value) {
172         return super.persistString(value);
173     }
174 
175     @Override
shouldPersist()176     protected boolean shouldPersist() {
177         return super.shouldPersist();
178     }
179 }
180 
181