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 bit per sample 27 */ 28 public class BluetoothBitPerSampleDialogPreference extends BaseBluetoothDialogPreference implements 29 RadioGroup.OnCheckedChangeListener { 30 BluetoothBitPerSampleDialogPreference(Context context)31 public BluetoothBitPerSampleDialogPreference(Context context) { 32 super(context); 33 initialize(context); 34 } 35 BluetoothBitPerSampleDialogPreference(Context context, AttributeSet attrs)36 public BluetoothBitPerSampleDialogPreference(Context context, AttributeSet attrs) { 37 super(context, attrs); 38 initialize(context); 39 } 40 BluetoothBitPerSampleDialogPreference(Context context, AttributeSet attrs, int defStyleAttr)41 public BluetoothBitPerSampleDialogPreference(Context context, AttributeSet attrs, 42 int defStyleAttr) { 43 super(context, attrs, defStyleAttr); 44 initialize(context); 45 } 46 BluetoothBitPerSampleDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)47 public BluetoothBitPerSampleDialogPreference(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_bit_per_sample_radio_group; 56 } 57 initialize(Context context)58 private void initialize(Context context) { 59 mRadioButtonIds.add(R.id.bluetooth_audio_bit_per_sample_default); 60 mRadioButtonIds.add(R.id.bluetooth_audio_bit_per_sample_16); 61 mRadioButtonIds.add(R.id.bluetooth_audio_bit_per_sample_24); 62 mRadioButtonIds.add(R.id.bluetooth_audio_bit_per_sample_32); 63 String[] stringArray = context.getResources().getStringArray( 64 com.android.settingslib.R.array.bluetooth_a2dp_codec_bits_per_sample_titles); 65 for (int i = 0; i < stringArray.length; i++) { 66 mRadioButtonStrings.add(stringArray[i]); 67 } 68 stringArray = context.getResources().getStringArray( 69 com.android.settingslib.R.array.bluetooth_a2dp_codec_bits_per_sample_summaries); 70 for (int i = 0; i < stringArray.length; i++) { 71 mSummaryStrings.add(stringArray[i]); 72 } 73 } 74 } 75