|
1 | 1 | package org.schabi.newpipe.settings; |
2 | 2 |
|
3 | 3 | import android.app.Activity; |
| 4 | +import android.content.ActivityNotFoundException; |
4 | 5 | import android.content.Context; |
5 | 6 | import android.content.Intent; |
6 | 7 | import android.content.SharedPreferences; |
|
25 | 26 | import org.schabi.newpipe.extractor.NewPipe; |
26 | 27 | import org.schabi.newpipe.extractor.localization.ContentCountry; |
27 | 28 | import org.schabi.newpipe.extractor.localization.Localization; |
| 29 | +import org.schabi.newpipe.streams.io.NoFileManagerHelper; |
28 | 30 | import org.schabi.newpipe.streams.io.StoredFileHelper; |
29 | 31 | import org.schabi.newpipe.util.NavigationHelper; |
30 | 32 | import org.schabi.newpipe.util.PicassoHelper; |
@@ -73,19 +75,29 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro |
73 | 75 |
|
74 | 76 | final Preference importDataPreference = requirePreference(R.string.import_data); |
75 | 77 | importDataPreference.setOnPreferenceClickListener((Preference p) -> { |
76 | | - requestImportPathLauncher.launch( |
77 | | - StoredFileHelper.getPicker(requireContext(), |
78 | | - ZIP_MIME_TYPE, getImportExportDataUri())); |
| 78 | + try { |
| 79 | + requestImportPathLauncher.launch( |
| 80 | + StoredFileHelper.getPicker(requireContext(), |
| 81 | + ZIP_MIME_TYPE, getImportExportDataUri())); |
| 82 | + } catch (final ActivityNotFoundException aex) { |
| 83 | + Log.w(TAG, "Unable to launch file-picker", aex); |
| 84 | + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); |
| 85 | + } |
79 | 86 | return true; |
80 | 87 | }); |
81 | 88 |
|
82 | 89 | final Preference exportDataPreference = requirePreference(R.string.export_data); |
83 | 90 | exportDataPreference.setOnPreferenceClickListener((final Preference p) -> { |
84 | 91 |
|
85 | | - requestExportPathLauncher.launch( |
86 | | - StoredFileHelper.getNewPicker(requireContext(), |
87 | | - "NewPipeData-" + exportDateFormat.format(new Date()) + ".zip", |
88 | | - ZIP_MIME_TYPE, getImportExportDataUri())); |
| 92 | + try { |
| 93 | + requestExportPathLauncher.launch( |
| 94 | + StoredFileHelper.getNewPicker(requireContext(), |
| 95 | + "NewPipeData-" + exportDateFormat.format(new Date()) + ".zip", |
| 96 | + ZIP_MIME_TYPE, getImportExportDataUri())); |
| 97 | + } catch (final ActivityNotFoundException aex) { |
| 98 | + Log.w(TAG, "Unable to launch file-picker", aex); |
| 99 | + NoFileManagerHelper.showActivityNotFoundAlert(getContext()); |
| 100 | + } |
89 | 101 | return true; |
90 | 102 | }); |
91 | 103 |
|
|
0 commit comments