only show "SDCards can be used to swap" if an SD Card is present
This commit is contained in:
parent
20ebc00e5e
commit
43ee48ac2b
@ -85,11 +85,15 @@ class NearbyViewBinder {
|
||||
Environment.isExternalStorageRemovable(activity.getExternalFilesDir("")));
|
||||
File[] dirs = activity.getExternalFilesDirs("");
|
||||
if (dirs != null) {
|
||||
for (File f : dirs) {
|
||||
if (f != null && Environment.isExternalStorageRemovable(f)) {
|
||||
// remove Android/data/org.fdroid.fdroid/files to get root
|
||||
externalStorage = f.getParentFile().getParentFile().getParentFile().getParentFile();
|
||||
break;
|
||||
for (File dir : dirs) {
|
||||
if (dir != null && Environment.isExternalStorageRemovable(dir)) {
|
||||
String state = Environment.getExternalStorageState(dir);
|
||||
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)
|
||||
|| Environment.MEDIA_MOUNTED.equals(state)) {
|
||||
// remove Android/data/org.fdroid.fdroid/files to get root
|
||||
externalStorage = dir.getParentFile().getParentFile().getParentFile().getParentFile();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,7 +104,11 @@ class NearbyViewBinder {
|
||||
externalStorage = Environment.getExternalStorageDirectory();
|
||||
}
|
||||
|
||||
if (externalStorage != null) {
|
||||
final String writeExternalStorage = Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
|
||||
if (externalStorage != null
|
||||
|| PackageManager.PERMISSION_GRANTED
|
||||
!= ContextCompat.checkSelfPermission(activity, writeExternalStorage)) {
|
||||
nearbySplash.setVisibility(View.GONE);
|
||||
View readExternalStorage = swapView.findViewById(R.id.readExternalStorage);
|
||||
readExternalStorage.setVisibility(View.VISIBLE);
|
||||
@ -116,9 +124,8 @@ class NearbyViewBinder {
|
||||
msg += "|" + f.getName();
|
||||
}
|
||||
Toast.makeText(activity, msg, Toast.LENGTH_LONG).show();
|
||||
final String writeExternalStorage = Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
if (Build.VERSION.SDK_INT >= 23
|
||||
&& !externalStorage.canRead()
|
||||
&& (externalStorage == null || !externalStorage.canRead())
|
||||
&& PackageManager.PERMISSION_GRANTED
|
||||
!= ContextCompat.checkSelfPermission(activity, writeExternalStorage)) {
|
||||
ActivityCompat.requestPermissions(activity, new String[]{writeExternalStorage},
|
||||
|
Loading…
x
Reference in New Issue
Block a user