Merge pull request #14070 from nextcloud/fix/choose_storage_location_dialogue

Fix exception when closing choose storage location dialogue
This commit is contained in:
Tobias Kaminsky 2024-11-25 11:19:54 +01:00 committed by GitHub
commit a0c5a9e3e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -819,6 +819,8 @@ public class SettingsActivity extends PreferenceActivity
final PreferenceCategory preferenceCategoryGeneral = (PreferenceCategory) findPreference("general");
viewThemeUtils.files.themePreferenceCategory(preferenceCategoryGeneral);
readStoragePath();
prefDataLoc = findPreference(AppPreferencesImpl.DATA_STORAGE_LOCATION);
if (prefDataLoc != null) {
prefDataLoc.setOnPreferenceClickListener(p -> {
@ -1000,7 +1002,7 @@ public class SettingsActivity extends PreferenceActivity
} else if (requestCode == ACTION_SET_STORAGE_LOCATION && data != null) {
String newPath = data.getStringExtra(ChooseStorageLocationActivity.KEY_RESULT_STORAGE_LOCATION);
if (!storagePath.equals(newPath)) {
if (storagePath != null && !storagePath.equals(newPath)) {
StorageMigration storageMigration = new StorageMigration(this, user, storagePath, newPath, viewThemeUtils);
storageMigration.setStorageMigrationProgressListener(this);
storageMigration.migrate();
@ -1150,6 +1152,12 @@ public class SettingsActivity extends PreferenceActivity
editor.apply();
}
private void readStoragePath() {
SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
// Load storage path from shared preferences. Use private internal storage by default.
storagePath = appPrefs.getString(AppPreferencesImpl.STORAGE_PATH, getApplicationContext().getFilesDir().getAbsolutePath());
}
@Override
public void onStorageMigrationFinished(String storagePath, boolean succeed) {
if (succeed) {