From 9221f64dbc58883612365400cfac084393048423 Mon Sep 17 00:00:00 2001 From: TrianguloY Date: Thu, 24 Oct 2024 18:28:00 +0200 Subject: [PATCH] migrate status module autoCheck to automation --- .../modules/companions/VersionManager.java | 33 +++++++++++++++++-- .../urlchecker/modules/list/StatusModule.java | 13 -------- app/src/main/res/layout/config_status.xml | 18 ---------- app/src/main/res/values-ar/strings.xml | 1 - app/src/main/res/values-cs/strings.xml | 1 - app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-fr-rFR/strings.xml | 1 - app/src/main/res/values-hi/strings.xml | 1 - app/src/main/res/values-in/strings.xml | 1 - app/src/main/res/values-ko/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 1 - app/src/main/res/values-pt-rBR/strings.xml | 1 - app/src/main/res/values-pt-rPT/strings.xml | 1 - app/src/main/res/values-ru/strings.xml | 1 - app/src/main/res/values-sr/strings.xml | 1 - app/src/main/res/values-tr/strings.xml | 1 - app/src/main/res/values-vi/strings.xml | 1 - app/src/main/res/values-zh-rCN/strings.xml | 1 - app/src/main/res/values-zh-rTW/strings.xml | 1 - app/src/main/res/values/strings.xml | 1 - 21 files changed, 31 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/com/trianguloy/urlchecker/modules/companions/VersionManager.java b/app/src/main/java/com/trianguloy/urlchecker/modules/companions/VersionManager.java index 2b29de41..9770142f 100644 --- a/app/src/main/java/com/trianguloy/urlchecker/modules/companions/VersionManager.java +++ b/app/src/main/java/com/trianguloy/urlchecker/modules/companions/VersionManager.java @@ -1,10 +1,16 @@ package com.trianguloy.urlchecker.modules.companions; +import android.app.Activity; import android.content.Context; import com.trianguloy.urlchecker.BuildConfig; +import com.trianguloy.urlchecker.R; import com.trianguloy.urlchecker.activities.TutorialActivity; +import com.trianguloy.urlchecker.modules.AutomationRules; import com.trianguloy.urlchecker.utilities.generics.GenericPref; +import com.trianguloy.urlchecker.utilities.methods.AndroidUtils; + +import org.json.JSONObject; import java.util.ArrayList; import java.util.Collections; @@ -27,7 +33,7 @@ public static GenericPref.Str LASTVERSION_PREF(Context cntx) { /** * Check if the version must be updated */ - public static void check(Context cntx) { + public static void check(Activity cntx) { // just call the constructor, it does the check new VersionManager(cntx); } @@ -60,7 +66,7 @@ public static boolean isVersionNewer(String version) { /* ------------------- instance ------------------- */ - public VersionManager(Context cntx) { + public VersionManager(Activity cntx) { lastVersion = LASTVERSION_PREF(cntx); if (lastVersion.get() == null) { // no previous setting, the app is a new install, mark as seen @@ -69,6 +75,29 @@ public VersionManager(Context cntx) { if (TutorialActivity.DONE(cntx).get()) lastVersion.set("<2.12"); else markSeen(); } + + // --- run migrations --- // + var prefs = GenericPref.getPrefs(cntx); + + // status module auto-check -> automation + try { + var regex = prefs.getString("statusCode_autoCheck", ""); + if (!regex.isEmpty()) { + var automationRules = new AutomationRules(cntx); + var catalog = automationRules.getCatalog(); + var name = cntx.getString(R.string.mStatus_check); + if (!catalog.has(name)) { + catalog.put(name, new JSONObject() + .put("regex", regex) + .put("action", "checkStatus") + ); + } + automationRules.save(catalog); + prefs.edit().remove("statusCode_autoCheck").apply(); + } + } catch (Exception e) { + AndroidUtils.assertError("Unable to migrate statusCode_autoCheck to automation", e); + } } /** diff --git a/app/src/main/java/com/trianguloy/urlchecker/modules/list/StatusModule.java b/app/src/main/java/com/trianguloy/urlchecker/modules/list/StatusModule.java index 9a6d0c9a..533ee237 100644 --- a/app/src/main/java/com/trianguloy/urlchecker/modules/list/StatusModule.java +++ b/app/src/main/java/com/trianguloy/urlchecker/modules/list/StatusModule.java @@ -35,11 +35,6 @@ public static GenericPref.Bool AUTOREDIR_PREF(Context cntx) { return new GenericPref.Bool("statusCode_autoRedir", false, cntx); } - public static GenericPref.Str AUTOCHECK_PREF(Context cntx) { - return new GenericPref.Str("statusCode_autoCheck", "", cntx); - } - - @Override public String getId() { return "statusCode"; @@ -80,7 +75,6 @@ public int getLayoutId() { @Override public void onInitialize(View views) { StatusModule.AUTOREDIR_PREF(getActivity()).attachToSwitch(views.findViewById(R.id.autoredirect)); - StatusModule.AUTOCHECK_PREF(getActivity()).attachToEditText(views.findViewById(R.id.autoCheck)); } } @@ -100,7 +94,6 @@ class StatusDialog extends AModuleDialog { private Thread thread = null; private GenericPref.Bool autoRedir; - private GenericPref.Str autoCheck; public StatusDialog(MainDialog dialog) { super(dialog); @@ -127,7 +120,6 @@ public void onInitialize(View views) { redirect = views.findViewById(R.id.redirect); autoRedir = StatusModule.AUTOREDIR_PREF(getActivity()); - autoCheck = StatusModule.AUTOCHECK_PREF(getActivity()); } @Override @@ -147,11 +139,6 @@ public void onDisplayUrl(UrlData urlData) { AndroidUtils.setHideableText(previous, urlData.getData(PREVIOUS)); AndroidUtils.setHideableText(info, null); updateRedirect(null); - - if (urlData.url.matches(autoCheck.get())) { - // autocheck - check(urlData.disableUpdates); - } } /** diff --git a/app/src/main/res/layout/config_status.xml b/app/src/main/res/layout/config_status.xml index 4bc9ddc7..5edefe7d 100644 --- a/app/src/main/res/layout/config_status.xml +++ b/app/src/main/res/layout/config_status.xml @@ -20,22 +20,4 @@ android:layout_height="wrap_content" android:text="@string/mStatus_autoRedirect" /> - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 3338b03e..a66c6257 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -193,7 +193,6 @@ تبديل وضع التصفح الخفي (Firefox فقط) كود الحالة من خلال الضغط على زر التحقق، سيتم إجراء طلب شبكة لاسترجاع وعرض كود حالة الموقع. إذا كانت النتيجة توجيهًا، فستتمكن من عرض عنوان URL النهائي. يتم الحصول على محتوى عنوان URL (GET)، ولكن لا يتم تقييمه، لذلك لن يتم اكتشاف التوجيهات استنادًا إلى JavaScript. - التحقق التلقائي من عناوين URL التي تتطابق مع نمط التعبير النمطي التالي. تحذير! من المستحسن تحديد نمط مقيد (وليس .* للجميع) وإلا فقد تقوم السيرفرات الخبيثة بتسجيل عنوان IP الخاص بك. عند تمكين هذه الوحدة، يمكنك فحص عنوان الويب باستخدام VirusTotal والتحقق من التقرير. يلزم وجود مفتاح API الخاص بـ VirusTotal الشخصي لعمله، يمكنك الحصول على واحد بعد التسجيل للحصول على حساب مجاني هنا: https://www.virustotal.com/gui/join-us . إذا قمت بإعادة ترتيب الوحدات، سيتم وضع الجديدة التي يتم إضافتها في التحديثات المستقبلية فوق هذه الوحدة. \n diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 9c349d98..55828e74 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -93,7 +93,6 @@ %d: Neznámý stavový kód Přesměrovává na %s Automaticky nahrazovat adresy přesměrování - Automaticky kontrolovat adresy URL, které odpovídají následujícímu vzoru regulárních výrazů. Varování! Doporučuje se zadat omezující vzor (a ne .* pro všechno), jinak by škodlivé servery mohly zaznamenat vaši IP. Vstupní text Zobrazuje aktuální adresu URL, kterou lze ručně upravit. API klíč diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 07f60015..04de34db 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -223,7 +223,6 @@ \n- Öffnen-Button: Tippen Sie auf den Namen der App um den Link in dieser zu öffnen. Wenn ein Link mit mehreren Apps geöffnet werden kann, wird ein Pfeil zur Auswahl angezeigt. \n- Kopieren-Button: Tippen Sie auf diesen Button um den Link zu kopieren. \n- Teilen-Button: Tippen Sie auf diesen Button um den Link zu teilen. - URLs, die diesem Muster entsprechen, automatisch prüfen. Warnung! Es ist ratsam ein restriktives Muster zu benutzen (nicht .* für alle Links), da sonst böswillige Server Ihre IP-Adresse loggen könnten. Abbrechen Scan läuft… Wenn eine URL verändert wird (manuell oder von anderen Modulen), können Sie hiermit Änderungen sehen und rückgängig machen. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9c89a0e6..2fb7e490 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -208,7 +208,6 @@ Hay algunos enlaces cuyo único propósito es redirigirte a otro enlace. Si el e %d: Código de error desconocido Redirige a %s Sustituir automáticamente las URL de redireccionamiento - Verifica automáticamente las URL que coincidan con el siguiente patrón de expresiones regulares. ¡Advertencia! Se recomienda especificar un patrón restrictivo (y no .* para todos), de lo contrario, los servidores maliciosos pueden registrar tu IP. Texto de entrada Muestra la URL actual. Pulsa para editarla. diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index a0d1f370..4b6d9e66 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -180,7 +180,6 @@ Ceci est le didacticiel, si vous souhaitez l'ignorer vous pouvez le faire en uti %d: Code d\'état inconnu Redirige vers %s Remplacer automatiquement les URLs de redirection - Vérifie automatiquement les URLs qui correspondent au modèle d\'expression régulière suivant. Avertissement ! Il est conseillé de spécifier un modèle restrictif (et non .* pour tous) sinon des serveurs malveillants pourraient enregistrer votre adresse IP. Texte d\'entrée Affiche l\'URL actuel. Appuyez dessus pour passer en mode édition. diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index 05580cd5..9021c627 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -167,7 +167,6 @@ होस्ट डेटाबेस प्रारंभ नहीं किया गया। बनाने के लिए दबाएँ सहेजा जा रहा है… सभी हटाएं - निम्नलिखित regex पैटर्न से मेल खाने वाले यूआरएल को स्वचालित रूप से जांचें। चेतावनी! यह सलाह दी जाती है कि एक प्रतिबंधात्मक पैटर्न निर्दिष्ट करें (और सभी के लिए .* नहीं) अन्यथा दुर्भावनापूर्ण सर्वर आपके आईपी को लॉग कर सकते हैं। कोई डेटा नहीं कोई लेबल नहीं खाली हटाएँ diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index a5c4228c..fe846015 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -88,7 +88,6 @@ Kode status Tutup kotak dialog setelah membagikan tautan Katalog bawaan disalin dari ClearURLs: https://docs.clearurls.xyz/latest/specs/rules/ - Cek secara otomatis kecocokan URL berdasarkan pola regex berikut. Peringatan! Disarankan untuk menentukan sebuah pola yang restriktif (bukan .* untuk semuanya), jika tidak, server yang berbahaya dapat merekam IP Anda. Kembali Tersembunyi Modul ini bertugas untuk mengecek url menggunakan pola regex yang akan memberi peringatan, saran ataupun menerapkan perubahan tertentu. Anda bisa membuat atau memodifikasi pola milik Anda sendiri, atau bahkan menggunakan pola dari pengguna lain. diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index e0e0bc8f..33bb25db 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -121,6 +121,5 @@ 자동으로 리다이렉트 URL로 교체하기 \'확인하기\' 버튼을 누르면 사이트의 상태 코드를 받아와 표시하기 위해 네트워크 요청이 이루어집니다. 결과가 리다이렉션이라면 도착 URL을 볼 수 있습니다. 만약 URL에서 정보를 받아오기눈 하지만, 실행되지는 않기에 JavaScript 기반 동적 리다이렉션은 감지되지 않습니다. 확인 중… - 다음의 정규식 패턴에 맞는 URL을 자동으로 확인합니다. 주의! (.*가 아닌) 제한적인 패턴을 사용하는 것이 권장됩니다. 그렇지 않다면 악의적인 서버는 당신의 IP를 기록할 수 있습니다. 익명 모드: \ No newline at end of file diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index e731837f..e34ef892 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -61,7 +61,6 @@ Dialoogvenster sluiten na delen Links openen in deze app: Android heeft in de loop der jaren de manier veranderd waarop het wordt geconfigureerd en verschilt per versie. Hieronder vindt u alle beschikbare instellingen voor uw apparaat. Als er geen links worden geopend in deze app, probeer ze dan allemaal. Ingebouwde catalogus gekopieerd van ClearURLs: https://docs.clearurls.xyz/latest/specs/rules/ - Controleer automatisch URL\'s die overeenkomen met het volgende regex-patroon. Waarschuwing! Het wordt aanbevolen om een beperkend patroon op te geven (en niet .* voor alles), anders kunnen kwaadwillende servers uw IP-adres registreren. Terug Verborgen Deze module controleert de url met regex-patronen die vervangingen waarschuwen, voorstellen of toepassen. U kunt uw eigen patronen wijzigen of creëren, of zelfs door de gebruiker gemaakte patronen gebruiken. diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index d13581e8..be6470b2 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -132,7 +132,6 @@ [Função Beta] Este é um editor avançado, o conteúdo deve ser formatado em JSON válido. Você pode pressionar o botão no canto superior direito para formatá-lo e validá-lo. Esquema HTTPS ausente. Não há padrões correspondentes. - Verifique automaticamente as URLs que correspondem ao seguinte padrão de expressão regular. Aviso! É aconselhável especificar um padrão restritivo (e não .* para todos) caso contrário, servidores mal-intencionados podem registrar seu endereço IP. Substituir as URLs de redirecionamento automaticamente Scanner de URL Mostra a URL atual, que pode ser editada manualmente. diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 7cf05a27..0818d931 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -308,7 +308,6 @@ Para desabilitar o log, basta desabilitar o módulo." Descartar Verificar ligação da área de transferência Substituir as URLs de redirecionamento automaticamente - Verifique automaticamente as URLs que correspondem ao seguinte padrão de expressão regular. Aviso! É aconselhável especificar um padrão restritivo (e não .* para todos) caso contrário, servidores mal-intencionados podem registar o seu endereço IP. (vazio) Novidades Modo anônimo: diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 28a1d97e..2bdcdf8c 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -107,7 +107,6 @@ Код состояния Закрыть диалоговое окно после того как поделились ссылкой Встроенный каталог скопирован с ClearURLs: https://docs.clearurls.xyz/latest/specs/rules/ - Автоматически проверять URL-адреса которые соответствуют следующему шаблону, заданным регулярным выражением. Внимание! Рекомендуется указать ограничивающий шаблон (а не .* для всех), потому что в ином случае вредоносные сервера могут сохранять ваш IP адрес. - найден бесполезный параметр Этот модуль проверяет URL при помощи регулярных выражений которые могут предупреждать, предлагать или применять изменения. Вы можете модифицировать шаблоны или создавать свои собственные, или даже использовать созданные пользователями шаблоны. \nВстроенные шаблоны включают в себя: diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 3dc95b3c..7a7c463a 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -241,7 +241,6 @@ Proveri %d: Nepoznat statusni kod Preusmerava na %s - Automatski proverite URL adrese koje odgovaraju sledećem regex šablonu . Upozorenje! Savetuje se da navedete restriktivni šablon (a ne .* za sve) u suprotnom zlonamerni serveri mogu da evidentiraju vašu IP adresu. Kada je ovaj modul omogućen, možete skenirati URL koristeći VirusTotal i proveriti izveštaj. Lični VirusTotal API ključ je potreban da bi funkcionisao, možete ga dobiti nakon registracije za besplatni nalog ovde: https://vvv.virustotal.com/gui/join-us. Nedostaje API ključ VirusTotal™ je zaštitni znak kompanije Google, Inc. diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index dab49e43..e33884be 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -181,7 +181,6 @@ Not: kalıpları düzenlerseniz, uygulama güncellemelerinden yeni yerleşik kal %d: Bilinmeyen durum kodu Yönlendirme: %s Yönlendirme URL\'lerini otomatik olarak değiştir - Aşağıdaki normal ifade kalıbıyla eşleşen URL\'leri otomatik olarak kontrol edin. Dikkat! Kısıtlayıcı bir model belirtmeniz önerilir (tümü için *. değil), aksi takdirde kötü niyetli sunucular IP\'nizi günlüğe kaydedebilir. Giriş metni Elle düzenlenebilen geçerli URL\'yi görüntüler. diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index a3f4ec73..c4d89a97 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -208,7 +208,6 @@ Chuyển hướng đến %s Tự động thay thế các URL chuyển hướng Bằng cách nhấn nút kiểm tra, yêu cầu mạng sẽ được thực hiện để truy xuất và hiển thị mã trạng thái trang web. Nếu kết quả là chuyển hướng, bạn sẽ có thể xem URL đích. Nội dung URL được lấy (GET) nhưng không được đánh giá, do đó các chuyển hướng dựa trên JavaScript sẽ không bị phát hiện. - Tự động kiểm tra các URL khớp với mẫu biểu thức chính quy sau. Cảnh báo! Bạn nên chỉ định một mẫu hạn chế (chứ không phải .* cho tất cả), nếu không các máy chủ độc hại có thể ghi lại IP của bạn. Văn bản đầu vào Hiển thị URL hiện tại, có thể chỉnh sửa thủ công. Máy quét URL diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 9b8e18cb..32162327 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -163,7 +163,6 @@ %d: 未知状态码 重定向到 %s 自动替换重定向链接 - 自动检查与以下正则表达式模式匹配的链接。警告!建议指定一个限制性模式(而不是使用 .* 匹配全部),否则恶意服务器可能会记录您的 IP。 输入文本 显示当前链接,点击以进入编辑模式。 链接扫描器 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 9c3595a5..112310fb 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -225,7 +225,6 @@ \n長按個別元素,則會將該元素複製到剪貼簿。 \n你也可以藉由點選「叉號」按鈕來移除個別元素。 \n這是進階版的「參數移除器」模組。 - 若網址匹配下列規則運算式型樣,將自動檢查狀態碼。警告!建議指定一個限制性的型樣 (並且避免使用「.*」來匹配全部),否則惡意的伺服器可能會記錄你的 IP 位址。 - 因「%s」而忽略 此模組能移除網址中的追蹤碼、參照連結等非必要參數。其亦能實現常見的離線重新導向。 此為規則目錄,其必須遵循 https://docs.clearurls.xyz/latest/specs/rules/ 的格式。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ee09184f..4d6a60e1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -257,7 +257,6 @@ Note: if you edit the patterns, new built-in patterns from app updates will not %d: Unknown status code Redirects to %s Automatically replace redirection URLs - Automatically check URLs that match the following regex pattern. Warning! It is advised to specify a restrictive pattern (and not .* for all) otherwise malicious servers may log your IP. Input text Displays the current URL. Press it to enter edit mode.