Implemented menu in feedinfo activity

This commit is contained in:
daniel oeh 2012-07-15 19:59:44 +02:00
parent bf482e8e70
commit 2e8ed263d8
3 changed files with 94 additions and 11 deletions

27
res/menu/feedinfo.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/visit_website_item"
android:icon="@drawable/location_web_site"
android:showAsAction="ifRoom|collapseActionView"
android:title="@string/visit_website_label"
android:visible="true">
</item>
<item
android:id="@+id/support_item"
android:showAsAction="ifRoom|collapseActionView"
android:title="@string/support_label"
android:visible="false">
</item>
<item
android:id="@+id/share_link_item"
android:showAsAction="collapseActionView"
android:title="@string/share_link_label">
</item>
<item
android:id="@+id/share_source_item"
android:showAsAction="collapseActionView"
android:title="@string/share_source_label">
</item>
</menu>

View File

@ -1,13 +1,51 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<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/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>
<item
android:id="@+id/refresh_item"
android:showAsAction="collapseActionView"
android:title="@string/refresh_label">
</item>
<item
android:id="@+id/mark_all_read_item"
android:showAsAction="ifRoom|withText"
android:title="@string/mark_all_read_label">
</item>
<item
android:id="@+id/show_info_item"
android:icon="@drawable/action_about"
android:showAsAction="always"
android:title="@string/show_info_label">
</item>
<item
android:id="@+id/remove_item"
android:icon="@drawable/content_discard"
android:showAsAction="collapseActionView"
android:title="@string/remove_feed_label"
android:visible="true">
</item>
<item
android:id="@+id/visit_website_item"
android:icon="@drawable/location_web_site"
android:showAsAction="ifRoom|collapseActionView"
android:title="@string/visit_website_label"
android:visible="true">
</item>
<item
android:id="@+id/support_item"
android:showAsAction="collapseActionView"
android:title="@string/support_label"
android:visible="false">
</item>
<item
android:id="@+id/share_link_item"
android:showAsAction="collapseActionView"
android:title="@string/share_link_label">
</item>
<item
android:id="@+id/share_source_item"
android:showAsAction="collapseActionView"
android:title="@string/share_source_label">
</item>
</menu> </menu>

View File

@ -7,11 +7,13 @@ import android.widget.TextView;
import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.asynctask.FeedImageLoader; import de.danoeh.antennapod.asynctask.FeedImageLoader;
import de.danoeh.antennapod.feed.Feed; import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedManager; import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.util.FeedMenuHandler;
import de.danoeh.antennapod.util.LangUtils; import de.danoeh.antennapod.util.LangUtils;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
@ -21,6 +23,8 @@ public class FeedInfoActivity extends SherlockActivity {
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId"; public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId";
private Feed feed;
private ImageView imgvCover; private ImageView imgvCover;
private TextView txtvTitle; private TextView txtvTitle;
private TextView txtvDescription; private TextView txtvDescription;
@ -34,7 +38,7 @@ public class FeedInfoActivity extends SherlockActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
long feedId = getIntent().getLongExtra(EXTRA_FEED_ID, -1); long feedId = getIntent().getLongExtra(EXTRA_FEED_ID, -1);
FeedManager manager = FeedManager.getInstance(); FeedManager manager = FeedManager.getInstance();
Feed feed = manager.getFeed(feedId); feed = manager.getFeed(feedId);
if (feed != null) { if (feed != null) {
Log.d(TAG, "Language is " + feed.getLanguage()); Log.d(TAG, "Language is " + feed.getLanguage());
Log.d(TAG, "Author is " + feed.getAuthor()); Log.d(TAG, "Author is " + feed.getAuthor());
@ -63,9 +67,23 @@ public class FeedInfoActivity extends SherlockActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = new MenuInflater(this);
inflater.inflate(R.menu.feedinfo, menu);
return true; return true;
} }
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.support_item).setVisible(feed.getPaymentLink() != null);
menu.findItem(R.id.share_link_item).setVisible(feed.getLink() != null);
return true;
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
@ -73,7 +91,7 @@ public class FeedInfoActivity extends SherlockActivity {
finish(); finish();
return true; return true;
default: default:
return false; return FeedMenuHandler.onOptionsItemClicked(this, item, feed);
} }
} }
} }