Skip to content

Commit 488bdd9

Browse files
domdomeggmaskaravivek
authored andcommitted
Use utils.handleWebUrl for view on commons web intent (commons-app#2796)
1 parent 7820ed9 commit 488bdd9

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

app/src/main/java/fr/free/nrw/commons/media/MediaDetailPagerFragment.java

+2-14
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import android.view.MenuItem;
1616
import android.view.View;
1717
import android.view.ViewGroup;
18-
import android.widget.Toast;
1918

2019
import com.google.android.material.snackbar.Snackbar;
2120

@@ -50,9 +49,8 @@
5049

5150
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
5251
import static android.content.Context.DOWNLOAD_SERVICE;
53-
import static android.content.Intent.ACTION_VIEW;
5452
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;
5654

5755
public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment implements ViewPager.OnPageChangeListener {
5856

@@ -166,17 +164,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
166164
return true;
167165
case R.id.menu_browser_current_image:
168166
// 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());
180168
return true;
181169
case R.id.menu_download_current_image:
182170
// Download

0 commit comments

Comments
 (0)