Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
91ce06e6aa
3 changed files with 22 additions and 6 deletions
|
@ -43,6 +43,8 @@ import android.net.ConnectivityManager;
|
|||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class OsmandSettings {
|
||||
|
||||
|
@ -1307,6 +1309,21 @@ public class OsmandSettings {
|
|||
putInt(EXTERNAL_STORAGE_DIR_TYPE_V19, type).
|
||||
putString(EXTERNAL_STORAGE_DIR_V19, externalStorageDir).commit();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File getSecondaryStorage() {
|
||||
final String value = System.getenv("SECONDARY_STORAGE");
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
final String[] paths = value.split(":");
|
||||
for (String path : paths) {
|
||||
File file = new File(path);
|
||||
if (file.isDirectory() && file.canWrite()) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setExternalStorageDirectory(int type, String directory) {
|
||||
if(Build.VERSION.SDK_INT < 19) {
|
||||
|
@ -1325,7 +1342,6 @@ public class OsmandSettings {
|
|||
return settingsAPI.edit(globalPreferences).putString(EXTERNAL_STORAGE_DIR, externalStorageDir).commit();
|
||||
}
|
||||
|
||||
|
||||
public Object getGlobalPreferences() {
|
||||
return globalPreferences;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
|
|||
}
|
||||
final boolean firstTime = getMyApplication().getAppInitializer().isFirstTime(null);
|
||||
final boolean externalExists =
|
||||
DataStoragePlaceDialogFragment.getExternalStorageDirectory(this) != null;
|
||||
DataStoragePlaceDialogFragment.getExternalStorageDirectory() != null;
|
||||
if (firstTime && externalExists) {
|
||||
new DataStoragePlaceDialogFragment().show(getFragmentManager(), null);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class DataStoragePlaceDialogFragment extends DialogFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
internalStorage = getInternalStorageDirectory(getActivity());
|
||||
externalStorage = getExternalStorageDirectory(getActivity());
|
||||
externalStorage = getExternalStorageDirectory();
|
||||
|
||||
final View view = inflater.inflate(R.layout.fragment_data_storage_place_dialog, container,
|
||||
false);
|
||||
|
@ -95,9 +95,8 @@ public class DataStoragePlaceDialogFragment extends DialogFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
public static File getExternalStorageDirectory(Activity activity) {
|
||||
return ((OsmandApplication) activity.getApplication()).getSettings()
|
||||
.getExternalStorageDirectory();
|
||||
public static File getExternalStorageDirectory() {
|
||||
return OsmandSettings.getSecondaryStorage();
|
||||
}
|
||||
|
||||
public static File getInternalStorageDirectory(Activity activity) {
|
||||
|
@ -122,6 +121,7 @@ public class DataStoragePlaceDialogFragment extends DialogFragment {
|
|||
String sz = "";
|
||||
if (dir.canRead()) {
|
||||
StatFs fs = new StatFs(dir.getAbsolutePath());
|
||||
@SuppressWarnings("deprecation")
|
||||
int size = fs.getAvailableBlocks() * fs.getBlockSize();
|
||||
if (size > 0) {
|
||||
if (size > 1 << 20) {
|
||||
|
|
Loading…
Reference in a new issue