diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index c6f6cc73c..9cc73dce0 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -179,7 +179,7 @@ class SubscriptionFragment : BaseStateFragment() { } 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() { 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() { 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() { } } - 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() { super.hideLoading() binding.itemsList.animate(true, 200) } + + companion object { + const val JSON_MIME_TYPE = "application/json" + } } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java index 4e667f2b9..c4d088e39 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java @@ -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) { diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index f1e19af94..7be9cf4d6 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -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; }); diff --git a/app/src/main/java/org/schabi/newpipe/streams/io/StoredFileHelper.java b/app/src/main/java/org/schabi/newpipe/streams/io/StoredFileHelper.java index dd379b730..9fe4a9340 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/io/StoredFileHelper.java +++ b/app/src/main/java/org/schabi/newpipe/streams/io/StoredFileHelper.java @@ -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,