Skip to content

Commit 9bbcfa6

Browse files
authored
Update Input Screen landscape behavior (#6898)
Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211507598155413?focus=true ### Description - Uses top omnibar behavior when in landscape and using bottom address bar ### Steps to test this PR - [ ] Set the address bar to “Bottom" - [ ] Open the Input Screen and type something (so that the input expands) - [ ] Rotate to landscape - [ ] Verify that the top omnibar behavior is used ### UI changes | Before | After | | ------ | ----- | <img width="2340" height="1080" alt="Screenshot_20251006_210315" src="https://github.com/user-attachments/assets/b158116e-c2c7-438c-95bf-77600ef90804" />|<img width="2340" height="1080" alt="Screenshot_20251006_210235" src="https://github.com/user-attachments/assets/5de6dc37-a9f3-4df3-801e-7fe92ec6d11a" />
1 parent dfb371d commit 9bbcfa6

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/inputscreen/ui/InputScreenConfigResolver.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
package com.duckduckgo.duckchat.impl.inputscreen.ui
1818

19+
import android.content.Context
1920
import android.content.Intent
21+
import android.content.res.Configuration
22+
import com.duckduckgo.app.di.ActivityContext
2023
import com.duckduckgo.di.scopes.ActivityScope
2124
import com.duckduckgo.duckchat.api.inputscreen.InputScreenActivityParams
2225
import com.duckduckgo.duckchat.impl.DuckChatInternal
@@ -37,6 +40,7 @@ interface InputScreenConfigResolver {
3740
@SingleInstanceIn(scope = ActivityScope::class)
3841
class InputScreenConfigResolverImpl @Inject constructor(
3942
private val duckChatInternal: DuckChatInternal,
43+
@ActivityContext private val activityContext: Context,
4044
) : InputScreenConfigResolver {
4145
companion object {
4246
fun useTopBar(
@@ -59,5 +63,5 @@ class InputScreenConfigResolverImpl @Inject constructor(
5963
useTopBar(
6064
isTopOmnibar = isTopOmnibar,
6165
duckChatInternal = duckChatInternal,
62-
)
66+
) || activityContext.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
6367
}

duckchat/duckchat-impl/src/test/kotlin/com/duckduckgo/duckchat/impl/inputscreen/ui/InputScreenConfigResolverTest.kt

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
package com.duckduckgo.duckchat.impl.inputscreen.ui
1818

19+
import android.content.Context
1920
import android.content.Intent
21+
import android.content.res.Configuration
22+
import android.content.res.Resources
2023
import androidx.test.ext.junit.runners.AndroidJUnit4
2124
import com.duckduckgo.duckchat.api.inputscreen.InputScreenActivityParams
2225
import com.duckduckgo.duckchat.impl.DuckChatInternal
@@ -33,13 +36,19 @@ import org.mockito.kotlin.whenever
3336
class InputScreenConfigResolverTest {
3437
private val duckChatInternal: DuckChatInternal = mock()
3538
private val inputScreenBottomBarEnabled = MutableStateFlow(false)
39+
private val mockActivityContext: Context = mock()
40+
private val mockResources: Resources = mock()
41+
private val configuration = Configuration()
3642

3743
private lateinit var inputScreenConfigResolver: InputScreenConfigResolverImpl
3844

3945
@Before
4046
fun setup() {
4147
whenever(duckChatInternal.inputScreenBottomBarEnabled).thenReturn(inputScreenBottomBarEnabled)
42-
inputScreenConfigResolver = InputScreenConfigResolverImpl(duckChatInternal)
48+
whenever(mockActivityContext.resources).thenReturn(mockResources)
49+
whenever(mockResources.configuration).thenReturn(configuration)
50+
configuration.orientation = Configuration.ORIENTATION_PORTRAIT
51+
inputScreenConfigResolver = InputScreenConfigResolverImpl(duckChatInternal, mockActivityContext)
4352
}
4453

4554
@Test
@@ -118,4 +127,68 @@ class InputScreenConfigResolverTest {
118127

119128
assertFalse(inputScreenConfigResolver.useTopBar())
120129
}
130+
131+
@Test
132+
fun `when landscape and isTopOmnibar true and bottom bar enabled then useTopBar returns true`() {
133+
configuration.orientation = Configuration.ORIENTATION_LANDSCAPE
134+
135+
val intent = Intent().apply {
136+
putExtra(
137+
"ACTIVITY_SERIALIZABLE_PARAMETERS_ARG",
138+
InputScreenActivityParams(query = "", isTopOmnibar = true),
139+
)
140+
}
141+
inputScreenConfigResolver.onInputScreenCreated(intent)
142+
inputScreenBottomBarEnabled.value = true
143+
144+
assertTrue(inputScreenConfigResolver.useTopBar())
145+
}
146+
147+
@Test
148+
fun `when landscape and isTopOmnibar true and bottom bar disabled then useTopBar returns true`() {
149+
configuration.orientation = Configuration.ORIENTATION_LANDSCAPE
150+
151+
val intent = Intent().apply {
152+
putExtra(
153+
"ACTIVITY_SERIALIZABLE_PARAMETERS_ARG",
154+
InputScreenActivityParams(query = "", isTopOmnibar = true),
155+
)
156+
}
157+
inputScreenConfigResolver.onInputScreenCreated(intent)
158+
inputScreenBottomBarEnabled.value = false
159+
160+
assertTrue(inputScreenConfigResolver.useTopBar())
161+
}
162+
163+
@Test
164+
fun `when landscape and isTopOmnibar false and bottom bar enabled then useTopBar returns true`() {
165+
configuration.orientation = Configuration.ORIENTATION_LANDSCAPE
166+
167+
val intent = Intent().apply {
168+
putExtra(
169+
"ACTIVITY_SERIALIZABLE_PARAMETERS_ARG",
170+
InputScreenActivityParams(query = "", isTopOmnibar = false),
171+
)
172+
}
173+
inputScreenConfigResolver.onInputScreenCreated(intent)
174+
inputScreenBottomBarEnabled.value = true
175+
176+
assertTrue(inputScreenConfigResolver.useTopBar())
177+
}
178+
179+
@Test
180+
fun `when landscape and isTopOmnibar false and bottom bar disabled then useTopBar returns true`() {
181+
configuration.orientation = Configuration.ORIENTATION_LANDSCAPE
182+
183+
val intent = Intent().apply {
184+
putExtra(
185+
"ACTIVITY_SERIALIZABLE_PARAMETERS_ARG",
186+
InputScreenActivityParams(query = "", isTopOmnibar = false),
187+
)
188+
}
189+
inputScreenConfigResolver.onInputScreenCreated(intent)
190+
inputScreenBottomBarEnabled.value = false
191+
192+
assertTrue(inputScreenConfigResolver.useTopBar())
193+
}
121194
}

0 commit comments

Comments
 (0)