mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-05-28 20:40:17 +02:00
Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay
This commit is contained in:
commit
d9403bf4da
@ -141,10 +141,9 @@ class HomeFragment : MainFragment() {
|
|||||||
|
|
||||||
val feedstyleChanged = recyclerData.loadedFeedStyle != feedStyle;
|
val feedstyleChanged = recyclerData.loadedFeedStyle != feedStyle;
|
||||||
val clientsChanged = lastClients == null || lastClients.size != clients.size || !lastClients.containsAll(clients);
|
val clientsChanged = lastClients == null || lastClients.size != clients.size || !lastClients.containsAll(clients);
|
||||||
val outdated = recyclerData.lastLoad.getNowDiffSeconds() > 60;
|
Logger.i(TAG, "onShown (recyclerData.loadedFeedStyle=${recyclerData.loadedFeedStyle}, recyclerData.lastLoad=${recyclerData.lastLoad}, feedstyleChanged=$feedstyleChanged, clientsChanged=$clientsChanged)")
|
||||||
Logger.i(TAG, "onShown (recyclerData.loadedFeedStyle=${recyclerData.loadedFeedStyle}, recyclerData.lastLoad=${recyclerData.lastLoad}, feedstyleChanged=$feedstyleChanged, clientsChanged=$clientsChanged, outdated=$outdated)")
|
|
||||||
|
|
||||||
if(feedstyleChanged || outdated || clientsChanged) {
|
if(feedstyleChanged || clientsChanged) {
|
||||||
recyclerData.lastLoad = OffsetDateTime.now();
|
recyclerData.lastLoad = OffsetDateTime.now();
|
||||||
recyclerData.loadedFeedStyle = feedStyle;
|
recyclerData.loadedFeedStyle = feedStyle;
|
||||||
recyclerData.lastClients = clients;
|
recyclerData.lastClients = clients;
|
||||||
|
@ -156,6 +156,14 @@ class PlaylistFragment : MainFragment() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun copyPlaylist(playlist: Playlist) {
|
||||||
|
StatePlaylists.instance.playlistStore.save(playlist)
|
||||||
|
_fragment.topBar?.assume<NavigationTopBarFragment>()?.setMenuItems(
|
||||||
|
arrayListOf()
|
||||||
|
)
|
||||||
|
UIDialogs.toast("Playlist saved")
|
||||||
|
}
|
||||||
|
|
||||||
fun onShown(parameter: Any?) {
|
fun onShown(parameter: Any?) {
|
||||||
_taskLoadPlaylist.cancel()
|
_taskLoadPlaylist.cancel()
|
||||||
|
|
||||||
@ -170,14 +178,10 @@ class PlaylistFragment : MainFragment() {
|
|||||||
setButtonDownloadVisible(true)
|
setButtonDownloadVisible(true)
|
||||||
setButtonEditVisible(true)
|
setButtonEditVisible(true)
|
||||||
|
|
||||||
if (!StatePlaylists.instance.playlistStore.getItems().contains(parameter)) {
|
if (!StatePlaylists.instance.playlistStore.hasItem { it.id == parameter.id }) {
|
||||||
_fragment.topBar?.assume<NavigationTopBarFragment>()
|
_fragment.topBar?.assume<NavigationTopBarFragment>()
|
||||||
?.setMenuItems(arrayListOf(Pair(R.drawable.ic_copy) {
|
?.setMenuItems(arrayListOf(Pair(R.drawable.ic_copy) {
|
||||||
StatePlaylists.instance.playlistStore.save(parameter)
|
copyPlaylist(parameter)
|
||||||
_fragment.topBar?.assume<NavigationTopBarFragment>()?.setMenuItems(
|
|
||||||
arrayListOf()
|
|
||||||
)
|
|
||||||
UIDialogs.toast("Playlist saved")
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -242,6 +246,15 @@ class PlaylistFragment : MainFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun download() {
|
private fun download() {
|
||||||
|
val playlist = _playlist ?: return
|
||||||
|
if (!StatePlaylists.instance.playlistStore.hasItem { it.id == playlist.id }) {
|
||||||
|
UIDialogs.showConfirmationDialog(context, "Playlist must be saved to download", {
|
||||||
|
copyPlaylist(playlist)
|
||||||
|
download()
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_playlist?.let {
|
_playlist?.let {
|
||||||
UISlideOverlays.showDownloadPlaylistOverlay(it, overlayContainer);
|
UISlideOverlays.showDownloadPlaylistOverlay(it, overlayContainer);
|
||||||
}
|
}
|
||||||
@ -266,6 +279,15 @@ class PlaylistFragment : MainFragment() {
|
|||||||
override fun canEdit(): Boolean { return _playlist != null; }
|
override fun canEdit(): Boolean { return _playlist != null; }
|
||||||
|
|
||||||
override fun onEditClick() {
|
override fun onEditClick() {
|
||||||
|
val playlist = _playlist ?: return
|
||||||
|
if (!StatePlaylists.instance.playlistStore.hasItem { it.id == playlist.id }) {
|
||||||
|
UIDialogs.showConfirmationDialog(context, "Playlist must be saved to edit the name", {
|
||||||
|
copyPlaylist(playlist)
|
||||||
|
onEditClick()
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_editPlaylistNameInput?.activate();
|
_editPlaylistNameInput?.activate();
|
||||||
_editPlaylistOverlay?.show();
|
_editPlaylistOverlay?.show();
|
||||||
}
|
}
|
||||||
|
@ -93,22 +93,40 @@ class VideoDetailFragment : MainFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateOrientation() {
|
private fun updateOrientation() {
|
||||||
|
val a = activity ?: return
|
||||||
val isMaximized = state == State.MAXIMIZED
|
val isMaximized = state == State.MAXIMIZED
|
||||||
val isFullScreenPortraitAllowed = Settings.instance.playback.fullscreenPortrait;
|
val isFullScreenPortraitAllowed = Settings.instance.playback.fullscreenPortrait;
|
||||||
val currentOrientation = _currentOrientation
|
val bypassRotationPrevention = Settings.instance.other.bypassRotationPrevention;
|
||||||
|
val currentRequestedOrientation = a.requestedOrientation
|
||||||
|
val currentOrientation = if (_currentOrientation == -1) currentRequestedOrientation else _currentOrientation
|
||||||
|
val isAutoRotate = Settings.instance.playback.isAutoRotate()
|
||||||
val isFs = isFullscreen
|
val isFs = isFullscreen
|
||||||
|
|
||||||
if (isFs && isMaximized) {
|
if (isFs && isMaximized) {
|
||||||
if (isFullScreenPortraitAllowed) {
|
if (isFullScreenPortraitAllowed) {
|
||||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
if (isAutoRotate) {
|
||||||
|
a.requestedOrientation = currentOrientation
|
||||||
|
}
|
||||||
|
} else if (currentOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
|
||||||
|
if (isAutoRotate) {
|
||||||
|
a.requestedOrientation = currentOrientation
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||||
|
}
|
||||||
|
} else if (bypassRotationPrevention) {
|
||||||
|
if (isAutoRotate) {
|
||||||
|
a.requestedOrientation = currentOrientation
|
||||||
|
}
|
||||||
|
} else if (currentOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
||||||
|
if (isAutoRotate) {
|
||||||
|
a.requestedOrientation = currentOrientation
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|
a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "updateOrientation (isFs = ${isFs}, currentOrientation = ${currentOrientation}, isMaximized = ${isMaximized}, isFullScreenPortraitAllowed = ${isFullScreenPortraitAllowed}) resulted in requested orientation ${activity?.requestedOrientation}");
|
Log.i(TAG, "updateOrientation (isFs = ${isFs}, currentOrientation = ${currentOrientation}, currentRequestedOrientation = ${currentRequestedOrientation}, isMaximized = ${isMaximized}, isAutoRotate = ${isAutoRotate}, isFullScreenPortraitAllowed = ${isFullScreenPortraitAllowed}) resulted in requested orientation ${activity?.requestedOrientation}");
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onShownWithView(parameter: Any?, isBack: Boolean) {
|
override fun onShownWithView(parameter: Any?, isBack: Boolean) {
|
||||||
@ -269,6 +287,9 @@ class VideoDetailFragment : MainFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_autoRotateChangeListener = AutoRotateChangeListener(requireContext(), Handler()) { _ ->
|
_autoRotateChangeListener = AutoRotateChangeListener(requireContext(), Handler()) { _ ->
|
||||||
|
if (updateAutoFullscreen()) {
|
||||||
|
return@AutoRotateChangeListener
|
||||||
|
}
|
||||||
updateOrientation()
|
updateOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,6 +301,9 @@ class VideoDetailFragment : MainFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StatePlayer.instance.onRotationLockChanged.subscribe(this) {
|
StatePlayer.instance.onRotationLockChanged.subscribe(this) {
|
||||||
|
if (updateAutoFullscreen()) {
|
||||||
|
return@subscribe
|
||||||
|
}
|
||||||
updateOrientation()
|
updateOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,23 +312,29 @@ class VideoDetailFragment : MainFragment {
|
|||||||
_currentOrientation = it
|
_currentOrientation = it
|
||||||
Logger.i(TAG, "Current orientation changed (_currentOrientation = ${_currentOrientation})")
|
Logger.i(TAG, "Current orientation changed (_currentOrientation = ${_currentOrientation})")
|
||||||
|
|
||||||
if (Settings.instance.playback.isAutoRotate()) {
|
if (updateAutoFullscreen()) {
|
||||||
if (state == State.MAXIMIZED && !isFullscreen && (it == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)) {
|
return@subscribe
|
||||||
_viewDetail?.setFullscreen(true)
|
|
||||||
return@subscribe
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == State.MAXIMIZED && isFullscreen && !Settings.instance.playback.fullscreenPortrait && (it == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)) {
|
|
||||||
_viewDetail?.setFullscreen(false)
|
|
||||||
return@subscribe
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOrientation()
|
updateOrientation()
|
||||||
}
|
}
|
||||||
return _view!!;
|
return _view!!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateAutoFullscreen(): Boolean {
|
||||||
|
if (Settings.instance.playback.isAutoRotate()) {
|
||||||
|
if (state == State.MAXIMIZED && !isFullscreen && (_currentOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || _currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)) {
|
||||||
|
_viewDetail?.setFullscreen(true)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.MAXIMIZED && isFullscreen && !Settings.instance.playback.fullscreenPortrait && (_currentOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || _currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)) {
|
||||||
|
_viewDetail?.setFullscreen(false)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
fun onUserLeaveHint() {
|
fun onUserLeaveHint() {
|
||||||
val viewDetail = _viewDetail;
|
val viewDetail = _viewDetail;
|
||||||
Logger.i(TAG, "onUserLeaveHint preventPictureInPicture=${viewDetail?.preventPictureInPicture} isCasting=${StateCasting.instance.isCasting} isBackgroundPictureInPicture=${Settings.instance.playback.isBackgroundPictureInPicture()} allowBackground=${viewDetail?.allowBackground}");
|
Logger.i(TAG, "onUserLeaveHint preventPictureInPicture=${viewDetail?.preventPictureInPicture} isCasting=${StateCasting.instance.isCasting} isBackgroundPictureInPicture=${Settings.instance.playback.isBackgroundPictureInPicture()} allowBackground=${viewDetail?.allowBackground}");
|
||||||
|
@ -645,6 +645,7 @@ class StateApp {
|
|||||||
wm.cancelAllWork();
|
wm.cancelAllWork();
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
Logger.e(TAG, "Failed to schedule background subscription updates.", e)
|
Logger.e(TAG, "Failed to schedule background subscription updates.", e)
|
||||||
|
UIDialogs.toast(context, "Background subscription update failed: " + e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user