Skip to content
11 changes: 10 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@
tools:ignore="LockedOrientationActivity"/>

<activity
android:name="uk.co.sentinelweb.cuer.app.ui.exoplayer.ExoPlayerActivity"
android:name="uk.co.sentinelweb.cuer.app.ui.player.exoplayer.ExoPlayerActivity"
android:label="@string/title_activity_fullscreen"
android:screenOrientation="landscape"
tools:ignore="LockedOrientationActivity">
<meta-data
android:name="com.samsung.android.support.cover"
android:value="true"/>
</activity>
<activity
android:name="uk.co.sentinelweb.cuer.app.ui.player.android.AndroidVideoPlayerActivity"
android:label="@string/title_activity_fullscreen"
android:screenOrientation="landscape"
tools:ignore="LockedOrientationActivity">
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/uk/co/sentinelweb/cuer/app/di/Modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import uk.co.sentinelweb.cuer.app.ui.common.ribbon.AndroidRibbonCreator
import uk.co.sentinelweb.cuer.app.ui.common.ribbon.RibbonCreator
import uk.co.sentinelweb.cuer.app.ui.common.views.PlayYangProgress
import uk.co.sentinelweb.cuer.app.ui.common.views.description.DescriptionView
import uk.co.sentinelweb.cuer.app.ui.exoplayer.ExoPlayerContract
import uk.co.sentinelweb.cuer.app.ui.filebrowser.FileBrowserFragment
import uk.co.sentinelweb.cuer.app.ui.filebrowser.dialog.FilesDialogFragment
import uk.co.sentinelweb.cuer.app.ui.filebrowser.transfers.TransfersFragment
Expand All @@ -46,6 +45,8 @@ import uk.co.sentinelweb.cuer.app.ui.main.MainContract
import uk.co.sentinelweb.cuer.app.ui.onboarding.OnboardingFragment
import uk.co.sentinelweb.cuer.app.ui.play_control.CastPlayerFragment
import uk.co.sentinelweb.cuer.app.ui.play_control.mvi.CastPlayerMviFragment
import uk.co.sentinelweb.cuer.app.ui.player.android.AndroidVideoPlayerContract
import uk.co.sentinelweb.cuer.app.ui.player.exoplayer.ExoPlayerContract
import uk.co.sentinelweb.cuer.app.ui.playlist.PlaylistMviFragment
import uk.co.sentinelweb.cuer.app.ui.playlist_edit.PlaylistEditContract
import uk.co.sentinelweb.cuer.app.ui.playlist_item_edit.PlaylistItemEditContract
Expand Down Expand Up @@ -88,6 +89,7 @@ import uk.co.sentinelweb.cuer.app.util.prefs.GeneralPreferencesWrapper
import uk.co.sentinelweb.cuer.app.util.prefs.SharedPrefsWrapper
import uk.co.sentinelweb.cuer.app.util.remote.AndroidWakeLockManager
import uk.co.sentinelweb.cuer.app.util.remote.AppPlayerLaunchHost
import uk.co.sentinelweb.cuer.app.util.remote.VideoWakeLockManager
import uk.co.sentinelweb.cuer.app.util.share.SharingShortcutsManager
import uk.co.sentinelweb.cuer.app.util.share.scan.AndroidLinkScanner
import uk.co.sentinelweb.cuer.app.util.share.scan.LinkScanner
Expand Down Expand Up @@ -158,6 +160,7 @@ object Modules {
CastDialogFragment.fragmentModule,
NodesDialogFragment.fragmentModule,
ExoPlayerContract.activityModule,
AndroidVideoPlayerContract.activityModule,
TransfersFragment.fragmentModule,
FilesDialogFragment.fragmentModule,
)
Expand Down Expand Up @@ -216,6 +219,7 @@ object Modules {
}
}
single<WakeLockManager> { AndroidWakeLockManager(androidApplication()) }
single { VideoWakeLockManager(androidApplication()) }
single<WifiStateProvider> { WifiStateReceiver(androidApplication(), get()) }
single<PlayerLaunchHost> { AppPlayerLaunchHost(androidApplication(), get()) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ class CastDialogFragment : DialogFragment(), AndroidScopeComponent {
scoped {
CastDialogViewModel(
castController = get(),
remotesLauncher = get(),
coroutines = get()
nodesDialogLauncher = get(),
launchLocalPlayer = get(),
launchRemotePlayer = get(),
log = get(),
)
}
}
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package uk.co.sentinelweb.cuer.app.ui.common.compose.video

import android.app.Activity
import android.view.WindowManager
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalView

@Composable
fun KeepScreenOnHandler(keepScreenOn: Boolean) {
val view = LocalView.current
LaunchedEffect(keepScreenOn) {
val window = (view.context as Activity).window
if (keepScreenOn) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import uk.co.sentinelweb.cuer.app.ui.common.navigation.NavigationModel.Param.PLAYLIST_ITEM
import uk.co.sentinelweb.cuer.app.ui.common.navigation.NavigationModel.Target.*
import uk.co.sentinelweb.cuer.app.ui.common.navigation.NavigationModel.Target.Companion.KEY
import uk.co.sentinelweb.cuer.app.ui.exoplayer.ExoPlayerActivity
import uk.co.sentinelweb.cuer.app.ui.player.android.AndroidVideoPlayerActivity
import uk.co.sentinelweb.cuer.app.ui.player.exoplayer.ExoPlayerActivity
import uk.co.sentinelweb.cuer.app.ui.share.ShareActivity
import uk.co.sentinelweb.cuer.app.ui.ytplayer.ayt_land.AytLandActivity
import uk.co.sentinelweb.cuer.app.ui.ytplayer.ayt_portrait.AytPortraitActivity
Expand All @@ -27,7 +28,7 @@
import uk.co.sentinelweb.cuer.domain.PlaylistItemDomain
import uk.co.sentinelweb.cuer.domain.ext.serialise

class NavigationRouter (
class NavigationRouter(

Check warning

Code scanning / detekt

The more parameters a function has the more complex it is. Long parameter lists are often used to control complex algorithms and violate the Single Responsibility Principle. Prefer functions with short parameter lists. Warning

The constructor(activity: Activity, toastWrapper: ToastWrapper, ytJavaApi: PlatformLaunchWrapper, navController: NavController?, log: LogWrapper, urlLauncher: UrlLauncherWrapper, cryptoLauncher: CryptoLauncher) has too many parameters. The current threshold is set to 7.
private val activity: Activity,
private val toastWrapper: ToastWrapper,
private val ytJavaApi: PlatformLaunchWrapper,
Expand All @@ -41,56 +42,60 @@
when (nav.target) {
NAV_NONE -> Unit
LOCAL_PLAYER_FULL ->
(nav.params[PLAYLIST_AND_ITEM] as PlaylistAndItemDomain?)?.let {
//YoutubeFullScreenActivity.start(activity, it)
AytLandActivity.start(activity, it)
}
(nav.params[PLAYLIST_AND_ITEM] as PlaylistAndItemDomain?)
?.let { AytLandActivity.start(activity, it) }
?: throw IllegalArgumentException("$LOCAL_PLAYER_FULL: $PLAYLIST_ITEM param required")

LOCAL_PLAYER -> {
(nav.params[PLAYLIST_AND_ITEM] as PlaylistAndItemDomain?)?.let {
AytPortraitActivity.start(activity, it)
} ?: throw IllegalArgumentException("$LOCAL_PLAYER: $PLAYLIST_ITEM param required")
(nav.params[PLAYLIST_AND_ITEM] as PlaylistAndItemDomain?)
?.let { AytPortraitActivity.start(activity, it) }
?: throw IllegalArgumentException("$LOCAL_PLAYER: $PLAYLIST_ITEM param required")
}

EXO_PLAYER_FULL -> {
(nav.params[PLAYLIST_AND_ITEM] as PlaylistAndItemDomain?)?.let {
ExoPlayerActivity.start(activity, it)
} ?: throw IllegalArgumentException("$LOCAL_PLAYER: $PLAYLIST_ITEM param required")
(nav.params[PLAYLIST_AND_ITEM] as PlaylistAndItemDomain?)
?.let { ExoPlayerActivity.start(activity, it, ExoPlayerActivity::class) }
?: throw IllegalArgumentException("$LOCAL_PLAYER: $PLAYLIST_ITEM param required")
}

ANDROID_VIDEO_PLAYER_FULL -> {
(nav.params[PLAYLIST_AND_ITEM] as PlaylistAndItemDomain?)
?.let { ExoPlayerActivity.start(activity, it, AndroidVideoPlayerActivity::class) }
?: throw IllegalArgumentException("$LOCAL_PLAYER: $PLAYLIST_ITEM param required")
}

WEB_LINK ->
nav.params[LINK]?.let {
urlLauncher.launchWithChooser(it.toString())
} ?: throw IllegalArgumentException("$WEB_LINK: $LINK param required")
nav.params[LINK]
?.let { urlLauncher.launchWithChooser(it.toString()) }
?: throw IllegalArgumentException("$WEB_LINK: $LINK param required")

CRYPTO_LINK ->
nav.getParam<LinkDomain.CryptoLinkDomain>(CRYPTO_ADDRESS)
?.let { cryptoLauncher.launch(it) }
?: throw IllegalArgumentException("$CRYPTO_LINK: $CRYPTO_ADDRESS param required")

NAV_BACK -> {
nav.params[BACK_PARAMS]?.let {
navController?.popBackStack(it as Int, false)
} ?: navController?.popBackStack()
nav.params[BACK_PARAMS]
?.let { navController?.popBackStack(it as Int, false) }
?: navController?.popBackStack()
}

NAV_FINISH -> activity.finish()

YOUTUBE_CHANNEL -> if (!ytJavaApi.launchChannel(nav.params[CHANNEL_ID] as String)) {
toastWrapper.show("can't launch channel")
}
YOUTUBE_CHANNEL -> ytJavaApi.launchChannel(nav.params[CHANNEL_ID] as String)
.takeIf { it }
?: { toastWrapper.show("can't launch channel") }

YOUTUBE_VIDEO -> if (!ytJavaApi.launchVideoSystem(nav.params[PLATFORM_ID] as String)) {
toastWrapper.show("can't launch channel")
}
YOUTUBE_VIDEO -> ytJavaApi.launchVideoSystem(nav.params[PLATFORM_ID] as String)
.takeIf { it }
?: { toastWrapper.show("can't launch channel") }

YOUTUBE_VIDEO_POS ->
(nav.params[PLAYLIST_ITEM] as? PlaylistItemDomain)?.media
?.also {
if (!ytJavaApi.launchVideoWithTimeSystem(it)) {
toastWrapper.show("can't launch media with time")
}
ytJavaApi.launchVideoWithTimeSystem(it)
.takeIf { it }
?: { toastWrapper.show("can't launch media with time") }
}

PLAYLIST -> navController?.navigate(
Expand Down Expand Up @@ -213,7 +218,7 @@
if (isFragment) {
try {
(get() as Fragment).findNavController()
} catch (e: IllegalStateException) {
} catch (_: IllegalStateException) {
null
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,15 @@ class FileBrowserFragment : Fragment(), AndroidScopeComponent {
filesInteractor = get(),
remotesRepository = get(),
mapper = get(),
playerInteractor = get(),
log = get(),
castController = get(),
nodesDialogLauncher = get(),
cuerCastPlayerWatcher = get(),
getFolderListUseCase = get(),
deleteFileUseCase = get(),
localRepository = get(),
localPlayerLaunchHost = get(),
transfersService = get(),
launchLocalPlayer = get(),
launchRemotePlayer = get(),
_effects = ViewModelEffects<Effect>(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,14 @@ class FilesDialogFragment(
filesInteractor = get(),
remotesRepository = get(),
mapper = get(),
playerInteractor = get(),
log = get(),
castController = get(),
nodesDialogLauncher = get(),
cuerCastPlayerWatcher = get(),
getFolderListUseCase = get(),
deleteFileUseCase = get(),
localRepository = get(),
localPlayerLaunchHost = get(),
launchLocalPlayer = get(),
launchRemotePlayer = get(),
transfersService = get(),
_effects = ViewModelEffects<Effect>(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import uk.co.sentinelweb.cuer.app.ui.player.PlayerContract
import uk.co.sentinelweb.cuer.app.ui.remotes.selector.NodesDialogContract
import uk.co.sentinelweb.cuer.app.ui.remotes.selector.NodesDialogLauncher
import uk.co.sentinelweb.cuer.app.ui.share.ShareNavigationHack
import uk.co.sentinelweb.cuer.app.usecase.LaunchRemotePlayerUseCase
import uk.co.sentinelweb.cuer.app.util.chromecast.CastDialogWrapper
import uk.co.sentinelweb.cuer.app.util.chromecast.CuerSimpleVolumeController
import uk.co.sentinelweb.cuer.app.util.chromecast.listener.ChromecastContract
Expand Down Expand Up @@ -168,6 +169,7 @@ interface MainContract {
scoped { CuerSimpleVolumeController(castController = get(), log = get()) }
scoped { StatusBarColorWrapper(activity = get<MainActivity>()) }
scoped {(ShowOnLockScreenWrapper(a = get<MainActivity>()))}
scoped { LaunchRemotePlayerUseCase(get(), get()) }
}
}
}
Expand Down
Loading
Loading