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