mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-20 13:30:15 -07:00
[Account manager] Still trying to fix wrong account path
This commit is contained in:
parent
fcdeab1935
commit
9f7f2fb62d
4 changed files with 7 additions and 18 deletions
|
|
@ -39,7 +39,6 @@ public class MCLauncherActivity extends BaseLauncherActivity
|
||||||
private TabLayout tabLayout;
|
private TabLayout tabLayout;
|
||||||
|
|
||||||
private TextView tvUsernameView;
|
private TextView tvUsernameView;
|
||||||
private String profilePath = null;
|
|
||||||
private ViewPagerAdapter viewPageAdapter;
|
private ViewPagerAdapter viewPageAdapter;
|
||||||
|
|
||||||
private Button switchUsrBtn, logoutBtn; // MineButtons
|
private Button switchUsrBtn, logoutBtn; // MineButtons
|
||||||
|
|
@ -74,7 +73,6 @@ public class MCLauncherActivity extends BaseLauncherActivity
|
||||||
mTextVersion = (TextView) findViewById(R.id.launcherMainVersionView);
|
mTextVersion = (TextView) findViewById(R.id.launcherMainVersionView);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
profilePath = PojavProfile.getCurrentProfilePath(this);
|
|
||||||
mProfile = PojavProfile.getCurrentProfileContent(this);
|
mProfile = PojavProfile.getCurrentProfileContent(this);
|
||||||
|
|
||||||
tvUsernameView.setText(getString(R.string.main_welcome, mProfile.username));
|
tvUsernameView.setText(getString(R.string.main_welcome, mProfile.username));
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
||||||
|
|
||||||
private TextView tvUsernameView;
|
private TextView tvUsernameView;
|
||||||
private Spinner accountSelector;
|
private Spinner accountSelector;
|
||||||
private String profilePath = null;
|
|
||||||
private ViewPagerAdapter viewPageAdapter;
|
private ViewPagerAdapter viewPageAdapter;
|
||||||
|
|
||||||
private Button switchUsrBtn, logoutBtn; // MineButtons
|
private Button switchUsrBtn, logoutBtn; // MineButtons
|
||||||
|
|
@ -136,7 +135,7 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
||||||
PojavProfile.setCurrentProfile(PojavLauncherActivity.this, tempProfile);
|
PojavProfile.setCurrentProfile(PojavLauncherActivity.this, tempProfile);
|
||||||
} else {
|
} else {
|
||||||
PojavProfile.setCurrentProfile(PojavLauncherActivity.this,
|
PojavProfile.setCurrentProfile(PojavLauncherActivity.this,
|
||||||
Tools.DIR_ACCOUNT_NEW + "/" + accountList.get(position + (tempProfile != null ? 1 : 0)) + ".json");
|
accountList.get(position + (tempProfile != null ? 1 : 0)));
|
||||||
}
|
}
|
||||||
pickAccount();
|
pickAccount();
|
||||||
}
|
}
|
||||||
|
|
@ -212,12 +211,10 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
||||||
|
|
||||||
private void pickAccount() {
|
private void pickAccount() {
|
||||||
try {
|
try {
|
||||||
profilePath = PojavProfile.getCurrentProfilePath(this);
|
|
||||||
mProfile = PojavProfile.getCurrentProfileContent(this);
|
mProfile = PojavProfile.getCurrentProfileContent(this);
|
||||||
|
|
||||||
tvUsernameView.setText(getString(R.string.main_welcome, mProfile.username));
|
tvUsernameView.setText(getString(R.string.main_welcome, mProfile.username));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
profilePath = "";
|
|
||||||
mProfile = new MinecraftAccount();
|
mProfile = new MinecraftAccount();
|
||||||
Tools.showError(this, e, true);
|
Tools.showError(this, e, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -283,8 +283,6 @@ public class PojavLoginActivity extends BaseActivity
|
||||||
|
|
||||||
// Clear current profile
|
// Clear current profile
|
||||||
PojavProfile.setCurrentProfile(this, null);
|
PojavProfile.setCurrentProfile(this, null);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isJavaRuntimeInstalled(AssetManager am) {
|
private boolean isJavaRuntimeInstalled(AssetManager am) {
|
||||||
|
|
@ -825,10 +823,9 @@ public class PojavLoginActivity extends BaseActivity
|
||||||
try {
|
try {
|
||||||
String profileName = null;
|
String profileName = null;
|
||||||
if (sRemember.isChecked() || notOnLogin) {
|
if (sRemember.isChecked() || notOnLogin) {
|
||||||
profileName = new File(mProfile.save()).getName();
|
profileName = mProfile.save();
|
||||||
}
|
}
|
||||||
profileName = profileName.substring(0, profileName.length() - 5);
|
|
||||||
|
|
||||||
MCProfile.launch(PojavLoginActivity.this, profileName == null ? mProfile : profileName);
|
MCProfile.launch(PojavLoginActivity.this, profileName == null ? mProfile : profileName);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Tools.showError(this, e);
|
Tools.showError(this, e);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public class PojavProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MinecraftAccount getCurrentProfileContent(Context ctx) throws IOException, JsonSyntaxException {
|
public static MinecraftAccount getCurrentProfileContent(Context ctx) throws IOException, JsonSyntaxException {
|
||||||
MinecraftAccount build = MinecraftAccount.load(getPrefs(ctx).getString(PROFILE_PREF_FILE, ""));
|
MinecraftAccount build = MinecraftAccount.load(getCurrentProfileName(ctx));
|
||||||
if (build == null) {
|
if (build == null) {
|
||||||
getTempProfileContent(ctx);
|
getTempProfileContent(ctx);
|
||||||
}
|
}
|
||||||
|
|
@ -26,7 +26,7 @@ public class PojavProfile
|
||||||
return MinecraftAccount.parse(getPrefs(ctx).getString(PROFILE_PREF_TEMP_CONTENT, ""));
|
return MinecraftAccount.parse(getPrefs(ctx).getString(PROFILE_PREF_TEMP_CONTENT, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentProfilePath(Context ctx) {
|
public static String getCurrentProfileName(Context ctx) {
|
||||||
return getPrefs(ctx).getString(PROFILE_PREF_FILE, "");
|
return getPrefs(ctx).getString(PROFILE_PREF_FILE, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,10 +42,7 @@ public class PojavProfile
|
||||||
}
|
}
|
||||||
} else if (obj instanceof String) {
|
} else if (obj instanceof String) {
|
||||||
String acc = (String) obj;
|
String acc = (String) obj;
|
||||||
pref.putString(PROFILE_PREF_FILE,
|
pref.putString(PROFILE_PREF_FILE, acc);
|
||||||
acc.startsWith("/") ?
|
|
||||||
acc :
|
|
||||||
Tools.DIR_ACCOUNT_NEW + "/" + acc + ".json");
|
|
||||||
MinecraftAccount.clearTempAccount();
|
MinecraftAccount.clearTempAccount();
|
||||||
} else if (obj == null) {
|
} else if (obj == null) {
|
||||||
pref.putString(PROFILE_PREF_FILE, "");
|
pref.putString(PROFILE_PREF_FILE, "");
|
||||||
|
|
@ -58,6 +55,6 @@ public class PojavProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFileType(Context ctx) {
|
public static boolean isFileType(Context ctx) {
|
||||||
return new File(PojavProfile.getCurrentProfilePath(ctx)).exists();
|
return new File(Tools.DIR_ACCOUNT_NEW + "/" + PojavProfile.getCurrentProfileName(ctx) + ".json").exists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue