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

Commit debf3bed authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 2948913 - provide lifecycle notifications for action modes

Change-Id: I432e29a7bddb18bc32dfbe21a8ecd7d83158e3a0
parent 9d305170
Loading
Loading
Loading
Loading
+112 −34
Original line number Diff line number Diff line
@@ -21087,6 +21087,32 @@
<parameter name="nonRoot" type="boolean">
</parameter>
</method>
<method name="onActionModeFinished"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="mode" type="android.view.ActionMode">
</parameter>
</method>
<method name="onActionModeStarted"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="mode" type="android.view.ActionMode">
</parameter>
</method>
<method name="onActivityResult"
 return="void"
 abstract="false"
@@ -21722,19 +21748,6 @@
 visibility="protected"
>
</method>
<method name="onStartActionMode"
 return="android.view.ActionMode"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="callback" type="android.view.ActionMode.Callback">
</parameter>
</method>
<method name="onStop"
 return="void"
 abstract="false"
@@ -21835,6 +21848,19 @@
<parameter name="hasFocus" type="boolean">
</parameter>
</method>
<method name="onWindowStartingActionMode"
 return="android.view.ActionMode"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="callback" type="android.view.ActionMode.Callback">
</parameter>
</method>
<method name="openContextMenu"
 return="void"
 abstract="false"
@@ -25434,6 +25460,32 @@
 visibility="public"
>
</method>
<method name="onActionModeFinished"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="mode" type="android.view.ActionMode">
</parameter>
</method>
<method name="onActionModeStarted"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="mode" type="android.view.ActionMode">
</parameter>
</method>
<method name="onAttachedToWindow"
 return="void"
 abstract="false"
@@ -25784,19 +25836,6 @@
 visibility="protected"
>
</method>
<method name="onStartActionMode"
 return="android.view.ActionMode"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="callback" type="android.view.ActionMode.Callback">
</parameter>
</method>
<method name="onStop"
 return="void"
 abstract="false"
@@ -25860,6 +25899,19 @@
<parameter name="hasFocus" type="boolean">
</parameter>
</method>
<method name="onWindowStartingActionMode"
 return="android.view.ActionMode"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="callback" type="android.view.ActionMode.Callback">
</parameter>
</method>
<method name="openContextMenu"
 return="void"
 abstract="false"
@@ -212083,6 +212135,32 @@
<parameter name="event" type="android.view.MotionEvent">
</parameter>
</method>
<method name="onActionModeFinished"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="mode" type="android.view.ActionMode">
</parameter>
</method>
<method name="onActionModeStarted"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="mode" type="android.view.ActionMode">
</parameter>
</method>
<method name="onAttachedToWindow"
 return="void"
 abstract="true"
@@ -212217,8 +212295,8 @@
 visibility="public"
>
</method>
<method name="onStartActionMode"
 return="android.view.ActionMode"
<method name="onWindowAttributesChanged"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
@@ -212227,10 +212305,10 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="callback" type="android.view.ActionMode.Callback">
<parameter name="attrs" type="android.view.WindowManager.LayoutParams">
</parameter>
</method>
<method name="onWindowAttributesChanged"
<method name="onWindowFocusChanged"
 return="void"
 abstract="true"
 native="false"
@@ -212240,11 +212318,11 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="attrs" type="android.view.WindowManager.LayoutParams">
<parameter name="hasFocus" type="boolean">
</parameter>
</method>
<method name="onWindowFocusChanged"
 return="void"
<method name="onWindowStartingActionMode"
 return="android.view.ActionMode"
 abstract="true"
 native="false"
 synchronized="false"
@@ -212253,7 +212331,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="hasFocus" type="boolean">
<parameter name="callback" type="android.view.ActionMode.Callback">
</parameter>
</method>
</interface>
+31 −2
Original line number Diff line number Diff line
@@ -4174,7 +4174,7 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * Start a context mode.
     * Start an action mode.
     *
     * @param callback Callback that will manage lifecycle events for this context mode
     * @return The ContextMode that was started, or null if it was canceled
