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.preference.Preference; 21 import android.preference.PreferenceGroup; 22 import android.util.AttributeSet; 23 24 public class CustomPreferenceGroup extends PreferenceGroup { 25 protected boolean mOnPrepareCalled; 26 CustomPreferenceGroup(Context context, AttributeSet attrs)27 public CustomPreferenceGroup(Context context, AttributeSet attrs) { 28 super(context, attrs); 29 init(attrs); 30 } 31 CustomPreferenceGroup(Context context)32 public CustomPreferenceGroup(Context context) { 33 super(context, null, 0); 34 } 35 CustomPreferenceGroup(Context context, AttributeSet attrs, int defStyle)36 public CustomPreferenceGroup(Context context, AttributeSet attrs, int defStyle) { 37 super(context, attrs, defStyle); 38 init(attrs); 39 } 40 init(AttributeSet attrs)41 private void init(AttributeSet attrs) { 42 TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustPref); 43 setTitle(a.getString(R.styleable.CustPref_title)); 44 setIcon(a.getDrawable(R.styleable.CustPref_icon)); 45 } 46 isOnSameScreenAsChildren()47 public boolean isOnSameScreenAsChildren() { 48 return super.isOnSameScreenAsChildren(); 49 } 50 onPrepareAddPreference(Preference preference)51 public boolean onPrepareAddPreference(Preference preference) { 52 mOnPrepareCalled = true; 53 return super.onPrepareAddPreference(preference); 54 } 55 } 56