Search code examples
javaandroidandroid-tvleanback

Leanback library - PlaybackSupportFragment - how to hide secondary actions


I'm working on an Android TV app that plays a video and I'm using PlaybackSupportFragment to implement the on-screen controls. I am, however, not able to fully hide the secondary actions (thumbs up, thumbs down, repeat, ...). Actually I was able to hide the buttons, however the "three dots" button still stays there. And I have not figured out how to hide this "three dots" button.

I tried not to add any secondary actions buttons. But no luck. There are no secondary buttons but the "three-dots" button is still there.

public class MySupportFragment extends PlaybackSupportFragment {
  MyPlaybackControlGlue myGlue = new MyPlaybackControlGlue(context);
  ...
  myGlue.setHost(new PlaybackSupportFragmentGlueHost(this));
  ...
}

public class MyPlaybackControlGlue extends PlaybackControlGlue{
  ...
  @Override
  protected void onCreateSecondaryActions(ArrayObjectAdapter adapter) {
    //Do not add any secondary actions to the adapter
  }
  @Override
  protected void onCreatePrimaryActions(SparseArrayObjectAdapter adapter) {
        //No need to add any other actions here. The Play/Pause action is enough.
  }
}

Solution

  • I think I figured it out. Do not add any secondary actions in the "onCreateSecondaryActions" method. But also call following method so that the "three dots" button is not shown. getControlsRowPresenter().setSecondaryActionsHidden(false)

    For example like so

    @Override
    protected  void onCreateControlsRowAndPresenter() {
        super.onCreateControlsRowAndPresenter();
        getControlsRowPresenter().setSecondaryActionsHidden(false);
    }