* Add basic leanback support * Add TV home fragment Adds basic media browsing screen for TV. Shows Home screen media. * Fix double emit when loading user views * Fix bug when going back to this screen would duplicate menu items * Add basic media detail fragment * Add ability to navigate to detail fragment * Fix imports and null safe calls * Fix displaying of home item view type media files * Playback refactor * Add basic Tv player controls and split PlayerActivity * Update strings * Add progress bar to partially played items on TV home screen * Track selection dialog PoC * Update track selection WIP * Show track selection of focus change * Fix series display from home * Minor updates * Add back button to media detail * Zero effort add server and login * Fix colors * Fix back button from home going back to init fragment * Add settings button to home screen * Fix crash after goig back from media detail fragment * Show seasons and cast * Merge branch 'develop' into add_basic_tv_support # Conflicts: # app/src/main/java/dev/jdtech/jellyfin/MainActivity.kt # app/src/main/java/dev/jdtech/jellyfin/dialogs/VideoVersionDialogFragment.kt # app/src/main/res/navigation/app_navigation.xml * Fix cast title being shown with empty cast list * Remove useless method * Remove unused parameter * Fix crash due to colorOnPrimary not existing in Leanback styles * Remove unused theme * Fix home to addserver fragment navigation * Reuse home item layouts This creates some duplicate code which will probably be cleaned up later * Ignore more MissingDefaultResource * Add banner Co-authored-by: Jarne Demeulemeester <32322857+jarnedemeulemeester@users.noreply.github.com>
69 lines
No EOL
2.6 KiB
Kotlin
69 lines
No EOL
2.6 KiB
Kotlin
package dev.jdtech.jellyfin
|
|
|
|
import android.os.Build
|
|
import android.view.View
|
|
import android.view.WindowManager
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.core.view.updatePadding
|
|
import com.google.android.exoplayer2.trackselection.MappingTrackSelector
|
|
import dev.jdtech.jellyfin.viewmodels.PlayerActivityViewModel
|
|
|
|
abstract class BasePlayerActivity: AppCompatActivity() {
|
|
|
|
abstract val viewModel: PlayerActivityViewModel
|
|
|
|
override fun onPause() {
|
|
super.onPause()
|
|
viewModel.playWhenReady = viewModel.player.playWhenReady == true
|
|
viewModel.player.playWhenReady = false
|
|
}
|
|
|
|
override fun onResume() {
|
|
super.onResume()
|
|
viewModel.player.playWhenReady = viewModel.playWhenReady
|
|
hideSystemUI()
|
|
}
|
|
|
|
@Suppress("DEPRECATION")
|
|
protected fun hideSystemUI() {
|
|
// These methods are deprecated but we still use them because the new WindowInsetsControllerCompat has a bug which makes the action bar reappear
|
|
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
|
|
View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
|
|
|
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
window.attributes.layoutInDisplayCutoutMode =
|
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
|
}
|
|
}
|
|
|
|
protected fun isRendererType(
|
|
mappedTrackInfo: MappingTrackSelector.MappedTrackInfo,
|
|
rendererIndex: Int,
|
|
type: Int
|
|
): Boolean {
|
|
val trackGroupArray = mappedTrackInfo.getTrackGroups(rendererIndex)
|
|
if (trackGroupArray.length == 0) {
|
|
return false
|
|
}
|
|
val trackType = mappedTrackInfo.getRendererType(rendererIndex)
|
|
return type == trackType
|
|
}
|
|
|
|
protected fun configureInsets(playerControls: View) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
playerControls
|
|
.setOnApplyWindowInsetsListener { _, windowInsets ->
|
|
val cutout = windowInsets.displayCutout
|
|
playerControls.updatePadding(
|
|
left = cutout?.safeInsetLeft ?: 0,
|
|
top = cutout?.safeInsetTop ?: 0,
|
|
right = cutout?.safeInsetRight ?: 0,
|
|
bottom = cutout?.safeInsetBottom ?: 0,
|
|
)
|
|
return@setOnApplyWindowInsetsListener windowInsets
|
|
}
|
|
}
|
|
}
|
|
} |