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

Commit 9ceae570 authored by Tony Wickham's avatar Tony Wickham
Browse files

Add support for dark tint on taskbar nav buttons

Tint the buttons when taskbar isn't drawing a background (either due to alpha or offset).

Test: Dark icons on a light wallpaper on home screen, dark icons when light IME is showing
Bug: 204256643
Change-Id: Iae634a1b604f50edc102905abd0d812a43c5346e
parent b797ca77
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
  -->

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/taskbar_icon_selection_ripple">
    android:color="@color/taskbar_nav_icon_selection_ripple">
    <item android:id="@android:id/mask">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white" />
+4 −1
Original line number Diff line number Diff line
@@ -15,7 +15,10 @@
-->
<ImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="@dimen/taskbar_nav_buttons_size"
    android:layout_height="@dimen/taskbar_nav_buttons_size"
    android:background="@drawable/taskbar_icon_click_feedback_roundrect"
    android:scaleType="center"/>
 No newline at end of file
    android:scaleType="center"
    android:tint="@color/taskbar_nav_icon_light_color"
    tools:ignore="UseAppTint" />
 No newline at end of file
+5 −5
Original line number Diff line number Diff line
@@ -25,14 +25,14 @@

    <!-- Taskbar -->
    <color name="taskbar_background">@color/overview_scrim_dark</color>
    <color name="taskbar_icon_selection_ripple">#E0E0E0</color>

    <color name="taskbar_nav_icon_selection_ripple">#E0E0E0</color>
    <color name="taskbar_nav_icon_light_color">#ffffff</color>
    <!-- The dark navigation button color is only used in the rare cases that taskbar isn't drawing
    its background and the underlying app has requested dark buttons. -->
    <color name="taskbar_nav_icon_dark_color">#99000000</color>
    <color name="taskbar_stashed_handle_light_color">#EBffffff</color>
    <color name="taskbar_stashed_handle_dark_color">#99000000</color>

    <color name="rotation_button_light_color">#FFF</color>
    <color name="rotation_button_dark_color">#99000000</color>

    <!-- Gesture navigation tutorial -->
    <color name="gesture_tutorial_back_arrow_color">#FFFFFFFF</color>

+31 −4
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@
 */
package com.android.launcher3.taskbar;

import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y_LONG_CLICK;
@@ -36,11 +34,11 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_N
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;

import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.annotation.DrawableRes;
import android.annotation.IdRes;
import android.annotation.LayoutRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Rect;
import android.graphics.Region;
@@ -94,7 +92,7 @@ public class NavbarButtonsViewController {

    private View.OnLongClickListener mA11yLongClickListener;
    private final ArrayList<StatePropertyHolder> mPropertyHolders = new ArrayList<>();
    private final ArrayList<View> mAllButtons = new ArrayList<>();
    private final ArrayList<ImageView> mAllButtons = new ArrayList<>();
    private int mState;

    private final TaskbarActivityContext mContext;
@@ -103,11 +101,17 @@ public class NavbarButtonsViewController {
    // Used for IME+A11Y buttons
    private final ViewGroup mEndContextualContainer;
    private final ViewGroup mStartContextualContainer;
    private final int mLightIconColor;
    private final int mDarkIconColor;

    private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat(
            this::updateNavButtonTranslationY);
    private final AnimatedFloat mNavButtonTranslationYMultiplier = new AnimatedFloat(
            this::updateNavButtonTranslationY);
    private final AnimatedFloat mTaskbarNavButtonDarkIntensity = new AnimatedFloat(
            this::updateNavButtonDarkIntensity);
    private final AnimatedFloat mNavButtonDarkIntensityMultiplier = new AnimatedFloat(
            this::updateNavButtonDarkIntensity);
    private final RotationButtonListener mRotationButtonListener = new RotationButtonListener();

    private final Rect mFloatingRotationButtonBounds = new Rect();
@@ -125,6 +129,9 @@ public class NavbarButtonsViewController {
        mNavButtonContainer = mNavButtonsView.findViewById(R.id.end_nav_buttons);
        mEndContextualContainer = mNavButtonsView.findViewById(R.id.end_contextual_buttons);
        mStartContextualContainer = mNavButtonsView.findViewById(R.id.start_contextual_buttons);

        mLightIconColor = context.getColor(R.color.taskbar_nav_icon_light_color);
        mDarkIconColor = context.getColor(R.color.taskbar_nav_icon_dark_color);
    }

    /**
@@ -379,6 +386,16 @@ public class NavbarButtonsViewController {
        return mTaskbarNavButtonTranslationY;
    }

    /** Use to set the dark intensity for the all nav+contextual buttons */
    public AnimatedFloat getTaskbarNavButtonDarkIntensity() {
        return mTaskbarNavButtonDarkIntensity;
    }

    /** Use to determine whether to use the dark intensity requested by the underlying app */
    public AnimatedFloat getNavButtonDarkIntensityMultiplier() {
        return mNavButtonDarkIntensityMultiplier;
    }

    /**
     * Does not call {@link #applyState()}. Don't forget to!
     */
@@ -402,6 +419,16 @@ public class NavbarButtonsViewController {
                * mNavButtonTranslationYMultiplier.value);
    }

    private void updateNavButtonDarkIntensity() {
        float darkIntensity = mTaskbarNavButtonDarkIntensity.value
                * mNavButtonDarkIntensityMultiplier.value;
        int iconColor = (int) ArgbEvaluator.getInstance().evaluate(darkIntensity, mLightIconColor,
                mDarkIconColor);
        for (ImageView button : mAllButtons) {
            button.setImageTintList(ColorStateList.valueOf(iconColor));
        }
    }

    private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType,
            ViewGroup parent, TaskbarNavButtonController navButtonController, @IdRes int id) {
        return addButton(drawableId, buttonType, parent, navButtonController, id,
+7 −2
Original line number Diff line number Diff line
@@ -151,8 +151,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                buttonController,
                new NavbarButtonsViewController(this, navButtonsView),
                new RotationButtonController(this,
                        c.getColor(R.color.rotation_button_light_color),
                        c.getColor(R.color.rotation_button_dark_color),
                        c.getColor(R.color.taskbar_nav_icon_light_color),
                        c.getColor(R.color.taskbar_nav_icon_dark_color),
                        R.drawable.ic_sysbar_rotate_button_ccw_start_0,
                        R.drawable.ic_sysbar_rotate_button_ccw_start_90,
                        R.drawable.ic_sysbar_rotate_button_cw_start_0,
@@ -394,6 +394,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        mControllers.rotationButtonController.onBehaviorChanged(displayId, behavior);
    }

    public void onNavButtonsDarkIntensityChanged(float darkIntensity) {
        mControllers.navbarButtonsViewController.getTaskbarNavButtonDarkIntensity()
                .updateValue(darkIntensity);
    }

    /**
     * Updates the TaskbarContainer to MATCH_PARENT vs original Taskbar size.
     */
Loading