Skip to content

Commit

Permalink
feat: show system's status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
abdallahmehiz committed Sep 23, 2024
1 parent 4df15b7 commit 49f1cc5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ class PlayerPreferences(
val defaultBrightness = preferenceStore.getFloat("default_brightness", -1f)

val allowGesturesInPanels = preferenceStore.getBoolean("allow_gestures_in_panels")
val showSystemStatusBar = preferenceStore.getBoolean("show_system_status_bar")
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PlayerActivity : AppCompatActivity() {
private val playerObserver by lazy { PlayerObserver(this) }
private val mpvKtDatabase: MpvKtDatabase by inject()
val player by lazy { binding.player }
private val windowInsetsController by lazy { WindowCompat.getInsetsController(window, window.decorView) }
val windowInsetsController by lazy { WindowCompat.getInsetsController(window, window.decorView) }
val audioManager by lazy { getSystemService(Context.AUDIO_SERVICE) as AudioManager }
private val playerPreferences: PlayerPreferences by inject()
private val audioPreferences: AudioPreferences by inject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.os.Build
import android.util.DisplayMetrics
import android.util.Log
import android.widget.Toast
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dev.vivvvek.seeker.Segment
Expand Down Expand Up @@ -286,12 +287,17 @@ class PlayerViewModel(
_paused.update { false }
}

private val showStatusBar = playerPreferences.showSystemStatusBar.get()
fun showControls() {
if (sheetShown.value != Sheets.None || panelShown.value != Panels.None) return
if (showStatusBar) {
activity.windowInsetsController.show(WindowInsetsCompat.Type.statusBars())
}
_controlsShown.update { true }
}

fun hideControls() {
activity.windowInsetsController.hide(WindowInsetsCompat.Type.statusBars())
_controlsShown.update { false }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ object PlayerPreferencesScreen : Screen() {
title = { Text(stringResource(R.string.pref_player_controls_show_chapter_indicator)) },
summary = { Text(stringResource(R.string.pref_player_controls_show_chapters_summary)) },
)
val showSystemStatusBar by preferences.showSystemStatusBar.collectAsState()
SwitchPreference(
value = showSystemStatusBar,
onValueChange = preferences.showSystemStatusBar::set,
title = { Text(stringResource(R.string.pref_player_controls_show_status_bar)) },
)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<string name="pref_player_controls_show_chapter_indicator">Show current chapter indicator</string>
<string name="pref_player_controls_show_chapters_button">Show chapters select button</string>
<string name="pref_player_controls_show_chapters_summary">Only appears if the video has chapters.</string>
<string name="pref_player_controls_show_status_bar">Show system status bar with controls</string>

<string name="pref_decoder">Decoder</string>
<string name="pref_decoder_summary">Hardware decoding, pixel format, debanding</string>
Expand Down

0 comments on commit 49f1cc5

Please sign in to comment.