Tweak bluetooth name preference
- remove accent color from device name - remove useless ripple when tap Change-Id: I7800523eb27bafa24f3a4549b1acf02c869ac8c8 Fix: 62891178 Test: robotests
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
@@ -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
|
||||
|
Reference in New Issue
Block a user