Loading src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java +4 −10 Original line number Diff line number Diff line Loading @@ -24,10 +24,8 @@ import android.content.IntentFilter; import android.support.annotation.VisibleForTesting; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceScreen; import android.text.Spannable; import android.text.SpannableString; import android.text.BidiFormatter; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import android.util.Log; import com.android.settings.R; Loading @@ -48,7 +46,6 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle public static final String KEY_DEVICE_NAME = "device_name"; private final int mAccentColor; @VisibleForTesting Preference mPreference; Loading @@ -70,7 +67,6 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle @VisibleForTesting BluetoothDeviceNamePreferenceController(Context context, LocalBluetoothAdapter localAdapter) { super(context); mAccentColor = com.android.settingslib.Utils.getColorAccent(context); mLocalAdapter = localAdapter; } Loading Loading @@ -133,12 +129,10 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle // TODO: show error message in preference subtitle return; } final Spannable spannableName = new SpannableString(deviceName); spannableName.setSpan(new ForegroundColorSpan(mAccentColor), 0, spannableName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); final CharSequence summary = TextUtils.expandTemplate( mContext.getText(R.string.bluetooth_device_name_summary), spannableName); mContext.getText(R.string.bluetooth_device_name_summary), BidiFormatter.getInstance().unicodeWrap(deviceName)); preference.setSelectable(false); preference.setSummary(summary); } Loading tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java +1 −8 Original line number Diff line number Diff line Loading @@ -26,8 +26,6 @@ import static org.mockito.Mockito.verify; import android.content.Context; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceScreen; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import com.android.settings.TestConfig; import com.android.settings.testutils.SettingsRobolectricTestRunner; Loading Loading @@ -74,14 +72,9 @@ public class BluetoothDeviceNamePreferenceControllerTest { mController.updateDeviceName(mPreference, DEVICE_NAME); final CharSequence summary = mPreference.getSummary(); final Object[] spans = ((SpannableStringBuilder) summary).getSpans(0, summary.length(), Object.class); assertThat(summary.toString()) .isEqualTo("Visible as 'Nightshade' to other devices"); // Test summary only has one color span assertThat(spans).asList().hasSize(1); assertThat(spans[0]).isInstanceOf(ForegroundColorSpan.class); assertThat(mPreference.isSelectable()).isFalse(); } @Test Loading Loading
src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java +4 −10 Original line number Diff line number Diff line Loading @@ -24,10 +24,8 @@ import android.content.IntentFilter; import android.support.annotation.VisibleForTesting; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceScreen; import android.text.Spannable; import android.text.SpannableString; import android.text.BidiFormatter; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import android.util.Log; import com.android.settings.R; Loading @@ -48,7 +46,6 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle public static final String KEY_DEVICE_NAME = "device_name"; private final int mAccentColor; @VisibleForTesting Preference mPreference; Loading @@ -70,7 +67,6 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle @VisibleForTesting BluetoothDeviceNamePreferenceController(Context context, LocalBluetoothAdapter localAdapter) { super(context); mAccentColor = com.android.settingslib.Utils.getColorAccent(context); mLocalAdapter = localAdapter; } Loading Loading @@ -133,12 +129,10 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle // TODO: show error message in preference subtitle return; } final Spannable spannableName = new SpannableString(deviceName); spannableName.setSpan(new ForegroundColorSpan(mAccentColor), 0, spannableName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); final CharSequence summary = TextUtils.expandTemplate( mContext.getText(R.string.bluetooth_device_name_summary), spannableName); mContext.getText(R.string.bluetooth_device_name_summary), BidiFormatter.getInstance().unicodeWrap(deviceName)); preference.setSelectable(false); preference.setSummary(summary); } Loading
tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java +1 −8 Original line number Diff line number Diff line Loading @@ -26,8 +26,6 @@ import static org.mockito.Mockito.verify; import android.content.Context; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceScreen; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import com.android.settings.TestConfig; import com.android.settings.testutils.SettingsRobolectricTestRunner; Loading Loading @@ -74,14 +72,9 @@ public class BluetoothDeviceNamePreferenceControllerTest { mController.updateDeviceName(mPreference, DEVICE_NAME); final CharSequence summary = mPreference.getSummary(); final Object[] spans = ((SpannableStringBuilder) summary).getSpans(0, summary.length(), Object.class); assertThat(summary.toString()) .isEqualTo("Visible as 'Nightshade' to other devices"); // Test summary only has one color span assertThat(spans).asList().hasSize(1); assertThat(spans[0]).isInstanceOf(ForegroundColorSpan.class); assertThat(mPreference.isSelectable()).isFalse(); } @Test Loading