aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/androidTest/java/github/daneren2005/dsub/activity/DownloadActivityTest.java32
-rw-r--r--app/src/androidTest/java/github/daneren2005/dsub/domain/BookmarkTest.java2
-rw-r--r--app/src/main/AndroidManifest.xml2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java1
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java294
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java87
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/DrawerAdapter.java126
-rw-r--r--app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java36
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java42
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java7
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java28
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Constants.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java11
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Notifications.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java24
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java4
-rw-r--r--app/src/main/res/layout/abstract_activity.xml15
-rw-r--r--app/src/main/res/layout/drawer_header.xml52
-rw-r--r--app/src/main/res/layout/drawer_list_item.xml27
-rw-r--r--app/src/main/res/menu/drawer_navigation.xml51
-rw-r--r--app/src/main/res/values/arrays.xml39
-rw-r--r--app/src/main/res/values/attrs.xml10
-rw-r--r--app/src/main/res/values/themes.xml26
-rw-r--r--app/src/main/res/xml/changelog.xml8
26 files changed, 457 insertions, 476 deletions
diff --git a/app/src/androidTest/java/github/daneren2005/dsub/activity/DownloadActivityTest.java b/app/src/androidTest/java/github/daneren2005/dsub/activity/DownloadActivityTest.java
deleted file mode 100644
index ce859181..00000000
--- a/app/src/androidTest/java/github/daneren2005/dsub/activity/DownloadActivityTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package github.daneren2005.dsub.activity;
-
-import github.daneren2005.dsub.R;
-import android.test.*;
-import android.view.View;
-
-public class DownloadActivityTest extends
- ActivityInstrumentationTestCase2<DownloadActivity> {
-
- private DownloadActivity activity;
-
- public DownloadActivityTest() {
- super(DownloadActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- activity = getActivity();
- }
-
- /**
- * Test the main layout.
- */
- public void testLayout() {
- View view = activity.findViewById(R.layout.download_activity);
- assertNotNull(view);
- assertNotNull(view.findViewById(R.layout.download_activity));
- assertNotNull(activity.findViewById(R.id.fragment_container));
- }
-
-}
diff --git a/app/src/androidTest/java/github/daneren2005/dsub/domain/BookmarkTest.java b/app/src/androidTest/java/github/daneren2005/dsub/domain/BookmarkTest.java
index 814f658a..30663543 100644
--- a/app/src/androidTest/java/github/daneren2005/dsub/domain/BookmarkTest.java
+++ b/app/src/androidTest/java/github/daneren2005/dsub/domain/BookmarkTest.java
@@ -15,7 +15,7 @@ public class BookmarkTest extends TestCase {
*/
public void testSetCreated() throws ParseException {
Bookmark bookmark = new Bookmark();
- bookmark.setCreated(null);
+ bookmark.setCreated((String) null);
assertEquals(null, bookmark.getCreated());
bookmark.setCreated("");
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8eeaab2e..2b3a5fbc 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,7 +3,7 @@
package="github.daneren2005.dsub"
android:installLocation="internalOnly"
android:versionCode="152"
- android:versionName="4.9.6">
+ android:versionName="4.9.7">
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="github.daneren2005.dsub"
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java
index d5ac60d3..babc9d48 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -73,6 +73,7 @@ public class SettingsActivity extends SubsonicActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ lastSelectedPosition = R.id.drawer_settings;
setContentView(R.layout.download_activity);
if (savedInstanceState == null) {
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
index cb09728c..d730b412 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -25,11 +25,11 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
-import android.content.res.TypedArray;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
+import android.support.design.widget.NavigationView;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
@@ -52,14 +52,12 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
-import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import github.daneren2005.dsub.R;
@@ -71,7 +69,6 @@ import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.Util;
-import github.daneren2005.dsub.adapter.DrawerAdapter;
import github.daneren2005.dsub.view.UpdateView;
import github.daneren2005.dsub.util.UserUtil;
@@ -80,10 +77,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
private static ImageLoader IMAGE_LOADER;
protected static String theme;
protected static boolean fullScreen;
- private String[] drawerItemsDescriptions;
- private String[] drawerItems;
+ private static final int MENU_GROUP_SERVER = 10;
+ private static final int MENU_ITEM_SERVER_BASE = 100;
+
private boolean drawerIdle = true;
- private boolean[] enabledItems = {true, true, true, true, true};
private boolean destroyed = false;
private boolean finished = false;
protected List<SubsonicFragment> backStack = new ArrayList<SubsonicFragment>();
@@ -97,15 +94,15 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
ViewGroup rootView;
DrawerLayout drawer;
ActionBarDrawerToggle drawerToggle;
- DrawerAdapter drawerAdapter;
- ListView drawerList;
+ NavigationView drawerList;
View drawerHeader;
ImageView drawerUserAvatar;
TextView drawerServerName;
TextView drawerUserName;
- TextView lastSelectedView = null;
int lastSelectedPosition = 0;
+ boolean showingTabs = true;
boolean drawerOpen = false;
+ SharedPreferences.OnSharedPreferenceChangeListener preferencesListener;
@Override
protected void onCreate(Bundle bundle) {
@@ -128,6 +125,33 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(getIntent().hasExtra(Constants.FRAGMENT_POSITION)) {
lastSelectedPosition = getIntent().getIntExtra(Constants.FRAGMENT_POSITION, 0);
}
+
+ if(preferencesListener == null) {
+ preferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ // When changing drawer settings change visibility
+ switch(key) {
+ case Constants.PREFERENCES_KEY_PODCASTS_ENABLED:
+ setDrawerItemVisible(R.id.drawer_podcasts, false);
+ break;
+ case Constants.PREFERENCES_KEY_BOOKMARKS_ENABLED:
+ setDrawerItemVisible(R.id.drawer_bookmarks, false);
+ break;
+ case Constants.PREFERENCES_KEY_SHARED_ENABLED:
+ setDrawerItemVisible(R.id.drawer_shares, false);
+ break;
+ case Constants.PREFERENCES_KEY_CHAT_ENABLED:
+ setDrawerItemVisible(R.id.drawer_chat, false);
+ break;
+ case Constants.PREFERENCES_KEY_ADMIN_ENABLED:
+ setDrawerItemVisible(R.id.drawer_admin, false);
+ break;
+ }
+ }
+ };
+ Util.getPreferences(this).registerOnSharedPreferenceChangeListener(preferencesListener);
+ }
}
@Override
@@ -174,7 +198,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
- populateDrawer();
+ populateTabs();
UpdateView.addActiveActivity();
}
@@ -189,6 +213,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
protected void onDestroy() {
super.onDestroy();
destroyed = true;
+ Util.getPreferences(this).unregisterOnSharedPreferenceChangeListener(preferencesListener);
}
@Override
@@ -198,19 +223,6 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
}
@Override
- public void startActivity(Intent intent) {
- if(intent.getComponent() != null) {
- String name = intent.getComponent().getClassName();
- if(name != null && name.indexOf("DownloadActivity") != -1) {
- intent.putExtra(Constants.FRAGMENT_POSITION, lastSelectedPosition);
- } else if(name != null && name.indexOf("SettingsActivity") != -1) {
- intent.putExtra(Constants.FRAGMENT_POSITION, drawerItems.length - 1);
- }
- }
- super.startActivity(intent);
- }
-
- @Override
public void setContentView(int viewId) {
if(isTv()) {
super.setContentView(R.layout.static_drawer_activity);
@@ -224,34 +236,88 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
layoutInflater.inflate(viewId, rootView);
}
- drawerList = (ListView) findViewById(R.id.left_drawer);
- drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
+ drawerList = (NavigationView) findViewById(R.id.left_drawer);
+ drawerList.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
- public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) {
- final int actualPosition = drawerAdapter.getActualPosition(position - 1);
- if("Settings".equals(drawerItemsDescriptions[actualPosition])) {
- startActivity(new Intent(SubsonicActivity.this, SettingsActivity.class));
- drawer.closeDrawers();
- } else if("Admin".equals(drawerItemsDescriptions[actualPosition]) && UserUtil.isCurrentAdmin()) {
- UserUtil.confirmCredentials(SubsonicActivity.this, new Runnable() {
- @Override
- public void run() {
- drawerItemSelected(actualPosition, view);
- }
- });
+ public boolean onNavigationItemSelected(MenuItem menuItem) {
+ if(showingTabs) {
+ // Settings are on a different selectable track
+ if (menuItem.getItemId() != R.id.drawer_settings) {
+ menuItem.setChecked(true);
+ }
+ lastSelectedPosition = menuItem.getItemId();
+
+ switch (menuItem.getItemId()) {
+ case R.id.drawer_home:
+ drawerItemSelected("Home");
+ return true;
+ case R.id.drawer_library:
+ drawerItemSelected("Artist");
+ return true;
+ case R.id.drawer_playlists:
+ drawerItemSelected("Playlist");
+ return true;
+ case R.id.drawer_podcasts:
+ drawerItemSelected("Podcast");
+ return true;
+ case R.id.drawer_bookmarks:
+ drawerItemSelected("Bookmark");
+ return true;
+ case R.id.drawer_shares:
+ drawerItemSelected("Share");
+ return true;
+ case R.id.drawer_chat:
+ drawerItemSelected("Chat");
+ return true;
+ case R.id.drawer_admin:
+ if (UserUtil.isCurrentAdmin()) {
+ UserUtil.confirmCredentials(SubsonicActivity.this, new Runnable() {
+ @Override
+ public void run() {
+ drawerItemSelected("Admin");
+ }
+ });
+ } else {
+ drawerItemSelected("Admin");
+ }
+ return true;
+ case R.id.drawer_downloading:
+ drawerItemSelected("Download");
+ return true;
+ case R.id.drawer_settings:
+ startActivity(new Intent(SubsonicActivity.this, SettingsActivity.class));
+ drawer.closeDrawers();
+ return true;
+ }
} else {
- drawerItemSelected(actualPosition, view);
+ int activeServer = menuItem.getItemId() - MENU_ITEM_SERVER_BASE;
+ SubsonicActivity.this.setActiveServer(activeServer);
+ populateTabs();
+ return true;
+ }
+
+ return false;
+ }
+ });
+ populateTabs();
+
+ drawerHeader = drawerList.inflateHeaderView(R.layout.drawer_header);
+ drawerHeader.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if(showingTabs) {
+ populateServers();
+ } else {
+ populateTabs();
}
}
});
- drawerHeader = getLayoutInflater().inflate(R.layout.drawer_header, drawerList, false);
drawerServerName = (TextView) drawerHeader.findViewById(R.id.header_server_name);
drawerUserName = (TextView) drawerHeader.findViewById(R.id.header_user_name);
drawerUserAvatar = (ImageView) drawerHeader.findViewById(R.id.header_user_avatar);
updateDrawerHeader();
- drawerList.addHeaderView(drawerHeader, null, false);
if(!isTv()) {
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
@@ -265,23 +331,19 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
drawerOpen = false;
supportInvalidateOptionsMenu();
+ if(!showingTabs) {
+ populateTabs();
+ }
}
@Override
public void onDrawerOpened(View view) {
DownloadService downloadService = getDownloadService();
- if (downloadService == null || downloadService.getBackgroundDownloads().isEmpty()) {
- drawerAdapter.setDownloadVisible(false);
- } else {
- drawerAdapter.setDownloadVisible(true);
- }
-
- if (lastSelectedView == null && drawerList.getCount() > lastSelectedPosition) {
- lastSelectedView = (TextView) drawerList.getChildAt(lastSelectedPosition + 1).findViewById(R.id.drawer_name);
- if (lastSelectedView != null) {
- lastSelectedView.setTextAppearance(SubsonicActivity.this, R.style.DSub_TextViewStyle_Bold);
- }
+ boolean downloadingVisible = downloadService != null && !downloadService.getBackgroundDownloads().isEmpty();
+ if(lastSelectedPosition == R.id.drawer_downloading) {
+ downloadingVisible = true;
}
+ setDrawerItemVisible(R.id.drawer_downloading, downloadingVisible);
getSupportActionBar().setTitle(R.string.common_appname);
getSupportActionBar().setDisplayShowCustomEnabled(false);
@@ -382,6 +444,12 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
}
lastSelectedPosition = savedInstanceState.getInt(Constants.FRAGMENT_POSITION);
+ if(lastSelectedPosition != 0) {
+ MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition);
+ if(item != null) {
+ item.setChecked(true);
+ }
+ }
recreateSpinner();
}
@@ -462,7 +530,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
}
- private void populateDrawer() {
+ private void populateTabs() {
+ drawerList.getMenu().clear();
+ drawerList.inflateMenu(R.menu.drawer_navigation);
+
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) && !Util.isOffline(this) && ServerInfo.canBookmark(this);
@@ -470,88 +541,56 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
boolean chatEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_CHAT_ENABLED, true) && !Util.isOffline(this);
boolean adminEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_ADMIN_ENABLED, true) && !Util.isOffline(this);
- if(drawerItems == null || !enabledItems[0] == podcastsEnabled || !enabledItems[1] == bookmarksEnabled || !enabledItems[2] == sharedEnabled || !enabledItems[3] == chatEnabled || !enabledItems[4] == adminEnabled) {
- drawerItems = getResources().getStringArray(R.array.drawerItems);
- drawerItemsDescriptions = getResources().getStringArray(R.array.drawerItemsDescriptions);
-
- List<String> drawerItemsList = new ArrayList<String>(Arrays.asList(drawerItems));
- List<Integer> drawerItemsIconsList = new ArrayList<Integer>();
- List<Boolean> drawerItemsVisibleList = new ArrayList<Boolean>();
-
- int[] arrayAttr = {R.attr.drawerItemsIcons};
- TypedArray arrayType = obtainStyledAttributes(arrayAttr);
- int arrayId = arrayType.getResourceId(0, 0);
- TypedArray iconType = getResources().obtainTypedArray(arrayId);
- for(int i = 0; i < drawerItemsList.size(); i++) {
- drawerItemsIconsList.add(iconType.getResourceId(i, 0));
- drawerItemsVisibleList.add(true);
- }
- iconType.recycle();
- arrayType.recycle();
-
- // Hide listings user doesn't want to see
- if(!podcastsEnabled) {
- drawerItemsVisibleList.set(3, false);
- }
- if(!bookmarksEnabled) {
- drawerItemsVisibleList.set(4, false);
- }
- if(!sharedEnabled) {
- drawerItemsVisibleList.set(5, false);
- }
- if(!chatEnabled) {
- drawerItemsVisibleList.set(6, false);
- }
- if(!adminEnabled) {
- drawerItemsVisibleList.set(7, false);
- }
- if(!getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW)) {
- drawerItemsVisibleList.set(8, false);
- }
-
- drawerList.setAdapter(drawerAdapter = new DrawerAdapter(this, drawerItemsList, drawerItemsIconsList, drawerItemsVisibleList));
- enabledItems[0] = podcastsEnabled;
- enabledItems[1] = bookmarksEnabled;
- enabledItems[2] = sharedEnabled;
- enabledItems[3] = chatEnabled;
- enabledItems[4] = adminEnabled;
-
- String fragmentType = getIntent().getStringExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE);
- if(fragmentType != null && lastSelectedPosition == 0) {
- for(int i = 0; i < drawerItemsDescriptions.length; i++) {
- if(fragmentType.equals(drawerItemsDescriptions[i])) {
- lastSelectedPosition = drawerAdapter.getAdapterPosition(i);
- break;
- }
- }
- }
+ if(!podcastsEnabled) {
+ setDrawerItemVisible(R.id.drawer_podcasts, false);
+ }
+ if(!bookmarksEnabled) {
+ setDrawerItemVisible(R.id.drawer_bookmarks, false);
+ }
+ if(!sharedEnabled) {
+ setDrawerItemVisible(R.id.drawer_shares, false);
+ }
+ if(!chatEnabled) {
+ setDrawerItemVisible(R.id.drawer_chat, false);
+ }
+ if(!adminEnabled) {
+ setDrawerItemVisible(R.id.drawer_admin, false);
+ }
- if(drawerList.getChildAt(lastSelectedPosition + 1) == null) {
- lastSelectedView = null;
- drawerAdapter.setSelectedPosition(lastSelectedPosition);
- } else {
- lastSelectedView = (TextView) drawerList.getChildAt(lastSelectedPosition + 1).findViewById(R.id.drawer_name);
- if(lastSelectedView != null) {
- lastSelectedView.setTextAppearance(SubsonicActivity.this, R.style.DSub_TextViewStyle_Bold);
- }
+ if(lastSelectedPosition != 0) {
+ MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition);
+ if(item != null) {
+ item.setChecked(true);
}
}
+ showingTabs = true;
}
+ private void populateServers() {
+ drawerList.getMenu().clear();
- protected void drawerItemSelected(int position, View view) {
- startFragmentActivity(drawerItemsDescriptions[position]);
-
- if(lastSelectedView != view) {
- if(lastSelectedView != null) {
- lastSelectedView.setTextAppearance(this, R.style.DSub_TextViewStyle);
+ int serverCount = Util.getServerCount(this);
+ int activeServer = Util.getActiveServer(this);
+ for(int i = 1; i <= serverCount; i++) {
+ MenuItem item = drawerList.getMenu().add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_BASE + i, MENU_ITEM_SERVER_BASE + i, Util.getServerName(this, i));
+ if(activeServer == i) {
+ item.setChecked(true);
}
+ }
+ drawerList.getMenu().setGroupCheckable(MENU_GROUP_SERVER, true, true);
- lastSelectedView = (TextView) view.findViewById(R.id.drawer_name);
- lastSelectedView.setTextAppearance(this, R.style.DSub_TextViewStyle_Bold);
- lastSelectedPosition = position;
+ showingTabs = false;
+ }
+ private void setDrawerItemVisible(int id, boolean visible) {
+ MenuItem item = drawerList.getMenu().findItem(id);
+ if(item != null) {
+ item.setVisible(visible);
}
}
+ protected void drawerItemSelected(String fragmentType) {
+ startFragmentActivity(fragmentType);
+ }
+
public void startFragmentActivity(String fragmentType) {
Intent intent = new Intent();
intent.setClass(SubsonicActivity.this, SubsonicFragmentActivity.class);
@@ -559,6 +598,9 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(!"".equals(fragmentType)) {
intent.putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, fragmentType);
}
+ if(lastSelectedPosition != 0) {
+ intent.putExtra(Constants.FRAGMENT_POSITION, lastSelectedPosition);
+ }
startActivity(intent);
finish();
}
@@ -719,7 +761,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
}
currentFragment.invalidate();
- populateDrawer();
+ populateTabs();
}
supportInvalidateOptionsMenu();
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index 774a8def..08930ae7 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -30,6 +30,7 @@ import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
+import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.util.Log;
@@ -111,9 +112,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
getImageLoader().clearCache();
} else if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW)) {
getIntent().putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, "Download");
- if(drawerAdapter != null) {
- drawerAdapter.setDownloadVisible(true);
- }
+ lastSelectedPosition = R.id.drawer_downloading;
}
setContentView(R.layout.abstract_fragment_activity);
@@ -126,6 +125,37 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
if(fragmentType != null) {
getIntent().putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, fragmentType);
firstRun = true;
+
+ switch(fragmentType) {
+ case "Home":
+ lastSelectedPosition = R.id.drawer_home;
+ break;
+ case "Artist":
+ lastSelectedPosition = R.id.drawer_library;
+ break;
+ case "Playlist":
+ lastSelectedPosition = R.id.drawer_playlists;
+ break;
+ case "Podcast":
+ lastSelectedPosition = R.id.drawer_podcasts;
+ break;
+ case "Bookmark":
+ lastSelectedPosition = R.id.drawer_bookmarks;
+ break;
+ case "Share":
+ lastSelectedPosition = R.id.drawer_shares;
+ break;
+ case "Chat":
+ lastSelectedPosition = R.id.drawer_chat;
+ break;
+ }
+ } else {
+ lastSelectedPosition = R.id.drawer_home;
+ }
+
+ MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition);
+ if(item != null) {
+ item.setChecked(true);
}
}
currentFragment = getNewFragment(fragmentType);
@@ -230,10 +260,12 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
setSupportActionBar(mainToolbar);
- nowPlayingFragment = new NowPlayingFragment();
- FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
- trans.add(R.id.now_playing_fragment_container, nowPlayingFragment, nowPlayingFragment.getTag() + "");
- trans.commit();
+ if (findViewById(R.id.fragment_container) != null && savedInstanceState == null) {
+ nowPlayingFragment = new NowPlayingFragment();
+ FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+ trans.add(R.id.now_playing_fragment_container, nowPlayingFragment, nowPlayingFragment.getTag() + "");
+ trans.commit();
+ }
ImageButton previousButton = (ImageButton) findViewById(R.id.download_previous);
previousButton.setOnClickListener(new View.OnClickListener() {
@@ -391,9 +423,6 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
replaceFragment(fragment, fragment.getSupportTag());
getIntent().removeExtra(Constants.INTENT_EXTRA_VIEW_ALBUM);
- if("Artist".equals(getIntent().getStringExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE))) {
- lastSelectedPosition = 1;
- }
}
createAccount();
@@ -409,8 +438,17 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
}
@Override
+ public void onSaveInstanceState(Bundle savedInstanceState) {
+ super.onSaveInstanceState(savedInstanceState);
+ savedInstanceState.putString(Constants.MAIN_NOW_PLAYING, nowPlayingFragment.getTag());
+ }
+ @Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
+
+ String id = savedInstanceState.getString(Constants.MAIN_NOW_PLAYING);
+ FragmentManager fm = getSupportFragmentManager();
+ nowPlayingFragment = (NowPlayingFragment) fm.findFragmentByTag(id);
if(drawerToggle != null && backStack.size() > 0) {
drawerToggle.setDrawerIndicatorEnabled(false);
}
@@ -468,8 +506,8 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
}
@Override
- protected void drawerItemSelected(int position, View view) {
- super.drawerItemSelected(position, view);
+ protected void drawerItemSelected(String fragmentType) {
+ super.drawerItemSelected(fragmentType);
if(slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
slideUpPanel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
@@ -565,19 +603,22 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
artistView.setText(R.string.main_artist);
}
- SilentBackgroundTask task = getImageLoader().loadImage(coverArtView, song, false, coverArtView.getHeight(), false);
- if(slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
- if(task == null) {
- getSupportActionBar().setHomeAsUpIndicator(coverArtView.getDrawable());
- } else {
- task.setOnCompletionListener(new Runnable() {
- @Override
- public void run() {
- getSupportActionBar().setHomeAsUpIndicator(coverArtView.getDrawable());
- }
- });
+ if(coverArtView != null && coverArtView.getHeight() != 0) {
+ SilentBackgroundTask task = getImageLoader().loadImage(coverArtView, song, false, coverArtView.getHeight(), false);
+ if (slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
+ if (task == null) {
+ getSupportActionBar().setHomeAsUpIndicator(coverArtView.getDrawable());
+ } else {
+ task.setOnCompletionListener(new Runnable() {
+ @Override
+ public void run() {
+ getSupportActionBar().setHomeAsUpIndicator(coverArtView.getDrawable());
+ }
+ });
+ }
}
}
+
int[] attrs = new int[] {(state == PlayerState.STARTED) ? R.attr.media_button_pause : R.attr.media_button_start};
TypedArray typedArray = this.obtainStyledAttributes(attrs);
startButton.setImageResource(typedArray.getResourceId(0, 0));
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/DrawerAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/DrawerAdapter.java
deleted file mode 100644
index b0a4a33d..00000000
--- a/app/src/main/java/github/daneren2005/dsub/adapter/DrawerAdapter.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- 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.adapter;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import java.util.List;
-
-import github.daneren2005.dsub.R;
-
-/**
- * Created by Scott on 11/8/13.
- */
-public class DrawerAdapter extends ArrayAdapter<String> {
- private static String TAG = DrawerAdapter.class.getSimpleName();
- private Context context;
- private List<String> items;
- private List<Integer> icons;
- private List<Boolean> visible;
- private int selectedPosition = -1;
-
- public DrawerAdapter(Context context, List<String> items, List<Integer> icons, List<Boolean> visible) {
- super(context, R.layout.drawer_list_item, items);
-
- this.context = context;
- this.items = items;
- this.icons = icons;
- this.visible = visible;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- position = getActualPosition(position);
- String item = items.get(position);
- Integer icon = icons.get(position);
-
- if(convertView == null) {
- convertView = LayoutInflater.from(context).inflate(R.layout.drawer_list_item, null);
- }
-
- TextView textView = (TextView) convertView.findViewById(R.id.drawer_name);
- textView.setText(item);
-
- if(selectedPosition == position) {
- textView.setTextAppearance(context, R.style.DSub_TextViewStyle_Bold);
- selectedPosition = -1;
- }
-
- ImageView iconView = (ImageView) convertView.findViewById(R.id.drawer_icon);
- iconView.setImageResource(icon);
-
- return convertView;
- }
-
- @Override
- public int getCount() {
- int count = 0;
- for(int i = 0; i < visible.size(); i++) {
- if(visible.get(i)) {
- count++;
- }
- }
-
- return count;
- }
-
- public int getActualPosition(int position) {
- for(int i = 0; i <= position; i++) {
- if(!visible.get(i)) {
- position++;
- }
- }
-
- return position;
- }
- public int getAdapterPosition(int position) {
- if(!visible.get(position)) {
- visible.set(position, true);
- notifyDataSetChanged();
- }
-
- for(int i = position; i >= 0; i--) {
- if(!visible.get(i)) {
- position--;
- }
- }
-
- return position;
- }
-
- public void setItemVisible(int position, boolean visible) {
- if(this.visible.get(position) != visible) {
- this.visible.set(position, visible);
- notifyDataSetInvalidated();
- }
- }
- public void setDownloadVisible(boolean visible) {
- setItemVisible(items.size() - 2, visible);
- }
-
- public void setSelectedPosition(int position) {
- selectedPosition = position;
- }
-}
diff --git a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
index 3ece6af9..07a86db4 100644
--- a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
+++ b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
@@ -208,6 +208,6 @@ public class ServerInfo implements Serializable {
}
public static boolean canAlbumListPerFolder(Context context) {
- return ServerInfo.checkServerVersion(context, "1.11") && !ServerInfo.isMadsonic(context);
+ return ServerInfo.checkServerVersion(context, "1.11") && !ServerInfo.isMadsonic(context) && !Util.isTagBrowsing(context);
}
}
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java
index b7080a8e..ea61f2c7 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/EqualizerFragment.java
@@ -274,11 +274,15 @@ public class EqualizerFragment extends SubsonicFragment {
bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- short level = (short) (progress + minEQLevel);
- if (fromUser) {
- equalizer.setBandLevel(band, (short)(level + masterLevel));
+ try {
+ short level = (short) (progress + minEQLevel);
+ if (fromUser) {
+ equalizer.setBandLevel(band, (short) (level + masterLevel));
+ }
+ updateLevelText(levelTextView, level);
+ } catch(Exception e) {
+ Log.e(TAG, "Failed to change equalizer", e);
}
- updateLevelText(levelTextView, level);
}
@Override
@@ -410,18 +414,22 @@ public class EqualizerFragment extends SubsonicFragment {
bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- masterLevel = (short) (progress + minEQLevel);
- if (fromUser) {
- SharedPreferences prefs = Util.getPreferences(context);
- SharedPreferences.Editor editor = prefs.edit();
- editor.putInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, masterLevel);
- editor.commit();
- for (short i = 0; i < equalizer.getNumberOfBands(); i++) {
- short level = (short) ((bars.get(i).getProgress() + minEQLevel) + masterLevel);
- equalizer.setBandLevel(i, level);
+ try {
+ masterLevel = (short) (progress + minEQLevel);
+ if (fromUser) {
+ SharedPreferences prefs = Util.getPreferences(context);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, masterLevel);
+ editor.commit();
+ for (short i = 0; i < equalizer.getNumberOfBands(); i++) {
+ short level = (short) ((bars.get(i).getProgress() + minEQLevel) + masterLevel);
+ equalizer.setBandLevel(i, level);
+ }
}
+ updateLevelText(levelTextView, masterLevel);
+ } catch(Exception e) {
+ Log.e(TAG, "Failed to change equalizer", e);
}
- updateLevelText(levelTextView, masterLevel);
}
@Override
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
index 71c135aa..0c33ef8c 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
@@ -116,35 +116,6 @@ public class MainFragment extends SubsonicFragment {
}
@Override
- public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, view, menuInfo);
-
- int serverCount = Util.getServerCount(context);
- int activeServer = Util.getActiveServer(context);
- for(int i = 1; i <= serverCount; i++) {
- android.view.MenuItem menuItem = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_BASE + i, MENU_ITEM_SERVER_BASE + i, Util.getServerName(context, i));
- if(i == activeServer) {
- menuItem.setChecked(true);
- }
- }
- menu.setGroupCheckable(MENU_GROUP_SERVER, true, true);
- menu.setHeaderTitle(R.string.main_select_server);
-
- recreateContextMenu(menu);
- }
-
- @Override
- public boolean onContextItemSelected(android.view.MenuItem menuItem) {
- if(menuItem.getGroupId() != getSupportTag()) {
- return false;
- }
-
- int activeServer = menuItem.getItemId() - MENU_ITEM_SERVER_BASE;
- context.setActiveServer(activeServer);
- return true;
- }
-
- @Override
protected void refresh(boolean refresh) {
createLayout();
}
@@ -152,8 +123,6 @@ public class MainFragment extends SubsonicFragment {
private void createLayout() {
View buttons = inflater.inflate(R.layout.main_buttons, null);
- final View serverButton = buttons.findViewById(R.id.main_select_server);
- final TextView serverTextView = (TextView) serverButton.findViewById(R.id.main_select_server_2);
final TextView offlineButton = (TextView) buttons.findViewById(R.id.main_offline);
offlineButton.setText(Util.isOffline(context) ? R.string.main_online : R.string.main_offline);
@@ -171,8 +140,6 @@ public class MainFragment extends SubsonicFragment {
final View albumsAlphabeticalButton = buttons.findViewById(R.id.main_albums_alphabetical);
final View videosButton = buttons.findViewById(R.id.main_videos);
- final View dummyView = rootView.findViewById(R.id.main_dummy);
-
final CheckBox albumsPerFolderCheckbox = (CheckBox) buttons.findViewById(R.id.main_albums_per_folder);
if(!Util.isOffline(context) && ServerInfo.canAlbumListPerFolder(context)) {
albumsPerFolderCheckbox.setChecked(Util.getAlbumListsPerFolder(context));
@@ -188,14 +155,10 @@ public class MainFragment extends SubsonicFragment {
int instance = Util.getActiveServer(context);
String name = Util.getServerName(context, instance);
- serverTextView.setText(name);
ListView list = (ListView) rootView.findViewById(R.id.main_list);
MergeAdapter adapter = new MergeAdapter();
- if (!Util.isOffline(context)) {
- adapter.addViews(Arrays.asList(serverButton), true);
- }
adapter.addView(offlineButton, true);
if (!Util.isOffline(context)) {
adapter.addView(albumsTitle, false);
@@ -213,14 +176,11 @@ public class MainFragment extends SubsonicFragment {
}
}
list.setAdapter(adapter);
- registerForContextMenu(dummyView);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- if (view == serverButton) {
- dummyView.showContextMenu();
- } else if (view == offlineButton) {
+ if (view == offlineButton) {
toggleOffline();
} else if (view == albumsNewestButton) {
showAlbumList("newest");
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index 6f325a4e..b9ef412c 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -573,9 +573,10 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
if(equalizerAvailable && !downloadService.isRemoteEnabled()) {
SharedPreferences prefs = Util.getPreferences(context);
boolean equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false);
- if (equalizerOn && getDownloadService() != null && getDownloadService().getEqualizerController() != null &&
- getDownloadService().getEqualizerController().isEnabled()) {
- menu.findItem(R.id.menu_equalizer).setChecked(true);
+ if (equalizerOn && downloadService != null) {
+ if(downloadService.getEqualizerController() != null && downloadService.getEqualizerController().isEnabled()) {
+ menu.findItem(R.id.menu_equalizer).setChecked(true);
+ }
}
} else {
menu.removeItem(R.id.menu_equalizer);
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index c1f8870e..c0268933 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -42,6 +42,7 @@ import github.daneren2005.dsub.domain.RepeatMode;
import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver;
import github.daneren2005.dsub.util.ArtistRadioBuffer;
+import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.Notifications;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.Constants;
@@ -174,7 +175,27 @@ public class DownloadService extends Service {
mediaPlayer = new MediaPlayer();
mediaPlayer.setWakeMode(DownloadService.this, PowerManager.PARTIAL_WAKE_LOCK);
- mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
+
+ audioSessionId = -1;
+ Integer id = prefs.getInt(Constants.CACHE_AUDIO_SESSION_ID, -1);
+ if(id != -1) {
+ try {
+ audioSessionId = id;
+ mediaPlayer.setAudioSessionId(audioSessionId);
+ } catch (Throwable e) {
+ audioSessionId = -1;
+ }
+ }
+
+ if(audioSessionId == -1) {
+ mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
+ try {
+ audioSessionId = mediaPlayer.getAudioSessionId();
+ prefs.edit().putInt(Constants.CACHE_AUDIO_SESSION_ID, audioSessionId).commit();
+ } catch (Throwable t) {
+ // Froyo or lower
+ }
+ }
mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
@@ -183,11 +204,6 @@ public class DownloadService extends Service {
return false;
}
});
- try {
- audioSessionId = mediaPlayer.getAudioSessionId();
- } catch(Throwable e) {
- // Froyo or lower
- }
try {
Intent i = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index c9f92f41..64da9a13 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -366,7 +366,7 @@ public class DownloadServiceLifecycleSupport {
}
private void handleKeyEvent(KeyEvent event) {
- if(event.getAction() == KeyEvent.ACTION_DOWN) {
+ if(event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
switch (event.getKeyCode()) {
case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
index 31c5bef2..6252d0e4 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
@@ -168,9 +168,11 @@ public final class Constants {
public static final String OFFLINE_STAR_SETTING = "starSetting";
public static final String CACHE_KEY_IGNORE = "ignoreArticles";
+ public static final String CACHE_AUDIO_SESSION_ID = "audioSessionId";
public static final String MAIN_BACK_STACK = "backStackIds";
public static final String MAIN_BACK_STACK_SIZE = "backStackIdsSize";
+ public static final String MAIN_NOW_PLAYING = "nowPlayingId";
public static final String FRAGMENT_LIST = "fragmentList";
public static final String FRAGMENT_LIST2 = "fragmentList2";
public static final String FRAGMENT_EXTRA = "fragmentExtra";
diff --git a/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java b/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java
index 54b4085d..a770fbb1 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java
@@ -88,10 +88,8 @@ public class ImageLoader {
@Override
protected void entryRemoved(boolean evicted, String key, Bitmap oldBitmap, Bitmap newBitmap) {
if(evicted) {
- if(oldBitmap != nowPlaying && key.indexOf("unknown") != 0 || clearingCache) {
- if(sizeOf("", oldBitmap) > 500) {
- oldBitmap.recycle();
- }
+ if(oldBitmap != nowPlaying || clearingCache) {
+ oldBitmap.recycle();
} else {
cache.put(key, oldBitmap);
}
@@ -279,6 +277,11 @@ public class ImageLoader {
}
public SilentBackgroundTask<Void> loadAvatar(Context context, ImageView view, String username) {
+ if(username == null) {
+ view.setImageResource(R.drawable.ic_social_person);
+ return null;
+ }
+
Bitmap bitmap = cache.get(username);
if (bitmap != null && !bitmap.isRecycled()) {
Drawable drawable = Util.createDrawableFromBitmap(this.context, bitmap);
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java
index d078d77e..c7b6986e 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java
@@ -260,10 +260,9 @@ public final class Notifications {
cancelPI);
Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class);
- notificationIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, true);
notificationIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW, true);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- builder.setContentIntent(PendingIntent.getActivity(context, 1, notificationIntent, 0));
+ builder.setContentIntent(PendingIntent.getActivity(context, 2, notificationIntent, 0));
final Notification notification = builder.build();
downloadShowing = true;
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
index 50283da6..46b6b47d 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
@@ -42,17 +42,27 @@ public class RemoteControlClientICS extends RemoteControlClientHelper {
}
public void unregister(final Context context) {
- if (mRemoteControl != null) {
- AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
- audioManager.unregisterRemoteControlClient(mRemoteControl);
+ if(mRemoteControl == null) {
+ return;
}
+
+ AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+ audioManager.unregisterRemoteControlClient(mRemoteControl);
}
public void setPlaybackState(final int state) {
+ if(mRemoteControl == null) {
+ return;
+ }
+
mRemoteControl.setPlaybackState(state);
}
public void updateMetadata(final Context context, final MusicDirectory.Entry currentSong) {
+ if(mRemoteControl == null) {
+ return;
+ }
+
if(imageLoader == null) {
imageLoader = SubsonicActivity.getStaticImageLoader(context);
}
@@ -72,11 +82,19 @@ public class RemoteControlClientICS extends RemoteControlClientHelper {
@Override
public void registerRoute(MediaRouter router) {
+ if(mRemoteControl == null) {
+ return;
+ }
+
router.addRemoteControlClient(mRemoteControl);
}
@Override
public void unregisterRoute(MediaRouter router) {
+ if(mRemoteControl == null) {
+ return;
+ }
+
router.removeRemoteControlClient(mRemoteControl);
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java
index c27df2ba..e61e9a47 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java
@@ -43,6 +43,10 @@ public class RemoteControlClientJB extends RemoteControlClientICS {
@Override
public void setPlaybackState(final int state) {
+ if(mRemoteControl == null) {
+ return;
+ }
+
long position = -1;
if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
position = downloadService.getPlayerPosition();
diff --git a/app/src/main/res/layout/abstract_activity.xml b/app/src/main/res/layout/abstract_activity.xml
index be65e437..f012f484 100644
--- a/app/src/main/res/layout/abstract_activity.xml
+++ b/app/src/main/res/layout/abstract_activity.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -9,13 +10,11 @@
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.design.widget.NavigationView
+ android:id="@+id/left_drawer"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml
index 00441b73..fe0a9f2d 100644
--- a/app/src/main/res/layout/drawer_header.xml
+++ b/app/src/main/res/layout/drawer_header.xml
@@ -3,34 +3,54 @@
android:layout_width="match_parent"
android:layout_height="178dp"
android:orientation="vertical"
- android:weightSum="1">
+ android:weightSum="1"
+ android:background="?attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
- android:orientation="vertical"
+ android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
- <TextView
- android:id="@+id/header_server_name"
+ <LinearLayout
+ android:orientation="vertical"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="16dp"
- android:textColor="?android:textColorPrimary"
- android:textSize="14sp"
- android:textStyle="bold"/>
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:id="@+id/header_server_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="16dp"
+ android:textColor="?android:textColorPrimary"
+ android:textSize="14sp"
+ android:textStyle="bold"/>
+
+ <TextView
+ android:id="@+id/header_user_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="16dp"
+ android:layout_marginTop="5dp"
+ android:textColor="?android:textColorSecondary"
+ android:textSize="14sp"
+ android:textStyle="normal"/>
+ </LinearLayout>
+
+ <View
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
- <TextView
- android:id="@+id/header_user_name"
+ <ImageView
+ android:id="@+id/header_select_image"
+ android:src="?attr/select_server"
+ android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="16dp"
- android:layout_marginTop="5dp"
- android:textColor="?android:textColorSecondary"
- android:textSize="14sp"
- android:textStyle="normal"/>
+ android:paddingRight="20dp"/>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
diff --git a/app/src/main/res/layout/drawer_list_item.xml b/app/src/main/res/layout/drawer_list_item.xml
deleted file mode 100644
index 607b3658..00000000
--- a/app/src/main/res/layout/drawer_list_item.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingTop="8dip"
- android:paddingBottom="9dip">
-
- <ImageView
- android:id="@+id/drawer_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="left|center_vertical"
- android:paddingTop="1dip"
- android:paddingBottom="1dip"
- android:paddingRight="8dip"
- android:paddingLeft="10dip"/>
-
- <TextView
- android:id="@+id/drawer_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textColor="?android:textColorPrimary"
- android:textAppearance="?android:attr/textAppearanceLarge"
- style="DSub.TextViewStyle"/>
-</LinearLayout>
diff --git a/app/src/main/res/menu/drawer_navigation.xml b/app/src/main/res/menu/drawer_navigation.xml
new file mode 100644
index 00000000..88ecd920
--- /dev/null
+++ b/app/src/main/res/menu/drawer_navigation.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <group android:checkableBehavior="single">
+ <item
+ android:id="@+id/drawer_home"
+ android:icon="?attr/drawerHome"
+ android:title="@string/button_bar.home"/>
+ <item
+ android:id="@+id/drawer_library"
+ android:icon="?attr/drawerLibrary"
+ android:title="@string/button_bar.browse"/>
+ <item
+ android:id="@+id/drawer_playlists"
+ android:icon="?attr/drawerPlaylists"
+ android:title="@string/button_bar.playlists"/>
+ <item
+ android:id="@+id/drawer_podcasts"
+ android:icon="?attr/drawerPodcasts"
+ android:title="@string/button_bar.podcasts"/>
+ <item
+ android:id="@+id/drawer_bookmarks"
+ android:icon="?attr/drawerBookmarks"
+ android:title="@string/button_bar.bookmarks"/>
+ <item
+ android:id="@+id/drawer_shares"
+ android:icon="?attr/drawerShares"
+ android:title="@string/button_bar.shares"/>
+ <item
+ android:id="@+id/drawer_chat"
+ android:icon="?attr/drawerChat"
+ android:title="@string/button_bar.chat"/>
+ <item
+ android:id="@+id/drawer_admin"
+ android:icon="?attr/drawerAdmin"
+ android:title="@string/button_bar.admin"/>
+ <item
+ android:id="@+id/drawer_downloading"
+ android:icon="?attr/drawerDownloading"
+ android:title="@string/button_bar.downloading"
+ android:visible="false"/>
+ </group>
+
+ <group
+ android:id="@+id/drawer_bottom"
+ android:checkableBehavior="single">
+
+ <item
+ android:id="@+id/drawer_settings"
+ android:title="@string/menu.settings"/>
+ </group>
+</menu> \ No newline at end of file
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 37b15d12..d876ecdb 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -1,18 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string-array name="drawerItems">
- <item>@string/button_bar.home</item>
- <item>@string/button_bar.browse</item>
- <item>@string/button_bar.playlists</item>
- <item>@string/button_bar.podcasts</item>
- <item>@string/button_bar.bookmarks</item>
- <item>@string/button_bar.shares</item>
- <item>@string/button_bar.chat</item>
- <item>@string/button_bar.admin</item>
- <item>@string/button_bar.downloading</item>
- <item>@string/menu.settings</item>
- </string-array>
-
<string-array name="drawerItemsDescriptions">
<item>Home</item>
<item>Artist</item>
@@ -46,32 +33,6 @@
<item>Chat</item>
</string-array>
- <array name="drawerItemIconsLight">
- <item>@drawable/main_offline_light</item>
- <item>@drawable/ic_menu_library_light</item>
- <item>@drawable/ic_menu_playlist_light</item>
- <item>@drawable/ic_menu_podcast_light</item>
- <item>@drawable/ic_menu_bookmark_light</item>
- <item>@drawable/ic_menu_share_light</item>
- <item>@drawable/ic_menu_chat_light</item>
- <item>@drawable/ic_menu_admin_light</item>
- <item>@drawable/ic_menu_download_light</item>
- <item>@drawable/ic_menu_settings_light</item>
- </array>
-
- <array name="drawerItemIconsDark">
- <item>@drawable/main_offline_dark</item>
- <item>@drawable/ic_menu_library_dark</item>
- <item>@drawable/ic_menu_playlist_dark</item>
- <item>@drawable/ic_menu_podcast_dark</item>
- <item>@drawable/ic_menu_bookmark_dark</item>
- <item>@drawable/ic_menu_share_dark</item>
- <item>@drawable/ic_menu_chat_dark</item>
- <item>@drawable/ic_menu_admin_dark</item>
- <item>@drawable/ic_menu_download_dark</item>
- <item>@drawable/ic_menu_settings_dark</item>
- </array>
-
<string-array name="themeValues">
<item>light</item>
<item>dark</item>
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index 9667117c..3db670e6 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -27,6 +27,16 @@
<attr name="rating_good" format="reference"/>
<attr name="radio" format="reference"/>
<attr name="drawerItemsIcons" format="reference"/>
+ <attr name="drawerHome" format="reference"/>
+ <attr name="drawerLibrary" format="reference"/>
+ <attr name="drawerPlaylists" format="reference"/>
+ <attr name="drawerPodcasts" format="reference"/>
+ <attr name="drawerBookmarks" format="reference"/>
+ <attr name="drawerShares" format="reference"/>
+ <attr name="drawerChat" format="reference"/>
+ <attr name="drawerAdmin" format="reference"/>
+ <attr name="drawerDownloading" format="reference"/>
+ <attr name="drawerSettings" format="reference"/>
<declare-styleable name="SeekBarPreference">
<attr name="min" format="integer"/>
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 50d2d171..27082530 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -29,10 +29,21 @@
<item name="rating_bad">@drawable/ic_action_rating_bad_light</item>
<item name="rating_good">@drawable/ic_action_rating_good_light</item>
<item name="radio">@drawable/ic_menu_radio_light</item>
- <item name="drawerItemsIcons">@array/drawerItemIconsLight</item>
+ <item name="drawerHome">@drawable/main_offline_light</item>
+ <item name="drawerLibrary">@drawable/ic_menu_library_light</item>
+ <item name="drawerPlaylists">@drawable/ic_menu_playlist_light</item>
+ <item name="drawerPodcasts">@drawable/ic_menu_podcast_light</item>
+ <item name="drawerBookmarks">@drawable/ic_menu_bookmark_light</item>
+ <item name="drawerShares">@drawable/ic_menu_share_light</item>
+ <item name="drawerChat">@drawable/ic_menu_chat_light</item>
+ <item name="drawerAdmin">@drawable/ic_menu_admin_light</item>
+ <item name="drawerDownloading">@drawable/ic_menu_download_light</item>
+ <item name="drawerSettings">@drawable/ic_menu_settings_light</item>
<item name="android:textViewStyle">@style/DSub.TextViewStyle</item>
<item name="android:buttonStyle">@style/DSub.ButtonStyle.Light</item>
<item name="drawerArrowStyle">@style/DSub.DrawerArrow</item>
+ <item name="colorPrimary">@color/cyan</item>
+ <item name="colorPrimaryDark">@color/cyan</item>
<item name="colorAccent">@color/cyan</item>
</style>
<style name="Theme.DSub.Dark" parent="@style/Theme.AppCompat">
@@ -64,10 +75,21 @@
<item name="rating_bad">@drawable/ic_action_rating_bad_dark</item>
<item name="rating_good">@drawable/ic_action_rating_good_dark</item>
<item name="radio">@drawable/ic_menu_radio_dark</item>
- <item name="drawerItemsIcons">@array/drawerItemIconsDark</item>
+ <item name="drawerHome">@drawable/main_offline_dark</item>
+ <item name="drawerLibrary">@drawable/ic_menu_library_dark</item>
+ <item name="drawerPlaylists">@drawable/ic_menu_playlist_dark</item>
+ <item name="drawerPodcasts">@drawable/ic_menu_podcast_dark</item>
+ <item name="drawerBookmarks">@drawable/ic_menu_bookmark_dark</item>
+ <item name="drawerShares">@drawable/ic_menu_share_dark</item>
+ <item name="drawerChat">@drawable/ic_menu_chat_dark</item>
+ <item name="drawerAdmin">@drawable/ic_menu_admin_dark</item>
+ <item name="drawerDownloading">@drawable/ic_menu_download_dark</item>
+ <item name="drawerSettings">@drawable/ic_menu_settings_dark</item>
<item name="android:textViewStyle">@style/DSub.TextViewStyle</item>
<item name="android:buttonStyle">@style/DSub.ButtonStyle.Dark</item>
<item name="drawerArrowStyle">@style/DSub.DrawerArrow</item>
+ <item name="colorPrimary">@color/cyan</item>
+ <item name="colorPrimaryDark">@color/cyan</item>
<item name="colorAccent">@color/cyan</item>
</style>
<style name="Theme.DSub.Black" parent="Theme.DSub.Dark">
diff --git a/app/src/main/res/xml/changelog.xml b/app/src/main/res/xml/changelog.xml
index 005ddf44..572c1d5b 100644
--- a/app/src/main/res/xml/changelog.xml
+++ b/app/src/main/res/xml/changelog.xml
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
+ <release version="4.9.7" versioncode="152" releasedate="5/8/2015">
+ <change>Lazy load artist bio information</change>
+ <change>Keep previous search in bar when searching again</change>
+ <change>Warning if trying to stream on mobile if set to stream only on Wifi</change>
+ <change>Fix crash on alphabetical list for some users</change>
+ <change>Hide per folder option for Browse By Tags (Subsonic does not support it)</change>
+ <change>Misc improvements/fixes</change>
+ </release>
<release version="4.9.6" versioncode="150" releasedate="4/20/2015">
<change>New setting: Automatic renaming of duplicate songs</change>
<change>New setting: auto play on headphone insert</change>