Skip to content

Commit b005d4a

Browse files
committed
update Input Screen settings toggle
1 parent 3e64e60 commit b005d4a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+445
-94
lines changed

.maestro/input_screen/input_screen_chat_mode.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ tags:
1414
# enable the Input Screen
1515
- runFlow: ../shared/open_ai_settings_screen.yaml
1616
- tapOn:
17-
id: "trailingSwitch"
18-
childOf:
19-
id: "duckAiInputScreenEnabledToggle"
17+
id: "duckAiInputScreenToggleWithAiImage"
2018
- action: back
2119
- action: back
2220

.maestro/input_screen/input_screen_preference_management.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ tags:
2020
# enable the Input Screen
2121
- runFlow: ../shared/open_ai_settings_screen.yaml
2222
- tapOn:
23-
id: "trailingSwitch"
24-
childOf:
25-
id: "duckAiInputScreenEnabledToggle"
23+
id: "duckAiInputScreenToggleWithAiImage"
2624
- action: back
2725
- action: back
2826

.maestro/input_screen/input_screen_search_mode.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ tags:
1414
# enable the Input Screen
1515
- runFlow: ../shared/open_ai_settings_screen.yaml
1616
- tapOn:
17-
id: "trailingSwitch"
18-
childOf:
19-
id: "duckAiInputScreenEnabledToggle"
17+
id: "duckAiInputScreenToggleWithAiImage"
2018
- action: back
2119
- action: back
2220

common/common-ui/src/main/res/values/design-experiments-theming.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<item name="daxColorControlFillPrimary">@color/controls_fill_primary_dark</item>
4141
<item name="daxColorControlFillSecondary">@color/controls_fill_secondary_dark</item>
4242
<item name="daxColorControlFillTertiary">@color/controls_fill_tertiary_dark</item>
43+
<item name="daxColorControlDecorationTertiary">@color/controls_decoration_tertiary_dark</item>
4344

4445
<!-- Widgets -->
4546
<item name="daxColorToolbar">?attr/daxColorBackground</item>
@@ -83,6 +84,7 @@
8384
<item name="daxColorControlFillPrimary">@color/controls_fill_primary_light</item>
8485
<item name="daxColorControlFillSecondary">@color/controls_fill_secondary_light</item>
8586
<item name="daxColorControlFillTertiary">@color/controls_fill_tertiary_light</item>
87+
<item name="daxColorControlDecorationTertiary">@color/controls_decoration_tertiary_light</item>
8688

8789
<!-- Widgets -->
8890
<item name="daxColorToolbar">?attr/daxColorBackground</item>

common/common-ui/src/main/res/values/design-system-colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
<attr name="daxColorControlFillPrimary" format="color"/>
7575
<attr name="daxColorControlFillSecondary" format="color"/>
7676
<attr name="daxColorControlFillTertiary" format="color"/>
77+
<attr name="daxColorControlDecorationTertiary" format="color"/>
7778

7879
<attr name="daxColorButtonPrimaryContainer" format="color"/>
7980
<attr name="daxColorButtonPrimaryContainerPressed" format="color"/>

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/ui/settings/DuckChatSettingsActivity.kt

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ class DuckChatSettingsActivity : DuckDuckGoActivity() {
6161
viewModel.onDuckChatUserEnabledToggled(isChecked)
6262
}
6363

64-
private val inputScreenToggleListener =
65-
CompoundButton.OnCheckedChangeListener { _, isChecked ->
66-
viewModel.onDuckAiInputScreenToggled(isChecked)
67-
}
68-
6964
@Inject
7065
lateinit var globalActivityStarter: GlobalActivityStarter
7166

@@ -135,18 +130,38 @@ class DuckChatSettingsActivity : DuckDuckGoActivity() {
135130
),
136131
)
137132

