diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-10-24 20:30:55 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-10-24 20:30:55 -0700 |
commit | 41c20a9feba2d30b0c6c5ffaf096ff0a81b415d2 (patch) | |
tree | 99982f58c362b292ba0b92220cf6fd25a0dd4a1a /subsonic-android/src | |
parent | 15bc6685206ccf68ce67a5a48ece54a45012add0 (diff) | |
download | dsub-41c20a9feba2d30b0c6c5ffaf096ff0a81b415d2.tar.gz dsub-41c20a9feba2d30b0c6c5ffaf096ff0a81b415d2.tar.bz2 dsub-41c20a9feba2d30b0c6c5ffaf096ff0a81b415d2.zip |
Moved all the menus to separate online/offline menus
Diffstat (limited to 'subsonic-android/src')
4 files changed, 40 insertions, 70 deletions
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 |