diff options
14 files changed, 266 insertions, 104 deletions
diff --git a/subsonic-android/res/menu/nowplaying_context_offline.xml b/subsonic-android/res/menu/nowplaying_context_offline.xml new file mode 100644 index 00000000..25d5031b --- /dev/null +++ b/subsonic-android/res/menu/nowplaying_context_offline.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/menu_show_album" + android:title="@string/download.menu_show_album"/> + + <item + android:id="@+id/menu_remove" + android:title="@string/download.menu_remove"/> + + <item + android:id="@+id/menu_delete" + android:title="@string/download.menu_delete"/> +</menu> diff --git a/subsonic-android/res/menu/nowplaying_downloading.xml b/subsonic-android/res/menu/nowplaying_downloading.xml new file mode 100644 index 00000000..60b81a7c --- /dev/null +++ b/subsonic-android/res/menu/nowplaying_downloading.xml @@ -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/menu_remove_all" + android:icon="@drawable/action_remove_all" + android:title="@string/download.menu_remove_all" + android:showAsAction="always|withText"/> + + <item + android:id="@+id/menu_screen_on_off" + android:icon="@drawable/action_screen_on_off" + android:title="@string/download.menu_screen_on" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_toggle_timer" + android:title="@string/download.start_timer"/> + + <item + android:id="@+id/menu_toggle_now_playing" + android:title="@string/download.show_downloading"/> + + <item + android:id="@+id/menu_exit" + android:icon="@drawable/action_exit" + android:title="@string/menu.exit"/> +</menu> diff --git a/subsonic-android/res/menu/nowplaying_offline.xml b/subsonic-android/res/menu/nowplaying_offline.xml new file mode 100644 index 00000000..677f654f --- /dev/null +++ b/subsonic-android/res/menu/nowplaying_offline.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + + <item + android:id="@+id/menu_shuffle" + android:icon="@drawable/action_shuffle" + android:title="@string/download.menu_shuffle" + android:showAsAction="always|withText"/> + + <item + android:id="@+id/menu_remove_all" + android:icon="@drawable/action_remove_all" + android:title="@string/download.menu_remove_all" + android:showAsAction="always|withText"/> + + <item + android:id="@+id/menu_toggle_timer" + android:title="@string/download.start_timer"/> + + <item + android:id="@+id/menu_exit" + android:icon="@drawable/action_exit" + android:title="@string/menu.exit"/> +</menu> diff --git a/subsonic-android/res/menu/select_album.xml b/subsonic-android/res/menu/select_album.xml index cd49e44f..5ca9c537 100644 --- a/subsonic-android/res/menu/select_album.xml +++ b/subsonic-android/res/menu/select_album.xml @@ -17,38 +17,4 @@ android:icon="@drawable/action_shuffle" android:title="@string/menu.shuffle" android:showAsAction="ifRoom|withText"/> - - <item - android:id="@+id/menu_select" - android:icon="@drawable/action_select" - android:title="@string/menu.select" - android:showAsAction="ifRoom|withText"/> - - <item - android:id="@+id/menu_download" - android:icon="@drawable/action_save" - android:title="@string/common.download" - android:showAsAction="ifRoom|withText"/> - - <item - android:id="@+id/menu_cache" - android:icon="@drawable/action_save" - android:title="@string/common.pin" - android:showAsAction="ifRoom|withText"/> - - <item - android:id="@+id/menu_delete" - android:icon="@drawable/action_remove_all" - android:title="@string/common.delete" - android:showAsAction="ifRoom|withText"/> - - <item - android:id="@+id/menu_add_playlist" - android:title="@string/menu.add_playlist"/> - - <item - android:id="@+id/menu_play_last" - android:icon="@drawable/action_play_all" - android:title="@string/menu.play_last" - android:showAsAction="ifRoom|withText"/> </menu> diff --git a/subsonic-android/res/menu/select_album_context_offline.xml b/subsonic-android/res/menu/select_album_context_offline.xml new file mode 100644 index 00000000..801b6c5d --- /dev/null +++ b/subsonic-android/res/menu/select_album_context_offline.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/album_menu_play_now" + android:title="@string/common.play_now" + /> + + <item + android:id="@+id/album_menu_play_shuffled" + android:title="@string/common.play_shuffled" + /> + + <item + android:id="@+id/album_menu_play_last" + android:title="@string/common.play_last" + /> +</menu>
\ No newline at end of file diff --git a/subsonic-android/res/menu/select_artist_context_offline.xml b/subsonic-android/res/menu/select_artist_context_offline.xml new file mode 100644 index 00000000..2a6ed744 --- /dev/null +++ b/subsonic-android/res/menu/select_artist_context_offline.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + + <item + android:id="@+id/artist_menu_play_now" + android:title="@string/common.play_now" + /> + + <item + android:id="@+id/artist_menu_play_shuffled" + android:title="@string/common.play_shuffled" + /> + + <item + android:id="@+id/artist_menu_play_last" + android:title="@string/common.play_last" + /> +</menu> diff --git a/subsonic-android/res/menu/select_playlist_context_offline.xml b/subsonic-android/res/menu/select_playlist_context_offline.xml new file mode 100644 index 00000000..90ce9573 --- /dev/null +++ b/subsonic-android/res/menu/select_playlist_context_offline.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/playlist_info" + android:title="@string/common.info" + /> + + <item + android:id="@+id/playlist_menu_play_now" + android:title="@string/common.play_now" + /> + + <item + android:id="@+id/playlist_menu_play_shuffled" + android:title="@string/common.play_shuffled" + /> +</menu>
\ No newline at end of file diff --git a/subsonic-android/res/menu/select_song.xml b/subsonic-android/res/menu/select_song.xml new file mode 100644 index 00000000..cd49e44f --- /dev/null +++ b/subsonic-android/res/menu/select_song.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/menu_play_now" + android:icon="@drawable/action_play_all" + android:title="@string/menu.play" + android:showAsAction="always|withText"/> + + <item + android:id="@+id/menu_refresh" + android:icon="@drawable/action_refresh" + android:title="@string/menu.refresh" + android:showAsAction="always|withText"/> + + <item + android:id="@+id/menu_shuffle" + android:icon="@drawable/action_shuffle" + android:title="@string/menu.shuffle" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_select" + android:icon="@drawable/action_select" + android:title="@string/menu.select" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_download" + android:icon="@drawable/action_save" + android:title="@string/common.download" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_cache" + android:icon="@drawable/action_save" + android:title="@string/common.pin" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_delete" + android:icon="@drawable/action_remove_all" + android:title="@string/common.delete" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_add_playlist" + android:title="@string/menu.add_playlist"/> + + <item + android:id="@+id/menu_play_last" + android:icon="@drawable/action_play_all" + android:title="@string/menu.play_last" + android:showAsAction="ifRoom|withText"/> +</menu> diff --git a/subsonic-android/res/menu/select_song_context_offline.xml b/subsonic-android/res/menu/select_song_context_offline.xml new file mode 100644 index 00000000..97f24319 --- /dev/null +++ b/subsonic-android/res/menu/select_song_context_offline.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/song_menu_play_now" + android:title="@string/common.play_now" + /> + + <item + android:id="@+id/song_menu_play_next" + android:title="@string/common.play_next" + /> + + <item + android:id="@+id/song_menu_play_last" + android:title="@string/common.play_last" + /> +</menu> diff --git a/subsonic-android/res/menu/select_song_offline.xml b/subsonic-android/res/menu/select_song_offline.xml new file mode 100644 index 00000000..6ed43b71 --- /dev/null +++ b/subsonic-android/res/menu/select_song_offline.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/menu_play_now" + android:icon="@drawable/action_play_all" + android:title="@string/menu.play" + android:showAsAction="always|withText"/> + + <item + android:id="@+id/menu_refresh" + android:icon="@drawable/action_refresh" + android:title="@string/menu.refresh" + android:showAsAction="always|withText"/> + + <item + android:id="@+id/menu_shuffle" + android:icon="@drawable/action_shuffle" + android:title="@string/menu.shuffle" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_select" + android:icon="@drawable/action_select" + android:title="@string/menu.select" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_delete" + android:icon="@drawable/action_remove_all" + android:title="@string/common.delete" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_play_last" + android:icon="@drawable/action_play_all" + android:title="@string/menu.play_last" + android:showAsAction="ifRoom|withText"/> +</menu> diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index 604966a9..0fa1ac94 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -513,33 +513,18 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getSupportMenuInflater(); - inflater.inflate(R.menu.nowplaying, menu); + if(Util.isOffline(this)) { + inflater.inflate(R.menu.nowplaying_offline, menu); + } else { + if(nowPlaying) + inflater.inflate(R.menu.nowplaying, menu); + else + inflater.inflate(R.menu.nowplaying_downloading, menu); + } return true; } @Override - public boolean onPrepareOptionsMenu(Menu menu) { - MenuItem savePlaylist = menu.findItem(R.id.menu_save_playlist); - boolean enabled = !Util.isOffline(this); - savePlaylist.setEnabled(enabled && nowPlaying); - savePlaylist.setVisible(enabled && nowPlaying); - MenuItem screenOption = menu.findItem(R.id.menu_screen_on_off); - if (getDownloadService() != null && getDownloadService().getKeepScreenOn()) { - screenOption.setTitle(R.string.download_menu_screen_off); - } else { - screenOption.setTitle(R.string.download_menu_screen_on); - } - MenuItem togglePlaying = menu.findItem(R.id.menu_toggle_now_playing); - togglePlaying.setVisible(enabled); - togglePlaying.setTitle(nowPlaying ? R.string.download_show_downloading : R.string.download_show_now_playing); - MenuItem shuffle = menu.findItem(R.id.menu_shuffle); - shuffle.setVisible(nowPlaying); - MenuItem timer = menu.findItem(R.id.menu_toggle_timer); - timer.setTitle(getDownloadService().getSleepTimer() ? R.string.download_stop_timer : R.string.download_start_timer); - return super.onPrepareOptionsMenu(menu); - } - - @Override public void onCreateContextMenu(android.view.ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); if (view == playlistView) { @@ -547,19 +532,16 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi DownloadFile downloadFile = (DownloadFile) playlistView.getItemAtPosition(info.position); android.view.MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.nowplaying_context, menu); + if(Util.isOffline(this)) { + inflater.inflate(R.menu.nowplaying_context_offline, menu); + } else { + inflater.inflate(R.menu.nowplaying_context, menu); + menu.findItem(R.id.menu_star).setTitle(downloadFile.getSong().isStarred() ? R.string.common_unstar : R.string.common_star); + } if (downloadFile.getSong().getParent() == null) { menu.findItem(R.id.menu_show_album).setVisible(false); } - if (Util.isOffline(this)) { - menu.findItem(R.id.menu_lyrics).setVisible(false); - menu.findItem(R.id.menu_save_playlist).setVisible(false); - menu.findItem(R.id.menu_star).setVisible(false); - menu.findItem(R.id.menu_toggle_now_playing).setVisible(false); - } else { - menu.findItem(R.id.menu_star).setTitle(downloadFile.getSong().isStarred() ? R.string.common_unstar : R.string.common_star); - } } } diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index 82405f51..7d9d7df2 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -51,12 +51,6 @@ public class SelectAlbumActivity extends SubsonicTabActivity { private View footer; private View emptyView; private boolean hideButtons = false; - private com.actionbarsherlock.view.MenuItem selectAll; - private com.actionbarsherlock.view.MenuItem download; - private com.actionbarsherlock.view.MenuItem cache; - private com.actionbarsherlock.view.MenuItem delete; - private com.actionbarsherlock.view.MenuItem addToPlaylist; - private com.actionbarsherlock.view.MenuItem playLast; private Button moreButton; private boolean licenseValid; @@ -114,20 +108,14 @@ public class SelectAlbumActivity extends SubsonicTabActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); - inflater.inflate(R.menu.select_album, menu); - selectAll = menu.findItem(R.id.menu_select); - download = menu.findItem(R.id.menu_download); - cache = menu.findItem(R.id.menu_cache); - delete = menu.findItem(R.id.menu_delete); - addToPlaylist = menu.findItem(R.id.menu_add_playlist); - playLast = menu.findItem(R.id.menu_play_last); if(hideButtons) { - selectAll.setVisible(false); - cache.setVisible(false); - delete.setVisible(false); - playLast.setVisible(false); - addToPlaylist.setVisible(false); + inflater.inflate(R.menu.select_album, menu); hideButtons = false; + } else { + if(Util.isOffline(this)) + inflater.inflate(R.menu.select_song_offline, menu); + else + inflater.inflate(R.menu.select_song, menu); } return true; } @@ -230,15 +218,19 @@ public class SelectAlbumActivity extends SubsonicTabActivity { if (entry.isDirectory()) { MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.select_album_context, menu); + if(Util.isOffline(this)) + inflater.inflate(R.menu.select_album_context_offline, menu); + else + inflater.inflate(R.menu.select_album_context, menu); } else { MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.select_song_context, menu); + if(Util.isOffline(this)) + inflater.inflate(R.menu.select_song_context_offline, menu); + else + inflater.inflate(R.menu.select_song_context, menu); } - if (Util.isOffline(this)) { - menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setVisible(false); - } else { + if (!Util.isOffline(this)) { menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); } } @@ -627,15 +619,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity { if (songCount > 0) { getImageLoader().loadImage(getSupportActionBar(), entries.get(0)); entryList.addFooterView(footer); - } else if(selectAll != null) { - selectAll.setVisible(false); - download.setVisible(false); - cache.setVisible(false); - delete.setVisible(false); - playLast.setVisible(false); - addToPlaylist.setVisible(false); - } else { + } else { hideButtons = true; + invalidateOptionsMenu(); } emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE); diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java index 16e00cc2..f9d45ac8 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java @@ -186,7 +186,10 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter if (artistList.getItemAtPosition(info.position) instanceof Artist) { MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.select_artist_context, menu); + if(Util.isOffline(this)) + inflater.inflate(R.menu.select_artist_context_offline, menu); + else + inflater.inflate(R.menu.select_artist_context, menu); } else if (info.position == 0) { String musicFolderId = Util.getSelectedMusicFolderId(this); MenuItem menuItem = menu.add(MENU_GROUP_MUSIC_FOLDER, -1, 0, R.string.select_artist_all_folders); diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java index 9aa13070..d667d3ff 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java @@ -118,12 +118,11 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.select_playlist_context, menu); - - if (Util.isOffline(this)) { - menu.findItem(R.id.playlist_menu_delete).setVisible(false); - } + MenuInflater inflater = getMenuInflater(); + if (Util.isOffline(this)) + inflater.inflate(R.menu.select_playlist_context_offline, menu); + else + inflater.inflate(R.menu.select_playlist_context, menu); } @Override |