浏览代码

background logic implemented

tobiasKaminsky 7 年之前
父节点
当前提交
ab096dd0f7

+ 43 - 3
src/main/java/com/owncloud/android/datamodel/ArbitraryDataProvider.java

@@ -108,12 +108,44 @@ public class ArbitraryDataProvider {
         }
     }
 
-    public boolean getBooleanValue(Account account, String key) {
-        String value = getValue(account, key);
+    public boolean getBooleanValue(String accountName, String key) {
+        String value = getValue(accountName, key);
 
         return !value.isEmpty() && value.equalsIgnoreCase("true");
     }
 
+    public boolean getBooleanValue(Account account, String key) {
+        return getBooleanValue(account.name, key);
+    }
+
+    /**
+     * returns integer if found else -1
+     *
+     * @param accountName
+     * @param key
+     * @return
+     */
+    public Integer getIntegerValue(String accountName, String key) {
+        String value = getValue(accountName, key);
+
+        if (value.isEmpty()) {
+            return -1;
+        } else {
+            return Integer.valueOf(value);
+        }
+    }
+
+    /**
+     * returns integer if found else -1
+     *
+     * @param account
+     * @param key
+     * @return
+     */
+    public Integer getIntegerValue(Account account, String key) {
+        return getIntegerValue(account.name, key);
+    }
+
     private ArrayList<String> getValues(Account account, String key) {
         Cursor cursor = contentResolver.query(
                 ProviderMeta.ProviderTableMeta.CONTENT_URI_ARBITRARY_DATA,
@@ -146,13 +178,21 @@ public class ArbitraryDataProvider {
         return new ArrayList<>();
     }
 
+    /**
+     * Returns stored value as string or empty string
+     * @return string if value found or empty string
+     */
     public String getValue(Account account, String key) {
+        return getValue(account.name, key);
+    }
+
+    public String getValue(String accountName, String key) {
         Cursor cursor = contentResolver.query(
                 ProviderMeta.ProviderTableMeta.CONTENT_URI_ARBITRARY_DATA,
                 null,
                 ProviderMeta.ProviderTableMeta.ARBITRARY_DATA_CLOUD_ID + " = ? and " +
                         ProviderMeta.ProviderTableMeta.ARBITRARY_DATA_KEY + " = ?",
-                new String[]{account.name, key},
+                new String[]{accountName, key},
                 null
         );
 

+ 47 - 7
src/main/java/com/owncloud/android/services/AdvancedFileAlterationListener.java

@@ -27,8 +27,11 @@ import android.text.TextUtils;
 import com.evernote.android.job.JobRequest;
 import com.evernote.android.job.util.support.PersistableBundleCompat;
 import com.owncloud.android.MainApp;
+import com.owncloud.android.datamodel.ArbitraryDataProvider;
+import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.datamodel.SyncedFolder;
 import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.ui.activity.FolderSyncActivity;
 import com.owncloud.android.utils.FileStorageUtils;
 
 import org.apache.commons.io.monitor.FileAlterationListener;
@@ -53,16 +56,18 @@ public class AdvancedFileAlterationListener implements FileAlterationListener {
     public static final String TAG = "AdvancedFileAlterationListener";
     public static final int DELAY_INVOCATION_MS = 2500;
     private Context context;
+    private boolean lightVersion;
 
     private SyncedFolder syncedFolder;
 
     private Map<String, Runnable> uploadMap = new HashMap<>();
     private Handler handler = new Handler();
 
-    public AdvancedFileAlterationListener(SyncedFolder syncedFolder) {
+    public AdvancedFileAlterationListener(SyncedFolder syncedFolder, boolean lightVersion) {
         super();
 
         context = MainApp.getAppContext();
+        this.lightVersion = lightVersion;
         this.syncedFolder = syncedFolder;
     }
 
@@ -122,20 +127,55 @@ public class AdvancedFileAlterationListener implements FileAlterationListener {
             Runnable runnable = new Runnable() {
                 @Override
                 public void run() {
+
+                    String remotePath;
+                    boolean subfolderByDate;
+                    boolean chargingOnly;
+                    boolean wifiOnly;
+                    Integer uploadAction;
+                    String accountName = syncedFolder.getAccount();
+
+                    if (lightVersion) {
+                        ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context
+                                .getContentResolver());
+
+                        remotePath = arbitraryDataProvider.getValue(accountName,
+                                FolderSyncActivity.SYNCED_FOLDER_LIGHT_REMOTE_FOLDER) + OCFile.PATH_SEPARATOR +
+                                new File(syncedFolder.getLocalPath()).getName() + OCFile.PATH_SEPARATOR;
+
+                        subfolderByDate = arbitraryDataProvider.getBooleanValue(accountName,
+                                FolderSyncActivity.SYNCED_FOLDER_LIGHT_USE_SUBFOLDERS);
+
+                        chargingOnly = arbitraryDataProvider.getBooleanValue(accountName,
+                                FolderSyncActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_CHARGING);
+
+                        wifiOnly = arbitraryDataProvider.getBooleanValue(accountName,
+                                FolderSyncActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
+
+                        uploadAction = arbitraryDataProvider.getIntegerValue(accountName,
+                                FolderSyncActivity.SYNCED_FOLDER_LIGHT_UPLOAD_BEHAVIOUR);
+                    } else {
+                        remotePath = syncedFolder.getRemotePath();
+                        subfolderByDate = syncedFolder.getSubfolderByDate();
+                        chargingOnly = syncedFolder.getChargingOnly();
+                        wifiOnly = syncedFolder.getWifiOnly();
+                        uploadAction = syncedFolder.getUploadAction();
+                    }
+
                     PersistableBundleCompat bundle = new PersistableBundleCompat();
                     bundle.putString(AutoUploadJob.LOCAL_PATH, file.getAbsolutePath());
                     bundle.putString(AutoUploadJob.REMOTE_PATH, FileStorageUtils.getInstantUploadFilePath(
                             currentLocale,
-                            syncedFolder.getRemotePath(), file.getName(),
+                            remotePath, file.getName(),
                             finalLastModificationTime,
-                            syncedFolder.getSubfolderByDate()));
-                    bundle.putString(AutoUploadJob.ACCOUNT, syncedFolder.getAccount());
-                    bundle.putInt(AutoUploadJob.UPLOAD_BEHAVIOUR, syncedFolder.getUploadAction());
+                            subfolderByDate));
+                    bundle.putString(AutoUploadJob.ACCOUNT, accountName);
+                    bundle.putInt(AutoUploadJob.UPLOAD_BEHAVIOUR, uploadAction);
 
                     new JobRequest.Builder(AutoUploadJob.TAG)
                             .setExecutionWindow(30_000L, 80_000L)
-                            .setRequiresCharging(syncedFolder.getChargingOnly())
-                            .setRequiredNetworkType(syncedFolder.getWifiOnly() ? JobRequest.NetworkType.UNMETERED :
+                            .setRequiresCharging(chargingOnly)
+                            .setRequiredNetworkType(wifiOnly ? JobRequest.NetworkType.UNMETERED :
                                     JobRequest.NetworkType.ANY)
                             .setExtras(bundle)
                             .setPersisted(false)

+ 7 - 3
src/main/java/com/owncloud/android/services/observer/SyncedFolderObserverService.java

@@ -28,6 +28,7 @@ import android.os.Binder;
 import android.os.IBinder;
 
 import com.owncloud.android.MainApp;
+import com.owncloud.android.R;
 import com.owncloud.android.datamodel.SyncedFolder;
 import com.owncloud.android.datamodel.SyncedFolderProvider;
 import com.owncloud.android.lib.common.utils.Log_OC;
@@ -69,7 +70,8 @@ public class SyncedFolderObserverService extends Service {
 
                 try {
                     observer.init();
-                    observer.addListener(new AdvancedFileAlterationListener(syncedFolder));
+                    observer.addListener(new AdvancedFileAlterationListener(syncedFolder,
+                            getResources().getBoolean(R.bool.syncedFolder_light)));
                     monitor.addObserver(observer);
                 } catch (Exception e) {
                     Log_OC.d(TAG, "Failed getting an observer to initialize " + e);
@@ -135,7 +137,8 @@ public class SyncedFolderObserverService extends Service {
                     try {
                         advancedFileAlterationObserver = new AdvancedFileAlterationObserver(syncedFolder, fileFilter);
                         advancedFileAlterationObserver.init();
-                        advancedFileAlterationObserver.addListener(new AdvancedFileAlterationListener(syncedFolder));
+                        advancedFileAlterationObserver.addListener(new AdvancedFileAlterationListener(syncedFolder,
+                                getResources().getBoolean(R.bool.syncedFolder_light)));
                         monitor.addObserver(advancedFileAlterationObserver);
                     } catch (Exception e) {
                         Log_OC.d(TAG, "Failed getting an observer to initialize");
@@ -152,7 +155,8 @@ public class SyncedFolderObserverService extends Service {
             try {
                 advancedFileAlterationObserver = new AdvancedFileAlterationObserver(syncedFolder, fileFilter);
                 advancedFileAlterationObserver.init();
-                advancedFileAlterationObserver.addListener(new AdvancedFileAlterationListener(syncedFolder));
+                advancedFileAlterationObserver.addListener(new AdvancedFileAlterationListener(syncedFolder,
+                        getResources().getBoolean(R.bool.syncedFolder_light)));
                 monitor.addObserver(advancedFileAlterationObserver);
             } catch (Exception e) {
                 Log_OC.d(TAG, "Failed getting an observer to initialize");

+ 4 - 0
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -353,6 +353,10 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
             navigationView.getMenu().removeItem(R.id.nav_contacts);
         }
 
+        if (getResources().getBoolean(R.bool.syncedFolder_light)) {
+            navigationView.getMenu().removeItem(R.id.nav_folder_sync);
+        }
+
         if (!getResources().getBoolean(R.bool.show_drawer_logout)) {
             navigationView.getMenu().removeItem(R.id.nav_logout);
         }

+ 185 - 4
src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java

@@ -22,6 +22,7 @@
 package com.owncloud.android.ui.activity;
 
 import android.accounts.Account;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.os.Bundle;
 import android.os.Handler;
@@ -29,16 +30,19 @@ import android.support.annotation.NonNull;
 import android.support.design.widget.BottomNavigationView;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
+import android.support.v7.app.AlertDialog;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.MenuItem;
 import android.view.View;
+import android.widget.CheckBox;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.AccountUtils;
+import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.MediaFolder;
 import com.owncloud.android.datamodel.MediaProvider;
 import com.owncloud.android.datamodel.OCFile;
@@ -72,11 +76,18 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
 
     private static final String SYNCED_FOLDER_PREFERENCES_DIALOG_TAG = "SYNCED_FOLDER_PREFERENCES_DIALOG";
     public static final String PRIORITIZED_FOLDER = "Camera";
+    public static final int REQUEST_CODE__SELECT_REMOTE_FOLDER = 0;
 
     private static final String SCREEN_NAME = "Auto upload";
 
     private static final String TAG = FolderSyncActivity.class.getSimpleName();
 
+    public static final String SYNCED_FOLDER_LIGHT_REMOTE_FOLDER = "SYNCED_FOLDER_LIGHT_REMOTE_FOLDER";
+    public static final String SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI = "SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI";
+    public static final String SYNCED_FOLDER_LIGHT_UPLOAD_ON_CHARGING = "SYNCED_FOLDER_LIGHT_UPLOAD_ON_CHARGING";
+    public static final String SYNCED_FOLDER_LIGHT_USE_SUBFOLDERS = "SYNCED_FOLDER_LIGHT_USE_SUBFOLDERS";
+    public static final String SYNCED_FOLDER_LIGHT_UPLOAD_BEHAVIOUR = "SYNCED_FOLDER_LIGHT_UPLOAD_BEHAVIOUR";
+
     private RecyclerView mRecyclerView;
     private FolderSyncAdapter mAdapter;
     private LinearLayout mProgress;
@@ -84,13 +95,29 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     private SyncedFolderProvider mSyncedFolderProvider;
     private List<SyncedFolderDisplayItem> syncFolderItems;
     private SyncedFolderPreferencesDialogFragment mSyncedFolderPreferencesDialogFragment;
+    private ArbitraryDataProvider arbitraryDataProvider;
+    private TextView mRemoteFolderSummary;
+    private CheckBox mUploadOnWifiCheckbox;
+    private CheckBox mUploadOnChargingCheckbox;
+    private CheckBox mUploadUseSubfoldersCheckbox;
+    private TextView mUploadBehaviorSummary;
+    private CharSequence[] mUploadBehaviorItemStrings;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
+
+
         setContentView(R.layout.folder_sync_layout);
 
+        if (getResources().getBoolean(R.bool.syncedFolder_light)) {
+            setupLightOption();
+        } else {
+            findViewById(R.id.folder_sync_light_linear_layout).setVisibility(View.GONE);
+        }
+
         // setup toolbar
         setupToolbar();
 
@@ -101,6 +128,154 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
         setupContent();
     }
 
+    private void setupLightOption() {
+        // Remote folder
+        mRemoteFolderSummary = (TextView) findViewById(R.id.remote_folder_summary);
+
+        String remoteFolder = arbitraryDataProvider.getValue(getAccount(), SYNCED_FOLDER_LIGHT_REMOTE_FOLDER);
+
+        if (remoteFolder.isEmpty()) {
+            remoteFolder = getString(R.string.instant_upload_path) + "/";
+            saveRemoteFolder(remoteFolder);
+        } else {
+            mRemoteFolderSummary.setText(remoteFolder);
+        }
+
+        findViewById(R.id.remote_folder_container).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Intent action = new Intent(getBaseContext(), FolderPickerActivity.class);
+                action.putExtra(
+                        FolderPickerActivity.EXTRA_ACTION, getResources().getText(R.string.choose_remote_folder));
+                startActivityForResult(action, REQUEST_CODE__SELECT_REMOTE_FOLDER);
+            }
+        });
+
+        // Upload on WiFi
+        mUploadOnWifiCheckbox = (CheckBox) findViewById(R.id.setting_instant_upload_on_wifi_checkbox);
+        mUploadOnWifiCheckbox.setChecked(
+                arbitraryDataProvider.getBooleanValue(getAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI));
+
+        findViewById(R.id.setting_instant_upload_on_wifi_container).setOnClickListener(
+                new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        mUploadOnWifiCheckbox.toggle();
+                        arbitraryDataProvider.storeOrUpdateKeyValue(getAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI,
+                                String.valueOf(mUploadOnWifiCheckbox.isChecked()));
+                    }
+                });
+
+        // Upload on charging
+        mUploadOnChargingCheckbox = (CheckBox) findViewById(R.id.setting_instant_upload_on_charging_checkbox);
+        mUploadOnChargingCheckbox.setChecked(
+                arbitraryDataProvider.getBooleanValue(getAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_CHARGING));
+
+        findViewById(R.id.setting_instant_upload_on_charging_container).setOnClickListener(
+                new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        mUploadOnChargingCheckbox.toggle();
+                        arbitraryDataProvider.storeOrUpdateKeyValue(getAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_CHARGING,
+                                String.valueOf(mUploadOnChargingCheckbox.isChecked()));
+                    }
+                });
+
+        // use subfolders
+        mUploadUseSubfoldersCheckbox = (CheckBox) findViewById(R.id.setting_instant_upload_path_use_subfolders_checkbox);
+        mUploadUseSubfoldersCheckbox.setChecked(
+                arbitraryDataProvider.getBooleanValue(getAccount(), SYNCED_FOLDER_LIGHT_USE_SUBFOLDERS));
+
+        findViewById(R.id.setting_instant_upload_path_use_subfolders_container).setOnClickListener(
+                new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        mUploadUseSubfoldersCheckbox.toggle();
+                        arbitraryDataProvider.storeOrUpdateKeyValue(getAccount(), SYNCED_FOLDER_LIGHT_USE_SUBFOLDERS,
+                                String.valueOf(mUploadUseSubfoldersCheckbox.isChecked()));
+                    }
+                });
+
+        // upload behaviour
+        mUploadBehaviorItemStrings = getResources().getTextArray(R.array.pref_behaviour_entries);
+        mUploadBehaviorSummary = (TextView) findViewById(R.id.setting_instant_behaviour_summary);
+
+        Integer uploadBehaviour = arbitraryDataProvider.getIntegerValue(getAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_BEHAVIOUR);
+
+        if (uploadBehaviour == -1) {
+            uploadBehaviour = FileUploader.LOCAL_BEHAVIOUR_FORGET;
+            arbitraryDataProvider.storeOrUpdateKeyValue(getAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_BEHAVIOUR,
+                    uploadBehaviour.toString());
+        }
+        mUploadBehaviorSummary.setText(mUploadBehaviorItemStrings[uploadBehaviour]);
+
+        findViewById(R.id.setting_instant_behaviour_container).setOnClickListener(
+                new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        Integer behaviourId = arbitraryDataProvider.getIntegerValue(getAccount(),
+                                SYNCED_FOLDER_LIGHT_UPLOAD_BEHAVIOUR);
+
+                        Integer behaviour;
+                        switch (behaviourId) {
+                            case FileUploader.LOCAL_BEHAVIOUR_FORGET:
+                                behaviour = 0;
+                                break;
+                            case FileUploader.LOCAL_BEHAVIOUR_MOVE:
+                                behaviour = 1;
+                                break;
+                            case FileUploader.LOCAL_BEHAVIOUR_DELETE:
+                                behaviour = 2;
+                                break;
+                            default:
+                                behaviour = 0;
+                                break;
+                        }
+
+                        AlertDialog.Builder builder = new AlertDialog.Builder(FolderSyncActivity.this);
+                        builder
+                                .setTitle(R.string.prefs_instant_behaviour_dialogTitle)
+                                .setSingleChoiceItems(getResources().getTextArray(R.array.pref_behaviour_entries),
+                                        behaviour,
+                                        new
+                                                DialogInterface.OnClickListener() {
+                                                    public void onClick(DialogInterface dialog, int which) {
+                                                        saveUploadAction(getResources().getTextArray(
+                                                                R.array.pref_behaviour_entryValues)[which].toString());
+                                                        mUploadBehaviorSummary.setText(mUploadBehaviorItemStrings[which]);
+                                                        dialog.dismiss();
+                                                    }
+                                                });
+                        builder.create().show();
+                    }
+                });
+    }
+
+    private void saveRemoteFolder(String newPath) {
+        arbitraryDataProvider.storeOrUpdateKeyValue(getAccount(), SYNCED_FOLDER_LIGHT_REMOTE_FOLDER, newPath);
+        mRemoteFolderSummary.setText(newPath);
+    }
+
+    private void saveUploadAction(String action) {
+        Integer actionId;
+        switch (action) {
+            case "LOCAL_BEHAVIOUR_FORGET":
+                actionId = FileUploader.LOCAL_BEHAVIOUR_FORGET;
+                break;
+            case "LOCAL_BEHAVIOUR_MOVE":
+                actionId = FileUploader.LOCAL_BEHAVIOUR_MOVE;
+                break;
+            case "LOCAL_BEHAVIOUR_DELETE":
+                actionId = FileUploader.LOCAL_BEHAVIOUR_DELETE;
+                break;
+            default:
+                actionId = FileUploader.LOCAL_BEHAVIOUR_FORGET;
+        }
+
+        arbitraryDataProvider.storeOrUpdateKeyValue(getAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_BEHAVIOUR,
+                actionId.toString());
+    }
+
     @Override
     protected void onResume() {
         super.onResume();
@@ -117,7 +292,8 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
         mEmpty = (TextView) findViewById(android.R.id.empty);
 
         final int gridWidth = getResources().getInteger(R.integer.media_grid_width);
-        mAdapter = new FolderSyncAdapter(this, gridWidth, this);
+        boolean lightVersion = getResources().getBoolean(R.bool.syncedFolder_light);
+        mAdapter = new FolderSyncAdapter(this, gridWidth, this, lightVersion);
         mSyncedFolderProvider = new SyncedFolderProvider(getContentResolver());
 
         final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
@@ -327,6 +503,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
         }
         return result;
     }
+
     /**
      * show/hide recycler view list or the empty message / progress info.
      *
@@ -401,10 +578,14 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_REMOTE_FOLDER
-                && resultCode == RESULT_OK && mSyncedFolderPreferencesDialogFragment != null) {
+                && resultCode == RESULT_OK) {
             OCFile chosenFolder = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
-            mSyncedFolderPreferencesDialogFragment.setRemoteFolderSummary(chosenFolder.getRemotePath());
 
+            if (mSyncedFolderPreferencesDialogFragment != null) {
+                mSyncedFolderPreferencesDialogFragment.setRemoteFolderSummary(chosenFolder.getRemotePath());
+            } else {
+                saveRemoteFolder(chosenFolder.getRemotePath());
+            }
         } else {
             super.onActivityResult(requestCode, resultCode, data);
         }
@@ -431,7 +612,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
         }
         mSyncedFolderPreferencesDialogFragment = null;
 
-        if(dirty) {
+        if (dirty) {
             mAdapter.setSyncFolderItem(syncedFolder.getSection(), item);
         }
     }

+ 18 - 0
src/main/java/com/owncloud/android/ui/activity/Preferences.java

@@ -161,6 +161,24 @@ public class Preferences extends PreferenceActivity
         // Register context menu for list of preferences.
         registerForContextMenu(getListView());
 
+        PreferenceCategory preferenceCategoryGeneral = (PreferenceCategory) findPreference("general");
+        Preference pSyncedFolder = findPreference("folder_sync");
+        if (pSyncedFolder != null) {
+            if (getResources().getBoolean(R.bool.syncedFolder_light)
+                    && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+                pSyncedFolder.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+                    @Override
+                    public boolean onPreferenceClick(Preference preference) {
+                        Intent folderSyncIntent = new Intent(getApplicationContext(), FolderSyncActivity.class);
+                        startActivity(folderSyncIntent);
+                        return true;
+                    }
+                });
+            } else {
+                preferenceCategoryGeneral.removePreference(pSyncedFolder);
+            }
+        }
+
         PreferenceCategory preferenceCategoryDetails = (PreferenceCategory) findPreference("details");
 
 

+ 15 - 9
src/main/java/com/owncloud/android/ui/adapter/FolderSyncAdapter.java

@@ -51,13 +51,15 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
     private final int mGridTotal;
     private final ClickListener mListener;
     private final List<SyncedFolderDisplayItem> mSyncFolderItems;
+    private final boolean mLight;
 
-    public FolderSyncAdapter(Context context, int gridWidth, ClickListener listener) {
+    public FolderSyncAdapter(Context context, int gridWidth, ClickListener listener, boolean light) {
         mContext = context;
         mGridWidth = gridWidth;
         mGridTotal = gridWidth * 2;
         mListener = listener;
         mSyncFolderItems = new ArrayList<>();
+        mLight = light;
     }
 
     public void setSyncFolderItems(List<SyncedFolderDisplayItem> syncFolderItems) {
@@ -100,14 +102,18 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
         });
         setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
 
-        holder.menuButton.setVisibility(View.VISIBLE);
-        holder.menuButton.setTag(section);
-        holder.menuButton.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                mListener.onSyncFolderSettingsClick(section, mSyncFolderItems.get(section));
-            }
-        });
+        if (mLight) {
+            holder.menuButton.setVisibility(View.GONE);
+        } else {
+            holder.menuButton.setVisibility(View.VISIBLE);
+            holder.menuButton.setTag(section);
+            holder.menuButton.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    mListener.onSyncFolderSettingsClick(section, mSyncFolderItems.get(section));
+                }
+            });
+        }
     }
 
     @Override

+ 4 - 2
src/main/res/layout/folder_sync_item_header.xml

@@ -51,7 +51,9 @@
             android:layout_height="wrap_content"
             android:background="@color/transparent"
             android:clickable="true"
-            android:padding="@dimen/standard_half_padding"
+            android:paddingTop="@dimen/standard_half_padding"
+            android:paddingBottom="@dimen/standard_half_padding"
+            android:paddingRight="@dimen/standard_padding"
             android:src="@drawable/ic_cloud_sync_off"/>
 
         <ImageButton
@@ -61,7 +63,7 @@
             android:background="@color/transparent"
             android:clickable="true"
             android:paddingBottom="@dimen/standard_half_padding"
-            android:paddingLeft="@dimen/standard_half_padding"
+            android:paddingLeft="0dp"
             android:paddingRight="@dimen/standard_padding"
             android:paddingTop="@dimen/standard_half_padding"
             android:src="@drawable/ic_dots_vertical"/>

+ 6 - 3
src/main/res/layout/folder_sync_layout.xml

@@ -35,11 +35,14 @@
         <include
             layout="@layout/toolbar_standard"/>
 
-        <FrameLayout
+        <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_above="@+id/bottom_navigation_view"
-            android:layout_below="@+id/appbar">
+            android:layout_below="@+id/appbar"
+            android:orientation="vertical">
+
+            <include layout="@layout/folder_sync_light_layout"/>
 
             <android.support.v7.widget.RecyclerView
                 android:id="@android:id/list"
@@ -86,7 +89,7 @@
                 android:gravity="center"
                 android:text="@string/folder_sync_no_results"
                 android:visibility="gone" />
-        </FrameLayout>
+        </LinearLayout>
 
         <android.support.design.widget.BottomNavigationView
             android:id="@+id/bottom_navigation_view"

+ 201 - 0
src/main/res/layout/folder_sync_light_layout.xml

@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Nextcloud Android client application
+
+  Copyright (C) 2017 Tobias Kaminsky
+  Copyright (C) 2017 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
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/folder_sync_light_linear_layout"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:padding="@dimen/standard_padding"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:id="@+id/remote_folder_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:baselineAligned="false"
+        android:gravity="center_vertical"
+        android:minHeight="?android:attr/listPreferredItemHeightSmall"
+        android:orientation="vertical"
+        android:paddingBottom="@dimen/standard_padding"
+        android:paddingTop="@dimen/standard_padding">
+
+        <TextView
+            android:id="@+id/remote_folder_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:maxLines="1"
+            android:text="@string/prefs_folder_sync_remote_path_title"
+            android:textAppearance="?attr/textAppearanceListItem"/>
+
+        <TextView
+            android:id="@+id/remote_folder_summary"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:ellipsize="middle"
+            android:maxLines="2"
+            android:text="@string/placeholder_filename"
+            android:textColor="?android:attr/textColorSecondary"/>
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/setting_instant_upload_on_wifi_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:baselineAligned="false"
+        android:clipToPadding="false"
+        android:gravity="center_vertical"
+        android:minHeight="?attr/listPreferredItemHeightSmall">
+
+        <TextView
+            android:id="@+id/setting_instant_upload_on_wifi_label"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:ellipsize="marquee"
+            android:maxLines="1"
+            android:text="@string/auto_upload_on_wifi"
+            android:textAppearance="?attr/textAppearanceListItem"/>
+
+        <android.support.v7.widget.AppCompatCheckBox
+            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
+        android:id="@+id/setting_instant_upload_on_charging_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:baselineAligned="false"
+        android:clipToPadding="false"
+        android:gravity="center_vertical"
+        android:minHeight="?attr/listPreferredItemHeightSmall">
+
+        <TextView
+            android:id="@+id/setting_instant_upload_on_charging_label"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:ellipsize="marquee"
+            android:maxLines="1"
+            android:text="@string/instant_upload_on_charging"
+            android:textAppearance="?attr/textAppearanceListItem"/>
+
+        <android.support.v7.widget.AppCompatCheckBox
+            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
+        android:id="@+id/setting_instant_upload_path_use_subfolders_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:baselineAligned="false"
+        android:clipToPadding="false"
+        android:gravity="center_vertical"
+        android:minHeight="?attr/listPreferredItemHeightSmall"
+        android:paddingBottom="16dp"
+        android:paddingTop="16dp">
+
+        <!-- Preference should place its actual preference widget here. -->
+
+        <LinearLayout
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/setting_instant_upload_path_use_subfolders_label"
+                android:layout_width="match_parent"
+                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="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_alignLeft="@id/setting_instant_upload_path_use_subfolders_label"
+                android:layout_below="@id/setting_instant_upload_path_use_subfolders_label"
+                android:ellipsize="end"
+                android:maxLines="2"
+                android:text="@string/prefs_instant_upload_path_use_subfolders_summary"
+                android:textColor="?android:attr/textColorSecondary"/>
+
+        </LinearLayout>
+
+        <android.support.v7.widget.AppCompatCheckBox
+            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
+        android:id="@+id/setting_instant_behaviour_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:baselineAligned="false"
+        android:clipToPadding="false"
+        android:gravity="center_vertical"
+        android:minHeight="?attr/listPreferredItemHeightSmall"
+        android:orientation="vertical"
+        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:ellipsize="end"
+            android:maxLines="1"
+            android:text="@string/placeholder_filename"
+            android:textColor="?android:attr/textColorSecondary"/>
+
+    </LinearLayout>
+
+</LinearLayout>

+ 1 - 0
src/main/res/values/setup.xml

@@ -103,6 +103,7 @@
     <string name="mail_feedback">"mailto:android@nextcloud.com"</string>
     <string name="url_app_download">"https://play.google.com/store/apps/details?id=com.nextcloud.client"</string>
     <string name="url_server_install">https://nextcloud.com/install</string>
+    <bool name="syncedFolder_light">false</bool> <!-- if enabled: in setting & global upload settings -->
 
     <!--Destination mail for sending log files -->
     <string name="mail_logger"></string>

+ 11 - 5
src/main/res/xml/preferences.xml

@@ -18,10 +18,16 @@
   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_general">
-		<ListPreference
-			android:title="@string/prefs_storage_path"
-			android:key="storage_path" />
+    <PreferenceCategory
+        android:title="@string/prefs_category_general"
+        android:key="general">
+        <ListPreference
+            android:title="@string/prefs_storage_path"
+            android:key="storage_path"/>
+        <Preference
+            android:title="@string/drawer_folder_sync"
+            android:id="@+id/folder_sync"
+            android:key="folder_sync"/>
 	</PreferenceCategory>
 
     <PreferenceCategory android:title="@string/prefs_category_instant_uploading" android:key="instant_uploading_category">
@@ -75,7 +81,7 @@
 		<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:key="details">

+ 1 - 0
src/modified/res/values/setup.xml

@@ -103,6 +103,7 @@
     <string name="mail_feedback">"mailto:android@nextcloud.com"</string>
     <string name="url_app_download">"https://play.google.com/store/apps/details?id=com.nextcloud.client"</string>
     <string name="url_server_install">https://nextcloud.com/install</string>
+    <bool name="syncedFolder_light">false</bool> <!-- if enabled: in setting & global upload settings -->
 
     <!--Destination mail for sending log files -->
     <string name="mail_logger"></string>