Merge branch 'remove_ActionBarSherlock' into navigationDrawer_update
authormasensio <masensio@solidgear.es>
Wed, 27 May 2015 12:19:30 +0000 (14:19 +0200)
committermasensio <masensio@solidgear.es>
Wed, 27 May 2015 12:19:30 +0000 (14:19 +0200)
Conflicts:
res/menu/main_menu.xml
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/activity/FolderPickerActivity.java
src/com/owncloud/android/ui/activity/Preferences.java
src/com/owncloud/android/ui/preview/PreviewImageActivity.java

34 files changed:
res/drawable-hdpi/ic_drawer.png [new file with mode: 0644]
res/drawable-mdpi/ic_drawer.png [new file with mode: 0644]
res/drawable-xhdpi/ic_drawer.png [new file with mode: 0644]
res/layout/drawer_account_group.xml [new file with mode: 0644]
res/layout/drawer_list_item.xml [new file with mode: 0644]
res/layout/drawer_radiobutton.xml [new file with mode: 0644]
res/layout/files.xml
res/layout/listrow_details.xml [new file with mode: 0644]
res/layout/listrow_group.xml [new file with mode: 0644]
res/layout/uploader_layout.xml
res/layout/uploader_list_item_layout.xml
res/menu/main_menu.xml
res/values/colors.xml
res/values/drawer_resources.xml [new file with mode: 0644]
res/values/strings.xml
src/com/owncloud/android/MainApp.java
src/com/owncloud/android/datamodel/FileDataStorageManager.java
src/com/owncloud/android/operations/RefreshFolderOperation.java
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
src/com/owncloud/android/ui/NavigationDrawerItem.java [new file with mode: 0644]
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/activity/FolderPickerActivity.java
src/com/owncloud/android/ui/activity/Preferences.java
src/com/owncloud/android/ui/activity/UploadPathActivity.java
src/com/owncloud/android/ui/activity/Uploader.java
src/com/owncloud/android/ui/adapter/FileListListAdapter.java
src/com/owncloud/android/ui/adapter/Group.java [new file with mode: 0644]
src/com/owncloud/android/ui/adapter/MyExpandableListAdapter.java [new file with mode: 0644]
src/com/owncloud/android/ui/adapter/NavigationDrawerListAdapter.java [new file with mode: 0644]
src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
src/com/owncloud/android/ui/preview/PreviewImageActivity.java
src/com/owncloud/android/ui/preview/PreviewImagePagerAdapter.java
src/com/owncloud/android/utils/BitmapUtils.java

diff --git a/res/drawable-hdpi/ic_drawer.png b/res/drawable-hdpi/ic_drawer.png
new file mode 100644 (file)
index 0000000..6614ea4
Binary files /dev/null and b/res/drawable-hdpi/ic_drawer.png differ
diff --git a/res/drawable-mdpi/ic_drawer.png b/res/drawable-mdpi/ic_drawer.png
new file mode 100644 (file)
index 0000000..fb681ba
Binary files /dev/null and b/res/drawable-mdpi/ic_drawer.png differ
diff --git a/res/drawable-xhdpi/ic_drawer.png b/res/drawable-xhdpi/ic_drawer.png
new file mode 100644 (file)
index 0000000..b9bc3d7
Binary files /dev/null and b/res/drawable-xhdpi/ic_drawer.png differ
diff --git a/res/layout/drawer_account_group.xml b/res/layout/drawer_account_group.xml
new file mode 100644 (file)
index 0000000..85a1c75
--- /dev/null
@@ -0,0 +1,22 @@
+<!--
+  Copyright 2013 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+  <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/drawer_radio_group"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_horizontal"
+        android:orientation="vertical" >
+    </RadioGroup>
\ No newline at end of file
diff --git a/res/layout/drawer_list_item.xml b/res/layout/drawer_list_item.xml
new file mode 100644 (file)
index 0000000..30f3843
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ownCloud Android client application
+
+  Copyright (C) 2015 ownCloud Inc.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License version 2,
+  as published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/itemLayout"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:layout_alignParentLeft="true"
+    android:orientation="horizontal"
+    android:background="@color/background_color"
+    android:layout_marginTop="10dp"
+    android:layout_marginBottom="10dp">
+
+    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/itemTitle"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:gravity="center_vertical"
+        android:paddingLeft="16dp"
+        android:paddingRight="16dp"
+        android:textColor="@color/textColor"
+        android:text="@string/app_name"
+        android:textAppearance="?android:attr/textAppearanceListItemSmall"
+        android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
+</LinearLayout>
+
diff --git a/res/layout/drawer_radiobutton.xml b/res/layout/drawer_radiobutton.xml
new file mode 100644 (file)
index 0000000..917d894
--- /dev/null
@@ -0,0 +1,9 @@
+<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/drawer_radiobutton"
+    android:layout_width="fill_parent"
+    android:layout_height="56dp"
+    android:gravity="center_vertical"
+    android:paddingLeft="16dp"
+    android:paddingRight="16dp"
+    android:textColor="#000"
+    android:textSize="18dp" />
\ No newline at end of file
index 5d62c13..5f11f06 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>\r
-<!-- \r
+<!--\r
   ownCloud Android client application\r
 \r
   Copyright (C) 2012  Bartek Przybylski\r
 \r
   You should have received a copy of the GNU General Public License\r
   along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- -->\r
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+  -->\r
+<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:id="@+id/drawer_layout"\r
     android:layout_width="match_parent"\r
     android:layout_height="match_parent"\r
-    android:background="@color/background_color"\r
-    android:orientation="horizontal"\r
-    android:baselineAligned="false"\r
-    >\r
-\r
-       <FrameLayout \r
-               android:layout_width="0dp"\r
-               android:layout_height="match_parent"\r
-               android:layout_weight="1"\r
-               android:id="@+id/left_fragment_container"\r
-           />\r
-       \r
-       <FrameLayout \r
-               android:layout_width="0dp"\r
-               android:layout_height="match_parent"\r
-               android:layout_weight="2"\r
-               android:id="@+id/right_fragment_container"\r
-           />\r
-       \r
- </LinearLayout>
\ No newline at end of file
+    android:clickable="true" >\r
+\r
+    <!-- The main content view -->\r
+    <LinearLayout\r
+        xmlns:android="http://schemas.android.com/apk/res/android"\r
+        android:layout_width="match_parent"\r
+        android:layout_height="match_parent"\r
+        android:background="@color/background_color"\r
+        android:baselineAligned="false"\r
+        android:orientation="horizontal" >\r
+\r
+\r
+        <FrameLayout\r
+            android:id="@+id/left_fragment_container"\r
+            android:layout_width="0dp"\r
+            android:layout_height="match_parent"\r
+            android:layout_weight="1" />\r
+\r
+        <FrameLayout\r
+            android:id="@+id/right_fragment_container"\r
+            android:layout_width="0dp"\r
+            android:layout_height="match_parent"\r
+            android:layout_weight="2" />\r
+    </LinearLayout>\r
+\r
+\r
+    <LinearLayout\r
+        xmlns:android="http://schemas.android.com/apk/res/android"\r
+        android:id="@+id/left_drawer"\r
+        android:layout_width="240dp"\r
+        android:layout_height="match_parent"\r
+        android:layout_gravity="start"\r
+        android:background="@color/background_color"\r
+        android:baselineAligned="false"\r
+        android:clickable="true"\r
+        android:orientation="vertical">\r
+\r
+        <LinearLayout\r
+            android:layout_width="match_parent"\r
+            android:layout_height="wrap_content"\r
+            android:layout_margin="5dp">\r
+\r
+            <ImageView\r
+                android:id="@+id/drawer_userIcon"\r
+                android:layout_width="40dp"\r
+                android:layout_height="40dp"\r
+                android:src="@drawable/abc_ab_bottom_solid_dark_holo" />\r
+\r
+            <TextView\r
+                android:id="@+id/drawer_username"\r
+                android:layout_width="wrap_content"\r
+                android:layout_height="wrap_content"\r
+                android:layout_gravity="center_vertical"\r
+                android:layout_marginLeft="5dp"\r
+                android:layout_marginStart="5dp"\r
+                android:textAppearance="?android:attr/textAppearanceLarge" />\r
+\r
+        </LinearLayout>\r
+\r
+        <TextView\r
+            android:layout_width="fill_parent"\r
+            android:layout_height="2dip"\r
+            android:background="@color/list_item_lastmod_and_filesize_text" />\r
+\r
+        <ListView\r
+            android:id="@+id/drawer_list"\r
+            android:layout_width="fill_parent"\r
+            android:layout_height="match_parent"\r
+            android:background="@color/background_color"\r
+            android:choiceMode="singleChoice"\r
+            />\r
+    </LinearLayout>\r
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
diff --git a/res/layout/listrow_details.xml b/res/layout/listrow_details.xml
new file mode 100644 (file)
index 0000000..01651bf
--- /dev/null
@@ -0,0 +1,27 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="56dp"
+    android:clickable="true"
+    android:orientation="vertical"
+    android:background="#fff"
+    android:paddingLeft="16dp"
+    tools:context=".MainActivity" >
+
+    <TextView
+        android:id="@+id/textView1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:drawablePadding="5dp"
+        android:gravity="center_vertical"
+        android:paddingLeft="16dp"
+        android:textSize="16dp" >
+
+    </TextView>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="@android:color/black" />
+
+</LinearLayout> 
\ No newline at end of file
diff --git a/res/layout/listrow_group.xml b/res/layout/listrow_group.xml
new file mode 100644 (file)
index 0000000..735a11e
--- /dev/null
@@ -0,0 +1,13 @@
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/textView1"
+    android:layout_width="wrap_content"
+    android:background="#fff"
+    android:layout_height="56dp"
+    android:layout_marginLeft="8dp"
+    android:gravity="left"
+    android:paddingLeft="16dp"
+    android:paddingTop="8dp"
+    android:textSize="16dp"
+    android:groupIndicator="@android:color/transparent"
+/> 
\ No newline at end of file
index 60a2111..a5351f0 100644 (file)
        android:layout_width="wrap_content" android:background="#fefefe"
        android:gravity="center">
        <TextView android:layout_width="fill_parent" android:text="@string/uploader_top_message"
-               android:layout_height="wrap_content" android:id="@+id/textView1" android:textColor="@android:color/black"
+               android:layout_height="wrap_content" android:id="@+id/drawer_username" android:textColor="@android:color/black"
                android:gravity="center_horizontal"></TextView>
        <FrameLayout android:layout_height="fill_parent"
                android:layout_width="fill_parent" android:id="@+id/frameLayout1"
-               android:layout_below="@+id/textView1" android:layout_above="@+id/linearLayout1">
+               android:layout_below="@+id/drawer_username" android:layout_above="@+id/linearLayout1">
                <ListView android:id="@android:id/list" android:layout_width="fill_parent"
                        android:layout_height="fill_parent" android:divider="@drawable/uploader_list_separator"
                        android:dividerHeight="1dip"></ListView>
index e093269..d2d0005 100644 (file)
@@ -35,7 +35,7 @@
     <TextView 
         android:text="TextView" 
         android:layout_width="fill_parent" 
-        android:id="@+id/textView1
+        android:id="@+id/drawer_username
         android:layout_height="wrap_content" 
         android:textColor="@android:color/black"
                android:layout_gravity="center_vertical"
index 053d84a..117afdd 100644 (file)
@@ -57,9 +57,9 @@
         android:contentDescription="@string/actionbar_logger"/>
        <item
         android:id="@+id/action_sort"
-        android:icon="@android:drawable/ic_menu_sort_alphabetically"
+        android:icon="@android:drawable/ic_menu_sort_by_size"
         android:orderInCategory="2"
-        app:showAsAction="never"
+        app:showAsAction="always"
         android:title="@string/actionbar_sort"
         android:contentDescription="@string/actionbar_sort"/>
 
index 6aeb6ac..b42538f 100644 (file)
@@ -22,6 +22,7 @@
     <color name="filelist_icon_backgorund">#DDDDDD</color>
     <color name="owncloud_blue_bright">#00ddff</color>
     <color name="list_item_lastmod_and_filesize_text">#989898</color>
+    <color name="black">#000000</color>
     <color name="textColor">#303030</color>
     <color name="list_divider_background">#fff0f0f0</color>
     
diff --git a/res/values/drawer_resources.xml b/res/values/drawer_resources.xml
new file mode 100644 (file)
index 0000000..ca0143b
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ownCloud Android client application
+
+  Copyright (C) 2015 ownCloud Inc.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License version 2,
+  as published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<resources>
+    <!-- Nav Drawer Menu Items -->
+    <string-array name="drawer_items">
+        <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/actionbar_logger</item>
+    </string-array>
+
+    <!-- Nav Drawer Content Descriptions -->
+    <string-array name="drawer_content_descriptions">
+        <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_logs</item>
+    </string-array>
+
+</resources>
\ No newline at end of file
index 0e2e945..8a7d813 100644 (file)
        <!-- TODO re-enable when server-side folder size calculation is available   
        <item>Biggest - Smallest</item>  -->
     </string-array>
+    <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_settings">Settings</string>
+    <string name="drawer_item_logs">Logs</string>
+    <string name="drawer_open">ownCloud</string>
+       <string name="drawer_close">Close</string>
     <string name="prefs_category_general">General</string>
     <string name="prefs_category_more">More</string>
     <string name="prefs_accounts">Accounts</string>
        <string name="prefs_instant_video_upload_path_title">Upload Video Path</string>
     <string name="download_folder_failed_content">Download of %1$s folder could not be completed</string>
 
-       <string name="subject_token">%1$s shared \"%2$s\" with you</string>
+       <string name="shared_subject_header">shared</string>
+       <string name="with_you_subject_header">with you</string>
+    
+       <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
 
     <string name="auth_refresh_button">Refresh connection</string>
     <string name="auth_host_address">Server address</string>
     <string name="common_error_out_memory">Not enough memory</string>
 
+    <string name="username">Username</string>
 </resources>