138-
binding.duckAiInputScreenEnabledToggle.apply {
139-
isVisible = viewState.shouldShowInputScreenToggle
140-
quietlySetIsChecked(viewState.isInputScreenEnabled, inputScreenToggleListener)
141-
}
133+
binding.duckAiInputScreenToggleContainer.isVisible = viewState.shouldShowInputScreenToggle
134+
configureInputScreenToggle(
135+
withoutAi = InputScreenToggleButton.WithoutAi(isActive = !viewState.isInputScreenEnabled),
136+
withAi = InputScreenToggleButton.WithAi(isActive = viewState.isInputScreenEnabled),
137+
)
138+
139+
binding.duckAiInputScreenDescription.isVisible = viewState.shouldShowInputScreenToggle
140+
binding.duckAiInputScreenDescription.addClickableSpan(
141+
textSequence = getText(R.string.input_screen_user_pref_description),
142+
spans = listOf(
143+
"share_feedback" to object : DuckDuckGoClickableSpan() {
144+
override fun onClick(widget: View) {
145+
viewModel.duckAiInputScreenShareFeedbackClicked()
146+
}
147+
},
148+
),
149+
)
142150

143151
binding.duckAiShortcuts.isVisible = viewState.shouldShowShortcuts
144152
binding.duckAiShortcuts.setOnClickListener {
145153
viewModel.onDuckAiShortcutsClicked()
146154
}
155+
147156
binding.showDuckChatSearchSettingsLink.setOnClickListener {
148157
viewModel.duckChatSearchAISettingsClicked()
149158
}
159+
binding.duckAiInputScreenWithoutAiContainer.setOnClickListener {
160+
viewModel.onDuckAiInputScreenWithoutAiSelected()
161+
}
162+
binding.duckAiInputScreenWithAiContainer.setOnClickListener {
163+
viewModel.onDuckAiInputScreenWithAiSelected()
164+
}
150165
}
151166

152167
private fun processCommand(command: DuckChatSettingsViewModel.Command) {
@@ -168,6 +183,54 @@ class DuckChatSettingsActivity : DuckDuckGoActivity() {
168183
val intent = Intent(this, DuckAiShortcutSettingsActivity::class.java)
169184
startActivity(intent)
170185
}
186+
187+
is DuckChatSettingsViewModel.Command.LaunchFeedback -> {
188+
globalActivityStarter.start(this, FeedbackActivityWithEmptyParams)
189+
}
190+
}
191+
}
192+
193+
private fun configureInputScreenToggle(
194+
withoutAi: InputScreenToggleButton,
195+
withAi: InputScreenToggleButton,
196+
) = with(binding) {
197+
val context = this@DuckChatSettingsActivity
198+
duckAiInputScreenToggleWithoutAiImage.setImageDrawable(ContextCompat.getDrawable(context, withoutAi.imageRes))
199+
duckAiInputScreenToggleWithoutAiImage.setBackgroundResource(withoutAi.backgroundRes)
200+
duckAiInputScreenToggleWithoutAiCheck.setImageDrawable(ContextCompat.getDrawable(context, withoutAi.checkRes))
201+
202+
duckAiInputScreenToggleWithAiImage.setImageDrawable(ContextCompat.getDrawable(context, withAi.imageRes))
203+
duckAiInputScreenToggleWithAiImage.setBackgroundResource(withAi.backgroundRes)
204+
duckAiInputScreenToggleWithAiCheck.setImageDrawable(ContextCompat.getDrawable(context, withAi.checkRes))
205+
}
206+
207+
private sealed class InputScreenToggleButton(isActive: Boolean) {
208+
abstract val imageRes: Int
209+
val backgroundRes: Int = if (isActive) {
210+
R.drawable.searchbox_background_active
211+
} else {
212+
R.drawable.searchbox_background
213+
}
214+
val checkRes: Int = if (isActive) {
215+
CommonR.drawable.ic_check_blue_round_24
216+
} else {
217+
CommonR.drawable.ic_shape_circle_24
218+
}
219+
220+
class WithoutAi(isActive: Boolean): InputScreenToggleButton(isActive) {
221+
override val imageRes: Int = if (isActive) {
222+
R.drawable.searchbox_withoutai_active
223+
} else {
224+
R.drawable.searchbox_withoutai
225+
}
226+
}
227+
228+
class WithAi(isActive: Boolean): InputScreenToggleButton(isActive) {
229+
override val imageRes: Int = if (isActive) {
230+
R.drawable.searchbox_withai_active
231+
} else {
232+
R.drawable.searchbox_withai
233+
}
171234
}
172235
}
173236
}

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/ui/settings/DuckChatSettingsViewModel.kt

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class DuckChatSettingsViewModel @Inject constructor(
7171
data class OpenLink(val link: String) : Command()
7272
data class OpenLinkInNewTab(val link: String) : Command()
7373
data object OpenShortcutSettings : Command()
74+
data object LaunchFeedback : Command()
7475
}
7576

