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 com.android.cts.preference2.R; 19 20 import android.content.Context; 21 import android.content.res.TypedArray; 22 import android.graphics.drawable.Drawable; 23 import android.preference.Preference; 24 import android.preference.PreferenceGroup; 25 import android.util.AttributeSet; 26 27 public class CustomPreferenceGroup extends PreferenceGroup { 28 protected boolean mOnPrepareCalled; 29 CustomPreferenceGroup(Context context, AttributeSet attrs)30 public CustomPreferenceGroup(Context context, AttributeSet attrs) { 31 super(context, attrs); 32 init(attrs); 33 } 34 CustomPreferenceGroup(Context context)35 public CustomPreferenceGroup(Context context) { 36 super(context, null, 0); 37 } 38 CustomPreferenceGroup(Context context, AttributeSet attrs, int defStyle)39 public CustomPreferenceGroup(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 isOnSameScreenAsChildren()50 public boolean isOnSameScreenAsChildren() { 51 return super.isOnSameScreenAsChildren(); 52 } 53 onPrepareAddPreference(Preference preference)54 public boolean onPrepareAddPreference (Preference preference) { 55 mOnPrepareCalled = true; 56 return super.onPrepareAddPreference(preference); 57 } 58 } 59