Fixed imports and added comments
authorSam <odeh_sam@hotmail.com>
Fri, 10 Oct 2014 13:27:54 +0000 (15:27 +0200)
committerMagnus Sjoqvist <magnus.b.j.sjoqvist@gmail.com>
Tue, 14 Oct 2014 07:37:50 +0000 (09:37 +0200)
src/com/owncloud/android/ui/activity/Preferences.java
src/com/owncloud/android/ui/activity/Uploader.java

index 32bd11d..6719824 100644 (file)
@@ -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;
+                }
             });
         }
 
index 75b171b..238b85c 100644 (file)
@@ -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();