Compare commits

..
Author SHA1 Message Date
Mathias-Boulay 12ef059ef3 Build: Allow proguard granularity 2024-12-10 17:44:03 +01:00
Mathias-Boulay 60f57a8851 Fix: allow CriticalNativeTest in proguard build 2024-12-10 17:25:23 +01:00
Mathias-Boulay 42a0e58570 fix(build): allow proguard profile to launch
It is still plagued with bugs, but it might stay handy the day we need to push some limits
2024-12-07 00:04:40 +01:00
Mathias-Boulay 1e7b005ee0 chore(build): update gradle to 8.11 2024-12-07 00:03:18 +01:00
Mathias-Boulay 15541ff490 build(actions): update GH Action gradle version 2024-12-06 21:17:48 +01:00
Mathias-Boulay 3ace0dd2cc chore(build): update gradle to 8.9 and AGP to 8.7.2
This may or may not force the generation of all sub projects
2024-12-06 21:06:38 +01:00
Mathias Boulay 1af64382eb QoL update (#6350)
* QoL(notification): click to go back into the current game

* Fix(system bars): fix colors for navigation bars

* Tweak(control editor): make snapping less aggressive

* Fix(system bars): properly remove colors in full screen
2024-12-06 21:04:17 +01:00
Mathias-Boulay bc7dfeacfd Fix(control-editors): make sure the layout is instantiated before using it 2024-12-03 21:04:09 +01:00
Maksim Belov fd6bea9b39 Merge pull request #6338 from PojavLauncherTeam/fix/QoL_stuff
QoL update
2024-12-02 13:07:37 +03:00
Mathias-Boulay fc81b87e7f Fix(controls): non square joystick, set size via text 2024-12-01 23:29:16 +01:00
Mathias-Boulay c6fe3c3de5 QoL(gesture): decouple gyroscope from long press gesture 2024-11-29 21:17:29 +01:00
Mathias-Boulay 68fa25cafc Fix(hotbar): first touch on 0 index not being taken into account 2024-11-29 21:14:16 +01:00
Mathias-Boulay fae327978e QoL(profile editor): make the text react like a button
This increases the space you can use, better for left handed people or large hands
2024-11-29 18:57:24 +01:00
Mathias-Boulay 29605ed6b7 QoL: make the settings button easier to click
Bigger hitbox, but not visually
2024-11-29 18:22:39 +01:00
Maksim Belov d5fd73c9e9 Feat[launcher]: Add a quick settings menu (#6303) 2024-11-26 21:05:47 +03:00
30 changed files with 267 additions and 121 deletions

No files matched your search

+2 -2
View File
@@ -56,9 +56,9 @@ jobs:
branch: buildjre17-21
name: jre21-pojav
- uses: gradle/gradle-build-action@v2
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 7.6.1
gradle-version: "8.11"
- name: Build JRE JAR files
run: |
+13 -3
View File
@@ -1,5 +1,5 @@
plugins {
id 'com.android.application' version '7.4.2'
id 'com.android.application' version '8.7.2'
}
static def getDate() { return new Date().format('yyyyMMdd') }
@@ -137,6 +137,10 @@ android {
minifyEnabled true
shrinkResources true
}
proguardNoDebug {
initWith proguard
debuggable false
}
release {
// Don't set to true or java.awt will be a.a or something similar.
@@ -182,9 +186,15 @@ android {
buildFeatures {
prefab true
buildConfig true
}
buildToolsVersion = '33.0.2'
buildToolsVersion = '34.0.0'
}
afterEvaluate {
// Explicit dependencies for which the apk relies on
tasks.mergeDebugAssets.dependsOn(":forge_installer:jar", ":arc_dns_injector:jar", ":jre_lwjgl3glfw:jar")
}
dependencies {
@@ -204,7 +214,7 @@ dependencies {
implementation 'com.github.PojavLauncherTeam:portrait-ssp:6c02fd739b'
implementation 'com.github.Mathias-Boulay:ExtendedView:1.0.0'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:2.0.3'
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:2e7aa25e50'
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:1.14'
// implementation 'com.intuit.sdp:sdp-android:1.0.5'
// implementation 'com.intuit.ssp:ssp-android:1.0.5'
@@ -106,7 +106,7 @@
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|keyboard|navigation|uiMode"
android:launchMode="standard"
android:launchMode="singleTop"
android:process=":game"
android:screenOrientation="sensorLandscape" />
@@ -186,6 +186,11 @@ public abstract class SideDialogView {
*/
@CallSuper
public final void disappear(boolean destroy) {
if(!mIsInstantiated) {
Log.w("SideDialogView", "Layout not inflated");
return;
}
if (!mDisplaying) {
if(destroy) {
onDisappear();
@@ -1,7 +1,10 @@
package net.kdt.pojavlaunch;
import androidx.annotation.Keep;
import dalvik.annotation.optimization.CriticalNative;
@Keep
public class CriticalNativeTest {
@CriticalNative
public static native void testCriticalNative(int arg0, int arg1);
@@ -156,7 +156,12 @@ public class LauncherActivity extends BaseActivity {
@Override
protected boolean shouldIgnoreNotch() {
return getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT || super.shouldIgnoreNotch();
return getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT;
}
@Override
public boolean setFullscreen() {
return false;
}
@Override
@@ -227,11 +232,6 @@ public class LauncherActivity extends BaseActivity {
mInstallTracker.detach();
}
@Override
public boolean setFullscreen() {
return false;
}
@Override
protected void onStart() {
super.onStart();
@@ -15,6 +15,7 @@ public class Logger {
public static native void begin(String logFilePath);
/** Small listener for anything listening to the log */
@Keep
public interface eventLogListener {
void onEventLogged(String text);
}
@@ -36,6 +36,7 @@ import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
@@ -442,6 +443,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
if(touchCharInput != null) touchCharInput.switchKeyboardState();
}
@Keep
public static void openLink(String link) {
Context ctx = touchpad.getContext(); // no more better way to obtain a context statically
((Activity)ctx).runOnUiThread(() -> {
@@ -461,6 +463,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
}
});
}
@SuppressWarnings("unused") //TODO: actually use it
public static void openPath(String path) {
Context ctx = touchpad.getContext(); // no more better way to obtain a context statically
@@ -473,6 +476,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
});
}
@Keep
public static void querySystemClipboard() {
Tools.runOnUiThread(()->{
ClipData clipData = GLOBAL_CLIPBOARD.getPrimaryClip();
@@ -491,6 +495,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
});
}
@Keep
public static void putClipboardData(String data, String mimeType) {
Tools.runOnUiThread(()-> {
ClipData clipData = null;
@@ -33,9 +33,6 @@ import android.util.ArrayMap;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;
@@ -47,6 +44,10 @@ import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -539,35 +540,32 @@ public final class Tools {
@RequiresApi(Build.VERSION_CODES.R)
private static void setFullscreenSdk30(Activity activity, boolean fullscreen) {
final Window window = activity.getWindow();
final View decorView = window.getDecorView();
final int insetControllerFlags = WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars();
final View.OnApplyWindowInsetsListener windowInsetsListener = (view, windowInsets) ->{
WindowInsetsController windowInsetsController = decorView.getWindowInsetsController();
if(windowInsetsController == null) return windowInsets;
boolean multiWindowMode = activity.isInMultiWindowMode();
// Emulate the behaviour of the legacy function using the new flags
if(fullscreen && !multiWindowMode) {
windowInsetsController.hide(insetControllerFlags);
windowInsetsController.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
window.setDecorFitsSystemWindows(false);
}else {
windowInsetsController.show(insetControllerFlags);
// Both of the constants below have the exact same numerical value, but
// for some reason the one that works below Android S was removed
// from the acceptable constants for setSystemBarsBehaviour
if (SDK_INT >= Build.VERSION_CODES.S) {
windowInsetsController.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_DEFAULT);
}else {
// noinspection WrongConstant
windowInsetsController.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE);
}
window.setDecorFitsSystemWindows(true);
}
return windowInsets;
};
decorView.setOnApplyWindowInsetsListener(windowInsetsListener);
windowInsetsListener.onApplyWindowInsets(decorView, null);
WindowInsetsControllerCompat windowInsetsController =
WindowCompat.getInsetsController(activity.getWindow(), activity.getWindow().getDecorView());
if (windowInsetsController == null) {
Log.w(APP_NAME, "WindowInsetsController is null, cannot set fullscreen");
return;
}
// Configure the behavior of the hidden system bars.
windowInsetsController.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
);
ViewCompat.setOnApplyWindowInsetsListener(
activity.getWindow().getDecorView(),
(view, windowInsets) -> {
if (fullscreen && !activity.isInMultiWindowMode()) {
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
activity.getWindow().setDecorFitsSystemWindows(false);
} else {
windowInsetsController.show(WindowInsetsCompat.Type.systemBars());
activity.getWindow().setDecorFitsSystemWindows(true);
}
return ViewCompat.onApplyWindowInsets(view, windowInsets);
});
}
public static void setFullscreen(Activity activity, boolean fullscreen) {
@@ -7,6 +7,7 @@ import android.util.ArrayMap;
import androidx.annotation.Keep;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.customcontrols.buttons.ControlInterface;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.utils.JSONUtils;
import net.objecthunter.exp4j.ExpressionBuilder;
@@ -240,7 +241,7 @@ public class ControlData {
keyValueMap.put("height", "DUMMY_HEIGHT");
keyValueMap.put("screen_width", "DUMMY_DATA");
keyValueMap.put("screen_height", "DUMMY_DATA");
keyValueMap.put("margin", Integer.toString((int) Tools.dpToPx(2)));
keyValueMap.put("margin", Integer.toString((int) ControlInterface.getMarginDistance()));
keyValueMap.put("preferred_scale", "DUMMY_DATA");
conversionMap = new WeakReference<>(keyValueMap);
@@ -57,13 +57,13 @@ public class CustomControls {
this.mControlDataList.add(new ControlData(ctx, R.string.control_jump, new int[]{LwjglGlfwKeycode.GLFW_KEY_SPACE}, "${right} - ${margin} * 2 - ${width}", "${bottom} - ${margin} * 2 - ${height}", true));
//The default controls are conform to the V3
version = 7;
version = 8;
}
public void save(String path) throws IOException {
//Current version is the V3.1 so the version as to be marked as 7 !
version = 7;
//Current version is the V3.2 so the version as to be marked as 8 !
version = 8;
Tools.write(path, Tools.GLOBAL_GSON.toJson(this));
}
@@ -24,27 +24,56 @@ public class LayoutConverter {
CustomControls layout = LayoutConverter.convertV1Layout(layoutJobj);
layout.save(jsonPath);
return layout;
} else if (layoutJobj.getInt("version") == 2) {
CustomControls layout = LayoutConverter.convertV2Layout(layoutJobj);
layout.save(jsonPath);
return layout;
}else if (layoutJobj.getInt("version") >= 3 && layoutJobj.getInt("version") <= 5) {
return LayoutConverter.convertV3_4Layout(layoutJobj);
} else if (layoutJobj.getInt("version") == 6 || layoutJobj.getInt("version") == 7) {
return Tools.GLOBAL_GSON.fromJson(jsonLayoutData, CustomControls.class);
} else {
return null;
int version = layoutJobj.getInt("version");
if (version == 2) {
CustomControls layout = LayoutConverter.convertV2Layout(layoutJobj);
layout.save(jsonPath);
return layout;
}
if (version == 3 || version == 4 || version == 5) {
return LayoutConverter.convertV3_4Layout(layoutJobj);
}
if (version == 6 || version == 7) {
return convertV6_7Layout(layoutJobj);
}
else if (version == 8) {
return Tools.GLOBAL_GSON.fromJson(jsonLayoutData, CustomControls.class);
}
}
return null;
} catch (JSONException e) {
throw new JsonSyntaxException("Failed to load", e);
}
}
/**
* Normalize the layout to v8 from v6/7. An issue from the joystick height and position has to be fixed.
* @param oldLayoutJson The old layout
* @return The new layout with the fixed joystick height
*/
public static CustomControls convertV6_7Layout(JSONObject oldLayoutJson) {
CustomControls layout = Tools.GLOBAL_GSON.fromJson(oldLayoutJson.toString(), CustomControls.class);
for (ControlJoystickData data : layout.mJoystickDataList) {
if (data.getHeight() > data.getWidth()) {
// Make the size square, adjust the dynamic position related to height
float ratio = data.getHeight() / data.getWidth();
data.dynamicX = data.dynamicX.replace("${height}", "(" + ratio + " * ${height})");
data.dynamicY = data.dynamicY.replace("${height}", "(" + ratio + " * ${height})") + " + (" + (ratio-1) + " * ${height})";
data.setHeight(data.getWidth());
}
}
layout.version = 8;
return layout;
}
/**
* Normalize the layout to v6 from v3/4: The stroke width is no longer dependant on the button size
*/
public static CustomControls convertV3_4Layout(JSONObject oldLayoutJson) {
private static CustomControls convertV3_4Layout(JSONObject oldLayoutJson) {
CustomControls layout = Tools.GLOBAL_GSON.fromJson(oldLayoutJson.toString(), CustomControls.class);
convertStrokeWidth(layout);
layout.version = 6;
@@ -52,7 +81,7 @@ public class LayoutConverter {
}
public static CustomControls convertV2Layout(JSONObject oldLayoutJson) throws JSONException {
private static CustomControls convertV2Layout(JSONObject oldLayoutJson) throws JSONException {
CustomControls layout = Tools.GLOBAL_GSON.fromJson(oldLayoutJson.toString(), CustomControls.class);
JSONArray layoutMainArray = oldLayoutJson.getJSONArray("mControlDataList");
layout.mControlDataList = new ArrayList<>(layoutMainArray.length());
@@ -95,7 +124,7 @@ public class LayoutConverter {
return layout;
}
public static CustomControls convertV1Layout(JSONObject oldLayoutJson) throws JSONException {
private static CustomControls convertV1Layout(JSONObject oldLayoutJson) throws JSONException {
CustomControls empty = new CustomControls();
JSONArray layoutMainArray = oldLayoutJson.getJSONArray("mControlDataList");
for (int i = 0; i < layoutMainArray.length(); i++) {
@@ -61,26 +61,27 @@ public class ControlDrawer extends ControlButton {
private void alignButtons(){
if(buttons == null) return;
if(drawerData.orientation == ControlDrawerData.Orientation.FREE) return;
int margin = (int) ControlInterface.getMarginDistance();
for(int i = 0; i < buttons.size(); ++i){
switch (drawerData.orientation){
case RIGHT:
buttons.get(i).setDynamicX(generateDynamicX(getX() + (drawerData.properties.getWidth() + Tools.dpToPx(2))*(i+1) ));
buttons.get(i).setDynamicX(generateDynamicX(getX() + (drawerData.properties.getWidth() + margin)*(i+1) ));
buttons.get(i).setDynamicY(generateDynamicY(getY()));
break;
case LEFT:
buttons.get(i).setDynamicX(generateDynamicX(getX() - (drawerData.properties.getWidth() + Tools.dpToPx(2))*(i+1)));
buttons.get(i).setDynamicX(generateDynamicX(getX() - (drawerData.properties.getWidth() + margin)*(i+1)));
buttons.get(i).setDynamicY(generateDynamicY(getY()));
break;
case UP:
buttons.get(i).setDynamicY(generateDynamicY(getY() - (drawerData.properties.getHeight() + Tools.dpToPx(2))*(i+1)));
buttons.get(i).setDynamicY(generateDynamicY(getY() - (drawerData.properties.getHeight() + margin)*(i+1)));
buttons.get(i).setDynamicX(generateDynamicX(getX()));
break;
case DOWN:
buttons.get(i).setDynamicY(generateDynamicY(getY() + (drawerData.properties.getHeight() + Tools.dpToPx(2))*(i+1)));
buttons.get(i).setDynamicY(generateDynamicY(getY() + (drawerData.properties.getHeight() + margin)*(i+1)));
buttons.get(i).setDynamicX(generateDynamicX(getX()));
break;
}
@@ -30,7 +30,6 @@ import org.lwjgl.glfw.CallbackBridge;
* sending keys has to be implemented by sub classes.
*/
public interface ControlInterface extends View.OnLongClickListener, GrabListener {
View getControlView();
ControlData getProperties();
@@ -214,7 +213,7 @@ public interface ControlInterface extends View.OnLongClickListener, GrabListener
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
default boolean canSnap(ControlInterface button) {
float MIN_DISTANCE = Tools.dpToPx(8);
float MIN_DISTANCE = getSnapDistance();
if (button == this) return false;
return !(net.kdt.pojavlaunch.utils.MathUtils.dist(
@@ -237,7 +236,7 @@ public interface ControlInterface extends View.OnLongClickListener, GrabListener
* @param y Coordinate on the y axis
*/
default void snapAndAlign(float x, float y) {
float MIN_DISTANCE = Tools.dpToPx(8);
final float MIN_DISTANCE = getSnapDistance();
String dynamicX = generateDynamicX(x);
String dynamicY = generateDynamicY(y);
@@ -404,4 +403,12 @@ public interface ControlInterface extends View.OnLongClickListener, GrabListener
return true;
}
static float getSnapDistance() {
return Tools.dpToPx(6);
}
static float getMarginDistance() {
return Tools.dpToPx(2);
}
}
@@ -16,23 +16,22 @@ public class DrawerPullButton extends View {
public DrawerPullButton(Context context) {super(context); init();}
public DrawerPullButton(Context context, @Nullable AttributeSet attrs) {super(context, attrs); init();}
private final Paint mPaint = new Paint();
private final Paint mBackgroundPaint = new Paint();
private VectorDrawableCompat mDrawable;
private void init(){
mDrawable = VectorDrawableCompat.create(getContext().getResources(), R.drawable.ic_sharp_settings_24, null);
setAlpha(0.33f);
mBackgroundPaint.setColor(Color.BLACK);
}
@Override
protected void onDraw(Canvas canvas) {
mPaint.setColor(Color.BLACK);
canvas.drawArc(0,-getHeight(),getWidth(), getHeight(), 0, 180, true, mPaint);
canvas.drawArc(getPaddingLeft(),-getHeight() + getPaddingBottom(),getWidth() - getPaddingRight(), getHeight() - getPaddingBottom(), 0, 180, true, mBackgroundPaint);
mPaint.setColor(Color.WHITE);
mDrawable.setBounds(0, 0, getHeight(), getHeight());
mDrawable.setBounds(getPaddingLeft()/2, getPaddingTop()/2, getHeight() - getPaddingRight()/2, getHeight() - getPaddingBottom()/2);
canvas.save();
canvas.translate((getWidth()-getHeight())/2f, 0);
canvas.translate((getWidth()-getHeight())/2f, -getPaddingBottom()/2f);
mDrawable.draw(canvas);
canvas.restore();
}
@@ -332,6 +332,7 @@ public class EditControlSideDialog extends SideDialogView {
/**
* A long function linking all the displayed data on the popup and,
* the currently edited mCurrentlyEditedButton
* @noinspection SuspiciousNameCombination
*/
private void setupRealTimeListeners() {
mNameEditText.addTextChangedListener((SimpleTextWatcher) s -> {
@@ -349,6 +350,10 @@ public class EditControlSideDialog extends SideDialogView {
float width = safeParseFloat(s.toString());
if (width >= 0) {
mCurrentlyEditedButton.getProperties().setWidth(width);
if (mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData) {
// Joysticks are square
mCurrentlyEditedButton.getProperties().setHeight(width);
}
mCurrentlyEditedButton.updateProperties();
}
});
@@ -359,6 +364,10 @@ public class EditControlSideDialog extends SideDialogView {
float height = safeParseFloat(s.toString());
if (height >= 0) {
mCurrentlyEditedButton.getProperties().setHeight(height);
if (mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData) {
// Joysticks are square
mCurrentlyEditedButton.getProperties().setWidth(height);
}
mCurrentlyEditedButton.updateProperties();
}
});
@@ -11,6 +11,7 @@ import android.view.ViewParent;
import androidx.annotation.Nullable;
import net.kdt.pojavlaunch.GrabListener;
import net.kdt.pojavlaunch.LwjglGlfwKeycode;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.utils.MCOptionUtils;
@@ -26,8 +27,16 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
LwjglGlfwKeycode.GLFW_KEY_4, LwjglGlfwKeycode.GLFW_KEY_5, LwjglGlfwKeycode.GLFW_KEY_6,
LwjglGlfwKeycode.GLFW_KEY_7, LwjglGlfwKeycode.GLFW_KEY_8, LwjglGlfwKeycode.GLFW_KEY_9};
private final DropGesture mDropGesture = new DropGesture(new Handler(Looper.getMainLooper()));
private final GrabListener mGrabListener = new GrabListener() {
@Override
public void onGrabState(boolean isGrabbing) {
mLastIndex = -1;
mDropGesture.cancel();
}
};
private int mWidth;
private int mLastIndex;
private int mLastIndex = -1;
private int mGuiScale;
public HotbarView(Context context) {
@@ -66,6 +75,13 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
}
mGuiScale = MCOptionUtils.getMcScale();
repositionView();
CallbackBridge.addGrabListener(mGrabListener);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallbackBridge.removeGrabListener(mGrabListener);
}
private void repositionView() {
@@ -33,8 +33,12 @@ public class InGameEventProcessor implements TouchEventProcessor {
case MotionEvent.ACTION_MOVE:
mTracker.trackEvent(motionEvent);
float[] motionVector = mTracker.getMotionVector();
CallbackBridge.mouseX += (float) (motionVector[0] * mSensitivity);
CallbackBridge.mouseY += (float) (motionVector[1] * mSensitivity);
float deltaX = (float) (motionVector[0] * mSensitivity);
float deltaY = (float) (motionVector[1] * mSensitivity);
mLeftClickGesture.setMotion(deltaX, deltaY);
mRightClickGesture.setMotion(deltaX, deltaY);
CallbackBridge.mouseX += deltaX;
CallbackBridge.mouseY += deltaY;
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
if(LauncherPreferences.PREF_DISABLE_GESTURES) break;
checkGestures();
@@ -13,7 +13,7 @@ import org.lwjgl.glfw.CallbackBridge;
public class LeftClickGesture extends ValidatorGesture {
public static final int FINGER_STILL_THRESHOLD = (int) Tools.dpToPx(9);
private float mGestureStartX, mGestureStartY;
private float mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY;
private boolean mMouseActivated;
public LeftClickGesture(Handler handler) {
@@ -22,14 +22,14 @@ public class LeftClickGesture extends ValidatorGesture {
public final void inputEvent() {
if(submit()) {
mGestureStartX = CallbackBridge.mouseX;
mGestureStartY = CallbackBridge.mouseY;
mGestureStartX = mGestureEndX = CallbackBridge.mouseX;
mGestureStartY = mGestureEndY = CallbackBridge.mouseY;
}
}
@Override
public boolean checkAndTrigger() {
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, FINGER_STILL_THRESHOLD);
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY, FINGER_STILL_THRESHOLD);
// If the finger is still, fire the gesture.
if(fingerStill) {
sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, true);
@@ -47,6 +47,11 @@ public class LeftClickGesture extends ValidatorGesture {
}
}
public void setMotion(float deltaX, float deltaY) {
mGestureEndX += deltaX;
mGestureEndY += deltaY;
}
/**
* Check if the finger is still when compared to mouseX/mouseY in CallbackBridge.
* @param startX the starting X of the gesture
@@ -61,4 +66,13 @@ public class LeftClickGesture extends ValidatorGesture {
startY
) <= threshold;
}
public static boolean isFingerStill(float startX, float startY, float endX, float endY, float threshold) {
return MathUtils.dist(
endX,
endY,
startX,
startY
) <= threshold;
}
}
@@ -9,7 +9,7 @@ import org.lwjgl.glfw.CallbackBridge;
public class RightClickGesture extends ValidatorGesture{
private boolean mGestureEnabled = true;
private boolean mGestureValid = true;
private float mGestureStartX, mGestureStartY;
private float mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY;
public RightClickGesture(Handler mHandler) {
super(mHandler, 150);
}
@@ -24,6 +24,11 @@ public class RightClickGesture extends ValidatorGesture{
}
}
public void setMotion(float deltaX, float deltaY) {
mGestureEndX += deltaX;
mGestureEndY += deltaY;
}
@Override
public boolean checkAndTrigger() {
// If the validate() method was called, it means that the user held on for too long. The cancellation should be ignored.
@@ -38,7 +43,7 @@ public class RightClickGesture extends ValidatorGesture{
public void onGestureCancelled(boolean isSwitching) {
mGestureEnabled = true;
if(!mGestureValid || isSwitching) return;
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, LeftClickGesture.FINGER_STILL_THRESHOLD);
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY, LeftClickGesture.FINGER_STILL_THRESHOLD);
if(!fingerStill) return;
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, true);
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, false);
@@ -107,7 +107,28 @@ public class ProfileEditorFragment extends Fragment implements CropperUtils.Crop
Tools.removeCurrentFragment(requireActivity());
});
mGameDirButton.setOnClickListener(v -> {
View.OnClickListener gameDirListener = getGameDirListener();
mGameDirButton.setOnClickListener(gameDirListener);
mDefaultPath.setOnClickListener(gameDirListener);
View.OnClickListener controlSelectListener = getControlSelectListener();
mControlSelectButton.setOnClickListener(controlSelectListener);
mDefaultControl.setOnClickListener(controlSelectListener);
// Setup the expendable list behavior
View.OnClickListener versionSelectListener = getVersionSelectListener();
mVersionSelectButton.setOnClickListener(versionSelectListener);
mDefaultVersion.setOnClickListener(versionSelectListener);
// Set up the icon change click listener
mProfileIcon.setOnClickListener(v -> CropperUtils.startCropper(mCropperLauncher));
loadValues(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE, ""), view.getContext());
}
private View.OnClickListener getGameDirListener() {
return v -> {
Bundle bundle = new Bundle(2);
bundle.putBoolean(FileSelectorFragment.BUNDLE_SELECT_FOLDER, true);
bundle.putString(FileSelectorFragment.BUNDLE_ROOT_PATH, Tools.DIR_GAME_HOME);
@@ -116,9 +137,11 @@ public class ProfileEditorFragment extends Fragment implements CropperUtils.Crop
Tools.swapFragment(requireActivity(),
FileSelectorFragment.class, FileSelectorFragment.TAG, bundle);
});
};
}
mControlSelectButton.setOnClickListener(v -> {
private View.OnClickListener getControlSelectListener() {
return v -> {
Bundle bundle = new Bundle(3);
bundle.putBoolean(FileSelectorFragment.BUNDLE_SELECT_FOLDER, false);
bundle.putString(FileSelectorFragment.BUNDLE_ROOT_PATH, Tools.CTRLMAP_PATH);
@@ -126,20 +149,14 @@ public class ProfileEditorFragment extends Fragment implements CropperUtils.Crop
Tools.swapFragment(requireActivity(),
FileSelectorFragment.class, FileSelectorFragment.TAG, bundle);
});
};
}
// Setup the expendable list behavior
mVersionSelectButton.setOnClickListener(v -> VersionSelectorDialog.open(v.getContext(), false, (id, snapshot)->{
private View.OnClickListener getVersionSelectListener() {
return v -> VersionSelectorDialog.open(v.getContext(), false, (id, snapshot)-> {
mTempProfile.lastVersionId = id;
mDefaultVersion.setText(id);
}));
// Set up the icon change click listener
mProfileIcon.setOnClickListener(v -> CropperUtils.startCropper(mCropperLauncher));
loadValues(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE, ""), view.getContext());
});
}
@@ -13,6 +13,7 @@ import android.os.Process;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import net.kdt.pojavlaunch.MainActivity;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.utils.NotificationUtils;
@@ -39,9 +40,14 @@ public class GameService extends Service {
killIntent.putExtra("kill", true);
PendingIntent pendingKillIntent = PendingIntent.getService(this, NotificationUtils.PENDINGINTENT_CODE_KILL_GAME_SERVICE
, killIntent, Build.VERSION.SDK_INT >=23 ? PendingIntent.FLAG_IMMUTABLE : 0);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT),
PendingIntent.FLAG_IMMUTABLE);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "channel_id")
.setContentTitle(getString(R.string.lazy_service_default_title))
.setContentText(getString(R.string.notification_game_runs))
.setContentIntent(contentIntent)
.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.notification_terminate), pendingKillIntent)
.setSmallIcon(R.drawable.notif_icon)
.setNotificationSilent();
@@ -2,8 +2,10 @@ package org.lwjgl.glfw;
import net.kdt.pojavlaunch.*;
import android.content.*;
import android.util.Log;
import android.view.Choreographer;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
import java.util.ArrayList;
@@ -102,6 +104,7 @@ public class CallbackBridge {
// Called from JRE side
@SuppressWarnings("unused")
@Keep
public static @Nullable String accessAndroidClipboard(int type, String copy) {
switch (type) {
case CLIPBOARD_COPY:
@@ -164,6 +167,7 @@ public class CallbackBridge {
//Called from JRE side
@SuppressWarnings("unused")
@Keep
private static void onGrabStateChanged(final boolean grabbing) {
isGrabbing = grabbing;
sChoreographer.postFrameCallbackDelayed((time) -> {
@@ -190,17 +194,17 @@ public class CallbackBridge {
}
}
@CriticalNative public static native void nativeSetUseInputStackQueue(boolean useInputStackQueue);
@Keep @CriticalNative public static native void nativeSetUseInputStackQueue(boolean useInputStackQueue);
@CriticalNative private static native boolean nativeSendChar(char codepoint);
@Keep @CriticalNative private static native boolean nativeSendChar(char codepoint);
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
@CriticalNative private static native boolean nativeSendCharMods(char codepoint, int mods);
@CriticalNative private static native void nativeSendKey(int key, int scancode, int action, int mods);
@Keep @CriticalNative private static native boolean nativeSendCharMods(char codepoint, int mods);
@Keep @CriticalNative private static native void nativeSendKey(int key, int scancode, int action, int mods);
// private static native void nativeSendCursorEnter(int entered);
@CriticalNative private static native void nativeSendCursorPos(float x, float y);
@CriticalNative private static native void nativeSendMouseButton(int button, int action, int mods);
@CriticalNative private static native void nativeSendScroll(double xoffset, double yoffset);
@CriticalNative private static native void nativeSendScreenSize(int width, int height);
@Keep @CriticalNative private static native void nativeSendCursorPos(float x, float y);
@Keep @CriticalNative private static native void nativeSendMouseButton(int button, int action, int mods);
@Keep @CriticalNative private static native void nativeSendScroll(double xoffset, double yoffset);
@Keep @CriticalNative private static native void nativeSendScreenSize(int width, int height);
public static native void nativeSetWindowAttrib(int attrib, int value);
static {
System.loadLibrary("pojavexec");
@@ -620,6 +620,7 @@ static bool tryCriticalNative(JNIEnv *env) {
};
jclass criticalNativeTest = (*env)->FindClass(env, "net/kdt/pojavlaunch/CriticalNativeTest");
if(criticalNativeTest == NULL) {
LOGD("No CriticalNativeTest class found !");
(*env)->ExceptionClear(env);
return false;
}
@@ -51,8 +51,9 @@
<net.kdt.pojavlaunch.customcontrols.handleview.DrawerPullButton
android:id="@+id/drawer_button"
android:layout_width="24dp"
android:layout_height="12dp"
android:layout_width="40dp"
android:layout_height="20dp"
android:padding="8dp"
android:elevation="10dp"
android:layout_gravity="center_horizontal"/>
<net.kdt.pojavlaunch.customcontrols.mouse.HotbarView
@@ -15,8 +15,9 @@
<net.kdt.pojavlaunch.customcontrols.handleview.DrawerPullButton
android:id="@+id/drawer_button"
android:layout_width="32dp"
android:layout_height="16dp"
android:layout_width="40dp"
android:layout_height="20dp"
android:padding="6dp"
android:elevation="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
+2
View File
@@ -5,3 +5,5 @@ android.useAndroidX=true
android.bundle.language.enableSplit=false
# Increase Gradle daemon RAM allocation
org.gradle.jvmargs=-Xmx4096M
android.nonTransitiveRClass=false
android.nonFinalResIds=false
Binary file not shown.
+3 -1
View File
@@ -1,6 +1,8 @@
#Fri Dec 06 21:56:04 CET 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+17 -12
View File
@@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \