From 641de54feaf5e2c0cce2ed5ac8baa7bcfa9bfe90 Mon Sep 17 00:00:00 2001 From: TaYaKi71751 Date: Wed, 23 Oct 2024 22:24:36 +0900 Subject: [PATCH] Add Use Excluded Tags 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 | 2 +- violet/lib/pages/settings/settings_page.dart | 31 ++++++++++++++++++++ violet/lib/settings/settings.dart | 8 +++++ 12 files changed, 49 insertions(+), 1 deletion(-) diff --git a/violet/assets/locale/en.json b/violet/assets/locale/en.json index c1e606428..78d1f2ec4 100644 --- a/violet/assets/locale/en.json +++ b/violet/assets/locale/en.json @@ -193,6 +193,7 @@ "usewebsearch": "Search on Web", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded 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 0a42a1fd3..2b0cb6349 100644 --- a/violet/assets/locale/eo.json +++ b/violet/assets/locale/eo.json @@ -193,6 +193,7 @@ "usewebsearch": "Buscar en la Web", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded 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 7e65f8d17..f12669ae6 100644 --- a/violet/assets/locale/it.json +++ b/violet/assets/locale/it.json @@ -193,6 +193,7 @@ "usewebsearch": "Cerca Sul Web", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded 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 0972878f0..2d8a7281b 100644 --- a/violet/assets/locale/ja.json +++ b/violet/assets/locale/ja.json @@ -193,6 +193,7 @@ "usewebsearch": "ウェブで検索する", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded Tag on Web", "usevioletserver": "Violet サーバーを使用する", "wouldyouupdate": "更新しますか?", "violetservermsg": "Violet サーバーの機能を有効にしますか?この機能は、ユーザーの行動情報を収集し、リアルタイムで統計情報を表示するサービスです。ユーザーを特定することができる情報は収集しません。", diff --git a/violet/assets/locale/ko.json b/violet/assets/locale/ko.json index 9bdc47528..4a54c948e 100644 --- a/violet/assets/locale/ko.json +++ b/violet/assets/locale/ko.json @@ -193,6 +193,7 @@ "usewebsearch": "웹에서 검색하기", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded Tag on Web", "usevioletserver": "바이올렛 서버 사용하기", "wouldyouupdate": "업데이트할까요? (업데이트가 제대로 진행되지 않는다면, 설정->수동 업데이트를 통해 업데이트 해주세요!)", "violetservermsg": "Violet Server 기능을 활성화하시겠습니까? 이 기능은 사용자 행동 정보을 수집하여 실시간으로 통계 정보를 보여주는 서비스입니다. 사용자를 특정할 수 있는 정보는 수집하지 않습니다.", diff --git a/violet/assets/locale/pt.json b/violet/assets/locale/pt.json index 0c820b9e6..7283fd91e 100644 --- a/violet/assets/locale/pt.json +++ b/violet/assets/locale/pt.json @@ -193,6 +193,7 @@ "usewebsearch": "Pesquisar na Web", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded 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 0af4f5bbc..1bf267a2a 100644 --- a/violet/assets/locale/zh.json +++ b/violet/assets/locale/zh.json @@ -193,6 +193,7 @@ "usewebsearch": "Search on Web", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded 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 35f511ad5..5728defa6 100644 --- a/violet/assets/locale/zh_Hans.json +++ b/violet/assets/locale/zh_Hans.json @@ -193,6 +193,7 @@ "usewebsearch": "在网路上搜寻", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded Tag on Web", "usevioletserver": "使用紫罗兰色服务器", "wouldyouupdate": "你会更新吗?", "violetservermsg": "您要启用Violet服务器功能吗? 此功能是一项收集用户行为信息并实时显示统计信息的服务。 我们不会收集任何可以识别您身份的信息。", diff --git a/violet/assets/locale/zh_Hant.json b/violet/assets/locale/zh_Hant.json index d4a7a22d6..56cb09b12 100644 --- a/violet/assets/locale/zh_Hant.json +++ b/violet/assets/locale/zh_Hant.json @@ -193,6 +193,7 @@ "usewebsearch": "Search on Web", "usesearchexpunged": "Search for Expunged", "includetagnetwork": "Use Default Tag on Web", + "excludetagnetwork": "Use Excluded 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 a89b46b3f..3746972fe 100644 --- a/violet/lib/component/hentai.dart +++ b/violet/lib/component/hentai.dart @@ -588,7 +588,7 @@ class HentaiManager { static Future> searchEHentai(String what, [int next = 0, bool exh = false]) async { final search = Uri.encodeComponent( - Settings.includeTagNetwork ? '${Settings.includeTags} ${what}' : what); + '${Settings.includeTagNetwork ? '${Settings.includeTags} ' : ''}$what${Settings.excludeTagNetwork ? ' ${Settings.excludeTags.where((e) => e.trim() != '').map((e) => '-$e').join(' ').trim()}' : ''}'); 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 7a2404136..0164b2944 100644 --- a/violet/lib/pages/settings/settings_page.dart +++ b/violet/lib/pages/settings/settings_page.dart @@ -806,6 +806,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('excludetagnetwork')), + trailing: Switch( + value: Settings.excludeTagNetwork, + onChanged: (newValue) async { + await Settings.setExcludeTagOnWeb(newValue); + setState(() { + _shouldReload = true; + }); + }, + activeTrackColor: Settings.majorColor, + activeColor: Settings.majorAccentColor, + ), + ), + onTap: () async { + await Settings.setExcludeTagOnWeb(!Settings.excludeTagNetwork); + 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 cd2924a33..2aa1b0144 100644 --- a/violet/lib/settings/settings.dart +++ b/violet/lib/settings/settings.dart @@ -52,6 +52,7 @@ class Settings { static late List searchRule; static late bool searchNetwork; static late bool includeTagNetwork; + static late bool excludeTagNetwork; static late bool searchExpunged; static late int searchCategory; @@ -200,6 +201,7 @@ class Settings { .split('|'); searchNetwork = await _getBool('searchnetwork'); includeTagNetwork = await _getBool('includetagnetwork'); + excludeTagNetwork = await _getBool('excludetagnetwork'); searchExpunged = await _getBool('searchexpunged'); searchCategory = await _getInt('searchcategory', 993); @@ -703,6 +705,12 @@ class Settings { await prefs.setBool('includetagnetwork', nn); } + static Future setExcludeTagOnWeb(bool nn) async { + excludeTagNetwork = nn; + + await prefs.setBool('excludetagnetwork', nn); + } + static Future setSearchExpunged(bool nn) async { searchExpunged = nn;