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;
+ }
});
}
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;
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;
.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("");
}
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();