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