Show display name in account selector of ReceiveExternalFilesActivity.java

This commit is contained in:
David A. Velasco 2016-06-15 10:22:24 +02:00
parent 282f62b735
commit ea3cf41b99
4 changed files with 22 additions and 13 deletions

@ -1 +1 @@
Subproject commit 75667c67f4455217c1843d576f6c471280c409f4
Subproject commit 4d80ca096dd68d718d68517d9ae52510007f8582

View file

@ -456,12 +456,11 @@ public class FileActivity extends AppCompatActivity
protected void setUsernameInDrawer(View navigationDrawerLayout, Account account) {
if (navigationDrawerLayout != null && account != null) {
TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
try {
OwnCloudAccount oca = new OwnCloudAccount(account, this);
username.setText(oca.getDisplayName());
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
} catch (Exception e) {
Log_OC.w(TAG, "Couldn't read display name of account; using account name instead");
int lastAtPos = account.name.lastIndexOf("@");

View file

@ -745,14 +745,16 @@ public class Preferences extends PreferenceActivity
null);
}
else {
OwnCloudAccount oca;
for (Account a : accounts) {
RadioButtonPreference accountPreference = new RadioButtonPreference(this);
accountPreference.setKey(a.name);
try {
OwnCloudAccount oca = new OwnCloudAccount(a, this);
accountPreference.setTitle(oca.getDisplayName());
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
oca = new OwnCloudAccount(a, this);
accountPreference.setTitle(
oca.getDisplayName() + " @ " + DisplayUtils.convertIdn(oca.getBaseUri().getHost(), false)
);
} catch (Exception e) {
Log_OC.w(
TAG,
"Account not found right after being read :\\ ; using account name instead of display name"

View file

@ -59,6 +59,7 @@ import com.owncloud.android.authentication.AccountAuthenticator;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.db.PreferenceManager;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
@ -265,14 +266,21 @@ public class ReceiveExternalFilesActivity extends FileActivity
});
return builder.create();
case DIALOG_MULTIPLE_ACCOUNT:
CharSequence ac[] = new CharSequence[
mAccountManager.getAccountsByType(MainApp.getAccountType()).length];
for (int i = 0; i < ac.length; ++i) {
ac[i] = DisplayUtils.convertIdn(
mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name, false);
Account accounts[] = mAccountManager.getAccountsByType(MainApp.getAccountType());
CharSequence dialogItems[] = new CharSequence[accounts.length];
OwnCloudAccount oca;
for (int i = 0; i < dialogItems.length; ++i) {
try {
oca = new OwnCloudAccount(accounts[i], this);
dialogItems[i] =
oca.getDisplayName() + " @ " + DisplayUtils.convertIdn(oca.getBaseUri().getHost(), false);
} catch (Exception e) {
Log_OC.w(TAG, "Couldn't read display name of account; using account name instead");
dialogItems[i] = DisplayUtils.convertIdn(accounts[i].name, false);
}
}
builder.setTitle(R.string.common_choose_account);
builder.setItems(ac, new OnClickListener() {
builder.setItems(dialogItems, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]);