Implemented sharing menus

This commit is contained in:
daniel oeh 2012-07-10 17:40:35 +02:00
parent d30a4f8495
commit 919e978f8d
6 changed files with 54 additions and 1 deletions

View File

@ -9,7 +9,8 @@
<item android:id="@+id/add_to_queue_item" android:title="@string/add_to_queue_label" android:visible="false" android:showAsAction="collapseActionView"></item> <item android:id="@+id/add_to_queue_item" android:title="@string/add_to_queue_label" android:visible="false" android:showAsAction="collapseActionView"></item>
<item android:id="@+id/remove_from_queue_item" android:title="@string/remove_from_queue_label" android:visible="false" android:showAsAction="collapseActionView"></item> <item android:id="@+id/remove_from_queue_item" android:title="@string/remove_from_queue_label" android:visible="false" android:showAsAction="collapseActionView"></item>
<item android:id="@+id/stream_item" android:title="@string/stream_label" android:visible="false" android:showAsAction="always" android:icon="@drawable/action_stream"></item> <item android:id="@+id/stream_item" android:title="@string/stream_label" android:visible="false" android:showAsAction="always" android:icon="@drawable/action_stream"></item>
<item android:id="@+id/visit_website_item" android:icon="@drawable/location_web_site" android:title="@string/visit_website_label" android:showAsAction="ifRoom|collapseActionView" android:visible="false"></item> <item android:id="@+id/share_link_item" android:title="@string/share_link_label" android:showAsAction="collapseActionView"></item><item android:id="@+id/visit_website_item" android:icon="@drawable/location_web_site" android:title="@string/visit_website_label" android:showAsAction="ifRoom|collapseActionView" android:visible="false"></item>
<item android:id="@+id/support_item" android:title="@string/support_label" android:showAsAction="collapseActionView" android:visible="false"></item> <item android:id="@+id/support_item" android:title="@string/support_label" android:showAsAction="collapseActionView" android:visible="false"></item>
</menu> </menu>

View File

@ -3,6 +3,8 @@
<item android:id="@+id/refresh_item" android:title="@string/refresh_label" android:showAsAction="collapseActionView"></item><item android:id="@+id/mark_all_read_item" android:title="@string/mark_all_read_label" android:showAsAction="ifRoom|withText"></item><item android:id="@+id/show_info_item" android:icon="@drawable/action_about" android:title="@string/show_info_label" android:showAsAction="always"></item><item android:id="@+id/remove_item" android:title="@string/remove_feed_label" android:icon="@drawable/content_discard" android:visible="true" android:showAsAction="collapseActionView"></item> <item android:id="@+id/refresh_item" android:title="@string/refresh_label" android:showAsAction="collapseActionView"></item><item android:id="@+id/mark_all_read_item" android:title="@string/mark_all_read_label" android:showAsAction="ifRoom|withText"></item><item android:id="@+id/show_info_item" android:icon="@drawable/action_about" android:title="@string/show_info_label" android:showAsAction="always"></item><item android:id="@+id/remove_item" android:title="@string/remove_feed_label" android:icon="@drawable/content_discard" android:visible="true" android:showAsAction="collapseActionView"></item>
<item android:id="@+id/visit_website_item" android:showAsAction="ifRoom|collapseActionView" android:icon="@drawable/location_web_site" android:title="@string/visit_website_label" android:visible="true"></item> <item android:id="@+id/visit_website_item" android:showAsAction="ifRoom|collapseActionView" android:icon="@drawable/location_web_site" android:title="@string/visit_website_label" android:visible="true"></item>
<item android:id="@+id/support_item" android:title="@string/support_label" android:showAsAction="collapseActionView" android:visible="false"></item> <item android:id="@+id/support_item" android:title="@string/support_label" android:showAsAction="collapseActionView" android:visible="false"></item>
<item android:id="@+id/share_link_item" android:title="@string/share_link_label" android:showAsAction="collapseActionView"></item>
<item android:id="@+id/share_source_item" android:title="@string/share_source_label" android:showAsAction="collapseActionView"></item>

View File

@ -94,5 +94,7 @@
<string name="download_report_title">All downloads completed</string> <string name="download_report_title">All downloads completed</string>
<string name="refresh_label">Refresh</string> <string name="refresh_label">Refresh</string>
<string name="external_storage_error_msg">No external storage is available. Please make sure that external storage is mounted so that the app can work properly.</string> <string name="external_storage_error_msg">No external storage is available. Please make sure that external storage is mounted so that the app can work properly.</string>
<string name="share_link_label">Share link...</string>
<string name="share_source_label">Share source link...</string>
</resources> </resources>

View File

@ -38,6 +38,8 @@ public class FeedItemMenuHandler {
} else { } else {
menu.findItem(R.id.add_to_queue_item).setVisible(true); menu.findItem(R.id.add_to_queue_item).setVisible(true);
} }
menu.findItem(R.id.share_link_item).setVisible(selectedItem.getLink() != null);
} }
if (selectedItem.isRead()) { if (selectedItem.isRead()) {
@ -100,6 +102,9 @@ public class FeedItemMenuHandler {
Uri supportUri = Uri.parse(selectedItem.getPaymentLink()); Uri supportUri = Uri.parse(selectedItem.getPaymentLink());
context.startActivity(new Intent(Intent.ACTION_VIEW, supportUri)); context.startActivity(new Intent(Intent.ACTION_VIEW, supportUri));
break; break;
case R.id.share_link_item:
ShareUtils.shareFeedItemLink(context, selectedItem);
break;
default: default:
return false; return false;
} }

View File

@ -40,6 +40,9 @@ public class FeedMenuHandler {
} else { } else {
refresh.setVisible(true); refresh.setVisible(true);
} }
menu.findItem(R.id.share_link_item).setVisible(selectedFeed.getLink() != null);
return true; return true;
} }
@ -68,6 +71,12 @@ public class FeedMenuHandler {
Uri supportUri = Uri.parse(selectedFeed.getPaymentLink()); Uri supportUri = Uri.parse(selectedFeed.getPaymentLink());
context.startActivity(new Intent(Intent.ACTION_VIEW, supportUri)); context.startActivity(new Intent(Intent.ACTION_VIEW, supportUri));
break; break;
case R.id.share_link_item:
ShareUtils.shareFeedlink(context, selectedFeed);
break;
case R.id.share_source_item:
ShareUtils.shareFeedDownloadLink(context, selectedFeed);
break;
default: default:
return false; return false;
} }

View File

@ -0,0 +1,34 @@
package de.podfetcher.util;
import de.podfetcher.feed.Feed;
import de.podfetcher.feed.FeedItem;
import android.content.Context;
import android.content.Intent;
/** Utility methods for sharing data */
public class ShareUtils {
private static final String TAG = "ShareUtils";
private ShareUtils() {}
private static void shareLink(Context context, String link) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
i.putExtra(Intent.EXTRA_TEXT, link);
context.startActivity(Intent.createChooser(i, "Share URL"));
}
public static void shareFeedItemLink(Context context, FeedItem item) {
shareLink(context, item.getLink());
}
public static void shareFeedDownloadLink(Context context, Feed feed) {
shareLink(context, feed.getDownload_url());
}
public static void shareFeedlink(Context context, Feed feed) {
shareLink(context, feed.getLink());
}
}