implemented menu in mediaplayer activity

This commit is contained in:
daniel oeh 2012-07-15 21:04:18 +02:00
parent dd3d6f9217
commit 4003ede4a7
3 changed files with 122 additions and 20 deletions

View File

@ -1,16 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/download_item" android:icon="@drawable/av_download" android:visible="false" android:title="@string/download_label" android:showAsAction="always"></item>
<item android:id="@+id/remove_item" android:icon="@drawable/content_discard" android:title="@string/remove_label" android:visible="false" android:showAsAction="always"></item>
<item android:id="@+id/play_item" android:title="@string/play_label" android:visible="false" android:icon="@drawable/av_play" android:showAsAction="always"></item>
<item android:id="@+id/cancel_download_item" android:icon="@drawable/navigation_cancel" android:title="@string/cancel_download_label" android:visible="false" android:showAsAction="always"></item>
<item android:id="@+id/mark_read_item" android:title="@string/mark_read_label" android:showAsAction="collapseActionView" android:visible="false"></item>
<item android:id="@+id/mark_unread_item" android:title="@string/mark_unread_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/stream_item" android:title="@string/stream_label" android:visible="false" android:showAsAction="always" android:icon="@drawable/action_stream"></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/download_item"
android:icon="@drawable/av_download"
android:showAsAction="always"
android:title="@string/download_label"
android:visible="false">
</item>
<item
android:id="@+id/remove_item"
android:icon="@drawable/content_discard"
android:showAsAction="always"
android:title="@string/remove_label"
android:visible="false">
</item>
<item
android:id="@+id/play_item"
android:icon="@drawable/av_play"
android:showAsAction="always"
android:title="@string/play_label"
android:visible="false">
</item>
<item
android:id="@+id/cancel_download_item"
android:icon="@drawable/navigation_cancel"
android:showAsAction="always"
android:title="@string/cancel_download_label"
android:visible="false">
</item>
<item
android:id="@+id/mark_read_item"
android:showAsAction="collapseActionView"
android:title="@string/mark_read_label"
android:visible="false">
</item>
<item
android:id="@+id/mark_unread_item"
android:showAsAction="collapseActionView"
android:title="@string/mark_unread_label"
android:visible="false">
</item>
<item
android:id="@+id/add_to_queue_item"
android:showAsAction="collapseActionView"
android:title="@string/add_to_queue_label"
android:visible="false">
</item>
<item
android:id="@+id/remove_from_queue_item"
android:showAsAction="collapseActionView"
android:title="@string/remove_from_queue_label"
android:visible="false">
</item>
<item
android:id="@+id/stream_item"
android:icon="@drawable/action_stream"
android:showAsAction="always"
android:title="@string/stream_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/visit_website_item"
android:icon="@drawable/location_web_site"
android:showAsAction="ifRoom|collapseActionView"
android:title="@string/visit_website_label"
android:visible="false">
</item>
<item
android:id="@+id/support_item"
android:showAsAction="collapseActionView"
android:title="@string/support_label"
android:visible="false">
</item>
</menu>

23
res/menu/mediaplayer.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/share_link_item"
android:showAsAction="collapseActionView"
android:title="@string/share_link_label">
</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="false">
</item>
<item
android:id="@+id/support_item"
android:showAsAction="collapseActionView"
android:title="@string/support_label"
android:visible="false">
</item>
</menu>

View File

@ -35,6 +35,7 @@ import android.widget.VideoView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.viewpagerindicator.TabPageIndicator;
@ -47,6 +48,7 @@ import de.danoeh.antennapod.fragment.ItemDescriptionFragment;
import de.danoeh.antennapod.service.PlaybackService;
import de.danoeh.antennapod.service.PlayerStatus;
import de.danoeh.antennapod.util.Converter;
import de.danoeh.antennapod.util.FeedItemMenuHandler;
import de.danoeh.antennapod.util.MediaPlayerError;
import de.danoeh.antennapod.util.StorageUtils;
@ -118,6 +120,16 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = new MenuInflater(this);
inflater.inflate(R.menu.mediaplayer, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.support_item).setVisible(media.getItem().getPaymentLink() != null);
menu.findItem(R.id.share_link_item).setVisible(media.getItem().getLink() != null);
menu.findItem(R.id.visit_website_item).setVisible(media.getItem().getLink() != null);
return true;
}
@ -128,7 +140,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
finish();
break;
default:
return false;
return FeedItemMenuHandler.onMenuItemClicked(this, item, media.getItem());
}
return true;
}
@ -468,13 +480,14 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
errorDialog.setTitle(R.string.error_label);
errorDialog
.setMessage(MediaPlayerError.getErrorString(this, errorCode));
errorDialog.setNeutralButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
errorDialog.setNeutralButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
errorDialog.create().show();
}