mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 16:47:14 -04:00
Fix the temporary account
This commit is contained in:
parent
be621f7732
commit
472c288721
@ -809,12 +809,10 @@ public class PojavLoginActivity extends BaseActivity
|
||||
builder.profileId = result[3];
|
||||
builder.username = result[4];
|
||||
builder.selectedVersion = "1.12.2";
|
||||
|
||||
mProfile = builder;
|
||||
}
|
||||
v.setEnabled(true);
|
||||
prb.setVisibility(View.GONE);
|
||||
|
||||
playProfile(false);
|
||||
}
|
||||
}).execute(edit2.getText().toString(), edit3.getText().toString());
|
||||
|
@ -3,6 +3,8 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -14,22 +16,47 @@ public class PojavProfile
|
||||
{
|
||||
private static String PROFILE_PREF = "pojav_profile";
|
||||
private static String PROFILE_PREF_FILE = "file";
|
||||
private static String PROFILE_PREF_TEMP_CONTENT = "tempContent";
|
||||
public static String PROFILE_PREF_TEMP_CONTENT = "tempContent";
|
||||
|
||||
private static SharedPreferences getPrefs(Context ctx) {
|
||||
public static SharedPreferences getPrefs(Context ctx) {
|
||||
return ctx.getSharedPreferences(PROFILE_PREF, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static MinecraftAccount getCurrentProfileContent(Context ctx) throws IOException, JsonSyntaxException {
|
||||
public static MinecraftAccount getCurrentProfileContent(Context ctx) throws JsonSyntaxException {
|
||||
MinecraftAccount build = MinecraftAccount.load(getCurrentProfileName(ctx));
|
||||
if (build == null) {
|
||||
System.out.println("isTempProfile null? " + (getTempProfileContent(ctx) == null));
|
||||
return getTempProfileContent(ctx);
|
||||
}
|
||||
return build;
|
||||
}
|
||||
|
||||
public static MinecraftAccount getTempProfileContent(Context ctx) {
|
||||
return MinecraftAccount.parse(getPrefs(ctx).getString(PROFILE_PREF_TEMP_CONTENT, ""));
|
||||
try {
|
||||
MinecraftAccount acc = MinecraftAccount.parse(Tools.read(Tools.DIR_DATA+"/cache/tempacc.json"));
|
||||
if (acc.accessToken == null) {
|
||||
acc.accessToken = "0";
|
||||
}
|
||||
if (acc.clientToken == null) {
|
||||
acc.clientToken = "0";
|
||||
}
|
||||
if (acc.profileId == null) {
|
||||
acc.profileId = "0";
|
||||
}
|
||||
if (acc.username == null) {
|
||||
acc.username = "0";
|
||||
}
|
||||
if (acc.selectedVersion == null) {
|
||||
acc.selectedVersion = "1.7.10";
|
||||
}
|
||||
if (acc.msaRefreshToken == null) {
|
||||
acc.msaRefreshToken = "0";
|
||||
}
|
||||
return acc;
|
||||
}catch (IOException e) {
|
||||
Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the temporary profile",e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCurrentProfileName(Context ctx) {
|
||||
|
@ -1,4 +1,6 @@
|
||||
package net.kdt.pojavlaunch.value;
|
||||
import android.util.Log;
|
||||
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import java.io.*;
|
||||
import com.google.gson.*;
|
||||
@ -26,22 +28,32 @@ public class MinecraftAccount
|
||||
return Tools.GLOBAL_GSON.fromJson(content, MinecraftAccount.class);
|
||||
}
|
||||
|
||||
public static MinecraftAccount load(String name) throws IOException, JsonSyntaxException {
|
||||
MinecraftAccount acc = parse(Tools.read(Tools.DIR_ACCOUNT_NEW + "/" + name + ".json"));
|
||||
if (acc.accessToken == null) {
|
||||
acc.accessToken = "0";
|
||||
} if (acc.clientToken == null) {
|
||||
acc.clientToken = "0";
|
||||
} if (acc.profileId == null) {
|
||||
acc.profileId = "0";
|
||||
} if (acc.username == null) {
|
||||
acc.username = "0";
|
||||
} if (acc.selectedVersion == null) {
|
||||
acc.selectedVersion = "1.7.10";
|
||||
} if (acc.msaRefreshToken == null) {
|
||||
acc.msaRefreshToken = "0";
|
||||
public static MinecraftAccount load(String name) throws JsonSyntaxException {
|
||||
try {
|
||||
MinecraftAccount acc = parse(Tools.read(Tools.DIR_ACCOUNT_NEW + "/" + name + ".json"));
|
||||
if (acc.accessToken == null) {
|
||||
acc.accessToken = "0";
|
||||
}
|
||||
if (acc.clientToken == null) {
|
||||
acc.clientToken = "0";
|
||||
}
|
||||
if (acc.profileId == null) {
|
||||
acc.profileId = "0";
|
||||
}
|
||||
if (acc.username == null) {
|
||||
acc.username = "0";
|
||||
}
|
||||
if (acc.selectedVersion == null) {
|
||||
acc.selectedVersion = "1.7.10";
|
||||
}
|
||||
if (acc.msaRefreshToken == null) {
|
||||
acc.msaRefreshToken = "0";
|
||||
}
|
||||
return acc;
|
||||
}catch(IOException e) {
|
||||
Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the profile",e);
|
||||
return null;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
public static void clearTempAccount() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user