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

Commit dde80a9c authored by Jin Seok Park's avatar Jin Seok Park
Browse files

Remove show/hide API

This CL removes the show/hide API from MediaControlView2 and instead
provides the developer with the same function by calling
setVisibility(View.VISIBLE | View.GONE), and calling the new APIs
set/getTimeout() and requestPlayButtonFocus(). The original Runnable
code has been moved to onVisibilityAggregated() as per API council's
request.

Test: build
Change-Id: If53fb8849b4e086619a9c93c85e61da70272976e
parent 752d7ca1
Loading
Loading
Loading
Loading
+43 −23
Original line number Diff line number Diff line
@@ -45,6 +45,19 @@ import java.lang.annotation.RetentionPolicy;
 * developer needs to manually retrieve a MediaController instance and set it to MediaControlView2
 * by calling setController(MediaController controller).
 *
 * <p>
 * There is no separate method that handles the show/hide behavior for MediaControlView2. Instead,
 * one can directly change the visibility of this view by calling View.setVisibility(int). The
 * values supported are View.VISIBLE and View.GONE.
 * In addition, the following customizations are supported:
 * 1. Modify default timeout value of 2 seconds by calling setTimeout(long).
 * 2. Set focus to the play/pause button by calling requestPlayButtonFocus().
 *
 * <p>
 * It is also possible to add custom buttons with custom icons and actions inside MediaControlView2.
 * Those buttons will be shown when the overflow button is clicked.
 * See {@link VideoView2#setCustomActions} for more details on how to add.
 *
 * TODO PUBLIC API
 * @hide
 */
@@ -164,22 +177,6 @@ public class MediaControlView2 extends FrameLayout {
        mProvider.setController_impl(controller);
    }

    /**
     * Shows the control view on screen. It will disappear automatically after 3 seconds of
     * inactivity.
     */
    public void show() {
        mProvider.show_impl();
    }

    /**
     * Shows the control view on screen. It will disappear automatically after {@code timeout}
     * milliseconds of inactivity.
     */
    public void show(long timeout) {
        mProvider.show_impl(timeout);
    }

    /**
     * Returns whether the control view is currently shown or hidden.
     */
@@ -187,13 +184,6 @@ public class MediaControlView2 extends FrameLayout {
        return mProvider.isShowing_impl();
    }

    /**
     * Hide the control view from the screen.
     */
    public void hide() {
        mProvider.hide_impl();
    }

    /**
     * Changes the visibility state of an individual button. Default value is View.Visible.
     *
@@ -217,6 +207,36 @@ public class MediaControlView2 extends FrameLayout {
        mProvider.setButtonVisibility_impl(button, visibility);
    }

    /**
     *  Requests focus for the play/pause button.
     */
    public void requestPlayButtonFocus() {
        mProvider.requestPlayButtonFocus_impl();
    }

    /**
     * Sets a new timeout value (in milliseconds) for showing MediaControlView2. The default value
     * is set as 2 seconds.
     * @param timeout the
     */
    public void setTimeout(long timeout) {
        mProvider.setTimeout_impl(timeout);
    }

    /**
     * Retrieves current timeout value (in milliseconds) for showing MediaControlView2. The default
     * value is set as 2 seconds.
     */
    public long getTimeout() {
        return mProvider.getTimeout_impl();
    }

    @Override
    public void onVisibilityAggregated(boolean isVisible) {

        mProvider.onVisibilityAggregated_impl(isVisible);
    }

    @Override
    protected void onAttachedToWindow() {
        mProvider.onAttachedToWindow_impl();
+4 −3
Original line number Diff line number Diff line
@@ -36,9 +36,10 @@ import android.view.View;
// TODO @SystemApi
public interface MediaControlView2Provider extends ViewProvider {
    void setController_impl(MediaController controller);
    void show_impl();
    void show_impl(long timeout);
    boolean isShowing_impl();
    void hide_impl();
    void setButtonVisibility_impl(int button, int visibility);
    void requestPlayButtonFocus_impl();
    void onVisibilityAggregated_impl(boolean isVisible);
    void setTimeout_impl(long timeout);
    long getTimeout_impl();
}