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

Commit 7fb5e757 authored by jackqdyulei's avatar jackqdyulei
Browse files

Make BT icon colorful

Add new method to get rainbow bt icon and also refactor
AdaptiveHomepageIcon:
1. Rename
2. Add ConstantState

Bug: 126425211
Test: RunSettingsRoboTests

Change-Id: Idb8aaf253d0d9e2ab33d8852f093e6689ebadde4
parent f5e2bfee
Loading
Loading
Loading
Loading
+225 −1
Original line number Diff line number Diff line
@@ -1309,6 +1309,230 @@
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_icon_1&quot;>#48a50e0e&lt;/color> &lt;!-- 72% Material Red 900 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="144"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_icon_2&quot;>#480d652d&lt;/color> &lt;!-- 72% Material Green 900 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="145"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_icon_3&quot;>#48e37400&lt;/color> &lt;!-- 72% Material Yellow 900 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="146"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_icon_4&quot;>#48b06000&lt;/color> &lt;!-- 72% Material Orange 900 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="147"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_icon_5&quot;>#489c166b&lt;/color> &lt;!-- 72% Material Pink 900 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="148"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_icon_6&quot;>#48681da8&lt;/color> &lt;!-- 72% Material Purple 900 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="149"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_icon_7&quot;>#48007b83&lt;/color> &lt;!-- 72% Material Cyan 900 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="150"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_bg_1&quot;>#fad2cf&lt;/color> &lt;!-- Material Red 100 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="152"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_bg_2&quot;>#ceead6&lt;/color> &lt;!-- Material Green 100 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="153"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_bg_3&quot;>#feefc3&lt;/color> &lt;!-- Material Yellow 100 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="154"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_bg_4&quot;>#fedfc8&lt;/color> &lt;!-- Material Orange 100 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="155"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_bg_5&quot;>#fdcfe8&lt;/color> &lt;!-- Material Pink 100 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="156"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_bg_6&quot;>#e9d2fd&lt;/color> &lt;!-- Material Purple 100 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="157"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;bt_color_bg_7&quot;>#cbf0f8&lt;/color> &lt;!-- Material Cyan 100 -->"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="158"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
@@ -2537,7 +2761,7 @@
        errorLine2="                                   ~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/strings.xml"
            line="6026"
            line="6020"
            column="36"/>
    </issue>

+21 −0
Original line number Diff line number Diff line
@@ -1378,4 +1378,25 @@
         <item>@string/wifi_calling_mode_cellular_preferred_summary</item>
    </string-array>

    <!-- Bluetooth icon foreground colors -->
    <integer-array name="bt_icon_fg_colors">
        <item>@color/bt_color_icon_1</item>
        <item>@color/bt_color_icon_2</item>
        <item>@color/bt_color_icon_3</item>
        <item>@color/bt_color_icon_4</item>
        <item>@color/bt_color_icon_5</item>
        <item>@color/bt_color_icon_6</item>
        <item>@color/bt_color_icon_7</item>
    </integer-array>

    <!-- Bluetooth icon background colors -->
    <integer-array name="bt_icon_bg_colors">
        <item>@color/bt_color_bg_1</item>
        <item>@color/bt_color_bg_2</item>
        <item>@color/bt_color_bg_3</item>
        <item>@color/bt_color_bg_4</item>
        <item>@color/bt_color_bg_5</item>
        <item>@color/bt_color_bg_6</item>
        <item>@color/bt_color_bg_7</item>
    </integer-array>
</resources>
+16 −0
Original line number Diff line number Diff line
@@ -140,4 +140,20 @@
    <color name="qr_focused_corner_line_color">#ff1a73e8</color>
    <color name="qr_background_color">#b3ffffff</color> <!-- 70% white transparency -->
    <!-- End of QR code scanner colors -->

    <color name="bt_color_icon_1">#48a50e0e</color> <!-- 72% Material Red 900 -->
    <color name="bt_color_icon_2">#480d652d</color> <!-- 72% Material Green 900 -->
    <color name="bt_color_icon_3">#48e37400</color> <!-- 72% Material Yellow 900 -->
    <color name="bt_color_icon_4">#48b06000</color> <!-- 72% Material Orange 900 -->
    <color name="bt_color_icon_5">#489c166b</color> <!-- 72% Material Pink 900 -->
    <color name="bt_color_icon_6">#48681da8</color> <!-- 72% Material Purple 900 -->
    <color name="bt_color_icon_7">#48007b83</color> <!-- 72% Material Cyan 900 -->

    <color name="bt_color_bg_1">#fad2cf</color> <!-- Material Red 100 -->
    <color name="bt_color_bg_2">#ceead6</color> <!-- Material Green 100 -->
    <color name="bt_color_bg_3">#feefc3</color> <!-- Material Yellow 100 -->
    <color name="bt_color_bg_4">#fedfc8</color> <!-- Material Orange 100 -->
    <color name="bt_color_bg_5">#fdcfe8</color> <!-- Material Pink 100 -->
    <color name="bt_color_bg_6">#e9d2fd</color> <!-- Material Purple 100 -->
    <color name="bt_color_bg_7">#cbf0f8</color> <!-- Material Cyan 100 -->
</resources>
 No newline at end of file
+2 −5
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import androidx.preference.PreferenceScreen;

import com.android.settings.R;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -66,10 +65,8 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController
    }

    protected void setHeaderProperties() {
        final Pair<Drawable, String> pair = BluetoothUtils
                .getBtClassDrawableWithDescription(mContext, mCachedDevice,
                        mContext.getResources().getFraction(R.fraction.bt_battery_scale_fraction, 1,
                                1));
        final Pair<Drawable, String> pair = Utils.getBtRainbowDrawableWithDescription(mContext,
                mCachedDevice);
        String summaryText = mCachedDevice.getConnectionSummary();
        // If both the hearing aids are connected, two device status should be shown.
        // If Second Summary is unavailable, to set it to null.
+2 −4
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.GearPreference;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;

@@ -130,8 +129,8 @@ public final class BluetoothDevicePreference extends GearPreference implements
        // Null check is done at the framework
        setSummary(mCachedDevice.getConnectionSummary());

        final Pair<Drawable, String> pair = BluetoothUtils
                .getBtClassDrawableWithDescription(getContext(), mCachedDevice);
        final Pair<Drawable, String> pair = Utils
                .getBtRainbowDrawableWithDescription(getContext(), mCachedDevice);
        if (pair.first != null) {
            setIcon(pair.first);
            contentDescription = pair.second;
@@ -246,5 +245,4 @@ public final class BluetoothDevicePreference extends GearPreference implements
                    R.string.bluetooth_pairing_error_message);
        }
    }

}
Loading