From 650c1e2872d9c27afbdf3857583c6d889550ef78 Mon Sep 17 00:00:00 2001 From: TaYaKi71751 Date: Thu, 3 Oct 2024 18:13:24 +0900 Subject: [PATCH] Add Use Default Tag on Web --- violet/assets/locale/en.json | 1 + violet/assets/locale/eo.json | 1 + violet/assets/locale/it.json | 1 + violet/assets/locale/ja.json | 1 + violet/assets/locale/ko.json | 1 + violet/assets/locale/pt.json | 1 + violet/assets/locale/zh.json | 1 + violet/assets/locale/zh_Hans.json | 1 + violet/assets/locale/zh_Hant.json | 1 + violet/lib/component/hentai.dart | 3 +- violet/lib/pages/settings/settings_page.dart | 31 ++++++++++++++++++++ violet/lib/settings/settings.dart | 8 +++++ 12 files changed, 50 insertions(+), 1 deletion(-) diff --git a/violet/assets/locale/en.json b/violet/assets/locale/en.json index 897e7ce66..c1e606428 100644 --- a/violet/assets/locale/en.json +++ b/violet/assets/locale/en.json @@ -192,6 +192,7 @@ "maindownload": "Download", "usewebsearch": "Search on Web", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "Use Violet Server", "wouldyouupdate": "Would you update?", "violetservermsg": "Would you like to enable the Violet Server function? This function is a service that collects user behavior information and displays statistical information in real time. We do not collect any information that could identify you.", diff --git a/violet/assets/locale/eo.json b/violet/assets/locale/eo.json index 27b8336f6..0a42a1fd3 100644 --- a/violet/assets/locale/eo.json +++ b/violet/assets/locale/eo.json @@ -192,6 +192,7 @@ "maindownload": "Donwload", "usewebsearch": "Buscar en la Web", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "Usar servidor violet", "wouldyouupdate": "¿Actualizarías?", "violetservermsg": "¿Le gustaría habilitar la función Violet Server? Esta función es un servicio que recopila información sobre el comportamiento del usuario y muestra información estadística en tiempo real. No recopilamos ninguna información que pueda identificarlo.", diff --git a/violet/assets/locale/it.json b/violet/assets/locale/it.json index 2cd9588b8..7e65f8d17 100644 --- a/violet/assets/locale/it.json +++ b/violet/assets/locale/it.json @@ -192,6 +192,7 @@ "maindownload": "Download", "usewebsearch": "Cerca Sul Web", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "Usa Violet Server", "wouldyouupdate": "Aggiorneresti?", "violetservermsg": "Vuoi abilitare la funzione Violet Server? Questa funzione è un servizio che raccoglie informazioni sul comportamento dell'utente e visualizza informazioni statistiche in tempo reale. Non raccogliamo alcuna informazione che possa identificarti.", diff --git a/violet/assets/locale/ja.json b/violet/assets/locale/ja.json index d28790966..0972878f0 100644 --- a/violet/assets/locale/ja.json +++ b/violet/assets/locale/ja.json @@ -192,6 +192,7 @@ "maindownload": "ダウンロード数", "usewebsearch": "ウェブで検索する", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "Violet サーバーを使用する", "wouldyouupdate": "更新しますか?", "violetservermsg": "Violet サーバーの機能を有効にしますか?この機能は、ユーザーの行動情報を収集し、リアルタイムで統計情報を表示するサービスです。ユーザーを特定することができる情報は収集しません。", diff --git a/violet/assets/locale/ko.json b/violet/assets/locale/ko.json index d4f8ff58f..9bdc47528 100644 --- a/violet/assets/locale/ko.json +++ b/violet/assets/locale/ko.json @@ -192,6 +192,7 @@ "maindownload": "다운로드 수", "usewebsearch": "웹에서 검색하기", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "바이올렛 서버 사용하기", "wouldyouupdate": "업데이트할까요? (업데이트가 제대로 진행되지 않는다면, 설정->수동 업데이트를 통해 업데이트 해주세요!)", "violetservermsg": "Violet Server 기능을 활성화하시겠습니까? 이 기능은 사용자 행동 정보을 수집하여 실시간으로 통계 정보를 보여주는 서비스입니다. 사용자를 특정할 수 있는 정보는 수집하지 않습니다.", diff --git a/violet/assets/locale/pt.json b/violet/assets/locale/pt.json index 70fd3ba5a..0c820b9e6 100644 --- a/violet/assets/locale/pt.json +++ b/violet/assets/locale/pt.json @@ -192,6 +192,7 @@ "maindownload": "Download", "usewebsearch": "Pesquisar na Web", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "Usar servido do Violet", "wouldyouupdate": "Você atualizaria?", "violetservermsg": "Deseja habilitar o servidor do Violet? Esta função é um serviço que coleta informações de comportamento do usuário e exibe informações estatísticas em tempo real. Não coletamos nenhuma informação que possa identificá-lo.", diff --git a/violet/assets/locale/zh.json b/violet/assets/locale/zh.json index 4c586b2d5..0af4f5bbc 100644 --- a/violet/assets/locale/zh.json +++ b/violet/assets/locale/zh.json @@ -192,6 +192,7 @@ "maindownload": "Download", "usewebsearch": "Search on Web", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "Use Violet Server", "wouldyouupdate": "Would you update?", "violetservermsg": "Would you like to enable the Violet Server function? This function is a service that collects user behavior information and displays statistical information in real time. We do not collect any information that could identify you.", diff --git a/violet/assets/locale/zh_Hans.json b/violet/assets/locale/zh_Hans.json index bd909793d..35f511ad5 100644 --- a/violet/assets/locale/zh_Hans.json +++ b/violet/assets/locale/zh_Hans.json @@ -192,6 +192,7 @@ "maindownload": "下载", "usewebsearch": "在网路上搜寻", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "使用紫罗兰色服务器", "wouldyouupdate": "你会更新吗?", "violetservermsg": "您要启用Violet服务器功能吗? 此功能是一项收集用户行为信息并实时显示统计信息的服务。 我们不会收集任何可以识别您身份的信息。", diff --git a/violet/assets/locale/zh_Hant.json b/violet/assets/locale/zh_Hant.json index e9d06cae6..d4a7a22d6 100644 --- a/violet/assets/locale/zh_Hant.json +++ b/violet/assets/locale/zh_Hant.json @@ -192,6 +192,7 @@ "maindownload": "Download", "usewebsearch": "Search on Web", "usesearchexpunged": "Search for Expunged", + "includetagnetwork": "Use Default Tag on Web", "usevioletserver": "Use Violet Server", "wouldyouupdate": "Would you update?", "violetservermsg": "Would you like to enable the Violet Server function? This function is a service that collects user behavior information and displays statistical information in real time. We do not collect any information that could identify you.", diff --git a/violet/lib/component/hentai.dart b/violet/lib/component/hentai.dart index a72e16864..a89b46b3f 100644 --- a/violet/lib/component/hentai.dart +++ b/violet/lib/component/hentai.dart @@ -587,7 +587,8 @@ class HentaiManager { static Future> searchEHentai(String what, [int next = 0, bool exh = false]) async { - final search = Uri.encodeComponent(what); + final search = Uri.encodeComponent( + Settings.includeTagNetwork ? '${Settings.includeTags} ${what}' : what); final url = 'https://e${exh ? 'x' : '-'}hentai.org/?${next == 0 ? '' : 'next=$next&'}f_cats=${Settings.searchCategory}&f_search=$search&advsearch=1&f_sname=on&f_stags=on${Settings.searchExpunged ? '&f_sh=on' : ''}&f_spf=&f_spt='; diff --git a/violet/lib/pages/settings/settings_page.dart b/violet/lib/pages/settings/settings_page.dart index b856bc65c..1350da41e 100644 --- a/violet/lib/pages/settings/settings_page.dart +++ b/violet/lib/pages/settings/settings_page.dart @@ -775,6 +775,37 @@ class _SettingsPageState extends State }); }, ), + if (Settings.searchNetwork) + InkWell( + customBorder: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(8.0), + bottomRight: Radius.circular(8.0))), + child: ListTile( + leading: Icon( + MdiIcons.searchWeb, + color: Settings.majorColor, + ), + title: Text(Translations.instance!.trans('includetagnetwork')), + trailing: Switch( + value: Settings.includeTagNetwork, + onChanged: (newValue) async { + await Settings.setIncludeTagOnWeb(newValue); + setState(() { + _shouldReload = true; + }); + }, + activeTrackColor: Settings.majorColor, + activeColor: Settings.majorAccentColor, + ), + ), + onTap: () async { + await Settings.setIncludeTagOnWeb(!Settings.includeTagNetwork); + setState(() { + _shouldReload = true; + }); + }, + ), if (Settings.searchNetwork) InkWell( customBorder: const RoundedRectangleBorder( diff --git a/violet/lib/settings/settings.dart b/violet/lib/settings/settings.dart index 2c40e8ead..71d155d73 100644 --- a/violet/lib/settings/settings.dart +++ b/violet/lib/settings/settings.dart @@ -51,6 +51,7 @@ class Settings { static late List routingRule; // image routing rule static late List searchRule; static late bool searchNetwork; + static late bool includeTagNetwork; static late bool searchExpunged; static late int searchCategory; @@ -198,6 +199,7 @@ class Settings { (await _getString('searchrule', 'Hitomi|EHentai|ExHentai|NHentai')) .split('|'); searchNetwork = await _getBool('searchnetwork'); + includeTagNetwork = await _getBool('includetagnetwork'); searchExpunged = await _getBool('searchexpunged'); searchCategory = await _getInt('searchcategory', 993); @@ -687,6 +689,12 @@ class Settings { await prefs.setBool('searchnetwork', nn); } + static Future setIncludeTagOnWeb(bool nn) async { + includeTagNetwork = nn; + + await prefs.setBool('includetagnetwork', nn); + } + static Future setSearchExpunged(bool nn) async { searchExpunged = nn;