Răsfoiți Sursa

initial code to read (yet empty DB) and display settings screen (non-functional yet)

Andy Scherzinger 8 ani în urmă
părinte
comite
17b9eaed96

BIN
res/drawable-hdpi/ic_cellphone.png


BIN
res/drawable-hdpi/ic_cloud_outline.png


BIN
res/drawable-mdpi/ic_cellphone.png


BIN
res/drawable-mdpi/ic_cloud_outline.png


BIN
res/drawable-xhdpi/ic_cellphone.png


BIN
res/drawable-xhdpi/ic_cloud_outline.png


BIN
res/drawable-xxhdpi/ic_cellphone.png


BIN
res/drawable-xxhdpi/ic_cloud_outline.png


BIN
res/drawable-xxxhdpi/ic_cellphone.png


BIN
res/drawable-xxxhdpi/ic_cloud_outline.png


+ 371 - 0
res/layout/folder_sync_settings_layout.xml

@@ -0,0 +1,371 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Nextcloud Android client application
+
+  Copyright (C) 2016 Andy Scherzinger
+  Copyright (C) 2016 Nextcloud.
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+  License as published by the Free Software Foundation; either
+  version 3 of the License, or any later version.
+
+  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 AFFERO GENERAL PUBLIC LICENSE for more details.
+
+  You should have received a copy of the GNU Affero General Public
+  License along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+<LinearLayout android:id="@+id/root"
+              xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:gravity="center"
+              android:orientation="vertical"
+              android:padding="@dimen/standard_padding">
+
+    <TextView
+        android:id="@+id/folder_sync_settings_title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/folder_sync_preferences"
+        android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
+
+    <ScrollView
+        android:id="@+id/details_scroll"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical"
+                android:minHeight="?android:attr/listPreferredItemHeightSmall">
+
+                <LinearLayout
+                    android:id="@+id/local_folder_icon_frame"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:gravity="start|center_vertical"
+                    android:minWidth="58dip"
+                    android:orientation="horizontal">
+
+                    <ImageView
+                        android:id="@+id/local_folder_icon"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginRight="@dimen/standard_half_margin"
+                        android:src="@drawable/ic_cellphone"/>
+                </LinearLayout>
+
+                <RelativeLayout
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:paddingBottom="16dip"
+                    android:paddingTop="16dip">
+
+                    <TextView
+                        android:id="@+id/local_folder_title"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/prefs_instant_upload_path_title"
+                        android:maxLines="1"
+                        android:textColor="?android:attr/textColorSecondary"
+                        android:textAppearance="?android:attr/textAppearanceListItem"/>
+
+                    <TextView
+                        android:id="@+id/local_folder_summary"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignLeft="@id/local_folder_title"
+                        android:layout_below="@id/local_folder_title"
+                        android:maxLines="2"
+                        android:text="@string/placeholder_filename"
+                        android:textColor="?android:attr/textColorSecondary"/>
+
+                </RelativeLayout>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical"
+                android:minHeight="?android:attr/listPreferredItemHeightSmall">
+
+                <LinearLayout
+                    android:id="@+id/remote_folder_icon_frame"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:gravity="start|center_vertical"
+                    android:minWidth="58dip"
+                    android:orientation="horizontal">
+
+                    <ImageView
+                        android:id="@+id/remote_folder_icon"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginRight="@dimen/standard_half_margin"
+                        android:src="@drawable/ic_cloud_outline"/>
+                </LinearLayout>
+
+                <RelativeLayout
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:paddingBottom="16dip"
+                    android:paddingTop="16dip">
+
+                    <TextView
+                        android:id="@+id/remote_folder_title"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/prefs_instant_upload_path_title"
+                        android:maxLines="1"
+                        android:textColor="?android:attr/textColorSecondary"
+                        android:textAppearance="?android:attr/textAppearanceListItem"/>
+
+                    <TextView
+                        android:id="@+id/remote_folder_summary"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignLeft="@id/remote_folder_title"
+                        android:layout_below="@id/remote_folder_title"
+                        android:maxLines="2"
+                        android:text="@string/placeholder_filename"
+                        android:textColor="?android:attr/textColorSecondary"/>
+
+                </RelativeLayout>
+
+            </LinearLayout>
+
+            <TextView
+                android:id="@+id/settings_title"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="16dip"
+                android:paddingTop="@dimen/standard_padding"
+                android:text="@string/folder_sync_settings"
+                android:textAppearance="@style/TextAppearance.AppCompat.Body2"
+                android:textColor="@color/color_accent"/>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:clipToPadding="false"
+                android:gravity="center_vertical"
+                android:minHeight="?attr/listPreferredItemHeightSmall">
+
+                <RelativeLayout
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:paddingBottom="@dimen/standard_padding"
+                    android:paddingTop="@dimen/standard_padding">
+
+                    <TextView
+                        android:id="@+id/setting_instant_upload_on_wifi"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:ellipsize="marquee"
+                        android:maxLines="1"
+                        android:text="@string/instant_upload_on_wifi"
+                        android:textAppearance="?attr/textAppearanceListItem"/>
+
+                </RelativeLayout>
+
+                <LinearLayout
+                    android:id="@+id/setting_instant_upload_on_wifi_frame"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:gravity="end|center_vertical"
+                    android:orientation="vertical"
+                    android:paddingLeft="@dimen/standard_padding">
+
+                    <CheckBox
+                        android:id="@+id/setting_instant_upload_on_wifi_checkbox"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:background="@null"
+                        android:clickable="false"
+                        android:focusable="false"/>
+
+                </LinearLayout>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:clipToPadding="false"
+                android:gravity="center_vertical"
+                android:minHeight="?attr/listPreferredItemHeightSmall">
+
+                <RelativeLayout
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:paddingBottom="@dimen/standard_padding"
+                    android:paddingTop="@dimen/standard_padding">
+
+                    <TextView
+                        android:id="@+id/setting_instant_upload_on_charging"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:ellipsize="marquee"
+                        android:maxLines="1"
+                        android:text="@string/instant_upload_on_charging"
+                        android:textAppearance="?attr/textAppearanceListItem"/>
+
+                </RelativeLayout>
+
+                <LinearLayout
+                    android:id="@+id/setting_instant_upload_on_charging_frame"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:gravity="end|center_vertical"
+                    android:orientation="vertical"
+                    android:paddingLeft="@dimen/standard_padding">
+
+                    <CheckBox
+                        android:id="@+id/setting_instant_upload_on_charging_checkbox"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:background="@null"
+                        android:clickable="false"
+                        android:focusable="false"/>
+
+                </LinearLayout>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:clipToPadding="false"
+                android:gravity="center_vertical"
+                android:minHeight="?attr/listPreferredItemHeightSmall">
+
+                <RelativeLayout
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:paddingBottom="@dimen/standard_padding"
+                    android:paddingTop="@dimen/standard_padding">
+
+                    <TextView
+                        android:id="@+id/setting_instant_upload_path_use_subfolders_title"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:ellipsize="marquee"
+                        android:maxLines="1"
+                        android:text="@string/prefs_instant_upload_path_use_subfolders_title"
+                        android:textAppearance="?attr/textAppearanceListItem"/>
+
+                    <TextView
+                        android:id="@+id/setting_instant_upload_path_use_subfolders_summary"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignLeft="@id/setting_instant_upload_path_use_subfolders_title"
+                        android:layout_below="@id/setting_instant_upload_path_use_subfolders_title"
+                        android:ellipsize="end"
+                        android:maxLines="2"
+                        android:text="@string/prefs_instant_upload_path_use_subfolders_summary"
+                        android:textColor="?android:attr/textColorSecondary"/>
+
+                </RelativeLayout>
+
+                <!-- Preference should place its actual preference widget here. -->
+                <LinearLayout
+                    android:id="@+id/setting_instant_upload_path_use_subfolders_frame"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:gravity="end|center_vertical"
+                    android:orientation="vertical"
+                    android:paddingLeft="@dimen/standard_padding">
+
+                    <CheckBox
+                        android:id="@+id/setting_instant_upload_path_use_subfolders_checkbox"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:background="@null"
+                        android:clickable="false"
+                        android:focusable="false"/>
+
+                </LinearLayout>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:clipToPadding="false"
+                android:gravity="center_vertical"
+                android:minHeight="?attr/listPreferredItemHeightSmall">
+
+                <RelativeLayout
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:paddingBottom="@dimen/standard_padding"
+                    android:paddingTop="@dimen/standard_padding">
+
+                    <TextView
+                        android:id="@+id/setting_instant_behaviour_title"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:ellipsize="marquee"
+                        android:maxLines="1"
+                        android:text="@string/prefs_instant_behaviour_title"
+                        android:textAppearance="?attr/textAppearanceListItem"/>
+
+                    <TextView
+                        android:id="@+id/setting_instant_behaviour_summary"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignLeft="@id/setting_instant_behaviour_title"
+                        android:layout_below="@id/setting_instant_behaviour_title"
+                        android:ellipsize="end"
+                        android:maxLines="1"
+                        android:text="@string/placeholder_filename"
+                        android:textColor="?android:attr/textColorSecondary"/>
+
+                </RelativeLayout>
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+    </ScrollView>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="right" >
+
+        <android.support.v7.widget.AppCompatButton
+            android:id="@+id/cancel"
+            style="@style/Button.Borderless"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/common_cancel" />
+
+        <android.support.v7.widget.AppCompatButton
+            android:id="@+id/save"
+            style="@style/Button.Borderless"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/common_save" />
+
+    </LinearLayout>
+
+</LinearLayout>

