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

Commit c8343406 authored by Aaron Heuckroth's avatar Aaron Heuckroth
Browse files

Use different colors for grid-based global actions menu.

Refactor EmergencyActions to group coloring code.

Test: Automated tests pass, global actions menu colors match mocks for dark + light themes. Buttons and text are readable.
Change-Id: Ia0ca8c31d09cda8acda7b8677c2ccd923cc2c0c5

Fixes: 126445990
Fixes: 128768560
parent f85bf680
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@
            android:paddingTop="@dimen/global_actions_grid_vertical_padding"
            android:paddingBottom="@dimen/global_actions_grid_vertical_padding"
            android:orientation="vertical"
            android:background="?android:attr/colorBackgroundFloating"
            android:gravity="center"
            android:translationZ="@dimen/global_actions_translate"
        />
@@ -48,7 +47,6 @@
            android:paddingRight="@dimen/global_actions_grid_horizontal_padding"
            android:paddingTop="@dimen/global_actions_grid_vertical_padding"
            android:paddingBottom="@dimen/global_actions_grid_vertical_padding"
            android:background="?android:attr/colorBackgroundFloating"
        >
            <LinearLayout
                android:layout_width="wrap_content"
+12 −0
Original line number Diff line number Diff line
@@ -47,4 +47,16 @@

    <!-- The color of the background in the bottom part of QSCustomizer -->
    <color name="qs_customize_decoration">@color/GM2_grey_800</color>

    <!-- The color of the background in the separated list of the Global Actions menu -->
    <color name="global_actions_separated_background">@color/GM2_grey_900</color>

    <!-- The color of the background in the grid of the Global Actions menu -->
    <color name="global_actions_grid_background">@color/GM2_grey_800</color>

    <!-- The color of the text in the Global Actions menu -->
    <color name="global_actions_text">@color/GM2_grey_200</color>

    <!-- The color of the text in the Global Actions menu -->
    <color name="global_actions_alert_text">@color/GM2_red_300</color>
</resources>
 No newline at end of file
+15 −0
Original line number Diff line number Diff line
@@ -38,6 +38,18 @@
    <color name="qs_customize_background">@color/GM2_grey_50</color>
    <color name="qs_customize_decoration">@color/GM2_grey_100</color>

    <!-- The color of the background in the separated list of the Global Actions menu -->
    <color name="global_actions_separated_background">@color/GM2_grey_300</color>

    <!-- The color of the background in the grid of the Global Actions menu -->
    <color name="global_actions_grid_background">@color/GM2_grey_200</color>

    <!-- The color of the text in the Global Actions menu -->
    <color name="global_actions_text">@color/GM2_grey_900</color>

    <!-- The color of the text in the Global Actions menu -->
    <color name="global_actions_alert_text">@color/GM2_red_500</color>

    <!-- Tint color for the content on the notification overflow card. -->
    <color name="keyguard_overflow_content_color">#ff686868</color>

@@ -149,4 +161,7 @@
    <color name="GM2_grey_700">#5F6368</color>
    <color name="GM2_grey_800">#3C4043</color>
    <color name="GM2_grey_900">#202124</color>

    <color name="GM2_red_300">#F28B82</color>
    <color name="GM2_red_500">#B71C1C</color>
