Skip to content

Commit b75ead0

Browse files
authored
fix: apply proper insets to player controls and extended details (#766)
* fix: apply proper insets to player controls and extended details This fixes overlap in landscape mode. * docs: update changelog
1 parent 541df95 commit b75ead0

File tree

6 files changed

+31
-5
lines changed

6 files changed

+31
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Fixed overlap between editor controls and preview ([#752])
1313
- Fixed crash when viewing photos with extended details enabled ([#754])
1414
- Fixed cropped copies being saved in app data when setting wallpaper ([#759])
15+
- Fixed overlap between player controls and navigation bars in landscape mode
1516

1617
## [1.8.1] - 2025-11-04
1718
### Changed

app/src/main/kotlin/org/fossify/gallery/activities/BaseViewerActivity.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.lifecycle.lifecycleScope
1010
import androidx.lifecycle.repeatOnLifecycle
1111
import com.google.android.material.appbar.AppBarLayout
1212
import kotlinx.coroutines.launch
13+
import org.fossify.commons.extensions.updateMarginWithBase
1314
import org.fossify.commons.extensions.updatePaddingWithBase
1415
import org.fossify.gallery.extensions.config
1516

@@ -52,7 +53,6 @@ abstract class BaseViewerActivity : SimpleActivity() {
5253
} else {
5354
val system = insets.getInsetsIgnoringVisibility(Type.systemBars())
5455
val cutout = insets.getInsetsIgnoringVisibility(Type.displayCutout())
55-
5656
appBarLayout.updatePaddingWithBase(
5757
top = if (cutout.top > 0) 0 else system.top,
5858
left = if (cutout.left > 0) 0 else system.left,
@@ -67,4 +67,25 @@ abstract class BaseViewerActivity : SimpleActivity() {
6767
)
6868
}
6969
}
70+
71+
fun applyProperHorizontalInsets(view: View) {
72+
ViewCompat.setOnApplyWindowInsetsListener(view) { _, insets ->
73+
if (config.showNotch) {
74+
val systemAndCutout =
75+
insets.getInsetsIgnoringVisibility(Type.systemBars() or Type.displayCutout())
76+
view.updateMarginWithBase(
77+
left = systemAndCutout.left,
78+
right = systemAndCutout.right
79+
)
80+
} else {
81+
val system = insets.getInsetsIgnoringVisibility(Type.systemBars())
82+
val cutout = insets.getInsetsIgnoringVisibility(Type.displayCutout())
83+
view.updateMarginWithBase(
84+
left = if (cutout.left > 0) 0 else system.left,
85+
right = if (cutout.right > 0) 0 else system.right
86+
)
87+
}
88+
insets
89+
}
90+
}
7091
}

app/src/main/kotlin/org/fossify/gallery/activities/VideoPlayerActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ open class VideoPlayerActivity : BaseViewerActivity(), SeekBar.OnSeekBarChangeLi
659659
binding.bottomVideoTimeHolder.videoSeekbar.max = mDuration.toInt()
660660
binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration()
661661
binding.bottomVideoTimeHolder.videoCurrTime.text = mCurrTime.getFormattedDuration()
662+
applyProperHorizontalInsets(binding.bottomVideoTimeHolder.videoTimeHolder)
662663
setupTimer()
663664
}
664665

app/src/main/kotlin/org/fossify/gallery/fragments/PhotoFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import org.fossify.commons.helpers.DEFAULT_ANIMATION_DURATION
7575
import org.fossify.commons.helpers.ensureBackgroundThread
7676
import org.fossify.commons.helpers.isRPlus
7777
import org.fossify.gallery.R
78+
import org.fossify.gallery.activities.BaseViewerActivity
7879
import org.fossify.gallery.activities.PhotoActivity
7980
import org.fossify.gallery.activities.PhotoVideoActivity
8081
import org.fossify.gallery.activities.ViewPagerActivity
@@ -909,6 +910,7 @@ class PhotoFragment : ViewPagerFragment() {
909910
beVisibleIf(text.isNotEmpty())
910911
val hideExtendedDetails = context?.config?.hideExtendedDetails == true
911912
alpha = if (!hideExtendedDetails || !mIsFullscreen) 1f else 0f
913+
(activity as? BaseViewerActivity)?.applyProperHorizontalInsets(this)
912914
}
913915
}
914916
}

app/src/main/kotlin/org/fossify/gallery/fragments/VideoFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import org.fossify.commons.extensions.updateTextColors
6262
import org.fossify.commons.helpers.DEFAULT_ANIMATION_DURATION
6363
import org.fossify.commons.helpers.ensureBackgroundThread
6464
import org.fossify.gallery.R
65+
import org.fossify.gallery.activities.BaseViewerActivity
6566
import org.fossify.gallery.activities.VideoActivity
6667
import org.fossify.gallery.databinding.PagerVideoItemBinding
6768
import org.fossify.gallery.extensions.config
@@ -566,6 +567,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener,
566567
text = getMediumExtendedDetails(mMedium)
567568
beVisibleIf(text.isNotEmpty())
568569
alpha = if (!mConfig.hideExtendedDetails || !mIsFullscreen) 1f else 0f
570+
(activity as? BaseViewerActivity)?.applyProperHorizontalInsets(this)
569571
}
570572
} else {
571573
binding.videoDetails.beGone()
@@ -575,6 +577,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener,
575577
private fun initTimeHolder() {
576578
mTimeHolder.beGoneIf(mIsFullscreen)
577579
mTimeHolder.alpha = if (mIsFullscreen) 0f else 1f
580+
(activity as? BaseViewerActivity)?.applyProperHorizontalInsets(mTimeHolder)
578581
}
579582

580583
private fun checkIfPanorama() {

app/src/main/res/layout/bottom_video_time_holder.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/video_time_holder"
66
android:layout_width="match_parent"
7-
android:layout_height="wrap_content">
7+
android:layout_height="wrap_content"
8+
android:paddingTop="@dimen/medium_margin">
89

910
<TextView
1011
android:id="@+id/video_playback_speed"
@@ -31,7 +32,6 @@
3132
android:layout_width="@dimen/video_player_play_pause_size"
3233
android:layout_height="@dimen/video_player_play_pause_size"
3334
android:layout_marginStart="@dimen/small_margin"
34-
android:layout_marginTop="@dimen/activity_margin"
3535
android:background="?attr/selectableItemBackgroundBorderless"
3636
android:padding="@dimen/normal_margin"
3737
android:src="@drawable/ic_prev_outline_vector"
@@ -44,7 +44,6 @@
4444
android:id="@+id/video_toggle_play_pause"
4545
android:layout_width="@dimen/video_player_play_pause_size"
4646
android:layout_height="@dimen/video_player_play_pause_size"
47-
android:layout_marginTop="@dimen/activity_margin"
4847
android:background="?attr/selectableItemBackgroundBorderless"
4948
android:padding="@dimen/small_margin"
5049
android:src="@drawable/ic_pause_outline_vector"
@@ -58,7 +57,6 @@
5857
android:id="@+id/video_next_file"
5958
android:layout_width="@dimen/video_player_play_pause_size"
6059
android:layout_height="@dimen/video_player_play_pause_size"
61-
android:layout_marginTop="@dimen/activity_margin"
6260
android:layout_marginEnd="@dimen/small_margin"
6361
android:background="?attr/selectableItemBackgroundBorderless"
6462
android:padding="@dimen/normal_margin"

0 commit comments

Comments
 (0)