fixed rotation issues

This commit is contained in:
Kai DeLorenzo 2024-08-22 12:43:39 -05:00
commit ce7d54c151
No known key found for this signature in database
3 changed files with 34 additions and 20 deletions

View file

@ -61,9 +61,6 @@ class MenuBottomBarFragment : MainActivityFragment() {
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)
_view?.updateAllButtonVisibility() _view?.updateAllButtonVisibility()
// collapse the more menu
_view?.onBackPressed()
} }
@SuppressLint("ViewConstructor") @SuppressLint("ViewConstructor")
@ -268,6 +265,10 @@ class MenuBottomBarFragment : MainActivityFragment() {
} }
fun updateAllButtonVisibility() { fun updateAllButtonVisibility() {
if(_moreVisible) {
setMoreVisible(false);
}
val defs = currentButtonDefinitions?.toMutableList() ?: return val defs = currentButtonDefinitions?.toMutableList() ?: return
val metrics = resources.displayMetrics; val metrics = resources.displayMetrics;
_buttonsVisible = floor(metrics.widthPixels.toDouble() / 65.dp(resources).toDouble()).roundToInt(); _buttonsVisible = floor(metrics.widthPixels.toDouble() / 65.dp(resources).toDouble()).roundToInt();

View file

@ -229,9 +229,7 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
} }
} }
override fun onConfigurationChanged(newConfig: Configuration?) { private fun updateSpanCount(){
super.onConfigurationChanged(newConfig)
if (resources.configuration.screenWidthDp >= resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 2){ if (resources.configuration.screenWidthDp >= resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 2){
recyclerData.layoutManager.spanCount = 2 recyclerData.layoutManager.spanCount = 2
} else if (resources.configuration.screenWidthDp < resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 1){ } 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() { fun onResume() {
//update the number of columns 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){
recyclerData.layoutManager.spanCount = 1
}
//Reload the pager if the plugin was killed //Reload the pager if the plugin was killed
val pager = recyclerData.pager; val pager = recyclerData.pager;

View file

@ -29,6 +29,7 @@ import com.futo.platformplayer.models.PlatformVideoWithTime
import com.futo.platformplayer.models.UrlVideoWithTime import com.futo.platformplayer.models.UrlVideoWithTime
import com.futo.platformplayer.states.StatePlayer import com.futo.platformplayer.states.StatePlayer
import com.futo.platformplayer.views.containers.SingleViewTouchableMotionLayout import com.futo.platformplayer.views.containers.SingleViewTouchableMotionLayout
import kotlin.math.min
class VideoDetailFragment : MainFragment { class VideoDetailFragment : MainFragment {
@ -96,13 +97,18 @@ class VideoDetailFragment : MainFragment {
val currentOrientation = _currentOrientation val currentOrientation = _currentOrientation
val isFs = isFullscreen val isFs = isFullscreen
if (isFs && isMaximized && !isFullScreenPortraitAllowed) { if (StatePlayer.instance.rotationLock && isMaximized) {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED
} else if (isFullscreen && !isFullScreenPortraitAllowed) {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
} else { } 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) { override fun onShownWithView(parameter: Any?, isBack: Boolean) {
@ -280,15 +286,23 @@ class VideoDetailFragment : MainFragment {
_orientationListener = SimpleOrientationListener(requireActivity(), lifecycleScope) _orientationListener = SimpleOrientationListener(requireActivity(), lifecycleScope)
_orientationListener.onOrientationChanged.subscribe { _orientationListener.onOrientationChanged.subscribe {
_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()) { val is_large_window = min(
if (!isFullscreen && (it == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)) { 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) _viewDetail?.setFullscreen(true)
return@subscribe 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) _viewDetail?.setFullscreen(false)
return@subscribe return@subscribe
} }