mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 05:13:53 +01:00
Add Share button to image Details page
This commit is contained in:
parent
e44dd21023
commit
ef0c192cd2
5 changed files with 40 additions and 1 deletions
|
|
@ -56,6 +56,7 @@ public class CommonsApplication extends Application {
|
|||
private Account currentAccount = null; // Unlike a savings account...
|
||||
public static final String API_URL = "https://test.wikipedia.org/w/api.php";
|
||||
public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/test";
|
||||
public static final String HOME_URL = "https://test.wikipedia.org/wiki/";
|
||||
public static final String EVENTLOG_URL = "https://bits.wikimedia.org/event.gif";
|
||||
|
||||
public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5257716L};
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ public class Media implements Parcelable {
|
|||
protected Media() {
|
||||
}
|
||||
|
||||
public String getDescriptionUrl() {
|
||||
// HACK! Geez
|
||||
return CommonsApplication.HOME_URL + "File:" + Utils.urlEncode(getFilename().replace("File:", "").replace(" ", "_"));
|
||||
}
|
||||
|
||||
public Uri getLocalUri() {
|
||||
return localUri;
|
||||
}
|
||||
|
|
@ -49,6 +54,10 @@ public class Media implements Parcelable {
|
|||
return Utils.makeThumbUrl(imageUrl, filename, width);
|
||||
}
|
||||
|
||||
public String getDisplayTitle() {
|
||||
return Utils.displayTitleFromTitle(filename);
|
||||
}
|
||||
|
||||
|
||||
protected Uri localUri;
|
||||
protected String imageUrl;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import com.actionbarsherlock.view.MenuItem;
|
|||
import com.actionbarsherlock.widget.ShareActionProvider;
|
||||
import org.wikimedia.commons.Media;
|
||||
import org.wikimedia.commons.R;
|
||||
import org.wikimedia.commons.Utils;
|
||||
|
||||
public class MediaDetailPagerFragment extends SherlockFragment {
|
||||
private ViewPager pager;
|
||||
|
|
@ -59,9 +60,26 @@ public class MediaDetailPagerFragment extends SherlockFragment {
|
|||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
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;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.fragment_image_detail, menu);
|
||||
}
|
||||
|
||||
public void showImage(int i) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue