From: David A. Velasco Date: Mon, 20 Oct 2014 11:56:18 +0000 (+0200) Subject: Merge pull request #658 from owncloud/instant_upload_path_chooseable X-Git-Tag: oc-android-1.7.0_signed~141 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/6ed394195d05b5b36c93ac8f112ff0dd50693af8?hp=8be4bb14a31ff988c24859af566d413e981c138d Merge pull request #658 from owncloud/instant_upload_path_chooseable Instant upload path chooseable --- diff --git a/.travis.yml b/.travis.yml index d205021d..50b73d1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,20 @@ -language: java +language: android +android: + components: + - build-tools-20.0.0 + - android-19 + - android-17 + - android-14 + - extra-android-support + licenses: + - 'android-sdk-license-5be876d5' + - 'android-sdk-license-598b93a6' + jdk: oraclejdk7 + before_install: - # Install base Android SDK - - sudo apt-get update -qq - - sudo apt-get install -qq libstdc++6:i386 lib32z1 expect - - export COMPONENTS="build-tools-20.0.0,android-14,android-17,android-19,sysimg-19,extra-android-support" - - export LICENSES="android-sdk-license-5be876d5|android-sdk-license-598b93a6" - - curl -3L https://raw.github.com/embarkmobile/android-sdk-installer/version-2/android-sdk-installer | bash /dev/stdin --install=$COMPONENTS --accept=$LICENSES - - source ~/.android-sdk-installer/env - - rm pom.xml - - ./setup_env.sh + - rm pom.xml + - ./setup_env.sh script: - ant clean diff --git a/res/values/strings.xml b/res/values/strings.xml index 4c7cf34d..b021ed7e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -251,6 +251,7 @@ This image cannot be shown %1$s could not be copied to %2$s local folder + Upload Path Sorry, sharing is not enabled on your server. Please contact your administrator. @@ -302,4 +303,7 @@ An error occurred while trying to move this file or folder to move this file + Instant Uploads + Security + diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 945e853c..3b8b3e81 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -21,35 +21,41 @@ - - - + + - - - - - + + + + + + + + + @@ -65,4 +71,4 @@ - \ No newline at end of file + diff --git a/src/com/owncloud/android/operations/CreateFolderOperation.java b/src/com/owncloud/android/operations/CreateFolderOperation.java index b0e7ed9d..4df8b3df 100644 --- a/src/com/owncloud/android/operations/CreateFolderOperation.java +++ b/src/com/owncloud/android/operations/CreateFolderOperation.java @@ -84,21 +84,36 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper } } - /** * Save new directory in local database */ public void saveFolderInDB() { - OCFile newDir = new OCFile(mRemotePath); - newDir.setMimetype("DIR"); - long parentId = getStorageManager().getFileByPath(FileStorageUtils.getParentPath(mRemotePath)).getFileId(); - newDir.setParentId(parentId); - newDir.setModificationTimestamp(System.currentTimeMillis()); - getStorageManager().saveFile(newDir); + if (mCreateFullPath && getStorageManager(). + getFileByPath(FileStorageUtils.getParentPath(mRemotePath)) == null){// When parent + // of remote path + // is not created + String[] subFolders = mRemotePath.split("/"); + String composedRemotePath = "/"; - Log_OC.d(TAG, "Create directory " + mRemotePath + " in Database"); + // For each antecesor folders create them recursively + for (int i=0; i 0 && uploadPath.charAt(uploadPath.length()-1) == slashString.charAt(0)) { + uploadPath = uploadPath.substring(0, uploadPath.length()-1); + } + + if (uploadPath.isEmpty()) { // Set default instant upload path + uploadPath = getString(R.string.instant_upload_path); + }else { + if (!uploadPath.startsWith(slashString)) { // Add initial slash on path if necessary + uploadPath = slashString.concat(uploadPath); + } + } + return uploadPath; + } + + /** + * Load upload path set on preferences + */ + private void loadInstantUploadPath() { + SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + mUploadPath = appPrefs.getString("instant_upload_path", getString(R.string.instant_upload_path)); + } + + /** + * Save the "Instant Upload Path" on preferences + */ + private void saveInstantUploadPathOnPreferences() { + SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + SharedPreferences.Editor editor = appPrefs.edit(); + editor.putString("instant_upload_path", mUploadPath); + editor.commit(); + } } diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index 58dda0da..3895821d 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -26,6 +26,8 @@ import com.owncloud.android.lib.resources.files.RemoteFile; import android.annotation.SuppressLint; import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; import android.net.Uri; import android.os.Environment; import android.os.StatFs; @@ -73,7 +75,9 @@ public class FileStorageUtils { } public static String getInstantUploadFilePath(Context context, String fileName) { - String uploadPath = context.getString(R.string.instant_upload_path); + SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); + String uploadPathdef = context.getString(R.string.instant_upload_path); + String uploadPath = pref.getString("instant_upload_path", uploadPathdef); String value = uploadPath + OCFile.PATH_SEPARATOR + (fileName == null ? "" : fileName); return value; } @@ -120,4 +124,4 @@ public class FileStorageUtils { return file; } -} \ No newline at end of file +}