@@ -4185,7 +4185,18 @@ public class Activity extends ContextThemeWrapper
        return mWindow.getDecorView().startActionMode(callback);
    }

    public ActionMode onStartActionMode(ActionMode.Callback callback) {
    /**
     * Give the Activity a chance to control the UI for an action mode requested
     * by the system.
     *
     * <p>Note: If you are looking for a notification callback that an action mode
     * has been started for this activity, see {@link #onActionModeStarted(ActionMode)}.</p>
     *
     * @param callback The callback that should control the new action mode
     * @return The new action mode, or <code>null</code> if the activity does not want to
     *         provide special handling for this action mode. (It will be handled by the system.)
     */
    public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
        initActionBar();
        if (mActionBar != null) {
            return mActionBar.startActionMode(callback);
@@ -4193,6 +4204,24 @@ public class Activity extends ContextThemeWrapper
        return null;
    }

    /**
     * Notifies the Activity that an action mode has been started.
     * Activity subclasses overriding this method should call the superclass implementation.
     *
     * @param mode The new action mode.
     */
    public void onActionModeStarted(ActionMode mode) {
    }

    /**
     * Notifies the activity that an action mode has finished.
     * Activity subclasses overriding this method should call the superclass implementation.
     *
     * @param mode The action mode that just finished.
     */
    public void onActionModeFinished(ActionMode mode) {
    }

    // ------------------ Internal API ------------------
    
    final void setParent(Activity parent) {
+7 −1
Original line number Diff line number Diff line
@@ -867,13 +867,19 @@ public class Dialog implements DialogInterface, Window.Callback,
        }
    }

    public ActionMode onStartActionMode(ActionMode.Callback callback) {
    public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
        if (mActionBar != null) {
            return mActionBar.startActionMode(callback);
        }
        return null;
    }

    public void onActionModeStarted(ActionMode mode) {
    }

    public void onActionModeFinished(ActionMode mode) {
    }

    /**
     * @return The activity associated with this dialog, or null if there is no associated activity.
     */
+22 −3
Original line number Diff line number Diff line
@@ -313,12 +313,31 @@ public abstract class Window {
        public boolean onSearchRequested();

        /**
         * Called when an action mode is being started.
         * Called when an action mode is being started for this window. Gives the
         * callback an opportunity to handle the action mode in its own unique and
         * beautiful way. If this method returns null the system can choose a way
         * to present the mode or choose not to start the mode at all.
         *
         * @param callback Callback to control the lifecycle of this action mode
         * @return The ActionMode that was started, or null if it was canceled
         * @return The ActionMode that was started, or null if the system should present it
         */
        public ActionMode onStartActionMode(ActionMode.Callback callback);
        public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);

        /**
         * Called when an action mode has been started. The appropriate mode callback
         * method will have already been invoked.
         *
         * @param mode The new mode that has just been started.
         */
        public void onActionModeStarted(ActionMode mode);

        /**
         * Called when an action mode has been finished. The appropriate mode callback
         * method will have already been invoked.
         *
         * @param mode The mode that was just finished.
         */
        public void onActionModeFinished(ActionMode mode);
    }

    public Window(Context context) {
+5 −1
Original line number Diff line number Diff line
@@ -1832,7 +1832,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            }

            final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
            ActionMode mode = getCallback().onStartActionMode(wrappedCallback);
            ActionMode mode = getCallback().onWindowStartingActionMode(wrappedCallback);
            if (mode != null) {
                mActionMode = mode;
            } else {
@@ -1876,6 +1876,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                    }
                }
            }
            if (mActionMode != null) {
                getCallback().onActionModeStarted(mActionMode);
            }
            return mActionMode;
        }

@@ -2091,6 +2094,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                if (mActionModeView != null) {
                    mActionModeView.removeAllViews();
                }
                getCallback().onActionModeFinished(mActionMode);
                mActionMode = null;
            }
        }