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 {
implementation 'androidx.annotation:annotation:1.3.0'
implementation 'androidx.annotation:annotation:1.5.0'
}

View file

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

View file

@ -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);
@ -33,7 +35,6 @@ public class MainActivity extends Activity {
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);
}

View file

@ -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;
}

View file

@ -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<String, String>(headers.size());