Prechádzať zdrojové kódy

Add username in subtitle

Only show switch account menu if have multiple account
Esa Firman 7 rokov pred
rodič
commit
cfcd069a84

+ 21 - 1
src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

@@ -698,11 +698,21 @@ public class ReceiveExternalFilesActivity extends FileActivity
         }
         }
     }
     }
 
 
+    private void setupActionBarSubtitle() {
+        if (isHaveMultipleAccount()) {
+            ActionBar actionBar = getSupportActionBar();
+            if(actionBar != null){
+                actionBar.setSubtitle(getAccount().name);
+            }
+        }
+    }
+
     private void populateDirectoryList() {
     private void populateDirectoryList() {
         setContentView(R.layout.uploader_layout);
         setContentView(R.layout.uploader_layout);
         setupEmptyList();
         setupEmptyList();
         setupToolbar();
         setupToolbar();
         ActionBar actionBar = getSupportActionBar();
         ActionBar actionBar = getSupportActionBar();
+        setupActionBarSubtitle();
 
 
         ListView mListView = (ListView) findViewById(android.R.id.list);
         ListView mListView = (ListView) findViewById(android.R.id.list);
 
 
@@ -1006,10 +1016,20 @@ public class ReceiveExternalFilesActivity extends FileActivity
         }
         }
     }
     }
 
 
+    private boolean isHaveMultipleAccount() {
+        return mAccountManager.getAccountsByType(MainApp.getAccountType()).length > 1;
+    }
+
     @Override
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
     public boolean onCreateOptionsMenu(Menu menu) {
         MenuInflater inflater = getMenuInflater();
         MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.menu.receive_file_menu, menu);
         inflater.inflate(R.menu.receive_file_menu, menu);
+
+        if (!isHaveMultipleAccount()) {
+            MenuItem switchAccountMenu = menu.findItem(R.id.action_switch_account);
+            switchAccountMenu.setVisible(false);
+        }
+
         return true;
         return true;
     }
     }
 
 
@@ -1028,7 +1048,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
                     onBackPressed();
                     onBackPressed();
                 }
                 }
                 break;
                 break;
-            case R.id.action_choose_account:
+            case R.id.action_switch_account:
                 showAccountChooserDialog();
                 showAccountChooserDialog();
                 break;
                 break;
 
 

+ 3 - 3
src/main/res/menu/receive_file_menu.xml

@@ -28,10 +28,10 @@
         app:actionViewClass="android.support.v7.widget.SearchView"
         app:actionViewClass="android.support.v7.widget.SearchView"
         app:showAsAction="always"/>
         app:showAsAction="always"/>
     <item
     <item
-        android:id="@+id/action_choose_account"
-        android:contentDescription="@string/common_choose_account"
+        android:id="@+id/action_switch_account"
+        android:contentDescription="@string/common_switch_account"
         android:orderInCategory="1"
         android:orderInCategory="1"
-        android:title="@string/common_choose_account"
+        android:title="@string/common_switch_account"
         app:showAsAction="never"/>
         app:showAsAction="never"/>
     <item
     <item
         android:id="@+id/action_create_dir"
         android:id="@+id/action_create_dir"

+ 1 - 0
src/main/res/values/strings.xml

@@ -184,6 +184,7 @@
     <string name="downloader_not_downloaded_yet">Not downloaded yet</string>
     <string name="downloader_not_downloaded_yet">Not downloaded yet</string>
     <string name="downloader_download_failed_credentials_error">Download failed, you need to log in again</string>
     <string name="downloader_download_failed_credentials_error">Download failed, you need to log in again</string>
     <string name="common_choose_account">Choose account</string>
     <string name="common_choose_account">Choose account</string>
+    <string name="common_switch_account">Switch Account</string>
     <string name="sync_fail_ticker">Sync failed</string>
     <string name="sync_fail_ticker">Sync failed</string>
     <string name="sync_fail_ticker_unauthorized">Sync failed, you need to log in again</string>
     <string name="sync_fail_ticker_unauthorized">Sync failed, you need to log in again</string>
     <string name="sync_fail_content">Could not complete sync of %1$s</string>
     <string name="sync_fail_content">Could not complete sync of %1$s</string>