From ea3cf41b99e2e621fa50ca5268382fcdecb81383 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 15 Jun 2016 10:22:24 +0200 Subject: [PATCH] Show display name in account selector of ReceiveExternalFilesActivity.java --- owncloud-android-library | 2 +- .../android/ui/activity/FileActivity.java | 3 +-- .../android/ui/activity/Preferences.java | 10 ++++++---- .../ReceiveExternalFilesActivity.java | 20 +++++++++++++------ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/owncloud-android-library b/owncloud-android-library index 75667c67f4..4d80ca096d 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit 75667c67f4455217c1843d576f6c471280c409f4 +Subproject commit 4d80ca096dd68d718d68517d9ae52510007f8582 diff --git a/src/com/owncloud/android/ui/activity/FileActivity.java b/src/com/owncloud/android/ui/activity/FileActivity.java index f45b95208a..f90f4922ab 100644 --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@ -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("@"); diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index cafa27fcce..5171b69226 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -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" diff --git a/src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index 22bb26ae70..8957082feb 100644 --- a/src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -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]);