index 657469e..c805f9f 100644 (file)
@@ -53,6 +53,11 @@ public class MainApp extends Application {
     private static final String POLICY_ALWAYS_NEW_CLIENT = "always new client";
 
     private static Context mContext;
+
+    // TODO Enable when "On Device" is recovered?
+    // TODO better place
+    // private static boolean mOnlyOnDevice = false;
+
     
     public void onCreate(){
         super.onCreate();
@@ -171,6 +176,15 @@ public class MainApp extends Application {
         return getAppContext().getResources().getString(R.string.log_name);
     }
 
+    // TODO Enable when "On Device" is recovered ?
+//    public static void showOnlyFilesOnDevice(boolean state){
+//        mOnlyOnDevice = state;
+//    }
+//
+//    public static boolean getOnlyOnDevice(){
+//        return mOnlyOnDevice;
+//    }
+
     // user agent
     public static String getUserAgent() {
         String appString = getAppContext().getResources().getString(R.string.user_agent);
index c32dbbc..7db0a63 100644 (file)
@@ -28,14 +28,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 
-import com.owncloud.android.MainApp;
-import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
-import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.lib.resources.shares.OCShare;
-import com.owncloud.android.lib.resources.shares.ShareType;
-import com.owncloud.android.lib.resources.files.FileUtils;
-import com.owncloud.android.utils.FileStorageUtils;
-
 import android.accounts.Account;
 import android.content.ContentProviderClient;
 import android.content.ContentProviderOperation;
@@ -50,6 +42,14 @@ import android.net.Uri;
 import android.os.RemoteException;
 import android.provider.MediaStore;
 
+import com.owncloud.android.MainApp;
+import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
+import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.lib.resources.files.FileUtils;
+import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.resources.shares.ShareType;
+import com.owncloud.android.utils.FileStorageUtils;
+
 public class FileDataStorageManager {
 
     public static final int ROOT_PARENT_ID = 0;
@@ -142,9 +142,10 @@ public class FileDataStorageManager {
     }
 
     
-    public Vector<OCFile> getFolderContent(OCFile f) {
+    public Vector<OCFile> getFolderContent(OCFile f/*, boolean onlyOnDevice*/) {
         if (f != null && f.isFolder() && f.getFileId() != -1) {
-            return getFolderContent(f.getFileId());
+            // TODO Enable when "On Device" is recovered ?
+            return getFolderContent(f.getFileId()/*, onlyOnDevice*/);
 
         } else {
             return new Vector<OCFile>();
@@ -152,11 +153,12 @@ public class FileDataStorageManager {
     }
     
     
-    public Vector<OCFile> getFolderImages(OCFile folder) {
+    public Vector<OCFile> getFolderImages(OCFile folder/*, boolean onlyOnDevice*/) {
         Vector<OCFile> ret = new Vector<OCFile>(); 
         if (folder != null) {
-            // TODO better implementation, filtering in the access to database instead of here 
-            Vector<OCFile> tmp = getFolderContent(folder);
+            // TODO better implementation, filtering in the access to database instead of here
+            // TODO Enable when "On Device" is recovered ?
+            Vector<OCFile> tmp = getFolderContent(folder/*, onlyOnDevice*/);
             OCFile current = null; 
             for (int i=0; i<tmp.size(); i++) {
                 current = tmp.get(i);
@@ -547,7 +549,8 @@ public class FileDataStorageManager {
         File localFolder = new File(localFolderPath);
         if (localFolder.exists()) {
             // stage 1: remove the local files already registered in the files database
-            Vector<OCFile> files = getFolderContent(folder.getFileId());
+            // TODO Enable when "On Device" is recovered ?
+            Vector<OCFile> files = getFolderContent(folder.getFileId()/*, false*/);
             if (files != null) {
                 for (OCFile file : files) {
                     if (file.isFolder()) {
@@ -731,7 +734,7 @@ public class FileDataStorageManager {
     }
     
     
-    private Vector<OCFile> getFolderContent(long parentId) {
+    private Vector<OCFile> getFolderContent(long parentId/*, boolean onlyOnDevice*/) {
 
         Vector<OCFile> ret = new Vector<OCFile>();
 
@@ -758,7 +761,10 @@ public class FileDataStorageManager {
         if (c.moveToFirst()) {
             do {
                 OCFile child = createFileInstance(c);
-                ret.add(child);
+                // TODO Enable when "On Device" is recovered ?
+                // if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
+                    ret.add(child);
+                // }
             } while (c.moveToNext());
         }
 
@@ -1435,14 +1441,14 @@ public class FileDataStorageManager {
     }
 
     private ArrayList<ContentProviderOperation> prepareRemoveSharesInFolder(
-            OCFile folder, ArrayList<ContentProviderOperation> preparedOperations
-            ) {
+            OCFile folder, ArrayList<ContentProviderOperation> preparedOperations) {
         if (folder != null) {
             String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND " 
                     + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
             String [] whereArgs = new String[]{ "", mAccount.name };
-            
-            Vector<OCFile> files = getFolderContent(folder);
+
+            // TODO Enable when "On Device" is recovered ?
+            Vector<OCFile> files = getFolderContent(folder /*, false*/);
             
             for (OCFile file : files) {
                 whereArgs[0] = file.getRemotePath();
index 50a35fd..2e3c469 100644 (file)
@@ -201,7 +201,8 @@ public class RefreshFolderOperation extends RemoteOperation {
             if (mRemoteFolderChanged) {
                 result = fetchAndSyncRemoteFolder(client);
             } else {
-                mChildren = mStorageManager.getFolderContent(mLocalFolder);
+                // TODO Enable when "On Device" is recovered ?
+                mChildren = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
             }
         }
         
@@ -341,7 +342,8 @@ public class RefreshFolderOperation extends RemoteOperation {
         List<SynchronizeFileOperation> filesToSyncContents = new Vector<SynchronizeFileOperation>();
 
         // get current data about local contents of the folder to synchronize
-        List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder);
+        // TODO Enable when "On Device" is recovered ?
+        List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
         Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
         for (OCFile file : localFiles) {
             localFilesMap.put(file.getRemotePath(), file);
index 286b5ea..6bf1ef8 100644 (file)
 
 package com.owncloud.android.operations;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
 import android.accounts.Account;
 import android.content.Context;
 import android.content.Intent;
 import android.util.Log;
 
-import com.owncloud.android.MainApp;
+
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileDownloader;
@@ -41,12 +48,6 @@ import com.owncloud.android.operations.common.SyncOperation;
 import com.owncloud.android.services.OperationsService;
 import com.owncloud.android.utils.FileStorageUtils;
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 //import android.support.v4.content.LocalBroadcastManager;
@@ -297,7 +298,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
         }
 
         // get current data about local contents of the folder to synchronize
-        List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder);
+        // TODO Enable when "On Device" is recovered ?
+        List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder/*, false*/);
         Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
         for (OCFile file : localFiles) {
             localFilesMap.put(file.getRemotePath(), file);
@@ -392,7 +394,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
     
     
     private void prepareOpsFromLocalKnowledge() throws OperationCancelledException {
-        List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder);
+        // TODO Enable when "On Device" is recovered ?
+        List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder/*, false*/);
         for (OCFile child : children) {
             /// classify file to sync/download contents later
             if (child.isFolder()) {
diff --git a/src/com/owncloud/android/ui/NavigationDrawerItem.java b/src/com/owncloud/android/ui/NavigationDrawerItem.java
new file mode 100644 (file)
index 0000000..44ed3ec
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ *   ownCloud Android client application
+ *
+ *   @author masensio
+ *   Copyright (C) 2015 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.ui;
+
+public class NavigationDrawerItem {
+
+    private String mTitle;
+    private String mContentDescription;
+
+    // Constructors
+    public NavigationDrawerItem(){}
+
+    public NavigationDrawerItem(String title){
+        mTitle = title;
+    }
+
+    public NavigationDrawerItem(String title, String contentDescription){
+        mTitle = title;
+        mContentDescription = contentDescription;
+    }
+
+    // Getters and Setters
+    public String getTitle() {
+        return mTitle;
+    }
+
+    public void setTitle(String title) {
+        this.mTitle = title;
+    }
+
+    public String getContentDescription() {
+        return mContentDescription;
+    }
+
+    public void setContentDescription(String contentDescription) {
+        this.mContentDescription = contentDescription;
+    }
+}
index 67173d7..0844dc2 100644 (file)
@@ -23,6 +23,7 @@
 package com.owncloud.android.ui.activity;
 
 import java.io.File;
+import java.util.ArrayList;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
@@ -39,6 +40,7 @@ import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.content.SharedPreferences;
 import android.content.SyncRequest;
+import android.content.res.Configuration;
 import android.content.res.Resources.NotFoundException;
 import android.database.Cursor;
 import android.net.Uri;
@@ -47,9 +49,13 @@ import android.os.Bundle;
 import android.os.IBinder;
 import android.preference.PreferenceManager;
 import android.provider.OpenableColumns;
+import android.support.v4.app.ActionBarDrawerToggle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
+
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
 import android.support.v7.app.ActionBar;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -57,13 +63,19 @@ import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.Window;
+
+import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.Toast;
 
 import com.owncloud.android.BuildConfig;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileDownloader;
 import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
@@ -89,6 +101,8 @@ import com.owncloud.android.operations.RefreshFolderOperation;
 import com.owncloud.android.operations.UnshareLinkOperation;
 import com.owncloud.android.services.observer.FileObserverService;
 import com.owncloud.android.syncadapter.FileSyncAdapter;
+import com.owncloud.android.ui.NavigationDrawerItem;
+import com.owncloud.android.ui.adapter.NavigationDrawerListAdapter;
 import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
 import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
@@ -150,8 +164,22 @@ public class FileDisplayActivity extends HookActivity implements
     private static String DIALOG_UPLOAD_SOURCE = "DIALOG_UPLOAD_SOURCE";
     private static String DIALOG_CERT_NOT_SAVED = "DIALOG_CERT_NOT_SAVED";
 
-
     private OCFile mWaitingToSend;
+
+    // Navigation Drawer
+    private DrawerLayout mDrawerLayout;
+    private ActionBarDrawerToggle mDrawerToggle;
+    private ListView mDrawerList;
+
+    // Slide menu items
+    private String[] mDrawerTitles;
+    private String[] mDrawerContentDescriptions;
+
+    private ArrayList<NavigationDrawerItem> mDrawerItems;
+
+    private NavigationDrawerListAdapter mNavigationDrawerAdapter = null;
+
+    private boolean mShowAccounts = false;
     
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -184,7 +212,11 @@ public class FileDisplayActivity extends HookActivity implements
         /// USER INTERFACE
 
         // Inflate and set the layout view
-        setContentView(R.layout.files);    
+        setContentView(R.layout.files);
+        
+        // Navigation Drawer
+        initDrawer();
+
         mDualPane = getResources().getBoolean(R.bool.large_land_layout);
         mLeftFragmentContainer = findViewById(R.id.left_fragment_container);
         mRightFragmentContainer = findViewById(R.id.right_fragment_container);
@@ -201,12 +233,101 @@ public class FileDisplayActivity extends HookActivity implements
         setSupportProgressBarIndeterminateVisibility(mSyncInProgress
         /*|| mRefreshSharesInProgress*/);
         // always AFTER setContentView(...) ; to work around bug in its implementation
+
+        // TODO Remove??, it is done in onPostCreate
+        mDrawerToggle.syncState();
         
         setBackgroundText();
 
         Log_OC.v(TAG, "onCreate() end");
     }
-    
+
+    private void initDrawer(){
+        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+        // Notification Drawer
+        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));
+        }
+
+        // load slide menu items
+        mDrawerTitles = getResources().getStringArray(R.array.drawer_items);
+
+        // nav drawer content description from resources
+        mDrawerContentDescriptions = getResources().
+                getStringArray(R.array.drawer_content_descriptions);
+
+        // nav drawer items
+        mDrawerItems = new ArrayList<NavigationDrawerItem>();
+        // adding nav drawer items to array
+        // Accounts
+        mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0]));
+        // All Files
+        mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1]));
+
+        // TODO Enable when "On Device" is recovered
+        // On Device
+        //mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
+        //        mDrawerContentDescriptions[2]));
+
+        // Settings
+        mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2]));
+        // Logs
+        if (BuildConfig.DEBUG) {
+            mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[3],
+                    mDrawerContentDescriptions[3]));
+        }
+
+        // setting the nav drawer list adapter
+        mNavigationDrawerAdapter = new NavigationDrawerListAdapter(getApplicationContext(), this,
+                mDrawerItems);
+        mDrawerList.setAdapter(mNavigationDrawerAdapter);
+
+        mDrawerToggle = new ActionBarDrawerToggle(
+                this,
+                mDrawerLayout,
+                R.drawable.ic_drawer,
+                R.string.drawer_open,
+                R.string.empty) {
+
+            /** Called when a drawer has settled in a completely closed state. */
+            public void onDrawerClosed(View view) {
+                super.onDrawerClosed(view);
+                getSupportActionBar().setDisplayShowTitleEnabled(true);
+                getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+                initFragmentsWithFile();
+                invalidateOptionsMenu();
+            }
+
+            /** Called when a drawer has settled in a completely open state. */
+            public void onDrawerOpened(View drawerView) {
+                super.onDrawerOpened(drawerView);
+                getSupportActionBar().setTitle(R.string.drawer_open);
+                getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+                invalidateOptionsMenu();
+            }
+        };
+
+        mDrawerToggle.setDrawerIndicatorEnabled(true);
+        // Set the list's click listener
+        mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
+
+        // Set the drawer toggle as the DrawerListener
+        mDrawerLayout.setDrawerListener(mDrawerToggle);
+    }
+
     @Override
     protected void onStart() {
         Log_OC.v(TAG, "onStart() start");
@@ -214,6 +335,19 @@ public class FileDisplayActivity extends HookActivity implements
         getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId());
         Log_OC.v(TAG, "onStart() end");
     }
+    
+    @Override
+    protected void onPostCreate(Bundle savedInstanceState) {
+        super.onPostCreate(savedInstanceState);
+        // Sync the toggle state after onRestoreInstanceState has occurred.
+        mDrawerToggle.syncState();
+    }
+    
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        mDrawerToggle.onConfigurationChanged(newConfig);
+    }
 
     @Override
     protected void onDestroy() {
@@ -298,7 +432,9 @@ public class FileDisplayActivity extends HookActivity implements
             /// First fragment
             OCFileListFragment listOfFiles = getListOfFilesFragment(); 
             if (listOfFiles != null) {
-                listOfFiles.listDirectory(getCurrentDir());   
+                listOfFiles.listDirectory(getCurrentDir());
+                // TODO Enable when "On Device" is recovered
+                // listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
             } else {
                 Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
             }
@@ -422,8 +558,10 @@ public class FileDisplayActivity extends HookActivity implements
 
     protected void refreshListOfFilesFragment() {
         OCFileListFragment fileListFragment = getListOfFilesFragment();
-        if (fileListFragment != null) { 
+        if (fileListFragment != null) {
             fileListFragment.listDirectory();
+            // TODO Enable when "On Device" is recovered ?
+            // fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
         }
     }
 
@@ -471,11 +609,11 @@ public class FileDisplayActivity extends HookActivity implements
 
     @Override
     public boolean onPrepareOptionsMenu(Menu menu) {
-        if (BuildConfig.DEBUG) {
-            menu.findItem(R.id.action_logger).setVisible(true);
-        } else {
-            menu.findItem(R.id.action_logger).setVisible(false);
-        }
+        boolean drawerOpen = mDrawerLayout.isDrawerOpen(GravityCompat.START);
+        menu.findItem(R.id.action_upload).setVisible(!drawerOpen);
+        menu.findItem(R.id.action_create_dir).setVisible(!drawerOpen);
+        menu.findItem(R.id.action_sort).setVisible(!drawerOpen);
+        
         return super.onPrepareOptionsMenu(menu);
     }
 
@@ -485,6 +623,7 @@ public class FileDisplayActivity extends HookActivity implements
         inflater.inflate(R.menu.main_menu, menu);
         return true;
     }
+    
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
@@ -495,34 +634,19 @@ public class FileDisplayActivity extends HookActivity implements
             dialog.show(getSupportFragmentManager(), DIALOG_CREATE_FOLDER);
             break;
         }
-        case R.id.action_sync_account: {
-            startSynchronization();
-            break;
-        }
         case R.id.action_upload: {
             UploadSourceDialogFragment dialog = UploadSourceDialogFragment.newInstance(getAccount());
             dialog.show(getSupportFragmentManager(), DIALOG_UPLOAD_SOURCE);
 
             break;
         }
-        case R.id.action_settings: {
-            Intent settingsIntent = new Intent(this, Preferences.class);
-            startActivity(settingsIntent);
-            break;
-        }
-        case R.id.action_logger: {
-            Intent loggerIntent = new Intent(getApplicationContext(),LogHistoryActivity.class);
-            startActivity(loggerIntent);
-            break;
-        }
         case android.R.id.home: {
-            FileFragment second = getSecondFragment();
-            OCFile currentDir = getCurrentDir();
-            if((currentDir != null && currentDir.getParentId() != 0) || 
-                    (second != null && second.getFile() != null)) {                
-                onBackPressed(); 
-                
+            if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
+                mDrawerLayout.closeDrawer(GravityCompat.START);
+            } else {
+                mDrawerLayout.openDrawer(GravityCompat.START);
             }
+            // TODO add hamburger to left of android.R.id.home
             break;
         }
         case R.id.action_sort: {
@@ -537,19 +661,16 @@ public class FileDisplayActivity extends HookActivity implements
             builder.setTitle(R.string.actionbar_sort_title)
             .setSingleChoiceItems(R.array.actionbar_sortby, sortOrder , new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int which) {
-                    
                     switch (which){
-                    case 0:
-                        sortByName(true);
-                        break;
-                    case 1:
-                        sortByDate(false);
-                        break;
-                        
+                        case 0:
+                            sortByName(true);
+                            break;
+                        case 1:
+                            sortByDate(false);
+                            break;
                     }
-                    
+
                     dialog.dismiss();
-                    
                 }
             });
             builder.create().show();
@@ -687,7 +808,8 @@ public class FileDisplayActivity extends HookActivity implements
 
         } else {
             Log_OC.d(TAG, "User clicked on 'Update' with no selection");
-            Toast t = Toast.makeText(this, getString(R.string.filedisplay_no_file_selected), Toast.LENGTH_LONG);
+            Toast t = Toast.makeText(this, getString(R.string.filedisplay_no_file_selected),
+                    Toast.LENGTH_LONG);
             t.show();
             return;
         }
@@ -819,6 +941,9 @@ public class FileDisplayActivity extends HookActivity implements
         Log_OC.v(TAG, "onResume() start");
         super.onResume();
 
+        // refresh Navigation Drawer account list
+        mNavigationDrawerAdapter.updateAccountList();
+
         // refresh list of files
         refreshListOfFilesFragment();
 
@@ -960,7 +1085,8 @@ public class FileDisplayActivity extends HookActivity implements
                         if (currentDir == null) {
                             // current folder was removed from the server 
                             Toast.makeText( FileDisplayActivity.this, 
-                                            String.format(getString(R.string.sync_current_folder_was_removed),
+                                            String.format(
+                                                    getString(R.string.sync_current_folder_was_removed),
                                                     mDirectories.getItem(0)),
                                             Toast.LENGTH_LONG)
                                 .show();
@@ -968,7 +1094,8 @@ public class FileDisplayActivity extends HookActivity implements
                             
                         } else {
                             if (currentFile == null && !getFile().isFolder()) {
-                                // currently selected file was removed in the server, and now we know it
+                                // currently selected file was removed in the server, and now we
+                                // know it
                                 cleanSecondFragment();
                                 currentFile = currentDir;
                             }
@@ -977,14 +1104,18 @@ public class FileDisplayActivity extends HookActivity implements
                                     currentDir.getRemotePath().equals(synchFolderRemotePath)) {
                                 OCFileListFragment fileListFragment = getListOfFilesFragment();
                                 if (fileListFragment != null) {
-                                    fileListFragment.listDirectory(currentDir);
+                                    fileListFragment.listDirectory();
+                                    // TODO Enable when "On Device" is recovered ?
+                                    // fileListFragment.listDirectory(currentDir,
+                                    // MainApp.getOnlyOnDevice());
                                 }
                             }
                             setFile(currentFile);
                         }
                         
                         mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
-                                !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
+                                !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED
+                                        .equals(event));
                                 
                         if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
                                     equals(event) &&
@@ -1215,6 +1346,8 @@ public class FileDisplayActivity extends HookActivity implements
             }
             OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
             listOfFiles.listDirectory(root);
+            // TODO Enable when "On Device" is recovered ?
+            // listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
             setFile(listOfFiles.getCurrentFile());
             startSyncFolderOperation(root, false);
         }
@@ -1230,6 +1363,8 @@ public class FileDisplayActivity extends HookActivity implements
         if (listOfFiles != null) {
             setNavigationListWithFolder(folder);
             listOfFiles.listDirectory(folder);
+            // TODO Enable when "On Device" is recovered ?
+            // listOfFiles.listDirectory(folder, MainApp.getOnlyOnDevice());
             setFile(listOfFiles.getCurrentFile());
             startSyncFolderOperation(folder, false);
         } else {
@@ -1283,13 +1418,16 @@ public class FileDisplayActivity extends HookActivity implements
             // only list of files - set for browsing through folders
             OCFile currentDir = getCurrentDir();
             boolean noRoot = (currentDir != null && currentDir.getParentId() != 0);
-            actionBar.setDisplayHomeAsUpEnabled(noRoot);
-            actionBar.setDisplayShowTitleEnabled(!noRoot); 
+//            actionBar.setDisplayHomeAsUpEnabled(noRoot);
+//            actionBar.setDisplayShowTitleEnabled(!noRoot); 
+            actionBar.setDisplayHomeAsUpEnabled(true);
+            actionBar.setDisplayShowTitleEnabled(true);
             if (!noRoot) {
                 actionBar.setTitle(getString(R.string.default_display_name_for_root_folder));
                 View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId);
                 if (actionBarTitleView != null) {    // it's null in Android 2.x
-                    actionBarTitleView.setContentDescription(getString(R.string.default_display_name_for_root_folder));
+                    actionBarTitleView.setContentDescription(
+                            getString(R.string.default_display_name_for_root_folder));
                 }
             }
             actionBar.setNavigationMode(!noRoot ? ActionBar.NAVIGATION_MODE_STANDARD :
@@ -1321,7 +1459,8 @@ public class FileDisplayActivity extends HookActivity implements
 
         @Override
         public void onServiceConnected(ComponentName component, IBinder service) {
-            if (component.equals(new ComponentName(FileDisplayActivity.this, FileDownloader.class))) {
+            if (component.equals(new ComponentName(
+                    FileDisplayActivity.this, FileDownloader.class))) {
                 Log_OC.d(TAG, "Download service connected");
                 mDownloaderBinder = (FileDownloaderBinder) service;
                 if (mWaitingToPreview != null)
@@ -1346,6 +1485,8 @@ public class FileDisplayActivity extends HookActivity implements
             OCFileListFragment listOfFiles = getListOfFilesFragment(); 
             if (listOfFiles != null) {
                 listOfFiles.listDirectory();
+                // TODO Enable when "On Device" is recovered ?
+                // listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
             }
             FileFragment secondFragment = getSecondFragment();
             if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
@@ -1705,7 +1846,7 @@ public class FileDisplayActivity extends HookActivity implements
     public void showUntrustedCertDialog(RemoteOperationResult result) {
         // Show a dialog with the certificate info
         SslUntrustedCertDialog dialog = SslUntrustedCertDialog.newInstanceForFullSslError(
-                (CertificateCombinedException)result.getException());
+                (CertificateCombinedException) result.getException());
         FragmentManager fm = getSupportFragmentManager();
         FragmentTransaction ft = fm.beginTransaction();
         dialog.show(ft, DIALOG_UNTRUSTED_CERT);
@@ -1836,5 +1977,54 @@ public class FileDisplayActivity extends HookActivity implements
     private void sortByName(boolean ascending){
         getListOfFilesFragment().sortByName(ascending);
     }
+    
+    public void restart(){
+        Intent i = new Intent(this, FileDisplayActivity.class);
+        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        startActivity(i);
+    }
+
+    public void closeDrawer() {
+        mDrawerLayout.closeDrawers();
+    }
 
+    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;
+            }
+            switch (position){
+                case 0: // Accounts
+                    mShowAccounts = !mShowAccounts;
+                    mNavigationDrawerAdapter.setShowAccounts(mShowAccounts);
+                    mNavigationDrawerAdapter.notifyDataSetChanged();
+                    break;
+
+                case 1: // All Files
+                    // TODO Enable when "On Device" is recovered ?
+                    //MainApp.showOnlyFilesOnDevice(false);
+                    mDrawerLayout.closeDrawers();
+                    break;
+
+                // TODO Enable when "On Device" is recovered ?
+//                case 2:
+//                    MainApp.showOnlyFilesOnDevice(true);
+//                    mDrawerLayout.closeDrawers();
+//                    break;
+
+                case 2: // Settings
+                    Intent settingsIntent = new Intent(getApplicationContext(),
+                            Preferences.class);
+                    startActivity(settingsIntent);
+                    break;
+
+                case 3: // Logs
+                    Intent loggerIntent = new Intent(getApplicationContext(),
+                            LogHistoryActivity.class);
+                    startActivity(loggerIntent);
+                    break;
+            }
+        }
+    }
 }
