mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 11:02:35 +01:00
Provide mime type to file picker to gray out unselectable files
This commit is contained in:
parent
cd713db029
commit
32dffb577c
@ -179,7 +179,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
}
|
||||
|
||||
private fun onImportPreviousSelected() {
|
||||
requestImportLauncher.launch(StoredFileHelper.getPicker(activity))
|
||||
requestImportLauncher.launch(StoredFileHelper.getPicker(activity, JSON_MIME_TYPE))
|
||||
}
|
||||
|
||||
private fun onExportSelected() {
|
||||
@ -187,7 +187,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
val exportName = "newpipe_subscriptions_$date.json"
|
||||
|
||||
requestExportLauncher.launch(
|
||||
StoredFileHelper.getNewPicker(activity, exportName, "application/json", null)
|
||||
StoredFileHelper.getNewPicker(activity, exportName, JSON_MIME_TYPE, null)
|
||||
)
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
FeedGroupReorderDialog().show(parentFragmentManager, null)
|
||||
}
|
||||
|
||||
fun requestExportResult(result: ActivityResult) {
|
||||
private fun requestExportResult(result: ActivityResult) {
|
||||
if (result.data != null && result.resultCode == Activity.RESULT_OK) {
|
||||
activity.startService(
|
||||
Intent(activity, SubscriptionsExportService::class.java)
|
||||
@ -204,7 +204,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
}
|
||||
}
|
||||
|
||||
fun requestImportResult(result: ActivityResult) {
|
||||
private fun requestImportResult(result: ActivityResult) {
|
||||
if (result.data != null && result.resultCode == Activity.RESULT_OK) {
|
||||
ImportConfirmationDialog.show(
|
||||
this,
|
||||
@ -407,4 +407,8 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
super.hideLoading()
|
||||
binding.itemsList.animate(true, 200)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val JSON_MIME_TYPE = "application/json"
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,8 @@ public class SubscriptionsImportFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
public void onImportFile() {
|
||||
requestImportFileLauncher.launch(StoredFileHelper.getPicker(activity));
|
||||
// leave */* mime type to support all services with different mime types and file extensions
|
||||
requestImportFileLauncher.launch(StoredFileHelper.getPicker(activity, "*/*"));
|
||||
}
|
||||
|
||||
private void requestImportFileResult(final ActivityResult result) {
|
||||
|
@ -77,7 +77,8 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
||||
final Preference importDataPreference = requirePreference(R.string.import_data);
|
||||
importDataPreference.setOnPreferenceClickListener((Preference p) -> {
|
||||
requestImportPathLauncher.launch(
|
||||
StoredFileHelper.getPicker(requireContext(), getImportExportDataUri()));
|
||||
StoredFileHelper.getPicker(requireContext(),
|
||||
ZIP_MIME_TYPE, getImportExportDataUri()));
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@ -459,11 +459,12 @@ public class StoredFileHelper implements Serializable {
|
||||
return !str1.equals(str2);
|
||||
}
|
||||
|
||||
public static Intent getPicker(@NonNull final Context ctx) {
|
||||
public static Intent getPicker(@NonNull final Context ctx,
|
||||
@NonNull final String mimeType) {
|
||||
if (NewPipeSettings.useStorageAccessFramework(ctx)) {
|
||||
return new Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||
.putExtra("android.content.extra.SHOW_ADVANCED", true)
|
||||
.setType("*/*")
|
||||
.setType(mimeType)
|
||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
|
||||
| StoredDirectoryHelper.PERMISSION_FLAGS);
|
||||
@ -477,8 +478,10 @@ public class StoredFileHelper implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public static Intent getPicker(@NonNull final Context ctx, @Nullable final Uri initialPath) {
|
||||
return applyInitialPathToPickerIntent(ctx, getPicker(ctx), initialPath, null);
|
||||
public static Intent getPicker(@NonNull final Context ctx,
|
||||
@NonNull final String mimeType,
|
||||
@Nullable final Uri initialPath) {
|
||||
return applyInitialPathToPickerIntent(ctx, getPicker(ctx, mimeType), initialPath, null);
|
||||
}
|
||||
|
||||
public static Intent getNewPicker(@NonNull final Context ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user