Browse Source

Make synced folder init/enable date persistent

Signed-off-by: Alice Gaudon <alice@gaudon.pro>
Alice Gaudon 5 years ago
parent
commit
7f4db3fdd0

+ 36 - 14
src/main/java/com/owncloud/android/datamodel/SyncedFolder.java

@@ -30,23 +30,23 @@ import lombok.Setter;
 /**
 /**
  * Synced folder entity containing all information per synced folder.
  * Synced folder entity containing all information per synced folder.
  */
  */
-@Getter
-@Setter
 @AllArgsConstructor
 @AllArgsConstructor
 public class SyncedFolder implements Serializable, Cloneable {
 public class SyncedFolder implements Serializable, Cloneable {
     public static final long UNPERSISTED_ID = Long.MIN_VALUE;
     public static final long UNPERSISTED_ID = Long.MIN_VALUE;
+    public static final long EMPTY_ENABLED_TIMESTAMP_MS = -1;
     private static final long serialVersionUID = -793476118299906429L;
     private static final long serialVersionUID = -793476118299906429L;
 
 
-    private long id = UNPERSISTED_ID;
-    private String localPath;
-    private String remotePath;
-    private Boolean wifiOnly;
-    private Boolean chargingOnly;
-    private Boolean subfolderByDate;
-    private String account;
-    private Integer uploadAction;
-    private boolean enabled;
-    private MediaFolderType type;
+    @Getter @Setter private long id;
+    @Getter @Setter private String localPath;
+    @Getter @Setter private String remotePath;
+    @Getter @Setter private Boolean wifiOnly;
+    @Getter @Setter private Boolean chargingOnly;
+    @Getter @Setter private Boolean subfolderByDate;
+    @Getter @Setter private String account;
+    @Getter @Setter private Integer uploadAction;
+    @Getter private boolean enabled;
+    @Getter private long enabledTimestampMs;
+    @Getter @Setter private MediaFolderType type;
 
 
     /**
     /**
      * constructor for new, to be persisted entity.
      * constructor for new, to be persisted entity.
@@ -59,11 +59,25 @@ public class SyncedFolder implements Serializable, Cloneable {
      * @param account         the account owning the synced folder
      * @param account         the account owning the synced folder
      * @param uploadAction    the action to be done after the upload
      * @param uploadAction    the action to be done after the upload
      * @param enabled         flag if synced folder config is active
      * @param enabled         flag if synced folder config is active
+     * @param timestampMs     the current timestamp in milliseconds
      * @param type            the type of the folder
      * @param type            the type of the folder
      */
      */
     public SyncedFolder(String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
     public SyncedFolder(String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
                         Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
                         Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
-                        MediaFolderType type) {
+                        long timestampMs, MediaFolderType type) {
+        this(UNPERSISTED_ID, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction,
+             enabled, timestampMs, type);
+    }
+
+    /**
+     * constructor for wrapping existing folders.
+     *
+     * @param id id
+     */
+    protected SyncedFolder(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
+                           Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
+                           long timestampMs, MediaFolderType type) {
+        this.id = id;
         this.localPath = localPath;
         this.localPath = localPath;
         this.remotePath = remotePath;
         this.remotePath = remotePath;
         this.wifiOnly = wifiOnly;
         this.wifiOnly = wifiOnly;
@@ -71,10 +85,18 @@ public class SyncedFolder implements Serializable, Cloneable {
         this.subfolderByDate = subfolderByDate;
         this.subfolderByDate = subfolderByDate;
         this.account = account;
         this.account = account;
         this.uploadAction = uploadAction;
         this.uploadAction = uploadAction;
-        this.enabled = enabled;
+        this.setEnabled(enabled, timestampMs);
         this.type = type;
         this.type = type;
     }
     }
 
 
+    /**
+     * @param timestampMs the current timestamp in milliseconds
+     */
+    public void setEnabled(boolean enabled, long timestampMs) {
+        this.enabled = enabled;
+        this.enabledTimestampMs = enabled ? timestampMs : EMPTY_ENABLED_TIMESTAMP_MS;
+    }
+
     public Object clone() {
     public Object clone() {
         try {
         try {
             return super.clone();
             return super.clone();

+ 7 - 4
src/main/java/com/owncloud/android/datamodel/SyncedFolderDisplayItem.java

@@ -56,9 +56,11 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
      */
      */
     public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
     public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
                                    Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
                                    Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
-                                   List<String> filePaths, String folderName, long numberOfFiles, MediaFolderType type)
+                                   long timestampMs, List<String> filePaths, String folderName, long numberOfFiles,
+                                   MediaFolderType type)
     {
     {
-        super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
+        super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
+              timestampMs, type);
         this.filePaths = filePaths;
         this.filePaths = filePaths;
         this.folderName = folderName;
         this.folderName = folderName;
         this.numberOfFiles = numberOfFiles;
         this.numberOfFiles = numberOfFiles;
@@ -66,8 +68,9 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
 
 
     public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
     public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
                                    Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
                                    Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
-                                   String folderName, MediaFolderType type) {
-        super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
+                                   long timestampMs, String folderName, MediaFolderType type) {
+        super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
+              timestampMs, type);
         this.folderName = folderName;
         this.folderName = folderName;
     }
     }
 }
 }

+ 10 - 2
src/main/java/com/owncloud/android/datamodel/SyncedFolderProvider.java

@@ -27,6 +27,7 @@ import android.content.Context;
 import android.database.Cursor;
 import android.database.Cursor;
 import android.net.Uri;
 import android.net.Uri;
 
 
+import com.nextcloud.client.core.Clock;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.nextcloud.client.preferences.AppPreferencesImpl;
 import com.nextcloud.client.preferences.AppPreferencesImpl;
 import com.owncloud.android.db.ProviderMeta;
 import com.owncloud.android.db.ProviderMeta;
@@ -37,6 +38,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 import java.util.Observable;
 import java.util.Observable;
 
 
+import javax.inject.Inject;
+
 import androidx.annotation.NonNull;
 import androidx.annotation.NonNull;
 
 
 import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
 import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
@@ -50,6 +53,8 @@ public class SyncedFolderProvider extends Observable {
     private ContentResolver mContentResolver;
     private ContentResolver mContentResolver;
     private AppPreferences preferences;
     private AppPreferences preferences;
 
 
+    @Inject protected Clock clock;
+
     /**
     /**
      * constructor.
      * constructor.
      *
      *
@@ -162,7 +167,7 @@ public class SyncedFolderProvider extends Observable {
                 // read sync folder object and update
                 // read sync folder object and update
                 SyncedFolder syncedFolder = createSyncedFolderFromCursor(cursor);
                 SyncedFolder syncedFolder = createSyncedFolderFromCursor(cursor);
 
 
-                syncedFolder.setEnabled(enabled);
+                syncedFolder.setEnabled(enabled, clock.getCurrentTime());
 
 
                 // update sync folder object in db
                 // update sync folder object in db
                 result = updateSyncFolder(syncedFolder);
                 result = updateSyncFolder(syncedFolder);
@@ -347,11 +352,13 @@ public class SyncedFolderProvider extends Observable {
                     ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION));
                     ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION));
             Boolean enabled = cursor.getInt(cursor.getColumnIndex(
             Boolean enabled = cursor.getInt(cursor.getColumnIndex(
                     ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED)) == 1;
                     ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED)) == 1;
+            long enabledTimestampMs = cursor.getLong(cursor.getColumnIndex(
+                    ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS));
             MediaFolderType type = MediaFolderType.getById(cursor.getInt(cursor.getColumnIndex(
             MediaFolderType type = MediaFolderType.getById(cursor.getInt(cursor.getColumnIndex(
                     ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE)));
                     ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE)));
 
 
             syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate,
             syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate,
-                    accountName, uploadAction, enabled, type);
+                    accountName, uploadAction, enabled, enabledTimestampMs, type);
         }
         }
         return syncedFolder;
         return syncedFolder;
     }
     }
@@ -370,6 +377,7 @@ public class SyncedFolderProvider extends Observable {
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.getWifiOnly());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.getWifiOnly());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.getChargingOnly());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.getChargingOnly());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED, syncedFolder.isEnabled());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED, syncedFolder.isEnabled());
+        cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS, syncedFolder.getEnabledTimestampMs());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.getSubfolderByDate());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.getSubfolderByDate());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT, syncedFolder.getAccount());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT, syncedFolder.getAccount());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION, syncedFolder.getUploadAction());
         cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION, syncedFolder.getUploadAction());

+ 2 - 1
src/main/java/com/owncloud/android/db/ProviderMeta.java

@@ -31,7 +31,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 = 49;
+    public static final int DB_VERSION = 50;
 
 
     private ProviderMeta() {
     private ProviderMeta() {
         // No instance
         // No instance
@@ -220,6 +220,7 @@ public class ProviderMeta {
         public static final String SYNCED_FOLDER_WIFI_ONLY = "wifi_only";
         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_CHARGING_ONLY = "charging_only";
         public static final String SYNCED_FOLDER_ENABLED = "enabled";
         public static final String SYNCED_FOLDER_ENABLED = "enabled";
+        public static final String SYNCED_FOLDER_ENABLED_TIMESTAMP_MS = "enabled_timestamp_ms";
         public static final String SYNCED_FOLDER_TYPE = "type";
         public static final String SYNCED_FOLDER_TYPE = "type";
         public static final String SYNCED_FOLDER_SUBFOLDER_BY_DATE = "subfolder_by_date";
         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_ACCOUNT = "account";

+ 2 - 5
src/main/java/com/owncloud/android/jobs/AccountRemovalJob.java

@@ -57,7 +57,6 @@ import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
 import com.owncloud.android.ui.events.AccountRemovedEvent;
 import com.owncloud.android.ui.events.AccountRemovedEvent;
 import com.owncloud.android.utils.EncryptionUtils;
 import com.owncloud.android.utils.EncryptionUtils;
 import com.owncloud.android.utils.FileStorageUtils;
 import com.owncloud.android.utils.FileStorageUtils;
-import com.owncloud.android.utils.FilesSyncHelper;
 import com.owncloud.android.utils.PushUtils;
 import com.owncloud.android.utils.PushUtils;
 
 
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.EventBus;
@@ -129,7 +128,7 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
             arbitraryDataProvider.deleteKeyForAccount(account.name, PENDING_FOR_REMOVAL);
             arbitraryDataProvider.deleteKeyForAccount(account.name, PENDING_FOR_REMOVAL);
 
 
             // remove synced folders set for account
             // remove synced folders set for account
-            remoceSyncedFolders(context, account, arbitraryDataProvider);
+            remoceSyncedFolders(context, account);
 
 
             // delete all uploads for account
             // delete all uploads for account
             uploadsStorageManager.removeAccountUploads(account);
             uploadsStorageManager.removeAccountUploads(account);
@@ -174,7 +173,7 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
         }
         }
     }
     }
 
 
-    private void remoceSyncedFolders(Context context, Account account, ArbitraryDataProvider arbitraryDataProvider) {
+    private void remoceSyncedFolders(Context context, Account account) {
         SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(context.getContentResolver(),
         SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(context.getContentResolver(),
                                                                              AppPreferencesImpl.fromContext(context));
                                                                              AppPreferencesImpl.fromContext(context));
         List<SyncedFolder> syncedFolders = syncedFolderProvider.getSyncedFolders();
         List<SyncedFolder> syncedFolders = syncedFolderProvider.getSyncedFolders();
@@ -183,8 +182,6 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
 
 
         for (SyncedFolder syncedFolder : syncedFolders) {
         for (SyncedFolder syncedFolder : syncedFolders) {
             if (syncedFolder.getAccount().equals(account.name)) {
             if (syncedFolder.getAccount().equals(account.name)) {
-                arbitraryDataProvider.deleteKeyForAccount(FilesSyncHelper.GLOBAL,
-                                                          FilesSyncHelper.SYNCEDFOLDERINITIATED + syncedFolder.getId());
                 syncedFolderIds.add(syncedFolder.getId());
                 syncedFolderIds.add(syncedFolder.getId());
             }
             }
         }
         }

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

@@ -42,9 +42,11 @@ import android.net.Uri;
 import android.os.Binder;
 import android.os.Binder;
 import android.text.TextUtils;
 import android.text.TextUtils;
 
 
+import com.nextcloud.client.core.Clock;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.datamodel.SyncedFolder;
 import com.owncloud.android.db.ProviderMeta;
 import com.owncloud.android.db.ProviderMeta;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
 import com.owncloud.android.lib.common.accounts.AccountUtils;
 import com.owncloud.android.lib.common.accounts.AccountUtils;
@@ -58,6 +60,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Locale;
 
 
+import javax.inject.Inject;
+
 import androidx.annotation.NonNull;
 import androidx.annotation.NonNull;
 
 
 /**
 /**
@@ -91,6 +95,7 @@ public class FileContentProvider extends ContentProvider {
     public static final int ARBITRARY_DATA_TABLE_INTRODUCTION_VERSION = 20;
     public static final int ARBITRARY_DATA_TABLE_INTRODUCTION_VERSION = 20;
     public static final int MINIMUM_PATH_SEGMENTS_SIZE = 1;
     public static final int MINIMUM_PATH_SEGMENTS_SIZE = 1;
 
 
+    @Inject protected Clock clock;
     private DataBaseHelper mDbHelper;
     private DataBaseHelper mDbHelper;
     private Context mContext;
     private Context mContext;
     private UriMatcher mUriMatcher;
     private UriMatcher mUriMatcher;
@@ -822,6 +827,7 @@ public class FileContentProvider extends ContentProvider {
                        + ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY + " INTEGER, "         // wifi_only
                        + ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY + " INTEGER, "         // wifi_only
                        + ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY + " INTEGER, "     // charging only
                        + ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY + " INTEGER, "     // charging only
                        + ProviderTableMeta.SYNCED_FOLDER_ENABLED + " INTEGER, "           // enabled
                        + ProviderTableMeta.SYNCED_FOLDER_ENABLED + " INTEGER, "           // enabled
+                       + ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " INTEGER, "           // enable date
                        + ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, " // subfolder by date
                        + ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, " // subfolder by date
                        + ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + "  TEXT, "             // account
                        + ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + "  TEXT, "             // account
                        + ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION + " INTEGER, "     // upload action
                        + ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION + " INTEGER, "     // upload action
@@ -2013,6 +2019,30 @@ public class FileContentProvider extends ContentProvider {
             if (!upgraded) {
             if (!upgraded) {
                 Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
                 Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
             }
             }
+
+            if (oldVersion < 50 && newVersion >= 50) {
+                Log_OC.i(SQL, "Entering in the #50 add persistent enable date to synced_folders table");
+                db.beginTransaction();
+                try {
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
+                                   ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " INTEGER ");
+
+                    db.execSQL("UPDATE " + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME + " SET " +
+                                   ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " = CASE " +
+                                   " WHEN enabled = 0 THEN " + SyncedFolder.EMPTY_ENABLED_TIMESTAMP_MS + " " +
+                                   " ELSE " + clock.getCurrentTime() +
+                                   " END ");
+
+                    upgraded = true;
+                    db.setTransactionSuccessful();
+                } finally {
+                    db.endTransaction();
+                }
+            }
+
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
         }
         }
 
 
         @Override
         @Override

+ 10 - 24
src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java

@@ -41,13 +41,13 @@ import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.TextView;
 
 
+import com.nextcloud.client.core.Clock;
 import com.nextcloud.client.device.PowerManagementService;
 import com.nextcloud.client.device.PowerManagementService;
 import com.nextcloud.client.di.Injectable;
 import com.nextcloud.client.di.Injectable;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.owncloud.android.BuildConfig;
 import com.owncloud.android.BuildConfig;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.R;
-import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.MediaFolder;
 import com.owncloud.android.datamodel.MediaFolder;
 import com.owncloud.android.datamodel.MediaFolderType;
 import com.owncloud.android.datamodel.MediaFolderType;
 import com.owncloud.android.datamodel.MediaProvider;
 import com.owncloud.android.datamodel.MediaProvider;
@@ -113,6 +113,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
     private int type;
     private int type;
     @Inject AppPreferences preferences;
     @Inject AppPreferences preferences;
     @Inject PowerManagementService powerManagementService;
     @Inject PowerManagementService powerManagementService;
+    @Inject Clock clock;
 
 
     @Override
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     protected void onCreate(Bundle savedInstanceState) {
@@ -223,7 +224,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
 
 
         final int gridWidth = getResources().getInteger(R.integer.media_grid_width);
         final int gridWidth = getResources().getInteger(R.integer.media_grid_width);
         boolean lightVersion = getResources().getBoolean(R.bool.syncedFolder_light);
         boolean lightVersion = getResources().getBoolean(R.bool.syncedFolder_light);
-        mAdapter = new SyncedFolderAdapter(this, gridWidth, this, lightVersion);
+        mAdapter = new SyncedFolderAdapter(this, clock, gridWidth, this, lightVersion);
         mSyncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences);
         mSyncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences);
 
 
         final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
         final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
@@ -386,6 +387,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                 syncedFolder.getAccount(),
                 syncedFolder.getAccount(),
                 syncedFolder.getUploadAction(),
                 syncedFolder.getUploadAction(),
                 syncedFolder.isEnabled(),
                 syncedFolder.isEnabled(),
+                clock.getCurrentTime(),
                 filePaths,
                 filePaths,
                 localFolder.getName(),
                 localFolder.getName(),
                 files.length,
                 files.length,
@@ -411,6 +413,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                 syncedFolder.getAccount(),
                 syncedFolder.getAccount(),
                 syncedFolder.getUploadAction(),
                 syncedFolder.getUploadAction(),
                 syncedFolder.isEnabled(),
                 syncedFolder.isEnabled(),
+                clock.getCurrentTime(),
                 mediaFolder.filePaths,
                 mediaFolder.filePaths,
                 mediaFolder.folderName,
                 mediaFolder.folderName,
                 mediaFolder.numberOfFiles,
                 mediaFolder.numberOfFiles,
@@ -432,9 +435,10 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                 true,
                 true,
                 false,
                 false,
                 false,
                 false,
-            getAccount().name,
+                getAccount().name,
                 FileUploader.LOCAL_BEHAVIOUR_FORGET,
                 FileUploader.LOCAL_BEHAVIOUR_FORGET,
                 false,
                 false,
+                clock.getCurrentTime(),
                 mediaFolder.filePaths,
                 mediaFolder.filePaths,
                 mediaFolder.folderName,
                 mediaFolder.folderName,
                 mediaFolder.numberOfFiles,
                 mediaFolder.numberOfFiles,
@@ -519,7 +523,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                 SyncedFolderDisplayItem emptyCustomFolder = new SyncedFolderDisplayItem(
                 SyncedFolderDisplayItem emptyCustomFolder = new SyncedFolderDisplayItem(
                     SyncedFolder.UNPERSISTED_ID, null, null, true, false,
                     SyncedFolder.UNPERSISTED_ID, null, null, true, false,
                     false, getAccount().name,
                     false, getAccount().name,
-                    FileUploader.LOCAL_BEHAVIOUR_FORGET, false, null, MediaFolderType.CUSTOM);
+                    FileUploader.LOCAL_BEHAVIOUR_FORGET, false, clock.getCurrentTime(), null, MediaFolderType.CUSTOM);
                 onSyncFolderSettingsClick(0, emptyCustomFolder);
                 onSyncFolderSettingsClick(0, emptyCustomFolder);
             }
             }
 
 
@@ -548,9 +552,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
 
 
     @Override
     @Override
     public void onSyncStatusToggleClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem) {
     public void onSyncStatusToggleClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem) {
-        ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
-                getContentResolver());
-
         if (syncedFolderDisplayItem.getId() > UNPERSISTED_ID) {
         if (syncedFolderDisplayItem.getId() > UNPERSISTED_ID) {
             mSyncedFolderProvider.updateSyncedFolderEnabled(syncedFolderDisplayItem.getId(),
             mSyncedFolderProvider.updateSyncedFolderEnabled(syncedFolderDisplayItem.getId(),
                     syncedFolderDisplayItem.isEnabled());
                     syncedFolderDisplayItem.isEnabled());
@@ -565,9 +566,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
             FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolderDisplayItem);
             FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolderDisplayItem);
 
 
             showBatteryOptimizationInfo();
             showBatteryOptimizationInfo();
-        } else {
-            String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + syncedFolderDisplayItem.getId();
-            arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
         }
         }
     }
     }
 
 
@@ -600,9 +598,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
 
 
     @Override
     @Override
     public void onSaveSyncedFolderPreference(SyncedFolderParcelable syncedFolder) {
     public void onSaveSyncedFolderPreference(SyncedFolderParcelable syncedFolder) {
-        ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
-                getContentResolver());
-
         // custom folders newly created aren't in the list already,
         // custom folders newly created aren't in the list already,
         // so triggering a refresh
         // so triggering a refresh
         if (MediaFolderType.CUSTOM == syncedFolder.getType() && syncedFolder.getId() == UNPERSISTED_ID) {
         if (MediaFolderType.CUSTOM == syncedFolder.getType() && syncedFolder.getId() == UNPERSISTED_ID) {
@@ -610,15 +605,12 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                     SyncedFolder.UNPERSISTED_ID, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(),
                     SyncedFolder.UNPERSISTED_ID, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(),
                     syncedFolder.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(),
                     syncedFolder.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(),
                     syncedFolder.getAccount(), syncedFolder.getUploadAction(), syncedFolder.getEnabled(),
                     syncedFolder.getAccount(), syncedFolder.getUploadAction(), syncedFolder.getEnabled(),
-                    new File(syncedFolder.getLocalPath()).getName(), syncedFolder.getType());
+                    clock.getCurrentTime(), new File(syncedFolder.getLocalPath()).getName(), syncedFolder.getType());
             long storedId = mSyncedFolderProvider.storeSyncedFolder(newCustomFolder);
             long storedId = mSyncedFolderProvider.storeSyncedFolder(newCustomFolder);
             if (storedId != -1) {
             if (storedId != -1) {
                 newCustomFolder.setId(storedId);
                 newCustomFolder.setId(storedId);
                 if (newCustomFolder.isEnabled()) {
                 if (newCustomFolder.isEnabled()) {
                     FilesSyncHelper.insertAllDBEntriesForSyncedFolder(newCustomFolder);
                     FilesSyncHelper.insertAllDBEntriesForSyncedFolder(newCustomFolder);
-                } else {
-                    String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + newCustomFolder.getId();
-                    arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
                 }
                 }
             }
             }
             mAdapter.addSyncFolderItem(newCustomFolder);
             mAdapter.addSyncFolderItem(newCustomFolder);
@@ -635,9 +627,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                     item.setId(storedId);
                     item.setId(storedId);
                     if (item.isEnabled()) {
                     if (item.isEnabled()) {
                         FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
                         FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
-                    } else {
-                        String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
-                        arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
                     }
                     }
                 }
                 }
             } else {
             } else {
@@ -645,9 +634,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                 mSyncedFolderProvider.updateSyncFolder(item);
                 mSyncedFolderProvider.updateSyncFolder(item);
                 if (item.isEnabled()) {
                 if (item.isEnabled()) {
                     FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
                     FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
-                } else {
-                    String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
-                    arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
                 }
                 }
             }
             }
 
 
@@ -699,7 +685,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         item.setChargingOnly(chargingOnly);
         item.setChargingOnly(chargingOnly);
         item.setSubfolderByDate(subfolderByDate);
         item.setSubfolderByDate(subfolderByDate);
         item.setUploadAction(uploadAction);
         item.setUploadAction(uploadAction);
-        item.setEnabled(enabled);
+        item.setEnabled(enabled, clock.getCurrentTime());
         return item;
         return item;
     }
     }
 
 

+ 6 - 3
src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java

@@ -33,6 +33,7 @@ import android.widget.TextView;
 
 
 import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
 import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
 import com.afollestad.sectionedrecyclerview.SectionedViewHolder;
 import com.afollestad.sectionedrecyclerview.SectionedViewHolder;
+import com.nextcloud.client.core.Clock;
 import com.owncloud.android.R;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.MediaFolderType;
 import com.owncloud.android.datamodel.MediaFolderType;
 import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
 import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
@@ -54,14 +55,16 @@ import butterknife.ButterKnife;
 public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedViewHolder> {
 public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedViewHolder> {
 
 
     private final Context mContext;
     private final Context mContext;
+    private final Clock clock;
     private final int mGridWidth;
     private final int mGridWidth;
     private final int mGridTotal;
     private final int mGridTotal;
     private final ClickListener mListener;
     private final ClickListener mListener;
     private final List<SyncedFolderDisplayItem> mSyncFolderItems;
     private final List<SyncedFolderDisplayItem> mSyncFolderItems;
     private final boolean mLight;
     private final boolean mLight;
 
 
-    public SyncedFolderAdapter(Context context, int gridWidth, ClickListener listener, boolean light) {
+    public SyncedFolderAdapter(Context context, Clock clock, int gridWidth, ClickListener listener, boolean light) {
         mContext = context;
         mContext = context;
+        this.clock = clock;
         mGridWidth = gridWidth;
         mGridWidth = gridWidth;
         mGridTotal = gridWidth * 2;
         mGridTotal = gridWidth * 2;
         mListener = listener;
         mListener = listener;
@@ -148,7 +151,7 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
         holder.syncStatusButton.setVisibility(View.VISIBLE);
         holder.syncStatusButton.setVisibility(View.VISIBLE);
         holder.syncStatusButton.setTag(section);
         holder.syncStatusButton.setTag(section);
         holder.syncStatusButton.setOnClickListener(v -> {
         holder.syncStatusButton.setOnClickListener(v -> {
-            mSyncFolderItems.get(section).setEnabled(!mSyncFolderItems.get(section).isEnabled());
+            mSyncFolderItems.get(section).setEnabled(!mSyncFolderItems.get(section).isEnabled(), clock.getCurrentTime());
             setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
             setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
             mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
             mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
         });
         });
@@ -157,7 +160,7 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
         holder.syncStatusButton.setVisibility(View.VISIBLE);
         holder.syncStatusButton.setVisibility(View.VISIBLE);
         holder.syncStatusButton.setTag(section);
         holder.syncStatusButton.setTag(section);
         holder.syncStatusButton.setOnClickListener(v -> {
         holder.syncStatusButton.setOnClickListener(v -> {
-            mSyncFolderItems.get(section).setEnabled(!mSyncFolderItems.get(section).isEnabled());
+            mSyncFolderItems.get(section).setEnabled(!mSyncFolderItems.get(section).isEnabled(), clock.getCurrentTime());
             setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
             setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
             mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
             mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
         });
         });

+ 23 - 54
src/main/java/com/owncloud/android/utils/FilesSyncHelper.java

@@ -30,7 +30,6 @@ import android.database.Cursor;
 import android.net.Uri;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Build;
 import android.provider.MediaStore;
 import android.provider.MediaStore;
-import android.text.TextUtils;
 import android.util.Log;
 import android.util.Log;
 
 
 import com.evernote.android.job.JobManager;
 import com.evernote.android.job.JobManager;
@@ -41,7 +40,6 @@ import com.nextcloud.client.jobs.BackgroundJobManager;
 import com.nextcloud.client.network.ConnectivityService;
 import com.nextcloud.client.network.ConnectivityService;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.MainApp;
-import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.FilesystemDataProvider;
 import com.owncloud.android.datamodel.FilesystemDataProvider;
 import com.owncloud.android.datamodel.MediaFolderType;
 import com.owncloud.android.datamodel.MediaFolderType;
 import com.owncloud.android.datamodel.SyncedFolder;
 import com.owncloud.android.datamodel.SyncedFolder;
@@ -73,7 +71,6 @@ public final class FilesSyncHelper {
     public static final String TAG = "FileSyncHelper";
     public static final String TAG = "FileSyncHelper";
 
 
     public static final String GLOBAL = "global";
     public static final String GLOBAL = "global";
-    public static final String SYNCEDFOLDERINITIATED = "syncedFolderIntitiated_";
 
 
     public static final int ContentSyncJobId = 315;
     public static final int ContentSyncJobId = 315;
 
 
@@ -84,59 +81,34 @@ public final class FilesSyncHelper {
     public static void insertAllDBEntriesForSyncedFolder(SyncedFolder syncedFolder) {
     public static void insertAllDBEntriesForSyncedFolder(SyncedFolder syncedFolder) {
         final Context context = MainApp.getAppContext();
         final Context context = MainApp.getAppContext();
         final ContentResolver contentResolver = context.getContentResolver();
         final ContentResolver contentResolver = context.getContentResolver();
-        ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(contentResolver);
 
 
-        Long currentTime = System.currentTimeMillis();
-        double currentTimeInSeconds = currentTime / 1000.0;
-        String currentTimeString = Long.toString((long) currentTimeInSeconds);
+        final long enabledTimestampMs = syncedFolder.getEnabledTimestampMs();
 
 
-        String syncedFolderInitiatedKey = SYNCEDFOLDERINITIATED + syncedFolder.getId();
-        boolean dryRun = TextUtils.isEmpty(arbitraryDataProvider.getValue
-                (GLOBAL, syncedFolderInitiatedKey));
-
-        if (MediaFolderType.IMAGE == syncedFolder.getType()) {
-            if (dryRun) {
-                arbitraryDataProvider.storeOrUpdateKeyValue(GLOBAL, syncedFolderInitiatedKey,
-                        currentTimeString);
-            } else {
-                FilesSyncHelper.insertContentIntoDB(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI
-                        , syncedFolder);
+        if (syncedFolder.isEnabled() && enabledTimestampMs >= 0) {
+            MediaFolderType mediaType = syncedFolder.getType();
+            if (mediaType == MediaFolderType.IMAGE) {
+                FilesSyncHelper.insertContentIntoDB(MediaStore.Images.Media.INTERNAL_CONTENT_URI
+                    , syncedFolder);
                 FilesSyncHelper.insertContentIntoDB(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                 FilesSyncHelper.insertContentIntoDB(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
-                        syncedFolder);
-            }
-
-        } else if (MediaFolderType.VIDEO == syncedFolder.getType()) {
-
-            if (dryRun) {
-                arbitraryDataProvider.storeOrUpdateKeyValue(GLOBAL, syncedFolderInitiatedKey,
-                        currentTimeString);
-            } else {
-                FilesSyncHelper.insertContentIntoDB(android.provider.MediaStore.Video.Media.INTERNAL_CONTENT_URI,
-                        syncedFolder);
+                                                    syncedFolder);
+            } else if (mediaType == MediaFolderType.VIDEO) {
+                FilesSyncHelper.insertContentIntoDB(MediaStore.Video.Media.INTERNAL_CONTENT_URI,
+                                                    syncedFolder);
                 FilesSyncHelper.insertContentIntoDB(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                 FilesSyncHelper.insertContentIntoDB(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
-                        syncedFolder);
-            }
-
-        } else {
-            try {
-                if (dryRun) {
-                    arbitraryDataProvider.storeOrUpdateKeyValue(GLOBAL, syncedFolderInitiatedKey,
-                            currentTimeString);
-                } else {
+                                                    syncedFolder);
+            } else {
+                try {
                     FilesystemDataProvider filesystemDataProvider = new FilesystemDataProvider(contentResolver);
                     FilesystemDataProvider filesystemDataProvider = new FilesystemDataProvider(contentResolver);
                     Path path = Paths.get(syncedFolder.getLocalPath());
                     Path path = Paths.get(syncedFolder.getLocalPath());
 
 
-                    String dateInitiated = arbitraryDataProvider.getValue(GLOBAL,
-                            syncedFolderInitiatedKey);
-
                     Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
                     Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
                         @Override
                         @Override
                         public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) {
                         public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) {
-
                             File file = path.toFile();
                             File file = path.toFile();
-                            if (attrs.lastModifiedTime().toMillis() >= Long.parseLong(dateInitiated) * 1000) {
+                            if (attrs.lastModifiedTime().toMillis() >= enabledTimestampMs) {
                                 filesystemDataProvider.storeOrUpdateFileValue(path.toAbsolutePath().toString(),
                                 filesystemDataProvider.storeOrUpdateFileValue(path.toAbsolutePath().toString(),
-                                        attrs.lastModifiedTime().toMillis(), file.isDirectory(), syncedFolder);
+                                                                              attrs.lastModifiedTime().toMillis(),
+                                                                              file.isDirectory(), syncedFolder);
                             }
                             }
 
 
                             return FileVisitResult.CONTINUE;
                             return FileVisitResult.CONTINUE;
@@ -147,11 +119,9 @@ public final class FilesSyncHelper {
                             return FileVisitResult.CONTINUE;
                             return FileVisitResult.CONTINUE;
                         }
                         }
                     });
                     });
-
+                } catch (IOException e) {
+                    Log.e(TAG, "Something went wrong while indexing files for auto upload " + e.getLocalizedMessage());
                 }
                 }
-
-            } catch (IOException e) {
-                Log.e(TAG, "Something went wrong while indexing files for auto upload " + e.getLocalizedMessage());
             }
             }
         }
         }
     }
     }
@@ -172,7 +142,6 @@ public final class FilesSyncHelper {
     private static void insertContentIntoDB(Uri uri, SyncedFolder syncedFolder) {
     private static void insertContentIntoDB(Uri uri, SyncedFolder syncedFolder) {
         final Context context = MainApp.getAppContext();
         final Context context = MainApp.getAppContext();
         final ContentResolver contentResolver = context.getContentResolver();
         final ContentResolver contentResolver = context.getContentResolver();
-        ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(contentResolver);
 
 
         Cursor cursor;
         Cursor cursor;
         int column_index_data;
         int column_index_data;
@@ -191,11 +160,10 @@ public final class FilesSyncHelper {
         }
         }
         path = path + "%";
         path = path + "%";
 
 
-        String syncedFolderInitiatedKey = SYNCEDFOLDERINITIATED + syncedFolder.getId();
-        String dateInitiated = arbitraryDataProvider.getValue(GLOBAL, syncedFolderInitiatedKey);
+        long enabledTimestampMs = syncedFolder.getEnabledTimestampMs();
 
 
         cursor = context.getContentResolver().query(uri, projection, MediaStore.MediaColumns.DATA + " LIKE ?",
         cursor = context.getContentResolver().query(uri, projection, MediaStore.MediaColumns.DATA + " LIKE ?",
-                new String[]{path}, null);
+                                                    new String[]{path}, null);
 
 
         if (cursor != null) {
         if (cursor != null) {
             column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
             column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
@@ -203,9 +171,10 @@ public final class FilesSyncHelper {
             while (cursor.moveToNext()) {
             while (cursor.moveToNext()) {
                 contentPath = cursor.getString(column_index_data);
                 contentPath = cursor.getString(column_index_data);
                 isFolder = new File(contentPath).isDirectory();
                 isFolder = new File(contentPath).isDirectory();
-                if (cursor.getLong(column_index_date_modified) >= Long.parseLong(dateInitiated)) {
+                if (cursor.getLong(column_index_date_modified) >= enabledTimestampMs / 1000.0) {
                     filesystemDataProvider.storeOrUpdateFileValue(contentPath,
                     filesystemDataProvider.storeOrUpdateFileValue(contentPath,
-                            cursor.getLong(column_index_date_modified), isFolder, syncedFolder);
+                                                                  cursor.getLong(column_index_date_modified), isFolder,
+                                                                  syncedFolder);
                 }
                 }
             }
             }
             cursor.close();
             cursor.close();

+ 1 - 0
src/test/java/com/owncloud/android/ui/activity/SyncedFoldersActivityTest.java

@@ -177,6 +177,7 @@ public class SyncedFoldersActivityTest {
                                            "test@nextcloud.com",
                                            "test@nextcloud.com",
                                            1,
                                            1,
                                            enabled,
                                            enabled,
+                                           System.currentTimeMillis(),
                                            new ArrayList<String>(),
                                            new ArrayList<String>(),
                                            folderName,
                                            folderName,
                                            2,
                                            2,