index 5fd2bdf..a358f79 100644 (file)
 
 package com.owncloud.android.ui.activity;
 
-import java.io.IOException;
-
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -141,7 +138,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
             
             if (!stateWasRecovered) {
                 OCFileListFragment listOfFolders = getListOfFilesFragment(); 
-                listOfFolders.listDirectory(folder);   
+                listOfFolders.listDirectory(folder/*, false*/);
                 
                 startSyncFolderOperation(folder, false);
             }
@@ -264,9 +261,6 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
         MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.menu.main_menu, menu);
         menu.findItem(R.id.action_upload).setVisible(false);
-        menu.findItem(R.id.action_settings).setVisible(false);
-        menu.findItem(R.id.action_sync_account).setVisible(false);
-        menu.findItem(R.id.action_logger).setVisible(false);
         menu.findItem(R.id.action_sort).setVisible(false);
         return true;
     }
@@ -312,8 +306,10 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
     
     protected void refreshListOfFilesFragment() {
         OCFileListFragment fileListFragment = getListOfFilesFragment();
-        if (fileListFragment != null) { 
+        if (fileListFragment != null) {
             fileListFragment.listDirectory();
+            // TODO Enable when "On Device" is recovered ?
+            // fileListFragment.listDirectory(false);
         }
     }
 
@@ -322,6 +318,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
         if (listOfFiles != null) {  // should never be null, indeed
             OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
             listOfFiles.listDirectory(root);
+            // TODO Enable when "On Device" is recovered ?
+            // listOfFiles.listDirectory(root, false);
             setFile(listOfFiles.getCurrentFile());
             updateNavigationElementsInActionBar();
             startSyncFolderOperation(root, false);
@@ -474,6 +472,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
                                 OCFileListFragment fileListFragment = getListOfFilesFragment();
                                 if (fileListFragment != null) {
                                     fileListFragment.listDirectory(currentDir);
+                                    // TODO Enable when "On Device" is recovered ?
+                                    // fileListFragment.listDirectory(currentDir, false);
                                 }
                             }
                             setFile(currentFile);
index 23ab550..ef8c222 100644 (file)
@@ -54,6 +54,7 @@ import android.widget.AdapterView.OnItemLongClickListener;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 
+import com.owncloud.android.BuildConfig;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.AccountUtils;
@@ -203,8 +204,21 @@ public class Preferences extends PreferenceActivity
             }
             
         }
+
+        if (BuildConfig.DEBUG) {
+            Preference pLog =  findPreference("log");
+            if (pLog != null ){
+                pLog.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+                    @Override
+                    public boolean onPreferenceClick(Preference preference) {
+                        Intent loggerIntent = new Intent(getApplicationContext(),LogHistoryActivity.class);
+                        startActivity(loggerIntent);
+                        return true;
+                    }
+                });
+            }
+        }
         
-       
        boolean recommendEnabled = getResources().getBoolean(R.bool.recommend_enabled);
        Preference pRecommend =  findPreference("recommend");
         if (pRecommend != null){
@@ -223,7 +237,8 @@ public class Preferences extends PreferenceActivity
                         Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(Preferences.this);
                         String username = currentAccount.name.substring(0, currentAccount.name.lastIndexOf('@'));
                         
-                        String recommendSubject = String.format(getString(R.string.recommend_subject), appName);
+                        String recommendSubject = String.format(getString(R.string.recommend_subject),
+                                appName);
                         String recommendText = String.format(getString(R.string.recommend_text),
                                 appName, downloadUrl, username);
                         
index d1509f9..db704d1 100644 (file)
@@ -20,7 +20,6 @@
 package com.owncloud.android.ui.activity;
 
 import android.accounts.Account;
-
 import android.os.Bundle;
 import android.view.View.OnClickListener;
 
@@ -68,7 +67,8 @@ public class UploadPathActivity extends FolderPickerActivity implements FileFrag
 
             if (!stateWasRecovered) {
                 OCFileListFragment listOfFolders = getListOfFilesFragment();
-                listOfFolders.listDirectory(folder);
+                // TODO Enable when "On Device" is recovered ?
+                listOfFolders.listDirectory(folder/*, false*/);
 
                 startSyncFolderOperation(folder, false);
             }
index f4bd273..533bb99 100644 (file)
@@ -72,9 +72,9 @@ import com.owncloud.android.R;
 import com.owncloud.android.authentication.AccountAuthenticator;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileUploader;
+import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
-import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.operations.CreateFolderOperation;
 import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
 import com.owncloud.android.ui.dialog.LoadingDialog;
@@ -326,7 +326,8 @@ public class Uploader extends FileActivity
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
         // click on folder in the list
         Log_OC.d(TAG, "on item click");
-        Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile);
+        // TODO Enable when "On Device" is recovered ?
+        Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile /*, false*/);
         if (tmpfiles.size() <= 0) return;
         // filter on dirtype
         Vector<OCFile> files = new Vector<OCFile>();
