Android: Add requestLegacyExternalStorage

This commit is contained in:
zilmar 2023-11-30 15:29:36 +10:30
parent d0445eb5cc
commit da092545e6
3 changed files with 24 additions and 20 deletions

View File

@ -17,7 +17,8 @@
android:icon="@drawable/icon" android:icon="@drawable/icon"
android:label="@string/app_name" android:label="@string/app_name"
android:banner="@drawable/banner" android:banner="@drawable/banner"
android:theme="@style/Theme.Project64" > android:theme="@style/Theme.Project64"
android:requestLegacyExternalStorage="true" >
<activity <activity
android:name="emu.project64.SplashActivity" android:name="emu.project64.SplashActivity"
android:label="@string/SplashActivity_title" android:label="@string/SplashActivity_title"

View File

@ -4,7 +4,6 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import emu.project64.R;
import emu.project64.jni.LanguageStringID; import emu.project64.jni.LanguageStringID;
import emu.project64.jni.NativeExports; import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID; import emu.project64.jni.SettingsID;

View File

@ -20,36 +20,40 @@ public final class FileUtil
boolean includeFiles, List<CharSequence> outNames, List<String> outPaths ) boolean includeFiles, List<CharSequence> outNames, List<String> outPaths )
{ {
if( !startPath.exists() ) if( !startPath.exists() )
{
return; return;
}
if( startPath.isFile() ) if(startPath.isFile())
{
startPath = startPath.getParentFile(); startPath = startPath.getParentFile();
}
if( startPath.getParentFile() == null ) if(startPath.getParentFile() == null)
{
includeParent = false; includeParent = false;
}
outNames.clear(); outNames.clear();
outPaths.clear(); outPaths.clear();
if( includeParent ) if( includeParent )
{ {
outNames.add( Html.fromHtml( "<b>..</b>" ) );
outNames.add( Html.fromHtml( "<b>..</b>" ) ); boolean BaseDir = false;
boolean BaseDir = false; ArrayList<String> StorageDirectories = AndroidDevice.getStorageDirectories();
ArrayList<String> StorageDirectories = AndroidDevice.getStorageDirectories();
for( String directory : StorageDirectories ) for( String directory : StorageDirectories )
{ {
if (TextUtils.equals(startPath.getPath(), directory)) if (TextUtils.equals(startPath.getPath(), directory))
{ {
BaseDir = true; BaseDir = true;
break; break;
} }
} }
outPaths.add( BaseDir ? null : startPath.getParentFile().getPath() ); outPaths.add( BaseDir ? null : startPath.getParentFile().getPath() );
} }
if( includeDirectories ) if(includeDirectories)
{ {
for( File directory : getContents( startPath, new VisibleDirectoryFilter() ) ) for( File directory : getContents( startPath, new VisibleDirectoryFilter() ) )
{ {
@ -58,7 +62,7 @@ public final class FileUtil
} }
} }
if( includeFiles ) if(includeFiles)
{ {
for( File file : getContents( startPath, new VisibleFileFilter() ) ) for( File file : getContents( startPath, new VisibleFileFilter() ) )
{ {
@ -71,7 +75,7 @@ public final class FileUtil
public static List<File> getContents( File startPath, FileFilter fileFilter ) public static List<File> getContents( File startPath, FileFilter fileFilter )
{ {
// Get a filtered, sorted list of files // Get a filtered, sorted list of files
List<File> results = new ArrayList<File>(); List<File> results = new ArrayList<>();
File[] files = startPath.listFiles( fileFilter ); File[] files = startPath.listFiles( fileFilter );
if( files != null ) if( files != null )