mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
name and avatr clickable (switching accounts)
This commit is contained in:
parent
42c61c9ed4
commit
8c9e2206cb
4 changed files with 31 additions and 28 deletions
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
|
@ -108,37 +108,9 @@ public class ManageAccountsActivity extends FileActivity
|
||||||
|
|
||||||
mListView.setAdapter(mAccountListAdapter);
|
mListView.setAdapter(mAccountListAdapter);
|
||||||
|
|
||||||
// added click listener to switch account
|
|
||||||
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
switchAccount(position);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
initializeComponentGetters();
|
initializeComponentGetters();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Switch current account to that contained in the received position of the list adapter.
|
|
||||||
*
|
|
||||||
* @param position A position of the account adapter containing an account.
|
|
||||||
*/
|
|
||||||
private void switchAccount(int position) {
|
|
||||||
Account clickedAccount = mAccountListAdapter.getItem(position).getAccount();
|
|
||||||
if (getAccount().name.equals(clickedAccount.name)) {
|
|
||||||
// current account selected, just go back
|
|
||||||
finish();
|
|
||||||
} else {
|
|
||||||
// restart list of files with new account
|
|
||||||
AccountUtils.setCurrentOwnCloudAccount(ManageAccountsActivity.this, clickedAccount.name);
|
|
||||||
Intent i = new Intent(ManageAccountsActivity.this, FileDisplayActivity.class);
|
|
||||||
i.putExtra(FileActivity.EXTRA_ACCOUNT, clickedAccount);
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
startActivity(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* converts an array of accounts into a set of account names.
|
* converts an array of accounts into a set of account names.
|
||||||
*
|
*
|
||||||
|
@ -291,6 +263,21 @@ public class ManageAccountsActivity extends FileActivity
|
||||||
}, mHandler);
|
}, mHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void switchAccount(Account account) {
|
||||||
|
if (getAccount().name.equals(account.name)) {
|
||||||
|
// current account selected, just go back
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
// restart list of files with new account
|
||||||
|
AccountUtils.setCurrentOwnCloudAccount(ManageAccountsActivity.this, account.name);
|
||||||
|
Intent i = new Intent(ManageAccountsActivity.this, FileDisplayActivity.class);
|
||||||
|
i.putExtra(FileActivity.EXTRA_ACCOUNT, account);
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(AccountManagerFuture<Boolean> future) {
|
public void run(AccountManagerFuture<Boolean> future) {
|
||||||
if (future.isDone()) {
|
if (future.isDone()) {
|
||||||
|
|
|
@ -103,6 +103,20 @@ public class AccountListAdapter extends ArrayAdapter<AccountListItem> implements
|
||||||
viewHolder.checkViewItem.setVisibility(View.INVISIBLE);
|
viewHolder.checkViewItem.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewHolder.imageViewItem.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mListener.switchAccount(mValues.get(position).getAccount());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
viewHolder.accountViewItem.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mListener.switchAccount(mValues.get(position).getAccount());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/// bind listener to change password
|
/// bind listener to change password
|
||||||
viewHolder.passwordButtonItem.setOnClickListener(new View.OnClickListener() {
|
viewHolder.passwordButtonItem.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -159,6 +173,8 @@ public class AccountListAdapter extends ArrayAdapter<AccountListItem> implements
|
||||||
void changePasswordOfAccount(Account account);
|
void changePasswordOfAccount(Account account);
|
||||||
|
|
||||||
void createAccount();
|
void createAccount();
|
||||||
|
|
||||||
|
void switchAccount(Account account);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue