Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03c595ce authored by Fan Zhang's avatar Fan Zhang Committed by Android (Google) Code Review
Browse files

Merge "Tweak bluetooth name preference" into oc-dr1-dev

parents 0ec3e4e6 9218e3b7
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -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);
    }

+1 −8
Original line number Diff line number Diff line
@@ -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