|
1 | 1 | package org.schabi.newpipe.settings; |
2 | 2 |
|
3 | | -import static org.schabi.newpipe.extractor.utils.Utils.decodeUrlUtf8; |
4 | 3 | import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; |
5 | 4 |
|
6 | 5 | import android.app.Activity; |
|
30 | 29 |
|
31 | 30 | import java.io.File; |
32 | 31 | import java.io.IOException; |
33 | | -import java.net.URI; |
34 | 32 |
|
35 | 33 | public class DownloadSettingsFragment extends BasePreferenceFragment { |
36 | 34 | public static final boolean IGNORE_RELEASE_ON_OLD_PATH = true; |
@@ -107,28 +105,15 @@ private void updatePreferencesSummary() { |
107 | 105 |
|
108 | 106 | private void showPathInSummary(final String prefKey, @StringRes final int defaultString, |
109 | 107 | final Preference target) { |
110 | | - String rawUri = defaultPreferences.getString(prefKey, null); |
111 | | - if (rawUri == null || rawUri.isEmpty()) { |
| 108 | + final Uri uri = Uri.parse(defaultPreferences.getString(prefKey, "")); |
| 109 | + if (uri.equals(Uri.EMPTY)) { |
112 | 110 | target.setSummary(getString(defaultString)); |
113 | 111 | return; |
114 | 112 | } |
115 | 113 |
|
116 | | - if (rawUri.charAt(0) == File.separatorChar) { |
117 | | - target.setSummary(rawUri); |
118 | | - return; |
119 | | - } |
120 | | - if (rawUri.startsWith(ContentResolver.SCHEME_FILE)) { |
121 | | - target.setSummary(new File(URI.create(rawUri)).getPath()); |
122 | | - return; |
123 | | - } |
124 | | - |
125 | | - try { |
126 | | - rawUri = decodeUrlUtf8(rawUri); |
127 | | - } catch (final IllegalArgumentException e) { |
128 | | - // nothing to do |
129 | | - } |
130 | | - |
131 | | - target.setSummary(rawUri); |
| 114 | + final String summary = ContentResolver.SCHEME_FILE.equals(uri.getScheme()) |
| 115 | + ? uri.getPath() : uri.toString(); |
| 116 | + target.setSummary(summary); |
132 | 117 | } |
133 | 118 |
|
134 | 119 | private boolean isFileUri(final String path) { |
|
0 commit comments