small fixes
This commit is contained in:
parent
efeb02ad2b
commit
faaa17f98d
5 changed files with 15 additions and 16 deletions
|
@ -37,6 +37,6 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.annotation:annotation:1.3.0'
|
||||
implementation 'androidx.annotation:annotation:1.5.0'
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue