mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Fix a bug with storage settings
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
63a6fd650c
commit
833c7f5773
3 changed files with 27 additions and 5 deletions
|
@ -103,8 +103,6 @@ public class MainApp extends MultiDexApplication {
|
|||
|
||||
private static boolean mOnlyOnDevice = false;
|
||||
|
||||
private static final String KEY_LAST_SEEN_VERSION_CODE = "lastSeenVersionCode";
|
||||
|
||||
private SharedPreferences appPrefs;
|
||||
@SuppressWarnings("unused")
|
||||
private boolean mBound;
|
||||
|
@ -219,11 +217,11 @@ public class MainApp extends MultiDexApplication {
|
|||
|
||||
private void fixStoragePath() {
|
||||
if (!PreferenceManager.getStoragePathFix(this) &&
|
||||
appPrefs.getInt(KEY_LAST_SEEN_VERSION_CODE, 0) != 0) {
|
||||
appPrefs.getInt(WhatsNewActivity.KEY_LAST_SEEN_VERSION_CODE, 0) != 0) {
|
||||
String storagePath = appPrefs.getString(Preferences.PreferenceKeys.STORAGE_PATH, "");
|
||||
if (TextUtils.isEmpty(storagePath)) {
|
||||
storagePath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
StoragePoint[] storagePoints = DataStorageProvider.getInstance().getAvailableStoragePoints();
|
||||
StoragePoint[] storagePoints = DataStorageProvider.getInstance().getLegacyAvailableStoragePoints();
|
||||
for(StoragePoint storagePoint : storagePoints) {
|
||||
if (storagePoint.getPath().startsWith(storagePath)) {
|
||||
storagePath = storagePoint.getPath();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
package com.owncloud.android.datastorage;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
|
@ -31,6 +32,7 @@ import com.owncloud.android.datastorage.providers.MountCommandStoragePointProvid
|
|||
import com.owncloud.android.datastorage.providers.SystemDefaultStoragePointProvider;
|
||||
import com.owncloud.android.datastorage.providers.VDCStoragePointProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
|
@ -57,6 +59,28 @@ public class DataStorageProvider {
|
|||
|
||||
private DataStorageProvider() {}
|
||||
|
||||
public StoragePoint[] getLegacyAvailableStoragePoints() {
|
||||
if (mCachedStoragePoints.size() != 0) {
|
||||
return mCachedStoragePoints.toArray(new StoragePoint[mCachedStoragePoints.size()]);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
for (File f : MainApp.getAppContext().getExternalMediaDirs()) {
|
||||
if (f != null) {
|
||||
mCachedStoragePoints.add(new StoragePoint(f.getAbsolutePath(), f.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (IStoragePointProvider p : mStorageProviders) {
|
||||
if (p.canProvideStoragePoints()) {
|
||||
mCachedStoragePoints.addAll(p.getAvailableStoragePoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mCachedStoragePoints.toArray(new StoragePoint[mCachedStoragePoints.size()]);
|
||||
}
|
||||
|
||||
public StoragePoint[] getAvailableStoragePoints() {
|
||||
if (mCachedStoragePoints.size() != 0) {
|
||||
return mCachedStoragePoints.toArray(new StoragePoint[mCachedStoragePoints.size()]);
|
||||
|
|
|
@ -62,7 +62,7 @@ import com.owncloud.android.utils.ThemeUtils;
|
|||
*/
|
||||
public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPageChangeListener {
|
||||
|
||||
private static final String KEY_LAST_SEEN_VERSION_CODE = "lastSeenVersionCode";
|
||||
public static final String KEY_LAST_SEEN_VERSION_CODE = "lastSeenVersionCode";
|
||||
|
||||
private static final String SCREEN_NAME = "What's new";
|
||||
|
||||
|
|
Loading…
Reference in a new issue