7677
fun onDuckChatUserEnabledToggled(checked: Boolean) {
@@ -84,17 +85,6 @@ class DuckChatSettingsViewModel @Inject constructor(
8485
}
8586
}
8687

87-
fun onDuckAiInputScreenToggled(checked: Boolean) {
88-
viewModelScope.launch {
89-
if (checked) {
90-
pixel.fire(DuckChatPixelName.DUCK_CHAT_EXPERIMENTAL_ADDRESS_BAR_SETTING_ON)
91-
} else {
92-
pixel.fire(DuckChatPixelName.DUCK_CHAT_EXPERIMENTAL_ADDRESS_BAR_SETTING_OFF)
93-
}
94-
duckChat.setInputScreenUserSetting(checked)
95-
}
96-
}
97-
9888
fun onShowDuckChatInMenuToggled(checked: Boolean) {
9989
viewModelScope.launch {
10090
if (checked) {
@@ -136,6 +126,26 @@ class DuckChatSettingsViewModel @Inject constructor(
136126
}
137127
}
138128

129+
fun onDuckAiInputScreenWithoutAiSelected() {
130+
viewModelScope.launch {
131+
pixel.fire(DuckChatPixelName.DUCK_CHAT_EXPERIMENTAL_ADDRESS_BAR_SETTING_OFF)
132+
duckChat.setInputScreenUserSetting(enabled = false)
133+
}
134+
}
135+
136+
fun onDuckAiInputScreenWithAiSelected() {
137+
viewModelScope.launch {
138+
pixel.fire(DuckChatPixelName.DUCK_CHAT_EXPERIMENTAL_ADDRESS_BAR_SETTING_ON)
139+
duckChat.setInputScreenUserSetting(enabled = true)
140+
}
141+
}
142+
143+
fun duckAiInputScreenShareFeedbackClicked() {
144+
viewModelScope.launch {
145+
commandChannel.send(Command.LaunchFeedback)
146+
}
147+
}
148+
139149
companion object {
140150
const val DUCK_CHAT_LEARN_MORE_LINK = "https://duckduckgo.com/duckduckgo-help-pages/aichat/"
141151
const val DUCK_CHAT_SEARCH_AI_SETTINGS_LINK = "https://duckduckgo.com/settings?ko=-1#aifeatures"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (c) 2025 DuckDuckGo
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:shape="rectangle">
19+
20+
<corners android:radius="16dp" />
21+
22+
<solid android:color="?attr/daxColorLines" />
23+
24+
</shape>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (c) 2025 DuckDuckGo
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:shape="rectangle">
19+
20+
<corners android:radius="16dp" />
21+
22+
<solid android:color="?attr/daxOmnibarTextColorHighlight" />
23+
24+
<stroke
25+
android:width="1dp"
26+
android:color="?attr/daxColorAccentBlue" />
27+
28+
</shape>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
~ Copyright (c) 2025 DuckDuckGo
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:width="128dp"
19+
android:height="72dp"
20+
android:viewportWidth="128"
21+
android:viewportHeight="72">
22+
<path
23+
android:pathData="M0,12C0,5.37 5.37,0 12,0h104c6.63,0 12,5.37 12,12v60H0V12Z"
24+
android:fillColor="?attr/daxColorWindow"/>
25+
<path
26+
android:pathData="M112,36a8,8 0,0 1,8 8v8a8,8 0,0 1,-8 8H16a8,8 0,0 1,-8 -8v-8a8,8 0,0 1,8 -8h96ZM82,12c5.52,0 10,4.48 10,10s-4.48,10 -10,10H46c-5.52,0 -10,-4.48 -10,-10s4.48,-10 10,-10h36Z"
27+
android:fillColor="?attr/daxColorControlFillPrimary"/>
28+
<path
29+
android:pathData="M116,0c6.63,0 12,5.37 12,12v60h-1L127,12c0,-6.07 -4.93,-11 -11,-11L12,1C5.93,1 1,5.93 1,12v60L0,72L0,12C0,5.37 5.37,0 12,0h104ZM112.41,36.01A8,8 0,0 1,120 44v8a8,8 0,0 1,-7.59 7.99L112,60L16,60a8,8 0,0 1,-7.99 -7.59L8,52v-8a8,8 0,0 1,8 -8h96l0.41,0.01ZM16,37a7,7 0,0 0,-7 7v8a7,7 0,0 0,7 7h96a7,7 0,0 0,7 -7v-8a7,7 0,0 0,-7 -7L16,37ZM82,12c5.52,0 10,4.48 10,10 0,5.35 -4.2,9.72 -9.48,9.99L82,32L46,32l-0.51,-0.01C40.2,31.72 36,27.35 36,22c0,-5.52 4.48,-10 10,-10h36ZM46,13a9,9 0,1 0,0 18h36a9,9 0,1 0,0 -18L46,13ZM56,14a8,8 0,1 1,0 16L46,30a8,8 0,1 1,0 -16h10ZM50.25,16a5.25,5.25 0,1 0,3.34 9.3l2.56,2.56 0.08,0.06a0.5,0.5 0,0 0,0.69 -0.69l-0.06,-0.08 -2.55,-2.55A5.25,5.25 0,0 0,50.25 16ZM77,16c3.31,0 6,2.39 6,5.34 0,2.24 -1.55,4.16 -3.74,4.95 -1.42,0.65 -4.91,1.31 -6.9,1.65a0.53,0.53 0,0 1,-0.49 -0.88l0.97,-1.12c0.21,-0.24 0.17,-0.61 -0.07,-0.82C71.68,24.16 71,22.82 71,21.34 71,18.39 73.69,16 77,16ZM77,17c-2.87,0 -5,2.05 -5,4.34 0,1.16 0.53,2.24 1.43,3.04 0.6,0.53 0.78,1.52 0.17,2.22l-0.11,0.12a68.24,68.24 0,0 0,2.32 -0.47c1.3,-0.29 2.43,-0.6 3.04,-0.88l0.04,-0.02 0.04,-0.01c1.87,-0.68 3.08,-2.26 3.08,-4.01C82,19.05 79.87,17 77,17ZM50.25,17a4.25,4.25 0,1 1,0 8.5,4.25 4.25,0 0,1 0,-8.5ZM76.71,18.45c0.07,-0.3 0.5,-0.3 0.57,0l0.16,0.66c0.22,0.88 0.91,1.56 1.78,1.78l0.66,0.16c0.3,0.07 0.3,0.5 0,0.57l-0.66,0.17a2.45,2.45 0,0 0,-1.78 1.78l-0.16,0.66c-0.07,0.3 -0.5,0.3 -0.57,0l-0.17,-0.66a2.45,2.45 0,0 0,-1.78 -1.78l-0.66,-0.17c-0.3,-0.07 -0.3,-0.5 0,-0.57l0.66,-0.17a2.45,2.45 0,0 0,1.78 -1.78l0.17,-0.66Z"
30+
android:fillColor="?attr/daxColorControlDecorationTertiary"/>
31+
</vector>

0 commit comments

Comments
 (0)