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

Commit 5fdaa0c9 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Remove FEATURE_SWIPE_TO_DISMISS functionality"

parents 263f6dd5 e06b1fd0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1609,7 +1609,7 @@ package android {
    field public static final int windowShowWallpaper = 16843410; // 0x1010292
    field public static final int windowSoftInputMode = 16843307; // 0x101022b
    field public static final int windowSplashscreenContent = 16844132; // 0x1010564
    field public static final int windowSwipeToDismiss = 16843763; // 0x10103f3
    field @Deprecated public static final int windowSwipeToDismiss = 16843763; // 0x10103f3
    field public static final int windowTitleBackgroundStyle = 16842844; // 0x101005c
    field public static final int windowTitleSize = 16842842; // 0x101005a
    field public static final int windowTitleStyle = 16842843; // 0x101005b
@@ -52078,7 +52078,7 @@ package android.view {
    field public static final int FEATURE_OPTIONS_PANEL = 0; // 0x0
    field @Deprecated public static final int FEATURE_PROGRESS = 2; // 0x2
    field public static final int FEATURE_RIGHT_ICON = 4; // 0x4
    field public static final int FEATURE_SWIPE_TO_DISMISS = 11; // 0xb
    field @Deprecated public static final int FEATURE_SWIPE_TO_DISMISS = 11; // 0xb
    field public static final int ID_ANDROID_CONTENT = 16908290; // 0x1020002
    field public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME = "android:navigation:background";
    field @Deprecated public static final int PROGRESS_END = 10000; // 0x2710
+0 −8
Original line number Diff line number Diff line
@@ -219,7 +219,6 @@ public class Dialog implements DialogInterface, Window.Callback,
            @Nullable Message cancelCallback) {
        this(context);
        mCancelable = cancelable;
        updateWindowForCancelable();
        mCancelMessage = cancelCallback;
    }

@@ -227,7 +226,6 @@ public class Dialog implements DialogInterface, Window.Callback,
            @Nullable OnCancelListener cancelListener) {
        this(context);
        mCancelable = cancelable;
        updateWindowForCancelable();
        setOnCancelListener(cancelListener);
    }

@@ -1249,7 +1247,6 @@ public class Dialog implements DialogInterface, Window.Callback,
     */
    public void setCancelable(boolean flag) {
        mCancelable = flag;
        updateWindowForCancelable();
    }

    /**
@@ -1263,7 +1260,6 @@ public class Dialog implements DialogInterface, Window.Callback,
    public void setCanceledOnTouchOutside(boolean cancel) {
        if (cancel && !mCancelable) {
            mCancelable = true;
            updateWindowForCancelable();
        }
        
        mWindow.setCloseOnTouchOutside(cancel);
@@ -1415,8 +1411,4 @@ public class Dialog implements DialogInterface, Window.Callback,
            }
        }
    }

    private void updateWindowForCancelable() {
        mWindow.setCloseOnSwipeEnabled(mCancelable);
    }
}
+1 −5
Original line number Diff line number Diff line
@@ -1242,15 +1242,11 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        final boolean isTranslucent =
                attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent,
                        false);
        final boolean isSwipeToDismiss = !attributes.hasValue(
                com.android.internal.R.styleable.Window_windowIsTranslucent)
                && attributes.getBoolean(
                        com.android.internal.R.styleable.Window_windowSwipeToDismiss, false);
        final boolean isFloating =
                attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsFloating,
                        false);

        return isFloating || isTranslucent || isSwipeToDismiss;
        return isFloating || isTranslucent;
    }

    /**
+3 −17
Original line number Diff line number Diff line
@@ -127,7 +127,10 @@ public abstract class Window {
    public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
    /**
     * Flag for requesting a decoration-free window that is dismissed by swiping from the left.
     *
     * @deprecated Swipe-to-dismiss isn't functional anymore.
     */
    @Deprecated
    public static final int FEATURE_SWIPE_TO_DISMISS = 11;
    /**
     * Flag for requesting that window content changes should be animated using a
@@ -2521,23 +2524,6 @@ public abstract class Window {
     */
    public abstract void reportActivityRelaunched();

    /**
     * Called to set flag to check if the close on swipe is enabled. This will only function if
     * FEATURE_SWIPE_TO_DISMISS has been set.
     * @hide
     */
    public void setCloseOnSwipeEnabled(boolean closeOnSwipeEnabled) {
        mCloseOnSwipeEnabled = closeOnSwipeEnabled;
    }

    /**
     * @return {@code true} if the close on swipe is enabled.
     * @hide
     */
    public boolean isCloseOnSwipeEnabled() {
        return mCloseOnSwipeEnabled;
    }

    /**
     * @return The {@link WindowInsetsController} associated with this window
     * @see View#getWindowInsetsController()
+1 −80
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
@@ -112,7 +111,6 @@ import com.android.internal.view.menu.MenuHelper;
import com.android.internal.view.menu.MenuPresenter;
import com.android.internal.view.menu.MenuView;
import com.android.internal.widget.DecorContentParent;
import com.android.internal.widget.SwipeDismissLayout;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -378,15 +376,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            removeFeature(FEATURE_ACTION_BAR);
        }

        if ((features & (1 << FEATURE_ACTION_BAR)) != 0 && featureId == FEATURE_SWIPE_TO_DISMISS) {
            throw new AndroidRuntimeException(
                    "You cannot combine swipe dismissal and the action bar.");
        }
        if ((features & (1 << FEATURE_SWIPE_TO_DISMISS)) != 0 && featureId == FEATURE_ACTION_BAR) {
            throw new AndroidRuntimeException(
                    "You cannot combine swipe dismissal and the action bar.");
        }

        if (featureId == FEATURE_INDETERMINATE_PROGRESS &&
                getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
            throw new AndroidRuntimeException("You cannot use indeterminate progress on a watch.");
@@ -2373,10 +2362,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            requestFeature(FEATURE_ACTION_MODE_OVERLAY);
        }

        if (a.getBoolean(R.styleable.Window_windowSwipeToDismiss, false)) {
            requestFeature(FEATURE_SWIPE_TO_DISMISS);
        }

        if (a.getBoolean(R.styleable.Window_windowFullscreen, false)) {
            setFlags(FLAG_FULLSCREEN, FLAG_FULLSCREEN & (~getForcedWindowFlags()));
        }
@@ -2565,10 +2550,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        int layoutResource;
        int features = getLocalFeatures();
        // System.out.println("Features: 0x" + Integer.toHexString(features));
        if ((features & (1 << FEATURE_SWIPE_TO_DISMISS)) != 0) {
            layoutResource = R.layout.screen_swipe_dismiss;
            setCloseOnSwipeEnabled(true);
        } else if ((features & ((1 << FEATURE_LEFT_ICON) | (1 << FEATURE_RIGHT_ICON))) != 0) {
        if ((features & ((1 << FEATURE_LEFT_ICON) | (1 << FEATURE_RIGHT_ICON))) != 0) {
            if (mIsFloating) {
                TypedValue res = new TypedValue();
                getContext().getTheme().resolveAttribute(
@@ -2638,10 +2620,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            }
        }

        if ((features & (1 << FEATURE_SWIPE_TO_DISMISS)) != 0) {
            registerSwipeCallbacks(contentParent);
        }

        // Remaining setup -- of background and title -- that only applies
        // to top-level windows.
        if (getContainer() == null) {
@@ -3047,63 +3025,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        return (mRightIconView = (ImageView)findViewById(R.id.right_icon));
    }

    private void registerSwipeCallbacks(ViewGroup contentParent) {
        if (!(contentParent instanceof SwipeDismissLayout)) {
            Log.w(TAG, "contentParent is not a SwipeDismissLayout: " + contentParent);
            return;
        }
        SwipeDismissLayout swipeDismiss = (SwipeDismissLayout) contentParent;
        swipeDismiss.setOnDismissedListener(new SwipeDismissLayout.OnDismissedListener() {
            @Override
            public void onDismissed(SwipeDismissLayout layout) {
                dispatchOnWindowSwipeDismissed();
                dispatchOnWindowDismissed(false /*finishTask*/, true /*suppressWindowTransition*/);
            }
        });
        swipeDismiss.setOnSwipeProgressChangedListener(
                new SwipeDismissLayout.OnSwipeProgressChangedListener() {
                    @Override
                    public void onSwipeProgressChanged(
                            SwipeDismissLayout layout, float alpha, float translate) {
                        WindowManager.LayoutParams newParams = getAttributes();
                        newParams.x = (int) translate;
                        newParams.alpha = alpha;
                        setAttributes(newParams);

                        int flags = 0;
                        if (newParams.x == 0) {
                            flags = FLAG_FULLSCREEN;
                        } else {
                            flags = FLAG_LAYOUT_NO_LIMITS;
                        }
                        setFlags(flags, FLAG_FULLSCREEN | FLAG_LAYOUT_NO_LIMITS);
                    }

                    @Override
                    public void onSwipeCancelled(SwipeDismissLayout layout) {
                        WindowManager.LayoutParams newParams = getAttributes();
                        // Swipe changes only affect the x-translation and alpha, check to see if
                        // those values have changed first before resetting them.
                        if (newParams.x != 0 || newParams.alpha != 1) {
                            newParams.x = 0;
                            newParams.alpha = 1;
                            setAttributes(newParams);
                            setFlags(FLAG_FULLSCREEN, FLAG_FULLSCREEN | FLAG_LAYOUT_NO_LIMITS);
                        }
                    }
                });
    }

    /** @hide */
    @Override
    public void setCloseOnSwipeEnabled(boolean closeOnSwipeEnabled) {
        if (hasFeature(Window.FEATURE_SWIPE_TO_DISMISS) // swipe-to-dismiss feature is requested
                && mContentParent instanceof SwipeDismissLayout) { // check casting mContentParent
            ((SwipeDismissLayout) mContentParent).setDismissable(closeOnSwipeEnabled);
        }
        super.setCloseOnSwipeEnabled(closeOnSwipeEnabled);
    }

    /**
     * Helper method for calling the {@link Callback#onPanelClosed(int, Menu)}
     * callback. This method will grab whatever extra state is needed for the
Loading