From f78983b16b6cd53269d14fc7fdf602703d47c11b Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sat, 27 Nov 2021 15:52:54 +0100 Subject: [PATCH 1/7] Show an alert/dialog when no appropriate file-manager was found --- .../newpipe/download/DownloadDialog.java | 18 +++++++++-- .../subscription/SubscriptionFragment.kt | 21 ++++++++++--- .../SubscriptionsImportFragment.java | 13 ++++++-- .../settings/ContentSettingsFragment.java | 26 +++++++++++----- .../settings/DownloadSettingsFragment.java | 9 +++++- .../streams/io/NoFileManagerHelper.java | 31 +++++++++++++++++++ .../giga/ui/fragment/MissionsFragment.java | 15 +++++++-- app/src/main/res/values/strings.xml | 1 + 8 files changed, 114 insertions(+), 20 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerHelper.java diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index a7f5b938f..49b9024cd 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.download; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; @@ -53,6 +54,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.SubtitlesStream; import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.settings.NewPipeSettings; +import org.schabi.newpipe.streams.io.NoFileManagerHelper; import org.schabi.newpipe.streams.io.StoredDirectoryHelper; import org.schabi.newpipe.streams.io.StoredFileHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; @@ -687,7 +689,12 @@ public class DownloadDialog extends DialogFragment } private void launchDirectoryPicker(final ActivityResultLauncher launcher) { - launcher.launch(StoredDirectoryHelper.getPicker(context)); + try { + launcher.launch(StoredDirectoryHelper.getPicker(context)); + } catch (final ActivityNotFoundException aex) { + Log.w(TAG, "Unable to launch directory-picker", aex); + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); + } } private void prepareSelectedDownload() { @@ -766,8 +773,13 @@ public class DownloadDialog extends DialogFragment initialPath = Uri.parse(initialSavePath.getAbsolutePath()); } - requestDownloadSaveAsLauncher.launch(StoredFileHelper.getNewPicker(context, - filenameTmp, mimeTmp, initialPath)); + try { + requestDownloadSaveAsLauncher.launch(StoredFileHelper.getNewPicker(context, + filenameTmp, mimeTmp, initialPath)); + } catch (final ActivityNotFoundException aex) { + Log.w(TAG, "Unable to launch file-picker", aex); + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); + } return; } 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 57e1effbe..8b170279d 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 @@ -1,6 +1,7 @@ package org.schabi.newpipe.local.subscription import android.app.Activity +import android.content.ActivityNotFoundException import android.content.BroadcastReceiver import android.content.Context import android.content.DialogInterface @@ -8,6 +9,7 @@ import android.content.Intent import android.content.IntentFilter import android.os.Bundle import android.os.Parcelable +import android.util.Log import android.view.LayoutInflater import android.view.Menu import android.view.MenuInflater @@ -55,6 +57,7 @@ import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_MODE import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_VALUE import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.PREVIOUS_EXPORT_MODE +import org.schabi.newpipe.streams.io.NoFileManagerHelper import org.schabi.newpipe.streams.io.StoredFileHelper import org.schabi.newpipe.util.NavigationHelper import org.schabi.newpipe.util.OnClickGesture @@ -179,16 +182,26 @@ class SubscriptionFragment : BaseStateFragment() { } private fun onImportPreviousSelected() { - requestImportLauncher.launch(StoredFileHelper.getPicker(activity, JSON_MIME_TYPE)) + try { + requestImportLauncher.launch(StoredFileHelper.getPicker(activity, JSON_MIME_TYPE)) + } catch (aex: ActivityNotFoundException) { + Log.w(TAG, "Unable to launch file-picker", aex) + NoFileManagerHelper.showActivityNotFoundAlert(context) + } } private fun onExportSelected() { val date = SimpleDateFormat("yyyyMMddHHmm", Locale.ENGLISH).format(Date()) val exportName = "newpipe_subscriptions_$date.json" - requestExportLauncher.launch( - StoredFileHelper.getNewPicker(activity, exportName, JSON_MIME_TYPE, null) - ) + try { + requestExportLauncher.launch( + StoredFileHelper.getNewPicker(activity, exportName, JSON_MIME_TYPE, null) + ) + } catch (aex: ActivityNotFoundException) { + Log.w(TAG, "Unable to launch file-picker", aex) + NoFileManagerHelper.showActivityNotFoundAlert(context) + } } private fun openReorderDialog() { 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 675799586..10816922b 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 @@ -1,10 +1,12 @@ package org.schabi.newpipe.local.subscription; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.text.util.Linkify; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -30,6 +32,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService; +import org.schabi.newpipe.streams.io.NoFileManagerHelper; import org.schabi.newpipe.streams.io.StoredFileHelper; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.ServiceHelper; @@ -175,8 +178,14 @@ public class SubscriptionsImportFragment extends BaseFragment { } public void onImportFile() { - // leave */* mime type to support all services with different mime types and file extensions - requestImportFileLauncher.launch(StoredFileHelper.getPicker(activity, "*/*")); + try { + // leave */* mime type to support all services + // with different mime types and file extensions + requestImportFileLauncher.launch(StoredFileHelper.getPicker(activity, "*/*")); + } catch (final ActivityNotFoundException aex) { + Log.w(TAG, "Unable to launch file-picker", aex); + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); + } } 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 6e7e75932..3e72cf9a6 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.settings; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -25,6 +26,7 @@ import org.schabi.newpipe.error.ReCaptchaActivity; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.localization.ContentCountry; import org.schabi.newpipe.extractor.localization.Localization; +import org.schabi.newpipe.streams.io.NoFileManagerHelper; import org.schabi.newpipe.streams.io.StoredFileHelper; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PicassoHelper; @@ -73,19 +75,29 @@ public class ContentSettingsFragment extends BasePreferenceFragment { final Preference importDataPreference = requirePreference(R.string.import_data); importDataPreference.setOnPreferenceClickListener((Preference p) -> { - requestImportPathLauncher.launch( - StoredFileHelper.getPicker(requireContext(), - ZIP_MIME_TYPE, getImportExportDataUri())); + try { + requestImportPathLauncher.launch( + StoredFileHelper.getPicker(requireContext(), + ZIP_MIME_TYPE, getImportExportDataUri())); + } catch (final ActivityNotFoundException aex) { + Log.w(TAG, "Unable to launch file-picker", aex); + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); + } return true; }); final Preference exportDataPreference = requirePreference(R.string.export_data); exportDataPreference.setOnPreferenceClickListener((final Preference p) -> { - requestExportPathLauncher.launch( - StoredFileHelper.getNewPicker(requireContext(), - "NewPipeData-" + exportDateFormat.format(new Date()) + ".zip", - ZIP_MIME_TYPE, getImportExportDataUri())); + try { + requestExportPathLauncher.launch( + StoredFileHelper.getNewPicker(requireContext(), + "NewPipeData-" + exportDateFormat.format(new Date()) + ".zip", + ZIP_MIME_TYPE, getImportExportDataUri())); + } catch (final ActivityNotFoundException aex) { + Log.w(TAG, "Unable to launch file-picker", aex); + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); + } return true; }); diff --git a/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java index dfd77f049..b083cc71d 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.settings; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; @@ -21,6 +22,7 @@ import androidx.preference.SwitchPreferenceCompat; import com.nononsenseapps.filepicker.Utils; import org.schabi.newpipe.R; +import org.schabi.newpipe.streams.io.NoFileManagerHelper; import org.schabi.newpipe.streams.io.StoredDirectoryHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; @@ -214,7 +216,12 @@ public class DownloadSettingsFragment extends BasePreferenceFragment { } private void launchDirectoryPicker(final ActivityResultLauncher launcher) { - launcher.launch(StoredDirectoryHelper.getPicker(ctx)); + try { + launcher.launch(StoredDirectoryHelper.getPicker(ctx)); + } catch (final ActivityNotFoundException aex) { + Log.w(TAG, "Unable to launch directory-picker", aex); + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); + } } private void requestDownloadVideoPathResult(final ActivityResult result) { diff --git a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerHelper.java b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerHelper.java new file mode 100644 index 000000000..cd9119c08 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerHelper.java @@ -0,0 +1,31 @@ +package org.schabi.newpipe.streams.io; + +import android.content.Context; + +import androidx.appcompat.app.AlertDialog; + +import org.schabi.newpipe.R; + +/** + * Helper for when no file-manager/activity was found. + */ +public final class NoFileManagerHelper { + private NoFileManagerHelper() { + // No impl + } + + /** + * Shows an alert dialog when no file-manager is found. + * @param context Context + */ + public static void showActivityNotFoundAlert(final Context context) { + new AlertDialog.Builder(context) + .setTitle(R.string.no_app_to_open_intent) + .setMessage( + context.getString( + R.string.no_appropriate_file_manager_message, + context.getString(R.string.downloads_storage_use_saf_title))) + .setPositiveButton(R.string.ok, null) + .show(); + } +} diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 2cca3239b..5aa3d2a53 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -1,6 +1,7 @@ package us.shandian.giga.ui.fragment; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -10,6 +11,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.IBinder; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -32,6 +34,7 @@ import com.nononsenseapps.filepicker.Utils; import org.schabi.newpipe.R; import org.schabi.newpipe.settings.NewPipeSettings; +import org.schabi.newpipe.streams.io.NoFileManagerHelper; import org.schabi.newpipe.streams.io.StoredFileHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; @@ -46,6 +49,7 @@ import us.shandian.giga.ui.adapter.MissionAdapter; public class MissionsFragment extends Fragment { + private static final String TAG = "MissionsFragment"; private static final int SPAN_SIZE = 2; private SharedPreferences mPrefs; @@ -257,9 +261,14 @@ public class MissionsFragment extends Fragment { initialPath = Uri.parse(initialSavePath.getAbsolutePath()); } - requestDownloadSaveAsLauncher.launch( - StoredFileHelper.getNewPicker(mContext, mission.storage.getName(), - mission.storage.getType(), initialPath)); + try { + requestDownloadSaveAsLauncher.launch( + StoredFileHelper.getNewPicker(mContext, mission.storage.getName(), + mission.storage.getType(), initialPath)); + } catch (final ActivityNotFoundException aex) { + Log.w(TAG, "Unable to launch file-picker", aex); + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); + } } @Override diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7c8fd98ab..112f1a94c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -671,6 +671,7 @@ Recent Chapters No app on your device can open this + No appropriate file-manager was found for this action.\nPlease install a file-manager or try to enable/disable \'%s\' in the download-settings. This content is not available in your country. This is a SoundCloud Go+ track, at least in your country, so it cannot be streamed or downloaded by NewPipe. This content is private, so it cannot be streamed or downloaded by NewPipe. From 68e7fcf8ee3870754487142f5281730674a450a7 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sat, 27 Nov 2021 23:39:17 +0100 Subject: [PATCH 2/7] Fixed typos --- .../main/java/org/schabi/newpipe/download/DownloadDialog.java | 4 ++-- .../schabi/newpipe/local/subscription/SubscriptionFragment.kt | 4 ++-- .../local/subscription/SubscriptionsImportFragment.java | 2 +- .../org/schabi/newpipe/settings/ContentSettingsFragment.java | 4 ++-- .../org/schabi/newpipe/settings/DownloadSettingsFragment.java | 2 +- .../java/us/shandian/giga/ui/fragment/MissionsFragment.java | 2 +- app/src/main/res/values/strings.xml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index 49b9024cd..0386b890d 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -692,7 +692,7 @@ public class DownloadDialog extends DialogFragment try { launcher.launch(StoredDirectoryHelper.getPicker(context)); } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch directory-picker", aex); + Log.w(TAG, "Unable to launch directory picker", aex); NoFileManagerHelper.showActivityNotFoundAlert(getContext()); } } @@ -777,7 +777,7 @@ public class DownloadDialog extends DialogFragment requestDownloadSaveAsLauncher.launch(StoredFileHelper.getNewPicker(context, filenameTmp, mimeTmp, initialPath)); } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file-picker", aex); + Log.w(TAG, "Unable to launch file picker", aex); NoFileManagerHelper.showActivityNotFoundAlert(getContext()); } 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 8b170279d..264fb17e7 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 @@ -185,7 +185,7 @@ class SubscriptionFragment : BaseStateFragment() { try { requestImportLauncher.launch(StoredFileHelper.getPicker(activity, JSON_MIME_TYPE)) } catch (aex: ActivityNotFoundException) { - Log.w(TAG, "Unable to launch file-picker", aex) + Log.w(TAG, "Unable to launch file picker", aex) NoFileManagerHelper.showActivityNotFoundAlert(context) } } @@ -199,7 +199,7 @@ class SubscriptionFragment : BaseStateFragment() { StoredFileHelper.getNewPicker(activity, exportName, JSON_MIME_TYPE, null) ) } catch (aex: ActivityNotFoundException) { - Log.w(TAG, "Unable to launch file-picker", aex) + Log.w(TAG, "Unable to launch file picker", aex) NoFileManagerHelper.showActivityNotFoundAlert(context) } } 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 10816922b..112300f1f 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 @@ -183,7 +183,7 @@ public class SubscriptionsImportFragment extends BaseFragment { // with different mime types and file extensions requestImportFileLauncher.launch(StoredFileHelper.getPicker(activity, "*/*")); } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file-picker", aex); + Log.w(TAG, "Unable to launch file picker", aex); NoFileManagerHelper.showActivityNotFoundAlert(getContext()); } } 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 3e72cf9a6..0a5e50be0 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -80,7 +80,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { StoredFileHelper.getPicker(requireContext(), ZIP_MIME_TYPE, getImportExportDataUri())); } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file-picker", aex); + Log.w(TAG, "Unable to launch file picker", aex); NoFileManagerHelper.showActivityNotFoundAlert(getContext()); } return true; @@ -95,7 +95,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { "NewPipeData-" + exportDateFormat.format(new Date()) + ".zip", ZIP_MIME_TYPE, getImportExportDataUri())); } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file-picker", aex); + Log.w(TAG, "Unable to launch file picker", aex); NoFileManagerHelper.showActivityNotFoundAlert(getContext()); } return true; diff --git a/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java index b083cc71d..45006bec4 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java @@ -219,7 +219,7 @@ public class DownloadSettingsFragment extends BasePreferenceFragment { try { launcher.launch(StoredDirectoryHelper.getPicker(ctx)); } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch directory-picker", aex); + Log.w(TAG, "Unable to launch directory picker", aex); NoFileManagerHelper.showActivityNotFoundAlert(getContext()); } } diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 5aa3d2a53..e08cc4dec 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -266,7 +266,7 @@ public class MissionsFragment extends Fragment { StoredFileHelper.getNewPicker(mContext, mission.storage.getName(), mission.storage.getType(), initialPath)); } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file-picker", aex); + Log.w(TAG, "Unable to launch file picker", aex); NoFileManagerHelper.showActivityNotFoundAlert(getContext()); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 112f1a94c..a8d308cd9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -671,7 +671,7 @@ Recent Chapters No app on your device can open this - No appropriate file-manager was found for this action.\nPlease install a file-manager or try to enable/disable \'%s\' in the download-settings. + No appropriate file manager was found for this action.\nPlease install a file manager or try to enable/disable \'%s\' in the download settings. This content is not available in your country. This is a SoundCloud Go+ track, at least in your country, so it cannot be streamed or downloaded by NewPipe. This content is private, so it cannot be streamed or downloaded by NewPipe. From b2323859e5c243856a989fd34a9bb2ed4c4adf27 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sun, 28 Nov 2021 14:07:45 +0100 Subject: [PATCH 3/7] Refactoring + deduplicated code --- .../newpipe/download/DownloadDialog.java | 28 ++++---- .../subscription/SubscriptionFragment.kt | 30 ++++----- .../SubscriptionsImportFragment.java | 20 +++--- .../settings/ContentSettingsFragment.java | 36 +++++----- .../settings/DownloadSettingsFragment.java | 15 ++--- .../streams/io/NoFileManagerHelper.java | 31 --------- .../streams/io/NoFileManagerSafeGuard.java | 67 +++++++++++++++++++ .../giga/ui/fragment/MissionsFragment.java | 19 +++--- 8 files changed, 134 insertions(+), 112 deletions(-) delete mode 100644 app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerHelper.java create mode 100644 app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index 0386b890d..439efda20 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -1,7 +1,6 @@ package org.schabi.newpipe.download; import android.app.Activity; -import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; @@ -54,7 +53,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.SubtitlesStream; import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.settings.NewPipeSettings; -import org.schabi.newpipe.streams.io.NoFileManagerHelper; +import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard; import org.schabi.newpipe.streams.io.StoredDirectoryHelper; import org.schabi.newpipe.streams.io.StoredFileHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; @@ -689,12 +688,12 @@ public class DownloadDialog extends DialogFragment } private void launchDirectoryPicker(final ActivityResultLauncher launcher) { - try { - launcher.launch(StoredDirectoryHelper.getPicker(context)); - } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch directory picker", aex); - NoFileManagerHelper.showActivityNotFoundAlert(getContext()); - } + NoFileManagerSafeGuard.launchSafe( + launcher, + StoredDirectoryHelper.getPicker(context), + TAG, + context + ); } private void prepareSelectedDownload() { @@ -773,13 +772,12 @@ public class DownloadDialog extends DialogFragment initialPath = Uri.parse(initialSavePath.getAbsolutePath()); } - try { - requestDownloadSaveAsLauncher.launch(StoredFileHelper.getNewPicker(context, - filenameTmp, mimeTmp, initialPath)); - } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file picker", aex); - NoFileManagerHelper.showActivityNotFoundAlert(getContext()); - } + NoFileManagerSafeGuard.launchSafe( + requestDownloadSaveAsLauncher, + StoredFileHelper.getNewPicker(context, filenameTmp, mimeTmp, initialPath), + TAG, + context + ); return; } 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 264fb17e7..008228083 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 @@ -1,7 +1,6 @@ package org.schabi.newpipe.local.subscription import android.app.Activity -import android.content.ActivityNotFoundException import android.content.BroadcastReceiver import android.content.Context import android.content.DialogInterface @@ -9,7 +8,6 @@ import android.content.Intent import android.content.IntentFilter import android.os.Bundle import android.os.Parcelable -import android.util.Log import android.view.LayoutInflater import android.view.Menu import android.view.MenuInflater @@ -57,7 +55,7 @@ import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_MODE import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_VALUE import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.PREVIOUS_EXPORT_MODE -import org.schabi.newpipe.streams.io.NoFileManagerHelper +import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard import org.schabi.newpipe.streams.io.StoredFileHelper import org.schabi.newpipe.util.NavigationHelper import org.schabi.newpipe.util.OnClickGesture @@ -182,26 +180,24 @@ class SubscriptionFragment : BaseStateFragment() { } private fun onImportPreviousSelected() { - try { - requestImportLauncher.launch(StoredFileHelper.getPicker(activity, JSON_MIME_TYPE)) - } catch (aex: ActivityNotFoundException) { - Log.w(TAG, "Unable to launch file picker", aex) - NoFileManagerHelper.showActivityNotFoundAlert(context) - } + NoFileManagerSafeGuard.launchSafe( + requestImportLauncher, + StoredFileHelper.getPicker(activity, JSON_MIME_TYPE), + TAG, + requireContext() + ) } private fun onExportSelected() { val date = SimpleDateFormat("yyyyMMddHHmm", Locale.ENGLISH).format(Date()) val exportName = "newpipe_subscriptions_$date.json" - try { - requestExportLauncher.launch( - StoredFileHelper.getNewPicker(activity, exportName, JSON_MIME_TYPE, null) - ) - } catch (aex: ActivityNotFoundException) { - Log.w(TAG, "Unable to launch file picker", aex) - NoFileManagerHelper.showActivityNotFoundAlert(context) - } + NoFileManagerSafeGuard.launchSafe( + requestExportLauncher, + StoredFileHelper.getNewPicker(activity, exportName, JSON_MIME_TYPE, null), + TAG, + requireContext() + ) } private fun openReorderDialog() { 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 112300f1f..4fbcfbec1 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 @@ -1,12 +1,10 @@ package org.schabi.newpipe.local.subscription; import android.app.Activity; -import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.text.util.Linkify; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -32,7 +30,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService; -import org.schabi.newpipe.streams.io.NoFileManagerHelper; +import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard; import org.schabi.newpipe.streams.io.StoredFileHelper; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.ServiceHelper; @@ -178,14 +176,14 @@ public class SubscriptionsImportFragment extends BaseFragment { } public void onImportFile() { - try { - // leave */* mime type to support all services - // with different mime types and file extensions - requestImportFileLauncher.launch(StoredFileHelper.getPicker(activity, "*/*")); - } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file picker", aex); - NoFileManagerHelper.showActivityNotFoundAlert(getContext()); - } + NoFileManagerSafeGuard.launchSafe( + requestImportFileLauncher, + // leave */* mime type to support all services + // with different mime types and file extensions + StoredFileHelper.getPicker(activity, "*/*"), + TAG, + getContext() + ); } 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 0a5e50be0..1511a23ae 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -1,7 +1,6 @@ package org.schabi.newpipe.settings; import android.app.Activity; -import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -26,7 +25,7 @@ import org.schabi.newpipe.error.ReCaptchaActivity; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.localization.ContentCountry; import org.schabi.newpipe.extractor.localization.Localization; -import org.schabi.newpipe.streams.io.NoFileManagerHelper; +import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard; import org.schabi.newpipe.streams.io.StoredFileHelper; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PicassoHelper; @@ -75,29 +74,28 @@ public class ContentSettingsFragment extends BasePreferenceFragment { final Preference importDataPreference = requirePreference(R.string.import_data); importDataPreference.setOnPreferenceClickListener((Preference p) -> { - try { - requestImportPathLauncher.launch( - StoredFileHelper.getPicker(requireContext(), - ZIP_MIME_TYPE, getImportExportDataUri())); - } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file picker", aex); - NoFileManagerHelper.showActivityNotFoundAlert(getContext()); - } + NoFileManagerSafeGuard.launchSafe( + requestImportPathLauncher, + StoredFileHelper.getPicker(requireContext(), + ZIP_MIME_TYPE, getImportExportDataUri()), + TAG, + getContext() + ); + return true; }); final Preference exportDataPreference = requirePreference(R.string.export_data); exportDataPreference.setOnPreferenceClickListener((final Preference p) -> { + NoFileManagerSafeGuard.launchSafe( + requestExportPathLauncher, + StoredFileHelper.getNewPicker(requireContext(), + "NewPipeData-" + exportDateFormat.format(new Date()) + ".zip", + ZIP_MIME_TYPE, getImportExportDataUri()), + TAG, + getContext() + ); - try { - requestExportPathLauncher.launch( - StoredFileHelper.getNewPicker(requireContext(), - "NewPipeData-" + exportDateFormat.format(new Date()) + ".zip", - ZIP_MIME_TYPE, getImportExportDataUri())); - } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file picker", aex); - NoFileManagerHelper.showActivityNotFoundAlert(getContext()); - } return true; }); diff --git a/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java index 45006bec4..681aee409 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java @@ -1,7 +1,6 @@ package org.schabi.newpipe.settings; import android.app.Activity; -import android.content.ActivityNotFoundException; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; @@ -22,7 +21,7 @@ import androidx.preference.SwitchPreferenceCompat; import com.nononsenseapps.filepicker.Utils; import org.schabi.newpipe.R; -import org.schabi.newpipe.streams.io.NoFileManagerHelper; +import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard; import org.schabi.newpipe.streams.io.StoredDirectoryHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; @@ -216,12 +215,12 @@ public class DownloadSettingsFragment extends BasePreferenceFragment { } private void launchDirectoryPicker(final ActivityResultLauncher launcher) { - try { - launcher.launch(StoredDirectoryHelper.getPicker(ctx)); - } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch directory picker", aex); - NoFileManagerHelper.showActivityNotFoundAlert(getContext()); - } + NoFileManagerSafeGuard.launchSafe( + launcher, + StoredDirectoryHelper.getPicker(ctx), + TAG, + ctx + ); } private void requestDownloadVideoPathResult(final ActivityResult result) { diff --git a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerHelper.java b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerHelper.java deleted file mode 100644 index cd9119c08..000000000 --- a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.schabi.newpipe.streams.io; - -import android.content.Context; - -import androidx.appcompat.app.AlertDialog; - -import org.schabi.newpipe.R; - -/** - * Helper for when no file-manager/activity was found. - */ -public final class NoFileManagerHelper { - private NoFileManagerHelper() { - // No impl - } - - /** - * Shows an alert dialog when no file-manager is found. - * @param context Context - */ - public static void showActivityNotFoundAlert(final Context context) { - new AlertDialog.Builder(context) - .setTitle(R.string.no_app_to_open_intent) - .setMessage( - context.getString( - R.string.no_appropriate_file_manager_message, - context.getString(R.string.downloads_storage_use_saf_title))) - .setPositiveButton(R.string.ok, null) - .show(); - } -} diff --git a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java new file mode 100644 index 000000000..1d14d1669 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java @@ -0,0 +1,67 @@ +package org.schabi.newpipe.streams.io; + +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.util.Log; + +import androidx.activity.result.ActivityResultLauncher; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; + +import org.schabi.newpipe.R; + +/** + * Helper for when no file-manager/activity was found. + */ +public final class NoFileManagerSafeGuard { + private NoFileManagerSafeGuard() { + // No impl + } + + /** + * Shows an alert dialog when no file-manager is found. + * @param context Context + */ + private static void showActivityNotFoundAlert(@NonNull final Context context) { + if (context == null) { + throw new IllegalArgumentException( + "Unable to open no file manager alert dialog: Context is null"); + } + + new AlertDialog.Builder(context) + .setTitle(R.string.no_app_to_open_intent) + .setMessage( + context.getString( + R.string.no_appropriate_file_manager_message, + context.getString(R.string.downloads_storage_use_saf_title))) + .setPositiveButton(R.string.ok, null) + .show(); + } + + /** + * Launches the file manager safely. + * + * If no file manager is found (which is normally only the case when the user uninstalled + * the default file manager or the OS lacks one) an alert dialog shows up, asking the user + * to fix the situation. + * + * @param activityResultLauncher see {@link ActivityResultLauncher#launch(Object)} + * @param input see {@link ActivityResultLauncher#launch(Object)} + * @param tag Tag used for logging + * @param context Context + * @param see {@link ActivityResultLauncher#launch(Object)} + */ + public static void launchSafe( + final ActivityResultLauncher activityResultLauncher, + final I input, + @NonNull final String tag, + @NonNull final Context context + ) { + try { + activityResultLauncher.launch(input); + } catch (final ActivityNotFoundException aex) { + Log.w(tag, "Unable to launch file/directory picker", aex); + NoFileManagerSafeGuard.showActivityNotFoundAlert(context); + } + } +} diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index e08cc4dec..dda2d6dee 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -1,7 +1,6 @@ package us.shandian.giga.ui.fragment; import android.app.Activity; -import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -11,7 +10,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.IBinder; -import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -34,7 +32,7 @@ import com.nononsenseapps.filepicker.Utils; import org.schabi.newpipe.R; import org.schabi.newpipe.settings.NewPipeSettings; -import org.schabi.newpipe.streams.io.NoFileManagerHelper; +import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard; import org.schabi.newpipe.streams.io.StoredFileHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; @@ -261,14 +259,13 @@ public class MissionsFragment extends Fragment { initialPath = Uri.parse(initialSavePath.getAbsolutePath()); } - try { - requestDownloadSaveAsLauncher.launch( - StoredFileHelper.getNewPicker(mContext, mission.storage.getName(), - mission.storage.getType(), initialPath)); - } catch (final ActivityNotFoundException aex) { - Log.w(TAG, "Unable to launch file picker", aex); - NoFileManagerHelper.showActivityNotFoundAlert(getContext()); - } + NoFileManagerSafeGuard.launchSafe( + requestDownloadSaveAsLauncher, + StoredFileHelper.getNewPicker(mContext, mission.storage.getName(), + mission.storage.getType(), initialPath), + TAG, + mContext + ); } @Override From 17724a901c10535d99436d8bdb59bc4f9cc574cd Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Mon, 29 Nov 2021 21:03:59 +0100 Subject: [PATCH 4/7] Removed annotations due to wrong warnings --- .../schabi/newpipe/streams/io/NoFileManagerSafeGuard.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java index 1d14d1669..09ef16d47 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java +++ b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java @@ -22,7 +22,7 @@ public final class NoFileManagerSafeGuard { * Shows an alert dialog when no file-manager is found. * @param context Context */ - private static void showActivityNotFoundAlert(@NonNull final Context context) { + private static void showActivityNotFoundAlert(final Context context) { if (context == null) { throw new IllegalArgumentException( "Unable to open no file manager alert dialog: Context is null"); @@ -54,8 +54,8 @@ public final class NoFileManagerSafeGuard { public static void launchSafe( final ActivityResultLauncher activityResultLauncher, final I input, - @NonNull final String tag, - @NonNull final Context context + final String tag, + final Context context ) { try { activityResultLauncher.launch(input); From 744cfe5672b04eb54442884131b8818b49d42fca Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Mon, 29 Nov 2021 21:13:22 +0100 Subject: [PATCH 5/7] Removed unused import --- .../org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java index 09ef16d47..c7dcb9975 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java +++ b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java @@ -5,7 +5,6 @@ import android.content.Context; import android.util.Log; import androidx.activity.result.ActivityResultLauncher; -import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import org.schabi.newpipe.R; From b9ee14ac303d10f3a5f56a8e550a682a12b196c0 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Tue, 7 Dec 2021 21:31:12 +0100 Subject: [PATCH 6/7] Update string-resource Co-authored-by: Stypox --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a8d308cd9..8d82c3dd7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -671,7 +671,7 @@ Recent Chapters No app on your device can open this - No appropriate file manager was found for this action.\nPlease install a file manager or try to enable/disable \'%s\' in the download settings. + No appropriate file manager was found for this action.\nPlease install a file manager or try to disable \'%s\' in the download settings. This content is not available in your country. This is a SoundCloud Go+ track, at least in your country, so it cannot be streamed or downloaded by NewPipe. This content is private, so it cannot be streamed or downloaded by NewPipe. From e806f8c4e602697eddeb7525e71ca5fe14d4d8fa Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Wed, 8 Dec 2021 20:22:26 +0100 Subject: [PATCH 7/7] Android 10+ only allows SAF -> Respect that in the dialog --- .../streams/io/NoFileManagerSafeGuard.java | 17 +++++++++++++---- app/src/main/res/values/strings.xml | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java index c7dcb9975..df43c34c1 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java +++ b/app/src/main/java/org/schabi/newpipe/streams/io/NoFileManagerSafeGuard.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.streams.io; import android.content.ActivityNotFoundException; import android.content.Context; +import android.os.Build; import android.util.Log; import androidx.activity.result.ActivityResultLauncher; @@ -27,12 +28,20 @@ public final class NoFileManagerSafeGuard { "Unable to open no file manager alert dialog: Context is null"); } + final String message; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + // Android 10+ only allows SAF + message = context.getString(R.string.no_appropriate_file_manager_message_android_10); + } else { + message = context.getString( + R.string.no_appropriate_file_manager_message, + context.getString(R.string.downloads_storage_use_saf_title)); + } + + new AlertDialog.Builder(context) .setTitle(R.string.no_app_to_open_intent) - .setMessage( - context.getString( - R.string.no_appropriate_file_manager_message, - context.getString(R.string.downloads_storage_use_saf_title))) + .setMessage(message) .setPositiveButton(R.string.ok, null) .show(); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8d82c3dd7..22051939b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -672,6 +672,7 @@ Chapters No app on your device can open this No appropriate file manager was found for this action.\nPlease install a file manager or try to disable \'%s\' in the download settings. + No appropriate file manager was found for this action.\nPlease install a Storage Access Framework compatible file manager. This content is not available in your country. This is a SoundCloud Go+ track, at least in your country, so it cannot be streamed or downloaded by NewPipe. This content is private, so it cannot be streamed or downloaded by NewPipe.