use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class UsbDefaultFragment method refresh.
private void refresh(long functions) {
final PreferenceScreen screen = getPreferenceScreen();
for (long option : UsbDetailsFunctionsController.FUNCTIONS_MAP.keySet()) {
final RadioButtonPreference pref = screen.findPreference(UsbBackend.usbFunctionsToString(option));
if (pref != null) {
final boolean isSupported = mUsbBackend.areFunctionsSupported(option);
pref.setEnabled(isSupported);
if (isSupported) {
if (functions == UsbManager.FUNCTION_NCM) {
pref.setChecked(UsbManager.FUNCTION_RNDIS == option);
} else {
pref.setChecked(functions == option);
}
}
}
}
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class UsbDetailsDataRoleController method makeRadioPreference.
private RadioButtonPreference makeRadioPreference(String key, int titleId) {
RadioButtonPreference pref = new RadioButtonPreference(mPreferenceCategory.getContext());
pref.setKey(key);
pref.setTitle(titleId);
pref.setOnClickListener(this);
mPreferenceCategory.addPreference(pref);
return pref;
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class UsbDetailsFunctionsController method onRadioButtonClicked.
@Override
public void onRadioButtonClicked(RadioButtonPreference preference) {
final long function = UsbBackend.usbFunctionsFromString(preference.getKey());
final long previousFunction = mUsbBackend.getCurrentFunctions();
if (DEBUG) {
Log.d(TAG, "onRadioButtonClicked() function : " + function + ", toString() : " + UsbManager.usbFunctionsToString(function) + ", previousFunction : " + previousFunction + ", toString() : " + UsbManager.usbFunctionsToString(previousFunction));
}
if (function != previousFunction && !Utils.isMonkeyRunning() && !isClickEventIgnored(function, previousFunction)) {
mPreviousFunction = previousFunction;
// Update the UI in advance to make it looks smooth
final RadioButtonPreference prevPref = (RadioButtonPreference) mProfilesContainer.findPreference(UsbBackend.usbFunctionsToString(mPreviousFunction));
if (prevPref != null) {
prevPref.setChecked(false);
preference.setChecked(true);
}
if (function == UsbManager.FUNCTION_RNDIS || function == UsbManager.FUNCTION_NCM) {
// We need to have entitlement check for usb tethering, so use API in
// TetheringManager.
mTetheringManager.startTethering(TetheringManager.TETHERING_USB, new HandlerExecutor(mHandler), mOnStartTetheringCallback);
} else {
mUsbBackend.setCurrentFunctions(function);
}
}
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class UsbDetailsFunctionsController method refresh.
@Override
protected void refresh(boolean connected, long functions, int powerRole, int dataRole) {
if (DEBUG) {
Log.d(TAG, "refresh() connected : " + connected + ", functions : " + functions + ", powerRole : " + powerRole + ", dataRole : " + dataRole);
}
if (!connected || dataRole != DATA_ROLE_DEVICE) {
mProfilesContainer.setEnabled(false);
} else {
// Functions are only available in device mode
mProfilesContainer.setEnabled(true);
}
RadioButtonPreference pref;
for (long option : FUNCTIONS_MAP.keySet()) {
int title = FUNCTIONS_MAP.get(option);
pref = getProfilePreference(UsbBackend.usbFunctionsToString(option), title);
// Only show supported options
if (mUsbBackend.areFunctionsSupported(option)) {
if (isAccessoryMode(functions)) {
pref.setChecked(UsbManager.FUNCTION_MTP == option);
} else if (functions == UsbManager.FUNCTION_NCM) {
pref.setChecked(UsbManager.FUNCTION_RNDIS == option);
} else {
pref.setChecked(functions == option);
}
} else {
mProfilesContainer.removePreference(pref);
}
}
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class OptimizedPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new OptimizedPreferenceController(RuntimeEnvironment.application, UID, PACKAGE_NAME);
mPreference = new RadioButtonPreference(RuntimeEnvironment.application);
mController.mBatteryOptimizeUtils = mockBatteryOptimizeUtils;
}
Aggregations