mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
Remove update option, more work at custom control
This commit is contained in:
parent
da136c0011
commit
325835ddaa
@ -46,12 +46,6 @@
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"/>
|
||||
|
||||
<activity
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:label="@string/update_console"
|
||||
android:name=".UpdateAppActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"/>
|
||||
|
||||
<activity
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:name=".prefs.LauncherPreferenceActivity"
|
||||
|
@ -1,55 +0,0 @@
|
||||
package com.kdtapi.mclup;
|
||||
|
||||
import android.content.*;
|
||||
import android.os.*;
|
||||
import android.util.*;
|
||||
import android.widget.*;
|
||||
import java.io.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
|
||||
public abstract class UpContext
|
||||
{
|
||||
public abstract void onCreate() throws Exception;
|
||||
public abstract void onFinish();
|
||||
public abstract void onErrorw(String message);
|
||||
|
||||
private UpdateAppActivity activity;
|
||||
public UpContext(UpdateAppActivity activity)
|
||||
{
|
||||
this.activity = activity;
|
||||
}
|
||||
public Context getContext()
|
||||
{
|
||||
return getUpActivity();
|
||||
}
|
||||
public UpdateAppActivity getUpActivity()
|
||||
{
|
||||
return activity;
|
||||
}
|
||||
public void onRun()
|
||||
{
|
||||
new AsyncTask<Void, Void, Void>(){
|
||||
@Override
|
||||
protected Void doInBackground(Void[] p1)
|
||||
{
|
||||
try{
|
||||
onCreate();
|
||||
onFinish();
|
||||
new File(Tools.worksDir + "/installer.jar").delete();
|
||||
}
|
||||
catch(Exception e){
|
||||
onErrorw(Log.getStackTraceString(e));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
public ProgressBar getProgressBar()
|
||||
{
|
||||
return activity.getProgressBar();
|
||||
}
|
||||
public void log(String message)
|
||||
{
|
||||
activity.putLog(message);
|
||||
}
|
||||
}
|
@ -203,7 +203,22 @@ public class AndroidLWJGLKeycode {
|
||||
}
|
||||
|
||||
public static void execKeyIndex(MainActivity mainActivity, int index) {
|
||||
mainActivity.sendKeyPress(androidToLwjglMap.valueAt(index));
|
||||
mainActivity.sendKeyPress(getKeyIndex(index));
|
||||
}
|
||||
|
||||
public static int getKeyIndex(int index) {
|
||||
return androidToLwjglMap.valueAt(index);
|
||||
}
|
||||
|
||||
public static int getIndexByLWJGLKey(int lwjglKey) {
|
||||
for (int i = 0; i < androidToLwjglMap.size(); i++) {
|
||||
int currKey = androidToLwjglMap.valueAt(i);
|
||||
if (currKey == lwjglKey) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class CustomControlsActivity extends AppCompatActivity
|
||||
@Override
|
||||
public void onShow(DialogInterface dialogInterface) {
|
||||
|
||||
Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
Button button = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
@ -128,18 +128,24 @@ public class CustomControlsActivity extends AppCompatActivity
|
||||
|
||||
private void actionLoad() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Select OptiFine jar file");
|
||||
builder.setTitle("Select control json file");
|
||||
builder.setPositiveButton(android.R.string.cancel, null);
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
FileListView flv = new FileListView(this);
|
||||
flv.listFileAt(Tools.CTRLMAP_PATH);
|
||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||
|
||||
@Override
|
||||
public void onFileSelected(File file, String path, String name) {
|
||||
if (name.endsWith(".json")) {
|
||||
// doInstallOptiFine(file);
|
||||
dialog.dismiss();
|
||||
try {
|
||||
mCtrl = gson.fromJson(Tools.read(path), CustomControls.class);
|
||||
ctrlLayout.loadLayout(mCtrl);
|
||||
dialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
Tools.showError(CustomControlsActivity.this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -134,7 +134,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
versions.add(fVer.getName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
versions.add(getStr(R.string.error_title) + ":");
|
||||
versions.add(getStr(com.android.internal.R.string.dlg_error_title) + ":");
|
||||
versions.add(e.getMessage());
|
||||
|
||||
} finally {
|
||||
@ -844,18 +844,15 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
case 1:{ // OptiFine installer
|
||||
installOptiFine();
|
||||
} break;
|
||||
case 2:{ // Check update
|
||||
checkUpdate();
|
||||
} break;
|
||||
case 3:{ // Custom controls
|
||||
case 2:{ // Custom controls
|
||||
if (Tools.enableDevFeatures) {
|
||||
startActivity(new Intent(MCLauncherActivity.this, CustomControlsActivity.class));
|
||||
}
|
||||
} break;
|
||||
case 4:{ // Settings
|
||||
case 3:{ // Settings
|
||||
startActivity(new Intent(MCLauncherActivity.this, LauncherPreferenceActivity.class));
|
||||
} break;
|
||||
case 5:{ // About
|
||||
case 4:{ // About
|
||||
final AlertDialog.Builder aboutB = new AlertDialog.Builder(MCLauncherActivity.this);
|
||||
aboutB.setTitle(R.string.mcl_option_about);
|
||||
try
|
||||
@ -970,7 +967,6 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
dialog = new ProgressDialog(MCLauncherActivity.this);
|
||||
dialog.setTitle("Installing OptiFine");
|
||||
dialog.setMessage("Prepaping");
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
dialog.setMax(5);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
@ -1010,7 +1006,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
String[] output = Tools.patchOptifineInstaller(MCLauncherActivity.this, file[0]);
|
||||
File patchedFile = new File(output[1]);
|
||||
|
||||
publishProgress("Converting OptiFine", null, "1", "ADD");
|
||||
publishProgress("Converting OptiFine", null, null, Integer.toString(ProgressDialog.STYLE_SPINNER));
|
||||
|
||||
System.setOut(new PrintStream(logOut));
|
||||
System.setErr(new PrintStream(logErr));
|
||||
@ -1019,7 +1015,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
@Override
|
||||
public void onReceived(String msg, int max, int current)
|
||||
{
|
||||
publishProgress("Converting OptiFine: " + msg, Integer.toString(max), Integer.toString(current), "SET");
|
||||
publishProgress("Converting OptiFine: " + msg, Integer.toString(max), null);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1032,7 +1028,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
patchedFile.delete();
|
||||
}
|
||||
|
||||
publishProgress("Launching OptiFine installer", null, "1", "ADD");
|
||||
publishProgress("Launching OptiFine installer", null, null, Integer.toString(ProgressDialog.STYLE_SPINNER));
|
||||
|
||||
File optDir = getDir("dalvik-cache", 0);
|
||||
optDir.mkdir();
|
||||
@ -1044,11 +1040,15 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
Method installerMethod = installerClass.getDeclaredMethod("doInstall", File.class);
|
||||
installerMethod.invoke(null, new File(Tools.MAIN_PATH));
|
||||
|
||||
publishProgress("(4/5) Patching OptiFine Tweaker", null, "1", "ADD");
|
||||
publishProgress("(4/5) Patching OptiFine Tweaker", null, null);
|
||||
File optifineLibFile = new File(AndroidOptiFineUtilities.optifineOutputJar);
|
||||
if (!optifineLibFile.exists()) {
|
||||
throw new FileNotFoundException(optifineLibFile.getAbsolutePath() + "\n\n--- OptiFine installer log ---\n" + currentLog.toString());
|
||||
}
|
||||
new OptiFinePatcher(optifineLibFile).saveTweaker();
|
||||
convertedFile.delete();
|
||||
|
||||
publishProgress("(5/5) Done!", null, "1", "ADD");
|
||||
publishProgress("(5/5) Done!", null, null);
|
||||
Thread.sleep(500);
|
||||
} catch (Throwable th) {
|
||||
throwable = th;
|
||||
@ -1076,12 +1076,10 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
dialog.setMessage(text[0]);
|
||||
if (text.length >= 2 && text[1] != null) {
|
||||
dialog.setMax(Integer.valueOf(text[1]));
|
||||
} if (text.length >= 3) {
|
||||
dialog.setProgress(dialog.getProgress() + 1);
|
||||
} if (text.length >= 4) {
|
||||
if (text[3].equals("ADD")) {
|
||||
dialog.setProgress(dialog.getProgress() + Integer.valueOf(text[2]));
|
||||
} else if (text[3].equals("SET")) {
|
||||
dialog.setProgress(7 + Integer.valueOf(text[2]));
|
||||
}
|
||||
dialog.setProgressStyle(Integer.parseInt(text[3]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1100,117 +1098,6 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAppProcess(final String ver)
|
||||
{
|
||||
new Thread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
DownloadUtils.downloadFile(Tools.mhomeUrl + "/installer_" + ver + ".jar", new File(Tools.worksDir + "/installer.jar"));
|
||||
startActivity(new Intent(MCLauncherActivity.this, UpdateAppActivity.class));
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
mkToast("Download failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void checkUpdate() {
|
||||
final ProgressDialog progUp = new ProgressDialog(this);
|
||||
progUp.setMessage(getStr(R.string.mcl_option_checkupdate));
|
||||
progUp.setCancelable(false);
|
||||
progUp.show();
|
||||
|
||||
new Thread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final AlertDialog.Builder alUp = new AlertDialog.Builder(MCLauncherActivity.this);
|
||||
alUp.setTitle(R.string.mcl_option_checkupdate);
|
||||
|
||||
try {
|
||||
final int myVer = Tools.usingVerCode;
|
||||
// final String currVerName = Tools.usingVerName;
|
||||
|
||||
String[] totalNewVer = DownloadUtils.downloadString(Tools.mhomeUrl + "/update.txt").split(";");
|
||||
final int newVer = Integer.parseInt(totalNewVer[1]);
|
||||
final String newVerName = totalNewVer[0];
|
||||
|
||||
//int myVer = 102;
|
||||
|
||||
runOnUiThread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(newVer != -1){
|
||||
boolean isAvailable = myVer < newVer;
|
||||
|
||||
String isNewVerAvailable =
|
||||
isAvailable ?
|
||||
"A new version is available!\nSee changelog at Launcher News tab." :
|
||||
"This launcher is up-to-date!";
|
||||
|
||||
if (myVer > newVer) {
|
||||
isNewVerAvailable = "This is an unreleased version or unofficial version?";
|
||||
}
|
||||
|
||||
alUp.setMessage(
|
||||
"Received version " + newVerName + "\n" +
|
||||
isNewVerAvailable
|
||||
);
|
||||
if(isAvailable){
|
||||
alUp.setPositiveButton("Update", new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
updateAppProcess(newVerName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else{
|
||||
alUp.setMessage("Failed to check for update. Reason: No Internet connection");
|
||||
}
|
||||
alUp.setNegativeButton(android.R.string.cancel, null);
|
||||
alUp.show();
|
||||
}
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
Log.e(Tools.APP_NAME + ".CheckUpdateError", e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
runOnUiThread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
alUp.setMessage("Failed to check for update. Reason: " + e.getMessage());
|
||||
alUp.show();
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
runOnUiThread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
progUp.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private class ViewPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
List<Fragment> fragmentList = new ArrayList<>();
|
||||
|
@ -1069,13 +1069,11 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
}
|
||||
|
||||
private void openLogOutput() {
|
||||
WindowAnimation.fadeIn(contentLog, 500);
|
||||
contentLog.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void closeLogOutput(View view) {
|
||||
//scrollLog.setVisibility(View.GONE);
|
||||
|
||||
WindowAnimation.fadeOut(contentLog, 500);
|
||||
contentLog.setVisibility(View.GONE);
|
||||
}
|
||||
/*
|
||||
private void openCanvasOutput() {
|
||||
@ -1168,7 +1166,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
public void dialogForceClose()
|
||||
{
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(R.string.mcn_exit_confirm)
|
||||
.setMessage(getResources().getString(R.string.mcn_exit_confirm, getResources().getString(com.android.internal.R.string.force_close)))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
|
||||
@ -1181,7 +1179,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
Log.w(Tools.APP_NAME, "Could not enable System.exit() method!", th);
|
||||
}
|
||||
|
||||
// If we are unable to enable exit, use method: kill myself.
|
||||
// If unable to enable exit, use method: kill self process.
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
|
||||
// Toast.makeText(MainActivity.this, "Could not exit. Please force close this app.", Toast.LENGTH_LONG).show();
|
||||
|
@ -52,6 +52,8 @@ public class PojavLoginActivity extends MineActivity
|
||||
firstLaunchPrefs = getSharedPreferences("pojav_extract", MODE_PRIVATE);
|
||||
new File(Tools.mpProfiles).mkdir();
|
||||
|
||||
// Remove vmos warning???
|
||||
/*
|
||||
if (isAndroid7() && !firstLaunchPrefs.getBoolean(PREF_IS_DONOTSHOWAGAIN_WARN, false)) {
|
||||
AlertDialog.Builder startDlg = new AlertDialog.Builder(PojavLoginActivity.this);
|
||||
startDlg.setTitle(R.string.warning_title);
|
||||
@ -109,8 +111,9 @@ public class PojavLoginActivity extends MineActivity
|
||||
|
||||
startDlg.show();
|
||||
} else {
|
||||
*/
|
||||
new InitTask().execute();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
private class InitTask extends AsyncTask<Void, String, Integer>{
|
||||
@ -550,7 +553,7 @@ public class PojavLoginActivity extends MineActivity
|
||||
{
|
||||
// TODO: Implement this method
|
||||
if(result[0].equals("ERROR")){
|
||||
Tools.dialogOnUiThread(PojavLoginActivity.this, getResources().getString(R.string.error_title), strArrToString(result));
|
||||
Tools.dialogOnUiThread(PojavLoginActivity.this, getResources().getString(com.android.internal.R.string.dlg_error_title), strArrToString(result));
|
||||
} else{
|
||||
MCProfile.Builder builder = new MCProfile.Builder();
|
||||
builder.setAccessToken(result[1]);
|
||||
|
@ -46,11 +46,7 @@ public class PojavProfile
|
||||
if (profileCon.equals(":::::")) {
|
||||
throw new RuntimeException("Profile not set or reset.");
|
||||
}
|
||||
/*
|
||||
if (true) {
|
||||
throw new RuntimeException(profilePath + ":" + new File(profilePath).exists());
|
||||
}
|
||||
*/
|
||||
|
||||
return new File(profilePath).exists();
|
||||
}
|
||||
}
|
||||
|
@ -163,71 +163,77 @@ public final class Tools
|
||||
}
|
||||
*/
|
||||
|
||||
public static void showError(Activity ctx, Throwable e)
|
||||
public static void showError(Context ctx, Throwable e)
|
||||
{
|
||||
showError(ctx, e, false);
|
||||
}
|
||||
|
||||
public static void showError(final Activity ctx, final Throwable e, final boolean exitIfOk)
|
||||
public static void showError(final Context ctx, final Throwable e, final boolean exitIfOk)
|
||||
{
|
||||
showError(ctx, e, exitIfOk, false);
|
||||
}
|
||||
|
||||
private static void showError(final Activity ctx, final Throwable e, final boolean exitIfOk, final boolean showMore)
|
||||
private static void showError(final Context ctx, final Throwable e, final boolean exitIfOk, final boolean showMore)
|
||||
{
|
||||
ctx.runOnUiThread(new Runnable(){
|
||||
Runnable runnable = new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final String errMsg = showMore ? Log.getStackTraceString(e): e.getMessage();
|
||||
new AlertDialog.Builder((Context) ctx)
|
||||
.setTitle(R.string.error_title)
|
||||
.setMessage(errMsg)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final String errMsg = showMore ? Log.getStackTraceString(e): e.getMessage();
|
||||
new AlertDialog.Builder((Context) ctx)
|
||||
.setTitle(com.android.internal.R.string.dlg_error_title)
|
||||
.setMessage(errMsg)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
if(exitIfOk) {
|
||||
if (ctx instanceof MainActivity) {
|
||||
MainActivity.fullyExit();
|
||||
} else {
|
||||
ctx.finish();
|
||||
}
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
if(exitIfOk) {
|
||||
if (ctx instanceof MainActivity) {
|
||||
MainActivity.fullyExit();
|
||||
} else if (ctx instanceof Activity) {
|
||||
((Activity) ctx).finish();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(showMore ? R.string.error_show_less : R.string.error_show_more, new DialogInterface.OnClickListener(){
|
||||
}
|
||||
})
|
||||
.setNegativeButton(showMore ? R.string.error_show_less : R.string.error_show_more, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
showError(ctx, e, exitIfOk, !showMore);
|
||||
}
|
||||
})
|
||||
.setNeutralButton(android.R.string.copy, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
showError(ctx, e, exitIfOk, !showMore);
|
||||
}
|
||||
})
|
||||
.setNeutralButton(android.R.string.copy, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
StringSelection errData = new StringSelection(errMsg);
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(errData, null);
|
||||
|
||||
if(exitIfOk) {
|
||||
if (ctx instanceof MainActivity) {
|
||||
MainActivity.fullyExit();
|
||||
} else {
|
||||
ctx.finish();
|
||||
}
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
StringSelection errData = new StringSelection(errMsg);
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(errData, null);
|
||||
|
||||
if(exitIfOk) {
|
||||
if (ctx instanceof MainActivity) {
|
||||
MainActivity.fullyExit();
|
||||
} else {
|
||||
((Activity) ctx).finish();
|
||||
}
|
||||
}
|
||||
})
|
||||
//.setNegativeButton("Report (not available)", null)
|
||||
.setCancelable(!exitIfOk)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
//.setNegativeButton("Report (not available)", null)
|
||||
.setCancelable(!exitIfOk)
|
||||
.show();
|
||||
}
|
||||
};
|
||||
|
||||
if (ctx instanceof Activity) {
|
||||
((Activity) ctx).runOnUiThread(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dialogOnUiThread(final Activity ctx, final CharSequence title, final CharSequence message) {
|
||||
|
@ -1,61 +0,0 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import android.app.*;
|
||||
import android.graphics.*;
|
||||
import android.os.*;
|
||||
import android.widget.*;
|
||||
import dalvik.system.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import android.util.*;
|
||||
|
||||
public class UpdateAppActivity extends Activity
|
||||
{
|
||||
private ProgressBar progress;
|
||||
private TextView logView;
|
||||
private boolean cancelable = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.launcher_update);
|
||||
|
||||
progress = (ProgressBar) findViewById(R.id.launcherupdateProgressBar);
|
||||
logView = (TextView) findViewById(R.id.launcherupdateLogView);
|
||||
logView.setTypeface(Typeface.MONOSPACE);
|
||||
|
||||
File inst = new File(Tools.worksDir + "/installer.jar");
|
||||
|
||||
try {
|
||||
File optDir = getDir("dalvik-cache", 0);
|
||||
optDir.mkdirs();
|
||||
|
||||
DexClassLoader mainLoader = new DexClassLoader(inst.getAbsolutePath(), optDir.getAbsolutePath(), getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.nativeLibraryDir, MainActivity.class.getClassLoader());
|
||||
Class mClass = mainLoader.loadClass("Main");
|
||||
Method method = mClass.getMethod("main", UpdateAppActivity.class);
|
||||
method.invoke(null, this);
|
||||
|
||||
} catch (Throwable th) {
|
||||
putLog("----- AN ERROR OCCURRED -----");
|
||||
putLog(Log.getStackTraceString(th));
|
||||
putLog("----- FAILED TO UPDATE! -----");
|
||||
} finally {
|
||||
cancelable = true;
|
||||
}
|
||||
}
|
||||
public void putLog(String message)
|
||||
{
|
||||
logView.append(message + "\n");
|
||||
}
|
||||
public ProgressBar getProgressBar()
|
||||
{
|
||||
return progress;
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
if (cancelable) super.onBackPressed();
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import android.view.*;
|
||||
|
||||
public class WindowAnimation
|
||||
{
|
||||
public static void fadeIn(final View view, int duration) {
|
||||
// 0.1 -> 1.0
|
||||
doFade(view, true, duration);
|
||||
}
|
||||
|
||||
public static void fadeOut(final View view, int duration) {
|
||||
// 1.0 -> 0.1
|
||||
doFade(view, false, duration);
|
||||
}
|
||||
|
||||
private static void doFade(final View view, final boolean fadeIn, int duration) {
|
||||
final long millis = ((long) duration) / 10l;
|
||||
|
||||
view.setVisibility(View.VISIBLE);
|
||||
view.setAlpha(fadeIn ? 0 : 1);
|
||||
view.setEnabled(false);
|
||||
new Thread(new Runnable(){
|
||||
private float alpha = fadeIn ? 0 : 1;
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
while (fadeIn ? alpha < 1 : alpha > 0) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException e) {}
|
||||
|
||||
if (fadeIn) alpha += 0.1;
|
||||
else alpha -= 0.1;
|
||||
|
||||
view.post(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
view.setAlpha(alpha);
|
||||
}
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
view.post(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (fadeIn) view.setEnabled(true);
|
||||
else {
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package net.kdt.pojavlaunch.value.customcontrols;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import android.view.*;
|
||||
import java.util.*;
|
||||
import android.content.*;
|
||||
|
||||
public class ControlButton
|
||||
{
|
||||
@ -10,11 +12,15 @@ public class ControlButton
|
||||
public static int SPECIALBTN_TOGGLECTRL = 1;
|
||||
|
||||
private static ControlButton[] SPECIAL_BUTTONS;
|
||||
private static String[] SPECIAL_BUTTON_NAME_ARRAY;
|
||||
|
||||
public static ControlButton[] getSpecialButtons(){
|
||||
if (SPECIAL_BUTTONS == null) {
|
||||
ControlButton keyboardBtn = new ControlButton();
|
||||
keyboardBtn.lwjglKeycode = -1;
|
||||
|
||||
ControlButton toggleCtrlBtn = new ControlButton();
|
||||
toggleCtrlBtn.lwjglKeycode = -2;
|
||||
|
||||
SPECIAL_BUTTONS = new ControlButton[]{
|
||||
keyboardBtn,
|
||||
@ -25,6 +31,18 @@ public class ControlButton
|
||||
return SPECIAL_BUTTONS;
|
||||
}
|
||||
|
||||
public static String[] buildSpecialButtonArray() {
|
||||
if (SPECIAL_BUTTON_NAME_ARRAY == null) {
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
for (ControlButton btn : getSpecialButtons()) {
|
||||
nameList.add(btn.name);
|
||||
}
|
||||
SPECIAL_BUTTON_NAME_ARRAY = nameList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
return SPECIAL_BUTTON_NAME_ARRAY;
|
||||
}
|
||||
|
||||
// Concept...
|
||||
public String name;
|
||||
public float x;
|
||||
@ -32,6 +50,7 @@ public class ControlButton
|
||||
public int width = pixelOf50dp;
|
||||
public int height = pixelOf50dp;
|
||||
public int lwjglKeycode;
|
||||
public boolean hidden;
|
||||
public boolean holdCtrl;
|
||||
public boolean holdAlt;
|
||||
public boolean holdShift;
|
||||
|
@ -20,16 +20,31 @@ public class ControlView extends Button implements OnTouchListener
|
||||
setOnTouchListener(this);
|
||||
|
||||
mGestureDetector = new GestureDetector(ctx, new SingleTapConfirm());
|
||||
|
||||
setProperties(properties);
|
||||
}
|
||||
|
||||
public ControlButton getProperties() {
|
||||
return mProperties;
|
||||
}
|
||||
|
||||
public void setProperties(ControlButton properties) {
|
||||
setProperties(properties, true);
|
||||
}
|
||||
|
||||
public void setProperties(ControlButton properties, boolean changePos) {
|
||||
mProperties = properties;
|
||||
// com.android.internal.R.string.delete
|
||||
// android.R.string.
|
||||
setText(properties.name);
|
||||
setTranslationX(moveX = properties.x);
|
||||
setTranslationY(moveY = properties.y);
|
||||
|
||||
if (changePos) {
|
||||
setTranslationX(moveX = properties.x);
|
||||
setTranslationY(moveY = properties.y);
|
||||
}
|
||||
|
||||
setLayoutParams(new FrameLayout.LayoutParams(properties.width, properties.height));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setTranslationX(float x)
|
||||
{
|
||||
@ -43,6 +58,10 @@ public class ControlView extends Button implements OnTouchListener
|
||||
mProperties.y = y;
|
||||
}
|
||||
|
||||
public void updateProperties() {
|
||||
setProperties(mProperties);
|
||||
}
|
||||
|
||||
private float moveX, moveY;
|
||||
private float downX, downY;
|
||||
@Override
|
||||
|
@ -19,6 +19,101 @@ public class ControlsLayout extends FrameLayout
|
||||
super(ctx, attrs);
|
||||
}
|
||||
|
||||
private void showCtrlOption(final ControlView view) {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
alert.setCancelable(false);
|
||||
alert.setTitle(getResources().getString(R.string.global_edit) + " " + view.getText());
|
||||
alert.setView(R.layout.control_setting);
|
||||
alert.setPositiveButton(android.R.string.ok, null);
|
||||
alert.setNegativeButton(android.R.string.cancel, null);
|
||||
alert.setNeutralButton(com.android.internal.R.string.delete, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
ControlButton.getSpecialButtons();
|
||||
|
||||
AlertDialog.Builder alert2 = new AlertDialog.Builder(getContext());
|
||||
alert2.setCancelable(false);
|
||||
alert2.setTitle(R.string.customctrl_specialkey);
|
||||
alert2.setItems(ControlButton.buildSpecialButtonArray(), new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dInterface, int position) {
|
||||
view.setProperties(ControlButton.getSpecialButtons()[position], false);
|
||||
}
|
||||
});
|
||||
alert2.setPositiveButton(android.R.string.cancel, null);
|
||||
alert2.show();
|
||||
}
|
||||
});
|
||||
final AlertDialog dialog = alert.create();
|
||||
|
||||
final ControlButton properties = view.getProperties();
|
||||
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
|
||||
@Override
|
||||
public void onShow(DialogInterface dialogInterface) {
|
||||
final LinearLayout normalBtnLayout = dialog.findViewById(R.id.controlsetting_normalbtnlayout);
|
||||
|
||||
final EditText editName = dialog.findViewById(R.id.controlsetting_edit_name);
|
||||
editName.setText(properties.name);
|
||||
|
||||
final Spinner spinnerKeycode = dialog.findViewById(R.id.controlsetting_spinner_lwjglkeycode);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item);
|
||||
|
||||
String[] specialArr = ControlButton.buildSpecialButtonArray();
|
||||
for (int i = 0; i < specialArr.length; i++) {
|
||||
specialArr[i] = "SPECIAL_" + specialArr[i];
|
||||
}
|
||||
|
||||
adapter.addAll(specialArr);
|
||||
adapter.addAll(AndroidLWJGLKeycode.generateKeyName());
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
||||
spinnerKeycode.setAdapter(adapter);
|
||||
spinnerKeycode.setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.lwjglKeycode) + 2);
|
||||
spinnerKeycode.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) {
|
||||
normalBtnLayout.setVisibility(id < 2 ? View.GONE : View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapter){
|
||||
// Unused
|
||||
}
|
||||
});
|
||||
|
||||
final CheckBox checkHidden = dialog.findViewById(R.id.controlsetting_checkbox_hidden);
|
||||
checkHidden.setChecked(properties.hidden);
|
||||
|
||||
Button button = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view2) {
|
||||
if (editName.getText().toString().isEmpty()) {
|
||||
editName.setError(getResources().getString(R.string.global_error_field_empty));
|
||||
} else {
|
||||
properties.lwjglKeycode = AndroidLWJGLKeycode.getKeyIndex(spinnerKeycode.getSelectedItemPosition()) - 2;
|
||||
properties.name = editName.getText().toString();
|
||||
properties.hidden = checkHidden.isChecked();
|
||||
|
||||
view.updateProperties();
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public void loadLayout(CustomControls controlLayout) {
|
||||
mLayout = controlLayout;
|
||||
removeAllViews();
|
||||
@ -28,10 +123,7 @@ public class ControlsLayout extends FrameLayout
|
||||
|
||||
@Override
|
||||
public void onClick(View p1) {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
alert.setTitle(getResources().getString(R.string.global_edit) + " " + view.getText());
|
||||
// alert.setView(edit);
|
||||
alert.show();
|
||||
showCtrlOption(view);
|
||||
}
|
||||
});
|
||||
view.setCanMove(mCanMove);
|
||||
|
@ -1,5 +0,0 @@
|
||||
package net.kdt.pojavlaunch.views;
|
||||
|
||||
public class MineButton
|
||||
{
|
||||
}
|
@ -5,17 +5,6 @@
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/global_name"/>
|
||||
|
||||
<EditText
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:singleLine="true"
|
||||
android:id="@+id/controlsetting_edit_name"/>
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
@ -26,11 +15,30 @@
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/controlsetting_spinner_lwjglkeycode"/>
|
||||
|
||||
<CheckBox
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:text="@string/customctrl_hidden"
|
||||
android:id="@+id/controlsetting_checkbox_hidden"/>
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/controlsetting_normalbtnlayout">
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/global_name"/>
|
||||
|
||||
<EditText
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:singleLine="true"
|
||||
android:id="@+id/controlsetting_edit_name"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:text="@string/customctrl_hidden"
|
||||
android:id="@+id/controlsetting_checkbox_hidden"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -244,6 +244,7 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:animateLayoutChanges="true"
|
||||
android:id="@+id/content_log_layout"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -2,7 +2,7 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:id="@+id/nav_forceclose"
|
||||
android:title="@string/control_forceclose" />
|
||||
android:title="@*android:string/force_close" />
|
||||
<item
|
||||
android:id="@+id/nav_viewlog"
|
||||
android:title="@string/control_viewout" />
|
||||
|
@ -3,7 +3,6 @@
|
||||
<string-array name="mcl_options">
|
||||
<item>@string/mcl_option_modmgr</item>
|
||||
<item>@string/mcl_option_optifineinstall</item>
|
||||
<item>@string/mcl_option_checkupdate</item>
|
||||
<item>@string/mcl_option_customcontrol</item>
|
||||
<item>@string/mcl_option_settings</item>
|
||||
<item>@string/mcl_option_about</item>
|
||||
|
@ -51,7 +51,6 @@
|
||||
|
||||
<!-- Error messages -->
|
||||
<string name="error_checklog">Error! Please check the log below: %s</string>
|
||||
<string name="error_title">Error</string>
|
||||
<string name="error_no_version">No version!</string>
|
||||
<string name="error_load_version">Unable to load version %s</string>
|
||||
<string name="error_convert_lib">Unable to convert library %s</string>
|
||||
@ -92,7 +91,7 @@
|
||||
<string name="mcl_option_about">About</string>
|
||||
|
||||
<string name="mcl_setting_title_setmaxdxref">Set max DX references</string>
|
||||
<string name="mcl_setting_subtitle_setmaxdxref">Increase If an error happend while converting: Too many ... references. You may try multi-dex option.</string>
|
||||
<string name="mcl_setting_subtitle_setmaxdxref">Increase If an error happend while converting: Too many ... references. You may try multi-dex option. Recommended: 4096 or 8192.</string>
|
||||
<string name="mcl_setting_title_freeform">Launch Minecraft in Freeform mode</string>
|
||||
<string name="mcl_setting_subtitle_freeform">Launch Minecraft in floating window. Requires Android 7.0+</string>
|
||||
<string name="mcl_setting_title_longpresstrigger">How long will trigger after long press</string>
|
||||
@ -146,7 +145,7 @@
|
||||
<string name="mcn_exit_call">Exit</string>
|
||||
<string name="mcn_exit_crash">Game Crash detected! Click OK to exit.</string>
|
||||
<string name="mcn_exit_errcrash">Unable to locate crash!</string>
|
||||
<string name="mcn_exit_confirm">Are you sure want to force exit?</string>
|
||||
<string name="mcn_exit_confirm">Are you sure want to %s ?</string>
|
||||
|
||||
<!-- MainActivity: Control buttons -->
|
||||
<string name="controls">Controls</string>
|
||||
@ -170,7 +169,6 @@
|
||||
<string name="control_mouseon">Mouse: on </string>
|
||||
|
||||
<!-- MainActivity: Menu advanced controls -->
|
||||
<string name="control_forceclose">Force close</string>
|
||||
<string name="control_viewout">Log output</string>
|
||||
<string name="control_adebug">PointerCapture Debug</string>
|
||||
<string name="control_customkey">Send custom keycode</string>
|
||||
@ -179,6 +177,7 @@
|
||||
<string name="control_more4"></string>
|
||||
|
||||
<string name="customctrl_keyname">LWJGL Keycode</string>
|
||||
<string name="customctrl_specialkey">Special Key</string>
|
||||
<string name="customctrl_hidden">Hidden</string>
|
||||
|
||||
<!-- Update part (unused now) -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user