+ 3 - 0
res/values/strings.xml

@@ -105,6 +105,7 @@
     <string name="common_cancel_sync">Cancel sync</string>
     <string name="common_cancel">Cancel</string>
     <string name="common_back">Back</string>
+    <string name="common_save">Save</string>
     <string name="common_save_exit">Save &amp; exit</string>
     <string name="common_error">Error</string>
     <string name="common_loading">Loading &#8230;</string>
@@ -496,6 +497,8 @@
     <string name="copy_to">Copy to&#8230;</string>
     <string name="folder_sync_loading_folders">Loading folders&#8230;</string>
     <string name="folder_sync_no_results">No results</string>
+    <string name="folder_sync_preferences">Folder Sync Preferences</string>
+    <string name="folder_sync_settings">Settings</string>
     <plurals name="items_selected_count">
         <!--
              As a developer, you should always supply "one" and "other"

+ 92 - 0
res/xml/folder_sync_preferences.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ownCloud Android client application
+
+  Copyright (C) 2012  Bartek Przybylski
+  Copyright (C) 2012-2013 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/>.
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <PreferenceCategory android:title="@string/prefs_category_instant_uploading" android:key="instant_uploading_category">
+		<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_uploading"
+	                        android:title="@string/prefs_instant_upload"
+	                        android:summary="@string/prefs_instant_upload_summary"/>
+        <com.owncloud.android.ui.PreferenceWithLongSummary
+							android:title="@string/prefs_instant_upload_path_title"
+							android:key="instant_upload_path" />
+		<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+							android:title="@string/prefs_instant_upload_path_use_subfolders_title"
+                            android:summary="@string/prefs_instant_upload_path_use_subfolders_summary"
+							android:key="instant_upload_path_use_subfolders" />
+	    <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+			android:dependency="instant_uploading"
+			android:disableDependentsState="true"
+	        android:title="@string/instant_upload_on_wifi"
+	        android:key="instant_upload_on_wifi"/>
+		<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+			android:title="@string/instant_upload_on_charging"
+			android:key="instant_upload_on_charging"/>
+		<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+			android:key="instant_video_uploading"
+	        android:title="@string/prefs_instant_video_upload"
+	        android:summary="@string/prefs_instant_video_upload_summary" />
+	    <com.owncloud.android.ui.PreferenceWithLongSummary
+							android:title="@string/prefs_instant_video_upload_path_title"
+							android:key="instant_video_upload_path" />
+		<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+			android:title="@string/prefs_instant_upload_path_use_subfolders_title"
+			android:summary="@string/prefs_instant_upload_path_use_subfolders_summary"
+			android:key="instant_video_upload_path_use_subfolders" />
+	    <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+	        				android:title="@string/instant_video_upload_on_wifi"
+	        				android:key="instant_video_upload_on_wifi"/>
+		<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+			android:title="@string/instant_video_upload_on_charging"
+			android:key="instant_video_upload_on_charging"/>
+		<com.owncloud.android.ui.dialog.OwnCloudListPreference android:key="prefs_instant_behaviour"
+			android:dialogTitle="@string/prefs_instant_behaviour_dialogTitle"
+			android:title="@string/prefs_instant_behaviour_title"
+			android:entries="@array/pref_behaviour_entries"
+			android:entryValues="@array/pref_behaviour_entryValues"
+			android:defaultValue="NOTHING"
+			android:summary="%s"
+			/>
+	    <!-- DISABLED FOR RELEASE UNTIL FIXED
+	    CheckBoxPreference android:key="log_to_file"
+	                        android:title="@string/prefs_log_title"
+	                        android:summary="@string/prefs_log_summary"/>
+		<Preference 		android:key="log_history"
+	                        android:title="@string/prefs_log_title_history"
+	                        android:summary="@string/prefs_log_summary_history"/ -->
+                        
+    </PreferenceCategory>
+
+	<PreferenceCategory android:title="@string/prefs_category_details">
+		<android.preference.CheckBoxPreference android:title="@string/prefs_passcode" android:key="set_pincode" />
+	</PreferenceCategory>
+
+	<PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
+		<Preference android:title="@string/prefs_calendar_contacts"
+					android:key="calendar_contacts"
+					android:summary="@string/prefs_calendar_contacts_summary" />
+		<Preference android:title="@string/prefs_help" android:key="help" />
+		<Preference android:title="@string/prefs_recommend" android:key="recommend" />
+		<Preference android:title="@string/prefs_feedback" android:key="feedback" />
+		<Preference android:title="@string/actionbar_logger" android:key="logger" />
+		<Preference android:title="@string/prefs_imprint" android:key="imprint" />
+		<Preference android:title="@string/about_title" android:id="@+id/about_app" android:key="about_app" />
+	</PreferenceCategory>
+
+</PreferenceScreen>

