Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlbo committed May 3, 2022
2 parents 95ef37f + 6216c66 commit 6533feb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import ru.vtosters.lite.utils.Globals;

public class MultiAccountManager {

public static void migrate() {
Expand All @@ -20,7 +22,15 @@ public static void migrate() {
SharedPreferences NewPrefs = getContext().getSharedPreferences("pref_account_manager0", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = NewPrefs.edit();
editor.putString("key_vk_account", OldPrefsValue);
editor.apply();
editor.commit();
}

public static void migrationRestart() {
SharedPreferences prefs = getPreferences();
if (prefs.getBoolean("multiaccount_restart", true)) {
prefs.edit().putBoolean("multiaccount_restart", false).commit();
Globals.restartApplication();
}
}

public static SharedPreferences getCurrentAccount() {
Expand Down Expand Up @@ -80,7 +90,15 @@ public static void deleteAccount(int i) {
prefs.edit().clear().commit();
File file = new File(new File(getContext().getFilesDir().getParent(), "shared_prefs"), "pref_account_manager" + i);
if (file.exists()) file.delete();
if (account == i && getAccountPrefsCount() > 0)
switchAccount(buildList().get(0).index);
if (account == i && getAccountPrefsCount() > 0) {
List<MultiAccountItem> accounts = buildList();
if (accounts.size() > 0)
switchAccount(buildList().get(0).index);
else {
getContext().getSharedPreferences("pref_account_manager", Context.MODE_PRIVATE)
.edit().clear().commit();
Globals.getPreferences().edit().putBoolean("multiaccount_restart", true).commit();
}
}
}
}
2 changes: 2 additions & 0 deletions smali/smali_classes4/com/vtosters/lite/AuthActivity.smali
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@
:cond_1
invoke-super {p0}, Landroid/support/v4/app/FragmentActivity;->finish()V

invoke-static {}, Lru/vtosters/lite/ui/fragments/multiaccount/MultiAccountManager;->migrationRestart()V

return-void
.end method

Expand Down

0 comments on commit 6533feb

Please sign in to comment.