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

Commit e3104682 authored by Jon Miranda's avatar Jon Miranda Committed by Jonathan Miranda
Browse files

Folder polish

- Update folder hint text to ensure enough contrast.
- Clamp down on alpha when animating to local color extraction
- Update colors to new spec.

Bug: 179209484
Bug: 175329686
Test: manual
Change-Id: I9471504e10f02630ae13b2c478ced1ee05bd5220
parent 3ed7ee76
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@
    <color name="workspace_text_color_light">@android:color/system_neutral1_0</color>
    <color name="workspace_text_color_dark">@android:color/system_neutral1_1000</color>

    <color name="folder_hint_text_color_light">@android:color/system_neutral1_50</color>
    <color name="folder_hint_text_color_dark">@android:color/system_neutral2_700</color>

    <color name="text_color_primary_dark">@android:color/system_neutral1_50</color>
    <color name="text_color_secondary_dark">@android:color/system_neutral2_200</color>
    <color name="text_color_tertiary_dark">@android:color/system_neutral2_400</color>
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@
    <color name="workspace_text_color_light">#FFF</color>
    <color name="workspace_text_color_dark">#FF000000</color>

    <color name="folder_hint_text_color_light">#FFF</color>
    <color name="folder_hint_text_color_dark">#FF000000</color>

    <color name="text_color_primary_dark">#FFFFFFFF</color>
    <color name="text_color_secondary_dark">#FFFFFFFF</color>
    <color name="text_color_tertiary_dark">#CCFFFFFF</color>
+6 −2
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@
        <item name="folderIconBorderColor">?android:attr/colorPrimary</item>
        <item name="folderTextColor">?android:attr/textColorPrimary</item>
        <item name="isFolderDarkText">true</item>
        <item name="folderHintColor">#89616161</item>
        <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
        <item name="loadingIconColor">#CCFFFFFF</item>
        <item name="iconOnlyShortcutColor">?android:attr/textColorSecondary</item>
        <item name="workProfileOverlayTextColor">#FF212121</item>
@@ -73,6 +73,7 @@
        <item name="folderFillColor">#FF3C4043</item> <!-- 100% GM2 800 -->
        <item name="folderTextColor">?attr/workspaceTextColor</item>
        <item name="isFolderDarkText">?attr/isWorkspaceDarkText</item>
        <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
        <item name="disabledIconAlpha">.254</item>

    </style>
@@ -89,6 +90,7 @@
        <item name="folderIconBorderColor">#FF80868B</item>
        <item name="folderTextColor">?attr/workspaceTextColor</item>
        <item name="isFolderDarkText">true</item>
        <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
    </style>

    <style name="LauncherTheme.Dark" parent="@style/LauncherTheme">
@@ -110,7 +112,7 @@
        <item name="folderIconBorderColor">?android:attr/colorPrimary</item>
        <item name="folderTextColor">?android:attr/textColorPrimary</item>
        <item name="isFolderDarkText">false</item>
        <item name="folderHintColor">#89CCCCCC</item>
        <item name="folderHintColor">@color/folder_hint_text_color_light</item>
        <item name="isMainColorDark">true</item>
        <item name="loadingIconColor">#99FFFFFF</item>
        <item name="iconOnlyShortcutColor">#B3FFFFFF</item>
@@ -123,6 +125,7 @@
        <item name="folderFillColor">#FF3C4043</item> <!-- 100% GM2 800 -->
        <item name="folderTextColor">@android:color/white</item>
        <item name="isFolderDarkText">false</item>
        <item name="folderHintColor">@color/folder_hint_text_color_light</item>
        <item name="disabledIconAlpha">.54</item>
    </style>

@@ -131,6 +134,7 @@
        <item name="folderFillColor">#CDFFFFFF</item>
        <item name="folderTextColor">?attr/workspaceTextColor</item>
        <item name="isFolderDarkText">?attr/isWorkspaceDarkText</item>
        <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
        <item name="workspaceTextColor">@color/workspace_text_color_dark</item>
        <item name="workspaceShadowColor">@android:color/transparent</item>
        <item name="workspaceAmbientShadowColor">@android:color/transparent</item>
