PresetPreference.java revision cc0e782871eb6b946ded880e391866f27953654b
1/* 2 * Copyright (C) 2013 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 17package com.android.settings.accessibility; 18 19import android.content.Context; 20import android.util.AttributeSet; 21import android.view.View; 22import android.view.accessibility.CaptioningManager.CaptionStyle; 23import android.widget.TextView; 24 25import com.android.settings.R; 26 27public class PresetPreference extends ListDialogPreference { 28 public PresetPreference(Context context, AttributeSet attrs) { 29 super(context, attrs); 30 31 setDialogLayoutResource(R.layout.grid_picker_dialog); 32 setListItemLayoutResource(R.layout.preset_picker_item); 33 } 34 35 @Override 36 public boolean shouldDisableDependents() { 37 return getValue() != CaptionStyle.PRESET_CUSTOM 38 || super.shouldDisableDependents(); 39 } 40 41 @Override 42 protected void onBindListItem(View view, int index) { 43 final CaptioningTextView previewText = (CaptioningTextView) view.findViewById( 44 R.id.preview); 45 final int value = getValueAt(index); 46 ToggleCaptioningPreferenceFragment.applyCaptionProperties(previewText, value); 47 48 final CharSequence title = getTitleAt(index); 49 if (title != null) { 50 final TextView summary = (TextView) view.findViewById(R.id.summary); 51 summary.setText(title); 52 } 53 } 54} 55