mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 06:39:54 -04:00
Add the ability to move all windows in Mod Installer
This commit is contained in:
parent
c38ae42a04
commit
ec87d27b28
@ -39,4 +39,5 @@ public class AWTInputBridge {
|
||||
|
||||
public static native void nativeSendData(int type, int i1, int i2, int i3, int i4);
|
||||
public static native void nativePutClipboard(String data);
|
||||
public static native void nativeMoveWindow(int xoff, int yoff);
|
||||
}
|
||||
|
@ -51,6 +51,10 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
|
||||
|
||||
findViewById(R.id.installmod_mouse_pri).setOnTouchListener(this);
|
||||
findViewById(R.id.installmod_mouse_sec).setOnTouchListener(this);
|
||||
findViewById(R.id.installmod_window_moveup).setOnTouchListener(this);
|
||||
findViewById(R.id.installmod_window_movedown).setOnTouchListener(this);
|
||||
findViewById(R.id.installmod_window_moveleft).setOnTouchListener(this);
|
||||
findViewById(R.id.installmod_window_moveright).setOnTouchListener(this);
|
||||
|
||||
mMousePointerImageView.post(() -> {
|
||||
ViewGroup.LayoutParams params = mMousePointerImageView.getLayoutParams();
|
||||
@ -187,6 +191,20 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
|
||||
AWTInputBridge.sendMousePress(AWTInputEvent.BUTTON3_DOWN_MASK, isDown);
|
||||
break;
|
||||
}
|
||||
if(isDown) switch(v.getId()) {
|
||||
case R.id.installmod_window_moveup:
|
||||
AWTInputBridge.nativeMoveWindow(0, -10);
|
||||
break;
|
||||
case R.id.installmod_window_movedown:
|
||||
AWTInputBridge.nativeMoveWindow(0, 10);
|
||||
break;
|
||||
case R.id.installmod_window_moveleft:
|
||||
AWTInputBridge.nativeMoveWindow(-10, 0);
|
||||
break;
|
||||
case R.id.installmod_window_moveright:
|
||||
AWTInputBridge.nativeMoveWindow(10, 0);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,15 @@ jmethodID method_GetRGB;
|
||||
jclass class_CTCAndroidInput;
|
||||
jmethodID method_ReceiveInput;
|
||||
|
||||
jclass class_Frame;
|
||||
jclass class_Rectangle;
|
||||
jmethodID constructor_Rectangle;
|
||||
jmethodID method_GetFrames;
|
||||
jmethodID method_GetBounds;
|
||||
jmethodID method_SetBounds;
|
||||
jfieldID field_x;
|
||||
jfieldID field_y;
|
||||
|
||||
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
if (dalvikJavaVMPtr == NULL) {
|
||||
//Save dalvik global JavaVM pointer
|
||||
@ -126,3 +135,36 @@ Java_net_kdt_pojavlaunch_AWTInputBridge_nativePutClipboard(JNIEnv *env, jclass c
|
||||
(*runtimeJNIEnvPtr_CLIPBOARD)->DeleteLocalRef(runtimeJNIEnvPtr_CLIPBOARD,stringSelection);
|
||||
(*runtimeJNIEnvPtr_CLIPBOARD)->DeleteLocalRef(runtimeJNIEnvPtr_CLIPBOARD,o_stringSelection);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_net_kdt_pojavlaunch_AWTInputBridge_nativeMoveWindow(JNIEnv *env, jclass clazz, jint xoff, jint yoff) {
|
||||
if (runtimeJNIEnvPtr_INPUT == NULL) {
|
||||
if (runtimeJavaVMPtr == NULL) {
|
||||
return;
|
||||
} else {
|
||||
(*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, &runtimeJNIEnvPtr_INPUT, NULL);
|
||||
}
|
||||
}
|
||||
if(field_y == NULL) {
|
||||
class_Frame = (*runtimeJNIEnvPtr_INPUT)->FindClass(runtimeJNIEnvPtr_INPUT, "java/awt/Frame");
|
||||
method_GetFrames = (*runtimeJNIEnvPtr_INPUT)->GetStaticMethodID(runtimeJNIEnvPtr_INPUT, class_Frame, "getFrames", "()[Ljava/awt/Frame;");
|
||||
method_GetBounds = (*runtimeJNIEnvPtr_INPUT)->GetMethodID(runtimeJNIEnvPtr_INPUT, class_Frame, "getBounds", "(Ljava/awt/Rectangle;)Ljava/awt/Rectangle;");
|
||||
method_SetBounds = (*runtimeJNIEnvPtr_INPUT)->GetMethodID(runtimeJNIEnvPtr_INPUT, class_Frame, "setBounds", "(Ljava/awt/Rectangle;)V");
|
||||
class_Rectangle = (*runtimeJNIEnvPtr_INPUT)->FindClass(runtimeJNIEnvPtr_INPUT, "java/awt/Rectangle");
|
||||
constructor_Rectangle = (*runtimeJNIEnvPtr_INPUT)->GetMethodID(runtimeJNIEnvPtr_INPUT, class_Rectangle, "<init>", "()V");
|
||||
field_x = (*runtimeJNIEnvPtr_INPUT)->GetFieldID(runtimeJNIEnvPtr_INPUT, class_Rectangle, "x", "I");
|
||||
field_y = (*runtimeJNIEnvPtr_INPUT)->GetFieldID(runtimeJNIEnvPtr_INPUT, class_Rectangle, "y", "I");
|
||||
}
|
||||
jobject rectangle = (*runtimeJNIEnvPtr_INPUT)->NewObject(runtimeJNIEnvPtr_INPUT, class_Rectangle, constructor_Rectangle);
|
||||
jobjectArray frames = (*runtimeJNIEnvPtr_INPUT)->CallStaticObjectMethod(runtimeJNIEnvPtr_INPUT, class_Frame, method_GetFrames);
|
||||
for(jsize i = 0; i < (*runtimeJNIEnvPtr_INPUT)->GetArrayLength(runtimeJNIEnvPtr_INPUT, frames); i++) {
|
||||
jobject frame = (*runtimeJNIEnvPtr_INPUT)->GetObjectArrayElement(runtimeJNIEnvPtr_INPUT, frames, i);
|
||||
(*runtimeJNIEnvPtr_INPUT)->CallObjectMethod(runtimeJNIEnvPtr_INPUT, frame, method_GetBounds, rectangle);
|
||||
(*runtimeJNIEnvPtr_INPUT)->SetIntField(runtimeJNIEnvPtr_INPUT, rectangle, field_x, (*runtimeJNIEnvPtr_INPUT)->GetIntField(runtimeJNIEnvPtr_INPUT, rectangle, field_x) + xoff);
|
||||
(*runtimeJNIEnvPtr_INPUT)->SetIntField(runtimeJNIEnvPtr_INPUT, rectangle, field_y, (*runtimeJNIEnvPtr_INPUT)->GetIntField(runtimeJNIEnvPtr_INPUT, rectangle, field_y) + yoff);
|
||||
(*runtimeJNIEnvPtr_INPUT)->CallVoidMethod(runtimeJNIEnvPtr_INPUT, frame, method_SetBounds, rectangle);
|
||||
(*runtimeJNIEnvPtr_INPUT)->DeleteLocalRef(runtimeJNIEnvPtr_INPUT, frame);
|
||||
}
|
||||
(*runtimeJNIEnvPtr_INPUT)->DeleteLocalRef(runtimeJNIEnvPtr_INPUT, rectangle);
|
||||
(*runtimeJNIEnvPtr_INPUT)->DeleteLocalRef(runtimeJNIEnvPtr_INPUT, frames);
|
||||
}
|
||||
|
@ -116,6 +116,48 @@
|
||||
app:layout_constraintLeft_toRightOf="@id/installmod_mouse_pri"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/installmod_window_moveleft"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/control_button"
|
||||
android:text="◀"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/installmod_window_moveright"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toRightOf="@id/installmod_mouse_pri"
|
||||
android:background="@drawable/control_button"
|
||||
android:text="▶"
|
||||
app:layout_constraintBottom_toTopOf="@+id/installmod_window_moveleft"
|
||||
app:layout_constraintEnd_toEndOf="@+id/installmod_window_moveleft" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/installmod_window_moveup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toRightOf="@id/installmod_mouse_pri"
|
||||
android:background="@drawable/control_button"
|
||||
android:text="▲"
|
||||
app:layout_constraintBottom_toTopOf="@+id/installmod_window_moveleft"
|
||||
app:layout_constraintEnd_toStartOf="@+id/installmod_window_moveright" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/installmod_window_movedown"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/control_button"
|
||||
android:text="▼"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/installmod_window_moveleft" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.kdt.LoggerView
|
||||
|
Loading…
x
Reference in New Issue
Block a user