try to rewrite a new magnify button on the video feature list

This commit is contained in:
Hsin-Yen Chung 2023-10-29 16:52:20 +11:00
parent 495f9b2eab
commit 517a33db5f
1 changed files with 42 additions and 0 deletions

View File

@ -78,6 +78,8 @@ public final class PlayQueueActivity extends AppCompatActivity
private Menu menu;
private ImageButton fullscreenButton;
////////////////////////////////////////////////////////////////////////////
// Activity Lifecycle
////////////////////////////////////////////////////////////////////////////
@ -96,6 +98,13 @@ public final class PlayQueueActivity extends AppCompatActivity
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.title_activity_play_queue);
}
fullscreenButton = findViewById(R.id.magnify_button);
fullscreenButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
toggleFullscreen();
}
});
serviceConnection = getServiceConnection();
bind();
@ -526,6 +535,39 @@ public final class PlayQueueActivity extends AppCompatActivity
unbind();
finish();
}
private void toggleFullscreen() {
if (isFullscreen) {
// Code to exit fullscreen mode
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_VISIBLE
);
// If you're using an ActionBar, show it
if (getSupportActionBar() != null) {
getSupportActionBar().show();
}
fullscreenButton.setImageResource(R.drawable.ic_fullscreen);
fullscreenButton.setContentDescription(getString(R.string.fullscreen));
} else {
// Code to enter fullscreen mode
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
);
// If you're using an ActionBar, hide it
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
fullscreenButton.setImageResource(R.drawable.ic_fullscreen_exit);
fullscreenButton.setContentDescription(getString(R.string.fullscreen));
}
}
isFullscreen = !isFullscreen;
}
////////////////////////////////////////////////////////////////////////////
// Binding Service Helper
////////////////////////////////////////////////////////////////////////////