diff options
| author | JosJuice <josjuice@gmail.com> | 2019-02-07 23:22:09 +0100 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2019-02-08 18:24:37 +0100 |
| commit | c520a033be313b59d7545be01f33d4b7dd539f4d (patch) | |
| tree | c47d6fef3208f8385816a8cec7d900e2e2d3c3ac /Source/Android/app/src/main/java | |
| parent | e79f37ceac8e79a0b111d7d44b09d66d4a32fe26 (diff) | |
Android: Show files in the directory picker
People in the Google Play reviews still seem to be confused about
games not showing up in the directory picker, so let's show them
even though they can't be selected. (Either that or they haven't
realized that they need to extract their pirated games.)
Diffstat (limited to 'Source/Android/app/src/main/java')
| -rw-r--r-- | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/CustomFilePickerFragment.java | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/CustomFilePickerFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/CustomFilePickerFragment.java index 372d9854ca..8197dfc955 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/CustomFilePickerFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/CustomFilePickerFragment.java @@ -4,10 +4,7 @@ import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.content.FileProvider; -import android.util.TypedValue; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.widget.TextView; import org.dolphinemu.dolphinemu.R; @@ -15,9 +12,15 @@ import org.dolphinemu.dolphinemu.R; import com.nononsenseapps.filepicker.FilePickerFragment; import java.io.File; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; public class CustomFilePickerFragment extends FilePickerFragment { + private static final Set<String> extensions = new HashSet<>(Arrays.asList( + "gcm", "tgc", "iso", "ciso", "gcz", "wbfs", "wad", "dol", "elf")); + @NonNull @Override public Uri toUri(@NonNull final File file) @@ -41,4 +44,33 @@ public class CustomFilePickerFragment extends FilePickerFragment cancel.setVisibility(View.GONE); } } + + @Override + protected boolean isItemVisible(@NonNull final File file) + { + // Some users jump to the conclusion that Dolphin isn't able to detect their + // files if the files don't show up in the file picker when mode == MODE_DIR. + // To avoid this, show files even when the user needs to select a directory. + + return (showHiddenItems || !file.isHidden()) && + (file.isDirectory() || + extensions.contains(fileExtension(file.getName()).toLowerCase())); + } + + @Override + public boolean isCheckable(@NonNull final File file) + { + // We need to make a small correction to the isCheckable logic due to + // overriding isItemVisible to show files when mode == MODE_DIR. + // AbstractFilePickerFragment always treats files as checkable when + // allowExistingFile == true, but we don't want files to be checkable when mode == MODE_DIR. + + return super.isCheckable(file) && !(mode == MODE_DIR && file.isFile()); + } + + private static String fileExtension(@NonNull String filename) + { + int i = filename.lastIndexOf('.'); + return i < 0 ? "" : filename.substring(i + 1); + } } |
