From 8ffcf136f875188d760dd568e0c15cacfcd72bf1 Mon Sep 17 00:00:00 2001 From: rainxchzed Date: Sun, 1 Mar 2026 15:11:56 +0500 Subject: [PATCH] feat(search): Implement automatic GitHub link detection from clipboard This commit introduces a feature that automatically detects GitHub links in the clipboard when opening the search screen. It includes the necessary logic to monitor the clipboard setting and UI strings for multiple languages. - **feat(search)**: Updated `SearchViewModel` to observe the `autoDetectClipboardLinks` setting. When enabled, it triggers a clipboard check and updates the state with detected links and banner visibility; when disabled, it clears detected links and hides the banner. - **i18n**: Added string resources for clipboard detection features (e.g., "Open GitHub link", "Clipboard link detected", "Auto detect clipboard links") across multiple locales including Turkish, Spanish, Chinese, French, Hindi, Italian, Japanese, Korean, Polish, Bengali, and Russian. --- .../composeResources/values-bn/strings-bn.xml | 8 ++++++++ .../composeResources/values-es/strings-es.xml | 8 ++++++++ .../composeResources/values-fr/strings-fr.xml | 8 ++++++++ .../composeResources/values-hi/strings-hi.xml | 8 ++++++++ .../composeResources/values-it/strings-it.xml | 8 ++++++++ .../composeResources/values-ja/strings-ja.xml | 8 ++++++++ .../composeResources/values-kr/strings-kr.xml | 8 ++++++++ .../composeResources/values-pl/strings-pl.xml | 8 ++++++++ .../composeResources/values-ru/strings-ru.xml | 8 ++++++++ .../composeResources/values-tr/strings-tr.xml | 8 ++++++++ .../composeResources/values-zh-rCN/strings-zh-rCN.xml | 8 ++++++++ .../zed/rainxch/search/presentation/SearchViewModel.kt | 10 +++++++++- 12 files changed, 97 insertions(+), 1 deletion(-) diff --git a/core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml b/core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml index 3a263b24..f8d2d45f 100644 --- a/core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml +++ b/core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml @@ -438,4 +438,12 @@ ভাষা পরিবর্তন করুন অনুবাদ ব্যর্থ হয়েছে। আবার চেষ্টা করুন। + GitHub লিংক খুলুন + ক্লিপবোর্ডে GitHub লিংক পাওয়া গেছে + ক্লিপবোর্ড লিংক স্বয়ংক্রিয় সনাক্তকরণ + অনুসন্ধান খোলার সময় স্বয়ংক্রিয়ভাবে ক্লিপবোর্ড থেকে GitHub লিংক সনাক্ত করুন + সনাক্তকৃত লিংক + অ্যাপে খুলুন + ক্লিপবোর্ডে কোনো GitHub লিংক পাওয়া যায়নি + diff --git a/core/presentation/src/commonMain/composeResources/values-es/strings-es.xml b/core/presentation/src/commonMain/composeResources/values-es/strings-es.xml index ff4a3ecd..0016f087 100644 --- a/core/presentation/src/commonMain/composeResources/values-es/strings-es.xml +++ b/core/presentation/src/commonMain/composeResources/values-es/strings-es.xml @@ -403,4 +403,12 @@ Cambiar idioma Error de traducción. Inténtalo de nuevo. + Abrir enlace de GitHub + Enlace de GitHub detectado en el portapapeles + Detectar enlaces del portapapeles + Detectar automáticamente enlaces de GitHub del portapapeles al abrir la búsqueda + Enlaces detectados + Abrir en la app + No se encontró enlace de GitHub en el portapapeles + \ No newline at end of file diff --git a/core/presentation/src/commonMain/composeResources/values-fr/strings-fr.xml b/core/presentation/src/commonMain/composeResources/values-fr/strings-fr.xml index 9ad125cb..01f8ddbc 100644 --- a/core/presentation/src/commonMain/composeResources/values-fr/strings-fr.xml +++ b/core/presentation/src/commonMain/composeResources/values-fr/strings-fr.xml @@ -403,4 +403,12 @@ Changer de langue Échec de la traduction. Veuillez réessayer. + Ouvrir le lien GitHub + Lien GitHub détecté dans le presse-papiers + Détecter les liens du presse-papiers + Détecter automatiquement les liens GitHub du presse-papiers lors de l\'ouverture de la recherche + Liens détectés + Ouvrir dans l\'app + Aucun lien GitHub trouvé dans le presse-papiers + \ No newline at end of file diff --git a/core/presentation/src/commonMain/composeResources/values-hi/strings-hi.xml b/core/presentation/src/commonMain/composeResources/values-hi/strings-hi.xml index d057f3bf..3a9f9f7a 100644 --- a/core/presentation/src/commonMain/composeResources/values-hi/strings-hi.xml +++ b/core/presentation/src/commonMain/composeResources/values-hi/strings-hi.xml @@ -438,4 +438,12 @@ भाषा बदलें अनुवाद विफल। कृपया पुनः प्रयास करें। + GitHub लिंक खोलें + क्लिपबोर्ड में GitHub लिंक मिला + क्लिपबोर्ड लिंक स्वतः पहचानें + खोज खोलते समय क्लिपबोर्ड से GitHub लिंक स्वचालित रूप से पहचानें + पहचाने गए लिंक + ऐप में खोलें + क्लिपबोर्ड में कोई GitHub लिंक नहीं मिला + diff --git a/core/presentation/src/commonMain/composeResources/values-it/strings-it.xml b/core/presentation/src/commonMain/composeResources/values-it/strings-it.xml index 3f4059ee..6c5a487b 100644 --- a/core/presentation/src/commonMain/composeResources/values-it/strings-it.xml +++ b/core/presentation/src/commonMain/composeResources/values-it/strings-it.xml @@ -439,4 +439,12 @@ Cambia lingua Traduzione fallita. Riprova. + Apri link GitHub + Link GitHub rilevato negli appunti + Rileva link dagli appunti + Rileva automaticamente i link GitHub dagli appunti all\'apertura della ricerca + Link rilevati + Apri nell\'app + Nessun link GitHub trovato negli appunti + \ No newline at end of file diff --git a/core/presentation/src/commonMain/composeResources/values-ja/strings-ja.xml b/core/presentation/src/commonMain/composeResources/values-ja/strings-ja.xml index ccddf4ac..b42ad892 100644 --- a/core/presentation/src/commonMain/composeResources/values-ja/strings-ja.xml +++ b/core/presentation/src/commonMain/composeResources/values-ja/strings-ja.xml @@ -402,4 +402,12 @@ 言語を変更 翻訳に失敗しました。もう一度お試しください。 + GitHubリンクを開く + クリップボードにGitHubリンクを検出 + クリップボードリンクの自動検出 + 検索画面を開く際にクリップボードからGitHubリンクを自動検出 + 検出されたリンク + アプリで開く + クリップボードにGitHubリンクが見つかりません + \ No newline at end of file diff --git a/core/presentation/src/commonMain/composeResources/values-kr/strings-kr.xml b/core/presentation/src/commonMain/composeResources/values-kr/strings-kr.xml index 698ef35c..e1772daf 100644 --- a/core/presentation/src/commonMain/composeResources/values-kr/strings-kr.xml +++ b/core/presentation/src/commonMain/composeResources/values-kr/strings-kr.xml @@ -435,4 +435,12 @@ 언어 변경 번역 실패. 다시 시도해주세요. + GitHub 링크 열기 + 클립보드에서 GitHub 링크 감지됨 + 클립보드 링크 자동 감지 + 검색을 열 때 클립보드에서 GitHub 링크를 자동으로 감지 + 감지된 링크 + 앱에서 열기 + 클립보드에서 GitHub 링크를 찾을 수 없습니다 + \ No newline at end of file diff --git a/core/presentation/src/commonMain/composeResources/values-pl/strings-pl.xml b/core/presentation/src/commonMain/composeResources/values-pl/strings-pl.xml index 8b00e022..7dc49d66 100644 --- a/core/presentation/src/commonMain/composeResources/values-pl/strings-pl.xml +++ b/core/presentation/src/commonMain/composeResources/values-pl/strings-pl.xml @@ -401,4 +401,12 @@ Zmień język Tłumaczenie nie powiodło się. Spróbuj ponownie. + Otwórz link GitHub + Wykryto link GitHub w schowku + Automatyczne wykrywanie linków ze schowka + Automatycznie wykrywaj linki GitHub ze schowka przy otwieraniu wyszukiwania + Wykryte linki + Otwórz w aplikacji + Nie znaleziono linku GitHub w schowku + \ No newline at end of file diff --git a/core/presentation/src/commonMain/composeResources/values-ru/strings-ru.xml b/core/presentation/src/commonMain/composeResources/values-ru/strings-ru.xml index de2286c3..67510cb3 100644 --- a/core/presentation/src/commonMain/composeResources/values-ru/strings-ru.xml +++ b/core/presentation/src/commonMain/composeResources/values-ru/strings-ru.xml @@ -403,4 +403,12 @@ Изменить язык Ошибка перевода. Попробуйте ещё раз. + Открыть ссылку GitHub + Обнаружена ссылка GitHub в буфере обмена + Автоопределение ссылок из буфера + Автоматически определять ссылки GitHub из буфера обмена при открытии поиска + Обнаруженные ссылки + Открыть в приложении + Ссылка GitHub не найдена в буфере обмена + \ No newline at end of file diff --git a/core/presentation/src/commonMain/composeResources/values-tr/strings-tr.xml b/core/presentation/src/commonMain/composeResources/values-tr/strings-tr.xml index d28b936c..bd51cdb8 100644 --- a/core/presentation/src/commonMain/composeResources/values-tr/strings-tr.xml +++ b/core/presentation/src/commonMain/composeResources/values-tr/strings-tr.xml @@ -435,4 +435,12 @@ Dili değiştir Çeviri başarısız. Lütfen tekrar deneyin. + GitHub bağlantısını aç + Panoda GitHub bağlantısı algılandı + Pano bağlantılarını otomatik algıla + Arama açılırken panodan GitHub bağlantılarını otomatik olarak algıla + Algılanan bağlantılar + Uygulamada aç + Panoda GitHub bağlantısı bulunamadı + diff --git a/core/presentation/src/commonMain/composeResources/values-zh-rCN/strings-zh-rCN.xml b/core/presentation/src/commonMain/composeResources/values-zh-rCN/strings-zh-rCN.xml index a57fd916..d2185ad7 100644 --- a/core/presentation/src/commonMain/composeResources/values-zh-rCN/strings-zh-rCN.xml +++ b/core/presentation/src/commonMain/composeResources/values-zh-rCN/strings-zh-rCN.xml @@ -403,4 +403,12 @@ 更改语言 翻译失败,请重试。 + 打开 GitHub 链接 + 在剪贴板中检测到 GitHub 链接 + 自动检测剪贴板链接 + 打开搜索时自动检测剪贴板中的 GitHub 链接 + 检测到的链接 + 在应用中打开 + 剪贴板中未找到 GitHub 链接 + \ No newline at end of file diff --git a/feature/search/presentation/src/commonMain/kotlin/zed/rainxch/search/presentation/SearchViewModel.kt b/feature/search/presentation/src/commonMain/kotlin/zed/rainxch/search/presentation/SearchViewModel.kt index 94119696..0761c67a 100644 --- a/feature/search/presentation/src/commonMain/kotlin/zed/rainxch/search/presentation/SearchViewModel.kt +++ b/feature/search/presentation/src/commonMain/kotlin/zed/rainxch/search/presentation/SearchViewModel.kt @@ -94,7 +94,15 @@ class SearchViewModel( private fun observeClipboardSetting() { viewModelScope.launch { themesRepository.getAutoDetectClipboardLinks().collect { enabled -> - _state.update { it.copy(autoDetectClipboardEnabled = enabled) } + _state.update { current -> + current.copy( + autoDetectClipboardEnabled = enabled, + clipboardLinks = if (enabled) current.clipboardLinks else emptyList(), + isClipboardBannerVisible = if (enabled) current.isClipboardBannerVisible else false + ) + } + if (enabled) checkClipboardForLinks() + } } }