@@ -411,7 +412,8 @@ public class Uploader extends FileActivity
 
         mFile = getStorageManager().getFileByPath(full_path);
         if (mFile != null) {
-            Vector<OCFile> files = getStorageManager().getFolderContent(mFile);
+            // TODO Enable when "On Device" is recovered ?
+            Vector<OCFile> files = getStorageManager().getFolderContent(mFile/*, false*/);
             List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();
             for (OCFile f : files) {
                 HashMap<String, Object> h = new HashMap<String, Object>();
index 2c1aa9e..c6ea034 100644 (file)
@@ -407,14 +407,16 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
      * @param updatedStorageManager     Optional updated storage manager; used to replace \r
      *                                  mStorageManager if is different (and not NULL)\r
      */\r
-    public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager) {\r
+    public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager\r
+            /*, boolean onlyOnDevice*/) {\r
         mFile = directory;\r
         if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {\r
             mStorageManager = updatedStorageManager;\r
             mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
         }\r
         if (mStorageManager != null) {\r
-            mFiles = mStorageManager.getFolderContent(mFile);\r
+            // TODO Enable when "On Device" is recovered ?\r
+            mFiles = mStorageManager.getFolderContent(mFile/*, onlyOnDevice*/);\r
             mFilesOrig.clear();\r
             mFilesOrig.addAll(mFiles);\r
             \r
diff --git a/src/com/owncloud/android/ui/adapter/Group.java b/src/com/owncloud/android/ui/adapter/Group.java
new file mode 100644 (file)
index 0000000..b01d29c
--- /dev/null
@@ -0,0 +1,15 @@
+package com.owncloud.android.ui.adapter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Group {
+
+  public String string;
+  public final List<String> children = new ArrayList<String>();
+
+  public Group(String string) {
+    this.string = string;
+  }
+
+}
\ No newline at end of file
diff --git a/src/com/owncloud/android/ui/adapter/MyExpandableListAdapter.java b/src/com/owncloud/android/ui/adapter/MyExpandableListAdapter.java
new file mode 100644 (file)
index 0000000..20cfdff
--- /dev/null
@@ -0,0 +1,120 @@
+package com.owncloud.android.ui.adapter;
+
+import android.app.Activity;
+import android.util.SparseArray;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.BaseExpandableListAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.owncloud.android.R;
+
+public class MyExpandableListAdapter extends BaseExpandableListAdapter {
+
+  private final SparseArray<Group> groups;
+  public LayoutInflater inflater;
+  public Activity activity;
+
+  public MyExpandableListAdapter(Activity act, SparseArray<Group> groups) {
+    activity = act;
+    this.groups = groups;
+    inflater = act.getLayoutInflater();
+    
+  }
+  
+  
+  @Override
+  public Object getChild(int groupPosition, int childPosition) {
+    return groups.get(groupPosition).children.get(childPosition);
+  }
+
+  @Override
+  public long getChildId(int groupPosition, int childPosition) {
+    return 0;
+  }
+
+  @Override
+  public View getChildView(int groupPosition, final int childPosition,
+      boolean isLastChild, View convertView, ViewGroup parent) {
+    final String children = (String) getChild(groupPosition, childPosition);
+    TextView text = null;
+    if (convertView == null) {
+      convertView = inflater.inflate(R.layout.listrow_details, null);
+    }
+    
+    
+    text = (TextView) convertView.findViewById(R.id.textView1);
+    text.setText(children);
+    convertView.setOnClickListener(new OnClickListener() {
+      @Override
+      public void onClick(View v) {
+        Toast.makeText(activity, children, Toast.LENGTH_SHORT).show();
+      }
+    });
+    return convertView;
+  }
+  
+  @Override
+  public View getGroupView(int groupPosition, boolean isExpanded,
+      View convertView, ViewGroup parent) {
+    if (convertView == null) {
+      convertView = inflater.inflate(R.layout.listrow_group, null);
+    }
+    
+    final Group group = (Group) getGroup(groupPosition);
+    if (group.children.size() == 0){
+        convertView.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Toast.makeText(activity, group.string, Toast.LENGTH_SHORT).show();
+            }
+        });
+    }
+    ((TextView) convertView).setText(group.string);
+    
+    return convertView;
+  }
+
+  @Override
+  public int getChildrenCount(int groupPosition) {
+    return groups.get(groupPosition).children.size();
+  }
+
+  @Override
+  public Object getGroup(int groupPosition) {
+    return groups.get(groupPosition);
+  }
+
+  @Override
+  public int getGroupCount() {
+    return groups.size();
+  }
+
+  @Override
+  public void onGroupCollapsed(int groupPosition) {
+    super.onGroupCollapsed(groupPosition);
+  }
+
+  @Override
+  public void onGroupExpanded(int groupPosition) {
+    super.onGroupExpanded(groupPosition);
+  }
+
+  @Override
+  public long getGroupId(int groupPosition) {
+    return 0;
+  }
+
+  @Override
+  public boolean hasStableIds() {
+    return false;
+  }
+
+  @Override
+  public boolean isChildSelectable(int groupPosition, int childPosition) {
+    return false;
+  }
+} 
\ No newline at end of file
diff --git a/src/com/owncloud/android/ui/adapter/NavigationDrawerListAdapter.java b/src/com/owncloud/android/ui/adapter/NavigationDrawerListAdapter.java
new file mode 100644 (file)
index 0000000..b53f66f
--- /dev/null
@@ -0,0 +1,200 @@
+/**
+ *   ownCloud Android client application
+ *
+ *   @author tobiasKaminsky
+ *   @author masensio
+ *   Copyright (C) 2015 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.ui.adapter;
+
+import java.nio.ByteBuffer;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.Context;
+import android.graphics.Color;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.LinearLayout;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.RadioGroup.LayoutParams;
+import android.widget.TextView;
+
+import com.owncloud.android.MainApp;
+import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
+import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.ui.NavigationDrawerItem;
+import com.owncloud.android.ui.activity.FileDisplayActivity;
+import com.owncloud.android.utils.BitmapUtils;
+
+public class NavigationDrawerListAdapter extends BaseAdapter {
+
+    private final static String TAG  = NavigationDrawerListAdapter.class.getSimpleName();
+
+    private Context mContext;
+
+    private ArrayList<NavigationDrawerItem> mNavigationDrawerItems;
+    private ArrayList<Object> mAll = new ArrayList<Object>();
+    private Account[] mAccounts;
+    private boolean mShowAccounts;
+    private Account mCurrentAccount;
+    private FileDisplayActivity mFileDisplayActivity;
+
+
+    public NavigationDrawerListAdapter(Context context, FileDisplayActivity fileDisplayActivity,
+                                       ArrayList<NavigationDrawerItem> navigationDrawerItems){
+        mFileDisplayActivity = fileDisplayActivity;
+        mContext = context;
+        mNavigationDrawerItems = navigationDrawerItems;
+
+        updateAccountList();
+
+        mAll.addAll(mNavigationDrawerItems);
+    }
+
+    public void updateAccountList(){
+        AccountManager am = (AccountManager) mContext.getSystemService(mContext.ACCOUNT_SERVICE);
+        mAccounts = am.getAccountsByType(MainApp.getAccountType());
+        mCurrentAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
+    }
+
+    @Override
+    public int getCount() {
+        if (mShowAccounts){
+            return mNavigationDrawerItems.size() + 1;
+        } else {
+            return mNavigationDrawerItems.size();
+        }
+    }
+
+    @Override
+    public Object getItem(int position) {
+        //return all.get(position);
+        return null;
+    }
+
+    @Override
+    public long getItemId(int position) {
+        return 0;
+    }
+
+    @Override
+    public View getView(int position, View convertView, ViewGroup parent) {
+
+        LayoutInflater inflator = (LayoutInflater) mContext
+                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+        if (mAll.size() > position) {
+            // Normal entry
+            if (mAll.get(position) instanceof NavigationDrawerItem){
+                NavigationDrawerItem navItem = (NavigationDrawerItem) mAll.get(position);
+
+                View view = inflator.inflate(R.layout.drawer_list_item, null);
+                view.setMinimumHeight(40);
+                LinearLayout itemLayout = (LinearLayout) view.findViewById(R.id.itemLayout);
+                itemLayout.setContentDescription(navItem.getContentDescription());
+                TextView itemText = (TextView) view.findViewById(R.id.itemTitle);
+                itemText.setText(navItem.getTitle());
+
+                return view;
+            }
+
+            // 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);
+
+                    try {
+                        byte[] bytesOfMessage = account.name.substring(0,5).getBytes("UTF-8");
+                        MessageDigest md = MessageDigest.getInstance("MD5");
+                        byte[] digest = md.digest(bytesOfMessage);
+                        int result = Math.abs(ByteBuffer.wrap(digest).getInt());
+
+                        Log_OC.d(TAG, "Integer: " + result % 100000);
+                        Log_OC.d(TAG, "length: " + digest.length);
+
+
+                        Double hue = (result % 100000) / 99999.0;
+
+                        Log_OC.d(TAG, "hue: " + hue);
+
+                        int[] rgb = BitmapUtils.hslToRgb(hue, 0.9, 0.65);
+                        rb.setTextColor(Color.rgb(rgb[0], rgb[1], rgb[2]));
+                        Log_OC.d(TAG, "Color: " + rgb[0] + " " + rgb[1] + rgb[2]);
+
+                    } 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();
+                        mFileDisplayActivity.closeDrawer();
+                        
+                        // restart the main activity
+                        mFileDisplayActivity.restart();
+                    }
+                });
+
+                return view;
+            }
+        }
+        return convertView;
+    }
+
+    // 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;
+    }
+}
index 782ed04..3045b27 100644 (file)
@@ -112,7 +112,8 @@ implements ConfirmationDialogFragmentListener {
         
         boolean containsKeepInSync = false;
         if (mTargetFile.isFolder()) {
-            Vector<OCFile> files = storageManager.getFolderContent(mTargetFile);
+            // TODO Enable when "On Device" is recovered ?
+            Vector<OCFile> files = storageManager.getFolderContent(mTargetFile/*, false*/);
             for(OCFile file: files) {
                 containsKeepInSync = file.keepInSync() || containsKeepInSync;
 
index ed97de0..dd8ed02 100644 (file)
@@ -77,7 +77,8 @@ public class OCFileListFragment extends ExtendedListFragment {
     private boolean mJustFolders;
     
     private OCFile mTargetFile;
-
+    
+   
     
     /**
      * {@inheritDoc}
@@ -182,8 +183,9 @@ public class OCFileListFragment extends ExtendedListFragment {
                 moveCount++;
             }   // exit is granted because storageManager.getFileByPath("/") never returns null
             mFile = parentDir;
-            
-            listDirectory(mFile);
+
+            // TODO Enable when "On Device" is recovered ?
+            listDirectory(mFile /*, MainApp.getOnlyOnDevice()*/);
 
             onRefresh(false);
             
@@ -201,7 +203,8 @@ public class OCFileListFragment extends ExtendedListFragment {
         if (file != null) {
             if (file.isFolder()) { 
                 // update state and view of this fragment
-                listDirectory(file);
+                // TODO Enable when "On Device" is recovered ?
+                listDirectory(file/*, MainApp.getOnlyOnDevice()*/);
                 // then, notify parent activity to let it update its state and view
                 mContainerActivity.onBrowsedDownTo(file);
                 // save index and top position
@@ -355,8 +358,15 @@ public class OCFileListFragment extends ExtendedListFragment {
     /**
      * Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null parameter
      */
-    public void listDirectory(){
+    public void listDirectory(/*boolean onlyOnDevice*/){
         listDirectory(null);
+        // TODO Enable when "On Device" is recovered ?
+        // listDirectory(null, onlyOnDevice);
+    }
+    
+    public void refreshDirectory(){
+        // TODO Enable when "On Device" is recovered ?
+        listDirectory(getCurrentFile()/*, MainApp.getOnlyOnDevice()*/);
     }
     
     /**
@@ -366,7 +376,7 @@ public class OCFileListFragment extends ExtendedListFragment {
      * 
      * @param directory File to be listed
      */
-    public void listDirectory(OCFile directory) {
+    public void listDirectory(OCFile directory/*, boolean onlyOnDevice*/) {
         FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
         if (storageManager != null) {
 
@@ -387,7 +397,8 @@ public class OCFileListFragment extends ExtendedListFragment {
                 directory = storageManager.getFileById(directory.getParentId());
             }
 
-            mAdapter.swapDirectory(directory, storageManager);
+            // TODO Enable when "On Device" is recovered ?
+            mAdapter.swapDirectory(directory, storageManager/*, onlyOnDevice*/);
             if (mFile == null || !mFile.equals(directory)) {
                 mCurrentListView.setSelection(0);
             }
@@ -459,5 +470,7 @@ public class OCFileListFragment extends ExtendedListFragment {
     public void sortBySize(boolean descending) {
         mAdapter.setSortOrder(FileStorageUtils.SORT_SIZE, descending);
     }  
-
+    
+   
+    
 }
index 6dc87cb..a67788a 100644 (file)
@@ -140,8 +140,11 @@ public class PreviewImageActivity extends FileActivity implements
             // should not be necessary
             parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
         }
+
+        // TODO Enable when "On Device" is recovered ?
         mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(),
-                parentFolder, getAccount(), getStorageManager());
+                parentFolder, getAccount(), getStorageManager()/*, MainApp.getOnlyOnDevice()*/);
+
         mViewPager = (ExtendedViewPager) findViewById(R.id.fragmentPager);
         int position = mHasSavedPosition ? mSavedPosition :
                 mPreviewImagePagerAdapter.getFilePosition(getFile());
index 6e7f19d..dda7dda 100644 (file)
@@ -19,8 +19,6 @@
  */
 package com.owncloud.android.ui.preview;
 
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -36,7 +34,6 @@ import android.view.ViewGroup;
 
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.ui.adapter.FileListListAdapter;
 import com.owncloud.android.ui.fragment.FileFragment;
 import com.owncloud.android.utils.FileStorageUtils;
 
@@ -58,11 +55,14 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
     /**
      * Constructor.
      * 
-     * @param fragmentManager   {@link FragmentManager} instance that will handle the {@link Fragment}s provided by the adapter. 
+     * @param fragmentManager   {@link FragmentManager} instance that will handle
+     *                          the {@link Fragment}s provided by the adapter.
      * @param parentFolder      Folder where images will be searched for.
      * @param storageManager    Bridge to database.
      */
-    public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFolder, Account account, FileDataStorageManager storageManager) {
+    public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFolder,
+                                    Account account, FileDataStorageManager storageManager /*,
+                                    boolean onlyOnDevice*/) {
         super(fragmentManager);
         
         if (fragmentManager == null) {
@@ -77,7 +77,8 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
 
         mAccount = account;
         mStorageManager = storageManager;
-        mImageFiles = mStorageManager.getFolderImages(parentFolder); 
+        // TODO Enable when "On Device" is recovered ?
+        mImageFiles = mStorageManager.getFolderImages(parentFolder/*, false*/);
         
         mImageFiles = FileStorageUtils.sortFolder(mImageFiles);
         
@@ -102,7 +103,8 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
         OCFile file = mImageFiles.get(i);
         Fragment fragment = null;
         if (file.isDown()) {
-            fragment = PreviewImageFragment.newInstance(file, mObsoletePositions.contains(Integer.valueOf(i)));
+            fragment = PreviewImageFragment.newInstance(file,
+                    mObsoletePositions.contains(Integer.valueOf(i)));
             
         } else if (mDownloadErrors.contains(Integer.valueOf(i))) {
             fragment = FileDownloadFragment.newInstance(file, mAccount, true);
index 7b9382e..7af6960 100644 (file)
@@ -178,6 +178,46 @@ public class BitmapUtils {
     }
 
     /**
+     * Converts an HSL color value to RGB. Conversion formula
+     * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
+     * Assumes h, s, and l are contained in the set [0, 1] and
+     * returns r, g, and b in the set [0, 255].
+     * from: http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
+     *
+     * @param   integer  h       The hue
+     * @param   Integer  s       The saturation
+     * @param   Integer  l       The lightness
+     * @return  Array           The RGB representation
+     */
+    public static int[] hslToRgb(Double h, Double s, Double l){
+        Double r, g, b;
+
+        if(s == 0){
+            r = g = b = l; // achromatic
+        } else {
+            Double q = l < 0.5 ? l * (1 + s) : l + s - l * s;
+            Double p = 2 * l - q;
+            r = hue2rgb(p, q, h + 1/3) * 255;
+            g = hue2rgb(p, q, h) * 255;
+            b = hue2rgb(p, q, h - 1/3) * 255;
+        }
+
+
+        int[] array = {r.intValue(), g.intValue(), b.intValue()};
+        return array;
+    }
+
+    private static Double hue2rgb(Double p, Double q, Double t){
+        if(t < 0) t += 1;
+        if(t > 1) t -= 1;
+        if(t < 1/6) return p + (q - p) * 6 * t;
+        if(t < 1/2) return q;
+        if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
+        return p;
+    }
+    
+
+    /**
      * Checks if file passed is an image
      * @param file
      * @return true/false