From b7cdaf310b1f070d1543288fc8b3fc578c7f4aea Mon Sep 17 00:00:00 2001 From: Chris Narkiewicz Date: Sun, 20 Oct 2019 23:19:38 +0100 Subject: [PATCH] Eliminate account status flags from BaseActivity onAccountSet(stateWasRecovered) is no longer used anywhere, so the flag mAccountWasRestored can be safely removed. This intermediary step opens path to eliminating out of band calls to onAccountSet(). Signed-off-by: Chris Narkiewicz --- .../client/onboarding/FirstRunActivity.java | 2 +- .../android/ui/activity/BaseActivity.java | 17 ++--------------- .../ui/activity/ManageAccountsActivity.java | 2 +- .../android/ui/activity/UserInfoActivity.java | 2 +- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.java b/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.java index 1616a4ace2..329556d62c 100644 --- a/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.java +++ b/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.java @@ -220,7 +220,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh setAccount(account); userAccountManager.setCurrentOwnCloudAccount(account.name); - onAccountSet(false); + onAccountSet(); Intent i = new Intent(this, FileDisplayActivity.class); i.setAction(FileDisplayActivity.RESTART); diff --git a/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java b/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java index a683a43046..52202ee2b8 100644 --- a/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java @@ -37,11 +37,6 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab */ private OCCapability mCapabilities; - /** - * Flag to signal when the value of mAccount was restored from a saved state. - */ - protected boolean mAccountWasRestored; - /** * Access point to the cached database for the current ownCloud {@link Account}. */ @@ -85,18 +80,14 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab * * If not valid, tries to swap it for other valid and existing ownCloud {@link Account}. * - * POSTCONDITION: updates {@link #mAccountWasRestored}. - * * @param account New {@link Account} to set. * @param savedAccount When 'true', account was retrieved from a saved instance state. */ @Deprecated protected void setAccount(Account account, boolean savedAccount) { - Account oldAccount = mCurrentAccount; boolean validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name); if (validAccount) { mCurrentAccount = account; - mAccountWasRestored = savedAccount || mCurrentAccount.equals(oldAccount); } else { swapToDefaultAccount(); } @@ -107,8 +98,6 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab * * If no valid ownCloud {@link Account} exists, then the user is requested * to create a new ownCloud {@link Account}. - * - * POSTCONDITION: updates {@link #mAccountWasRestored}. */ protected void swapToDefaultAccount() { // default to the most recently used account @@ -116,9 +105,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab if (newAccount == null) { /// no account available: force account creation createAccount(true); - mAccountWasRestored = false; } else { - mAccountWasRestored = newAccount.equals(mCurrentAccount); mCurrentAccount = newAccount; } } @@ -146,7 +133,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab * Child classes must grant that state depending on the {@link Account} is updated. */ @Deprecated - protected void onAccountSet(boolean stateWasRecovered) { + protected void onAccountSet() { if (getAccount() != null) { mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver()); mCapabilities = mStorageManager.getCapability(mCurrentAccount.name); @@ -186,7 +173,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab super.onStart(); if(mCurrentAccount != null) { - onAccountSet(mAccountWasRestored); + onAccountSet(); } } diff --git a/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java b/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java index a5bcb20114..7656482a63 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java @@ -133,7 +133,7 @@ public class ManageAccountsActivity extends FileActivity implements AccountListA } setAccount(currentAccount); - onAccountSet(false); + onAccountSet(); arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver()); diff --git a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java index 1d81fa6cb3..df42ac4426 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java @@ -136,7 +136,7 @@ public class UserInfoActivity extends FileActivity implements Injectable { unbinder = ButterKnife.bind(this); setAccount(getUserAccountManager().getCurrentAccount()); - onAccountSet(false); + onAccountSet(); boolean useBackgroundImage = URLUtil.isValidUrl( getStorageManager().getCapability(account.name).getServerBackground());