|
1 | 1 | package org.wordpress.android.ui.prefs.language |
2 | 2 |
|
| 3 | +import android.content.res.Configuration |
3 | 4 | import android.os.Bundle |
4 | 5 | import android.view.KeyEvent |
5 | 6 | import android.view.LayoutInflater |
@@ -55,6 +56,18 @@ class LocalePickerBottomSheet : BottomSheetDialogFragment() { |
55 | 56 | binding?.apply { |
56 | 57 | setupContentViews() |
57 | 58 | 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 | + } |
58 | 71 | } |
59 | 72 | } |
60 | 73 |
|
@@ -153,6 +166,23 @@ class LocalePickerBottomSheet : BottomSheetDialogFragment() { |
153 | 166 | callback = null |
154 | 167 | } |
155 | 168 |
|
| 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 | + |
156 | 186 | private fun expandBottomSheet() { |
157 | 187 | bottomSheet?.let { |
158 | 188 | val behavior = BottomSheetBehavior.from(it) |
|
0 commit comments