|
15 | 15 | import android.view.MenuItem;
|
16 | 16 | import android.view.View;
|
17 | 17 | import android.view.ViewGroup;
|
18 |
| -import android.widget.Toast; |
19 | 18 |
|
20 | 19 | import com.google.android.material.snackbar.Snackbar;
|
21 | 20 |
|
|
50 | 49 |
|
51 | 50 | import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
52 | 51 | import static android.content.Context.DOWNLOAD_SERVICE;
|
53 |
| -import static android.content.Intent.ACTION_VIEW; |
54 | 52 | import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
55 |
| -import static android.widget.Toast.LENGTH_SHORT; |
| 53 | +import static fr.free.nrw.commons.Utils.handleWebUrl; |
56 | 54 |
|
57 | 55 | public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment implements ViewPager.OnPageChangeListener {
|
58 | 56 |
|
@@ -166,17 +164,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
|
166 | 164 | return true;
|
167 | 165 | case R.id.menu_browser_current_image:
|
168 | 166 | // View in browser
|
169 |
| - Intent viewIntent = new Intent(); |
170 |
| - viewIntent.setAction(ACTION_VIEW); |
171 |
| - viewIntent.setData(m.getFilePageTitle().getMobileUri()); |
172 |
| - //check if web browser available |
173 |
| - if (viewIntent.resolveActivity(getActivity().getPackageManager()) != null){ |
174 |
| - startActivity(viewIntent); |
175 |
| - } else { |
176 |
| - Toast toast = Toast.makeText(getContext(), getString(R.string.no_web_browser), LENGTH_SHORT); |
177 |
| - toast.show(); |
178 |
| - } |
179 |
| - |
| 167 | + handleWebUrl(requireContext(), m.getFilePageTitle().getMobileUri()); |
180 | 168 | return true;
|
181 | 169 | case R.id.menu_download_current_image:
|
182 | 170 | // Download
|
|
0 commit comments