Disable 'Accounts' in Navigation Drawer
authormasensio <masensio@solidgear.es>
Fri, 29 May 2015 09:32:36 +0000 (11:32 +0200)
committermasensio <masensio@solidgear.es>
Fri, 29 May 2015 09:32:36 +0000 (11:32 +0200)
res/layout/drawer.xml
res/values/drawer_resources.xml
res/values/strings.xml
src/com/owncloud/android/ui/activity/FileActivity.java
src/com/owncloud/android/ui/adapter/NavigationDrawerListAdapter.java

index 249dd7d..07ad5ee 100644 (file)
     android:orientation="vertical"
     android:fitsSystemWindows="true">
 
     android:orientation="vertical"
     android:fitsSystemWindows="true">
 
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_margin="5dp">
+    <!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
+    <!--<LinearLayout-->
+        <!--android:layout_width="match_parent"-->
+        <!--android:layout_height="wrap_content"-->
+        <!--android:layout_margin="5dp">-->
 
 
-        <ImageView
-            android:id="@+id/drawer_userIcon"
-            android:layout_width="40dp"
-            android:layout_height="40dp"
-            android:src="@drawable/abc_ab_bottom_solid_dark_holo" />
+        <!--<ImageView-->
+            <!--android:id="@+id/drawer_userIcon"-->
+            <!--android:layout_width="40dp"-->
+            <!--android:layout_height="40dp"-->
+            <!--android:src="@drawable/abc_ab_bottom_solid_dark_holo" />-->
 
 
-        <TextView
-            android:id="@+id/drawer_username"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
-            android:layout_marginLeft="5dp"
-            android:layout_marginStart="5dp"
-            android:textAppearance="?android:attr/textAppearanceLarge" />
+        <!--<TextView-->
+            <!--android:id="@+id/drawer_username"-->
+            <!--android:layout_width="wrap_content"-->
+            <!--android:layout_height="wrap_content"-->
+            <!--android:layout_gravity="center_vertical"-->
+            <!--android:layout_marginLeft="5dp"-->
+            <!--android:layout_marginStart="5dp"-->
+            <!--android:textAppearance="?android:attr/textAppearanceLarge" />-->
 
 
-    </LinearLayout>
+    <!--</LinearLayout>-->
 
 
-    <TextView
-        android:layout_width="fill_parent"
-        android:layout_height="2dip"
-        android:background="@color/list_item_lastmod_and_filesize_text" />
+    <!--<TextView-->
+        <!--android:layout_width="fill_parent"-->
+        <!--android:layout_height="2dip"-->
+        <!--android:background="@color/list_item_lastmod_and_filesize_text" />-->
 
     <ListView
         android:id="@+id/drawer_list"
 
     <ListView
         android:id="@+id/drawer_list"
index ca0143b..287eb69 100644 (file)
@@ -20,7 +20,8 @@
 <resources>
     <!-- Nav Drawer Menu Items -->
     <string-array name="drawer_items">
 <resources>
     <!-- Nav Drawer Menu Items -->
     <string-array name="drawer_items">
-        <item>@string/prefs_accounts</item>
+        <!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
+        <!--<item>@string/prefs_accounts</item>-->
         <item>@string/drawer_item_all_files</item>
         <!--<item>@string/drawer_item_on_device</item>-->
         <item>@string/actionbar_settings</item>
         <item>@string/drawer_item_all_files</item>
         <!--<item>@string/drawer_item_on_device</item>-->
         <item>@string/actionbar_settings</item>
@@ -29,7 +30,8 @@
 
     <!-- Nav Drawer Content Descriptions -->
     <string-array name="drawer_content_descriptions">
 
     <!-- Nav Drawer Content Descriptions -->
     <string-array name="drawer_content_descriptions">
-        <item>@string/drawer_item_accounts</item>
+        <!-- TODO re-enable when "Accounts" is available in Navigation Drawer-->
+        <!--<item>@string/drawer_item_accounts</item>-->
         <item>@string/drawer_item_all_files</item>
         <!--<item>@string/drawer_item_on_device</item>-->
         <item>@string/drawer_item_settings</item>
         <item>@string/drawer_item_all_files</item>
         <!--<item>@string/drawer_item_on_device</item>-->
         <item>@string/drawer_item_settings</item>
index 8a7d813..a8ddd76 100644 (file)
@@ -20,7 +20,8 @@
        <!-- TODO re-enable when server-side folder size calculation is available   
        <item>Biggest - Smallest</item>  -->
     </string-array>
        <!-- TODO re-enable when server-side folder size calculation is available   
        <item>Biggest - Smallest</item>  -->
     </string-array>
