Left align preferences and graphs to leave space for icon.

Bug: 33559277
Test: Visual inspection
Change-Id: Iacf9556826174a03b1cbf8a6f179b63d8686c5f5
This commit is contained in:
Fan Zhang
2016-12-19 11:14:59 -08:00
parent 1aba712008
commit ec407ff78c
22 changed files with 113 additions and 208 deletions

View File

@@ -65,9 +65,9 @@ public final class BluetoothDevicePreference extends Preference implements
/* Talk-back descriptions for various BT icons */
Resources r = getContext().getResources();
public final String COMPUTER = r.getString(R.string.bluetooth_talkback_computer);
public final String COMPUTER = r.getString(R.string.bluetooth_talkback_computer);
public final String INPUT_PERIPHERAL = r.getString(
R.string.bluetooth_talkback_input_peripheral);
R.string.bluetooth_talkback_input_peripheral);
public final String HEADSET = r.getString(R.string.bluetooth_talkback_headset);
public final String PHONE = r.getString(R.string.bluetooth_talkback_phone);
public final String IMAGING = r.getString(R.string.bluetooth_talkback_imaging);
@@ -85,11 +85,9 @@ public final class BluetoothDevicePreference extends Preference implements
mCachedDevice = cachedDevice;
setLayoutResource(R.layout.preference_bt_icon);
if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (! um.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) {
if (!um.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) {
setWidgetLayoutResource(R.layout.preference_bluetooth);
}
}
@@ -266,7 +264,7 @@ public final class BluetoothDevicePreference extends Preference implements
case BluetoothClass.Device.Major.PERIPHERAL:
return new Pair<Integer, String>(HidProfile.getHidClassDrawable(btClass),
INPUT_PERIPHERAL);
INPUT_PERIPHERAL);
case BluetoothClass.Device.Major.IMAGING:
return new Pair<Integer, String>(R.drawable.ic_bt_imaging, IMAGING);

View File

@@ -27,21 +27,28 @@ import com.android.settings.R;
*/
public class BluetoothProgressCategory extends ProgressCategory {
public BluetoothProgressCategory(Context context) {
this(context, null);
super(context);
init();
}
public BluetoothProgressCategory(Context context, AttributeSet attrs) {
this(context, attrs, 0);
super(context, attrs);
init();
}
public BluetoothProgressCategory(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
super(context, attrs, defStyleAttr);
init();
}
public BluetoothProgressCategory(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}
private void init() {
setIcon(R.drawable.ic_settings_bluetooth);
setEmptyTextRes(R.string.bluetooth_no_devices_found);
}
}

View File

@@ -161,13 +161,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
@Override
void addPreferencesForActivity() {
addPreferencesFromResource(R.xml.bluetooth_settings);
mPairedDevicesCategory = new PreferenceCategory(getPrefContext());
final Context prefContext = getPrefContext();
mPairedDevicesCategory = new PreferenceCategory(prefContext);
mPairedDevicesCategory.setKey(KEY_PAIRED_DEVICES);
mPairedDevicesCategory.setOrder(1);
getPreferenceScreen().addPreference(mPairedDevicesCategory);
mAvailableDevicesCategory = new BluetoothProgressCategory(getActivity());
mAvailableDevicesCategory = new BluetoothProgressCategory(prefContext);
mAvailableDevicesCategory.setSelectable(false);
mAvailableDevicesCategory.setOrder(2);
getPreferenceScreen().addPreference(mAvailableDevicesCategory);