Skip to content

Commit

Permalink
Android: Add requestLegacyExternalStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
project64 committed Nov 30, 2023
1 parent d0445eb commit da09254
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
3 changes: 2 additions & 1 deletion Android/app/src/main/AndroidManifest.xml
Expand Up @@ -17,7 +17,8 @@
android:icon="@drawable/icon"
android:label="@string/app_name"
android:banner="@drawable/banner"
android:theme="@style/Theme.Project64" >
android:theme="@style/Theme.Project64"
android:requestLegacyExternalStorage="true" >
<activity
android:name="emu.project64.SplashActivity"
android:label="@string/SplashActivity_title"
Expand Down
Expand Up @@ -4,7 +4,6 @@
import java.util.ArrayList;
import java.util.List;

import emu.project64.R;
import emu.project64.jni.LanguageStringID;
import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID;
Expand Down
40 changes: 22 additions & 18 deletions Android/app/src/main/java/emu/project64/util/FileUtil.java
Expand Up @@ -20,36 +20,40 @@ public static void populate( File startPath, boolean includeParent, boolean incl
boolean includeFiles, List<CharSequence> outNames, List<String> outPaths )
{
if( !startPath.exists() )
{
return;

if( startPath.isFile() )
}

if(startPath.isFile())
{
startPath = startPath.getParentFile();

if( startPath.getParentFile() == null )
}

if(startPath.getParentFile() == null)
{
includeParent = false;
}

outNames.clear();
outPaths.clear();

if( includeParent )
{

outNames.add( Html.fromHtml( "<b>..</b>" ) );
boolean BaseDir = false;
ArrayList<String> StorageDirectories = AndroidDevice.getStorageDirectories();
outNames.add( Html.fromHtml( "<b>..</b>" ) );
boolean BaseDir = false;
ArrayList<String> StorageDirectories = AndroidDevice.getStorageDirectories();
for( String directory : StorageDirectories )
{
if (TextUtils.equals(startPath.getPath(), directory))
{
BaseDir = true;
break;
}
if (TextUtils.equals(startPath.getPath(), directory))
{
BaseDir = true;
break;
}
}

outPaths.add( BaseDir ? null : startPath.getParentFile().getPath() );
}

if( includeDirectories )
if(includeDirectories)
{
for( File directory : getContents( startPath, new VisibleDirectoryFilter() ) )
{
Expand All @@ -58,7 +62,7 @@ public static void populate( File startPath, boolean includeParent, boolean incl
}
}

if( includeFiles )
if(includeFiles)
{
for( File file : getContents( startPath, new VisibleFileFilter() ) )
{
Expand All @@ -71,9 +75,9 @@ public static void populate( File startPath, boolean includeParent, boolean incl
public static List<File> getContents( File startPath, FileFilter fileFilter )
{
// Get a filtered, sorted list of files
List<File> results = new ArrayList<File>();
List<File> results = new ArrayList<>();
File[] files = startPath.listFiles( fileFilter );

if( files != null )
{
Collections.addAll( results, files );
Expand Down

0 comments on commit da09254

Please sign in to comment.