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

Commit 8176012e authored by Chih-Chung Chang's avatar Chih-Chung Chang
Browse files

Fix 5158468: Hide system bar when no play control is shown.

Change-Id: Iada70c39440f19eec1cb00088531719bc1bb8328
parent da071d27
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class MovieActivity extends Activity {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        winParams.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
        winParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        win.setAttributes(winParams);
    }

+24 −1
Original line number Diff line number Diff line
@@ -112,16 +112,33 @@ public class MoviePlayer implements
        mMediaController = new MediaController(movieActivity) {
            @Override
            public void show() {
                super.show();
                showSystemUi(true);
                mActionBar.show();
                super.show();
            }

            @Override
            public void hide() {
                super.hide();
                mActionBar.hide();
                showSystemUi(false);
            }
        };

        mMediaController.show();

        // When the user touches the screen or uses some hard key, the framework
        // will change system ui visibility from invisible to visible. We show
        // the media control at this point.
        mVideoView.setOnSystemUiVisibilityChangeListener(
                new View.OnSystemUiVisibilityChangeListener() {
            public void onSystemUiVisibilityChange(int visibility) {
                if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
                    mMediaController.show();
                }
            }
        });

        mMediaController.setOnKeyListener(new View.OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
@@ -162,6 +179,12 @@ public class MoviePlayer implements
        }
    }

    private void showSystemUi(boolean visible) {
        int flag = visible ? 0 : View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        mVideoView.setSystemUiVisibility(flag);
        mMediaController.setSystemUiVisibility(flag);
    }

    public void onSaveInstanceState(Bundle outState) {
        outState.putInt(KEY_VIDEO_POSITION, mVideoPosition);
        outState.putLong(KEY_RESUMEABLE_TIME, mResumeableTime);