diff --git a/app/build.gradle b/app/build.gradle index 3cef6e7..183ee57 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,6 +37,6 @@ android { } dependencies { - implementation 'androidx.annotation:annotation:1.3.0' + implementation 'androidx.annotation:annotation:1.5.0' } diff --git a/app/src/main/java/dev/vendicated/vencord/HttpClient.java b/app/src/main/java/dev/vendicated/vencord/HttpClient.java index 13ace39..a58f7e6 100644 --- a/app/src/main/java/dev/vendicated/vencord/HttpClient.java +++ b/app/src/main/java/dev/vendicated/vencord/HttpClient.java @@ -22,14 +22,14 @@ public class HttpClient { @NonNull public String getMessage() { if (message == null) { - try { + try(var es = conn.getErrorStream()) { message = String.format( Locale.ENGLISH, "%d: %s (%s)\n%s", conn.getResponseCode(), conn.getResponseMessage(), conn.getURL().toString(), - readAsText(conn.getErrorStream()) + readAsText(es) ); } catch (IOException ex) { message = "Error while building message lmao. Url is " + conn.getURL().toString(); @@ -67,6 +67,7 @@ public class HttpClient { } baos.flush(); + //noinspection CharsetObjectCanBeUsed thank you so much android studio but no i do not want to use an sdk33 api ._. return baos.toString("UTF-8"); } } diff --git a/app/src/main/java/dev/vendicated/vencord/MainActivity.java b/app/src/main/java/dev/vendicated/vencord/MainActivity.java index 28b8915..950c97c 100644 --- a/app/src/main/java/dev/vendicated/vencord/MainActivity.java +++ b/app/src/main/java/dev/vendicated/vencord/MainActivity.java @@ -2,6 +2,7 @@ package dev.vendicated.vencord; import androidx.annotation.NonNull; +import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.os.StrictMode; @@ -12,6 +13,7 @@ import java.io.IOException; public class MainActivity extends Activity { private WebView wv; + @SuppressLint("SetJavaScriptEnabled") // mad? watch this swag @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -32,8 +34,7 @@ public class MainActivity extends Activity { s.setJavaScriptEnabled(true); s.setDomStorageEnabled(true); s.setAllowFileAccess(true); - - + try { HttpClient.fetchVencord(); } catch (IOException ex) { @@ -46,15 +47,13 @@ public class MainActivity extends Activity { } @Override - protected void onSaveInstanceState(@NonNull Bundle state) - { + protected void onSaveInstanceState(@NonNull Bundle state) { super.onSaveInstanceState(state); wv.saveState(state); } @Override - protected void onRestoreInstanceState(Bundle state) - { + protected void onRestoreInstanceState(Bundle state) { super.onRestoreInstanceState(state); wv.restoreState(state); } diff --git a/app/src/main/java/dev/vendicated/vencord/VChromeClient.java b/app/src/main/java/dev/vendicated/vencord/VChromeClient.java index 37a1f16..a9d7321 100644 --- a/app/src/main/java/dev/vendicated/vencord/VChromeClient.java +++ b/app/src/main/java/dev/vendicated/vencord/VChromeClient.java @@ -8,11 +8,8 @@ import java.util.Locale; public class VChromeClient extends WebChromeClient { @Override public boolean onConsoleMessage(ConsoleMessage msg) { - var m = String.format(Locale.ENGLISH,"[Javascript] %s @ %d: %s", msg.message(), msg.lineNumber(), msg.sourceId()); + var m = String.format(Locale.ENGLISH, "[Javascript] %s @ %d: %s", msg.message(), msg.lineNumber(), msg.sourceId()); switch (msg.messageLevel()) { - case LOG: - Logger.i(m); - break; case DEBUG: Logger.d(m); break; @@ -22,6 +19,9 @@ public class VChromeClient extends WebChromeClient { case WARNING: Logger.w(m); break; + default: + Logger.i(m); + break; } return true; } diff --git a/app/src/main/java/dev/vendicated/vencord/VWebviewClient.java b/app/src/main/java/dev/vendicated/vencord/VWebviewClient.java index 60c4404..2bff9cd 100644 --- a/app/src/main/java/dev/vendicated/vencord/VWebviewClient.java +++ b/app/src/main/java/dev/vendicated/vencord/VWebviewClient.java @@ -11,8 +11,8 @@ import java.net.URL; import java.util.*; public class VWebviewClient extends WebViewClient { - @Override - public boolean shouldOverrideUrlLoading(WebView view, String url){ + @Override // this makes URLs open in the webview instead of external browser + public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; } @@ -45,7 +45,6 @@ public class VWebviewClient extends WebViewClient { var code = conn.getResponseCode(); var msg = conn.getResponseMessage(); - conn.getHeaderFields(); var headers = conn.getHeaderFields(); var modifiedHeaders = new HashMap(headers.size());