Skip to content

Commit

Permalink
Merge branch 'v3_sol' into v3_sol-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
SolDev69 committed Jan 8, 2024
2 parents c366b98 + 2c80d42 commit d28122d
Show file tree
Hide file tree
Showing 112 changed files with 1,698 additions and 4,452 deletions.
6 changes: 6 additions & 0 deletions app_pojavlauncher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ android {
jniLibs {
useLegacyPackaging = true
}
pickFirst '**/libbytehook.so'
}

buildFeatures {
prefab true
}

buildToolsVersion = '33.0.2'
Expand Down Expand Up @@ -208,6 +213,7 @@ dependencies {
implementation 'org.tukaani:xz:1.8'
implementation 'com.github.PojavLauncherTeam:exp4j:60eaec6f78'
implementation 'net.sourceforge.htmlcleaner:htmlcleaner:2.6.1'
implementation 'com.bytedance:bytehook:1.0.9'

// implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.0'

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1699725139188
1703946470579
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ public mcAccountSpinner(@NonNull Context context, @Nullable AttributeSet attrs)

private final ErrorListener mErrorListener = errorMessage -> {
mLoginBarPaint.setColor(Color.RED);
Context context = getContext();
if(errorMessage instanceof PresentedException) {
PresentedException exception = (PresentedException) errorMessage;
Tools.showError(getContext(), exception.toString(getContext()), exception.getCause());
Throwable cause = exception.getCause();
if(cause == null) {
Tools.dialog(context, context.getString(R.string.global_error), exception.toString(context));
}else {
Tools.showError(context, exception.toString(context), exception.getCause());
}
}else {
Tools.showError(getContext(), errorMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public void onClick(View v) {
return;
}
mPopupWindow.showAsDropDown(mcVersionSpinner.this, 0, offset);
// Post() is required for the layout inflation phase
post(() -> mListView.setSelection(mSelectedIndex));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static boolean installNewJreIfNeeded(Activity activity, JMinecraftVersion

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

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.kdt.pojavlaunch;

import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.ClipboardManager;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
Expand All @@ -24,9 +26,11 @@
import net.kdt.pojavlaunch.utils.JREUtils;
import net.kdt.pojavlaunch.utils.MathUtils;

import org.apache.commons.io.IOUtils;
import org.lwjgl.glfw.CallbackBridge;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
Expand All @@ -47,7 +51,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
private ImageView mMousePointerImageView;
private GestureDetector mGestureDetector;

private boolean mSkipDetectMod, mIsVirtualMouseEnabled;
private boolean mIsVirtualMouseEnabled;

@SuppressLint("ClickableViewAccessibility")
@Override
Expand Down Expand Up @@ -147,40 +151,23 @@ public boolean onTouch(View v, MotionEvent event) {
try {

placeMouseAt(CallbackBridge.physicalWidth / 2f, CallbackBridge.physicalHeight / 2f);

final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
final String javaArgs = getIntent().getExtras().getString("javaArgs");
String jreName = LauncherPreferences.PREF_DEFAULT_RUNTIME;
if(modFile != null) {
int javaVersion = getJavaVersion(modFile);
if(javaVersion != -1) {
String autoselectRuntime = MultiRTUtils.getNearestJreName(javaVersion);
if (autoselectRuntime != null) jreName = autoselectRuntime;
}
}
final Runtime runtime = MultiRTUtils.forceReread(jreName);

mSkipDetectMod = getIntent().getExtras().getBoolean("skipDetectMod", false);
if(getIntent().getExtras().getBoolean("openLogOutput", false)) openLogOutput(null);
if (mSkipDetectMod) {
new Thread(() -> launchJavaRuntime(runtime, modFile, javaArgs), "JREMainThread").start();
Bundle extras = getIntent().getExtras();
if(extras == null) {
finish();
return;
}

// No skip detection
openLogOutput(null);
new Thread(() -> {
try {
// Due to time, the code here became, like, actually useless
// So it was removed
// Tbh this whole class needs a refactor...
doCustomInstall(runtime, modFile, javaArgs);
} catch (Throwable e) {
Logger.appendToLog("Install failed:");
Logger.appendToLog(Log.getStackTraceString(e));
Tools.showError(JavaGUILauncherActivity.this, e);
}
}, "Installer").start();
final String javaArgs = extras.getString("javaArgs");
final Uri resourceUri = (Uri) extras.getParcelable("modUri");
if(extras.getBoolean("openLogOutput", false)) openLogOutput(null);
if (javaArgs != null) {
startModInstaller(null, javaArgs);
}else if(resourceUri != null) {
ProgressDialog barrierDialog = Tools.getWaitingDialog(this, R.string.multirt_progress_caching);
PojavApplication.sExecutorService.execute(()->{
startModInstallerWithUri(resourceUri);
runOnUiThread(barrierDialog::dismiss);
});
}
} catch (Throwable th) {
Tools.showError(this, th, true);
}
Expand All @@ -194,6 +181,39 @@ public void handleOnBackPressed() {
});
}

private void startModInstallerWithUri(Uri uri) {
try {
File cacheFile = new File(getCacheDir(), "mod-installer-temp");
InputStream contentStream = getContentResolver().openInputStream(uri);
try (FileOutputStream fileOutputStream = new FileOutputStream(cacheFile)) {
IOUtils.copy(contentStream, fileOutputStream);
}
contentStream.close();
startModInstaller(cacheFile, null);
}catch (IOException e) {
Tools.showError(this, e, true);
}
}

private void startModInstaller(File modFile, String javaArgs) {
new Thread(() -> {
Runtime runtime = pickJreForMod(modFile);
launchJavaRuntime(runtime, modFile, javaArgs);
}, "JREMainThread").start();
}

private Runtime pickJreForMod(File modFile) {
String jreName = LauncherPreferences.PREF_DEFAULT_RUNTIME;
if(modFile != null) {
int javaVersion = getJavaVersion(modFile);
if(javaVersion != -1) {
String autoselectRuntime = MultiRTUtils.getNearestJreName(javaVersion);
if (autoselectRuntime != null) jreName = autoselectRuntime;
}
}
return MultiRTUtils.forceReread(jreName);
}

@Override
public void onResume() {
super.onResume();
Expand Down Expand Up @@ -313,13 +333,6 @@ public void launchJavaRuntime(Runtime runtime, File modFile, String javaArgs) {
}
}



private void doCustomInstall(Runtime runtime, File modFile, String javaArgs) {
mSkipDetectMod = true;
launchJavaRuntime(runtime, modFile, javaArgs);
}

public void toggleKeyboard(View view) {
mTouchCharInput.switchKeyboardState();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import net.kdt.pojavlaunch.tasks.AsyncMinecraftDownloader;
import net.kdt.pojavlaunch.tasks.AsyncVersionList;
import net.kdt.pojavlaunch.lifecycle.ContextAwareDoneListener;
import net.kdt.pojavlaunch.tasks.MinecraftDownloader;
import net.kdt.pojavlaunch.utils.NotificationUtils;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
Expand Down Expand Up @@ -132,7 +133,7 @@ public void onFragmentResumed(@NonNull FragmentManager fm, @NonNull Fragment f)
}
String normalizedVersionId = AsyncMinecraftDownloader.normalizeVersionId(prof.lastVersionId);
JMinecraftVersionList.Version mcVersion = AsyncMinecraftDownloader.getListedVersion(normalizedVersionId);
new AsyncMinecraftDownloader().start(
new MinecraftDownloader().start(
this,
mcVersion,
normalizedVersionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.kdt.pojavlaunch.lifecycle.ContextExecutor;
import net.kdt.pojavlaunch.tasks.AsyncAssetManager;
import net.kdt.pojavlaunch.utils.*;
import net.kdt.pojavlaunch.utils.FileUtils;

public class PojavApplication extends Application {
public static final String CRASH_REPORT_TAG = "PojavCrashReport";
Expand All @@ -35,10 +36,7 @@ public void onCreate() {
File crashFile = new File(storagePermAllowed ? Tools.DIR_GAME_HOME : Tools.DIR_DATA, "latestcrash.txt");
try {
// Write to file, since some devices may not able to show error
File crashHome = crashFile.getParentFile();
if(crashHome != null && !crashHome.exists() && !crashHome.mkdirs()) {
throw new IOException("Failed to create crash log home");
}
FileUtils.ensureParentDirectory(crashFile);
PrintStream crashStream = new PrintStream(crashFile);
crashStream.append("PojavLauncher crash report\n");
crashStream.append(" - Time: ").append(DateFormat.getDateTimeInstance().format(new Date())).append("\n");
Expand Down
Loading

0 comments on commit d28122d

Please sign in to comment.