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

Commit 8dec2efc authored by changbetty's avatar changbetty
Browse files

Change the SIM color for passing the GAR

Bug: 195710292
Test: Manual test
Test: make RunSettingsRoboTests ROBOTEST_FILTER=RenameMobileNetworkDialogFragmentTest
Change-Id: I7b7a3e1b6d72709acbae0a0433af897a28d73afc
Merged-In: I7b7a3e1b6d72709acbae0a0433af897a28d73afc
parent 7514b30f
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -1179,14 +1179,24 @@
        <item>Cached (empty)</item>
    </string-array>

    <!-- Array of color for sim color for multi-sim in light mode -->
    <string-array name="sim_color_light">
        <item>@color/SIM_color_cyan</item>
        <item>@color/SIM_color_blue800</item>
        <item>@color/SIM_color_green800</item>
        <item>@color/SIM_color_purple800</item>
        <item>@color/SIM_color_pink800</item>
        <item>@color/SIM_color_orange</item>
    </string-array>

    <!-- Array of titles for sim color for multi-sim -->
    <string-array name="color_picker">
        <item>Teal</item>
        <item>Cyan</item>
        <item>Blue</item>
        <item>Indigo</item>
        <item>Green</item>
        <item>Purple</item>
        <item>Pink</item>
        <item>Red</item>
        <item>Orange</item>
    </string-array>

    <!-- Automatic storage management settings. The amount of days for the automatic storage manager
+14 −6
Original line number Diff line number Diff line
@@ -184,13 +184,21 @@
    <color name="SIM_color_pink">#ffc2185b</color> <!-- Material Pink 700 -->
    <color name="SIM_color_red">#ffd32f2f</color> <!-- Material Red 700 -->

    <!-- SIM colors updated for GAR -->
    <color name="SIM_color_cyan">#ff006D74</color> <!-- Material Custom Cyan -->
    <color name="SIM_color_blue800">#ff185ABC</color> <!-- Material Blue 800 -->
    <color name="SIM_color_green800">#ff137333</color> <!-- Material Green 800 -->
    <color name="SIM_color_purple800">#ff7627bb</color> <!-- Material Purple 800 -->
    <color name="SIM_color_pink800">#ffb80672</color> <!-- Material Pink 800 -->
    <color name="SIM_color_orange">#ff995400</color> <!-- Material Custom Orange -->

    <!-- Dark mode SIM colors -->
    <color name="SIM_dark_mode_color_teal">#ff80cbc4</color> <!-- Material Teal 200 -->
    <color name="SIM_dark_mode_color_blue">#ff90caf9</color> <!-- Material Blue 200 -->
    <color name="SIM_dark_mode_color_indigo">#ffc5cae9</color> <!-- Material Indigo 100 -->
    <color name="SIM_dark_mode_color_purple">#ffe1bee7</color> <!-- Material Purple 100 -->
    <color name="SIM_dark_mode_color_pink">#fff48fb1</color> <!-- Material Pink 200 -->
    <color name="SIM_dark_mode_color_red">#ffef9a9a</color> <!-- Material Red 200 -->
    <color name="SIM_dark_mode_color_cyan">#ff4DD0E1</color> <!-- Material Cyan 300 -->
    <color name="SIM_dark_mode_color_blue">#ff8AB4F8</color> <!-- Material Blue 300 -->
    <color name="SIM_dark_mode_color_green">#ff81C995</color> <!-- Material Green 300 -->
    <color name="SIM_dark_mode_color_purple">#ffC58AF9</color> <!-- Material Purple 300 -->
    <color name="SIM_dark_mode_color_pink">#ffff8bcb</color> <!-- Material Pink 300 -->
    <color name="SIM_dark_mode_color_orange">#fffcad70</color> <!-- Material Orange 300 -->

    <!-- Top app bar colors -->
    <color name="color_surface_header">@*android:color/surface_header_light</color>
+39 −16
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.settingslib.DeviceInfoUtils;

