mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-13 01:51:30 -07:00
config.json and basics to allow auto login
This commit is contained in:
parent
5ee9de1895
commit
0b3478a5af
5 changed files with 100 additions and 12 deletions
|
|
@ -139,7 +139,7 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
|
|
||||||
//final Uri uri = data.getData();
|
//final Uri uri = data.getData();
|
||||||
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.beta);
|
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.miniclient);
|
||||||
String path = uri.getPath();
|
String path = uri.getPath();
|
||||||
//File modFile = new File(new URI(path));
|
//File modFile = new File(new URI(path));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ package net.kdt.pojavlaunch;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.view.View.*;
|
import android.view.View.*;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
@ -91,6 +93,8 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
findViewById(R.id.keyboard).setOnTouchListener(this);
|
findViewById(R.id.keyboard).setOnTouchListener(this);
|
||||||
findViewById(R.id.camera).setOnTouchListener(this);
|
findViewById(R.id.camera).setOnTouchListener(this);
|
||||||
findViewById(R.id.mb2).setOnTouchListener(this);
|
findViewById(R.id.mb2).setOnTouchListener(this);
|
||||||
|
|
||||||
|
|
||||||
this.touchPad = findViewById(R.id.main_touchpad);
|
this.touchPad = findViewById(R.id.main_touchpad);
|
||||||
touchPad.setVisibility(View.VISIBLE);
|
touchPad.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
|
@ -187,7 +191,8 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
|
|
||||||
placeMouseAt(CallbackBridge.physicalWidth / 2, CallbackBridge.physicalHeight / 2);
|
placeMouseAt(CallbackBridge.physicalWidth / 2, CallbackBridge.physicalHeight / 2);
|
||||||
|
|
||||||
final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
|
final File miniclient = (File) getIntent().getExtras().getSerializable("miniclient");
|
||||||
|
final File config = new File(getFilesDir(), "config.json");
|
||||||
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
||||||
|
|
||||||
mTextureView = findViewById(R.id.installmod_surfaceview);
|
mTextureView = findViewById(R.id.installmod_surfaceview);
|
||||||
|
|
@ -213,7 +218,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
});
|
});
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
launchJavaRuntime(modFile, javaArgs);
|
launchJavaRuntime(miniclient, javaArgs,config);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Tools.showError(JavaGUILauncherActivity.this, e);
|
Tools.showError(JavaGUILauncherActivity.this, e);
|
||||||
}
|
}
|
||||||
|
|
@ -392,7 +397,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
touchPad.setVisibility(isVirtualMouseEnabled ? View.GONE : View.VISIBLE);
|
touchPad.setVisibility(isVirtualMouseEnabled ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int launchJavaRuntime(File modFile, String javaArgs) {
|
public int launchJavaRuntime(File miniclient, String javaArgs,File config) {
|
||||||
JREUtils.redirectAndPrintJRELog(this);
|
JREUtils.redirectAndPrintJRELog(this);
|
||||||
try {
|
try {
|
||||||
JREUtils.jreReleaseList = JREUtils.readJREReleaseProperties();
|
JREUtils.jreReleaseList = JREUtils.readJREReleaseProperties();
|
||||||
|
|
@ -406,13 +411,18 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
javaArgList.addAll(Arrays.asList(javaArgs.split(" ")));
|
javaArgList.addAll(Arrays.asList(javaArgs.split(" ")));
|
||||||
} else {
|
} else {
|
||||||
javaArgList.add("-jar");
|
javaArgList.add("-jar");
|
||||||
javaArgList.add(modFile.getAbsolutePath());
|
javaArgList.add(miniclient.getAbsolutePath());
|
||||||
|
javaArgList.add(config.getAbsolutePath()); // Pass client config as arg0
|
||||||
|
javaArgList.add("username=miniclientparam:");
|
||||||
|
javaArgList.add("password=miniclientparam:");
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.getInstance().appendToLog("Info: Java arguments: " + Arrays.toString(javaArgList.toArray(new String[0])));
|
Logger.getInstance().appendToLog("Info: Java arguments: " + Arrays.toString(javaArgList.toArray(new String[0])));
|
||||||
|
Log.i("Info: Java arguments: ",Arrays.toString(javaArgList.toArray(new String[0])));
|
||||||
|
|
||||||
// Run java on sandbox, non-overrideable.
|
// Run java on sandbox, non-overrideable.
|
||||||
Collections.reverse(javaArgList);
|
Collections.reverse(javaArgList);
|
||||||
|
|
||||||
javaArgList.add("-Xbootclasspath/a:" + Tools.DIR_DATA + "/pro-grade.jar");
|
javaArgList.add("-Xbootclasspath/a:" + Tools.DIR_DATA + "/pro-grade.jar");
|
||||||
javaArgList.add("-Djava.security.manager=net.sourceforge.prograde.sm.ProGradeJSM");
|
javaArgList.add("-Djava.security.manager=net.sourceforge.prograde.sm.ProGradeJSM");
|
||||||
javaArgList.add("-Djava.security.policy=" + Tools.DIR_DATA + "/java_sandbox.policy");
|
javaArgList.add("-Djava.security.policy=" + Tools.DIR_DATA + "/java_sandbox.policy");
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import static net.kdt.pojavlaunch.Tools.getFileName;
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
|
@ -19,14 +20,12 @@ import android.view.View;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
|
@ -42,7 +41,6 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class PojavLoginActivity extends BaseActivity
|
public class PojavLoginActivity extends BaseActivity
|
||||||
// MineActivity
|
// MineActivity
|
||||||
|
|
@ -155,20 +153,20 @@ public class PojavLoginActivity extends BaseActivity
|
||||||
barrier.setCancelable(false);
|
barrier.setCancelable(false);
|
||||||
barrier.show();
|
barrier.show();
|
||||||
|
|
||||||
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.beta);
|
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.miniclient);
|
||||||
|
|
||||||
barrier.setMessage(PojavLoginActivity.this.getString(R.string.multirt_progress_caching));
|
barrier.setMessage(PojavLoginActivity.this.getString(R.string.multirt_progress_caching));
|
||||||
Thread t = new Thread(()->{
|
Thread t = new Thread(()->{
|
||||||
try {
|
try {
|
||||||
final String name = getFileName(this, uri);
|
final String name = getFileName(this, uri);
|
||||||
final File modInstallerFile = new File(getCacheDir(), name);
|
final File miniclient = new File(getCacheDir(), name);
|
||||||
FileOutputStream fos = new FileOutputStream(modInstallerFile);
|
FileOutputStream fos = new FileOutputStream(miniclient);
|
||||||
IOUtils.copy(getContentResolver().openInputStream(uri), fos);
|
IOUtils.copy(getContentResolver().openInputStream(uri), fos);
|
||||||
fos.close();
|
fos.close();
|
||||||
PojavLoginActivity.this.runOnUiThread(() -> {
|
PojavLoginActivity.this.runOnUiThread(() -> {
|
||||||
barrier.dismiss();
|
barrier.dismiss();
|
||||||
Intent intent = new Intent(PojavLoginActivity.this, JavaGUILauncherActivity.class);
|
Intent intent = new Intent(PojavLoginActivity.this, JavaGUILauncherActivity.class);
|
||||||
intent.putExtra("modFile", modInstallerFile);
|
intent.putExtra("miniclient", miniclient);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}catch(IOException e) {
|
}catch(IOException e) {
|
||||||
|
|
@ -219,6 +217,23 @@ public class PojavLoginActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void initMain() throws Throwable {
|
private void initMain() throws Throwable {
|
||||||
|
// Copy config.json to writable storage
|
||||||
|
// https://stackoverflow.com/questions/38590996/copy-xml-from-raw-folder-to-internal-storage-and-use-it-in-android
|
||||||
|
File file = new File(getFilesDir(), "config.json");
|
||||||
|
try {
|
||||||
|
Context context = getApplicationContext();
|
||||||
|
InputStream inputStream = context.getResources().openRawResource(R.raw.config);
|
||||||
|
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||||
|
byte buf[]=new byte[1024];
|
||||||
|
int len;
|
||||||
|
while((len=inputStream.read(buf))>0) {
|
||||||
|
fileOutputStream.write(buf,0,len);
|
||||||
|
}
|
||||||
|
fileOutputStream.close();
|
||||||
|
inputStream.close();
|
||||||
|
System.out.println("Write to Local");
|
||||||
|
} catch (IOException e1) {}
|
||||||
|
|
||||||
mkdirs(Tools.DIR_ACCOUNT_NEW);
|
mkdirs(Tools.DIR_ACCOUNT_NEW);
|
||||||
mkdirs(Tools.DIR_GAME_HOME);
|
mkdirs(Tools.DIR_GAME_HOME);
|
||||||
mkdirs(Tools.DIR_GAME_HOME + "/lwjgl3");
|
mkdirs(Tools.DIR_GAME_HOME + "/lwjgl3");
|
||||||
|
|
|
||||||
63
app_2009scape/src/main/res/raw/config.json
Normal file
63
app_2009scape/src/main/res/raw/config.json
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
{
|
||||||
|
"ip_management": "play.2009scape.org",
|
||||||
|
"world": 1,
|
||||||
|
"debug": {
|
||||||
|
"hd_login_region_debug_verbose": false,
|
||||||
|
"npc_debug": false,
|
||||||
|
"hd_login_region_debug": false,
|
||||||
|
"world_map_debug": false,
|
||||||
|
"item_debug": false,
|
||||||
|
"object_debug": false,
|
||||||
|
"cache_debug": false
|
||||||
|
},
|
||||||
|
"customization": {
|
||||||
|
"slayer": {
|
||||||
|
"color": "#635a38",
|
||||||
|
"opacity": "180",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"login_theme": "scape main",
|
||||||
|
"rendering_options": {
|
||||||
|
"skybox": {
|
||||||
|
"skybox_color": "Coming in a future update..."
|
||||||
|
},
|
||||||
|
"technical": {
|
||||||
|
"render_distance_increase": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"december_snow": false,
|
||||||
|
"right_click_menu": {
|
||||||
|
"border": {
|
||||||
|
"color": "#FFFFFF",
|
||||||
|
"opacity": "0"
|
||||||
|
},
|
||||||
|
"background": {
|
||||||
|
"color": "#5D5447",
|
||||||
|
"opacity": "255"
|
||||||
|
},
|
||||||
|
"styles": {
|
||||||
|
"presets": "custom",
|
||||||
|
"rs3border": false,
|
||||||
|
"Presets provide default customizations.": "rs3, classic, or custom. custom allows you to define your own values above. Classic is standard 2009."
|
||||||
|
},
|
||||||
|
"title_bar": {
|
||||||
|
"color": "#000000",
|
||||||
|
"font_color": "#FFFFFF",
|
||||||
|
"opacity": "255"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xpdrops": {
|
||||||
|
"drop_mode": 0,
|
||||||
|
"track_mode": 0,
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"launcher": {
|
||||||
|
"closeOnClientLaunch": true,
|
||||||
|
"notifyUpdates": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"server_port": 43594,
|
||||||
|
"ip_address": "play.2009scape.org",
|
||||||
|
"wl_port": 5555,
|
||||||
|
"js5_port": 43593
|
||||||
|
}
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue