From 8f9a04390a9e18dbba7429f853abb87aca13fae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ulrych?= <74597246+TomasULR@users.noreply.github.com> Date: Wed, 22 Apr 2026 12:41:33 -0700 Subject: [PATCH] android: cap popup width on tablets and large screens (#521) On tablets in landscape mode, the AirPods connection popup covers the entire screen because width is set to MATCH_PARENT. This caps the popup width to 400dp on screens wider than 600dp and centers it horizontally. Also removes a duplicate gravity assignment in init that was overwriting the CENTER_HORIZONTAL flag. Fixes #425 Co-authored-by: TomasULR --- .../librepods/presentation/overlays/PopupWindow.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/me/kavishdevar/librepods/presentation/overlays/PopupWindow.kt b/android/app/src/main/java/me/kavishdevar/librepods/presentation/overlays/PopupWindow.kt index 45bdf9f..13bd22a 100644 --- a/android/app/src/main/java/me/kavishdevar/librepods/presentation/overlays/PopupWindow.kt +++ b/android/app/src/main/java/me/kavishdevar/librepods/presentation/overlays/PopupWindow.kt @@ -64,10 +64,16 @@ class PopupWindow( @Suppress("DEPRECATION") private val mParams: WindowManager.LayoutParams = WindowManager.LayoutParams().apply { height = WindowManager.LayoutParams.WRAP_CONTENT - width = WindowManager.LayoutParams.MATCH_PARENT + val displayMetrics = context.resources.displayMetrics + val screenWidthDp = displayMetrics.widthPixels / displayMetrics.density + width = if (screenWidthDp >= 600) { + (400 * displayMetrics.density).toInt() + } else { + WindowManager.LayoutParams.MATCH_PARENT + } type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY format = PixelFormat.TRANSLUCENT - gravity = Gravity.BOTTOM + gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL dimAmount = 0.3f flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS or WindowManager.LayoutParams.FLAG_FULLSCREEN or @@ -84,7 +90,6 @@ class PopupWindow( mParams.x = 0 mParams.y = 0 - mParams.gravity = Gravity.BOTTOM mView.setOnClickListener { close() }