mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 07:05:40 -04:00
Decouple selected profile from the Minecraft account
This commit is contained in:
parent
c21e945e7c
commit
8b5efa9a6f
@ -106,8 +106,9 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
||||
v.setEnabled(false);
|
||||
mTask = new MinecraftDownloaderTask(this);
|
||||
LauncherProfiles.update();
|
||||
if (LauncherProfiles.mainProfileJson != null && LauncherProfiles.mainProfileJson.profiles != null && LauncherProfiles.mainProfileJson.profiles.containsKey(mProfile.selectedProfile + "")) {
|
||||
MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile + "");
|
||||
String selectedProfile = LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,"");
|
||||
if (LauncherProfiles.mainProfileJson != null && LauncherProfiles.mainProfileJson.profiles != null && LauncherProfiles.mainProfileJson.profiles.containsKey(selectedProfile)) {
|
||||
MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(selectedProfile);
|
||||
if (prof != null && prof.lastVersionId != null) {
|
||||
if (mProfile.accessToken.equals("0")) {
|
||||
String versionId = getVersionId(prof.lastVersionId);
|
||||
|
@ -78,7 +78,7 @@ public class BaseMainActivity extends BaseActivity {
|
||||
mControlLayout = findViewById(R.id.main_control_layout);
|
||||
|
||||
mProfile = PojavProfile.getCurrentProfileContent(this);
|
||||
minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile);
|
||||
minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,""));
|
||||
if(minecraftProfile == null) {
|
||||
Toast.makeText(this,"Attempted to launch nonexistent profile",Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
|
@ -203,9 +203,9 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
||||
}
|
||||
profileAdapter.notifyDataSetChanged();
|
||||
});
|
||||
mVersionSelector.setOnLongClickListener((v)->profileEditor.show(mProfile.selectedProfile));
|
||||
mVersionSelector.setOnLongClickListener((v)->profileEditor.show(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,"")));
|
||||
mVersionSelector.setAdapter(profileAdapter);
|
||||
mVersionSelector.setSelection(profileAdapter.resolveProfileIndex(mProfile.selectedProfile));
|
||||
mVersionSelector.setSelection(profileAdapter.resolveProfileIndex(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,"")));
|
||||
mVersionSelector.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> p1, View p2, int p3, long p4)
|
||||
@ -216,16 +216,11 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
||||
mVersionSelector.setSelection(0);
|
||||
return;
|
||||
}
|
||||
mProfile.selectedProfile = p1.getItemAtPosition(p3).toString();
|
||||
PojavProfile.setCurrentProfile(PojavLauncherActivity.this, mProfile);
|
||||
if (PojavProfile.isFileType(PojavLauncherActivity.this)) {
|
||||
try {
|
||||
PojavProfile.setCurrentProfile(PojavLauncherActivity.this, mProfile.save());
|
||||
} catch (IOException e) {
|
||||
Tools.showError(PojavLauncherActivity.this, e);
|
||||
}
|
||||
}
|
||||
|
||||
LauncherPreferences.DEFAULT_PREF.edit()
|
||||
.putString(
|
||||
LauncherPreferences.PREF_KEY_CURRENT_PROFILE,
|
||||
p1.getItemAtPosition(p3).toString())
|
||||
.commit();
|
||||
}
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> p1)
|
||||
|
@ -6,6 +6,7 @@ import net.kdt.pojavlaunch.multirt.MultiRTUtils;
|
||||
import net.kdt.pojavlaunch.utils.JREUtils;
|
||||
|
||||
public class LauncherPreferences {
|
||||
public static final String PREF_KEY_CURRENT_PROFILE = "currentProfile";
|
||||
public static SharedPreferences DEFAULT_PREF;
|
||||
public static String PREF_RENDERER = "opengles2";
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class MinecraftDownloaderTask extends AsyncTask<String, String, Throwable
|
||||
//Now we have the reliable information to check if our runtime settings are good enough
|
||||
if(verInfo.javaVersion != null) { //1.17+
|
||||
LauncherProfiles.update();
|
||||
MinecraftProfile minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(mActivity.mProfile.selectedProfile);
|
||||
MinecraftProfile minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,""));
|
||||
if(minecraftProfile == null) throw new SilentException();
|
||||
String selectedRuntime = null;
|
||||
if(minecraftProfile.javaDir != null && minecraftProfile.javaDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX)) {
|
||||
|
@ -113,7 +113,8 @@ public class V117CompatUtil {
|
||||
String renderer;
|
||||
String gamePath;
|
||||
LauncherProfiles.update();
|
||||
MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(((BaseLauncherActivity)activity).mProfile.selectedProfile);
|
||||
String selectedProfile = LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,"");
|
||||
MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(selectedProfile);
|
||||
if(prof == null) throw new MinecraftDownloaderTask.SilentException();
|
||||
renderer = prof.pojavRendererName != null ? prof.pojavRendererName : LauncherPreferences.PREF_RENDERER;
|
||||
gamePath = prof.gameDir != null && prof.gameDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX) ? prof.gameDir.replace(Tools.LAUNCHERPROFILES_RTPREFIX,Tools.DIR_GAME_HOME + "/") : Tools.DIR_GAME_NEW;
|
||||
@ -150,7 +151,7 @@ public class V117CompatUtil {
|
||||
}
|
||||
switch(proceed.get()) {
|
||||
case 1:
|
||||
MinecraftProfile minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(((BaseLauncherActivity)activity).mProfile.selectedProfile);
|
||||
MinecraftProfile minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(selectedProfile);
|
||||
if(minecraftProfile == null) throw new MinecraftDownloaderTask.SilentException();
|
||||
minecraftProfile.pojavRendererName = "opengles2";
|
||||
LauncherProfiles.update();
|
||||
|
@ -18,7 +18,6 @@ public class MinecraftAccount
|
||||
public String profileId = "00000000-0000-0000-0000-000000000000"; // profile UUID, for obtaining skin
|
||||
public String username = "Steve";
|
||||
public String selectedVersion = "1.7.10";
|
||||
public String selectedProfile = "";
|
||||
public boolean isMicrosoft = false;
|
||||
public String msaRefreshToken = "0";
|
||||
public String skinFaceBase64;
|
||||
|
Loading…
x
Reference in New Issue
Block a user