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 LDAC quality
27  */
28 public class BluetoothQualityDialogPreference extends BaseBluetoothDialogPreference implements
29         RadioGroup.OnCheckedChangeListener {
30 
BluetoothQualityDialogPreference(Context context)31     public BluetoothQualityDialogPreference(Context context) {
32         super(context);
33         initialize(context);
34     }
35 
BluetoothQualityDialogPreference(Context context, AttributeSet attrs)36     public BluetoothQualityDialogPreference(Context context, AttributeSet attrs) {
37         super(context, attrs);
38         initialize(context);
39     }
40 
BluetoothQualityDialogPreference(Context context, AttributeSet attrs, int defStyleAttr)41     public BluetoothQualityDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
42         super(context, attrs, defStyleAttr);
43         initialize(context);
44     }
45 
BluetoothQualityDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)46     public BluetoothQualityDialogPreference(Context context, AttributeSet attrs, int defStyleAttr,
47                                             int defStyleRes) {
48         super(context, attrs, defStyleAttr, defStyleRes);
49         initialize(context);
50     }
51 
52     @Override
getRadioButtonGroupId()53     protected int getRadioButtonGroupId() {
54         return R.id.bluetooth_audio_quality_radio_group;
55     }
56 
57     @Override
getDefaultIndex()58     protected int getDefaultIndex() {
59         return 3;
60     }
61 
initialize(Context context)62     private void initialize(Context context) {
63         mRadioButtonIds.add(R.id.bluetooth_audio_quality_default);
64         mRadioButtonIds.add(R.id.bluetooth_audio_quality_optimized_quality);
65         mRadioButtonIds.add(R.id.bluetooth_audio_quality_optimized_connection);
66         mRadioButtonIds.add(R.id.bluetooth_audio_quality_best_effort);
67         String[] stringArray = context.getResources().getStringArray(
68                 R.array.bluetooth_a2dp_codec_ldac_playback_quality_titles);
69         for (int i = 0; i < stringArray.length; i++) {
70             mRadioButtonStrings.add(stringArray[i]);
71         }
72         stringArray = context.getResources().getStringArray(
73                 R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries);
74         for (int i = 0; i < stringArray.length; i++) {
75             mSummaryStrings.add(stringArray[i]);
76         }
77     }
78 }
79