Rename RadioButtonPreference -> SelectorWithWidgetPreference.
This change is to reduce ambiguity as we're adding the option to style the preference like a checkbox as well. Bug: 190180868 Test: SelectorWithWidgetPreferenceTest, RunSettingsLibRoboTests Change-Id: Ie414347bf67ed394ef495604890c5851fc42dbc7
This commit is contained in:
@@ -31,7 +31,7 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.widget.RadioButtonPreference;
|
||||
import com.android.settingslib.widget.SelectorWithWidgetPreference;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -40,7 +40,7 @@ import java.util.Map;
|
||||
* This class controls the radio buttons for choosing between different USB functions.
|
||||
*/
|
||||
public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
implements RadioButtonPreference.OnClickListener {
|
||||
implements SelectorWithWidgetPreference.OnClickListener {
|
||||
|
||||
private static final String TAG = "UsbFunctionsCtrl";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
@@ -83,10 +83,10 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
/**
|
||||
* Gets a switch preference for the particular option, creating it if needed.
|
||||
*/
|
||||
private RadioButtonPreference getProfilePreference(String key, int titleId) {
|
||||
RadioButtonPreference pref = mProfilesContainer.findPreference(key);
|
||||
private SelectorWithWidgetPreference getProfilePreference(String key, int titleId) {
|
||||
SelectorWithWidgetPreference pref = mProfilesContainer.findPreference(key);
|
||||
if (pref == null) {
|
||||
pref = new RadioButtonPreference(mProfilesContainer.getContext());
|
||||
pref = new SelectorWithWidgetPreference(mProfilesContainer.getContext());
|
||||
pref.setKey(key);
|
||||
pref.setTitle(titleId);
|
||||
pref.setSingleLineTitle(false);
|
||||
@@ -108,7 +108,7 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
// Functions are only available in device mode
|
||||
mProfilesContainer.setEnabled(true);
|
||||
}
|
||||
RadioButtonPreference pref;
|
||||
SelectorWithWidgetPreference pref;
|
||||
for (long option : FUNCTIONS_MAP.keySet()) {
|
||||
int title = FUNCTIONS_MAP.get(option);
|
||||
pref = getProfilePreference(UsbBackend.usbFunctionsToString(option), title);
|
||||
@@ -128,7 +128,7 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
||||
public void onRadioButtonClicked(SelectorWithWidgetPreference preference) {
|
||||
final long function = UsbBackend.usbFunctionsFromString(preference.getKey());
|
||||
final long previousFunction = mUsbBackend.getCurrentFunctions();
|
||||
if (DEBUG) {
|
||||
@@ -142,8 +142,8 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
mPreviousFunction = previousFunction;
|
||||
|
||||
//Update the UI in advance to make it looks smooth
|
||||
final RadioButtonPreference prevPref =
|
||||
(RadioButtonPreference) mProfilesContainer.findPreference(
|
||||
final SelectorWithWidgetPreference prevPref =
|
||||
(SelectorWithWidgetPreference) mProfilesContainer.findPreference(
|
||||
UsbBackend.usbFunctionsToString(mPreviousFunction));
|
||||
if (prevPref != null) {
|
||||
prevPref.setChecked(false);
|
||||
|
Reference in New Issue
Block a user