diff options
-rw-r--r-- | AndroidManifest.xml | 4 | ||||
-rw-r--r-- | res/layout/abstract_activity.xml | 21 | ||||
-rw-r--r-- | res/menu/chat.xml | 10 | ||||
-rw-r--r-- | res/menu/main.xml | 10 | ||||
-rw-r--r-- | res/menu/nowplaying.xml | 5 | ||||
-rw-r--r-- | res/menu/select_artist.xml | 10 | ||||
-rw-r--r-- | res/menu/select_genres.xml | 10 | ||||
-rw-r--r-- | res/menu/select_playlist.xml | 10 | ||||
-rw-r--r-- | res/menu/select_podcasts.xml | 10 | ||||
-rw-r--r-- | res/values/arrays.xml | 8 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/activity/DownloadActivity.java | 3 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/activity/MainActivity.java | 9 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/activity/SearchActivity.java | 3 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/activity/SubsonicActivity.java | 135 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java | 73 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Constants.java | 1 |
17 files changed, 242 insertions, 82 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index af1d2718..8a64393e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -38,6 +38,9 @@ </intent-filter>
</activity>
+ <activity android:name="github.daneren2005.dsub.activity.SubsonicFragmentActivity"
+ android:configChanges="orientation|keyboardHidden"/>
+
<activity android:name="github.daneren2005.dsub.activity.SearchActivity"
android:label="@string/search.label"
android:configChanges="orientation|keyboardHidden"
@@ -48,7 +51,6 @@ android:launchMode="singleTask"/>
<activity android:name="github.daneren2005.dsub.activity.SettingsActivity"
- android:theme="@style/Theme.DSub.Dark"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask"/>
diff --git a/res/layout/abstract_activity.xml b/res/layout/abstract_activity.xml new file mode 100644 index 00000000..ed16c695 --- /dev/null +++ b/res/layout/abstract_activity.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.DrawerLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <!-- The main content view -->
+ <FrameLayout
+ android:id="@+id/content_frame"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ <!-- The navigation drawer -->
+ <ListView android:id="@+id/left_drawer"
+ android:layout_width="240dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ android:choiceMode="singleChoice"
+ android:divider="@android:color/transparent"
+ android:dividerHeight="0dp"
+ android:background="?android:windowBackground"/>
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file diff --git a/res/menu/chat.xml b/res/menu/chat.xml index 685aba18..67c13587 100644 --- a/res/menu/chat.xml +++ b/res/menu/chat.xml @@ -6,14 +6,4 @@ android:icon="@drawable/action_refresh" android:title="@string/menu.refresh" compat:showAsAction="always|withText"/> - - <item - android:id="@+id/menu_settings" - android:icon="@drawable/action_settings" - android:title="@string/menu.settings"/> - - <item - android:id="@+id/menu_exit" - android:icon="@drawable/action_exit" - android:title="@string/menu.exit"/> </menu>
\ No newline at end of file diff --git a/res/menu/main.xml b/res/menu/main.xml index 1390b68b..213dbf1c 100644 --- a/res/menu/main.xml +++ b/res/menu/main.xml @@ -31,14 +31,4 @@ android:id="@+id/menu_changelog" android:title="@string/changelog_full_title"/> - <item - android:id="@+id/menu_settings" - android:icon="@drawable/action_settings" - android:title="@string/menu.settings"/> - - <item - android:id="@+id/menu_exit" - android:icon="@drawable/action_exit" - android:title="@string/menu.exit"/> - </menu> diff --git a/res/menu/nowplaying.xml b/res/menu/nowplaying.xml index ae411240..6b87dc76 100644 --- a/res/menu/nowplaying.xml +++ b/res/menu/nowplaying.xml @@ -32,9 +32,4 @@ <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/res/menu/select_artist.xml b/res/menu/select_artist.xml index 3c694cd2..2cc04541 100644 --- a/res/menu/select_artist.xml +++ b/res/menu/select_artist.xml @@ -18,14 +18,4 @@ android:icon="@drawable/action_search" android:title="@string/menu.search" compat:showAsAction="ifRoom|withText"/> - - <item - android:id="@+id/menu_settings" - android:icon="@drawable/action_settings" - android:title="@string/menu.settings"/> - - <item - android:id="@+id/menu_exit" - android:icon="@drawable/action_exit" - android:title="@string/menu.exit"/> </menu> diff --git a/res/menu/select_genres.xml b/res/menu/select_genres.xml index 7ce7f1a0..ad2756d6 100644 --- a/res/menu/select_genres.xml +++ b/res/menu/select_genres.xml @@ -6,14 +6,4 @@ android:icon="@drawable/action_refresh" android:title="@string/menu.refresh" compat:showAsAction="always|withText"/> - - <item - android:id="@+id/menu_settings" - android:icon="@drawable/action_settings" - android:title="@string/menu.settings"/> - - <item - android:id="@+id/menu_exit" - android:icon="@drawable/action_exit" - android:title="@string/menu.exit"/> </menu>
\ No newline at end of file diff --git a/res/menu/select_playlist.xml b/res/menu/select_playlist.xml index 4c4cc302..ee134377 100644 --- a/res/menu/select_playlist.xml +++ b/res/menu/select_playlist.xml @@ -12,14 +12,4 @@ android:icon="@drawable/action_search" android:title="@string/menu.search" compat:showAsAction="always|withText"/> - - <item - android:id="@+id/menu_settings" - android:icon="@drawable/action_settings" - android:title="@string/menu.settings"/> - - <item - android:id="@+id/menu_exit" - android:icon="@drawable/action_exit" - android:title="@string/menu.exit"/> </menu> diff --git a/res/menu/select_podcasts.xml b/res/menu/select_podcasts.xml index 6c1ffa07..ce0a2bb6 100644 --- a/res/menu/select_podcasts.xml +++ b/res/menu/select_podcasts.xml @@ -16,14 +16,4 @@ android:id="@+id/menu_check" android:icon="@drawable/action_refresh" android:title="@string/menu.check_podcasts"/> - - <item - android:id="@+id/menu_settings" - android:icon="@drawable/action_settings" - android:title="@string/menu.settings"/> - - <item - android:id="@+id/menu_exit" - android:icon="@drawable/action_exit" - android:title="@string/menu.exit"/> </menu>
\ No newline at end of file diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 4b0d440f..0e856e08 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -1,5 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <resources> + <string-array name="drawerItems"> + <item>@string/button_bar.home</item> + <item>@string/button_bar.podcasts</item> + <item>@string/button_bar.chat</item> + <item>@string/button_bar.now_playing</item> + <item>@string/main.settings</item> + <item>@string/menu.exit</item> + </string-array> <string-array name="themeValues"> <item>light</item> diff --git a/res/values/strings.xml b/res/values/strings.xml index 3721109e..579acf3a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -27,7 +27,7 @@ <string name="button_bar.browse">Library</string>
<string name="button_bar.search">Search</string>
<string name="button_bar.playlists">Playlists</string>
- <string name="button_bar.now_playing">Playing</string>
+ <string name="button_bar.now_playing">Now Playing</string>
<string name="button_bar.podcasts">Podcasts</string>
<string name="button_bar.chat">Chat</string>
diff --git a/src/github/daneren2005/dsub/activity/DownloadActivity.java b/src/github/daneren2005/dsub/activity/DownloadActivity.java index d8ebb98a..262beffe 100644 --- a/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -66,9 +66,6 @@ public class DownloadActivity extends SubsonicActivity { currentFragment.setPrimaryFragment(true); getSupportFragmentManager().beginTransaction().add(R.id.download_container, currentFragment, currentFragment.getSupportTag() + "").commit(); } - - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); } @Override diff --git a/src/github/daneren2005/dsub/activity/MainActivity.java b/src/github/daneren2005/dsub/activity/MainActivity.java index 9dbc2b5e..fca1b1e9 100644 --- a/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/src/github/daneren2005/dsub/activity/MainActivity.java @@ -159,14 +159,7 @@ public class MainActivity extends SubsonicActivity { addTab(R.string.button_bar_home, MainFragment.class, null); addTab(R.string.button_bar_browse, SelectArtistFragment.class, null); addTab(R.string.button_bar_playlists, SelectPlaylistFragment.class, null); - addTab(R.string.button_bar_podcasts, SelectPodcastsFragment.class, null); - SharedPreferences prefs = Util.getPreferences(this); - if(prefs.getBoolean(Constants.PREFERENCES_KEY_CHAT_ENABLED, true)) { - addTab(R.string.button_bar_chat, ChatFragment.class, null); - } - - getSupportActionBar().setDisplayHomeAsUpEnabled(false); - getSupportActionBar().setHomeButtonEnabled(false); + getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } diff --git a/src/github/daneren2005/dsub/activity/SearchActivity.java b/src/github/daneren2005/dsub/activity/SearchActivity.java index 1dfe4790..4e93afb6 100644 --- a/src/github/daneren2005/dsub/activity/SearchActivity.java +++ b/src/github/daneren2005/dsub/activity/SearchActivity.java @@ -41,9 +41,6 @@ public class SearchActivity extends SubsonicActivity { currentFragment.setPrimaryFragment(true); getSupportFragmentManager().beginTransaction().add(R.id.download_container, currentFragment, currentFragment.getSupportTag() + "").commit(); } - - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); } @Override diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index bae3273c..98698d87 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -1,3 +1,21 @@ +/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
package github.daneren2005.dsub.activity;
import android.content.Context;
@@ -7,22 +25,27 @@ import android.media.AudioManager; import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
+import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
+import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
+import android.widget.ListView;
import android.widget.Spinner;
import github.daneren2005.dsub.R;
@@ -48,6 +71,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte protected SubsonicFragment currentFragment;
Spinner actionBarSpinner;
ArrayAdapter<CharSequence> spinnerAdapter;
+ ViewGroup rootView;
+ DrawerLayout drawer;
+ ActionBarDrawerToggle drawerToggle;
+ ListView drawerList;
@Override
protected void onCreate(Bundle bundle) {
@@ -65,6 +92,15 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte actionBarSpinner.setAdapter(spinnerAdapter);
getSupportActionBar().setCustomView(actionbar);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setHomeButtonEnabled(true);
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ drawerToggle.syncState();
}
@Override
@@ -90,6 +126,67 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte super.finish();
Util.disablePendingTransition(this);
}
+
+ @Override
+ public void setContentView(int viewId) {
+ super.setContentView(R.layout.abstract_activity);
+ rootView = (ViewGroup) findViewById(R.id.content_frame);
+ LayoutInflater layoutInflater = getLayoutInflater();
+ layoutInflater.inflate(viewId, rootView);
+
+ String[] drawerListItems = getResources().getStringArray(R.array.drawerItems);
+ drawerList = (ListView) findViewById(R.id.left_drawer);
+ drawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, drawerListItems));
+
+ drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ Intent intent;
+
+ switch(position) {
+ case 0:
+ startActivity(MainActivity.class);
+ break;
+ case 1:
+ startFragmentActivity("Podcast");
+ break;
+ case 2:
+ startFragmentActivity("Chat");
+ break;
+ case 3:
+ startActivity(DownloadActivity.class);
+ break;
+ case 4:
+ startActivity(SettingsActivity.class);
+ break;
+ case 5:
+ exit();
+ break;
+ }
+ }
+ });
+
+ drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
+ drawerToggle = new ActionBarDrawerToggle(this, drawer, R.drawable.ic_drawer, R.string.common_appname, R.string.common_appname) {
+ @Override
+ public void onDrawerClosed(View view) {
+ /*if(pagerAdapter != null) {
+
+ } else {
+ getActionBar().setTitle(currentFragment.getTitle());
+ }*/
+ }
+
+ @Override
+ public void onDrawerOpened(View view) {
+ // getActionBar().setTitle(R.string.common_appname);
+ }
+ };
+ drawer.setDrawerListener(drawerToggle);
+ if(this.getClass() != MainActivity.class) {
+ drawerToggle.setDrawerIndicatorEnabled(false);
+ }
+ }
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
@@ -141,6 +238,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
+ if(drawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+
if(pagerAdapter != null) {
return pagerAdapter.onOptionsItemSelected(item);
} else if(currentFragment != null) {
@@ -194,7 +295,39 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte public void onNothingSelected(AdapterView<?> parent) {
}
-
+
+ public void startActivity(Class t) {
+ Intent intent = new Intent();
+ intent.setClass(SubsonicActivity.this, t);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+ if(this.getClass() != MainActivity.class) {
+ finish();
+ }
+ }
+ public void startFragmentActivity(String fragmentType) {
+ Intent intent = new Intent();
+ intent.setClass(SubsonicActivity.this, SubsonicFragmentActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, fragmentType);
+ startActivity(intent);
+ if(this.getClass() != MainActivity.class) {
+ finish();
+ }
+ }
+
+ protected void exit() {
+ if(this.getClass() != MainActivity.class) {
+ Intent intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
+ Util.startActivityWithoutTransition(this, intent);
+ } else {
+ this.stopService(new Intent(this, DownloadServiceImpl.class));
+ this.finish();
+ }
+ }
+
public boolean onBackPressedSupport() {
if(pagerAdapter != null) {
return pagerAdapter.onBackPressed();
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java new file mode 100644 index 00000000..4d85e9d4 --- /dev/null +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -0,0 +1,73 @@ +/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+package github.daneren2005.dsub.activity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.MenuItem;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.fragments.ChatFragment;
+import github.daneren2005.dsub.fragments.SelectPodcastsFragment;
+import github.daneren2005.dsub.util.Constants;
+
+/**
+ * Created by Scott on 10/14/13.
+ */
+public class SubsonicFragmentActivity extends SubsonicActivity {
+ private static String TAG = SubsonicFragmentActivity.class.getSimpleName();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.download_activity);
+
+ if (findViewById(R.id.download_container) != null && savedInstanceState == null) {
+ String fragmentType = getIntent().getStringExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE);
+ if("Chat".equals(fragmentType)) {
+ currentFragment = new ChatFragment();
+ } else if("Podcast".equals(fragmentType)) {
+ currentFragment = new SelectPodcastsFragment();
+ } else {
+ finish();
+ return;
+ }
+ currentFragment.setPrimaryFragment(true);
+ getSupportFragmentManager().beginTransaction().add(R.id.download_container, currentFragment, currentFragment.getSupportTag() + "").commit();
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if(item.getItemId() == android.R.id.home) {
+ startActivity(MainActivity.class);
+ return true;
+ } else {
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ if(onBackPressedSupport()) {
+ super.onBackPressed();
+ }
+ }
+}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index edc919ae..36ea928c 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -59,6 +59,7 @@ public final class Constants { public static final String INTENT_EXTRA_NAME_PODCAST_ID = "subsonic.podcast.id"; public static final String INTENT_EXTRA_NAME_PODCAST_NAME = "subsonic.podcast.name"; public static final String INTENT_EXTRA_NAME_PODCAST_DESCRIPTION = "subsonic.podcast.description"; + public static final String INTENT_EXTRA_FRAGMENT_TYPE = "fragmentType"; // Notification IDs. public static final int NOTIFICATION_ID_PLAYING = 100; |