Skip to content

Commit

Permalink
migrate status module autoCheck to automation
Browse files Browse the repository at this point in the history
  • Loading branch information
TrianguloY committed Oct 24, 2024
1 parent afc2cbd commit 9221f64
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
}
}

Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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);
}
}

/**
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/res/layout/config_status.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,4 @@
android:layout_height="wrap_content"
android:text="@string/mStatus_autoRedirect" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mStatus_autoCheck" />

<EditText
android:id="@+id/autoCheck"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/none"
android:inputType="none" />

</LinearLayout>
1 change: 0 additions & 1 deletion app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
<string name="mOpen_incognitoDesc">تبديل وضع التصفح الخفي (Firefox فقط)</string>
<string name="mStatus_name">كود الحالة</string>
<string name="mStatus_desc">من خلال الضغط على زر التحقق، سيتم إجراء طلب شبكة لاسترجاع وعرض كود حالة الموقع. إذا كانت النتيجة توجيهًا، فستتمكن من عرض عنوان URL النهائي. يتم الحصول على محتوى عنوان URL (GET)، ولكن لا يتم تقييمه، لذلك لن يتم اكتشاف التوجيهات استنادًا إلى JavaScript.</string>
<string name="mStatus_autoCheck">التحقق التلقائي من عناوين URL التي تتطابق مع نمط التعبير النمطي التالي. تحذير! من المستحسن تحديد نمط مقيد (وليس .* للجميع) وإلا فقد تقوم السيرفرات الخبيثة بتسجيل عنوان IP الخاص بك.</string>
<string name="mVT_desc">عند تمكين هذه الوحدة، يمكنك فحص عنوان الويب باستخدام VirusTotal والتحقق من التقرير. يلزم وجود مفتاح API الخاص بـ VirusTotal الشخصي لعمله، يمكنك الحصول على واحد بعد التسجيل للحصول على حساب مجاني هنا: https://www.virustotal.com/gui/join-us .</string>
<string name="mD_desc">إذا قمت بإعادة ترتيب الوحدات، سيتم وضع الجديدة التي يتم إضافتها في التحديثات المستقبلية فوق هذه الوحدة.
\n
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<string name="mStatus_unknownCode">%d: Neznámý stavový kód</string>
<string name="mStatus_redir">Přesměrovává na %s</string>
<string name="mStatus_autoRedirect">Automaticky nahrazovat adresy přesměrování</string>
<string name="mStatus_autoCheck">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.</string>
<string name="mInput_name">Vstupní text</string>
<string name="mInput_desc">Zobrazuje aktuální adresu URL, kterou lze ručně upravit.</string>
<string name="mVT_apiKey">API klíč</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.</string>
<string name="mStatus_autoCheck">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.</string>
<string name="mVT_cancel">Abbrechen</string>
<string name="mVT_scanning">Scan läuft…</string>
<string name="mHist_desc">Wenn eine URL verändert wird (manuell oder von anderen Modulen), können Sie hiermit Änderungen sehen und rückgängig machen.</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ Hay algunos enlaces cuyo único propósito es redirigirte a otro enlace. Si el e
<string name="mStatus_unknownCode">%d: Código de error desconocido</string>
<string name="mStatus_redir">Redirige a %s</string>
<string name="mStatus_autoRedirect">Sustituir automáticamente las URL de redireccionamiento</string>
<string name="mStatus_autoCheck">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.</string>
<!-- -->
<string name="mInput_name">Texto de entrada</string>
<string name="mInput_desc">Muestra la URL actual. Pulsa para editarla.</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fr-rFR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ Ceci est le didacticiel, si vous souhaitez l'ignorer vous pouvez le faire en uti
<string name="mStatus_unknownCode">%d: Code d\'état inconnu</string>
<string name="mStatus_redir">Redirige vers %s</string>
<string name="mStatus_autoRedirect">Remplacer automatiquement les URLs de redirection</string>
<string name="mStatus_autoCheck">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.</string>
<!-- -->
<string name="mInput_name">Texte d\'entrée</string>
<string name="mInput_desc">Affiche l\'URL actuel. Appuyez dessus pour passer en mode édition.</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
<string name="mHosts_uninitialized">होस्ट डेटाबेस प्रारंभ नहीं किया गया। बनाने के लिए दबाएँ</string>
<string name="mHosts_buildSave">सहेजा जा रहा है…</string>
<string name="mRemove_all">सभी हटाएं</string>
<string name="mStatus_autoCheck">निम्नलिखित regex पैटर्न से मेल खाने वाले यूआरएल को स्वचालित रूप से जांचें। चेतावनी! यह सलाह दी जाती है कि एक प्रतिबंधात्मक पैटर्न निर्दिष्ट करें (और सभी के लिए .* नहीं) अन्यथा दुर्भावनापूर्ण सर्वर आपके आईपी को लॉग कर सकते हैं।</string>
<string name="mLog_empty">कोई डेटा नहीं</string>
<string name="mHosts_noLabel">कोई लेबल नहीं</string>
<string name="mRemove_empty">खाली हटाएँ</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
<string name="mStatus_name">Kode status</string>
<string name="mOpen_closeShare">Tutup kotak dialog setelah membagikan tautan</string>
<string name="mClear_tm">Katalog bawaan disalin dari ClearURLs: https://docs.clearurls.xyz/latest/specs/rules/</string>
<string name="mStatus_autoCheck">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.</string>
<string name="back">Kembali</string>
<string name="hidden">Tersembunyi</string>
<string name="mPttrn_desc">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.
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,5 @@
<string name="mStatus_autoRedirect">자동으로 리다이렉트 URL로 교체하기</string>
<string name="mStatus_desc">\'확인하기\' 버튼을 누르면 사이트의 상태 코드를 받아와 표시하기 위해 네트워크 요청이 이루어집니다. 결과가 리다이렉션이라면 도착 URL을 볼 수 있습니다. 만약 URL에서 정보를 받아오기눈 하지만, 실행되지는 않기에 JavaScript 기반 동적 리다이렉션은 감지되지 않습니다.</string>
<string name="mStatus_checking">확인 중…</string>
<string name="mStatus_autoCheck">다음의 정규식 패턴에 맞는 URL을 자동으로 확인합니다. 주의! (.*가 아닌) 제한적인 패턴을 사용하는 것이 권장됩니다. 그렇지 않다면 악의적인 서버는 당신의 IP를 기록할 수 있습니다.</string>
<string name="mOpen_incognito">익명 모드:</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<string name="mOpen_closeShare">Dialoogvenster sluiten na delen</string>
<string name="txt_openLinks">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.</string>
<string name="mClear_tm">Ingebouwde catalogus gekopieerd van ClearURLs: https://docs.clearurls.xyz/latest/specs/rules/</string>
<string name="mStatus_autoCheck">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.</string>
<string name="back">Terug</string>
<string name="hidden">Verborgen</string>
<string name="mPttrn_desc">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.
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
<string name="json_desc">[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.</string>
<string name="mPttrn_noSchemeHttps">Esquema HTTPS ausente.</string>
<string name="mPttrn_ok">Não há padrões correspondentes.</string>
<string name="mStatus_autoCheck">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.</string>
<string name="mStatus_autoRedirect">Substituir as URLs de redirecionamento automaticamente</string>
<string name="mVT_name">Scanner de URL</string>
<string name="mInput_desc">Mostra a URL atual, que pode ser editada manualmente.</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pt-rPT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ Para desabilitar o log, basta desabilitar o módulo."</string>
<string name="dismiss">Descartar</string>
<string name="shortcut_checkClipboard">Verificar ligação da área de transferência</string>
<string name="mStatus_autoRedirect">Substituir as URLs de redirecionamento automaticamente</string>
<string name="mStatus_autoCheck">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.</string>
<string name="mParts_empty">(vazio)</string>
<string name="mChg_name">Novidades</string>
<string name="mOpen_incognito">Modo anônimo:</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
<string name="mStatus_name">Код состояния</string>
<string name="mOpen_closeShare">Закрыть диалоговое окно после того как поделились ссылкой</string>
<string name="mClear_tm">Встроенный каталог скопирован с ClearURLs: https://docs.clearurls.xyz/latest/specs/rules/</string>
<string name="mStatus_autoCheck">Автоматически проверять URL-адреса которые соответствуют следующему шаблону, заданным регулярным выражением. Внимание! Рекомендуется указать ограничивающий шаблон (а не .* для всех), потому что в ином случае вредоносные сервера могут сохранять ваш IP адрес.</string>
<string name="mClear_rule">- найден бесполезный параметр</string>
<string name="mPttrn_desc">Этот модуль проверяет URL при помощи регулярных выражений которые могут предупреждать, предлагать или применять изменения. Вы можете модифицировать шаблоны или создавать свои собственные, или даже использовать созданные пользователями шаблоны.
\nВстроенные шаблоны включают в себя:
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-sr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@
<string name="mStatus_recheck">Proveri</string>
<string name="mStatus_unknownCode">%d: Nepoznat statusni kod</string>
<string name="mStatus_redir">Preusmerava na %s</string>
<string name="mStatus_autoCheck">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.</string>
<string name="mVT_desc">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.</string>
<string name="mVT_noKey">Nedostaje API ključ</string>
<string name="mVT_tm">VirusTotal™ je zaštitni znak kompanije Google, Inc.</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ Not: kalıpları düzenlerseniz, uygulama güncellemelerinden yeni yerleşik kal
<string name="mStatus_unknownCode">%d: Bilinmeyen durum kodu</string>
<string name="mStatus_redir">Yönlendirme: %s</string>
<string name="mStatus_autoRedirect">Yönlendirme URL\'lerini otomatik olarak değiştir</string>
<string name="mStatus_autoCheck">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.</string>
<!-- -->
<string name="mInput_name">Giriş metni</string>
<string name="mInput_desc">Elle düzenlenebilen geçerli URL\'yi görüntüler.</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@
<string name="mStatus_redir">Chuyển hướng đến %s</string>
<string name="mStatus_autoRedirect">Tự động thay thế các URL chuyển hướng</string>
<string name="mStatus_desc">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.</string>
<string name="mStatus_autoCheck">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.</string>
<string name="mInput_name">Văn bản đầu vào</string>
<string name="mInput_desc">Hiển thị URL hiện tại, có thể chỉnh sửa thủ công.</string>
<string name="mVT_name">Máy quét URL</string>
Expand Down
Loading

0 comments on commit 9221f64

Please sign in to comment.