-    <string name="drawer_item_accounts">Accounts</string>
+    <!-- TODO re-enable when "Accounts" is available in Navigation Drawer -->
+    <!--<string name="drawer_item_accounts">Accounts</string>-->
     <string name="drawer_item_all_files">All files</string>
     <!-- TODO re-enable when "On Device" is available
     <string name="drawer_item_on_device">On device</string>-->
     <string name="drawer_item_all_files">All files</string>
     <!-- TODO re-enable when "On Device" is available
     <string name="drawer_item_on_device">On device</string>-->
index e792df8..531de79 100644 (file)
@@ -157,7 +157,8 @@ public class FileActivity extends ActionBarActivity
 
     protected NavigationDrawerListAdapter mNavigationDrawerAdapter = null;
 
 
     protected NavigationDrawerListAdapter mNavigationDrawerAdapter = null;
 
-    protected boolean mShowAccounts = false;
+    // TODO re-enable when "Accounts" is available in Navigation Drawer
+//    protected boolean mShowAccounts = false;
     
     /**
      * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of 
     
     /**
      * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of 
@@ -304,19 +305,20 @@ public class FileActivity extends ActionBarActivity
         LinearLayout navigationDrawerLayout = (LinearLayout) findViewById(R.id.left_drawer);
         mDrawerList = (ListView) navigationDrawerLayout.findViewById(R.id.drawer_list);
 
         LinearLayout navigationDrawerLayout = (LinearLayout) findViewById(R.id.left_drawer);
         mDrawerList = (ListView) navigationDrawerLayout.findViewById(R.id.drawer_list);
 
-        // load Account in the Drawer Title
-        // User-Icon
-        ImageView userIcon = (ImageView) navigationDrawerLayout.findViewById(R.id.drawer_userIcon);
-        userIcon.setImageResource(DisplayUtils.getSeasonalIconId());
-
-        // Username
-        TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
-        Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
-
-        if (account != null) {
-            int lastAtPos = account.name.lastIndexOf("@");
-            username.setText(account.name.substring(0, lastAtPos));
-        }
+        // TODO re-enable when "Accounts" is available in Navigation Drawer
+//        // load Account in the Drawer Title
+//        // User-Icon
+//        ImageView userIcon = (ImageView) navigationDrawerLayout.findViewById(R.id.drawer_userIcon);
+//        userIcon.setImageResource(DisplayUtils.getSeasonalIconId());
+//
+//        // Username
+//        TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
+//        Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
+//
+//        if (account != null) {
+//            int lastAtPos = account.name.lastIndexOf("@");
+//            username.setText(account.name.substring(0, lastAtPos));
+//        }
 
         // load slide menu items
         mDrawerTitles = getResources().getStringArray(R.array.drawer_items);
 
         // load slide menu items
         mDrawerTitles = getResources().getStringArray(R.array.drawer_items);
@@ -328,10 +330,12 @@ public class FileActivity extends ActionBarActivity
         // nav drawer items
         mDrawerItems = new ArrayList<NavigationDrawerItem>();
         // adding nav drawer items to array
         // nav drawer items
         mDrawerItems = new ArrayList<NavigationDrawerItem>();
         // adding nav drawer items to array
+        // TODO re-enable when "Accounts" is available in Navigation Drawer
         // Accounts
         // Accounts
-        mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0]));
+        // mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0],
+        // mDrawerContentDescriptions[0]));
         // All Files
         // All Files
-        mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1]));
+        mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0]));
 
         // TODO Enable when "On Device" is recovered
         // On Device
 
         // TODO Enable when "On Device" is recovered
         // On Device
@@ -339,11 +343,11 @@ public class FileActivity extends ActionBarActivity
         //        mDrawerContentDescriptions[2]));
 
         // Settings
         //        mDrawerContentDescriptions[2]));
 
         // Settings
-        mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2]));
+        mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1]));
         // Logs
         if (BuildConfig.DEBUG) {
         // Logs
         if (BuildConfig.DEBUG) {
-            mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[3],
-                    mDrawerContentDescriptions[3]));
+            mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
+                    mDrawerContentDescriptions[2]));
         }
 
         // setting the nav drawer list adapter
         }
 
         // setting the nav drawer list adapter
@@ -818,9 +822,10 @@ public class FileActivity extends ActionBarActivity
         startActivity(i);
     }
 
         startActivity(i);
     }
 
-    public void closeDrawer() {
-        mDrawerLayout.closeDrawers();
-    }
+//    TODO re-enable when "Accounts" is available in Navigation Drawer
+//    public void closeDrawer() {
+//        mDrawerLayout.closeDrawers();
+//    }
 
     public void allFilesOption(){
         restart();
 
     public void allFilesOption(){
         restart();
@@ -829,17 +834,19 @@ public class FileActivity extends ActionBarActivity
     private class DrawerItemClickListener implements ListView.OnItemClickListener {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
     private class DrawerItemClickListener implements ListView.OnItemClickListener {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-            if (mShowAccounts && position > 0){
-                position = position - 1;
-            }
+            // TODO re-enable when "Accounts" is available in Navigation Drawer
+//            if (mShowAccounts && position > 0){
+//                position = position - 1;
+//            }
             switch (position){
             switch (position){
-                case 0: // Accounts
-                    mShowAccounts = !mShowAccounts;
-                    mNavigationDrawerAdapter.setShowAccounts(mShowAccounts);
-                    mNavigationDrawerAdapter.notifyDataSetChanged();
-                    break;
+                // TODO re-enable when "Accounts" is available in Navigation Drawer
+//                case 0: // Accounts
+//                    mShowAccounts = !mShowAccounts;
+//                    mNavigationDrawerAdapter.setShowAccounts(mShowAccounts);
+//                    mNavigationDrawerAdapter.notifyDataSetChanged();
+//                    break;
 
 
-                case 1: // All Files
+                case 0: // All Files
                     allFilesOption();
                     mDrawerLayout.closeDrawers();
                     break;
                     allFilesOption();
                     mDrawerLayout.closeDrawers();
                     break;
@@ -850,7 +857,7 @@ public class FileActivity extends ActionBarActivity
 //                    mDrawerLayout.closeDrawers();
 //                    break;
 
 //                    mDrawerLayout.closeDrawers();
 //                    break;
 
-                case 2: // Settings
+                case 1: // Settings
                     Intent settingsIntent = new Intent(getApplicationContext(),
                             Preferences.class);
                     startActivity(settingsIntent);
                     Intent settingsIntent = new Intent(getApplicationContext(),
                             Preferences.class);
                     startActivity(settingsIntent);
index fdc1971..428acd8 100644 (file)
@@ -121,92 +121,93 @@ public class NavigationDrawerListAdapter extends BaseAdapter {
 
                 return view;
             }
 
                 return view;
             }
-
+            // TODO re-enable when "Accounts" is available in Navigation Drawer
             // Account
             // Account
-            if (mAll.get(position) instanceof Account[]){
-                final View view = inflator.inflate(R.layout.drawer_account_group, null);
-
-                final RadioGroup group = (RadioGroup) view.findViewById(R.id.drawer_radio_group);
-
-                for (Account account : mAccounts) {
-                    RadioButton rb = new RadioButton(mContext);
-
-                    rb.setText(account.name);
-                    rb.setContentDescription(account.name);
-                    rb.setTextColor(Color.BLACK);
-                    rb.setEllipsize(TextUtils.TruncateAt.MIDDLE);
-                    rb.setSingleLine();
-                    rb.setCompoundDrawablePadding(30);
-
-
-                    try {
-                        // using adapted algorithm from /core/js/placeholder.js:50
-                        int lastAtPos = account.name.lastIndexOf("@");
-                        String username  = account.name.substring(0, lastAtPos);
-                        byte[] seed = username.getBytes("UTF-8");
-                        MessageDigest md = MessageDigest.getInstance("MD5");
-//                        Integer seedMd5Int = Math.abs(new String(Hex.encodeHex(seedMd5))
-//                      .hashCode());
-                        Integer seedMd5Int = String.format(Locale.ROOT, "%032x",
-                                new BigInteger(1, md.digest(seed))).hashCode();
-
-                        double maxRange = java.lang.Integer.MAX_VALUE;
-                        float hue = (float) (seedMd5Int / maxRange * 360);
-
-                        int[] rgb = BitmapUtils.HSLtoRGB(hue, 90.0f, 65.0f, 1.0f);
-
-                        TextDrawable text = new TextDrawable(username.substring(0, 1).toUpperCase(),
-                                rgb[0], rgb[1], rgb[2]);
-                        rb.setCompoundDrawablesWithIntrinsicBounds(text, null, null, null);
-
-
-                    } catch (Exception e){
-                        Log_OC.d(TAG, e.toString());
-                        rb.setTextColor(mContext.getResources().getColor(R.color.black));
-                    }
-                    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
-                            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
-                    params.weight=1.0f;
-                    params.setMargins(15, 5, 5, 5);
-
-                    // Check the current account that is being used
-                    if (account.name.equals(mCurrentAccount.name)) {
-                        rb.setChecked(true);
-                    } else {
-                        rb.setChecked(false);
-                    }
-
-                    group.addView(rb, params);
-                }
-
-                group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
-                    public void onCheckedChanged(RadioGroup group, int checkedId) {
-                        // checkedId is the RadioButton selected
-                        RadioButton rb = (RadioButton) view.findViewById(checkedId);
-
-                        AccountUtils.setCurrentOwnCloudAccount(mContext,rb.getText().toString());
-                        notifyDataSetChanged();
-                        mFileActivity.closeDrawer();
-                        
-                        // restart the main activity
-                        mFileActivity.restart();
-                    }
-                });
-
-                return view;
-            }
+//            if (mAll.get(position) instanceof Account[]){
+//                final View view = inflator.inflate(R.layout.drawer_account_group, null);
+//
+//                final RadioGroup group = (RadioGroup) view.findViewById(R.id.drawer_radio_group);
+//
+//                for (Account account : mAccounts) {
+//                    RadioButton rb = new RadioButton(mContext);
+//
+//                    rb.setText(account.name);
+//                    rb.setContentDescription(account.name);
+//                    rb.setTextColor(Color.BLACK);
+//                    rb.setEllipsize(TextUtils.TruncateAt.MIDDLE);
+//                    rb.setSingleLine();
+//                    rb.setCompoundDrawablePadding(30);
+//
+//
+//                    try {
+//                        // using adapted algorithm from /core/js/placeholder.js:50
+//                        int lastAtPos = account.name.lastIndexOf("@");
+//                        String username  = account.name.substring(0, lastAtPos);
+//                        byte[] seed = username.getBytes("UTF-8");
+//                        MessageDigest md = MessageDigest.getInstance("MD5");
+////                        Integer seedMd5Int = Math.abs(new String(Hex.encodeHex(seedMd5))
+////                      .hashCode());
+//                        Integer seedMd5Int = String.format(Locale.ROOT, "%032x",
+//                                new BigInteger(1, md.digest(seed))).hashCode();
+//
+//                        double maxRange = java.lang.Integer.MAX_VALUE;
+//                        float hue = (float) (seedMd5Int / maxRange * 360);
+//
+//                        int[] rgb = BitmapUtils.HSLtoRGB(hue, 90.0f, 65.0f, 1.0f);
+//
+//                        TextDrawable text = new TextDrawable(username.substring(0, 1).toUpperCase(),
+//                                rgb[0], rgb[1], rgb[2]);
+//                        rb.setCompoundDrawablesWithIntrinsicBounds(text, null, null, null);
+//
+//
+//                    } catch (Exception e){
+//                        Log_OC.d(TAG, e.toString());
+//                        rb.setTextColor(mContext.getResources().getColor(R.color.black));
+//                    }
+//                    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
+//                            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+//                    params.weight=1.0f;
+//                    params.setMargins(15, 5, 5, 5);
+//
+//                    // Check the current account that is being used
+//                    if (account.name.equals(mCurrentAccount.name)) {
+//                        rb.setChecked(true);
+//                    } else {
+//                        rb.setChecked(false);
+//                    }
+//
+//                    group.addView(rb, params);
+//                }
+//
+//                group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
+//                    public void onCheckedChanged(RadioGroup group, int checkedId) {
+//                        // checkedId is the RadioButton selected
+//                        RadioButton rb = (RadioButton) view.findViewById(checkedId);
+//
+//                        AccountUtils.setCurrentOwnCloudAccount(mContext,rb.getText().toString());
+//                        notifyDataSetChanged();
+//                        mFileActivity.closeDrawer();
+//
+//                        // restart the main activity
+//                        mFileActivity.restart();
+//                    }
+//                });
+//
+//                return view;
+//            }
         }
         return convertView;
     }
 
         }
         return convertView;
     }
 
+    //TODO re-enable when "Accounts" is available in Navigation Drawer
     // TODO update Account List after creating a new account and on fresh installation
     // TODO update Account List after creating a new account and on fresh installation
-    public void setShowAccounts(boolean value){
-        mAll.clear();
-        mAll.addAll(mNavigationDrawerItems);
-
-        if (value){
-            mAll.add(1, mAccounts);
-        }
-        mShowAccounts = value;
-    }
+//    public void setShowAccounts(boolean value){
+//        mAll.clear();
+//        mAll.addAll(mNavigationDrawerItems);
+//
+//        if (value){
+//            mAll.add(1, mAccounts);
+//        }
+//        mShowAccounts = value;
+//    }
 }
 }