From: Sam Date: Fri, 10 Oct 2014 13:27:54 +0000 (+0200) Subject: Fixed imports and added comments X-Git-Tag: oc-android-1.7.0_signed~119^2~2^2~9 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/4275f02cab7b82a9b1488dd8324ce1b805c5bf56?ds=inline;hp=--cc Fixed imports and added comments --- 4275f02cab7b82a9b1488dd8324ce1b805c5bf56 diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index 32bd11d2..6719824a 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -103,18 +103,15 @@ public class Preferences extends SherlockPreferenceActivity { pSaveLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - if( newValue instanceof Boolean) - { - if(!(Boolean) newValue) - { - SharedPreferences.Editor appPrefs = PreferenceManager + //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; + appPrefs.remove("last_upload_path"); + appPrefs.apply(); } + return true; + } }); } diff --git a/src/com/owncloud/android/ui/activity/Uploader.java b/src/com/owncloud/android/ui/activity/Uploader.java index 75b171b2..238b85c2 100644 --- a/src/com/owncloud/android/ui/activity/Uploader.java +++ b/src/com/owncloud/android/ui/activity/Uploader.java @@ -39,7 +39,6 @@ import android.accounts.AccountManager; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; -import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; @@ -56,7 +55,6 @@ import android.provider.MediaStore.Audio; import android.provider.MediaStore.Images; import android.provider.MediaStore.Video; import android.view.View; -import android.view.Window; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.Button; @@ -122,11 +120,11 @@ public class Uploader extends SherlockListActivity implements OnItemClickListene .getDefaultSharedPreferences(getApplicationContext()); mSaveUploadLocation = appPreferences.getBoolean("save_last_upload_location", false); - + //If the users has enabled last upload path saving then populate mParents with the previous path if(mSaveUploadLocation) { String last_path = appPreferences.getString("last_upload_path", ""); - + // "/" equals root-directory if(last_path.equals("/")) { mParents.add(""); } @@ -464,11 +462,12 @@ public class Uploader extends SherlockListActivity implements OnItemClickListene intent.putExtra(FileUploader.KEY_ACCOUNT, mAccount); startService(intent); + //If the user has enabled last upload path then save the path to shared preferences if(mSaveUploadLocation){ SharedPreferences.Editor appPrefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()).edit(); appPrefs.putString("last_upload_path", mUploadPath); - appPrefs.commit(); + appPrefs.apply(); } finish();