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

Commit 01dd0e86 authored by Filip Gruszczynski's avatar Filip Gruszczynski Committed by Android (Google) Code Review
Browse files

Merge "Force translucency from windowIsTranslucent on SwipeDismissLayout." into lmp-mr1-modular-dev

parents 91aa1bdb 23958c6e
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.widget;
import android.animation.TimeInterpolator;
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
@@ -38,6 +39,7 @@ public class SwipeDismissLayout extends FrameLayout {
    private static final String TAG = "SwipeDismissLayout";

    private static final float DISMISS_MIN_DRAG_WIDTH_RATIO = .33f;
    private boolean mUseDynamicTranslucency = true;

    public interface OnDismissedListener {
        void onDismissed(SwipeDismissLayout layout);
@@ -85,7 +87,7 @@ public class SwipeDismissLayout extends FrameLayout {
                    // and temporarily disables translucency when it is fully visible.
                    // As soon as the user starts swiping, we will re-enable
                    // translucency.
                    if (getContext() instanceof Activity) {
                    if (mUseDynamicTranslucency && getContext() instanceof Activity) {
                        ((Activity) getContext()).convertFromTranslucent();
                    }
                }
@@ -117,6 +119,11 @@ public class SwipeDismissLayout extends FrameLayout {
                android.R.integer.config_shortAnimTime);
        mCancelInterpolator = new DecelerateInterpolator(1.5f);
        mDismissInterpolator = new AccelerateInterpolator(1.5f);
        TypedArray a = context.getTheme().obtainStyledAttributes(
                com.android.internal.R.styleable.Theme);
        mUseDynamicTranslucency = !a.hasValue(
                com.android.internal.R.styleable.Window_windowIsTranslucent);
        a.recycle();
    }

    public void setOnDismissedListener(OnDismissedListener listener) {
@@ -230,7 +237,7 @@ public class SwipeDismissLayout extends FrameLayout {
                mLastX = ev.getRawX();
                updateSwiping(ev);
                if (mSwiping) {
                    if (getContext() instanceof Activity) {
                    if (mUseDynamicTranslucency && getContext() instanceof Activity) {
                        ((Activity) getContext()).convertToTranslucent(null, null);
                    }
                    setProgress(ev.getRawX() - mDownX);
@@ -254,7 +261,7 @@ public class SwipeDismissLayout extends FrameLayout {
    }

    protected void cancel() {
        if (getContext() instanceof Activity) {
        if (mUseDynamicTranslucency && getContext() instanceof Activity) {
            ((Activity) getContext()).convertFromTranslucent();
        }
        if (mProgressListener != null) {
+6 −2
Original line number Diff line number Diff line
@@ -329,7 +329,9 @@
        <attr name="windowOverscan" format="boolean" />
        <!-- Flag indicating whether this is a floating window. -->
        <attr name="windowIsFloating" format="boolean" />
        <!-- Flag indicating whether this is a translucent window. -->
        <!-- Flag indicating whether this is a translucent window. If this attribute is unset (but
             not if set to false), the window might still be considered translucent, if
             windowSwipeToDismiss is set to true. -->
        <attr name="windowIsTranslucent" format="boolean" />
        <!-- Flag indicating that this window's background should be the
             user's current wallpaper.  Corresponds
@@ -455,7 +457,9 @@
        <attr name="windowTranslucentNavigation" format="boolean" />

        <!-- Flag to indicate that a window can be swiped away to be dismissed.
             Corresponds to {@link android.view.Window#FEATURE_SWIPE_TO_DISMISS} -->
             Corresponds to {@link android.view.Window#FEATURE_SWIPE_TO_DISMISS}. It will also
             dynamically change translucency of the window, if the windowIsTranslucent is not set.
             If windowIsTranslucent is set (to either true or false) it will obey that setting. -->
        <attr name="windowSwipeToDismiss" format="boolean" />

        <!-- Flag indicating whether this window requests that content changes be performed
+0 −6
Original line number Diff line number Diff line
@@ -24,9 +24,6 @@
        <item name="windowBackground">@color/black</item>
        <item name="windowContentOverlay">@null</item>
        <item name="windowIsFloating">false</item>
        <!-- We need the windows to be translucent for SwipeToDismiss layout
             to work properly. -->
        <item name="windowIsTranslucent">true</item>
        <item name="windowSwipeToDismiss">true</item>
        <!-- Required to force windowInsets dispatch through application UI. -->
        <item name="windowOverscan">true</item>
@@ -42,9 +39,6 @@
        <item name="windowBackground">@color/white</item>
        <item name="windowContentOverlay">@null</item>
        <item name="windowIsFloating">false</item>
        <!-- We need the windows to be translucent for SwipeToDismiss layout
             to work properly. -->
        <item name="windowIsTranslucent">true</item>
        <item name="windowSwipeToDismiss">true</item>
        <!-- Required to force windowInsets dispatch through application UI. -->
        <item name="windowOverscan">true</item>
+0 −6
Original line number Diff line number Diff line
@@ -4159,12 +4159,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        return mMediaController;
    }

    private boolean isTranslucent() {
        TypedArray a = getWindowStyle();
        return a.getBoolean(a.getResourceId(
                R.styleable.Window_windowIsTranslucent, 0), false);
    }

    @Override
    public void setEnterTransition(Transition enterTransition) {
        mEnterTransition = enterTransition;
+8 −2
Original line number Diff line number Diff line
@@ -474,10 +474,16 @@ final class ActivityRecord {

            AttributeCache.Entry ent = AttributeCache.instance().get(packageName,
                    realTheme, com.android.internal.R.styleable.Window, userId);
            final boolean translucent = ent.array.getBoolean(
                    com.android.internal.R.styleable.Window_windowIsTranslucent, false)
                    || (!ent.array.hasValue(
                            com.android.internal.R.styleable.Window_windowIsTranslucent)
                            && ent.array.getBoolean(
                                    com.android.internal.R.styleable.Window_windowSwipeToDismiss,
                                            false));
            fullscreen = ent != null && !ent.array.getBoolean(
                    com.android.internal.R.styleable.Window_windowIsFloating, false)
                    && !ent.array.getBoolean(
                    com.android.internal.R.styleable.Window_windowIsTranslucent, false);
                    && !translucent;
            noDisplay = ent != null && ent.array.getBoolean(
                    com.android.internal.R.styleable.Window_windowNoDisplay, false);

Loading