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
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user