mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 10:18:59 +03:00
Merge pull request #4710 from nextcloud/ezaquarii/eliminate-account-status-flags-from-base-activity
Eliminate account status flags from BaseActivity
This commit is contained in:
commit
123e708b7a
4 changed files with 5 additions and 18 deletions
|
@ -220,7 +220,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||||
|
|
||||||
setAccount(account);
|
setAccount(account);
|
||||||
userAccountManager.setCurrentOwnCloudAccount(account.name);
|
userAccountManager.setCurrentOwnCloudAccount(account.name);
|
||||||
onAccountSet(false);
|
onAccountSet();
|
||||||
|
|
||||||
Intent i = new Intent(this, FileDisplayActivity.class);
|
Intent i = new Intent(this, FileDisplayActivity.class);
|
||||||
i.setAction(FileDisplayActivity.RESTART);
|
i.setAction(FileDisplayActivity.RESTART);
|
||||||
|
|
|
@ -37,11 +37,6 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||||
*/
|
*/
|
||||||
private OCCapability mCapabilities;
|
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}.
|
* 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}.
|
* 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 account New {@link Account} to set.
|
||||||
* @param savedAccount When 'true', account was retrieved from a saved instance state.
|
* @param savedAccount When 'true', account was retrieved from a saved instance state.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected void setAccount(Account account, boolean savedAccount) {
|
protected void setAccount(Account account, boolean savedAccount) {
|
||||||
Account oldAccount = mCurrentAccount;
|
|
||||||
boolean validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name);
|
boolean validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name);
|
||||||
if (validAccount) {
|
if (validAccount) {
|
||||||
mCurrentAccount = account;
|
mCurrentAccount = account;
|
||||||
mAccountWasRestored = savedAccount || mCurrentAccount.equals(oldAccount);
|
|
||||||
} else {
|
} else {
|
||||||
swapToDefaultAccount();
|
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
|
* If no valid ownCloud {@link Account} exists, then the user is requested
|
||||||
* to create a new ownCloud {@link Account}.
|
* to create a new ownCloud {@link Account}.
|
||||||
*
|
|
||||||
* POSTCONDITION: updates {@link #mAccountWasRestored}.
|
|
||||||
*/
|
*/
|
||||||
protected void swapToDefaultAccount() {
|
protected void swapToDefaultAccount() {
|
||||||
// default to the most recently used account
|
// default to the most recently used account
|
||||||
|
@ -116,9 +105,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||||
if (newAccount == null) {
|
if (newAccount == null) {
|
||||||
/// no account available: force account creation
|
/// no account available: force account creation
|
||||||
createAccount(true);
|
createAccount(true);
|
||||||
mAccountWasRestored = false;
|
|
||||||
} else {
|
} else {
|
||||||
mAccountWasRestored = newAccount.equals(mCurrentAccount);
|
|
||||||
mCurrentAccount = newAccount;
|
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.
|
* Child classes must grant that state depending on the {@link Account} is updated.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected void onAccountSet(boolean stateWasRecovered) {
|
protected void onAccountSet() {
|
||||||
if (getAccount() != null) {
|
if (getAccount() != null) {
|
||||||
mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
|
mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
|
||||||
mCapabilities = mStorageManager.getCapability(mCurrentAccount.name);
|
mCapabilities = mStorageManager.getCapability(mCurrentAccount.name);
|
||||||
|
@ -186,7 +173,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
if(mCurrentAccount != null) {
|
if(mCurrentAccount != null) {
|
||||||
onAccountSet(mAccountWasRestored);
|
onAccountSet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class ManageAccountsActivity extends FileActivity implements AccountListA
|
||||||
}
|
}
|
||||||
|
|
||||||
setAccount(currentAccount);
|
setAccount(currentAccount);
|
||||||
onAccountSet(false);
|
onAccountSet();
|
||||||
|
|
||||||
arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class UserInfoActivity extends FileActivity implements Injectable {
|
||||||
unbinder = ButterKnife.bind(this);
|
unbinder = ButterKnife.bind(this);
|
||||||
|
|
||||||
setAccount(getUserAccountManager().getCurrentAccount());
|
setAccount(getUserAccountManager().getCurrentAccount());
|
||||||
onAccountSet(false);
|
onAccountSet();
|
||||||
|
|
||||||
boolean useBackgroundImage = URLUtil.isValidUrl(
|
boolean useBackgroundImage = URLUtil.isValidUrl(
|
||||||
getStorageManager().getCapability(account.name).getServerBackground());
|
getStorageManager().getCapability(account.name).getServerBackground());
|
||||||
|
|
Loading…
Reference in a new issue