Update USb preference controller to use the new summary texts.
- since the choose usb mode dialog and the preference summary use separate strings now, the two classes can have their own handling for getting the title/summary text and hence revert the earlier change that move the setTitle() and setSummary() from the activity to controller - only show summary for the option for "supply power", and don't set summary for all other options - update the controller to use the new summary text. - update test correspondingly. Change-Id: Ie56eb33ba24262e6f3a2259e4ee5ad6f3bfb8061 Fix: 36234108 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -31,6 +31,7 @@ import android.hardware.usb.UsbManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -40,7 +41,6 @@ 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;
|
||||
|
||||
@@ -136,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(UsbModePreferenceController.getTitle(mode));
|
||||
titleView.setText(getTitle(mode));
|
||||
TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
|
||||
summaryView.setText(UsbModePreferenceController.getSummary(mode));
|
||||
updateSummary(summaryView, mode);
|
||||
|
||||
if (disallowedByAdmin) {
|
||||
if (mEnforcedAdmin != null) {
|
||||
@@ -178,4 +178,27 @@ public class UsbModeChooserActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static void updateSummary(TextView summaryView, int mode) {
|
||||
if (mode == (UsbBackend.MODE_POWER_SOURCE | UsbBackend.MODE_DATA_NONE)) {
|
||||
summaryView.setText(R.string.usb_use_power_only_desc);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
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