</resources>
+54 −44
Original line number Diff line number Diff line
@@ -379,8 +379,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
                    mHasLogoutButton = true;
                }
            } else if (GLOBAL_ACTION_KEY_EMERGENCY.equals(actionKey)) {
                if (shouldUseSeparatedView()
                        && !mEmergencyAffordanceManager.needsEmergencyAffordance()) {
                if (!mEmergencyAffordanceManager.needsEmergencyAffordance()) {
                    mItems.add(new EmergencyDialerAction());
                }
            } else {
@@ -391,7 +390,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
        }

        if (mEmergencyAffordanceManager.needsEmergencyAffordance()) {
            mItems.add(getEmergencyAction());
            mItems.add(new EmergencyAffordanceAction());
        }

        mAdapter = new MyAdapter();
@@ -469,22 +468,33 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
        }
    }

    private class EmergencyDialerAction extends SinglePressAction {
        private EmergencyDialerAction() {
            super(R.drawable.ic_faster_emergency,
                    R.string.global_action_emergency);
    private abstract class EmergencyAction extends SinglePressAction {
        EmergencyAction(int iconResId, int messageResId) {
            super(iconResId, messageResId);
        }

        @Override
        public void onPress() {
            MetricsLogger.action(mContext, MetricsEvent.ACTION_EMERGENCY_DIALER_FROM_POWER_MENU);
            Intent intent = new Intent(EmergencyDialerConstants.ACTION_DIAL);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.putExtra(EmergencyDialerConstants.EXTRA_ENTRY_TYPE,
                    EmergencyDialerConstants.ENTRY_TYPE_POWER_MENU);
            mContext.startActivityAsUser(intent, UserHandle.CURRENT);
        public boolean shouldBeSeparated() {
            return shouldUseSeparatedView();
        }

        @Override
        public View create(
                Context context, View convertView, ViewGroup parent, LayoutInflater inflater) {
            View v = super.create(context, convertView, parent, inflater);
            int textColor;
            if (shouldBeSeparated()) {
                textColor = v.getResources().getColor(
                        com.android.systemui.R.color.global_actions_alert_text);
            } else {
                textColor = v.getResources().getColor(
                        com.android.systemui.R.color.global_actions_text);
            }
            TextView messageView = v.findViewById(R.id.message);
            messageView.setTextColor(textColor);
            ImageView icon = (ImageView) v.findViewById(R.id.icon);
            icon.getDrawable().setTint(textColor);
            return v;
        }

        @Override
@@ -496,10 +506,36 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
        public boolean showBeforeProvisioning() {
            return true;
        }
    }

    private class EmergencyAffordanceAction extends EmergencyAction {
        EmergencyAffordanceAction() {
            super(R.drawable.emergency_icon,
                    R.string.global_action_emergency);
        }

        @Override
        public boolean shouldBeSeparated() {
            return true;
        public void onPress() {
            mEmergencyAffordanceManager.performEmergencyCall();
        }
    }

    private class EmergencyDialerAction extends EmergencyAction {
        private EmergencyDialerAction() {
            super(R.drawable.ic_faster_emergency,
                    R.string.global_action_emergency);
        }

        @Override
        public void onPress() {
            MetricsLogger.action(mContext, MetricsEvent.ACTION_EMERGENCY_DIALER_FROM_POWER_MENU);
            Intent intent = new Intent(EmergencyDialerConstants.ACTION_DIAL);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.putExtra(EmergencyDialerConstants.EXTRA_ENTRY_TYPE,
                    EmergencyDialerConstants.ENTRY_TYPE_POWER_MENU);
            mContext.startActivityAsUser(intent, UserHandle.CURRENT);
        }
    }

@@ -688,32 +724,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
        };
    }

    private Action getEmergencyAction() {
        Drawable emergencyIcon = mContext.getDrawable(R.drawable.emergency_icon);
        if (!shouldUseSeparatedView()) {
            // use un-colored legacy treatment
            emergencyIcon.setTintList(null);
        }

        return new SinglePressAction(R.drawable.emergency_icon,
                R.string.global_action_emergency) {
            @Override
            public void onPress() {
                mEmergencyAffordanceManager.performEmergencyCall();
            }

            @Override
            public boolean showDuringKeyguard() {
                return true;
            }

            @Override
            public boolean showBeforeProvisioning() {
                return true;
            }
        };
    }

    private Action getAssistAction() {
        return new SinglePressAction(R.drawable.ic_action_assist_focused,
                R.string.global_action_assist) {
+8 −3
Original line number Diff line number Diff line
@@ -42,11 +42,16 @@ public class GlobalActionsGridLayout extends MultiListLayout {
    }

    private void setBackgrounds() {
        int gridBackgroundColor = getResources().getColor(
                com.android.systemui.R.color.global_actions_grid_background, null);
        int separatedBackgroundColor = getResources().getColor(
                com.android.systemui.R.color.global_actions_separated_background, null);
        HardwareBgDrawable listBackground  = new HardwareBgDrawable(true, true, getContext());
        HardwareBgDrawable separatedViewBackground = new HardwareBgDrawable(true, true,
                getContext());
        HardwareBgDrawable separatedBackground = new HardwareBgDrawable(true, true, getContext());
        listBackground.setTint(gridBackgroundColor);
        separatedBackground.setTint(separatedBackgroundColor);
        getListView().setBackground(listBackground);
        getSeparatedView().setBackground(separatedViewBackground);
        getSeparatedView().setBackground(separatedBackground);
    }

    @Override
+1 −1

File changed.

Contains only whitespace changes.

Loading