Navigation drawer updated when account is removed in settings, opening this from uploads view

This commit is contained in:
David A. Velasco 2016-03-29 14:10:47 +02:00
parent 9b85e57c8c
commit f1bd697d7f
3 changed files with 16 additions and 3 deletions

View file

@ -455,7 +455,7 @@ public class FileActivity extends AppCompatActivity
* @param navigationDrawerLayout the drawer layout to be used * @param navigationDrawerLayout the drawer layout to be used
* @param account the account to be set in the drawer * @param account the account to be set in the drawer
*/ */
protected void setUsernameInDrawer(RelativeLayout navigationDrawerLayout, Account account) { protected void setUsernameInDrawer(View navigationDrawerLayout, Account account) {
if (navigationDrawerLayout != null && account != null) { if (navigationDrawerLayout != null && account != null) {
TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username); TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
int lastAtPos = account.name.lastIndexOf("@"); int lastAtPos = account.name.lastIndexOf("@");

View file

@ -56,7 +56,6 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.Toast; import android.widget.Toast;
import com.owncloud.android.MainApp; import com.owncloud.android.MainApp;
@ -310,7 +309,7 @@ public class FileDisplayActivity extends HookActivity implements
setFile(file); setFile(file);
if (mAccountWasSet) { if (mAccountWasSet) {
setUsernameInDrawer((RelativeLayout) findViewById(R.id.left_drawer), getAccount()); setUsernameInDrawer(findViewById(R.id.left_drawer), getAccount());
} }
if (!stateWasRecovered) { if (!stateWasRecovered) {

View file

@ -344,4 +344,18 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
protected String getDefaultTitle() { protected String getDefaultTitle() {
return getString(R.string.uploads_view_title); return getString(R.string.uploads_view_title);
} }
/**
* Called when the ownCloud {@link Account} associated to the Activity was just updated.
*/
@Override
protected void onAccountSet(boolean stateWasRecovered) {
super.onAccountSet(stateWasRecovered);
updateActionBarTitleAndHomeButton(null);
if (mAccountWasSet) {
setUsernameInDrawer(findViewById(R.id.left_drawer), getAccount());
}
}
} }