From 1d6294de8292f6945534f3ed4819b86d11c6ea75 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 8 Nov 2013 19:33:22 -0800 Subject: Added bookmarks tab to layout, more optimizations --- res/menu/abstract_top_menu.xml | 25 ++++++++++++++ res/menu/select_playlist.xml | 25 -------------- res/menu/select_podcasts.xml | 6 ++++ res/values/arrays.xml | 8 +++-- res/values/strings.xml | 3 ++ res/xml/settings.xml | 6 ++++ .../dsub/activity/SubsonicActivity.java | 39 +++++++++------------- .../dsub/activity/SubsonicFragmentActivity.java | 3 ++ .../dsub/fragments/SelectBookmarkFragment.java | 4 +-- .../dsub/fragments/SelectPlaylistFragment.java | 2 +- src/github/daneren2005/dsub/util/Constants.java | 1 + 11 files changed, 68 insertions(+), 54 deletions(-) create mode 100644 res/menu/abstract_top_menu.xml delete mode 100644 res/menu/select_playlist.xml diff --git a/res/menu/abstract_top_menu.xml b/res/menu/abstract_top_menu.xml new file mode 100644 index 00000000..98f9884e --- /dev/null +++ b/res/menu/abstract_top_menu.xml @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/res/menu/select_playlist.xml b/res/menu/select_playlist.xml deleted file mode 100644 index 68904502..00000000 --- a/res/menu/select_playlist.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - diff --git a/res/menu/select_podcasts.xml b/res/menu/select_podcasts.xml index 6311eaca..de6b83a7 100644 --- a/res/menu/select_podcasts.xml +++ b/res/menu/select_podcasts.xml @@ -7,6 +7,12 @@ android:title="@string/menu.refresh" compat:showAsAction="always|withText"/> + + @string/button_bar.browse @string/button_bar.playlists @string/button_bar.podcasts + @string/button_bar.bookmarks @string/button_bar.chat Home - Library - Playlists - Podcasts + Artist + Playlist + Podcast + Bookmark Chat diff --git a/res/values/strings.xml b/res/values/strings.xml index d162cd81..4eb57348 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -30,6 +30,7 @@ Playlists Now Playing Podcasts + Bookmarks Chat Welcome! @@ -332,6 +333,8 @@ Hide widget after exiting app Podcasts Enabled Whether or not to display the podcast listing in the pull out drawer + Bookmarks Enabled + Whether or not to display the bookmarks listing in the pull out drawer Shuffle By Start Year: diff --git a/res/xml/settings.xml b/res/xml/settings.xml index a53b1ee4..f83f361c 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -69,6 +69,12 @@ android:summary="@string/settings.podcasts_enabled_summary" android:key="podcastsEnabled" android:defaultValue="true"/> + + diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 68f398bc..135a76a2 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -71,7 +71,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte private String[] drawerItemsDescriptions; private String[] drawerItems; private boolean drawerIdle = true; - private boolean[] enabledItems = {true, true}; + private boolean[] enabledItems = {true, true, true}; private boolean destroyed = false; private boolean finished = false; protected List backStack = new ArrayList(); @@ -152,23 +152,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte drawerList.setOnItemClickListener(new ListView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - if("Home".equals(drawerItemsDescriptions[position])) { - startFragmentActivity(""); - } else if("Library".equals(drawerItemsDescriptions[position])) { - startFragmentActivity("Artist"); - } else if("Playlists".equals(drawerItemsDescriptions[position])) { - startFragmentActivity("Playlist"); - } else if("Podcasts".equals(drawerItemsDescriptions[position])) { - startFragmentActivity("Podcast"); - } else if("Chat".equals(drawerItemsDescriptions[position])) { - startFragmentActivity("Chat"); - } else if("Now Playing".equals(drawerItemsDescriptions[position])) { - startActivity(DownloadActivity.class); - } else if("Settings".equals(drawerItemsDescriptions[position])) { - startActivity(SettingsActivity.class); - } else if("Exit".equals(drawerItemsDescriptions[position])) { - exit(); - } + startFragmentActivity(drawerItemsDescriptions[position]); if(lastSelectedView != view) { lastSelectedView.setBackgroundResource(android.R.color.transparent); @@ -372,9 +356,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte private void populateDrawer() { SharedPreferences prefs = Util.getPreferences(this); boolean podcastsEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_PODCASTS_ENABLED, true); + boolean bookmarksEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_BOOKMARKS_ENABLED, true); boolean chatEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_CHAT_ENABLED, true); - if(drawerItems == null || !enabledItems[0] == podcastsEnabled || !enabledItems[1] == chatEnabled) { + if(drawerItems == null || !enabledItems[0] == podcastsEnabled || !enabledItems[1] == bookmarksEnabled || !enabledItems[2] == chatEnabled) { drawerItems = getResources().getStringArray(R.array.drawerItems); drawerItemsDescriptions = getResources().getStringArray(R.array.drawerItemsDescriptions); @@ -389,14 +374,21 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte drawerItemsDescriptionsList.remove(3 - alreadyRemoved); alreadyRemoved++; } - - // Selectively remove chat listing: [4] - if(!chatEnabled) { + + // Selectively remove bookmarks listing [4] + if(!bookmarksEnabled) { drawerItemsList.remove(4 - alreadyRemoved); drawerItemsDescriptionsList.remove(4 - alreadyRemoved); alreadyRemoved++; } + // Selectively remove chat listing: [5] + if(!chatEnabled) { + drawerItemsList.remove(5 - alreadyRemoved); + drawerItemsDescriptionsList.remove(5 - alreadyRemoved); + alreadyRemoved++; + } + // Put list back together if(alreadyRemoved > 0) { drawerItems = drawerItemsList.toArray(new String[0]); @@ -405,7 +397,8 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte drawerList.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, drawerItems)); enabledItems[0] = podcastsEnabled; - enabledItems[1] = chatEnabled; + enabledItems[1] = bookmarksEnabled; + enabledItems[2] = chatEnabled; } } diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 9c006ae1..5fe7333d 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -44,6 +44,7 @@ import github.daneren2005.dsub.fragments.ChatFragment; import github.daneren2005.dsub.fragments.MainFragment; import github.daneren2005.dsub.fragments.SearchFragment; import github.daneren2005.dsub.fragments.SelectArtistFragment; +import github.daneren2005.dsub.fragments.SelectBookmarkFragment; import github.daneren2005.dsub.fragments.SelectDirectoryFragment; import github.daneren2005.dsub.fragments.SelectPlaylistFragment; import github.daneren2005.dsub.fragments.SelectPodcastsFragment; @@ -332,6 +333,8 @@ public class SubsonicFragmentActivity extends SubsonicActivity { return new ChatFragment(); } else if("Podcast".equals(fragmentType)) { return new SelectPodcastsFragment(); + } else if("Bookmark".equals(fragmentType)) { + return new SelectBookmarkFragment(); } else { return new MainFragment(); } diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index cf57ce58..b0969b29 100644 --- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -80,7 +80,7 @@ public class SelectBookmarkFragment extends SubsonicFragment implements AdapterV @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { - menuInflater.inflate(R.menu.select_genres, menu); + menuInflater.inflate(R.menu.abstract_top_menu, menu); } @Override @@ -94,7 +94,7 @@ public class SelectBookmarkFragment extends SubsonicFragment implements AdapterV @Override protected void refresh(final boolean refresh) { - setTitle(R.string.main_albums_genres); + setTitle(R.string.button_bar_bookmarks); bookmarkListView.setVisibility(View.INVISIBLE); BackgroundTask> task = new TabBackgroundTask>(this) { diff --git a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index 9ae229b8..79889c2c 100644 --- a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -81,7 +81,7 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { - menuInflater.inflate(R.menu.select_playlist, menu); + menuInflater.inflate(R.menu.abstract_top_menu, menu); } @Override diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index fece424b..efcaf2d3 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -121,6 +121,7 @@ public final class Constants { public static final String PREFERENCES_KEY_PAUSE_DISCONNECT = "pauseOnDisconnect"; public static final String PREFERENCES_KEY_HIDE_WIDGET = "hideWidget"; public static final String PREFERENCES_KEY_PODCASTS_ENABLED = "podcastsEnabled"; + public static final String PREFERENCES_KEY_BOOKMARKS_ENABLED = "bookmarksEnabled"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; -- cgit v1.2.3