+0 −10
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer;
import com.android.launcher3.widget.LocalColorExtractor;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -112,21 +111,12 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch

    protected boolean mIsOpen;

    // Index used to get background color when using local wallpaper color extraction.
    protected int mColorExtractionIndex;

    public AbstractFloatingView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public AbstractFloatingView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        mColorExtractionIndex = LocalColorExtractor.getColorIndex(context);
    }

    /**
+32 −7
Original line number Diff line number Diff line
@@ -32,8 +32,10 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.appwidget.AppWidgetHostView;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Insets;
import android.graphics.Path;
@@ -65,6 +67,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.graphics.ColorUtils;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Alarm;
@@ -157,13 +160,18 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
    private static final float ICON_OVERSCROLL_WIDTH_FACTOR = 0.45f;

    private static final int FOLDER_NAME_ANIMATION_DURATION = 633;
    private static final int FOLDER_COLOR_ANIMATION_DURATION = 150;
    private static final int FOLDER_COLOR_ANIMATION_DURATION = 200;

    private static final int REORDER_DELAY = 250;
    private static final int ON_EXIT_CLOSE_DELAY = 400;
    private static final Rect sTempRect = new Rect();
    private static final int MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION = 10;

    // Index used to get background color when using local wallpaper color extraction,
    private static final int DARK_COLOR_EXTRACTION_INDEX = android.R.color.system_neutral1_900;
    private static final int LIGHT_COLOR_EXTRACTION_INDEX = android.R.color.system_neutral2_500;
    private static final int LIGHT_COLOR_L_STAR = 98;

    private final Alarm mReorderAlarm = new Alarm();
    private final Alarm mOnExitAlarm = new Alarm();
    private final Alarm mOnScrollHintAlarm = new Alarm();
@@ -296,8 +304,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
        }

        if (Utilities.ATLEAST_S) {
            mColorExtractionIndex = LocalColorExtractor.getColorIndex(
                    !Themes.getAttrBoolean(getContext(), R.attr.isFolderDarkText));
            boolean isFolderDarkText = Themes.getAttrBoolean(getContext(), R.attr.isFolderDarkText);
            mColorExtractor = LocalColorExtractor.newInstance(getContext());
            mColorListener = (RectF rect, SparseIntArray extractedColors) -> {
                mColorChangeRunnable = () -> {
@@ -313,11 +320,14 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                        mOpenAnimationColorChangeAnimator = null;
                    }

                    // Start a new animator to the extracted color.
                    int newColor = extractedColors.get(mColorExtractionIndex);
                    // Start a new animator to the extracted color. Clamp down on the alpha
                    // to prevent folder from being transparent for too long.
                    GradientDrawable bg = (GradientDrawable) getBackground();
                    mColorChangeAnimator = ObjectAnimator.ofArgb(bg, "color",
                            bg.getColor().getDefaultColor(), newColor).setDuration(duration);
                    int currentColor = ColorUtils.setAlphaComponent(bg.getColor().getDefaultColor(),
                            255);
                    int newColor = getExtractedColor(extractedColors, isFolderDarkText);
                    mColorChangeAnimator = ObjectAnimator.ofArgb(bg, "color", currentColor,
                            newColor).setDuration(duration);
                    mColorChangeAnimator.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
@@ -337,6 +347,21 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
        }
    }

    /**
     * Returns an index used to query the color of interest from the list of extracted colors.
     * @param hasDarkText True when dark index is wanted, False when light index is wanted.
     */
    @TargetApi(Build.VERSION_CODES.S)
    private int getExtractedColor(SparseIntArray colors, boolean hasDarkText) {
        int color = colors.get(hasDarkText
                ? LIGHT_COLOR_EXTRACTION_INDEX
                : DARK_COLOR_EXTRACTION_INDEX);
        if (hasDarkText) {
            color = ColorStateList.valueOf(color).withLStar(LIGHT_COLOR_L_STAR).getDefaultColor();
        }
        return color;
    }

    public boolean onLongClick(View v) {
        // Return if global dragging is not enabled
        if (!mLauncherDelegate.isDraggingEnabled()) return true;
Loading