Merge pull request #8962 from JosJuice/android-saf-wad
Android: Use storage access framework for importing WADs
This commit is contained in:
commit
43d11ca3eb
|
@ -297,9 +297,6 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||||
case MainPresenter.REQUEST_GAME_FILE:
|
case MainPresenter.REQUEST_GAME_FILE:
|
||||||
extensions = FileBrowserHelper.GAME_EXTENSIONS;
|
extensions = FileBrowserHelper.GAME_EXTENSIONS;
|
||||||
break;
|
break;
|
||||||
case MainPresenter.REQUEST_WAD_FILE:
|
|
||||||
extensions = FileBrowserHelper.WAD_EXTENSION;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidParameterException("Unhandled request code");
|
throw new InvalidParameterException("Unhandled request code");
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,8 +175,10 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||||
@Override
|
@Override
|
||||||
public void launchInstallWAD()
|
public void launchInstallWAD()
|
||||||
{
|
{
|
||||||
FileBrowserHelper.openFilePicker(this, MainPresenter.REQUEST_WAD_FILE, false,
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
FileBrowserHelper.WAD_EXTENSION);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
intent.setType("*/*");
|
||||||
|
startActivityForResult(intent, MainPresenter.REQUEST_WAD_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,7 +205,7 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainPresenter.REQUEST_WAD_FILE:
|
case MainPresenter.REQUEST_WAD_FILE:
|
||||||
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
|
mPresenter.installWAD(result.getData().toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.dolphinemu.dolphinemu.R;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||||
import org.dolphinemu.dolphinemu.model.GameFileCache;
|
import org.dolphinemu.dolphinemu.model.GameFileCache;
|
||||||
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
|
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
|
||||||
|
import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner;
|
||||||
|
|
||||||
public final class MainPresenter
|
public final class MainPresenter
|
||||||
{
|
{
|
||||||
|
@ -99,7 +100,7 @@ public final class MainPresenter
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.menu_install_wad:
|
case R.id.menu_install_wad:
|
||||||
mView.launchInstallWAD();
|
new AfterDirectoryInitializationRunner().run(context, true, mView::launchInstallWAD);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,8 +179,10 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
||||||
@Override
|
@Override
|
||||||
public void launchInstallWAD()
|
public void launchInstallWAD()
|
||||||
{
|
{
|
||||||
FileBrowserHelper.openFilePicker(this, MainPresenter.REQUEST_WAD_FILE, false,
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
FileBrowserHelper.WAD_EXTENSION);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
intent.setType("*/*");
|
||||||
|
startActivityForResult(intent, MainPresenter.REQUEST_WAD_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -226,7 +228,7 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainPresenter.REQUEST_WAD_FILE:
|
case MainPresenter.REQUEST_WAD_FILE:
|
||||||
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
|
mPresenter.installWAD(result.getData().toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,6 @@ public final class FileBrowserHelper
|
||||||
public static final HashSet<String> RAW_EXTENSION = new HashSet<>(Collections.singletonList(
|
public static final HashSet<String> RAW_EXTENSION = new HashSet<>(Collections.singletonList(
|
||||||
"raw"));
|
"raw"));
|
||||||
|
|
||||||
public static final HashSet<String> WAD_EXTENSION = new HashSet<>(Collections.singletonList(
|
|
||||||
"wad"));
|
|
||||||
|
|
||||||
public static void openDirectoryPicker(FragmentActivity activity, HashSet<String> extensions)
|
public static void openDirectoryPicker(FragmentActivity activity, HashSet<String> extensions)
|
||||||
{
|
{
|
||||||
Intent i = new Intent(activity, CustomFilePickerActivity.class);
|
Intent i = new Intent(activity, CustomFilePickerActivity.class);
|
||||||
|
|
Loading…
Reference in New Issue