Skip to content

Commit

Permalink
Merge branch 'TrianguloY:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pokegamer5547 authored Nov 27, 2024
2 parents fdcee0a + 59b5fd3 commit 6e95d53
Show file tree
Hide file tree
Showing 28 changed files with 582 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- name: Zip ${{ env.VARIANT }} apk as ${{ env.ZIP }}
# just remove the password here if you want to build the apk yourself instead of sponsoring me and getting it as a benefit :(
run: zip -j -P ${{ secrets.ALPHA_PASS }} ${{ env.ZIP }} app/build/outputs/apk/${{ env.VARIANT }}/app-${{ env.VARIANT }}.apk
run: zip -j -P ${{ secrets.ALPHA_PASS }} ${{ env.ZIP }} app/build/outputs/apk/${{ env.VARIANT }}/*.apk

- name: Update ${{ env.TAG }} tag to current commit
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/validate-gradle-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ jobs:
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/upload-artifact@v4
with:
path: ./app/build/outputs/apk/${{ env.VARIANT }}/app-${{ env.VARIANT }}.apk
path: ./app/build/outputs/apk/${{ env.VARIANT }}/*.apk
name: ${{ env.NAME }}
retention-days: ${{ env.RETENTION_DAYS }}
if-no-files-found: error

outputs:
artifact-url: ${{ steps.artifact-upload-step.outputs.artifact-url }}
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<!-- Original background with CC0 from https://www.maxpixel.net/Digital-Network-Internet-Communication-Connections-3537400 -->

<!-- title -->

# URLCheck

<!-- ---------- Badges ---------- -->
Expand All @@ -25,9 +26,10 @@ height="80">](https://play.google.com/store/apps/details?id=com.trianguloy.urlch
<hr width="50%">

<!-- contributors -->

### Android app made by [TrianguloY](https://github.com/TrianguloY)

Special contributors: [Ilithy](https://github.com/Ilithy), [PabloOQ](https://github.com/PabloOQ)
Special contributors: [Ilithy](https://github.com/Ilithy), [PabloOQ](https://github.com/PabloOQ), [anoop-b](https://github.com/anoop-b)

All contributors: \
[![Contributors](https://contrib.rocks/image?repo=TrianguloY/UrlChecker&anon=1)](https://github.com/TrianguloY/UrlChecker/graphs/contributors) \
Expand Down
13 changes: 8 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.android.application'
id 'com.github.triplet.play' version '3.8.3'
id 'com.github.triplet.play' version '3.10.1'
}

android {
Expand All @@ -10,8 +10,8 @@ android {
compileSdk 34
minSdkVersion 19
targetSdkVersion 34
versionCode 35
versionName "2.17"
versionCode 37
versionName "3.0"
}

buildTypes {
Expand Down Expand Up @@ -66,7 +66,9 @@ dependencies {
}

// configure signing for release
private String secret(String name) { project.hasProperty(name) ? project.property(name) : System.getenv(name) }
private String secret(String name) {
project.hasProperty(name) ? project.property(name) : System.getenv(name)
}

if (secret('RELEASE_STORE_FILE')) {
println("Secrets provided, release will be signed")
Expand Down Expand Up @@ -105,7 +107,8 @@ android {
.collect { '"' + it + '"' } // convert as 'string'
.join(',') // and concatenate with commas
println "Found locales: $locales"
buildConfigField "java.util.List<String>", 'LOCALES', "java.util.List.of($locales)" // create field
buildConfigField "java.util.List<String>", 'LOCALES', "java.util.List.of($locales)"
// create field

// generate string resource with all translators
def translators = translations.stream() // for all translations
Expand Down
24 changes: 13 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down Expand Up @@ -29,11 +29,12 @@
<activity android:name=".activities.TutorialActivity" />
<activity
android:name=".dialogs.MainDialog"
android:excludeFromRecents="true"
android:clearTaskOnLaunch="true"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleInstance"
android:noHistory="true"
android:taskAffinity="com.trianguloy.urlchecker.dialog"
android:theme="@android:style/Theme.DeviceDefault.Dialog">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -100,12 +101,13 @@
</activity>
<activity
android:name=".activities.ShortcutsActivity"
android:label="@string/shortcut_checkClipboard"
android:icon="@mipmap/clipboard_launcher"
android:exported="true"
android:documentLaunchMode="always"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@mipmap/clipboard_launcher"
android:label="@string/shortcut_checkClipboard"
android:launchMode="singleTask"
android:taskAffinity="com.trianguloy.urlchecker.shortcuts"
android:theme="@android:style/Theme.DeviceDefault.Dialog.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
Expand All @@ -118,8 +120,8 @@

<activity
android:name=".activities.BackupActivity"
android:parentActivityName=".activities.SettingsActivity"
android:exported="true">
android:exported="true"
android:parentActivityName=".activities.SettingsActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

Expand All @@ -144,10 +146,10 @@

<service
android:name=".activities.ShortcutsActivity$ShortcutsTile"
android:exported="true"
android:icon="@drawable/ic_clipboard"
android:label="@string/shortcut_checkClipboard"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:exported="true">
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.trianguloy.urlchecker.modules.companions.VersionManager;
import com.trianguloy.urlchecker.modules.list.LogModule;
import com.trianguloy.urlchecker.modules.list.VirusTotalModule;
import com.trianguloy.urlchecker.modules.list.WebhookModule;
import com.trianguloy.urlchecker.utilities.AndroidSettings;
import com.trianguloy.urlchecker.utilities.generics.GenericPref;
import com.trianguloy.urlchecker.utilities.methods.AndroidUtils;
Expand Down Expand Up @@ -437,7 +438,7 @@ private void deleteFilesMatching(Function<String, Boolean> predicate) {
private static final String EMPTY = ".empty";
private static final String ADVANCED_EXTRA = "advanced";

private static final Function<String, Boolean> IS_PREF_SECRET = List.of(VirusTotalModule.PREF, LogModule.PREF)::contains;
private static final Function<String, Boolean> IS_PREF_SECRET = List.of(VirusTotalModule.PREF, LogModule.PREF, WebhookModule.URL_PREF)::contains;
private static final Function<String, Boolean> IS_FILE_CACHE = s -> s.startsWith(Hosts.PREFIX);

private void chooseFile(String action, JavaUtils.Consumer<Uri> listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ public AutomationRules(Activity cntx) {
@Override
public JSONObject buildBuiltIn(Context cntx) throws JSONException {
return new JSONObject()

.put("Unshort bit.ly", new JSONObject()
.put(cntx.getString(R.string.auto_rule_bitly), new JSONObject()
.put("regex", "https?://bit\\.ly/.*")
.put("action", "unshort")
.put("enabled", false)
)
.put(cntx.getString(R.string.auto_rule_webhook), new JSONObject()
.put("regex", ".*")
.put("action", "webhook")
.put("enabled", false)
)
;
}

Expand All @@ -73,11 +77,17 @@ public List<String> check(UrlData urlData) {
var automation = catalog.getJSONObject(key);
if (!automation.optBoolean("enabled", true)) continue;

if (urlData.url.matches(automation.getString("regex"))) {
matches.add(automation.getString("action"));
for (String pattern : JavaUtils.getArrayOrElement(automation.get("regex"), String.class)){
if (urlData.url.matches(pattern)) {
matches.add(automation.getString("action"));
break;
}
}

} catch (JSONException e) {
AndroidUtils.assertError("Invalid automation rule", e);
} catch (ClassCastException e) {
AndroidUtils.assertError("Invalid automation regex", e);
}
}
return matches;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.trianguloy.urlchecker.modules.list.UnshortenModule;
import com.trianguloy.urlchecker.modules.list.UriPartsModule;
import com.trianguloy.urlchecker.modules.list.VirusTotalModule;
import com.trianguloy.urlchecker.modules.list.WebhookModule;
import com.trianguloy.urlchecker.utilities.generics.GenericPref;

import java.util.ArrayList;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class ModuleManager {
modules.add(new UriPartsModule());
modules.add(new PatternModule());
modules.add(new HostsModule());
modules.add(new WebhookModule());
// new modules should preferably be added directly above this line
modules.add(new FlagsModule());
modules.add(new DebugModule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.trianguloy.urlchecker.modules.AModuleConfig;
import com.trianguloy.urlchecker.modules.AModuleData;
import com.trianguloy.urlchecker.modules.AModuleDialog;
import com.trianguloy.urlchecker.modules.AutomationRules;
import com.trianguloy.urlchecker.modules.companions.ClearUrlCatalog;
import com.trianguloy.urlchecker.url.UrlData;
import com.trianguloy.urlchecker.utilities.generics.GenericPref;
Expand All @@ -25,7 +26,6 @@
import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -66,6 +66,11 @@ public AModuleDialog getDialog(MainDialog cntx) {
public AModuleConfig getConfig(ModulesActivity cntx) {
return new ClearUrlConfig(cntx);
}

@Override
public List<AutomationRules.Automation<AModuleDialog>> getAutomations() {
return (List<AutomationRules.Automation<AModuleDialog>>) (List<?>) ClearUrlDialog.AUTOMATIONS;
}
}

class ClearUrlConfig extends AModuleConfig {
Expand Down Expand Up @@ -103,6 +108,10 @@ public void onInitialize(View views) {

class ClearUrlDialog extends AModuleDialog {

static final List<AutomationRules.Automation<ClearUrlDialog>> AUTOMATIONS = List.of(
new AutomationRules.Automation<>("clear", R.string.auto_clear, ClearUrlDialog::clear)
);

public static final String CLEARED = "clearUrl.cleared";

private final GenericPref.Bool allowReferral;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.trianguloy.urlchecker.utilities.methods.AndroidUtils.MARKER;

import android.content.Context;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.Button;
Expand Down Expand Up @@ -118,6 +119,7 @@ public void onInitialize(View views) {
info = views.findViewById(R.id.info);

redirect = views.findViewById(R.id.redirect);
redirect.setMovementMethod(LinkMovementMethod.getInstance());

autoRedir = StatusModule.AUTOREDIR_PREF(getActivity());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void showEditor(int position) {
// init dialog
var dialog = new AlertDialog.Builder(getActivity())
.setView(editText)
.setPositiveButton(android.R.string.ok, (d, w) -> setUrl(editText.getText().toString()))
.setPositiveButton(android.R.string.ok, (d, w) -> setUrl(new UrlData(editText.getText().toString()).disableUpdates()))
.setNegativeButton(android.R.string.cancel, null)
.setCancelable(true)
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.trianguloy.urlchecker.utilities.methods.AndroidUtils.MARKER;

import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.Button;
Expand Down Expand Up @@ -87,6 +88,7 @@ public void onInitialize(View views) {
unshort.setOnClickListener(v -> unshort(false));

info = views.findViewById(R.id.text);
info.setMovementMethod(LinkMovementMethod.getInstance());
}

@Override
Expand Down
Loading

0 comments on commit 6e95d53

Please sign in to comment.