Skip to content

Commit 2d659ab

Browse files
authored
Merge pull request #17139 from GitStartHQ/issue/17033-Language-Picker-Picker-is-mostly-below-the-screen-in-landscape-mode
Language Picker: Picker is mostly below the screen in landscape mode #17033
2 parents a42aad1 + f5d1f8b commit 2d659ab

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerBottomSheet.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.wordpress.android.ui.prefs.language
22

3+
import android.content.res.Configuration
34
import android.os.Bundle
45
import android.view.KeyEvent
56
import android.view.LayoutInflater
@@ -55,6 +56,18 @@ class LocalePickerBottomSheet : BottomSheetDialogFragment() {
5556
binding?.apply {
5657
setupContentViews()
5758
setupObservers()
59+
60+
val orientation = resources.configuration.orientation
61+
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
62+
val sheet = dialog?.findViewById<View>(
63+
com.google.android.material.R.id.design_bottom_sheet
64+
) as? FrameLayout
65+
sheet?.let {
66+
val behavior = BottomSheetBehavior.from(it)
67+
behavior.state = BottomSheetBehavior.STATE_EXPANDED
68+
behavior.skipCollapsed = true
69+
}
70+
}
5871
}
5972
}
6073

@@ -153,6 +166,23 @@ class LocalePickerBottomSheet : BottomSheetDialogFragment() {
153166
callback = null
154167
}
155168

169+
override fun onConfigurationChanged(newConfig: Configuration) {
170+
super.onConfigurationChanged(newConfig)
171+
172+
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
173+
bottomSheet?.let {
174+
val behavior = BottomSheetBehavior.from(it)
175+
behavior.state = BottomSheetBehavior.STATE_EXPANDED
176+
behavior.skipCollapsed = true
177+
}
178+
} else {
179+
bottomSheet?.let {
180+
val behavior = BottomSheetBehavior.from(it)
181+
behavior.skipCollapsed = false
182+
}
183+
}
184+
}
185+
156186
private fun expandBottomSheet() {
157187
bottomSheet?.let {
158188
val behavior = BottomSheetBehavior.from(it)

0 commit comments

Comments
 (0)