|
@@ -57,8 +57,6 @@ import com.owncloud.android.authentication.AuthenticatorActivity;
|
|
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
|
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
|
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
|
|
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
|
|
import com.owncloud.android.datamodel.ExternalLinksProvider;
|
|
import com.owncloud.android.datamodel.ExternalLinksProvider;
|
|
-import com.owncloud.android.datastorage.DataStorageProvider;
|
|
|
|
-import com.owncloud.android.datastorage.StoragePoint;
|
|
|
|
import com.owncloud.android.lib.common.ExternalLink;
|
|
import com.owncloud.android.lib.common.ExternalLink;
|
|
import com.owncloud.android.lib.common.ExternalLinkType;
|
|
import com.owncloud.android.lib.common.ExternalLinkType;
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
@@ -115,6 +113,7 @@ public class SettingsActivity extends PreferenceActivity
|
|
private static final int ACTION_REQUEST_CODE_DAVDROID_SETUP = 10;
|
|
private static final int ACTION_REQUEST_CODE_DAVDROID_SETUP = 10;
|
|
private static final int ACTION_SHOW_MNEMONIC = 11;
|
|
private static final int ACTION_SHOW_MNEMONIC = 11;
|
|
private static final int ACTION_E2E = 12;
|
|
private static final int ACTION_E2E = 12;
|
|
|
|
+ private static final int ACTION_SET_STORAGE_LOCATION = 13;
|
|
private static final int TRUE_VALUE = 1;
|
|
private static final int TRUE_VALUE = 1;
|
|
|
|
|
|
private static final String DAV_PATH = "/remote.php/dav";
|
|
private static final String DAV_PATH = "/remote.php/dav";
|
|
@@ -128,7 +127,7 @@ public class SettingsActivity extends PreferenceActivity
|
|
private ThemeableSwitchPreference showEcosystemApps;
|
|
private ThemeableSwitchPreference showEcosystemApps;
|
|
private AppCompatDelegate delegate;
|
|
private AppCompatDelegate delegate;
|
|
|
|
|
|
- private ListPreference prefStoragePath;
|
|
|
|
|
|
+ private Preference prefDataLoc;
|
|
private String storagePath;
|
|
private String storagePath;
|
|
private String pendingLock;
|
|
private String pendingLock;
|
|
|
|
|
|
@@ -800,34 +799,16 @@ public class SettingsActivity extends PreferenceActivity
|
|
final PreferenceCategory preferenceCategoryGeneral = (PreferenceCategory) findPreference("general");
|
|
final PreferenceCategory preferenceCategoryGeneral = (PreferenceCategory) findPreference("general");
|
|
viewThemeUtils.files.themePreferenceCategory(preferenceCategoryGeneral);
|
|
viewThemeUtils.files.themePreferenceCategory(preferenceCategoryGeneral);
|
|
|
|
|
|
- prefStoragePath = (ListPreference) findPreference(AppPreferencesImpl.STORAGE_PATH);
|
|
|
|
- if (prefStoragePath != null) {
|
|
|
|
- StoragePoint[] storageOptions = DataStorageProvider.getInstance().getAvailableStoragePoints();
|
|
|
|
- String[] entries = new String[storageOptions.length];
|
|
|
|
- String[] values = new String[storageOptions.length];
|
|
|
|
- for (int i = 0; i < storageOptions.length; ++i) {
|
|
|
|
- entries[i] = storageOptions[i].getDescription();
|
|
|
|
- values[i] = storageOptions[i].getPath();
|
|
|
|
- }
|
|
|
|
- prefStoragePath.setEntries(entries);
|
|
|
|
- prefStoragePath.setEntryValues(values);
|
|
|
|
-
|
|
|
|
- prefStoragePath.setOnPreferenceChangeListener((preference, newValue) -> {
|
|
|
|
- String newPath = (String) newValue;
|
|
|
|
-
|
|
|
|
- if (storagePath.equals(newPath)) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- StorageMigration storageMigration = new StorageMigration(this, user, storagePath, newPath, viewThemeUtils);
|
|
|
|
- storageMigration.setStorageMigrationProgressListener(this);
|
|
|
|
- storageMigration.migrate();
|
|
|
|
-
|
|
|
|
- return false;
|
|
|
|
|
|
+ prefDataLoc = findPreference(AppPreferencesImpl.DATA_STORAGE_LOCATION);
|
|
|
|
+ if (prefDataLoc != null) {
|
|
|
|
+ prefDataLoc.setOnPreferenceClickListener(p -> {
|
|
|
|
+ Intent intent = new Intent(MainApp.getAppContext(), ChooseStorageLocationActivity.class);
|
|
|
|
+ intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
|
|
+ startActivityForResult(intent, ACTION_SET_STORAGE_LOCATION);
|
|
|
|
+ return true;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- loadStoragePath();
|
|
|
|
-
|
|
|
|
ListPreference themePref = (ListPreference) findPreference("darkMode");
|
|
ListPreference themePref = (ListPreference) findPreference("darkMode");
|
|
|
|
|
|
List<String> themeEntries = new ArrayList<>(3);
|
|
List<String> themeEntries = new ArrayList<>(3);
|
|
@@ -994,6 +975,14 @@ public class SettingsActivity extends PreferenceActivity
|
|
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
startActivity(i);
|
|
startActivity(i);
|
|
|
|
+ } else if (requestCode == ACTION_SET_STORAGE_LOCATION && data != null) {
|
|
|
|
+ String newPath = data.getStringExtra(ChooseStorageLocationActivity.KEY_RESULT_STORAGE_LOCATION);
|
|
|
|
+
|
|
|
|
+ if (!storagePath.equals(newPath)) {
|
|
|
|
+ StorageMigration storageMigration = new StorageMigration(this, user, storagePath, newPath, viewThemeUtils);
|
|
|
|
+ storageMigration.setStorageMigrationProgressListener(this);
|
|
|
|
+ storageMigration.migrate();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1137,21 +1126,6 @@ public class SettingsActivity extends PreferenceActivity
|
|
SharedPreferences.Editor editor = appPrefs.edit();
|
|
SharedPreferences.Editor editor = appPrefs.edit();
|
|
editor.putString(AppPreferencesImpl.STORAGE_PATH, storagePath);
|
|
editor.putString(AppPreferencesImpl.STORAGE_PATH, storagePath);
|
|
editor.apply();
|
|
editor.apply();
|
|
- String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(storagePath);
|
|
|
|
- prefStoragePath.setSummary(storageDescription);
|
|
|
|
- prefStoragePath.setValue(newStoragePath);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Load storage path set on preferences
|
|
|
|
- */
|
|
|
|
- private void loadStoragePath() {
|
|
|
|
- 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());
|
|
|
|
- String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(storagePath);
|
|
|
|
- prefStoragePath.setSummary(storageDescription);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|