Skip to content

Commit

Permalink
Use insets instead of UiVisibility flags in PlayerActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed Nov 22, 2021
1 parent cbb8d59 commit 7e67f7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import android.widget.SeekBar
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import com.github.vkay94.dtpv.DoubleTapPlayerView
import com.github.vkay94.dtpv.youtube.YouTubeOverlay
import com.google.android.exoplayer2.DefaultLoadControl
Expand Down Expand Up @@ -65,7 +67,6 @@ import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.system.isOnline
import eu.kanade.tachiyomi.util.system.logcat
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.hideBar
import eu.kanade.tachiyomi.widget.listener.SimpleSeekBarListener
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
Expand Down Expand Up @@ -132,9 +133,10 @@ class PlayerActivity : AppCompatActivity() {
applyAppTheme(preferences)
super.onCreate(savedInstanceState)
setContentView(R.layout.watcher_activity)
window.decorView.setOnSystemUiVisibilityChangeListener {
window.hideBar()
}
val windowInsetsController = WindowInsetsControllerCompat(window, findViewById(R.id.watcher_activity))
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

playerView = findViewById(R.id.player_view)
playerView.resizeMode = preferences.getPlayerViewMode()
youTubeDoubleTap = findViewById(R.id.youtube_overlay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,11 @@ package eu.kanade.tachiyomi.util.view
import android.content.Context
import android.graphics.Color
import android.os.Build
import android.view.View
import android.view.Window
import android.view.WindowManager
import eu.kanade.tachiyomi.util.system.InternalResourceHelper
import eu.kanade.tachiyomi.util.system.getResourceColor

fun Window.showBar() {
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}

fun Window.hideBar() {
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
}

fun Window.defaultBar() {
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
}

fun Window.isDefaultBar() = decorView.systemUiVisibility == View.SYSTEM_UI_FLAG_VISIBLE

/**
* Sets navigation bar color to transparent if system's config_navBarNeedsScrim is false,
* otherwise it will use the theme navigationBarColor with 70% opacity.
Expand Down

0 comments on commit 7e67f7a

Please sign in to comment.