import com.google.common.collect.ImmutableMap;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@@ -108,18 +109,18 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
        mSubId = getArguments().getInt(KEY_SUBSCRIPTION_ID);
        Resources res = context.getResources();
        mLightDarkMap = ImmutableMap.<Integer, Integer>builder()
                .put(res.getInteger(R.color.SIM_color_teal),
                        res.getInteger(R.color.SIM_dark_mode_color_teal))
                .put(res.getInteger(R.color.SIM_color_blue),
                .put(res.getInteger(R.color.SIM_color_cyan),
                        res.getInteger(R.color.SIM_dark_mode_color_cyan))
                .put(res.getInteger(R.color.SIM_color_blue800),
                        res.getInteger(R.color.SIM_dark_mode_color_blue))
                .put(res.getInteger(R.color.SIM_color_indigo),
                        res.getInteger(R.color.SIM_dark_mode_color_indigo))
                .put(res.getInteger(R.color.SIM_color_purple),
                .put(res.getInteger(R.color.SIM_color_green800),
                        res.getInteger(R.color.SIM_dark_mode_color_green))
                .put(res.getInteger(R.color.SIM_color_purple800),
                        res.getInteger(R.color.SIM_dark_mode_color_purple))
                .put(res.getInteger(R.color.SIM_color_pink),
                .put(res.getInteger(R.color.SIM_color_pink800),
                        res.getInteger(R.color.SIM_dark_mode_color_pink))
                .put(res.getInteger(R.color.SIM_color_red),
                        res.getInteger(R.color.SIM_dark_mode_color_red))
                .put(res.getInteger(R.color.SIM_color_orange),
                        res.getInteger(R.color.SIM_dark_mode_color_orange))
                .build();
    }

@@ -175,12 +176,7 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
        final ColorAdapter adapter = new ColorAdapter(getContext(),
                R.layout.dialog_mobile_network_color_picker_item, mColors);
        mColorSpinner.setAdapter(adapter);
        for (int i = 0; i < mColors.length; i++) {
            if (mColors[i].getColor() == info.getIconTint()) {
                mColorSpinner.setSelection(i);
                break;
            }
        }
        mColorSpinner.setSelection(getSimColorIndex(info.getIconTint()));

        final TextView operatorName = view.findViewById(R.id.operator_name_value);
        mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
@@ -239,7 +235,7 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen

    private Color[] getColors() {
        final Resources res = getContext().getResources();
        final int[] colorInts = res.getIntArray(com.android.internal.R.array.sim_colors);
        final int[] colorInts = res.getIntArray(R.array.sim_color_light);
        final String[] colorStrings = res.getStringArray(R.array.color_picker);
        final int iconSize = res.getDimensionPixelSize(R.dimen.color_swatch_size);
        final int strokeWidth = res.getDimensionPixelSize(R.dimen.color_swatch_stroke_width);
@@ -286,4 +282,31 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
    private int getDarkColor(int lightColor) {
        return mLightDarkMap.getOrDefault(lightColor, lightColor);
    }

    /*
    * Get the color index from previous color that defined in Android OS
    * (frameworks/base/core/res/res/values/arrays.xml). If can't find the color, continue to look
    * for it in the new color plattee. If not, give it the first index.
    */

    private int getSimColorIndex(int color) {
        int index = -1;
        final int[] previousSimColorInts =
                getContext().getResources().getIntArray(com.android.internal.R.array.sim_colors);
        for (int i = 0; i < previousSimColorInts.length; i++) {
            if (previousSimColorInts[i] == color) {
                index = i;
            }
        }

        if (index == -1) {
            for (int i = 0; i < mColors.length; i++) {
                if (mColors[i].getColor() == color) {
                    index = i;
                }
            }
        }

        return index == -1 ? 0 : index;
    }
}
+29 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public class RenameMobileNetworkDialogFragmentTest {
                eq(SubscriptionManager.NAME_SOURCE_USER_INPUT));
        assertThat(captor.getValue()).isEqualTo("test2");
        verify(mSubscriptionMgr)
                .setIconTint(eq(Color.parseColor("#ff00796b" /* teal */)), eq(mSubscriptionId));
                .setIconTint(eq(Color.parseColor("#ff006D74" /* cyan */)), eq(mSubscriptionId));
    }

    @Test
@@ -174,6 +174,34 @@ public class RenameMobileNetworkDialogFragmentTest {
        assertThat(view.findViewById(R.id.number_label).getVisibility()).isEqualTo(View.GONE);
    }

    @Test
    public void populateView_getPreviousSimColor_setCorrectSelection() {
        final View view = LayoutInflater.from(mActivity).inflate(
                R.layout.dialog_mobile_network_rename, null);
        when(mSubscriptionInfo.getIconTint())
                .thenReturn(Color.parseColor("#ff3367d6"/* blue700 */));

        startDialog();
        mFragment.populateView(view);

        final Spinner colorSpinnerView = mFragment.getColorSpinnerView();
        assertThat(colorSpinnerView.getSelectedItemPosition()).isEqualTo(1);
    }

    @Test
    public void populateView_getUpdatedSimColor_setCorrectSelection() {
        final View view = LayoutInflater.from(mActivity).inflate(
                R.layout.dialog_mobile_network_rename, null);
        when(mSubscriptionInfo.getIconTint())
                .thenReturn(Color.parseColor("#ff137333"/* Green800 */));

        startDialog();
        mFragment.populateView(view);

        final Spinner colorSpinnerView = mFragment.getColorSpinnerView();
        assertThat(colorSpinnerView.getSelectedItemPosition()).isEqualTo(2);
    }

    /**
     * Helper method to start the dialog
     */