Browse Source

add database for synced folders

tobiasKaminsky 8 years ago
parent
commit
cf27c2c9d3

+ 12 - 3
src/com/owncloud/android/db/ProviderMeta.java

@@ -33,7 +33,7 @@ import com.owncloud.android.MainApp;
 public class ProviderMeta {
 public class ProviderMeta {
 
 
     public static final String DB_NAME = "filelist";
     public static final String DB_NAME = "filelist";
-    public static final int DB_VERSION = 15;
+    public static final int DB_VERSION = 16;
 
 
     private ProviderMeta() {
     private ProviderMeta() {
     }
     }
@@ -43,6 +43,7 @@ public class ProviderMeta {
         public static final String OCSHARES_TABLE_NAME = "ocshares";
         public static final String OCSHARES_TABLE_NAME = "ocshares";
         public static final String CAPABILITIES_TABLE_NAME = "capabilities";
         public static final String CAPABILITIES_TABLE_NAME = "capabilities";
         public static final String UPLOADS_TABLE_NAME = "list_of_uploads";
         public static final String UPLOADS_TABLE_NAME = "list_of_uploads";
+        public static final String SYNCED_FOLDERS_TABLE_NAME = "synced_folders";
         public static final Uri CONTENT_URI = Uri.parse("content://"
         public static final Uri CONTENT_URI = Uri.parse("content://"
                 + MainApp.getAuthority() + "/");
                 + MainApp.getAuthority() + "/");
         public static final Uri CONTENT_URI_FILE = Uri.parse("content://"
         public static final Uri CONTENT_URI_FILE = Uri.parse("content://"
@@ -149,8 +150,16 @@ public class ProviderMeta {
         public static final String UPLOADS_UPLOAD_END_TIMESTAMP = "upload_end_timestamp";
         public static final String UPLOADS_UPLOAD_END_TIMESTAMP = "upload_end_timestamp";
         public static final String UPLOADS_LAST_RESULT = "last_result";
         public static final String UPLOADS_LAST_RESULT = "last_result";
         public static final String UPLOADS_CREATED_BY = "created_by";
         public static final String UPLOADS_CREATED_BY = "created_by";
-
         public static final String UPLOADS_DEFAULT_SORT_ORDER = ProviderTableMeta._ID  + " collate nocase desc";
         public static final String UPLOADS_DEFAULT_SORT_ORDER = ProviderTableMeta._ID  + " collate nocase desc";
 
 
+        // Columns of synced folder table
+        public static final String SYNCED_FOLDER_LOCAL_PATH = "local_path";
+        public static final String SYNCED_FOLDER_REMOTE_PATH = "remote_path";
+        public static final String SYNCED_FOLDER_WIFI_ONLY = "wifi_only";
+        public static final String SYNCED_FOLDER_CHARGING_ONLY = "charging_only";
+        public static final String SYNCED_FOLDER_ENABLED = "enabled";
+        public static final String SYNCED_FOLDER_SUBFOLDER_BY_DATE = "subfolder_by_date";
+        public static final String SYNCED_FOLDER_ACCOUNT = "account";
+        public static final String SYNCED_FOLDER_UPLOAD_OPTION = "upload_option";
     }
     }
-}
+}

+ 29 - 0
src/com/owncloud/android/providers/FileContentProvider.java

@@ -535,6 +535,8 @@ public class FileContentProvider extends ContentProvider {
             // Create uploads table
             // Create uploads table
             createUploadsTable(db);
             createUploadsTable(db);
 
 
+            // Create synced folders table
+            createSyncedFoldersTable(db);
         }
         }
 
 
         @Override
         @Override
@@ -779,6 +781,19 @@ public class FileContentProvider extends ContentProvider {
                 }
                 }
             }
             }
 
 
+            if (oldVersion < 16 && newVersion >= 16) {
+                Log_OC.i("SQL", "Entering in the #16 ADD synced folders table");
+                db.beginTransaction();
+                try {
+                    // Create synced folders table
+                    createSyncedFoldersTable(db);
+                    upgraded = true;
+                    db.setTransactionSuccessful();
+                } finally {
+                    db.endTransaction();
+                }
+            }
+
             if (!upgraded)
             if (!upgraded)
                 Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
                 Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
                         ", newVersion == " + newVersion);
                         ", newVersion == " + newVersion);
@@ -892,6 +907,20 @@ public class FileContentProvider extends ContentProvider {
         */
         */
     }
     }
 
 
+    private void createSyncedFoldersTable(SQLiteDatabase db){
+        db.execSQL("CREATE TABLE " + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME + "("
+        + ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "                          // id
+                + ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH  + " TEXT, "           // local path
+                + ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH + " TEXT, "           // remote path
+                + ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY + " INTEGER, "          // wifi_only
+                + ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY + " INTEGER, "      // charging only
+                + ProviderTableMeta.SYNCED_FOLDER_ENABLED + " INTEGER, "            // enabled
+                + ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, "  // subfolder by date
+                + ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " INTEGER, "            // account
+                + ProviderTableMeta.SYNCED_FOLDER_UPLOAD_OPTION + " INTEGER );"     // upload action
+        );
+    }
+
     /**
     /**
      * Version 10 of database does not modify its scheme. It coincides with the upgrade of the ownCloud account names
      * Version 10 of database does not modify its scheme. It coincides with the upgrade of the ownCloud account names
      * structure to include in it the path to the server instance. Updating the account names and path to local files
      * structure to include in it the path to the server instance. Updating the account names and path to local files