Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploate grab workaround to mainline #5739

Merged
merged 10 commits into from
Jul 3, 2024
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ body:
Give us some details into the problem, and how this affects it.
placeholder: 'Example: You should add a version selector because of the text box being too small.'
validations:
required: false
required: true

- type: textarea
attributes:
Expand All @@ -20,7 +20,7 @@ body:
What do you want to see changed, added, or removed? Make sure to be specific.
placeholder: 'Example: A scrollable version picker.'
validations:
required: false
required: true

- type: textarea
attributes:
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,19 @@ jobs:
path: app_pojavlauncher/src/main/assets/components/jre-new
workflow_conclusion: success
repo: PojavLauncherTeam/android-openjdk-build-multiarch
branch: buildjre17
branch: buildjre17-21
name: jre17-pojav

- name: Get JRE21
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
path: app_pojavlauncher/src/main/assets/components/jre-21
workflow_conclusion: success
repo: PojavLauncherTeam/android-openjdk-build-multiarch
branch: buildjre17-21
name: jre21-pojav

- uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.6.1
Expand Down Expand Up @@ -80,19 +90,20 @@ jobs:
run: |
rm -r app_pojavlauncher/src/main/assets/components/jre
rm -r app_pojavlauncher/src/main/assets/components/jre-new
rm -r app_pojavlauncher/src/main/assets/components/jre-21
gradle assembleDebug
mv app_pojavlauncher/build/outputs/apk/debug/app_pojavlauncher-debug.apk out/app-debug-noruntime.apk
- name: Gen md5sums
run: |
md5sum out/app-debug.apk > out/app-debug.md5
md5sum out/app-debug-noruntime.apk > out/app-debug-noruntime.md5

- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: app-debug
path: out/app-debug.*

- name: Upload AAB
uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/build
/*/build
app_pojavlauncher/src/main/assets/components/jre
/app_pojavlauncher/src/main/assets/components/jre-new/
/app_pojavlauncher/src/main/assets/components/jre-21/
local.properties
.idea/
app_pojavlauncher/.cxx/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

## Introduction
* PojavLauncher is a Minecraft: Java Edition launcher for Android and iOS based on [Boardwalk](https://github.com/zhuowei/Boardwalk).
* This launcher can launch almost all available Minecraft versions ranging from rd-132211 to 1.19 snapshots (including Combat Test versions).
* This launcher can launch almost all available Minecraft versions ranging from rd-132211 to 1.21 snapshots (including Combat Test versions).
* Modding via Forge and Fabric are also supported.
* This repository contains source code for Android.
* For iOS/iPadOS, check out [PojavLauncher_iOS](https://github.com/PojavLauncherTeam/PojavLauncher_iOS).
Expand Down
2 changes: 1 addition & 1 deletion app_pojavlauncher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def getVersionName = {
return ("LOCAL-" + "${getDate()}")
}else {
// Used by github actions
TAG_STRING = 'edelweiss-' + "${getDate()}" + "-" + TAG_PART_COMMIT.toString().trim()
TAG_STRING = 'foxglove-' + "${getDate()}" + "-" + TAG_PART_COMMIT.toString().trim()
}

}
Expand Down
98 changes: 0 additions & 98 deletions app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JRE17Util.java

This file was deleted.

116 changes: 116 additions & 0 deletions app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/NewJREUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package net.kdt.pojavlaunch;

import static net.kdt.pojavlaunch.Architecture.archAsString;

import android.app.Activity;
import android.content.res.AssetManager;
import android.util.Log;

import net.kdt.pojavlaunch.multirt.MultiRTUtils;
import net.kdt.pojavlaunch.multirt.Runtime;
import net.kdt.pojavlaunch.utils.MathUtils;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class NewJREUtil {
private static boolean checkInternalRuntime(AssetManager assetManager, InternalRuntime internalRuntime) {
String launcher_runtime_version;
String installed_runtime_version = MultiRTUtils.readInternalRuntimeVersion(internalRuntime.name);
try {
launcher_runtime_version = Tools.read(assetManager.open(internalRuntime.path+"/version"));
}catch (IOException exc) {
//we don't have a runtime included!
//if we have one installed -> return true -> proceed (no updates but the current one should be functional)
//if we don't -> return false -> Cannot find compatible Java runtime
return installed_runtime_version != null;
}
// this implicitly checks for null, so it will unpack the runtime even if we don't have one installed
if(!launcher_runtime_version.equals(installed_runtime_version))
return unpackInternalRuntime(assetManager, internalRuntime, launcher_runtime_version);
else return true;
}

private static boolean unpackInternalRuntime(AssetManager assetManager, InternalRuntime internalRuntime, String version) {
try {
MultiRTUtils.installRuntimeNamedBinpack(
assetManager.open(internalRuntime.path+"/universal.tar.xz"),
assetManager.open(internalRuntime.path+"/bin-" + archAsString(Tools.DEVICE_ARCHITECTURE) + ".tar.xz"),
internalRuntime.name, version);
MultiRTUtils.postPrepare(internalRuntime.name);
return true;
}catch (IOException e) {
Log.e("NewJREAuto", "Internal JRE unpack failed", e);
return false;
}
}
public static InternalRuntime getInternalRuntime(String s_runtime) {
Runtime runtime = MultiRTUtils.read(s_runtime);
if(runtime == null) return null;
for(InternalRuntime internalRuntime : InternalRuntime.values()) {
if(internalRuntime.name.equals(runtime.name)) return internalRuntime;
}
return null;
}

private static InternalRuntime findAppropriateInternalRuntime(int targetVersion) {
List<InternalRuntime> runtimeList = Arrays.asList(InternalRuntime.values());
return MathUtils.findNearestPositive(targetVersion, runtimeList, (runtime)->runtime.majorVersion);
}

/** @return true if everything is good, false otherwise. */
public static boolean installNewJreIfNeeded(Activity activity, JMinecraftVersionList.Version versionInfo) {
//Now we have the reliable information to check if our runtime settings are good enough
if (versionInfo.javaVersion == null || versionInfo.javaVersion.component.equalsIgnoreCase("jre-legacy"))
return true;

LauncherProfiles.load();
MinecraftProfile minecraftProfile = LauncherProfiles.getCurrentProfile();
String selectedRuntime = Tools.getSelectedRuntime(minecraftProfile);
Runtime runtime = MultiRTUtils.read(selectedRuntime);
if (runtime.javaVersion >= versionInfo.javaVersion.majorVersion) {
return true;
}

String appropriateRuntime = MultiRTUtils.getNearestJreName(versionInfo.javaVersion.majorVersion);
boolean failOnMiss = false;
InternalRuntime internalRuntime;
if(appropriateRuntime == null) {
internalRuntime = NewJREUtil.findAppropriateInternalRuntime(versionInfo.javaVersion.majorVersion);
failOnMiss = true;
}else {
internalRuntime = NewJREUtil.getInternalRuntime(appropriateRuntime);
}

if((internalRuntime == null || !NewJREUtil.checkInternalRuntime(activity.getAssets(), internalRuntime)) && failOnMiss) {
showRuntimeFail(activity, versionInfo);
return false;
}

minecraftProfile.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX + appropriateRuntime;
LauncherProfiles.write();
return true;
}

