Merge remote-tracking branch 'remotes/upstream/avoidDuplicateFiles' into beta
authortobiasKaminsky <tobias@kaminsky.me>
Thu, 29 Oct 2015 17:49:00 +0000 (18:49 +0100)
committertobiasKaminsky <tobias@kaminsky.me>
Thu, 29 Oct 2015 17:49:00 +0000 (18:49 +0100)
1  2 
CHANGELOG.md
res/layout/upload_files_layout.xml
res/values/strings.xml
res/xml/preferences.xml
src/com/owncloud/android/datamodel/FileDataStorageManager.java
src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/ui/activity/UploadFilesActivity.java

diff --combined CHANGELOG.md
@@@ -1,15 -1,42 +1,16 @@@
 -## 1.7.2 (July 2015)
 -- New navigation drawer
 -- Improved Passcode
 -- Automatic grid view just for folders full of images
 -- More characters allowed in file names
 -- Support for servers in same domain, different path
 -- Bugs fixed:
 -  + Frequent crashes in folder with several images
 -  + Sync error in servers with huge quota and external storage enable
 -  + Share by link error 
 -  + Some other crashes and minor bugs
 -
 -## 1.7.1 (April 2015)
 -
 -- Share link even with password enforced by server
 -- Get the app ready for oc 8.1 servers
 -- Added option to create new folder in uploads from external apps
 -- Improved management of deleted users
 -- Bugs fixed
 -  + Fixed crash on Android 2.x devices
 -  + Improvements on uploads
 -
 -## 1.7.0 (February 2015)
 -
 -- Download full folders
 -- Grid view for images
 -- Remote thumbnails (OC Server 8.0+)
 -- Added number of files and folders at the end of the list
 -- "Open with" in contextual menu
 -- Downloads added to Media Provider
 -- Uploads:
 -  + Local thumbnails in section "Files"
 -  + Multiple selection in "Content from other apps" (Android 4.3+)
 -- Gallery: 
 -  + proper handling of EXIF
 -  + obey sorting in the list of files
 -- Settings view updated
 -- Improved subjects in e-mails
 -- Bugs fixed
 -
 +# 2015-10-29
 +- PR [#1099](https://github.com/owncloud/android/pull/1099) "Switch list vs grid" merged
 +- PR [#1100](https://github.com/owncloud/android/pull/1100) "Material FAB with speed dial implementation" merged
 +- PR [#1209](https://github.com/owncloud/android/pull/1209) "Material buttons - before in #1090" merged
 +- PR [#1205](https://github.com/owncloud/android/pull/1205) "Switch between online and offline files" merged
 +- PR [#1195](https://github.com/owncloud/android/pull/1195) "Resize Cache" merged
 +- PR [#1187](https://github.com/owncloud/android/pull/1187) "Video: Big thumbnails" merged
 +- PR [#1058](https://github.com/owncloud/android/pull/1058) "add sort to UploadFileActiviy" merged
++- PR [#1168](https://github.com/owncloud/android/pull/1168) "Avoid duplicate files" merged
  
  
 +# 2015-10-26
 +- start of branch
 +- PR [#745](https://github.com/owncloud/android/pull/745) merged
 +- PR [#1044](https://github.com/owncloud/android/pull/1044) merged: < 8.1: GalleryPlus app needed, >= 8.2 Gallery app needed
 +- PR [#1111](https://github.com/owncloud/android/pull/1111) merged
      <LinearLayout\r
          android:layout_width="match_parent"\r
          android:layout_height="wrap_content"\r
+         android:orientation="horizontal">\r
\r
+         <ImageView\r
+             android:layout_width="match_parent"\r
+             android:layout_height="1dp"\r
+             android:src="@drawable/uploader_list_separator"/>\r
\r
+     </LinearLayout>\r
\r
+     <LinearLayout\r
+         android:orientation="horizontal"\r
+         android:layout_width="match_parent"\r
+         android:layout_height="wrap_content"\r
+         android:paddingTop="8dp"\r
+         android:paddingLeft="16dp"\r
+         android:paddingRight="16dp">\r
\r
+         <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"\r
+             android:id="@+id/drawer_radio_group"\r
+             android:layout_width="fill_parent"\r
+             android:layout_height="wrap_content"\r
+             android:gravity="center"\r
+             android:orientation="horizontal">\r
\r
+             <RadioButton\r
+                 android:layout_width="wrap_content"\r
+                 android:layout_height="wrap_content"\r
+                 android:text="@string/upload_copy_files"\r
+                 android:id="@+id/upload_radio_copy"\r
+                 android:paddingRight="8dp"\r
+                 android:checked="false" />\r
\r
+             <RadioButton\r
+                 android:layout_width="wrap_content"\r
+                 android:layout_height="wrap_content"\r
+                 android:text="@string/upload_move_files"\r
+                 android:id="@+id/upload_radio_move"\r
+                 android:paddingRight="8dp"\r
+                 android:checked="false" />\r
+         </RadioGroup>\r
+     </LinearLayout>\r
\r
+     <LinearLayout\r
+         android:layout_width="match_parent"\r
+         android:layout_height="wrap_content"\r
          android:gravity="center"\r
-         android:orientation="horizontal" >\r
+         android:orientation="horizontal"\r
+         android:paddingLeft="16dp"\r
+         android:paddingRight="16dp"\r
+         android:paddingBottom="16dp">\r
  \r
          <android.support.v7.widget.AppCompatButton\r
              android:id="@+id/upload_files_btn_cancel"\r
 -            style="@style/ownCloud.Button"\r
 +            android:theme="@style/Button"\r
              android:layout_width="wrap_content"\r
              android:layout_height="wrap_content"\r
              android:layout_weight="1"\r
@@@ -46,7 -94,7 +94,7 @@@
  \r
          <android.support.v7.widget.AppCompatButton\r
                    android:id="@+id/upload_files_btn_upload"\r
 -            style="@style/ownCloud.Button"\r
 +            android:theme="@style/Button.Primary"\r
                    android:layout_width="wrap_content"\r
                    android:layout_height="wrap_content"\r
                    android:layout_weight="1"\r
diff --combined res/values/strings.xml
@@@ -23,7 -23,8 +23,7 @@@
      <!-- TODO re-enable when "Accounts" is available in Navigation Drawer -->
      <!--<string name="drawer_item_accounts">Accounts</string>-->
      <string name="drawer_item_all_files">All files</string>
 -    <!-- TODO re-enable when "On Device" is available
 -    <string name="drawer_item_on_device">On device</string>-->
 +    <string name="drawer_item_on_device">On device</string>
      <string name="drawer_item_settings">Settings</string>
      <string name="drawer_item_logs">Logs</string>
        <string name="drawer_close">Close</string>
@@@ -73,7 -74,6 +73,7 @@@
      <string name="file_list_seconds_ago">seconds ago</string>
      <string name="file_list_empty">Nothing in here. Upload something!</string>
      <string name="file_list_loading">Loading&#8230;</string>
 +    <string name="file_list_no_app_for_file_type">No App found for file type!</string>
      <string name="local_file_list_empty">There are no files in this folder.</string>
      <string name="filedetails_select_file">Tap on a file to display additional information.</string>
      <string name="filedetails_size">Size:</string>
      <string name="placeholder_filesize">389 KB</string>
      <string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
      <string name="placeholder_media_time">12:23:45</string>
 -
 -    <string name="instant_upload_on_wifi">Upload pictures via WiFi only</string>
 -    <string name="instant_video_upload_on_wifi">Upload videos via WiFi only</string>
 +    
 +    <string name="instant_upload_on_wifi">Upload pictures via wifi only</string>
 +    <string name="instant_upload_on_charging">Upload when charging only</string>
 +    <string name="instant_video_upload_on_wifi">Upload videos via wifi only</string>
 +    <string name="instant_video_upload_on_charging">Upload when charging only</string>
      <string name="instant_upload_path">/InstantUpload</string>
      <string name="conflict_title">File conflict</string>
      <string name="conflict_message">Which files do you want to keep? If you select both versions, the local file will have a number added to its name.</string>
      <string name="preview_image_error_unknown_format">This image cannot be shown</string>
  
      <string name="error__upload__local_file_not_copied">%1$s could not be copied to %2$s local folder</string>
 -    <string name="prefs_instant_upload_path_title">Upload Path</string>
 +    <string name="prefs_instant_upload_path_title">Upload path</string>
  
        <string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your
                administrator.</string>
      <string name="prefs_category_instant_uploading">Instant Uploads</string>
        <string name="prefs_category_security">Security</string>
  
 -      <string name="prefs_instant_video_upload_path_title">Upload Video Path</string>
 +      <string name="prefs_instant_video_upload_path_title">Upload video path</string>
      <string name="download_folder_failed_content">Download of %1$s folder could not be completed</string>
  
        <string name="shared_subject_header">shared</string>
      <string name="file_list__footer__files">%1$d files</string>
      <string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
      <string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
 +    <string name="action_switch_grid_view">Switch to grid view</string>
 +    <string name="action_switch_list_view">Switch to list view</string>
 +    <string name="common_category">Common</string>
 +    <string name="pref_cache_size">Cache size</string>
+     <string name="prefs_instant_behaviour_dialogTitle">Upload file to server and ...</string>
+     <string name="prefs_instant_behaviour_title">Behaviour</string>
+     <string name="upload_copy_files">Copy file</string>
+     <string name="upload_move_files">Move file</string>
+     <string name="pref_behaviour_entries_do_nothing">do nothing</string>
+     <string name="pref_behaviour_entries_copy">copy file to OC folder</string>
+     <string name="pref_behaviour_entries_move">move file to OC folder</string>
+     <string name="pref_behaviour_entries_delete">delete origin file</string>
  
  </resources>
diff --combined res/xml/preferences.xml
@@@ -3,7 -3,7 +3,7 @@@
    ownCloud Android client application
  
    Copyright (C) 2012  Bartek Przybylski
 -  Copyright (C) 2015 ownCloud Inc.
 +  Copyright (C) 2012-2013 ownCloud Inc.
  
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License version 2,
    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_accounts" android:key="accounts_category">
 +    <PreferenceCategory
 +              android:title="@string/prefs_category_accounts"
 +              android:key="accounts_category">
      </PreferenceCategory>
      
        <PreferenceCategory android:title="@string/prefs_category_security">
 -          <android.preference.CheckBoxPreference android:title="@string/prefs_passcode" android:key="set_pincode" />
 +              <!-- ListPreference
 +            android:key="select_oc_account"
 +            android:title="@string/prefs_select_oc_account"
 +            android:summary="@string/prefs_summary_select_oc_account"
 +            / -->
 +              <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:title="@string/prefs_pincode" android:key="set_pincode"
 +                      android:summary="@string/prefs_pincode_summary"/>
        </PreferenceCategory>
  
-     <PreferenceCategory android:title="@string/prefs_category_instant_uploading"
-               android:key="instant_uploading_category">
+     <PreferenceCategory android:title="@string/prefs_category_instant_uploading" android:key="instant_uploading_category">
+          <com.owncloud.android.ui.dialog.OwnCloudListPreference android:key="prefs_instant_behaviour"
+                        android:dialogTitle="@string/prefs_instant_behaviour_dialogTitle"
+                        android:title="@string/prefs_instant_behaviour_title"
+                        android:entries="@array/pref_behaviour_entries"
+                        android:entryValues="@array/pref_behaviour_entryValues"
+                        android:defaultValue="NOTHING"
+                        android:summary="%s"
+                        />
  
+               <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_uploading"
+                               android:title="@string/prefs_instant_upload"
+                               android:summary="@string/prefs_instant_upload_summary"/>
+          <com.owncloud.android.ui.PreferenceWithLongSummary
+                                                       android:title="@string/prefs_instant_upload_path_title"
+                                                       android:key="instant_upload_path" />
            <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
 -                                              android:title="@string/instant_upload_on_wifi"
 -                                              android:key="instant_upload_on_wifi"/>
 -          <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_video_uploading"
 -                              android:title="@string/prefs_instant_video_upload"
 -                              android:summary="@string/prefs_instant_video_upload_summary" />
 +                      android:key="instant_uploading"
 +              android:title="@string/prefs_instant_upload"
 +              android:summary="@string/prefs_instant_upload_summary"/>
 +              <com.owncloud.android.ui.PreferenceWithLongSummary
 +                      android:dependency="instant_uploading"
 +                      android:disableDependentsState="true"
 +                      android:title="@string/prefs_instant_upload_path_title"
 +                      android:key="instant_upload_path" />
 +          <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
 +                      android:dependency="instant_uploading"
 +                      android:disableDependentsState="true"
 +              android:title="@string/instant_upload_on_wifi"
 +              android:key="instant_upload_on_wifi"/>
 +              <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
 +                      android:dependency="instant_uploading"
 +                      android:disableDependentsState="true"
 +                      android:title="@string/instant_upload_on_charging"
 +                      android:key="instant_upload_on_charging"/>
 +
 +              <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
 +                      android:key="instant_video_uploading"
 +              android:title="@string/prefs_instant_video_upload"
 +              android:summary="@string/prefs_instant_video_upload_summary" />
            <com.owncloud.android.ui.PreferenceWithLongSummary
 -                                                      android:title="@string/prefs_instant_video_upload_path_title"
 -                                                      android:key="instant_video_upload_path" />
 +                      android:dependency="instant_video_uploading"
 +                      android:disableDependentsState="true"
 +                      android:title="@string/prefs_instant_video_upload_path_title"
 +                      android:key="instant_video_upload_path" />
            <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
 -                                              android:title="@string/instant_video_upload_on_wifi"
 -                                              android:key="instant_video_upload_on_wifi"/>
 -          <!-- DISABLED FOR RELEASE UNTIL FIXED
 +                      android:dependency="instant_video_uploading"
 +                      android:disableDependentsState="true"
 +              android:title="@string/instant_video_upload_on_wifi"
 +              android:key="instant_video_upload_on_wifi"/>
 +              <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
 +                      android:dependency="instant_video_uploading"
 +                      android:disableDependentsState="true"
 +                      android:title="@string/instant_video_upload_on_charging"
 +                      android:key="instant_video_upload_on_charging"/>
 +      </PreferenceCategory>
 +      
 +      <PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
 +              <!-- DISABLED FOR RELEASE UNTIL FIXED
            CheckBoxPreference android:key="log_to_file"
                                android:title="@string/prefs_log_title"
                                android:summary="@string/prefs_log_summary"/>
                                android:summary="@string/prefs_log_summary_history"/ -->
                          
      </PreferenceCategory>
 -      
 +
 +      <PreferenceCategory android:title="@string/common_category" android:key="common_category">
 +              <EditTextPreference android:title="@string/pref_cache_size"
 +                                                      android:key="pref_cache_size"
 +                                                      android:digits="0123456789"/>
 +      </PreferenceCategory>
 +
        <PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
      <Preference android:title="@string/prefs_help" android:key="help" />
      <Preference android:title="@string/prefs_recommend" android:key="recommend" />
                                        android:title="@string/about_title" 
                                        android:key="about_app" />
        </PreferenceCategory>
 -    
 +
  
  </PreferenceScreen>
@@@ -148,9 -148,10 +148,9 @@@ public class FileDataStorageManager 
      }
  
  
 -    public Vector<OCFile> getFolderContent(OCFile f/*, boolean onlyOnDevice*/) {
 +    public Vector<OCFile> getFolderContent(OCFile f, boolean onlyOnDevice) {
          if (f != null && f.isFolder() && f.getFileId() != -1) {
 -            // TODO Enable when "On Device" is recovered ?
 -            return getFolderContent(f.getFileId()/*, onlyOnDevice*/);
 +            return getFolderContent(f.getFileId(), onlyOnDevice);
  
          } else {
              return new Vector<OCFile>();
      }
  
  
 -    public Vector<OCFile> getFolderImages(OCFile folder/*, boolean onlyOnDevice*/) {
 +    public Vector<OCFile> getFolderImages(OCFile folder, boolean onlyOnDevice) {
          Vector<OCFile> ret = new Vector<OCFile>(); 
          if (folder != null) {
              // TODO better implementation, filtering in the access to database instead of here
 -            // TODO Enable when "On Device" is recovered ?
 -            Vector<OCFile> tmp = getFolderContent(folder/*, onlyOnDevice*/);
 +            Vector<OCFile> tmp = getFolderContent(folder, onlyOnDevice);
              OCFile current = null; 
              for (int i=0; i<tmp.size(); i++) {
                  current = tmp.get(i);
          File localFolder = new File(localFolderPath);
          if (localFolder.exists()) {
              // stage 1: remove the local files already registered in the files database
 -            // TODO Enable when "On Device" is recovered ?
 -            Vector<OCFile> files = getFolderContent(folder.getFileId()/*, false*/);
 +            Vector<OCFile> files = getFolderContent(folder.getFileId(), false);
              if (files != null) {
                  for (OCFile file : files) {
                      if (file.isFolder()) {
      }
  
      
 -    private Vector<OCFile> getFolderContent(long parentId/*, boolean onlyOnDevice*/) {
 +    private Vector<OCFile> getFolderContent(long parentId, boolean onlyOnDevice) {
  
          Vector<OCFile> ret = new Vector<OCFile>();
  
          if (c.moveToFirst()) {
              do {
                  OCFile child = createFileInstance(c);
 -                // TODO Enable when "On Device" is recovered ?
 -                // if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
 +                 if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
                      ret.add(child);
 -                // }
 +                 }
              } while (c.moveToNext());
          }
  
                      + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
              String [] whereArgs = new String[]{ "", mAccount.name };
  
 -            // TODO Enable when "On Device" is recovered ?
 -            Vector<OCFile> files = getFolderContent(folder /*, false*/);
 +            Vector<OCFile> files = getFolderContent(folder, false);
              
              for (OCFile file : files) {
                  whereArgs[0] = file.getRemotePath();
          //}
      }
  
-     public void triggerMediaScan(String path) {
+     public static void triggerMediaScan(String path) {
          Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
          intent.setData(Uri.fromFile(new File(path)));
          MainApp.getAppContext().sendBroadcast(intent);
@@@ -29,15 -29,15 +29,16 @@@ import com.owncloud.android.files.servi
  import com.owncloud.android.lib.common.utils.Log_OC;
  import com.owncloud.android.utils.FileStorageUtils;
  
 -
  import android.accounts.Account;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
 +import android.content.IntentFilter;
+ import android.content.SharedPreferences;
  import android.database.Cursor;
  import android.net.ConnectivityManager;
  import android.net.NetworkInfo.State;
 +import android.os.BatteryManager;
  import android.preference.PreferenceManager;
  import android.provider.MediaStore.Images;
  import android.provider.MediaStore.Video;
@@@ -59,7 -59,7 +60,7 @@@ public class InstantUploadBroadcastRece
      @Override
      public void onReceive(Context context, Intent intent) {
          Log_OC.d(TAG, "Received: " + intent.getAction());
 -        if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
 +        if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION) || intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
              handleConnectivityAction(context, intent);
          }else if (intent.getAction().equals(NEW_PHOTO_ACTION_UNOFFICIAL)) {
              handleNewPictureAction(context, intent); 
          file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
          mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE));
          c.close();
 -        
          Log_OC.d(TAG, file_path + "");
  
          // save always temporally the picture to upload
          db.putFileForLater(file_path, account.name, null);
          db.close();
  
 -        if (!isOnline(context) || (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
 +        if (!isOnline(context) 
 +                || (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))
 +                || (instantUploadWhenChargingOnly(context) && !isCharging(context))
 +           ) {
              return;
          }
  
          i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
          i.putExtra(FileUploader.KEY_MIME_TYPE, mime_type);
          i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true);
+         // instant upload behaviour
+         SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+         String behaviour = appPreferences.getString("prefs_instant_behaviour", "NOTHING");
+         if (behaviour.equalsIgnoreCase("NOTHING")) {
+             Log_OC.d(TAG, "upload file and do nothing");
+             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_FORGET);
+         } else if (behaviour.equalsIgnoreCase("COPY")) {
+             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_COPY);
+             Log_OC.d(TAG, "upload file and copy file to oc folder");
+         } else if (behaviour.equalsIgnoreCase("MOVE")) {
+             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
+             Log_OC.d(TAG, "upload file and move file to oc folder");
+         } else if (behaviour.equalsIgnoreCase("DELETE")){
+             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_REMOVE);
+             Log_OC.d(TAG, "upload file and delete file in original place");
+         }
          context.startService(i);
      }
  
          mime_type = c.getString(c.getColumnIndex(Video.Media.MIME_TYPE));
          c.close();
          Log_OC.d(TAG, file_path + "");
 +        
 +        // save always temporally the picture to upload
 +        DbHandler db = new DbHandler(context);
 +        db.putFileForLater(file_path, account.name, null);
 +        db.close();
  
 -        if (!isOnline(context) || (instantVideoUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
 +        if (!isOnline(context) 
 +                || (instantVideoUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))
 +                || (instantVideoUploadWhenChargingOnly(context) && !isCharging(context))
 +           ) {
              return;
          }
  
          i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
          i.putExtra(FileUploader.KEY_MIME_TYPE, mime_type);
          i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true);
+         // instant upload behaviour
+         SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+         String behaviour = appPreferences.getString("prefs_instant_behaviour", "NOTHING");
+         if (behaviour.equalsIgnoreCase("NOTHING")) {
+             Log_OC.d(TAG, "upload file and do nothing");
+             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_FORGET);
+         } else if (behaviour.equalsIgnoreCase("COPY")) {
+             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_COPY);
+             Log_OC.d(TAG, "upload file and copy file to oc folder");
+         } else if (behaviour.equalsIgnoreCase("MOVE")) {
+             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
+             Log_OC.d(TAG, "upload file and move file to oc folder");
+         } else if (behaviour.equalsIgnoreCase("DELETE")){
+             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_REMOVE);
+             Log_OC.d(TAG, "upload file and delete file in original place");
+         }
          context.startService(i);
  
      }
  
      private void handleConnectivityAction(Context context, Intent intent) {
 -        if (!instantPictureUploadEnabled(context)) {
 +        if (!instantPictureUploadEnabled(context) && !instantVideoUploadEnabled(context)) {
              Log_OC.d(TAG, "Instant upload disabled, don't upload anything");
              return;
          }
  
          if (!intent.hasExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY)
                  && isOnline(context)
 -                && (!instantPictureUploadViaWiFiOnly(context) || (instantPictureUploadViaWiFiOnly(context) == isConnectedViaWiFi(context) == true))) {
 +                && (!instantUploadWhenChargingOnly(context) || (instantUploadWhenChargingOnly(context) && isCharging(context)))
 +                && (!instantVideoUploadWhenChargingOnly(context) || (instantVideoUploadWhenChargingOnly(context) && isCharging(context)))
 +                && (!instantPictureUploadViaWiFiOnly(context) || (instantPictureUploadViaWiFiOnly(context) && isConnectedViaWiFi(context)))
 +                && (!instantVideoUploadViaWiFiOnly(context) || (instantVideoUploadViaWiFiOnly(context) && isConnectedViaWiFi(context)))
 +            ) {
              DbHandler db = new DbHandler(context);
              Cursor c = db.getAwaitingFiles();
              if (c.moveToFirst()) {
                          i.putExtra(FileUploader.KEY_REMOTE_FILE, FileStorageUtils.getInstantUploadFilePath(context, f.getName()));
                          i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
                          i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true);
+                         // instant upload behaviour
+                         SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+                         String behaviour = appPreferences.getString("prefs_instant_behaviour", "NOTHING");
+                         if (behaviour.equalsIgnoreCase("NOTHING")) {
+                             Log_OC.d(TAG, "upload file and do nothing");
+                             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_FORGET);
+                         } else if (behaviour.equalsIgnoreCase("COPY")) {
+                             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_COPY);
+                             Log_OC.d(TAG, "upload file and copy file to oc folder");
+                         } else if (behaviour.equalsIgnoreCase("MOVE")) {
+                             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
+                             Log_OC.d(TAG, "upload file and move file to oc folder");
+                         } else if (behaviour.equalsIgnoreCase("DELETE")){
+                             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_REMOVE);
+                             Log_OC.d(TAG, "upload file and delete file in original place");
+                         }
                          context.startService(i);
  
                      } else {
              c.close();
              db.close();
          }
 -
      }
  
      public static boolean isOnline(Context context) {
                  && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI
                  && cm.getActiveNetworkInfo().getState() == State.CONNECTED;
      }
 +    
 +    public static boolean isCharging(Context context){
 +        IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
 +        Intent batteryStatus = context.registerReceiver(null, ifilter);
 +
 +        int status = 0;
 +        if (batteryStatus != null) {
 +            status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
 +        }
 +        return status == BatteryManager.BATTERY_STATUS_CHARGING ||
 +                status == BatteryManager.BATTERY_STATUS_FULL;
 +    }
  
      public static boolean instantPictureUploadEnabled(Context context) {
          return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_uploading", false);
      public static boolean instantVideoUploadViaWiFiOnly(Context context) {
          return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_video_upload_on_wifi", false);
      }
 +    public static boolean instantUploadWhenChargingOnly(Context context) {
 +        return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_upload_on_charging", false);
 +    }
 +    public static boolean instantVideoUploadWhenChargingOnly(Context context) {
 +        return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_video_upload_on_charging", false);
 +    }
  }
@@@ -103,6 -103,7 +103,7 @@@ public class FileUploader extends Servi
      public static final int LOCAL_BEHAVIOUR_COPY = 0;
      public static final int LOCAL_BEHAVIOUR_MOVE = 1;
      public static final int LOCAL_BEHAVIOUR_FORGET = 2;
+     public static final int LOCAL_BEHAVIOUR_REMOVE = 3;
  
      public static final int UPLOAD_SINGLE_FILE = 0;
      public static final int UPLOAD_MULTIPLE_FILES = 1;
          }
          file.setNeedsUpdateThumbnail(true);
          mStorageManager.saveFile(file);
 +        mStorageManager.triggerMediaScan(file.getStoragePath());
      }
  
      private void updateOCFile(OCFile file, RemoteFile remoteFile) {
@@@ -21,8 -21,6 +21,8 @@@
  package com.owncloud.android.ui.activity;
  
  import android.accounts.Account;
 +import android.app.AlertDialog;
 +import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.AsyncTask;
@@@ -31,17 -29,17 +31,19 @@@ import android.os.Environment
  import android.preference.PreferenceManager;
  import android.support.v4.app.DialogFragment;
  import android.support.v7.app.ActionBar;
 +import android.view.Menu;
 +import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
+ import android.widget.RadioButton;
  import android.widget.TextView;
  
  import com.owncloud.android.R;
+ import com.owncloud.android.files.services.FileUploader;
  import com.owncloud.android.lib.common.utils.Log_OC;
  import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
  import com.owncloud.android.ui.dialog.ConfirmationDialogFragment.ConfirmationDialogFragmentListener;
@@@ -79,8 -77,10 +81,10 @@@ public class UploadFilesActivity extend
      private static final String TAG = "UploadFilesActivity";
      private static final String WAIT_DIALOG_TAG = "WAIT";
      private static final String QUERY_TO_MOVE_DIALOG_TAG = "QUERY_TO_MOVE";
-     
-     
+     private RadioButton mRadioBtnCopyFiles;
+     private RadioButton mRadioBtnMoveFiles;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          Log_OC.d(TAG, "onCreate() start");
          mCancelBtn.setOnClickListener(this);
          mUploadBtn = (Button) findViewById(R.id.upload_files_btn_upload);
          mUploadBtn.setOnClickListener(this);
+         SharedPreferences appPreferences = PreferenceManager
+                 .getDefaultSharedPreferences(getApplicationContext());
+         Integer localBehaviour = appPreferences.getInt("prefs_uploader_behaviour", FileUploader.LOCAL_BEHAVIOUR_COPY);
+         mRadioBtnMoveFiles = (RadioButton) findViewById(R.id.upload_radio_move);
+         if (localBehaviour == FileUploader.LOCAL_BEHAVIOUR_MOVE){
+             mRadioBtnMoveFiles.setChecked(true);
+         }
+         mRadioBtnCopyFiles = (RadioButton) findViewById(R.id.upload_radio_copy);
+         if (localBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY){
+             mRadioBtnCopyFiles.setChecked(true);
+         }
          
              
          // Action bar setup
          Log_OC.d(TAG, "onCreate() end");
      }
  
 +    @Override
 +    public boolean onCreateOptionsMenu(Menu menu) {
 +        MenuInflater inflater = getMenuInflater();
 +        inflater.inflate(R.menu.uploader_menu, menu);
 +        return true;
 +    }
 +
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
                  }
                  break;
              }
 +            case R.id.action_sort: {
 +                SharedPreferences appPreferences = PreferenceManager
 +                        .getDefaultSharedPreferences(this);
 +
 +                // Read sorting order, default to sort by name ascending
 +                Integer sortOrder = appPreferences
 +                        .getInt("sortOrder", FileStorageUtils.SORT_NAME);
 +
 +                AlertDialog.Builder builder = new AlertDialog.Builder(this);
 +                builder.setTitle(R.string.actionbar_sort_title)
 +                        .setSingleChoiceItems(R.array.actionbar_sortby, sortOrder ,
 +                                new DialogInterface.OnClickListener() {
 +                                    public void onClick(DialogInterface dialog, int which) {
 +                                        switch (which){
 +                                            case 0:
 +                                                mFileListFragment.sortByName(true);
 +                                                break;
 +                                            case 1:
 +                                                mFileListFragment.sortByDate(false);
 +                                                break;
 +                                        }
 +
 +                                        dialog.dismiss();
 +                                    }
 +                                });
 +                builder.create().show();
 +                break;
 +            }
              default:
                  retval = super.onOptionsItemSelected(item);
          }
                  // return the list of selected files (success)
                  Intent data = new Intent();
                  data.putExtra(EXTRA_CHOSEN_FILES, mFileListFragment.getCheckedFilePaths());
-                 setResult(RESULT_OK, data);
+                 SharedPreferences.Editor appPreferencesEditor = PreferenceManager
+                         .getDefaultSharedPreferences(getApplicationContext()).edit();
+                 if (mRadioBtnMoveFiles.isChecked()){
+                     setResult(RESULT_OK_AND_MOVE, data);
+                     appPreferencesEditor.putInt("prefs_uploader_behaviour",
+                             FileUploader.LOCAL_BEHAVIOUR_MOVE);
+                 } else {
+                     setResult(RESULT_OK, data);
+                     appPreferencesEditor.putInt("prefs_uploader_behaviour",
+                             FileUploader.LOCAL_BEHAVIOUR_COPY);
+                 }
+                 appPreferencesEditor.apply();
                  finish();
-                 
              } else {
                  // show a dialog to query the user if wants to move the selected files
                  // to the ownCloud folder instead of copying