mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
fixed rotation issues
This commit is contained in:
parent
3c778c07c2
commit
ce7d54c151
3 changed files with 34 additions and 20 deletions
|
@ -61,9 +61,6 @@ class MenuBottomBarFragment : MainActivityFragment() {
|
|||
super.onConfigurationChanged(newConfig)
|
||||
|
||||
_view?.updateAllButtonVisibility()
|
||||
|
||||
// collapse the more menu
|
||||
_view?.onBackPressed()
|
||||
}
|
||||
|
||||
@SuppressLint("ViewConstructor")
|
||||
|
@ -268,6 +265,10 @@ class MenuBottomBarFragment : MainActivityFragment() {
|
|||
}
|
||||
|
||||
fun updateAllButtonVisibility() {
|
||||
if(_moreVisible) {
|
||||
setMoreVisible(false);
|
||||
}
|
||||
|
||||
val defs = currentButtonDefinitions?.toMutableList() ?: return
|
||||
val metrics = resources.displayMetrics;
|
||||
_buttonsVisible = floor(metrics.widthPixels.toDouble() / 65.dp(resources).toDouble()).roundToInt();
|
||||
|
|
|
@ -229,9 +229,7 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
|
|||
}
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
|
||||
private fun updateSpanCount(){
|
||||
if (resources.configuration.screenWidthDp >= resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 2){
|
||||
recyclerData.layoutManager.spanCount = 2
|
||||
} else if (resources.configuration.screenWidthDp < resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 1){
|
||||
|
@ -239,13 +237,14 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
|
|||
}
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
|
||||
updateSpanCount()
|
||||
}
|
||||
|
||||
fun onResume() {
|
||||
//update the number of columns
|
||||
if (resources.configuration.screenWidthDp >= resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 2){
|
||||
recyclerData.layoutManager.spanCount = 2
|
||||
} else if (resources.configuration.screenWidthDp < resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 1){
|
||||
recyclerData.layoutManager.spanCount = 1
|
||||
}
|
||||
updateSpanCount()
|
||||
|
||||
//Reload the pager if the plugin was killed
|
||||
val pager = recyclerData.pager;
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.futo.platformplayer.models.PlatformVideoWithTime
|
|||
import com.futo.platformplayer.models.UrlVideoWithTime
|
||||
import com.futo.platformplayer.states.StatePlayer
|
||||
import com.futo.platformplayer.views.containers.SingleViewTouchableMotionLayout
|
||||
import kotlin.math.min
|
||||
|
||||
|
||||
class VideoDetailFragment : MainFragment {
|
||||
|
@ -96,13 +97,18 @@ class VideoDetailFragment : MainFragment {
|
|||
val currentOrientation = _currentOrientation
|
||||
val isFs = isFullscreen
|
||||
|
||||
if (isFs && isMaximized && !isFullScreenPortraitAllowed) {
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||
if (StatePlayer.instance.rotationLock && isMaximized) {
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED
|
||||
} else if (isFullscreen && !isFullScreenPortraitAllowed) {
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
} else {
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
}
|
||||
|
||||
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}, isMaximized = ${isMaximized}, isFullScreenPortraitAllowed = ${isFullScreenPortraitAllowed}) resulted in requested orientation ${activity?.requestedOrientation}"
|
||||
);
|
||||
}
|
||||
|
||||
override fun onShownWithView(parameter: Any?, isBack: Boolean) {
|
||||
|
@ -280,15 +286,23 @@ class VideoDetailFragment : MainFragment {
|
|||
_orientationListener = SimpleOrientationListener(requireActivity(), lifecycleScope)
|
||||
_orientationListener.onOrientationChanged.subscribe {
|
||||
_currentOrientation = it
|
||||
Logger.i(TAG, "Current orientation changed (_currentOrientation = ${_currentOrientation})")
|
||||
Logger.i(
|
||||
TAG,
|
||||
"Current orientation changed (_currentOrientation = ${_currentOrientation})"
|
||||
)
|
||||
|
||||
if (Settings.instance.playback.isAutoRotate()) {
|
||||
if (!isFullscreen && (it == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)) {
|
||||
val is_large_window = min(
|
||||
resources.configuration.screenWidthDp,
|
||||
resources.configuration.screenHeightDp
|
||||
) < resources.getDimension(R.dimen.landscape_threshold)
|
||||
|
||||
if (Settings.instance.playback.isAutoRotate() && is_large_window) {
|
||||
if (!isFullscreen && (it == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)) {
|
||||
_viewDetail?.setFullscreen(true)
|
||||
return@subscribe
|
||||
}
|
||||
|
||||
if (isFullscreen && !Settings.instance.playback.fullscreenPortrait && (it == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)) {
|
||||
if (isFullscreen && !Settings.instance.playback.fullscreenPortrait && (it == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)) {
|
||||
_viewDetail?.setFullscreen(false)
|
||||
return@subscribe
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue