mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 00:59:35 -04:00
- Removed old files
This commit is contained in:
parent
6fe7440850
commit
9a06523148
@ -1,45 +0,0 @@
|
||||
package net.kdt.pojavlaunch.authenticator.microsoft;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class HttpClient
|
||||
{
|
||||
public static class Builder {
|
||||
public HttpClient build() {
|
||||
return new HttpClient(/* this */);
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
// private Builder mBuilder;
|
||||
protected HttpClient(/* Builder b */) {
|
||||
// mBuilder = b;
|
||||
}
|
||||
|
||||
// This method is not official java.net.http.HttpClient API.
|
||||
public <T> HttpResponse<T> sendRequest(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler) throws IOException {
|
||||
req.mBuilder.getBase().connect();
|
||||
|
||||
if (req.mBuilder.mData != null) {
|
||||
byte[] byteArr = req.mBuilder.mData.getBody().getBytes();
|
||||
OutputStream os = req.mBuilder.getBase().getOutputStream();
|
||||
os.write(byteArr, 0, byteArr.length);
|
||||
os.close();
|
||||
}
|
||||
|
||||
HttpResponse<T> response = new HttpResponse<T>(req);
|
||||
return response;
|
||||
}
|
||||
|
||||
/*
|
||||
public <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler) throws IOException {
|
||||
CompletableFuture<HttpResponse<T>> result = new CompletableFuture<HttpResponse<T>>();
|
||||
result.complete(sendRequest(req, responseBodyHandler));
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package net.kdt.pojavlaunch.authenticator.microsoft;
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class HttpRequest
|
||||
{
|
||||
public static class Builder {
|
||||
private URI mURI;
|
||||
private HttpURLConnection mConn;
|
||||
|
||||
protected BodyPublisher mData;
|
||||
public Builder(URI uri) throws IOException {
|
||||
mURI = uri;
|
||||
mConn = (HttpURLConnection) uri.toURL().openConnection();
|
||||
mConn.setUseCaches(false);
|
||||
mConn.setDoOutput(true);
|
||||
}
|
||||
|
||||
public HttpURLConnection getBase() {
|
||||
return mConn;
|
||||
}
|
||||
|
||||
public Builder header(String key, String value) {
|
||||
mConn.setRequestProperty(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder GET() throws ProtocolException {
|
||||
mConn.setRequestMethod("GET");
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder POST(BodyPublisher data) throws ProtocolException {
|
||||
mConn.setDoInput(true);
|
||||
mConn.setRequestMethod("POST");
|
||||
mData = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpRequest build() throws IOException {
|
||||
return new HttpRequest(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BodyPublisher {
|
||||
private String mStr;
|
||||
private BodyPublisher(String str) {
|
||||
mStr = str;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return mStr;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BodyPublishers {
|
||||
public static BodyPublisher ofString(String str) {
|
||||
return new BodyPublisher(str);
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder newBuilder(URI uri) throws IOException {
|
||||
return new Builder(uri);
|
||||
}
|
||||
|
||||
protected Builder mBuilder;
|
||||
protected HttpRequest(Builder b) {
|
||||
mBuilder = b;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package net.kdt.pojavlaunch.authenticator.microsoft;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
|
||||
public class HttpResponse<T>
|
||||
{
|
||||
private HttpRequest mRequest;
|
||||
public HttpResponse(HttpRequest request) {
|
||||
mRequest = request;
|
||||
}
|
||||
|
||||
public static class BodyHandler<T> {
|
||||
// public BodySubscriber<T> apply(ResponseInfo responseInfo);
|
||||
}
|
||||
|
||||
public static class BodyHandlers {
|
||||
public static BodyHandler<String> ofString() {
|
||||
return new BodyHandler<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public int statusCode() throws IOException {
|
||||
return mRequest.mBuilder.getBase().getResponseCode();
|
||||
}
|
||||
|
||||
public T body() throws IOException {
|
||||
if (statusCode() >= 200 && statusCode() < 300) {
|
||||
return (T) Tools.read(mRequest.mBuilder.getBase().getInputStream());
|
||||
} else {
|
||||
return (T) Tools.read(mRequest.mBuilder.getBase().getErrorStream());
|
||||
}
|
||||
|
||||
/*
|
||||
if (T instanceof String) {
|
||||
if (statusCode() >= 200 && statusCode() < 300) {
|
||||
return (T) Tools.read(mRequest.mBuilder.getBase().getInputStream());
|
||||
} else {
|
||||
return (T) Tools.read(mRequest.mBuilder.getBase().getErrorStream());
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
package org.lwjgl.glfw;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import android.widget.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import android.content.*;
|
||||
|
||||
public abstract class CallbackBridge {
|
||||
public static final int ANDROID_TYPE_GRAB_STATE = 0;
|
||||
|
||||
public static final int CLIPBOARD_COPY = 2000;
|
||||
public static final int CLIPBOARD_PASTE = 2001;
|
||||
|
||||
public static volatile int windowWidth, windowHeight;
|
||||
public static int mouseX, mouseY;
|
||||
public static boolean mouseLeft;
|
||||
public static StringBuilder DEBUG_STRING = new StringBuilder();
|
||||
|
||||
public static final CallbackBridge INSTANCE = new CallbackBridgeV3();
|
||||
|
||||
// volatile private static boolean isGrabbing = false;
|
||||
|
||||
public void putMouseEventWithCoords(int button, int x, int y /* , int dz, long nanos */) {
|
||||
putMouseEventWithCoords(button, 1, x, y);
|
||||
putMouseEventWithCoords(button, 0, x, y);
|
||||
}
|
||||
|
||||
public void putMouseEventWithCoords(int button, int state, int x, int y /* , int dz, long nanos */) {
|
||||
sendCursorPos(x, y);
|
||||
sendMouseKeycode(button, 0, state == 1);
|
||||
}
|
||||
|
||||
private static boolean threadAttached;
|
||||
public void sendCursorPos(int x, int y) {
|
||||
if (!threadAttached) {
|
||||
threadAttached = CallbackBridge.nativeAttachThreadToOther(true, BaseMainActivity.isInputStackCall);
|
||||
}
|
||||
|
||||
DEBUG_STRING.append("CursorPos=" + x + ", " + y + "\n");
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
nativeSendCursorPos(x, y);
|
||||
}
|
||||
|
||||
public void sendPrepareGrabInitialPos() {
|
||||
DEBUG_STRING.append("Prepare set grab initial posititon");
|
||||
sendMouseKeycode(-1, 0, false);
|
||||
}
|
||||
|
||||
public void sendKeycode(int keycode, char keychar, int modifiers, boolean isDown) {
|
||||
DEBUG_STRING.append("KeyCode=" + keycode + ", Char=" + keychar);
|
||||
// TODO CHECK: This may cause input issue, not receive input!
|
||||
/*
|
||||
if (!nativeSendCharMods(keychar, modifiers) || !nativeSendChar(keychar)) {
|
||||
nativeSendKey(keycode, 0, isDown ? 1 : 0, modifiers);
|
||||
}
|
||||
*/
|
||||
|
||||
nativeSendKeycode(keycode, keychar, modifiers, isDown);
|
||||
|
||||
// sendData(JRE_TYPE_KEYCODE_CONTROL, keycode, Character.toString(keychar), Boolean.toString(isDown), modifiers);
|
||||
}
|
||||
|
||||
public void sendMouseKeycode(int button, int modifiers, boolean isDown) {
|
||||
DEBUG_STRING.append("MouseKey=" + button + ", down=" + isDown + "\n");
|
||||
// if (isGrabbing()) DEBUG_STRING.append("MouseGrabStrace: " + android.util.Log.getStackTraceString(new Throwable()) + "\n");
|
||||
nativeSendMouseButton(button, isDown ? 1 : 0, modifiers);
|
||||
}
|
||||
|
||||
public void sendMouseKeycode(int keycode) {
|
||||
sendMouseKeycode(keycode, 0, true);
|
||||
sendMouseKeycode(keycode, 0, false);
|
||||
}
|
||||
|
||||
public void sendScroll(double xoffset, double yoffset) {
|
||||
DEBUG_STRING.append("ScrollX=" + xoffset + ",ScrollY=" + yoffset);
|
||||
nativeSendScroll(xoffset, yoffset);
|
||||
}
|
||||
|
||||
public void sendUpdateWindowSize(int w, int h) {
|
||||
nativeSendScreenSize(w, h);
|
||||
}
|
||||
|
||||
public static boolean isGrabbing() {
|
||||
// return isGrabbing;
|
||||
return nativeIsGrabbing();
|
||||
}
|
||||
|
||||
// Called from JRE side
|
||||
public static String accessAndroidClipboard(int type, String copy) {
|
||||
switch (type) {
|
||||
case CLIPBOARD_COPY:
|
||||
BaseMainActivity.GLOBAL_CLIPBOARD.setPrimaryClip(ClipData.newPlainText("Copy", copy));
|
||||
return null;
|
||||
|
||||
case CLIPBOARD_PASTE:
|
||||
if (BaseMainActivity.GLOBAL_CLIPBOARD.hasPrimaryClip() && BaseMainActivity.GLOBAL_CLIPBOARD.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
|
||||
return BaseMainActivity.GLOBAL_CLIPBOARD.getPrimaryClip().getItemAt(0).getText().toString();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
public void receiveCallback(int type, String data) {
|
||||
switch (type) {
|
||||
case ANDROID_TYPE_GRAB_STATE:
|
||||
// isGrabbing = Boolean.parseBoolean(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static native boolean nativeAttachThreadToOther(boolean isAndroid, boolean isUsePushPoll);
|
||||
public static native boolean nativeIsGrabbing();
|
||||
|
||||
protected abstract boolean nativeSendChar(char codepoint /* int codepoint */);
|
||||
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
||||
protected abstract boolean nativeSendCharMods(char codepoint, int mods);
|
||||
// protected abstract void nativeSendCursorEnter(int entered);
|
||||
protected abstract void nativeSendCursorPos(int x, int y);
|
||||
protected abstract void nativeSendKey(int key, int scancode, int action, int mods);
|
||||
protected abstract void nativeSendMouseButton(int button, int action, int mods);
|
||||
protected abstract void nativeSendScroll(double xoffset, double yoffset);
|
||||
protected abstract void nativeSendScreenSize(int width, int height);
|
||||
|
||||
|
||||
|
||||
static {
|
||||
System.loadLibrary("pojavexec");
|
||||
}
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
package org.lwjgl.glfw;
|
||||
|
||||
public class CallbackBridgeV1 extends CallbackBridge
|
||||
{
|
||||
public static final int JRE_TYPE_CURSOR_POS = 0;
|
||||
public static final int JRE_TYPE_CURSOR_BUTTON = 1;
|
||||
public static final int JRE_TYPE_KEYCODE_CONTROL = 2;
|
||||
public static final int JRE_TYPE_KEYCODE_CHAR = 3;
|
||||
public static final int JRE_TYPE_MOUSE_KEYCODE_CONTROL = 4;
|
||||
public static final int JRE_TYPE_WINDOW_SIZE = 5;
|
||||
public static final int JRE_TYPE_GRAB_INITIAL_POS_UNSET = 6;
|
||||
|
||||
public static final int ANDROID_TYPE_GRAB_STATE = 0;
|
||||
|
||||
public void nativeSendCursorPos(int x, int y) {
|
||||
DEBUG_STRING.append("CursorPos=" + x + ", " + y + "\n");
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
sendData(JRE_TYPE_CURSOR_POS, x, y);
|
||||
}
|
||||
|
||||
public void nativeSendGrabInitialPosUnset() {
|
||||
DEBUG_STRING.append("Grab initial posititon uset");
|
||||
sendData(JRE_TYPE_GRAB_INITIAL_POS_UNSET);
|
||||
}
|
||||
|
||||
public void nativeSendKeycode(int keycode, char keychar, int modifiers, boolean isDown) {
|
||||
DEBUG_STRING.append("KeyCode=" + keycode + ", Char=" + keychar);
|
||||
sendData(JRE_TYPE_KEYCODE_CONTROL, keycode, Character.toString(keychar), Boolean.toString(isDown), modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nativeSendMouseButton(int keycode, int action, int modifiers) {
|
||||
DEBUG_STRING.append("MouseKey=" + keycode + ", down=" + action + "\n");
|
||||
// if (isGrabbing()) DEBUG_STRING.append("MouseGrabStrace: " + android.util.Log.getStackTraceString(new Throwable()) + "\n");
|
||||
sendData(JRE_TYPE_MOUSE_KEYCODE_CONTROL, keycode, action == 1, modifiers);
|
||||
}
|
||||
|
||||
public void nativeSendMouseKeycode(int keycode) {
|
||||
sendMouseKeycode(keycode, 0, true);
|
||||
sendMouseKeycode(keycode, 0, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nativeSendScreenSize(int w, int h) {
|
||||
sendData(JRE_TYPE_WINDOW_SIZE, w, h);
|
||||
}
|
||||
|
||||
private static String currData;
|
||||
public void sendData(int type, Object... dataArr) {
|
||||
currData = "";
|
||||
for (int i = 0; i < dataArr.length; i++) {
|
||||
if (dataArr[i] instanceof Integer) {
|
||||
currData += Integer.toString((int) dataArr[i]);
|
||||
} else if (dataArr[i] instanceof String) {
|
||||
currData += (String) dataArr[i];
|
||||
} else {
|
||||
currData += dataArr[i].toString();
|
||||
}
|
||||
currData += (i + 1 < dataArr.length ? ":" : "");
|
||||
}
|
||||
nativeSendData(type, currData);
|
||||
}
|
||||
|
||||
protected native void nativeSendData(int type, String data);
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package org.lwjgl.glfw;
|
||||
|
||||
public class CallbackBridgeV3 extends CallbackBridge
|
||||
{
|
||||
@Override protected native boolean nativeSendChar(char codepoint /* int codepoint */);
|
||||
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
||||
@Override protected native boolean nativeSendCharMods(char codepoint, int mods);
|
||||
// @Override protected native void nativeSendCursorEnter(int entered);
|
||||
@Override protected native void nativeSendCursorPos(int x, int y);
|
||||
@Override protected native void nativeSendKey(int key, int scancode, int action, int mods);
|
||||
@Override protected native void nativeSendMouseButton(int button, int action, int mods);
|
||||
@Override protected native void nativeSendScroll(double xoffset, double yoffset);
|
||||
@Override protected native void nativeSendScreenSize(int width, int height);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user