mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 06:39:54 -04:00
Fix unconverted version go to run
This commit is contained in:
parent
420d9af8b2
commit
125e2f4a5e
@ -75,8 +75,8 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
AndroidDisplay.windowHeight = dm.heightPixels;
|
AndroidDisplay.windowHeight = dm.heightPixels;
|
||||||
viewInit();
|
viewInit();
|
||||||
}
|
}
|
||||||
// DEBUG
|
// DEBUG
|
||||||
//new android.support.design.widget.NavigationView(this);
|
//new android.support.design.widget.NavigationView(this);
|
||||||
|
|
||||||
private String getStr(int id, Object... val) {
|
private String getStr(int id, Object... val) {
|
||||||
if (val != null && val.length > 0) {
|
if (val != null && val.length > 0) {
|
||||||
@ -165,77 +165,77 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
|
|
||||||
public class RefreshVersionListTask extends AsyncTask<Void, Void, ArrayList<String>>{
|
public class RefreshVersionListTask extends AsyncTask<Void, Void, ArrayList<String>>{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ArrayList<String> doInBackground(Void[] p1)
|
protected ArrayList<String> doInBackground(Void[] p1)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
versionList = gson.fromJson(DownloadUtils.downloadString("https://launchermeta.mojang.com/mc/game/version_manifest.json"), JMinecraftVersionList.class);
|
versionList = gson.fromJson(DownloadUtils.downloadString("https://launchermeta.mojang.com/mc/game/version_manifest.json"), JMinecraftVersionList.class);
|
||||||
ArrayList<String> versionStringList = filter(versionList.versions, new File(Tools.versnDir).listFiles());
|
ArrayList<String> versionStringList = filter(versionList.versions, new File(Tools.versnDir).listFiles());
|
||||||
|
|
||||||
return versionStringList;
|
return versionStringList;
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(ArrayList<String> result)
|
protected void onPostExecute(ArrayList<String> result)
|
||||||
{
|
{
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
|
|
||||||
final PopupMenu popup = new PopupMenu(MCLauncherActivity.this, versionSelector);
|
final PopupMenu popup = new PopupMenu(MCLauncherActivity.this, versionSelector);
|
||||||
popup.getMenuInflater().inflate(R.menu.menu_versionopt, popup.getMenu());
|
popup.getMenuInflater().inflate(R.menu.menu_versionopt, popup.getMenu());
|
||||||
|
|
||||||
if(result != null && result.size() > 0) {
|
if(result != null && result.size() > 0) {
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MCLauncherActivity.this, android.R.layout.simple_spinner_item, result);
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MCLauncherActivity.this, android.R.layout.simple_spinner_item, result);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
||||||
versionSelector.setAdapter(adapter);
|
versionSelector.setAdapter(adapter);
|
||||||
versionSelector.setSelection(selectAt(result.toArray(new String[0]), profile.getVersion()));
|
versionSelector.setSelection(selectAt(result.toArray(new String[0]), profile.getVersion()));
|
||||||
} else {
|
} else {
|
||||||
versionSelector.setSelection(selectAt(availableVersions, profile.getVersion()));
|
versionSelector.setSelection(selectAt(availableVersions, profile.getVersion()));
|
||||||
}
|
}
|
||||||
versionSelector.setOnItemSelectedListener(new OnItemSelectedListener(){
|
versionSelector.setOnItemSelectedListener(new OnItemSelectedListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> p1, View p2, int p3, long p4)
|
public void onItemSelected(AdapterView<?> p1, View p2, int p3, long p4)
|
||||||
{
|
{
|
||||||
String version = p1.getItemAtPosition(p3).toString();
|
String version = p1.getItemAtPosition(p3).toString();
|
||||||
profile.setVersion(version);
|
profile.setVersion(version);
|
||||||
|
|
||||||
PojavProfile.setCurrentProfile(MCLauncherActivity.this, profile);
|
PojavProfile.setCurrentProfile(MCLauncherActivity.this, profile);
|
||||||
if (PojavProfile.isFileType(MCLauncherActivity.this)) {
|
if (PojavProfile.isFileType(MCLauncherActivity.this)) {
|
||||||
PojavProfile.setCurrentProfile(MCLauncherActivity.this, MCProfile.build(profile));
|
PojavProfile.setCurrentProfile(MCLauncherActivity.this, MCProfile.build(profile));
|
||||||
|
}
|
||||||
|
|
||||||
|
tvVersion.setText(getStr(R.string.mcl_version_msg, version));
|
||||||
}
|
}
|
||||||
|
|
||||||
tvVersion.setText(getStr(R.string.mcl_version_msg, version));
|
@Override
|
||||||
}
|
public void onNothingSelected(AdapterView<?> p1)
|
||||||
|
{
|
||||||
|
// TODO: Implement this method
|
||||||
|
}
|
||||||
|
});
|
||||||
|
versionSelector.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
|
||||||
|
@Override
|
||||||
|
public boolean onItemLongClick(AdapterView<?> p1, View p2, int p3, long p4)
|
||||||
|
{
|
||||||
|
// Implement copy, remove, reinstall,...
|
||||||
|
popup.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Override
|
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
public void onNothingSelected(AdapterView<?> p1)
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
{
|
return true;
|
||||||
// TODO: Implement this method
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
versionSelector.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
|
|
||||||
@Override
|
|
||||||
public boolean onItemLongClick(AdapterView<?> p1, View p2, int p3, long p4)
|
|
||||||
{
|
|
||||||
// Implement copy, remove, reinstall,...
|
|
||||||
popup.show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
tvVersion.setText(getStr(R.string.mcl_version_msg) + versionSelector.getSelectedItem());
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
tvVersion.setText(getStr(R.string.mcl_version_msg) + versionSelector.getSelectedItem());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostResume()
|
protected void onPostResume()
|
||||||
@ -341,34 +341,34 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
|
|
||||||
new Thread(new Runnable(){
|
new Thread(new Runnable(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
while (consoleView == null) {
|
while (consoleView == null) {
|
||||||
try {
|
|
||||||
Thread.sleep(20);
|
|
||||||
} catch (Throwable th) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (Throwable th) {}
|
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
consoleView.putLog("");
|
Thread.sleep(20);
|
||||||
barrier.dismiss();
|
} catch (Throwable th) {}
|
||||||
} catch (Throwable th) {
|
|
||||||
startActivity(getIntent());
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
try {
|
||||||
}).start();
|
Thread.sleep(100);
|
||||||
|
} catch (Throwable th) {}
|
||||||
|
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
consoleView.putLog("");
|
||||||
|
barrier.dismiss();
|
||||||
|
} catch (Throwable th) {
|
||||||
|
startActivity(getIntent());
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
File lastCrashFile = Tools.lastFileModified(Tools.crashPath);
|
File lastCrashFile = Tools.lastFileModified(Tools.crashPath);
|
||||||
if(CrashFragment.isNewCrash(lastCrashFile) || !crashView.getLastCrash().isEmpty()){
|
if(CrashFragment.isNewCrash(lastCrashFile) || !crashView.getLastCrash().isEmpty()){
|
||||||
@ -523,7 +523,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
libItem.name.startsWith("net.minecraft.launchwrapper") ||
|
libItem.name.startsWith("net.minecraft.launchwrapper") ||
|
||||||
libItem.name.startsWith("org.lwjgl.lwjgl:lwjgl") ||
|
libItem.name.startsWith("org.lwjgl.lwjgl:lwjgl") ||
|
||||||
libItem.name.startsWith("tv.twitch")
|
libItem.name.startsWith("tv.twitch")
|
||||||
) { // Black list
|
) { // Black list
|
||||||
publishProgress("1", "Ignored " + libItem.name);
|
publishProgress("1", "Ignored " + libItem.name);
|
||||||
//Thread.sleep(100);
|
//Thread.sleep(100);
|
||||||
} else {
|
} else {
|
||||||
@ -579,12 +579,12 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
publishProgress("0", convertStr + ": (" + currProg + "/" + maxProg + ") " + step, "");
|
publishProgress("0", convertStr + ": (" + currProg + "/" + maxProg + ") " + step, "");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
if (!new File(outDexedLib + "/finish").exists()) {
|
if (!new File(outDexedLib + "/finish").exists()) {
|
||||||
toast("Unable to convert library " + libItem.name + " but still continue. Is it a wrong check?");
|
toast("Unable to convert library " + libItem.name + " but still continue. Is it a wrong check?");
|
||||||
//throw new RuntimeException("Unable to convert library " + libItem.name);
|
//throw new RuntimeException("Unable to convert library " + libItem.name);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!outDexedLib.exists()) {
|
if (!outDexedLib.exists()) {
|
||||||
RuntimeException dxError = new RuntimeException(getResources().getString(R.string.error_convert_lib, libItem.name) + "\n" + currentLog.toString());
|
RuntimeException dxError = new RuntimeException(getResources().getString(R.string.error_convert_lib, libItem.name) + "\n" + currentLog.toString());
|
||||||
@ -600,11 +600,8 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
publishProgress("5", getStr(R.string.mcl_launch_download_client) + p1[0]);
|
publishProgress("5", getStr(R.string.mcl_launch_download_client) + p1[0]);
|
||||||
outUnpatchedConvert = new File(unpatchedPath);
|
outUnpatchedConvert = new File(unpatchedPath);
|
||||||
boolean patchedExist = new File(patchedFile).exists();
|
boolean patchedExist = new File(patchedFile).exists();
|
||||||
System.out.println("PATCHED:" + patchedFile + ",exist:" + Boolean.toString(patchedExist));
|
|
||||||
if (!patchedExist) {
|
if (!patchedExist) {
|
||||||
System.out.println("UNPATCHED:" + outUnpatchedConvert + ",exist:" + Boolean.toString(outUnpatchedConvert.exists()));
|
|
||||||
if (!outUnpatchedConvert.exists()) {
|
if (!outUnpatchedConvert.exists()) {
|
||||||
System.out.println("INPUT:" + inputPath + ",exist:" + Boolean.toString(new File(inputPath).exists()));
|
|
||||||
if (!new File(inputPath).exists()) {
|
if (!new File(inputPath).exists()) {
|
||||||
currentLog.setLength(0);
|
currentLog.setLength(0);
|
||||||
|
|
||||||
@ -613,29 +610,29 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
inputPath,
|
inputPath,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
convertStr = getStr(R.string.mcl_launch_convert_client, p1[0]);
|
|
||||||
publishProgress("5", convertStr);
|
|
||||||
addProgress = 0;
|
|
||||||
Tools.runDx(MCLauncherActivity.this, inputPath, outUnpatchedConvert.getAbsolutePath(), new PojavDXManager.Listen(){
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceived(String step, int maxProg, int currProg)
|
|
||||||
{
|
|
||||||
maxSubProgress = maxProg;
|
|
||||||
valSubProgress = currProg;
|
|
||||||
publishProgress("0", convertStr + " (" + currProg + "/" + maxProg + ") " + step, "");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!outUnpatchedConvert.exists()) {
|
|
||||||
RuntimeException dxError = new RuntimeException(getResources().getString(R.string.error_convert_client) + "\n" + currentLog.toString());
|
|
||||||
dxError.setStackTrace(new StackTraceElement[0]);
|
|
||||||
throw dxError;
|
|
||||||
}
|
|
||||||
|
|
||||||
patchAndCleanJar(p1[0], outUnpatchedConvert.getAbsolutePath(), patchedFile);
|
|
||||||
outUnpatchedConvert.delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convertStr = getStr(R.string.mcl_launch_convert_client, p1[0]);
|
||||||
|
publishProgress("5", convertStr);
|
||||||
|
addProgress = 0;
|
||||||
|
Tools.runDx(MCLauncherActivity.this, inputPath, outUnpatchedConvert.getAbsolutePath(), new PojavDXManager.Listen(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceived(String step, int maxProg, int currProg)
|
||||||
|
{
|
||||||
|
maxSubProgress = maxProg;
|
||||||
|
valSubProgress = currProg;
|
||||||
|
publishProgress("0", convertStr + " (" + currProg + "/" + maxProg + ") " + step, "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!outUnpatchedConvert.exists()) {
|
||||||
|
RuntimeException dxError = new RuntimeException(getResources().getString(R.string.error_convert_client) + "\n" + currentLog.toString());
|
||||||
|
dxError.setStackTrace(new StackTraceElement[0]);
|
||||||
|
throw dxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
patchAndCleanJar(p1[0], outUnpatchedConvert.getAbsolutePath(), patchedFile);
|
||||||
|
outUnpatchedConvert.delete();
|
||||||
} else {
|
} else {
|
||||||
patchAndCleanJar(p1[0], outUnpatchedConvert.getAbsolutePath(), patchedFile);
|
patchAndCleanJar(p1[0], outUnpatchedConvert.getAbsolutePath(), patchedFile);
|
||||||
outUnpatchedConvert.delete();
|
outUnpatchedConvert.delete();
|
||||||
@ -741,10 +738,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
/*
|
/*
|
||||||
List<String> jvmArgs = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
List<String> jvmArgs = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
||||||
jvmArgs.add("-Xms128M");
|
jvmArgs.add("-Xms128M");
|
||||||
jvmArgs.add("-Xmx1G");
|
jvmArgs.add("-Xmx1G");
|
||||||
*/
|
*/
|
||||||
Intent mainIntent = new Intent(MCLauncherActivity.this, MainActivity.class);
|
Intent mainIntent = new Intent(MCLauncherActivity.this, MainActivity.class);
|
||||||
// mainIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
// mainIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||||
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||||
@ -765,10 +762,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
Tools.showError(MCLauncherActivity.this, e);
|
Tools.showError(MCLauncherActivity.this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FloatingIntent maini = new FloatingIntent(MCLauncherActivity.this, MainActivity.class);
|
FloatingIntent maini = new FloatingIntent(MCLauncherActivity.this, MainActivity.class);
|
||||||
maini.startFloatingActivity();
|
maini.startFloatingActivity();
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
mTask = null;
|
mTask = null;
|
||||||
@ -858,10 +855,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
aboutB.setMessage(String.format(Tools.read(getAssets().open("about_en.txt")),
|
aboutB.setMessage(String.format(Tools.read(getAssets().open("about_en.txt")),
|
||||||
Tools.APP_NAME,
|
Tools.APP_NAME,
|
||||||
Tools.usingVerName,
|
Tools.usingVerName,
|
||||||
org.lwjgl.Sys.getVersion())
|
org.lwjgl.Sys.getVersion())
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -1040,10 +1037,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
System.setOut(logOut.getRootStream());
|
System.setOut(logOut.getRootStream());
|
||||||
System.setErr(logErr.getRootStream());
|
System.setErr(logErr.getRootStream());
|
||||||
/*
|
/*
|
||||||
if (throwable != null && convertedFile != null) {
|
if (throwable != null && convertedFile != null) {
|
||||||
convertedFile.delete();
|
convertedFile.delete();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return throwable;
|
return throwable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user