diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-09-12 13:49:50 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-09-12 13:49:50 +0200 |
commit | 2e8f102248164486359aa1735ca776b7173aa9cf (patch) | |
tree | 91ee49dfa484f9b2a5c0547a826607742fa0fca8 | |
parent | 455b6c717254e921c579a2aa6af8ab2ec0979786 (diff) | |
download | AntennaPod-2e8f102248164486359aa1735ca776b7173aa9cf.zip |
MenuItems in ItemviewActivity were not displayed correctly. fixes #273
-rw-r--r-- | res/menu/feeditem.xml | 17 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/ItemviewActivity.java | 150 |
2 files changed, 90 insertions, 77 deletions
diff --git a/res/menu/feeditem.xml b/res/menu/feeditem.xml index 505de1d4a..bba0973a6 100644 --- a/res/menu/feeditem.xml +++ b/res/menu/feeditem.xml @@ -1,22 +1,22 @@ <?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/skip_episode_item" android:title="@string/skip_episode_label" android:showAsAction="collapseActionView"></item><item + <item android:id="@+id/download_item" android:icon="?attr/av_download" - android:showAsAction="ifRoom" + android:showAsAction="ifRoom|collapseActionView" android:title="@string/download_label"> </item> <item android:id="@+id/stream_item" android:icon="?attr/action_stream" - android:showAsAction="ifRoom" + android:showAsAction="ifRoom|collapseActionView" android:title="@string/stream_label"> </item> <item android:id="@+id/play_item" android:icon="?attr/av_play" - android:showAsAction="ifRoom" + android:showAsAction="ifRoom|collapseActionView" android:title="@string/play_label"> </item> <item @@ -26,9 +26,14 @@ android:title="@string/remove_label"> </item> <item + android:id="@id/skip_episode_item" + android:title="@string/skip_episode_label" + android:showAsAction="collapseActionView"> + </item> + <item android:id="@+id/cancel_download_item" android:icon="?attr/navigation_cancel" - android:showAsAction="ifRoom" + android:showAsAction="ifRoom|collapseActionView" android:title="@string/cancel_download_label"> </item> <item diff --git a/src/de/danoeh/antennapod/activity/ItemviewActivity.java b/src/de/danoeh/antennapod/activity/ItemviewActivity.java index c2833760d..60b59a993 100644 --- a/src/de/danoeh/antennapod/activity/ItemviewActivity.java +++ b/src/de/danoeh/antennapod/activity/ItemviewActivity.java @@ -5,6 +5,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBarActivity; import android.text.format.DateUtils; import android.util.Log; @@ -30,21 +31,23 @@ import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler; import java.text.DateFormat; -/** Displays a single FeedItem and provides various actions */ +/** + * Displays a single FeedItem and provides various actions + */ public class ItemviewActivity extends ActionBarActivity { - private static final String TAG = "ItemviewActivity"; + private static final String TAG = "ItemviewActivity"; private static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED | EventDistributor.DOWNLOAD_QUEUED; - private FeedItem item; + private FeedItem item; - @Override - public void onCreate(Bundle savedInstanceState) { - setTheme(UserPreferences.getTheme()); - super.onCreate(savedInstanceState); - StorageUtils.checkStorageAvailability(this); - requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); - getSupportActionBar().setDisplayShowTitleEnabled(false); + @Override + public void onCreate(Bundle savedInstanceState) { + setTheme(UserPreferences.getTheme()); + super.onCreate(savedInstanceState); + StorageUtils.checkStorageAvailability(this); + requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); + getSupportActionBar().setDisplayShowTitleEnabled(false); EventDistributor.getInstance().register(contentUpdate); setVolumeControlStream(AudioManager.STREAM_MUSIC); @@ -55,22 +58,22 @@ public class ItemviewActivity extends ActionBarActivity { } else { loadData(itemId); } - } + } - @Override - protected void onResume() { - super.onResume(); - StorageUtils.checkStorageAvailability(this); + @Override + protected void onResume() { + super.onResume(); + StorageUtils.checkStorageAvailability(this); - } + } - @Override - public void onStop() { - super.onStop(); + @Override + public void onStop() { + super.onStop(); EventDistributor.getInstance().unregister(contentUpdate); - if (AppConfig.DEBUG) - Log.d(TAG, "Stopping Activity"); - } + if (AppConfig.DEBUG) + Log.d(TAG, "Stopping Activity"); + } private void loadData(long itemId) { AsyncTask<Long, Void, FeedItem> loadTask = new AsyncTask<Long, Void, FeedItem>() { @@ -99,61 +102,66 @@ public class ItemviewActivity extends ActionBarActivity { loadTask.execute(itemId); } - private void populateUI() { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setContentView(R.layout.feeditemview); - TextView txtvTitle = (TextView) findViewById(R.id.txtvItemname); - TextView txtvPublished = (TextView) findViewById(R.id.txtvPublished); - setTitle(item.getFeed().getTitle()); - - txtvPublished.setText(DateUtils.formatSameDayTime(item.getPubDate() - .getTime(), System.currentTimeMillis(), DateFormat.MEDIUM, - DateFormat.SHORT)); - txtvTitle.setText(item.getTitle()); - - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = fragmentManager - .beginTransaction(); - ItemDescriptionFragment fragment = ItemDescriptionFragment - .newInstance(item, false); - fragmentTransaction.replace(R.id.description_fragment, fragment); - fragmentTransaction.commit(); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { + private void populateUI() { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + setContentView(R.layout.feeditemview); + TextView txtvTitle = (TextView) findViewById(R.id.txtvItemname); + TextView txtvPublished = (TextView) findViewById(R.id.txtvPublished); + setTitle(item.getFeed().getTitle()); + + txtvPublished.setText(DateUtils.formatSameDayTime(item.getPubDate() + .getTime(), System.currentTimeMillis(), DateFormat.MEDIUM, + DateFormat.SHORT)); + txtvTitle.setText(item.getTitle()); + + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = fragmentManager + .beginTransaction(); + ItemDescriptionFragment fragment = ItemDescriptionFragment + .newInstance(item, false); + fragmentTransaction.replace(R.id.description_fragment, fragment); + fragmentTransaction.commit(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { if (item != null) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.feeditem, menu); + // MenuItem visibility has to be set programmatically here; TODO remove this workaround + MenuItemCompat.setShowAsAction(menu.findItem(R.id.download_item), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); + MenuItemCompat.setShowAsAction(menu.findItem(R.id.stream_item), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); + MenuItemCompat.setShowAsAction(menu.findItem(R.id.play_item), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); + MenuItemCompat.setShowAsAction(menu.findItem(R.id.cancel_download_item), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); return true; } else { return false; } - } - - @Override - public boolean onOptionsItemSelected(MenuItem menuItem) { - try { - if (!FeedItemMenuHandler.onMenuItemClicked(this, - menuItem.getItemId(), item)) { - switch (menuItem.getItemId()) { - case android.R.id.home: - finish(); - break; - } - } - } catch (DownloadRequestException e) { - e.printStackTrace(); - DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, - e.getMessage()); - } - supportInvalidateOptionsMenu(); - return true; - } - - @Override - public boolean onPrepareOptionsMenu(final Menu menu) { - return FeedItemMenuHandler.onPrepareMenu( + } + + @Override + public boolean onOptionsItemSelected(MenuItem menuItem) { + try { + if (!FeedItemMenuHandler.onMenuItemClicked(this, + menuItem.getItemId(), item)) { + switch (menuItem.getItemId()) { + case android.R.id.home: + finish(); + break; + } + } + } catch (DownloadRequestException e) { + e.printStackTrace(); + DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, + e.getMessage()); + } + supportInvalidateOptionsMenu(); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(final Menu menu) { + return FeedItemMenuHandler.onPrepareMenu( new FeedItemMenuHandler.MenuInterface() { @Override @@ -161,7 +169,7 @@ public class ItemviewActivity extends ActionBarActivity { menu.findItem(id).setVisible(visible); } }, item, true, QueueAccess.NotInQueueAccess()); - } + } private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() { |