mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Add 'view in browser' action to detail page
This commit is contained in:
parent
48b6e5cc53
commit
b6400139ae
3 changed files with 15 additions and 2 deletions
|
|
@ -6,5 +6,10 @@
|
|||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:title="@string/menu_share"
|
||||
/>
|
||||
<item android:id="@+id/menu_browser_current_image"
|
||||
android:showAsAction="always"
|
||||
android:icon="@android:drawable/ic_menu_view"
|
||||
android:title="@string/menu_open_in_browser"
|
||||
/>
|
||||
|
||||
</menu>
|
||||
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
<string name="provider_contributions">My uploads</string>
|
||||
<string name="menu_share">Share</string>
|
||||
<string name="menu_open_in_browser">View in Browser</string>
|
||||
|
||||
<plurals name="contributions_subtitle">
|
||||
<item quantity="zero">No uploads yet</item>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.wikimedia.commons.media;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
|
|
@ -62,16 +63,22 @@ public class MediaDetailPagerFragment extends SherlockFragment {
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
MediaDetailProvider provider = (MediaDetailProvider)getSherlockActivity();
|
||||
Media m = provider.getItem(pager.getCurrentItem());
|
||||
switch(item.getItemId()) {
|
||||
case R.id.menu_share_current_image:
|
||||
Intent shareIntent = new Intent();
|
||||
shareIntent.setAction(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
MediaDetailProvider provider = (MediaDetailProvider)getSherlockActivity();
|
||||
Media m = provider.getItem(pager.getCurrentItem());
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, m.getDisplayTitle() + " " + m.getDescriptionUrl());
|
||||
startActivity(shareIntent);
|
||||
return true;
|
||||
case R.id.menu_browser_current_image:
|
||||
Intent viewIntent = new Intent();
|
||||
viewIntent.setAction(Intent.ACTION_VIEW);
|
||||
viewIntent.setData(Uri.parse(m.getDescriptionUrl()));
|
||||
startActivity(viewIntent);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue