diff --git a/src/main/java/com/nextcloud/client/preferences/AppPreferences.java b/src/main/java/com/nextcloud/client/preferences/AppPreferences.java index e339bfafa5..19e714dae4 100644 --- a/src/main/java/com/nextcloud/client/preferences/AppPreferences.java +++ b/src/main/java/com/nextcloud/client/preferences/AppPreferences.java @@ -92,6 +92,20 @@ public interface AppPreferences { boolean isShowMediaScanNotifications(); void setShowMediaScanNotifications(boolean showMediaScanNotification); + /** + * Gets the uploader behavior which the user has set last. + * + * @return uploader behavior the uploader behavior + */ + int getUploaderBehaviour(); + + /** + * Saves the uploader behavior which the user has set last. + * + * @param uploaderBehaviour the uploader behavior + */ + void setUploaderBehaviour(int uploaderBehaviour); + float getGridColumns(); void setGridColumns(float gridColumns); diff --git a/src/main/java/com/nextcloud/client/preferences/PreferenceManager.java b/src/main/java/com/nextcloud/client/preferences/PreferenceManager.java index e532edbe92..ebc6d38cfc 100644 --- a/src/main/java/com/nextcloud/client/preferences/PreferenceManager.java +++ b/src/main/java/com/nextcloud/client/preferences/PreferenceManager.java @@ -439,24 +439,14 @@ public final class PreferenceManager implements AppPreferences { saveBooleanPreference(context, PREF__AUTO_UPLOAD_SPLIT_OUT, splitOut); } - /** - * Gets the uploader behavior which the user has set last. - * - * @param context Caller {@link Context}, used to access to shared preferences manager. - * @return uploader behavior the uploader behavior - */ - public static int getUploaderBehaviour(Context context) { - return getDefaultSharedPreferences(context).getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1); + @Override + public int getUploaderBehaviour() { + return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1); } - /** - * Saves the uploader behavior which the user has set last. - * - * @param context Caller {@link Context}, used to access to shared preferences manager. - * @param uploaderBehaviour the uploader behavior - */ - public static void setUploaderBehaviour(Context context, int uploaderBehaviour) { - saveIntPreference(context, AUTO_PREF__UPLOADER_BEHAVIOR, uploaderBehaviour); + @Override + public void setUploaderBehaviour(int uploaderBehaviour) { + preferences.edit().putInt(AUTO_PREF__UPLOADER_BEHAVIOR, uploaderBehaviour).apply(); } /** diff --git a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index ac9cb3a0f3..a18bdc03d7 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -180,7 +180,7 @@ public class UploadFilesActivity extends FileActivity implements mUploadBtn.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP); mUploadBtn.setOnClickListener(this); - int localBehaviour = PreferenceManager.getUploaderBehaviour(this); + int localBehaviour = preferences.getUploaderBehaviour(); // file upload spinner mBehaviourSpinner = findViewById(R.id.upload_files_spinner_behaviour); @@ -479,7 +479,7 @@ public class UploadFilesActivity extends FileActivity implements data.putExtra(EXTRA_CHOSEN_FILES, new String[]{filesToUpload[0]}); setResult(RESULT_OK_AND_MOVE, data); - PreferenceManager.setUploaderBehaviour(getApplicationContext(), FileUploader.LOCAL_BEHAVIOUR_MOVE); + preferences.setUploaderBehaviour(FileUploader.LOCAL_BEHAVIOUR_MOVE); } else { data.putExtra(EXTRA_CHOSEN_FILES, mFileListFragment.getCheckedFilePaths()); @@ -499,8 +499,7 @@ public class UploadFilesActivity extends FileActivity implements } // store behaviour - PreferenceManager.setUploaderBehaviour(getApplicationContext(), - mBehaviourSpinner.getSelectedItemPosition()); + preferences.setUploaderBehaviour(mBehaviourSpinner.getSelectedItemPosition()); } finish(); @@ -586,7 +585,7 @@ public class UploadFilesActivity extends FileActivity implements if (canWriteIntoFolder) { textView.setText(getString(R.string.uploader_upload_files_behaviour)); - int localBehaviour = PreferenceManager.getUploaderBehaviour(this); + int localBehaviour = preferences.getUploaderBehaviour(); mBehaviourSpinner.setSelection(localBehaviour); } else { mBehaviourSpinner.setSelection(1);