-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Duck.Ai/ChatHistory: Add context menu #9760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/karl/duckai-sidebar/re-route
Are you sure you want to change the base?
Changes from all commits
31a8ee8
3165abd
1e45cd0
f45e521
1f24033
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
|
|
||
| package com.duckduckgo.duckchat.impl.history | ||
|
|
||
| import androidx.core.net.toUri | ||
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.duckduckgo.anvil.annotations.ContributesViewModel | ||
|
|
@@ -287,6 +288,20 @@ class ChatHistoryViewModel @Inject constructor( | |
| controls.update { it.copy(mode = Mode.Selecting(emptySet())) } | ||
| } | ||
|
|
||
| fun onChatsProtectionClicked() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: the inNewTab decision here isn't covered, and the fixture is already in place since FakeDuckChatInternal stubs getChatProtectionUrl. two cases worth pinning with the existing navigationEvents pattern: selected tab is a duck.ai chat so we reuse it, and anything else so we open a new one. |
||
| viewModelScope.launch { | ||
| val sourceTab = tabRepository.getSelectedTab() | ||
| val fromChatTab = sourceTab?.url?.let { duckChat.isDuckChatUrl(it.toUri()) } == true | ||
| navigationChannel.trySend( | ||
| NavigationEvent.OpenChatProtection( | ||
| url = duckChat.getChatProtectionUrl(), | ||
| sourceTabId = sourceTab?.tabId, | ||
| inNewTab = !fromChatTab, | ||
| ), | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| fun onSelectionToggled(chatId: String) { | ||
| controls.update { c -> | ||
| val mode = c.mode as? Mode.Selecting ?: return@update c | ||
|
|
@@ -408,6 +423,7 @@ class ChatHistoryViewModel @Inject constructor( | |
|
|
||
| sealed interface NavigationEvent { | ||
| data class OpenChat(val url: String, val sourceTabId: String?) : NavigationEvent | ||
| data class OpenChatProtection(val url: String, val sourceTabId: String?, val inNewTab: Boolean) : NavigationEvent | ||
| data class OpenRename(val chatId: String, val currentTitle: String) : NavigationEvent | ||
| data class ShowDownloadComplete(val fileName: String) : NavigationEvent | ||
| data class ShowBulkDownloadComplete(val count: Int) : NavigationEvent | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24"> | ||
| <path | ||
| android:pathData="M12,2c1.078,0 2.187,0.36 3.125,1.267 0.608,0.588 1.626,1.2 3.042,1.651 0.919,0.294 1.86,0.591 2.557,1.235 0.744,0.688 1.118,1.669 1.224,3.097l0.025,0.389c0.103,1.842 -0.035,4.028 -1.376,6.443l-0.307,0.521c-1.063,1.715 -2.638,3.053 -4.162,3.96C14.626,21.459 13.062,22 11.98,22c-1.083,0 -2.638,-0.543 -4.13,-1.438 -1.514,-0.909 -3.078,-2.247 -4.14,-3.959 -1.733,-2.796 -1.81,-5.306 -1.659,-7.353l0.053,-0.515c0.153,-1.153 0.52,-1.98 1.172,-2.582 0.696,-0.644 1.638,-0.941 2.557,-1.235 1.415,-0.452 2.433,-1.063 3.041,-1.651C9.813,2.359 10.923,2 12,2M12,3.505c-0.726,0 -1.448,0.233 -2.078,0.843 -0.817,0.79 -2.058,1.501 -3.63,2.004 -0.998,0.319 -1.588,0.531 -1.993,0.906 -0.357,0.33 -0.655,0.878 -0.746,2.102v0.001c-0.14,1.884 -0.064,4.03 1.435,6.448h0.001c0.906,1.46 2.272,2.644 3.637,3.463 1.388,0.832 2.664,1.223 3.355,1.223s1.979,-0.392 3.377,-1.224c1.375,-0.82 2.749,-2.002 3.654,-3.462 1.5,-2.418 1.575,-4.563 1.436,-6.449 -0.09,-1.224 -0.388,-1.772 -0.745,-2.102 -0.405,-0.374 -0.996,-0.587 -1.994,-0.906 -1.574,-0.502 -2.814,-1.215 -3.63,-2.004 -0.63,-0.61 -1.352,-0.843 -2.079,-0.843M15.468,8.912c0.29,-0.298 0.767,-0.304 1.064,-0.014s0.304,0.766 0.014,1.064l-5.133,5.271c-0.286,0.294 -0.754,0.305 -1.053,0.025l-2.88,-2.7c-0.304,-0.283 -0.319,-0.759 -0.035,-1.062s0.76,-0.32 1.063,-0.035l2.341,2.193z" | ||
| android:fillColor="?attr/daxColorPrimaryIcon"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- | ||
| ~ Copyright (c) 2026 DuckDuckGo | ||
| ~ | ||
| ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
| ~ you may not use this file except in compliance with the License. | ||
| ~ You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, software | ||
| ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| ~ See the License for the specific language governing permissions and | ||
| ~ limitations under the License. | ||
| --> | ||
|
|
||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:background="@drawable/popup_menu_bg" | ||
| android:orientation="vertical"> | ||
|
|
||
| <com.duckduckgo.common.ui.view.PopupMenuItemView | ||
| android:id="@+id/selectChats" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| app:leadingIcon="@drawable/ic_chevron_circle_down_24" | ||
| app:primaryText="@string/duck_ai_chat_history_overflow_select_chats" /> | ||
|
|
||
| <com.duckduckgo.common.ui.view.PopupMenuItemView | ||
| android:id="@+id/chatsProtection" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| app:leadingIcon="@drawable/ic_shield_check_24" | ||
| app:primaryText="@string/duck_ai_chat_history_overflow_chats_protection" /> | ||
|
|
||
| </LinearLayout> |
Uh oh!
There was an error while loading. Please reload this page.