+ 40 - 29
src/com/owncloud/android/datamodel/MediaProvider.java

@@ -21,7 +21,7 @@
 
 package com.owncloud.android.datamodel;
 
-import android.app.Activity;
+import android.content.ContentResolver;
 import android.database.Cursor;
 import android.net.Uri;
 import android.provider.MediaStore;
@@ -41,18 +41,18 @@ public class MediaProvider {
      * TODO rewrite
      * Getting All Images Path
      *
-     * @param activity
+     * @param contentResolver the content resolver
      * @return List with images folders
      */
-    public static List<MediaFolder> getAllShownImagesPath(Activity activity) {
+    public static List<MediaFolder> getAllShownImagesPath(ContentResolver contentResolver) {
         Cursor cursor;
+        List<MediaFolder> mediaFolders = new ArrayList<>();
         int column_index_data, column_index_folder_name, column_index_data_image;
         ArrayList<String> listOfAllImages = new ArrayList<>();
-        String absolutePathOfImage = null;
-        String folderName = null;
+        String absolutePathOfImage;
+        String folderName;
 
         String[] projectionTest = {MediaStore.MediaColumns.DATA, MediaStore.Images.Media.BUCKET_DISPLAY_NAME};
-        //String[] projection = {MediaStore.Images.Media.BUCKET_DISPLAY_NAME,MediaStore.Images.Media.BUCKET_ID};
         String[] folderProjection = new String[]{"Distinct " + MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore
                 .MediaColumns.DATA};
         String[] fileProjection = new String[]{MediaStore.MediaColumns.DATA};
@@ -63,41 +63,52 @@ public class MediaProvider {
         String folderSortOrder = "MAX(" + MediaStore.Images.Media.DISPLAY_NAME + ") DESC";
         String fileSortOrder = MediaStore.MediaColumns.DATA + " DESC LIMIT 8"; //  LIMIT 8
 
-        cursor = activity.getContentResolver().query(MEDIA_URI, folderProjection, folderSelection, null, folderSortOrder);
+        cursor = contentResolver.query(MEDIA_URI, folderProjection, folderSelection, null, folderSortOrder);
+
+        if (cursor == null) {
+            return mediaFolders;
+        }
 
         column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
         column_index_folder_name = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
+        Cursor cursorImages;
 
-        List<MediaFolder> mediaFolders = new ArrayList<>();
         while (cursor.moveToNext()) {
-            MediaFolder mediaFolder = new MediaFolder();
             absolutePathOfImage = cursor.getString(column_index_data);
-            folderName = cursor.getString(column_index_folder_name);
-            mediaFolder.folderName = folderName;
-            mediaFolder.absolutePath = absolutePathOfImage.substring(0, absolutePathOfImage.lastIndexOf(folderName) +
-                    folderName
-                    .length());
-            mediaFolder.filePaths = new ArrayList<>();
-
-            // TODO: This can be done with one query, no limit, but only adding the 8 to the list and still get the
-            // total count
 
-            Cursor cursorImages = activity.getContentResolver().query(MEDIA_URI, fileProjection, fileSelection + "'" +
+            cursorImages = contentResolver.query(MEDIA_URI, fileProjection, fileSelection + "'" +
                             absolutePathOfImage.substring(0, absolutePathOfImage.lastIndexOf("/")) + "/%'", null,
                     fileSortOrder);
-            column_index_data_image = cursorImages.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
-            Log.d(TAG, "Reading images for --> " + mediaFolder.absolutePath);
-            while (cursorImages.moveToNext()) {
-                mediaFolder.filePaths.add(cursorImages.getString(column_index_data_image));
-            }
 
-            mediaFolder.numberOfFiles = activity.getContentResolver().query(MEDIA_URI, fileProjection, fileSelection +
-                            "'" +
-                            absolutePathOfImage.substring(0, absolutePathOfImage.lastIndexOf("/")) + "/%'", null,
-                    null).getCount();
+            if (cursorImages != null) {
+
+                MediaFolder mediaFolder = new MediaFolder();
+                folderName = cursor.getString(column_index_folder_name);
+                mediaFolder.folderName = folderName;
+                mediaFolder.absolutePath = absolutePathOfImage.substring(0, absolutePathOfImage.lastIndexOf(folderName) +
+                        folderName
+                                .length());
+                mediaFolder.filePaths = new ArrayList<>();
+
+                column_index_data_image = cursorImages.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
+                Log.d(TAG, "Reading images for --> " + mediaFolder.absolutePath);
+                while (cursorImages.moveToNext()) {
+                    mediaFolder.filePaths.add(cursorImages.getString(column_index_data_image));
+                }
+                cursorImages.close();
 
-            mediaFolders.add(mediaFolder);
+                mediaFolder.numberOfFiles = contentResolver.query(
+                        MEDIA_URI,
+                        fileProjection,
+                        fileSelection + "'"
+                                + absolutePathOfImage.substring(0, absolutePathOfImage.lastIndexOf("/")) + "/%'",
+                        null,
+                        null).getCount();
+
+                mediaFolders.add(mediaFolder);
+            }
         }
+        cursor.close();
 
         return mediaFolders;
     }

+ 66 - 0
src/com/owncloud/android/datamodel/SyncedFolderItem.java

@@ -0,0 +1,66 @@
+/**
+ *   Nextcloud Android client application
+ *
+ *   @author Andy Scherzinger
+ *   Copyright (C) 2016 Andy Scherzinger
+ *   Copyright (C) 2016 Nextcloud
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ *   License as published by the Free Software Foundation; either
+ *   version 3 of the License, or any later version.
+ *
+ *   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 AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public
+ *   License along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.owncloud.android.datamodel;
+
+import java.util.List;
+
+/**
+ * TODO javadoc
+ */
+public class SyncedFolderItem extends SyncedFolder {
+    private List<String> filePaths;
+    private String folderName;
+    private long numberOfFiles;
+
+    public SyncedFolderItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
+                            Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
+                            List<String> filePaths, String folderName, long numberOfFiles) {
+        super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled);
+        this.filePaths = filePaths;
+        this.folderName = folderName;
+        this.numberOfFiles = numberOfFiles;
+    }
+
+    public List<String> getFilePaths() {
+        return filePaths;
+    }
+
+    public void setFilePaths(List<String> filePaths) {
+        this.filePaths = filePaths;
+    }
+
+    public String getFolderName() {
+        return folderName;
+    }
+
+    public void setFolderName(String folderName) {
+        this.folderName = folderName;
+    }
+
+    public long getNumberOfFiles() {
+        return numberOfFiles;
+    }
+
+    public void setNumberOfFiles(long numberOfFiles) {
+        this.numberOfFiles = numberOfFiles;
+    }
+}

+ 6 - 4
src/com/owncloud/android/datamodel/SyncedFolderProvider.java

@@ -28,6 +28,8 @@ import android.support.annotation.NonNull;
 import com.owncloud.android.db.ProviderMeta;
 import com.owncloud.android.lib.common.utils.Log_OC;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Observable;
 
 /**
@@ -77,7 +79,7 @@ public class SyncedFolderProvider extends Observable {
      *
      * @return all synced folder entries, empty if none have been found
      */
-    public SyncedFolder[] getSyncedFolders() {
+    public List<SyncedFolder> getSyncedFolders() {
         Cursor cursor = mContentResolver.query(
                 ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
                 null,
@@ -87,14 +89,14 @@ public class SyncedFolderProvider extends Observable {
         );
 
         if (cursor != null) {
-            SyncedFolder[] list = new SyncedFolder[cursor.getCount()];
+            List<SyncedFolder> list = new ArrayList<>(cursor.getCount());
             if (cursor.moveToFirst()) {
                 do {
                     SyncedFolder syncedFolder = createSyncedFolderFromCursor(cursor);
                     if (syncedFolder == null) {
                         Log_OC.e(TAG, "SyncedFolder could not be created from cursor");
                     } else {
-                        list[cursor.getPosition()] = syncedFolder;
+                        list.add(cursor.getPosition(), syncedFolder);
                     }
                 } while (cursor.moveToNext());
 
@@ -105,7 +107,7 @@ public class SyncedFolderProvider extends Observable {
             Log_OC.e(TAG, "DB error creating read all cursor for synced folders.");
         }
 
-        return new SyncedFolder[0];
+        return new ArrayList<>(0);
     }
 
     /**

+ 2 - 1
src/com/owncloud/android/services/observer/SyncedFolderObserverService.java

@@ -9,11 +9,12 @@ import com.owncloud.android.datamodel.SyncedFolder;
 import com.owncloud.android.datamodel.SyncedFolderProvider;
 
 import java.util.ArrayList;
+import java.util.List;
 
 public class SyncedFolderObserverService extends Service {
     private static final String TAG = "SyncedFolderObserverService";
     private SyncedFolderProvider mProvider;
-    private ArrayList<SyncedFolderObserver> syncedFolderObservers = new ArrayList<>();
+    private List<SyncedFolderObserver> syncedFolderObservers = new ArrayList<>();
 
     @Override
     public void onCreate() {

+ 94 - 8
src/com/owncloud/android/ui/activity/FolderSyncActivity.java

@@ -24,6 +24,8 @@ package com.owncloud.android.ui.activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.os.Handler;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.util.Log;
@@ -35,22 +37,35 @@ import android.widget.Toast;
 
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.datamodel.MediaFolder;
 import com.owncloud.android.datamodel.MediaProvider;
+import com.owncloud.android.datamodel.SyncedFolder;
+import com.owncloud.android.datamodel.SyncedFolderItem;
+import com.owncloud.android.datamodel.SyncedFolderProvider;
 import com.owncloud.android.ui.adapter.FolderSyncAdapter;
+import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.TimerTask;
 
 /**
  * Activity displaying all auto-synced folders and/or instant upload media folders.
  */
-public class FolderSyncActivity extends FileActivity implements FolderSyncAdapter.ClickListener {
+public class FolderSyncActivity extends FileActivity implements FolderSyncAdapter.ClickListener, SyncedFolderPreferencesDialogFragment.OnSyncedFolderPreferenceListener {
     private static final String TAG = FolderSyncActivity.class.getSimpleName();
+
+    private static final String SYNCED_FOLDER_PREFERENCES_DIALOG_TAG = "SYNCED_FOLDER_PREFERENCES_DIALOG";
+
     private RecyclerView mRecyclerView;
     private FolderSyncAdapter mAdapter;
     private LinearLayout mProgress;
     private TextView mEmpty;
+    private SyncedFolderProvider mSyncedFolderProvider;
+    private List<SyncedFolderItem> syncFolderItems;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -77,6 +92,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
 
         final int gridWidth = 4;
         mAdapter = new FolderSyncAdapter(this, gridWidth, this, mRecyclerView);
+        mSyncedFolderProvider = new SyncedFolderProvider(getContentResolver());
 
         final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
         mAdapter.setLayoutManager(lm);
@@ -93,7 +109,9 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
         new Thread(new Runnable() {
             @Override
             public void run() {
-                final List<MediaFolder> mediaFolders = MediaProvider.getAllShownImagesPath(FolderSyncActivity.this);
+                final List<MediaFolder> mediaFolders = MediaProvider.getAllShownImagesPath(getContentResolver());
+                syncFolderItems = mergeFolderData(mSyncedFolderProvider.getSyncedFolders(),
+                        mediaFolders);
 
                 for (MediaFolder mediaFolder : mediaFolders) {
                     Log.d(TAG, mediaFolder.absolutePath);
@@ -102,7 +120,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
                 mHandler.post(new TimerTask() {
                     @Override
                     public void run() {
-                        mAdapter.setMediaFolders(mediaFolders);
+                        mAdapter.setSyncFolderItems(syncFolderItems);
                         setListShown(true);
                     }
                 });
@@ -110,7 +128,65 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
         }).start();
     }
 
-    void setListShown(boolean shown) {
+    private List<SyncedFolderItem> mergeFolderData(List<SyncedFolder> syncedFolders, List<MediaFolder> mediaFolders) {
+        Map<String, SyncedFolder> syncedFoldersMap = createSyncedFoldersMap(syncedFolders);
+        List<SyncedFolderItem> result = new ArrayList<>();
+
+        for (MediaFolder mediaFolder : mediaFolders) {
+            if (syncedFoldersMap.containsKey(mediaFolder.absolutePath)) {
+                SyncedFolder syncedFolder = syncedFoldersMap.get(mediaFolder.absolutePath);
+                result.add(createSyncedFolder(syncedFolder,mediaFolder));
+            } else {
+                result.add(createSyncedFolderFromMediaFolder(mediaFolder));
+            }
+        }
+
+        return result;
+    }
+
+    private SyncedFolderItem createSyncedFolder(SyncedFolder syncedFolder, MediaFolder mediaFolder) {
+        return new SyncedFolderItem(
+                syncedFolder.getId(),
+                syncedFolder.getLocalPath(),
+                syncedFolder.getRemotePath(),
+                syncedFolder.getWifiOnly(),
+                syncedFolder.getChargingOnly(),
+                syncedFolder.getSubfolderByDate(),
+                syncedFolder.getAccount(),
+                syncedFolder.getUploadAction(),
+                syncedFolder.isEnabled(),
+                mediaFolder.filePaths,
+                mediaFolder.folderName,
+                mediaFolder.numberOfFiles);
+    }
+
+    private SyncedFolderItem createSyncedFolderFromMediaFolder(MediaFolder mediaFolder) {
+        return new SyncedFolderItem(
+                0,
+                mediaFolder.absolutePath,
+                getString(R.string.instant_upload_path) + "/" + mediaFolder.folderName,
+                true,
+                false,
+                false,
+                AccountUtils.getCurrentOwnCloudAccount(this).name,
+                1,
+                false,
+                mediaFolder.filePaths,
+                mediaFolder.folderName,
+                mediaFolder.numberOfFiles);
+    }
+
+    private Map<String,SyncedFolder> createSyncedFoldersMap(List<SyncedFolder> syncFolders) {
+        Map<String, SyncedFolder> result = new HashMap<>();
+        if (syncFolders != null) {
+            for (SyncedFolder syncFolder : syncFolders) {
+                result.put(syncFolder.getLocalPath(), syncFolder);
+            }
+        }
+        return result;
+    }
+
+    private void setListShown(boolean shown) {
         if (mRecyclerView != null) {
             mRecyclerView.setVisibility(shown ? View.VISIBLE : View.GONE);
             mProgress.setVisibility(shown ? View.GONE : View.VISIBLE);
@@ -152,12 +228,22 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     }
 
     @Override
-    public void onSyncStatusToggleClick(int section, MediaFolder mediaFolder) {
-        Toast.makeText(this,"Sync Status Clicked for " + mediaFolder.absolutePath,Toast.LENGTH_SHORT).show();
+    public void onSyncStatusToggleClick(int section, SyncedFolderItem syncedFolderItem) {
+        Toast.makeText(this, "Sync Status Clicked for " + syncedFolderItem.getLocalPath(), Toast.LENGTH_SHORT).show();
+    }
+
+    @Override
+    public void onSyncFolderSettingsClick(int section, SyncedFolderItem syncedFolderItem) {
+        FragmentManager fm = getSupportFragmentManager();
+        FragmentTransaction ft = fm.beginTransaction();
+        ft.addToBackStack(null);
+
+        SyncedFolderPreferencesDialogFragment.newInstance(syncedFolderItem)
+                .show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
     }
 
     @Override
-    public void onSyncFolderSettingsClick(int section, MediaFolder mediaFolder) {
-        Toast.makeText(this,"Menu Clicked for " + mediaFolder.absolutePath,Toast.LENGTH_SHORT).show();
+    public void onSaveSyncedFolderPreference() {
+        Toast.makeText(this, "onSaveSyncedFolderPreference clicked", Toast.LENGTH_SHORT).show();
     }
 }

+ 16 - 16
src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java

@@ -34,7 +34,7 @@ import android.widget.TextView;
 
 import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
 import com.owncloud.android.R;
-import com.owncloud.android.datamodel.MediaFolder;
+import com.owncloud.android.datamodel.SyncedFolderItem;
 import com.owncloud.android.datamodel.ThumbnailsCacheManager;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.utils.BitmapUtils;
@@ -54,42 +54,42 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
     private final Context mContext;
     private final int mGridWidth;
     private final ClickListener mListener;
-    private final List<MediaFolder> mMediaFolders;
+    private final List<SyncedFolderItem> mSyncFolderItems;
     private final RecyclerView mRecyclerView;
 
     public FolderSyncAdapter(Context context, int gridWidth, ClickListener listener, RecyclerView recyclerView) {
         mContext = context;
         mGridWidth = gridWidth * 2;
         mListener = listener;
-        mMediaFolders = new ArrayList<>();
+        mSyncFolderItems = new ArrayList<>();
         mRecyclerView = recyclerView;
     }
 
-    public void setMediaFolders(List<MediaFolder> mediaFolders) {
-        mMediaFolders.clear();
-        mMediaFolders.addAll(mediaFolders);
+    public void setSyncFolderItems(List<SyncedFolderItem> syncFolderItems) {
+        mSyncFolderItems.clear();
+        mSyncFolderItems.addAll(syncFolderItems);
         notifyDataSetChanged();
     }
 
     @Override
     public int getSectionCount() {
-        return mMediaFolders.size();
+        return mSyncFolderItems.size();
     }
 
     @Override
     public int getItemCount(int section) {
-        return mMediaFolders.get(section).filePaths.size();
+        return mSyncFolderItems.get(section).getFilePaths().size();
     }
 
     @Override
     public void onBindHeaderViewHolder(MainViewHolder holder, final int section) {
-        holder.title.setText(mMediaFolders.get(section).folderName);
+        holder.title.setText(mSyncFolderItems.get(section).getFolderName());
         holder.syncStatusButton.setVisibility(View.VISIBLE);
         holder.syncStatusButton.setTag(section);
         holder.syncStatusButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                mListener.onSyncStatusToggleClick(section,mMediaFolders.get(section));
+                mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
             }
         });
         holder.menuButton.setVisibility(View.VISIBLE);
@@ -97,7 +97,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
         holder.menuButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                mListener.onSyncFolderSettingsClick(section,mMediaFolders.get(section));
+                mListener.onSyncFolderSettingsClick(section, mSyncFolderItems.get(section));
             }
         });
     }
@@ -106,7 +106,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
     public void onBindViewHolder(MainViewHolder holder, int section, int relativePosition, int absolutePosition) {
         final Context c = holder.itemView.getContext();
 
-        File file = new File(mMediaFolders.get(section).filePaths.get(relativePosition));
+        File file = new File(mSyncFolderItems.get(section).getFilePaths().get(relativePosition));
 
         /** Cancellation needs do be checked and done before changing the drawable in fileIcon, or
          * {@link ThumbnailsCacheManager#cancelPotentialThumbnailWork} will NEVER cancel any task.
@@ -158,8 +158,8 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
             holder.image.setImageResource(MimetypeIconUtil.getFileTypeIconId(null, file.getName()));
         }
 
-        if(mMediaFolders.get(section).numberOfFiles > 8 && relativePosition >= 8-1) {
-            holder.counterValue.setText(Long.toString(mMediaFolders.get(section).numberOfFiles-8));
+        if (mSyncFolderItems.get(section).getNumberOfFiles() > 8 && relativePosition >= 8 - 1) {
+            holder.counterValue.setText(Long.toString(mSyncFolderItems.get(section).getNumberOfFiles() - 8));
             holder.counterBar.setVisibility(View.VISIBLE);
             holder.thumbnailDarkener.setVisibility(View.VISIBLE);
         } else {
@@ -180,8 +180,8 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
     }
 
     public interface ClickListener {
-        void onSyncStatusToggleClick(int section, MediaFolder mediaFolder);
-        void onSyncFolderSettingsClick(int section, MediaFolder mediaFolder);
+        void onSyncStatusToggleClick(int section, SyncedFolderItem syncedFolderItem);
+        void onSyncFolderSettingsClick(int section, SyncedFolderItem syncedFolderItem);
     }
 
     static class MainViewHolder extends RecyclerView.ViewHolder {

+ 138 - 0
src/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java

@@ -0,0 +1,138 @@
+/**
+ * Nextcloud Android client application
+ *
+ * @author Andy Scherzinger
+ * Copyright (C) 2016 Andy Scherzinger
+ * Copyright (C) 2016 Nextcloud
+ * <p>
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ * <p>
+ * 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 AFFERO GENERAL PUBLIC LICENSE for more details.
+ * <p>
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.owncloud.android.ui.dialog;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.DialogFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.owncloud.android.R;
+import com.owncloud.android.datamodel.SyncedFolderItem;
+import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.ui.dialog.parcel.SyncedFolderParcelable;
+
+/**
+ * Dialog to show the preferences/configuration of a synced folder allowing the user
+ * to change the different parameters.
+ */
+public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
+
+    private final static String TAG = SyncedFolderPreferencesDialogFragment.class.getSimpleName();
+    public static final String SYNCED_FOLDER_PARCELABLE = "SyncedFolderParcelable";
+
+    protected View mView = null;
+
+    private SyncedFolderParcelable mSyncedFolder;
+
+    public static SyncedFolderPreferencesDialogFragment newInstance(SyncedFolderItem syncedFolder) {
+        SyncedFolderPreferencesDialogFragment dialogFragment = new SyncedFolderPreferencesDialogFragment();
+
+        if (syncedFolder == null) {
+            throw new IllegalArgumentException("SyncedFolder is mandatory but NULL!");
+        }
+
+        Bundle args = new Bundle();
+        args.putParcelable(SYNCED_FOLDER_PARCELABLE, new SyncedFolderParcelable(syncedFolder));
+        dialogFragment.setArguments(args);
+
+        return dialogFragment;
+    }
+
+    @Override
+    public void onAttach(Activity activity) {
+        super.onAttach(activity);
+        if (!(activity instanceof OnSyncedFolderPreferenceListener)) {
+            throw new IllegalArgumentException("The host activity must implement " + OnSyncedFolderPreferenceListener.class.getCanonicalName());
+        }
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        // keep the state of the fragment on configuration changes
+        setRetainInstance(true);
+
+        // TODO check UX if it shouldn't be cancelable
+        //setCancelable(false);
+        mView = null;
+
+        mSyncedFolder = getArguments().getParcelable(SYNCED_FOLDER_PARCELABLE);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+        Log_OC.d(TAG, "onCreateView, savedInstanceState is " + savedInstanceState);
+
+        mView = inflater.inflate(R.layout.folder_sync_settings_layout, container, false);
+
+        Button save = (Button) mView.findViewById(R.id.save);
+        save.setOnClickListener(new OnSyncedFolderSaveClickListener());
+
+        Button cancel = (Button) mView.findViewById(R.id.cancel);
+        cancel.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                dismiss();
+            }
+        });
+
+        ((TextView) mView.findViewById(R.id.local_folder_summary)).setText(mSyncedFolder.getLocalPath());
+        ((TextView) mView.findViewById(R.id.remote_folder_summary)).setText(mSyncedFolder.getRemotePath());
+
+        return mView;
+    }
+
+    @Override
+    @NonNull
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+        final Dialog dialog = super.onCreateDialog(savedInstanceState);
+        dialog.setTitle(R.string.folder_sync_preferences);
+        return dialog;
+    }
+
+    @Override
+    public void onDestroyView() {
+        Log_OC.d(TAG, "destroy SyncedFolderPreferencesDialogFragment view");
+        if (getDialog() != null && getRetainInstance())
+            getDialog().setDismissMessage(null);
+        super.onDestroyView();
+    }
+
+    private class OnSyncedFolderSaveClickListener implements OnClickListener {
+        @Override
+        public void onClick(View v) {
+            dismiss();
+            ((OnSyncedFolderPreferenceListener) getActivity()).onSaveSyncedFolderPreference();
+        }
+    }
+
+    public interface OnSyncedFolderPreferenceListener {
+        public void onSaveSyncedFolderPreference();
+    }
+}

+ 172 - 0
src/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java

@@ -0,0 +1,172 @@
+/**
+ * Nextcloud Android client application
+ *
+ * @author Andy Scherzinger
+ * Copyright (C) 2016 Andy Scherzinger
+ * Copyright (C) 2016 Nextcloud
+ * <p>
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ * <p>
+ * 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 AFFERO GENERAL PUBLIC LICENSE for more details.
+ * <p>
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.owncloud.android.ui.dialog.parcel;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import com.owncloud.android.datamodel.SyncedFolderItem;
+
+/**
+ * Parceble for SyncedFolder objects to transport them from/to dialog fragments.
+ */
+public class SyncedFolderParcelable implements Parcelable {
+    private String mLocalPath;
+    private String mRemotePath;
+    private Boolean mWifiOnly;
+    private Boolean mChargingOnly;
+    private boolean mEnabled;
+    private Boolean mSubfolderByDate;
+    private Integer mUploadAction;
+    private long mId;
+    private String mAccount;
+
+    public SyncedFolderParcelable() {
+    }
+
+    public SyncedFolderParcelable(SyncedFolderItem syncedFolderItem) {
+        mId = syncedFolderItem.getId();
+        mLocalPath = syncedFolderItem.getLocalPath();
+        mRemotePath = syncedFolderItem.getRemotePath();
+        mWifiOnly = syncedFolderItem.getWifiOnly();
+        mChargingOnly = syncedFolderItem.getChargingOnly();
+        mEnabled = syncedFolderItem.isEnabled();
+        mSubfolderByDate = syncedFolderItem.getSubfolderByDate();
+        mAccount = syncedFolderItem.getAccount();
+        mUploadAction = syncedFolderItem.getUploadAction();
+    }
+
+    public SyncedFolderParcelable(Parcel read) {
+        mId = read.readLong();
+        mLocalPath = read.readString();
+        mRemotePath = read.readString();
+        mWifiOnly = read.readInt()!= 0;
+        mChargingOnly = read.readInt() != 0;
+        mEnabled = read.readInt() != 0;
+        mSubfolderByDate = read.readInt() != 0;
+        mAccount = read.readString();
+        mUploadAction = read.readInt();
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeLong(mId);
+        dest.writeString(mLocalPath);
+        dest.writeString(mRemotePath);
+        dest.writeInt(mWifiOnly ? 1 : 0);
+        dest.writeInt(mChargingOnly ? 1 : 0);
+        dest.writeInt(mEnabled ? 1 : 0);
+        dest.writeInt(mSubfolderByDate ? 1 : 0);
+        dest.writeString(mAccount);
+        dest.writeInt(mUploadAction);
+    }
+
+    public static final Creator<SyncedFolderParcelable> CREATOR =
+            new Creator<SyncedFolderParcelable>() {
+
+                @Override
+                public SyncedFolderParcelable createFromParcel(Parcel source) {
+                    return new SyncedFolderParcelable(source);
+                }
+
+                @Override
+                public SyncedFolderParcelable[] newArray(int size) {
+                    return new SyncedFolderParcelable[size];
+                }
+            };
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    public String getLocalPath() {
+        return mLocalPath;
+    }
+
+    public void setLocalPath(String mLocalPath) {
+        this.mLocalPath = mLocalPath;
+    }
+
+    public String getRemotePath() {
+        return mRemotePath;
+    }
+
+    public void setRemotePath(String mRemotePath) {
+        this.mRemotePath = mRemotePath;
+    }
+
+    public Boolean getWifiOnly() {
+        return mWifiOnly;
+    }
+
+    public void setWifiOnly(Boolean mWifiOnly) {
+        this.mWifiOnly = mWifiOnly;
+    }
+
+    public Boolean getChargingOnly() {
+        return mChargingOnly;
+    }
+
+    public void setChargingOnly(Boolean mChargingOnly) {
+        this.mChargingOnly = mChargingOnly;
+    }
+
+    public boolean isEnabled() {
+        return mEnabled;
+    }
+
+    public void setEnabled(boolean mEnabled) {
+        this.mEnabled = mEnabled;
+    }
+
+    public Boolean getSubfolderByDate() {
+        return mSubfolderByDate;
+    }
+
+    public void setSubfolderByDate(Boolean mSubfolderByDate) {
+        this.mSubfolderByDate = mSubfolderByDate;
+    }
+
+    public Integer getUploadAction() {
+        return mUploadAction;
+    }
+
+    public void setUploadAction(Integer mUploadAction) {
+        this.mUploadAction = mUploadAction;
+    }
+
+    public long getId() {
+        return mId;
+    }
+
+    public void setId(long mId) {
+        this.mId = mId;
+    }
+
+    public String getAccount() {
+        return mAccount;
+    }
+
+    public void setAccount(String mAccount) {
+        this.mAccount = mAccount;
+    }
+}