aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java20
-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/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.java6
-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/xml/changelog.xml8
12 files changed, 104 insertions, 37 deletions
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/SubsonicFragmentActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index 92e711a3..c5391a88 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;
@@ -230,10 +231,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() {
@@ -409,8 +412,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);
}
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/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index cbceccbe..851e9478 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -574,9 +574,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 0a542689..40521051 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..c3d86d4b 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);
}
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/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>