1
0
Fork 0

small fixes

This commit is contained in:
Vendicated 2022-11-25 11:07:01 +01:00
parent efeb02ad2b
commit faaa17f98d
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
5 changed files with 15 additions and 16 deletions

View file

@ -37,6 +37,6 @@ android {
} }
dependencies { dependencies {
implementation 'androidx.annotation:annotation:1.3.0' implementation 'androidx.annotation:annotation:1.5.0'
} }

View file

@ -22,14 +22,14 @@ public class HttpClient {
@NonNull @NonNull
public String getMessage() { public String getMessage() {
if (message == null) { if (message == null) {
try { try(var es = conn.getErrorStream()) {
message = String.format( message = String.format(
Locale.ENGLISH, Locale.ENGLISH,
"%d: %s (%s)\n%s", "%d: %s (%s)\n%s",
conn.getResponseCode(), conn.getResponseCode(),
conn.getResponseMessage(), conn.getResponseMessage(),
conn.getURL().toString(), conn.getURL().toString(),
readAsText(conn.getErrorStream()) readAsText(es)
); );
} catch (IOException ex) { } catch (IOException ex) {
message = "Error while building message lmao. Url is " + conn.getURL().toString(); message = "Error while building message lmao. Url is " + conn.getURL().toString();
@ -67,6 +67,7 @@ public class HttpClient {
} }
baos.flush(); 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"); return baos.toString("UTF-8");
} }
} }

View file

@ -2,6 +2,7 @@ package dev.vendicated.vencord;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.StrictMode; import android.os.StrictMode;
@ -12,6 +13,7 @@ import java.io.IOException;
public class MainActivity extends Activity { public class MainActivity extends Activity {
private WebView wv; private WebView wv;
@SuppressLint("SetJavaScriptEnabled") // mad? watch this swag
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -33,7 +35,6 @@ public class MainActivity extends Activity {
s.setDomStorageEnabled(true); s.setDomStorageEnabled(true);
s.setAllowFileAccess(true); s.setAllowFileAccess(true);
try { try {
HttpClient.fetchVencord(); HttpClient.fetchVencord();
} catch (IOException ex) { } catch (IOException ex) {
@ -46,15 +47,13 @@ public class MainActivity extends Activity {
} }
@Override @Override
protected void onSaveInstanceState(@NonNull Bundle state) protected void onSaveInstanceState(@NonNull Bundle state) {
{
super.onSaveInstanceState(state); super.onSaveInstanceState(state);
wv.saveState(state); wv.saveState(state);
} }
@Override @Override
protected void onRestoreInstanceState(Bundle state) protected void onRestoreInstanceState(Bundle state) {
{
super.onRestoreInstanceState(state); super.onRestoreInstanceState(state);
wv.restoreState(state); wv.restoreState(state);
} }

View file

@ -8,11 +8,8 @@ import java.util.Locale;
public class VChromeClient extends WebChromeClient { public class VChromeClient extends WebChromeClient {
@Override @Override
public boolean onConsoleMessage(ConsoleMessage msg) { 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()) { switch (msg.messageLevel()) {
case LOG:
Logger.i(m);
break;
case DEBUG: case DEBUG:
Logger.d(m); Logger.d(m);
break; break;
@ -22,6 +19,9 @@ public class VChromeClient extends WebChromeClient {
case WARNING: case WARNING:
Logger.w(m); Logger.w(m);
break; break;
default:
Logger.i(m);
break;
} }
return true; return true;
} }

View file

@ -11,8 +11,8 @@ import java.net.URL;
import java.util.*; import java.util.*;
public class VWebviewClient extends WebViewClient { public class VWebviewClient extends WebViewClient {
@Override @Override // this makes URLs open in the webview instead of external browser
public boolean shouldOverrideUrlLoading(WebView view, String url){ public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false; return false;
} }
@ -45,7 +45,6 @@ public class VWebviewClient extends WebViewClient {
var code = conn.getResponseCode(); var code = conn.getResponseCode();
var msg = conn.getResponseMessage(); var msg = conn.getResponseMessage();
conn.getHeaderFields();
var headers = conn.getHeaderFields(); var headers = conn.getHeaderFields();
var modifiedHeaders = new HashMap<String, String>(headers.size()); var modifiedHeaders = new HashMap<String, String>(headers.size());