Skip to content

Commit

Permalink
Fix some dumb bugs I created 6 hours ago, again.
Browse files Browse the repository at this point in the history
  • Loading branch information
astarivi committed Jun 13, 2023
1 parent 3b14571 commit 025b5ea
Showing 1 changed file with 39 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.astarivi.kaizoyu.video;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -81,14 +83,37 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
// Everything else
binding.downloadStatus.setText(getResources().getString(R.string.executing_irc_handshake));
gestureDetector = new GestureDetectorCompat(this, new PlayerGestureListener());
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);

binding.mainPlayer.initialize(
animeEpisodeManager != null ? animeEpisodeManager.getAnimeTitle() : result.getCleanedFilename(),
animeEpisodeManager != null ? animeEpisodeManager.getEpisodeTitle(this) : getString(R.string.advanced_mode_title),
this::finish
);

// Fullscreen setup

// Draw behind screen cutout
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
final WindowManager.LayoutParams wManager = getWindow().getAttributes();
wManager.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}

// Draw behind system bars (edge to edge)
WindowCompat.setDecorFitsSystemWindows(getWindow(), false); // This doesn't seem to do the trick by itself
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
);

// Show system bars only when swiping down, and hide them again automatically
WindowInsetsControllerCompat windowInsetsController = WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
windowInsetsController.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
);

// Actually hide the goddamn bars.
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());

spark = new Spark.Builder()
.setView(binding.getRoot())
.setDuration(4000)
Expand Down Expand Up @@ -246,20 +271,19 @@ public boolean onTouchEvent(MotionEvent event) {
}

private void hideSystemUI(){
WindowInsetsControllerCompat windowInsetsController = WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());

View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// WindowInsetsControllerCompat windowInsetsController = WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
// windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
// } else {
// getWindow().getDecorView().setSystemUiVisibility(
// View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_IMMERSIVE
// | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// );
// }
}

private void delayedExit(){
Expand Down

0 comments on commit 025b5ea

Please sign in to comment.