private static void showRuntimeFail(Activity activity, JMinecraftVersionList.Version verInfo) {
Tools.dialogOnUiThread(activity, activity.getString(R.string.global_error),
activity.getString(R.string.multirt_nocompatiblert, verInfo.javaVersion.majorVersion));
}

private enum InternalRuntime {
JRE_17(17, "Internal-17", "components/jre-new"),
JRE_21(21, "Internal-21", "components/jre-21");
public final int majorVersion;
public final String name;
public final String path;
InternalRuntime(int majorVersion, String name, String path) {
this.majorVersion = majorVersion;
this.name = name;
this.path = path;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public InGUIEventProcessor(float scaleFactor) {

@Override
public boolean processTouchEvent(MotionEvent motionEvent) {
boolean singleTap = mSingleTapDetector.onTouchEvent(motionEvent);

switch (motionEvent.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
mTracker.startTracking(motionEvent);
Expand Down Expand Up @@ -66,13 +68,17 @@ public boolean processTouchEvent(MotionEvent motionEvent) {
case MotionEvent.ACTION_UP:
mScroller.resetScrollOvershoot();
mTracker.cancelTracking();

// Handle single tap on gestures
if((!LauncherPreferences.PREF_DISABLE_GESTURES || touchpadDisplayed()) && !mIsMouseDown && singleTap) {
CallbackBridge.putMouseEventWithCoords(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, CallbackBridge.mouseX, CallbackBridge.mouseY);
}

if(mIsMouseDown) disableMouse();
resetGesture();
}

if((!LauncherPreferences.PREF_DISABLE_GESTURES || touchpadDisplayed()) && mSingleTapDetector.onTouchEvent(motionEvent)) {
clickMouse();
}

return true;
}

Expand All @@ -98,14 +104,9 @@ private void disableMouse() {
mIsMouseDown = false;
}

private void clickMouse() {
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, true);
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, false);
}

private void setGestureStart(MotionEvent event) {
mStartX = event.getX();
mStartY = event.getY();
mStartX = event.getX() * mScaleFactor;
mStartY = event.getY() * mScaleFactor;
}

private void resetGesture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TapDetector {
public final static int DETECTION_METHOD_UP = 0x2;
public final static int DETECTION_METHOD_BOTH = 0x3; //Unused for now

private final static int TAP_MIN_DELTA_MS = 10;
private final static int TAP_MIN_DELTA_MS = -1;
private final static int TAP_MAX_DELTA_MS = 300;
private final static int TAP_SLOP_SQUARE_PX = (int) Tools.dpToPx(2500);

Expand Down
Loading
Loading