Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand Down Expand Up @@ -55,7 +52,6 @@
<application
android:name=".FlowApplication"
android:allowBackup="true"
android:banner="@drawable/tv_banner"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand Down Expand Up @@ -88,19 +84,6 @@
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />

<activity
android:name=".TvActivity"
android:banner="@drawable/tv_banner"
android:exported="true"
android:launchMode="singleTop"
android:screenOrientation="landscape"
android:theme="@style/Theme.Flow.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
127 changes: 50 additions & 77 deletions app/src/main/java/io/github/aedev/flow/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import androidx.compose.runtime.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import io.github.aedev.flow.data.local.LocalDataManager
import io.github.aedev.flow.data.local.AppUiModePreferences
import io.github.aedev.flow.player.GlobalPlayerState
import io.github.aedev.flow.ui.FlowApp
import io.github.aedev.flow.ui.theme.FlowTheme
Expand All @@ -46,11 +44,7 @@ import io.github.aedev.flow.utils.UpdateManager
import io.github.aedev.flow.utils.UpdateInfo
import io.github.aedev.flow.network.AppProxyManager
import io.github.aedev.flow.player.PictureInPictureHelper
import io.github.aedev.flow.platform.AppUiMode
import io.github.aedev.flow.platform.AppUiRoot
import io.github.aedev.flow.platform.DeviceFormFactorDetector
import io.github.aedev.flow.ui.components.UpdateDialog
import io.github.aedev.flow.ui.tv.FlowTvApp
import io.github.aedev.flow.BuildConfig
import androidx.activity.SystemBarStyle
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
Expand Down Expand Up @@ -84,7 +78,6 @@ class MainActivity : ComponentActivity() {

private var pipDismissCheckJob: Job? = null
private var pendingAutoPip = false
private var cachedAppUiRoot = AppUiRoot.MOBILE

private fun videoPlaybackStateName(state: Int?): String = when (state) {
androidx.media3.common.Player.STATE_IDLE -> "IDLE"
Expand Down Expand Up @@ -192,14 +185,6 @@ class MainActivity : ComponentActivity() {
var showSplash by remember { mutableStateOf(true) }

val context = LocalContext.current
val configuration = LocalConfiguration.current
val uiPreferences = remember { AppUiModePreferences(applicationContext) }
val appUiMode by uiPreferences.mode.collectAsState(initial = AppUiMode.AUTOMATIC)
val deviceFormFactor = remember(configuration.uiMode, context) {
DeviceFormFactorDetector.detect(context)
}
val appUiRoot = appUiMode.resolve(deviceFormFactor)
SideEffect { cachedAppUiRoot = appUiRoot }

// Check for a crash that happened last session.
// If found, show the CrashReporterScreen instead of the normal UI.
Expand Down Expand Up @@ -346,64 +331,56 @@ class MainActivity : ComponentActivity() {
val isDeeplinkShort by this@MainActivity.isDeeplinkShort
val openMusicPlayerRequest by this@MainActivity.openMusicPlayerRequest

if (appUiRoot == AppUiRoot.TV) {
FlowTvApp(
deeplinkVideoId = deeplinkVideoId,
isShort = isDeeplinkShort,
onDeeplinkConsumed = { consumeDeeplink() },
)
} else {
FlowApp(
currentTheme = themeMode,
themeVariant = themeVariant,
customThemePalettes = customThemePalettes,
systemLightThemeMode = systemLightThemeMode,
systemDarkThemeMode = systemDarkThemeMode,
systemDarkThemeVariant = systemDarkThemeVariant,
onThemeChange = { newTheme ->
themeMode = newTheme
scope.launch {
dataManager.setThemeMode(newTheme)
}
},
onThemeVariantChange = { variant ->
themeVariant = variant
scope.launch {
dataManager.setThemeVariant(variant)
}
},
onCustomThemePalettesChange = { palettes ->
customThemePalettes = palettes
scope.launch {
dataManager.setCustomThemePalettes(palettes)
}
},
onSystemLightThemeChange = { newTheme ->
systemLightThemeMode = newTheme
scope.launch {
dataManager.setSystemLightThemeMode(newTheme)
}
},
onSystemDarkThemeChange = { newTheme ->
systemDarkThemeMode = newTheme
scope.launch {
dataManager.setSystemDarkThemeMode(newTheme)
}
},
onSystemDarkThemeVariantChange = { variant ->
systemDarkThemeVariant = variant
scope.launch {
dataManager.setSystemDarkThemeVariant(variant)
}
},
deeplinkVideoId = deeplinkVideoId,
isShort = isDeeplinkShort,
openMusicPlayerRequest = openMusicPlayerRequest,
onDeeplinkConsumed = {
consumeDeeplink()
FlowApp(
currentTheme = themeMode,
themeVariant = themeVariant,
customThemePalettes = customThemePalettes,
systemLightThemeMode = systemLightThemeMode,
systemDarkThemeMode = systemDarkThemeMode,
systemDarkThemeVariant = systemDarkThemeVariant,
onThemeChange = { newTheme ->
themeMode = newTheme
scope.launch {
dataManager.setThemeMode(newTheme)
}
)
}
},
onThemeVariantChange = { variant ->
themeVariant = variant
scope.launch {
dataManager.setThemeVariant(variant)
}
},
onCustomThemePalettesChange = { palettes ->
customThemePalettes = palettes
scope.launch {
dataManager.setCustomThemePalettes(palettes)
}
},
onSystemLightThemeChange = { newTheme ->
systemLightThemeMode = newTheme
scope.launch {
dataManager.setSystemLightThemeMode(newTheme)
}
},
onSystemDarkThemeChange = { newTheme ->
systemDarkThemeMode = newTheme
scope.launch {
dataManager.setSystemDarkThemeMode(newTheme)
}
},
onSystemDarkThemeVariantChange = { variant ->
systemDarkThemeVariant = variant
scope.launch {
dataManager.setSystemDarkThemeVariant(variant)
}
},
deeplinkVideoId = deeplinkVideoId,
isShort = isDeeplinkShort,
openMusicPlayerRequest = openMusicPlayerRequest,
onDeeplinkConsumed = {
consumeDeeplink()
}
)

// 2. THE SPLASH SCREEN (Z-Index Top)
if (showSplash) {
Expand Down Expand Up @@ -613,9 +590,7 @@ class MainActivity : ComponentActivity() {
)
videoLifecycleLog("onStop")
if (!isInPictureInPictureMode && !PictureInPictureHelper.isPopupActive) {
if (cachedAppUiRoot == AppUiRoot.MOBILE) {
requestedOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
requestedOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
if (!cachedShortsBackgroundPlay) {
io.github.aedev.flow.player.shorts.ShortsPlayerPool.getInstance().pauseAll()
}
Expand All @@ -640,7 +615,6 @@ class MainActivity : ComponentActivity() {

override fun onUserLeaveHint() {
super.onUserLeaveHint()
if (cachedAppUiRoot == AppUiRoot.TV) return
FlowCrashHandler.recordPhase("activity", "onUserLeaveHint autoPip=$cachedAutoPipEnabled")
videoLifecycleLog("onUserLeaveHint")
// Only enter PiP mode if video is playing and has progressed
Expand Down Expand Up @@ -679,7 +653,6 @@ class MainActivity : ComponentActivity() {
isPlaying: Boolean = true,
openSettingsOnDenied: Boolean = false
): Boolean {
if (cachedAppUiRoot == AppUiRoot.TV) return false
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return false
if (!PictureInPictureHelper.isPipAllowed(this)) {
if (openSettingsOnDenied) {
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/java/io/github/aedev/flow/TvActivity.kt

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions app/src/main/java/io/github/aedev/flow/platform/AppUiMode.kt

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading