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

Commit bb20575f authored by Adam Powell's avatar Adam Powell Committed by Android Git Automerger
Browse files

am 130b4572: ActionProvider API update

* commit '130b4572':
  ActionProvider API update
parents 60860192 130b4572
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22815,10 +22815,12 @@ package android.view {
  public abstract class ActionProvider {
    ctor public ActionProvider(android.content.Context);
    method public boolean hasSubMenu();
    method public boolean isVisible();
    method public abstract deprecated android.view.View onCreateActionView();
    method public android.view.View onCreateActionView(android.view.MenuItem);
    method public boolean onPerformDefaultAction();
    method public void onPrepareSubMenu(android.view.SubMenu);
    method public boolean overridesItemVisibility();
  }
  public final class Choreographer {
+7 −19
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import com.android.internal.app.MediaRouteChooserDialogFragment;
import android.content.Context;
import android.content.ContextWrapper;
import android.media.MediaRouter;
import android.media.MediaRouter.RouteInfo;
import android.util.Log;
import android.view.ActionProvider;
import android.view.MenuItem;
@@ -35,7 +34,6 @@ public class MediaRouteActionProvider extends ActionProvider {
    private MenuItem mMenuItem;
    private MediaRouteButton mView;
    private int mRouteTypes;
    private final RouterCallback mRouterCallback = new RouterCallback();
    private View.OnClickListener mExtendedSettingsListener;

    public MediaRouteActionProvider(Context context) {
@@ -50,18 +48,10 @@ public class MediaRouteActionProvider extends ActionProvider {
    }

    public void setRouteTypes(int types) {
        if (types == mRouteTypes) {
            // Already registered; nothing to do.
            return;
        }
        if (mRouteTypes != 0) {
            mRouter.removeCallback(mRouterCallback);
        }
        mRouteTypes = types;
        if (mView != null) {
            mView.setRouteTypes(mRouteTypes);
        }
        mRouter.addCallback(types, mRouterCallback);
    }

    @Override
@@ -124,15 +114,13 @@ public class MediaRouteActionProvider extends ActionProvider {
        }
    }

    private class RouterCallback extends MediaRouter.SimpleCallback {
    @Override
        public void onRouteAdded(MediaRouter router, RouteInfo info) {
            mMenuItem.setVisible(mRouter.getRouteCount() > 1);
    public boolean overridesItemVisibility() {
        return true;
    }

    @Override
        public void onRouteRemoved(MediaRouter router, RouteInfo info) {
            mMenuItem.setVisible(mRouter.getRouteCount() > 1);
        }
    public boolean isVisible() {
        return mRouter.getRouteCount() > 1;
    }
}
+26 −0
Original line number Diff line number Diff line
@@ -95,6 +95,32 @@ public abstract class ActionProvider {
        return onCreateActionView();
    }

    /**
     * The result of this method determines whether or not {@link #isVisible()} will be used
     * by the {@link MenuItem} this ActionProvider is bound to help determine its visibility.
     *
     * @return true if this ActionProvider overrides the visibility of the MenuItem
     *         it is bound to, false otherwise. The default implementation returns false.
     * @see #isVisible()
     */
    public boolean overridesItemVisibility() {
        return false;
    }

    /**
     * If {@link #overridesItemVisibility()} returns true, the return value of this method
     * will help determine the visibility of the {@link MenuItem} this ActionProvider is bound to.
     *
     * <p>If the MenuItem's visibility is explicitly set to false by the application,
     * the MenuItem will not be shown, even if this method returns true.</p>
     *
     * @return true if the MenuItem this ActionProvider is bound to is visible, false if
     *         it is invisible. The default implementation returns true.
     */
    public boolean isVisible() {
        return true;
    }

    /**
     * Performs an optional default action.
     * <p>
+3 −0
Original line number Diff line number Diff line
@@ -456,6 +456,9 @@ public final class MenuItemImpl implements MenuItem {
    }
    
    public boolean isVisible() {
        if (mActionProvider != null && mActionProvider.overridesItemVisibility()) {
            return (mFlags & HIDDEN) == 0 && mActionProvider.isVisible();
        }
        return (mFlags & HIDDEN) == 0;
    }

+1 −1
Original line number Diff line number Diff line
@@ -662,6 +662,7 @@ public class MediaRouter {
         */
        public void setTag(Object tag) {
            mTag = tag;
            routeUpdated();
        }

        /**
@@ -675,7 +676,6 @@ public class MediaRouter {
        void setStatusInt(CharSequence status) {
            if (!status.equals(mStatus)) {
                mStatus = status;
                routeUpdated();
                if (mGroup != null) {
                    mGroup.memberStatusChanged(this, status);
                }