From: Magnus Sjoqvist Date: Mon, 20 Oct 2014 12:38:13 +0000 (+0200) Subject: Merge with develop X-Git-Tag: oc-android-1.7.0_signed~119^2~2^2~6 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/844790057b6519bc6e90f49c139335a97aade4c8?hp=-c Merge with develop --- 844790057b6519bc6e90f49c139335a97aade4c8 diff --combined res/values/strings.xml index 30c9557b,b021ed7e..4332c19b --- a/res/values/strings.xml +++ b/res/values/strings.xml @@@ -31,9 -31,7 +31,9 @@@ Recommend to a friend Feedback Imprint - + Remember share location + Remember last share upload location + "Try %1$s on your smartphone!" "I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s" @@@ -253,6 -251,7 +253,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. @@@ -272,7 -271,6 +273,7 @@@ An error occurred while waiting for the server, the operation couldn\'t have been done An error occurred while waiting for the server, the operation couldn\'t have been done The operation couldn\'t be completed, server is unavailable + You do not have permission %s @@@ -304,4 -302,8 +305,7 @@@ The file exists already in the destination folder An error occurred while trying to move this file or folder to move this file + + Instant Uploads + Security - diff --combined res/xml/preferences.xml index 77ef6ed1,3b8b3e81..bda15014 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@@ -21,39 -21,42 +21,45 @@@ - - - + + - ++ + - - - - - + + + + + + + + + - @@@ -68,4 -71,4 +74,4 @@@ - + diff --combined src/com/owncloud/android/ui/activity/Preferences.java index 01c235c6,d078b1e2..8840eee9 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@@ -51,7 -51,6 +51,7 @@@ import com.owncloud.android.R import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.db.DbHandler; +import com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.LongClickableCheckBoxPreference; import com.owncloud.android.utils.DisplayUtils; @@@ -69,13 -68,13 +69,14 @@@ public class Preferences extends Sherlo private DbHandler mDbHandler; private CheckBoxPreference pCode; + private CheckBoxPreference pSaveLocation; private Preference pAboutApp; private PreferenceCategory mAccountsPrefCategory = null; private final Handler mHandler = new Handler(); private String mAccountName; private boolean mShowContextMenu = false; + private String mUploadPath; @SuppressWarnings("deprecation") @@@ -89,7 -88,9 +90,9 @@@ actionBar.setIcon(DisplayUtils.getSeasonalIconId()); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.actionbar_settings); - + + loadInstantUploadPath(); + // Load the accounts category for adding the list of accounts mAccountsPrefCategory = (PreferenceCategory) findPreference("accounts_category"); @@@ -133,24 -134,6 +136,24 @@@ } + pSaveLocation = (CheckBoxPreferenceWithLongTitle) findPreference("save_last_upload_location"); + if(pSaveLocation != null){ + pSaveLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + //The saved path is removed when the preference is turned off + if( newValue instanceof Boolean && !(Boolean) newValue) { + SharedPreferences.Editor appPrefs = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()).edit(); + appPrefs.remove("last_upload_path"); + appPrefs.commit(); + } + return true; + } + }); + } + + PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more"); boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled); @@@ -259,6 -242,16 +262,16 @@@ preferenceCategory.removePreference(pImprint); } } + + Preference pInstantUploadPathApp = (Preference) findPreference("instant_upload_path"); + + pInstantUploadPathApp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + mUploadPath = updateInstantUploadPath(newValue.toString()); + return true; + } + }); /* About App */ pAboutApp = (Preference) findPreference("about_app"); @@@ -275,6 -268,12 +288,12 @@@ } @Override + protected void onPause() { + saveInstantUploadPathOnPreferences(); + super.onPause(); + } + + @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // Filter for only showing contextual menu when long press on the @@@ -482,4 -481,47 +501,47 @@@ } + /** + * Update the upload path checking that it is a correct path + * @param uploadPath: path write by user + * @return String: uploadPath + */ + private String updateInstantUploadPath(String uploadPath) { + String slashString = "/"; + + // If slashes are duplicated, replace them for only one slash + uploadPath = uploadPath.replaceAll("/+", slashString); + + // Remove last slash from path + if (uploadPath.length() > 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(); + } }