1 /* 2 * Copyright (C) 2019 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 17 package com.android.settings.development.bluetooth; 18 19 import android.content.Context; 20 import android.util.AttributeSet; 21 import android.widget.RadioGroup; 22 23 import com.android.settings.R; 24 25 /** 26 * Dialog preference to set the Bluetooth A2DP config of sample rate 27 */ 28 public class BluetoothSampleRateDialogPreference extends BaseBluetoothDialogPreference implements 29 RadioGroup.OnCheckedChangeListener { 30 BluetoothSampleRateDialogPreference(Context context)31 public BluetoothSampleRateDialogPreference(Context context) { 32 super(context); 33 initialize(context); 34 } 35 BluetoothSampleRateDialogPreference(Context context, AttributeSet attrs)36 public BluetoothSampleRateDialogPreference(Context context, AttributeSet attrs) { 37 super(context, attrs); 38 initialize(context); 39 } 40 BluetoothSampleRateDialogPreference(Context context, AttributeSet attrs, int defStyleAttr)41 public BluetoothSampleRateDialogPreference(Context context, AttributeSet attrs, 42 int defStyleAttr) { 43 super(context, attrs, defStyleAttr); 44 initialize(context); 45 } 46 BluetoothSampleRateDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)47 public BluetoothSampleRateDialogPreference(Context context, AttributeSet attrs, 48 int defStyleAttr, int defStyleRes) { 49 super(context, attrs, defStyleAttr, defStyleRes); 50 initialize(context); 51 } 52 53 @Override getRadioButtonGroupId()54 protected int getRadioButtonGroupId() { 55 return R.id.bluetooth_audio_sample_rate_radio_group; 56 } 57 initialize(Context context)58 private void initialize(Context context) { 59 mRadioButtonIds.add(R.id.bluetooth_audio_sample_rate_default); 60 mRadioButtonIds.add(R.id.bluetooth_audio_sample_rate_441); 61 mRadioButtonIds.add(R.id.bluetooth_audio_sample_rate_480); 62 mRadioButtonIds.add(R.id.bluetooth_audio_sample_rate_882); 63 mRadioButtonIds.add(R.id.bluetooth_audio_sample_rate_960); 64 String[] stringArray = context.getResources().getStringArray( 65 com.android.settingslib.R.array.bluetooth_a2dp_codec_sample_rate_titles); 66 for (int i = 0; i < stringArray.length; i++) { 67 mRadioButtonStrings.add(stringArray[i]); 68 } 69 stringArray = context.getResources().getStringArray( 70 com.android.settingslib.R.array.bluetooth_a2dp_codec_sample_rate_summaries); 71 for (int i = 0; i < stringArray.length; i++) { 72 mSummaryStrings.add(stringArray[i]); 73 } 74 } 75 } 76