Merged PR 1187
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / FileActivity.java
index 3ea067a..ae75fde 100644 (file)
@@ -363,12 +363,7 @@ public class FileActivity extends AppCompatActivity
 //        }
 
         // Display username in drawer
-        Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
-        if (account != null) {
-            TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
-            int lastAtPos = account.name.lastIndexOf("@");
-            username.setText(account.name.substring(0, lastAtPos));
-        }
+        setUsernameInDrawer(navigationDrawerLayout, AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()));
 
         // load slide menu items
         mDrawerTitles = getResources().getStringArray(R.array.drawer_items);
@@ -394,7 +389,7 @@ public class FileActivity extends AppCompatActivity
 
         // Settings
         mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2],
-                R.drawable.ic_settings));
+                R.drawable.ic_action_settings));
         // Logs
         if (BuildConfig.DEBUG) {
             mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[3],
@@ -434,6 +429,21 @@ public class FileActivity extends AppCompatActivity
     }
 
     /**
+     * sets the given account name in the drawer in case the drawer is available. The account name
+     * is shortened beginning from the @-sign in the username.
+     *
+     * @param navigationDrawerLayout the drawer layout to be used
+     * @param account                the account to be set in the drawer
+     */
+    protected void setUsernameInDrawer(RelativeLayout navigationDrawerLayout, Account account) {
+        if (navigationDrawerLayout != null && getAccount() != null) {
+            TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
+            int lastAtPos = account.name.lastIndexOf("@");
+            username.setText(account.name.substring(0, lastAtPos));
+        }
+    }
+
+    /**
      * Updates title bar and home buttons (state and icon).
      *
      * Assumes that navigation drawer is NOT visible.
@@ -944,6 +954,10 @@ public class FileActivity extends AppCompatActivity
         restart();
     }
 
+    public void refreshDirectory(){
+        // overridden by FileDisplayActivity
+    }
+
     private class DrawerItemClickListener implements ListView.OnItemClickListener {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@@ -961,15 +975,13 @@ public class FileActivity extends AppCompatActivity
 
                 case 0: // All Files
                     MainApp.showOnlyFilesOnDevice(false);
-                    allFilesOption();
+                    refreshDirectory();
                     mDrawerLayout.closeDrawers();
                     break;
 
                 case 1: // On Device
-                    // TODO Tobi: refresh
                     MainApp.showOnlyFilesOnDevice(true);
-                    allFilesOption();
-
+                    refreshDirectory();
                     mDrawerLayout.closeDrawers();
                     break;