mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 23:28:52 -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;
|
||||
viewInit();
|
||||
}
|
||||
// DEBUG
|
||||
//new android.support.design.widget.NavigationView(this);
|
||||
// DEBUG
|
||||
//new android.support.design.widget.NavigationView(this);
|
||||
|
||||
private String getStr(int id, Object... val) {
|
||||
if (val != null && val.length > 0) {
|
||||
@ -165,77 +165,77 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
|
||||
public class RefreshVersionListTask extends AsyncTask<Void, Void, ArrayList<String>>{
|
||||
|
||||
@Override
|
||||
protected ArrayList<String> doInBackground(Void[] p1)
|
||||
{
|
||||
try{
|
||||
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());
|
||||
@Override
|
||||
protected ArrayList<String> doInBackground(Void[] p1)
|
||||
{
|
||||
try{
|
||||
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());
|
||||
|
||||
return versionStringList;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return versionStringList;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(ArrayList<String> result)
|
||||
{
|
||||
super.onPostExecute(result);
|
||||
@Override
|
||||
protected void onPostExecute(ArrayList<String> result)
|
||||
{
|
||||
super.onPostExecute(result);
|
||||
|
||||
final PopupMenu popup = new PopupMenu(MCLauncherActivity.this, versionSelector);
|
||||
popup.getMenuInflater().inflate(R.menu.menu_versionopt, popup.getMenu());
|
||||
final PopupMenu popup = new PopupMenu(MCLauncherActivity.this, versionSelector);
|
||||
popup.getMenuInflater().inflate(R.menu.menu_versionopt, popup.getMenu());
|
||||
|
||||
if(result != null && result.size() > 0) {
|
||||
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);
|
||||
versionSelector.setAdapter(adapter);
|
||||
versionSelector.setSelection(selectAt(result.toArray(new String[0]), profile.getVersion()));
|
||||
} else {
|
||||
versionSelector.setSelection(selectAt(availableVersions, profile.getVersion()));
|
||||
}
|
||||
versionSelector.setOnItemSelectedListener(new OnItemSelectedListener(){
|
||||
if(result != null && result.size() > 0) {
|
||||
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);
|
||||
versionSelector.setAdapter(adapter);
|
||||
versionSelector.setSelection(selectAt(result.toArray(new String[0]), profile.getVersion()));
|
||||
} else {
|
||||
versionSelector.setSelection(selectAt(availableVersions, profile.getVersion()));
|
||||
}
|
||||
versionSelector.setOnItemSelectedListener(new OnItemSelectedListener(){
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> p1, View p2, int p3, long p4)
|
||||
{
|
||||
String version = p1.getItemAtPosition(p3).toString();
|
||||
profile.setVersion(version);
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> p1, View p2, int p3, long p4)
|
||||
{
|
||||
String version = p1.getItemAtPosition(p3).toString();
|
||||
profile.setVersion(version);
|
||||
|
||||
PojavProfile.setCurrentProfile(MCLauncherActivity.this, profile);
|
||||
if (PojavProfile.isFileType(MCLauncherActivity.this)) {
|
||||
PojavProfile.setCurrentProfile(MCLauncherActivity.this, MCProfile.build(profile));
|
||||
PojavProfile.setCurrentProfile(MCLauncherActivity.this, profile);
|
||||
if (PojavProfile.isFileType(MCLauncherActivity.this)) {
|
||||
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
|
||||
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;
|
||||
}
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
tvVersion.setText(getStr(R.string.mcl_version_msg) + versionSelector.getSelectedItem());
|
||||
tvVersion.setText(getStr(R.string.mcl_version_msg) + versionSelector.getSelectedItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostResume()
|
||||
@ -341,34 +341,34 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
|
||||
new Thread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
while (consoleView == null) {
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (Throwable th) {}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (Throwable th) {}
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
while (consoleView == null) {
|
||||
try {
|
||||
consoleView.putLog("");
|
||||
barrier.dismiss();
|
||||
} catch (Throwable th) {
|
||||
startActivity(getIntent());
|
||||
finish();
|
||||
}
|
||||
Thread.sleep(20);
|
||||
} catch (Throwable th) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
|
||||
try {
|
||||
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);
|
||||
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("org.lwjgl.lwjgl:lwjgl") ||
|
||||
libItem.name.startsWith("tv.twitch")
|
||||
) { // Black list
|
||||
) { // Black list
|
||||
publishProgress("1", "Ignored " + libItem.name);
|
||||
//Thread.sleep(100);
|
||||
} else {
|
||||
@ -579,12 +579,12 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
publishProgress("0", convertStr + ": (" + currProg + "/" + maxProg + ") " + step, "");
|
||||
}
|
||||
});
|
||||
/*
|
||||
if (!new File(outDexedLib + "/finish").exists()) {
|
||||
toast("Unable to convert library " + libItem.name + " but still continue. Is it a wrong check?");
|
||||
//throw new RuntimeException("Unable to convert library " + libItem.name);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (!new File(outDexedLib + "/finish").exists()) {
|
||||
toast("Unable to convert library " + libItem.name + " but still continue. Is it a wrong check?");
|
||||
//throw new RuntimeException("Unable to convert library " + libItem.name);
|
||||
}
|
||||
*/
|
||||
|
||||
if (!outDexedLib.exists()) {
|
||||
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]);
|
||||
outUnpatchedConvert = new File(unpatchedPath);
|
||||
boolean patchedExist = new File(patchedFile).exists();
|
||||
System.out.println("PATCHED:" + patchedFile + ",exist:" + Boolean.toString(patchedExist));
|
||||
if (!patchedExist) {
|
||||
System.out.println("UNPATCHED:" + outUnpatchedConvert + ",exist:" + Boolean.toString(outUnpatchedConvert.exists()));
|
||||
if (!outUnpatchedConvert.exists()) {
|
||||
System.out.println("INPUT:" + inputPath + ",exist:" + Boolean.toString(new File(inputPath).exists()));
|
||||
if (!new File(inputPath).exists()) {
|
||||
currentLog.setLength(0);
|
||||
|
||||
@ -613,29 +610,29 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
inputPath,
|
||||
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 {
|
||||
patchAndCleanJar(p1[0], outUnpatchedConvert.getAbsolutePath(), patchedFile);
|
||||
outUnpatchedConvert.delete();
|
||||
@ -741,10 +738,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
|
||||
try {
|
||||
/*
|
||||
List<String> jvmArgs = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
||||
jvmArgs.add("-Xms128M");
|
||||
jvmArgs.add("-Xmx1G");
|
||||
*/
|
||||
List<String> jvmArgs = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
||||
jvmArgs.add("-Xms128M");
|
||||
jvmArgs.add("-Xmx1G");
|
||||
*/
|
||||
Intent mainIntent = new Intent(MCLauncherActivity.this, MainActivity.class);
|
||||
// mainIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
@ -765,10 +762,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
Tools.showError(MCLauncherActivity.this, e);
|
||||
}
|
||||
|
||||
/*
|
||||
FloatingIntent maini = new FloatingIntent(MCLauncherActivity.this, MainActivity.class);
|
||||
maini.startFloatingActivity();
|
||||
*/
|
||||
/*
|
||||
FloatingIntent maini = new FloatingIntent(MCLauncherActivity.this, MainActivity.class);
|
||||
maini.startFloatingActivity();
|
||||
*/
|
||||
}
|
||||
|
||||
mTask = null;
|
||||
@ -858,10 +855,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
try
|
||||
{
|
||||
aboutB.setMessage(String.format(Tools.read(getAssets().open("about_en.txt")),
|
||||
Tools.APP_NAME,
|
||||
Tools.usingVerName,
|
||||
org.lwjgl.Sys.getVersion())
|
||||
);
|
||||
Tools.APP_NAME,
|
||||
Tools.usingVerName,
|
||||
org.lwjgl.Sys.getVersion())
|
||||
);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -1040,10 +1037,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
System.setOut(logOut.getRootStream());
|
||||
System.setErr(logErr.getRootStream());
|
||||
/*
|
||||
if (throwable != null && convertedFile != null) {
|
||||
convertedFile.delete();
|
||||
}
|
||||
*/
|
||||
if (throwable != null && convertedFile != null) {
|
||||
convertedFile.delete();
|
||||
}
|
||||
*/
|
||||
return throwable;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user