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

Commit 0239d5fa authored by Tony Wickham's avatar Tony Wickham
Browse files

Change swipe up onboarding color based on nav bar color

If the nav bar icons are dark, the onboarding content is
also dark on a white background. Otherwise the onboarding
content is white on a black background.

Also updated a couple of visuals:
- Added a divider to the top of onboarding
- Increased text size to 16sp
- Added ripple to dismiss "X"

Test: manual

Bug: 70180942
Change-Id: Ifc51143ba7e32015bc1519f9d79f9249849787a5
parent fb63fe85
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -20,20 +20,27 @@
    android:layout_width="match_parent"
    android:background="@android:color/black"
    android:layout_gravity="center">
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="?android:attr/listDivider"
        android:gravity="top"/>
    <TextView
        android:id="@+id/onboarding_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="@string/recents_swipe_up_onboarding"
        android:textColor="@android:color/white"
        android:textSize="16sp"
        android:drawableBottom="@drawable/ic_chevron_up"/>
    <ImageView
        android:id="@+id/dismiss"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:paddingTop="12dp"
        android:paddingBottom="12dp"
        android:paddingEnd="18dp"
        android:padding="12dp"
        android:layout_marginEnd="6dp"
        android:src="@drawable/ic_close_white"
        android:background="?android:attr/selectableItemBackgroundBorderless"
        android:layout_gravity="center_vertical|end"/>
</FrameLayout>
 No newline at end of file
+46 −3
Original line number Diff line number Diff line
@@ -20,14 +20,16 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -36,6 +38,8 @@ import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.systemui.Prefs;
import com.android.systemui.R;
@@ -58,10 +62,20 @@ public class SwipeUpOnboarding {
    private final Context mContext;
    private final WindowManager mWindowManager;
    private final View mLayout;
    private final TextView mTextView;
    private final ImageView mDismissView;
    private final ColorDrawable mBackgroundDrawable;
    private final int mDarkBackgroundColor;
    private final int mLightBackgroundColor;
    private final int mDarkContentColor;
    private final int mLightContentColor;
    private final RippleDrawable mDarkRipple;
    private final RippleDrawable mLightRipple;

    private boolean mTaskListenerRegistered;
    private ComponentName mLauncherComponent;
    private boolean mLayoutAttachedToWindow;
    private boolean mBackgroundIsLight;

    private final SysUiTaskStackChangeListener mTaskListener = new SysUiTaskStackChangeListener() {
        @Override
@@ -110,10 +124,24 @@ public class SwipeUpOnboarding {

    public SwipeUpOnboarding(Context context) {
        mContext = context;
        final Resources res = context.getResources();
        mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        mLayout = LayoutInflater.from(mContext).inflate(R.layout.recents_swipe_up_onboarding, null);
        mTextView = (TextView) mLayout.findViewById(R.id.onboarding_text);
        mDismissView = (ImageView) mLayout.findViewById(R.id.dismiss);
        mDarkBackgroundColor = res.getColor(android.R.color.background_dark);
        mLightBackgroundColor = res.getColor(android.R.color.background_light);
        mDarkContentColor = res.getColor(R.color.primary_text_default_material_light);
        mLightContentColor = res.getColor(R.color.primary_text_default_material_dark);
        mDarkRipple = new RippleDrawable(res.getColorStateList(R.color.ripple_material_light),
                null, null);
        mLightRipple = new RippleDrawable(res.getColorStateList(R.color.ripple_material_dark),
                null, null);
        mBackgroundDrawable = new ColorDrawable(mDarkBackgroundColor);

        mLayout.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
        mLayout.findViewById(R.id.dismiss).setOnClickListener(v -> hide(true));
        mLayout.setBackground(mBackgroundDrawable);
        mDismissView.setOnClickListener(v -> hide(true));

        if (RESET_PREFS_FOR_DEBUG) {
            Prefs.putBoolean(mContext, Prefs.Key.HAS_SWIPED_UP_FOR_RECENTS, false);
@@ -186,6 +214,21 @@ public class SwipeUpOnboarding {
        }
    }

    public void setContentDarkIntensity(float contentDarkIntensity) {
        boolean backgroundIsLight = contentDarkIntensity > 0.5f;
        if (backgroundIsLight != mBackgroundIsLight) {
            mBackgroundIsLight = backgroundIsLight;
            mBackgroundDrawable.setColor(mBackgroundIsLight
                    ? mLightBackgroundColor : mDarkBackgroundColor);
            int contentColor = mBackgroundIsLight ? mDarkContentColor : mLightContentColor;
            mTextView.setTextColor(contentColor);
            mTextView.getCompoundDrawables()[3].setColorFilter(contentColor,
                    PorterDuff.Mode.SRC_IN);
            mDismissView.setColorFilter(contentColor);
            mDismissView.setBackground(mBackgroundIsLight ? mDarkRipple : mLightRipple);
        }
    }

    private WindowManager.LayoutParams getWindowLayoutParams() {
        int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
+3 −0
Original line number Diff line number Diff line
@@ -634,6 +634,9 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        if (mGestureHelper != null) {
            mGestureHelper.onDarkIntensityChange(intensity);
        }
        if (mSwipeUpOnboarding != null) {
            mSwipeUpOnboarding.setContentDarkIntensity(intensity);
        }
    }

    @Override