mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
Granted update of file list view after removing the currently selected account from 'manage accounts' activity
This commit is contained in:
parent
b2a260286e
commit
11117ace15
1 changed files with 33 additions and 11 deletions
|
@ -40,12 +40,21 @@ import com.owncloud.android.R;
|
||||||
public class AccountSelectActivity extends SherlockListActivity implements
|
public class AccountSelectActivity extends SherlockListActivity implements
|
||||||
AccountManagerCallback<Boolean> {
|
AccountManagerCallback<Boolean> {
|
||||||
|
|
||||||
|
private static final String PREVIOUS_ACCOUNT_KEY = "ACCOUNT";
|
||||||
|
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
|
private Account mPreviousAccount = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
mPreviousAccount = savedInstanceState.getParcelable(PREVIOUS_ACCOUNT_KEY);
|
||||||
|
} else {
|
||||||
|
mPreviousAccount = AccountUtils.getCurrentOwnCloudAccount(this);
|
||||||
|
}
|
||||||
|
|
||||||
ActionBar action_bar = getSupportActionBar();
|
ActionBar action_bar = getSupportActionBar();
|
||||||
action_bar.setDisplayShowTitleEnabled(true);
|
action_bar.setDisplayShowTitleEnabled(true);
|
||||||
action_bar.setDisplayHomeAsUpEnabled(false);
|
action_bar.setDisplayHomeAsUpEnabled(false);
|
||||||
|
@ -56,6 +65,29 @@ public class AccountSelectActivity extends SherlockListActivity implements
|
||||||
super.onResume();
|
super.onResume();
|
||||||
populateAccountList();
|
populateAccountList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (this.isFinishing()) {
|
||||||
|
Account current = AccountUtils.getCurrentOwnCloudAccount(this);
|
||||||
|
if ((mPreviousAccount == null && current != null) ||
|
||||||
|
(mPreviousAccount != null && !mPreviousAccount.equals(current))) {
|
||||||
|
/// the account set as default changed since this activity was created
|
||||||
|
|
||||||
|
// trigger synchronization
|
||||||
|
ContentResolver.cancelSync(null, AccountAuthenticator.AUTH_TOKEN_TYPE);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
|
||||||
|
ContentResolver.requestSync(AccountUtils.getCurrentOwnCloudAccount(this), AccountAuthenticator.AUTH_TOKEN_TYPE, bundle);
|
||||||
|
|
||||||
|
// restart the main activity
|
||||||
|
Intent i = new Intent(this, FileDisplayActivity.class);
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
@ -76,17 +108,7 @@ public class AccountSelectActivity extends SherlockListActivity implements
|
||||||
String accountName = ((TextView) v.findViewById(android.R.id.text1))
|
String accountName = ((TextView) v.findViewById(android.R.id.text1))
|
||||||
.getText().toString();
|
.getText().toString();
|
||||||
AccountUtils.setCurrentOwnCloudAccount(this, accountName);
|
AccountUtils.setCurrentOwnCloudAccount(this, accountName);
|
||||||
|
finish(); // immediate exit
|
||||||
// trigger synchronization when current account is changed
|
|
||||||
ContentResolver.cancelSync(null, "org.owncloud");
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
|
|
||||||
ContentResolver.requestSync(AccountUtils.getCurrentOwnCloudAccount(this), "org.owncloud", bundle);
|
|
||||||
|
|
||||||
Intent i = new Intent(this, FileDisplayActivity.class);
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
startActivity(i);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue