Improvements of multiacc + added migrating from old type of accounts to new type

This commit is contained in:
gdlbo
2022-03-30 17:16:23 +03:00
parent 122c6d8b80
commit 18de5e9289
2 changed files with 16 additions and 7 deletions
@@ -1,6 +1,7 @@
package ru.vtosters.lite.utils;
import static android.content.Context.MODE_PRIVATE;
import static ru.vtosters.lite.utils.Helper.GetContext;
import android.content.SharedPreferences;
@@ -13,6 +14,15 @@ public class AccountManager {
return Helper.GetContext().getSharedPreferences("pref_account_manager" + Value, MODE_PRIVATE);
}
public static void MigrateToNewType() {
SharedPreferences OldPrefs = Helper.GetContext().getSharedPreferences("pref_account_manager", MODE_PRIVATE);
String OldPrefsValue = OldPrefs.getString("key_vk_account", "");
SharedPreferences NewPrefs = GetContext().getSharedPreferences("pref_account_manager0", MODE_PRIVATE);
SharedPreferences.Editor editor = NewPrefs.edit();
editor.putString("key_vk_account", OldPrefsValue);
editor.commit();
}
public static String getCurrentAccountName() {
String Value = ru.vtosters.lite.utils.Helper.GetPreferences().getString("account", "");
return getName(Value);
@@ -31,26 +41,25 @@ public class AccountManager {
}
return "err";
}
public static String getAvalibleAcc(){
public static String getAvalibleAcc() {
int intg = 0;
while (true) {
if (getName(Integer.toString(intg)) != "err") {
intg++;
}
else {
} else {
break;
}
};
return Integer.toString(intg);
}
public static int getAvalibleAccInt(){
public static int getAvalibleAccInt() {
int intg = 0;
while (true) {
if (getName(Integer.toString(intg)) != "err") {
intg++;
}
else {
} else {
break;
}
};
@@ -707,7 +707,7 @@ public class Prefs {
setupFilters();
fixGapps();
setProxy();
AccountManager.MigrateToNewType();
registerActivities(application);
}