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

Commit ca6234e0 authored by Will Haldean Brown's avatar Will Haldean Brown
Browse files

Add swipe-to-dismiss support to PhoneWindow.

This adds a new window feature -- FEATURE_SWIPE_TO_DISMISS -- and a
theme attribute to activate that feature. When the feature is
activated, a SwipeDismissLayout is inflated as the DecorView layout.
SwipeDismissLayout intercepts touch events and steals ones that are
large swipes to the right if its children don't. PhoneWindow registers
handlers that listen for these swipe events, translate the window when
necessary, and finish the activity at the end of the gesture.

Change-Id: I512e758f3c3ffd3b353dba3b911c0e80a88d6f5f
parent a4bd2cbe
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2850,6 +2850,7 @@ package android.app {
    method public void onUserInteraction();
    method protected void onUserLeaveHint();
    method public void onWindowAttributesChanged(android.view.WindowManager.LayoutParams);
    method public void onWindowDismissed();
    method public void onWindowFocusChanged(boolean);
    method public android.view.ActionMode onWindowStartingActionMode(android.view.ActionMode.Callback);
    method public void openContextMenu(android.view.View);
@@ -3366,6 +3367,7 @@ package android.app {
    method public boolean onTouchEvent(android.view.MotionEvent);
    method public boolean onTrackballEvent(android.view.MotionEvent);
    method public void onWindowAttributesChanged(android.view.WindowManager.LayoutParams);
    method public void onWindowDismissed();
    method public void onWindowFocusChanged(boolean);
    method public android.view.ActionMode onWindowStartingActionMode(android.view.ActionMode.Callback);
    method public void openContextMenu(android.view.View);
@@ -22701,6 +22703,7 @@ package android.service.dreams {
    method public boolean onPreparePanel(int, android.view.View, android.view.Menu);
    method public boolean onSearchRequested();
    method public void onWindowAttributesChanged(android.view.WindowManager.LayoutParams);
    method public void onWindowDismissed();
    method public void onWindowFocusChanged(boolean);
    method public android.view.ActionMode onWindowStartingActionMode(android.view.ActionMode.Callback);
    method public void setContentView(int);
@@ -28648,6 +28651,7 @@ package android.view {
    field public static final int FEATURE_OPTIONS_PANEL = 0; // 0x0
    field 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 public static final int ID_ANDROID_CONTENT = 16908290; // 0x1020002
    field public static final int PROGRESS_END = 10000; // 0x2710
    field public static final int PROGRESS_INDETERMINATE_OFF = -4; // 0xfffffffc
@@ -28679,6 +28683,7 @@ package android.view {
    method public abstract boolean onPreparePanel(int, android.view.View, android.view.Menu);
    method public abstract boolean onSearchRequested();
    method public abstract void onWindowAttributesChanged(android.view.WindowManager.LayoutParams);
    method public abstract void onWindowDismissed();
    method public abstract void onWindowFocusChanged(boolean);
    method public abstract android.view.ActionMode onWindowStartingActionMode(android.view.ActionMode.Callback);
  }
+7 −0
Original line number Diff line number Diff line
@@ -2403,6 +2403,13 @@ public class Activity extends ContextThemeWrapper
        return false;
    }

    /**
     * Called when the main window associated with the activity has been dismissed.
     */
    public void onWindowDismissed() {
        finish();
    }
    
    /**
     * Called to process key events.  You can override this to intercept all 
     * key events before they are dispatched to the window.  Be sure to call 
+4 −0
Original line number Diff line number Diff line
@@ -696,6 +696,10 @@ public class Dialog implements DialogInterface, Window.Callback,
    public void onDetachedFromWindow() {
    }

    public void onWindowDismissed() {
        dismiss();
    }
    
    /**
     * Called to process key events.  You can override this to intercept all 
     * key events before they are dispatched to the window.  Be sure to call 
+4 −0
Original line number Diff line number Diff line
@@ -300,6 +300,10 @@ public class DreamService extends Service implements Window.Callback {
    public void onDetachedFromWindow() {
    }

    @Override
    public void onWindowDismissed() {
    }

    /** {@inheritDoc} */
    @Override
    public void onPanelClosed(int featureId, Menu menu) {
+12 −1
Original line number Diff line number Diff line
@@ -90,11 +90,16 @@ 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.
     */
    public static final int FEATURE_SWIPE_TO_DISMISS = 11;

    /**
     * Max value used as a feature ID
     * @hide
     */
    public static final int FEATURE_MAX = FEATURE_ACTION_MODE_OVERLAY;
    public static final int FEATURE_MAX = FEATURE_SWIPE_TO_DISMISS;

    /** Flag for setting the progress bar's visibility to VISIBLE */
    public static final int PROGRESS_VISIBILITY_ON = -1;
@@ -385,6 +390,12 @@ public abstract class Window {
         * @param mode The mode that was just finished.
         */
        public void onActionModeFinished(ActionMode mode);

        /**
         * Called when a window is dismissed. This informs the callback that the
         * window is gone, and it should finish itself.
         */
        public void onWindowDismissed();
    }

    public Window(Context context) {
Loading