Add Usb preference to connected devices dashboard.
Add Usb preference and the corresponding controller. Change-Id: I79e3f20b5c024ece0515f9a6cba1185ba8b8c7be Fixes: 31800290 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -40,6 +40,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settings.connecteddevice.UsbModePreferenceController;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
@@ -135,9 +136,9 @@ public class UsbModeChooserActivity extends Activity {
|
||||
View v = mLayoutInflater.inflate(R.layout.restricted_radio_with_summary, container, false);
|
||||
|
||||
TextView titleView = (TextView) v.findViewById(android.R.id.title);
|
||||
titleView.setText(getTitle(mode));
|
||||
titleView.setText(UsbModePreferenceController.getTitle(mode));
|
||||
TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
|
||||
summaryView.setText(getSummary(mode));
|
||||
summaryView.setText(UsbModePreferenceController.getSummary(mode));
|
||||
|
||||
if (disallowedByAdmin) {
|
||||
if (mEnforcedAdmin != null) {
|
||||
@@ -177,35 +178,4 @@ public class UsbModeChooserActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
private static int getSummary(int mode) {
|
||||
switch (mode) {
|
||||
case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_NONE:
|
||||
return R.string.usb_use_charging_only_desc;
|
||||
case UsbBackend.MODE_POWER_SOURCE | UsbBackend.MODE_DATA_NONE:
|
||||
return R.string.usb_use_power_only_desc;
|
||||
case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MTP:
|
||||
return R.string.usb_use_file_transfers_desc;
|
||||
case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_PTP:
|
||||
return R.string.usb_use_photo_transfers_desc;
|
||||
case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MIDI:
|
||||
return R.string.usb_use_MIDI_desc;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int getTitle(int mode) {
|
||||
switch (mode) {
|
||||
case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_NONE:
|
||||
return R.string.usb_use_charging_only;
|
||||
case UsbBackend.MODE_POWER_SOURCE | UsbBackend.MODE_DATA_NONE:
|
||||
return R.string.usb_use_power_only;
|
||||
case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MTP:
|
||||
return R.string.usb_use_file_transfers;
|
||||
case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_PTP:
|
||||
return R.string.usb_use_photo_transfers;
|
||||
case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MIDI:
|
||||
return R.string.usb_use_MIDI;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user