From bfeb0640c7b4894ef3e1349d66028c4309ceba38 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 6 Feb 2013 17:51:23 -0800 Subject: Only load visualizer when started --- .../dsub/activity/DownloadActivity.java | 8 ++--- .../dsub/audiofx/EqualizerController.java | 1 + .../dsub/audiofx/VisualizerController.java | 1 + .../daneren2005/dsub/service/DownloadService.java | 4 +++ .../dsub/service/DownloadServiceImpl.java | 39 +++++++++++++--------- .../daneren2005/dsub/view/VisualizerView.java | 4 +-- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index dd5b3f0a..f6017a54 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -343,8 +343,8 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi downloadService.setShufflePlayEnabled(true); } - boolean visualizerAvailable = downloadService != null && downloadService.getVisualizerController() != null; - boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerController() != null; + boolean visualizerAvailable = downloadService != null && downloadService.getVisualizerAvailable(); + boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerAvailable(); if (!equalizerAvailable) { equalizerButton.setVisibility(View.GONE); @@ -400,8 +400,8 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } - if (visualizerView != null) { - visualizerView.setActive(downloadService != null && downloadService.getShowVisualization()); + if (visualizerView != null && downloadService != null && downloadService.getShowVisualization()) { + visualizerView.setActive(true); } updateButtons(); diff --git a/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java b/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java index f16ff968..4206b156 100644 --- a/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java +++ b/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java @@ -56,6 +56,7 @@ public class EqualizerController { } public EqualizerController(Context context, MediaPlayer mediaPlayer) { + Log.d(TAG, "Setting up equalizer"); this.context = context; try { equalizer = new Equalizer(0, mediaPlayer.getAudioSessionId()); diff --git a/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java b/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java index 184aeb51..dc46ee18 100644 --- a/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java +++ b/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java @@ -54,6 +54,7 @@ public class VisualizerController { } public VisualizerController(Context context, MediaPlayer mediaPlayer) { + Log.d(TAG, "Setting up visualizer"); this.context = context; try { visualizer = new Visualizer(mediaPlayer.getAudioSessionId()); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java index 663a6e6c..0536c198 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java @@ -106,6 +106,10 @@ public interface DownloadService { void setSuggestedPlaylistName(String name); String getSuggestedPlaylistName(); + + boolean getEqualizerAvailable(); + + boolean getVisualizerAvailable(); EqualizerController getEqualizerController(); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 72198850..340ff179 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -158,21 +158,6 @@ public class DownloadServiceImpl extends Service implements DownloadService { mRemoteControl.register(this, mediaButtonReceiverComponent); } - if (equalizerAvailable) { - equalizerController = new EqualizerController(this, mediaPlayer); - if (!equalizerController.isAvailable()) { - equalizerController = null; - } else { - equalizerController.loadSettings(); - } - } - if (visualizerAvailable) { - visualizerController = new VisualizerController(this, mediaPlayer); - if (!visualizerController.isAvailable()) { - visualizerController = null; - } - } - PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName()); wakeLock.setReferenceCounted(false); @@ -781,14 +766,38 @@ public class DownloadServiceImpl extends Service implements DownloadService { public String getSuggestedPlaylistName() { return suggestedPlaylistName; } + + @Override + public boolean getEqualizerAvailable() { + return equalizerAvailable; + } + + @Override + public boolean getVisualizerAvailable() { + return visualizerAvailable; + } @Override public EqualizerController getEqualizerController() { + if (equalizerAvailable && equalizerController == null) { + equalizerController = new EqualizerController(this, mediaPlayer); + if (!equalizerController.isAvailable()) { + equalizerController = null; + } else { + equalizerController.loadSettings(); + } + } return equalizerController; } @Override public VisualizerController getVisualizerController() { + if (visualizerAvailable && visualizerController == null) { + visualizerController = new VisualizerController(this, mediaPlayer); + if (!visualizerController.isAvailable()) { + visualizerController = null; + } + } return visualizerController; } diff --git a/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java b/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java index 9bff3a2d..19097885 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java @@ -45,14 +45,14 @@ public class VisualizerView extends View { private byte[] data; private float[] points; - private boolean active; + private boolean active = false; public VisualizerView(Context context) { super(context); paint.setStrokeWidth(2f); paint.setAntiAlias(true); - paint.setColor(Color.rgb(129, 201, 54)); + paint.setColor(Color.rgb(51, 181, 229)); } public boolean isActive() { -- cgit v1.2.3 From ef9ce9a9c7984ab9b34e826132f4a2e21ada98f9 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 7 Feb 2013 19:12:09 -0800 Subject: Fix VS/EQ not being visible in landscape mode --- subsonic-android/res/layout-land/download.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/subsonic-android/res/layout-land/download.xml b/subsonic-android/res/layout-land/download.xml index 431fef96..4992d169 100644 --- a/subsonic-android/res/layout-land/download.xml +++ b/subsonic-android/res/layout-land/download.xml @@ -53,7 +53,6 @@ android:text="EQ" android:textStyle="bold" android:textSize="22sp" - android:visibility="gone" android:background="@android:color/transparent" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -76,7 +75,6 @@ android:text="VIS" android:textStyle="bold" android:textSize="22sp" - android:visibility="gone" android:background="@android:color/transparent" android:layout_width="wrap_content" android:layout_height="wrap_content" -- cgit v1.2.3 From 6612b1049231374d69d4cdd3fe9b52571048cda1 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 7 Feb 2013 19:13:08 -0800 Subject: Release the visualizer object when not being used --- .../daneren2005/dsub/activity/DownloadActivity.java | 9 +++++++-- .../daneren2005/dsub/audiofx/VisualizerController.java | 17 +++++++++++++++-- .../github/daneren2005/dsub/view/VisualizerView.java | 11 ++++++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index f6017a54..05591818 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -285,9 +285,14 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi public void onClick(View view) { boolean active = !visualizerView.isActive(); visualizerView.setActive(active); - getDownloadService().setShowVisualization(visualizerView.isActive()); + boolean isActive = visualizerView.isActive(); + getDownloadService().setShowVisualization(isActive); updateButtons(); - Util.toast(DownloadActivity.this, active ? R.string.download_visualizer_on : R.string.download_visualizer_off); + if(active == isActive) { + Util.toast(DownloadActivity.this, active ? R.string.download_visualizer_on : R.string.download_visualizer_off); + } else { + Util.toast(DownloadActivity.this, "Failed to start visualizer. Try restarting."); + } setControlsVisible(true); } }); diff --git a/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java b/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java index dc46ee18..b32245f4 100644 --- a/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java +++ b/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java @@ -36,6 +36,8 @@ public class VisualizerController { private final Context context; private Visualizer visualizer; + private boolean released = false; + private int audioSessionId = 0; // Class initialization fails when this throws an exception. static { @@ -54,10 +56,10 @@ public class VisualizerController { } public VisualizerController(Context context, MediaPlayer mediaPlayer) { - Log.d(TAG, "Setting up visualizer"); this.context = context; try { - visualizer = new Visualizer(mediaPlayer.getAudioSessionId()); + audioSessionId = mediaPlayer.getAudioSessionId(); + visualizer = new Visualizer(audioSessionId); } catch (Throwable x) { Log.w(TAG, "Failed to create visualizer.", x); } @@ -81,10 +83,21 @@ public class VisualizerController { public void release() { if (isAvailable()) { visualizer.release(); + released = true; } } public Visualizer getVisualizer() { + if(released) { + released = false; + try { + visualizer = new Visualizer(audioSessionId); + } catch (Throwable x) { + visualizer = null; + Log.w(TAG, "Failed to create visualizer.", x); + } + } + return visualizer; } } diff --git a/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java b/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java index 19097885..53ebc2ec 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java @@ -61,8 +61,10 @@ public class VisualizerView extends View { public void setActive(boolean active) { this.active = active; - Visualizer visualizer = getVizualiser(); + VisualizerController visualizerController = getVizualiser(); + Visualizer visualizer = visualizerController == null ? null : visualizerController.getVisualizer(); if (visualizer == null) { + this.active = false; return; } @@ -83,13 +85,16 @@ public class VisualizerView extends View { } visualizer.setEnabled(active); + if(!active) { + visualizerController.release(); + } invalidate(); } - private Visualizer getVizualiser() { + private VisualizerController getVizualiser() { DownloadService downloadService = DownloadServiceImpl.getInstance(); VisualizerController visualizerController = downloadService == null ? null : downloadService.getVisualizerController(); - return visualizerController == null ? null : visualizerController.getVisualizer(); + return visualizerController; } private void updateVisualizer(byte[] waveform) { -- cgit v1.2.3 From f11bcc17cdd7495b577812b4bcb68710c22e6a6c Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 7 Feb 2013 19:44:56 -0800 Subject: Only start Equalizer if actually being used --- .../daneren2005/dsub/activity/DownloadActivity.java | 18 +++++++++++++----- .../daneren2005/dsub/activity/EqualizerActivity.java | 7 +++++++ .../daneren2005/dsub/audiofx/EqualizerController.java | 1 - .../daneren2005/dsub/service/DownloadServiceImpl.java | 4 ++++ .../src/github/daneren2005/dsub/util/Constants.java | 1 + 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index 05591818..1c44fca1 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -119,6 +119,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi private int swipeDistance; private int swipeVelocity; private VisualizerView visualizerView; + private boolean equalizerOn; private boolean nowPlaying = true; private ScheduledFuture hideControlsFuture; @@ -275,6 +276,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi equalizerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + equalizerOn = true; startActivity(new Intent(DownloadActivity.this, EqualizerActivity.class)); setControlsVisible(true); } @@ -353,7 +355,10 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi if (!equalizerAvailable) { equalizerButton.setVisibility(View.GONE); - } + } else { + SharedPreferences prefs = Util.getPreferences(DownloadActivity.this); + equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false); + } if (!visualizerAvailable) { visualizerButton.setVisibility(View.GONE); } else { @@ -446,10 +451,13 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi } private void updateButtons() { - boolean eqEnabled = getDownloadService() != null && getDownloadService().getEqualizerController() != null && - getDownloadService().getEqualizerController().isEnabled(); - equalizerButton.setTextColor(eqEnabled ? COLOR_BUTTON_ENABLED : COLOR_BUTTON_DISABLED); - + if(equalizerOn && getDownloadService() != null && getDownloadService().getEqualizerController() != null && + getDownloadService().getEqualizerController().isEnabled()) { + equalizerButton.setTextColor(COLOR_BUTTON_ENABLED); + } else { + equalizerButton.setTextColor(COLOR_BUTTON_DISABLED); + } + if (visualizerView != null) { visualizerButton.setTextColor(visualizerView.isActive() ? COLOR_BUTTON_ENABLED : COLOR_BUTTON_DISABLED); } diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java index 9906673a..2aa61945 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Map; import android.app.Activity; +import android.content.SharedPreferences; import android.media.audiofx.Equalizer; import android.os.Bundle; import android.view.ContextMenu; @@ -36,6 +37,8 @@ import android.widget.TextView; import github.daneren2005.dsub.R; import github.daneren2005.dsub.audiofx.EqualizerController; import github.daneren2005.dsub.service.DownloadServiceImpl; +import github.daneren2005.dsub.util.Constants; +import github.daneren2005.dsub.util.Util; /** * Equalizer controls. @@ -114,6 +117,10 @@ public class EqualizerActivity extends Activity { } private void setEqualizerEnabled(boolean enabled) { + SharedPreferences prefs = Util.getPreferences(EqualizerActivity.this); + SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean(Constants.PREFERENCES_EQUALIZER_ON, enabled); + editor.commit(); equalizer.setEnabled(enabled); updateBars(); } diff --git a/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java b/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java index 4206b156..f16ff968 100644 --- a/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java +++ b/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java @@ -56,7 +56,6 @@ public class EqualizerController { } public EqualizerController(Context context, MediaPlayer mediaPlayer) { - Log.d(TAG, "Setting up equalizer"); this.context = context; try { equalizer = new Equalizer(0, mediaPlayer.getAudioSessionId()); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 340ff179..9e6662cf 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -174,6 +174,10 @@ public class DownloadServiceImpl extends Service implements DownloadService { instance = this; lifecycleSupport.onCreate(); + + if(prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false)) { + getEqualizerController(); + } } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index c116c484..d633e7f0 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -88,6 +88,7 @@ public final class Constants { public static final String PREFERENCES_KEY_SHUFFLE_GENRE = "genre"; public static final String PREFERENCES_KEY_KEEP_SCREEN_ON = "keepScreenOn"; public static final String PREFERENCES_KEY_BUFFER_LENGTH = "bufferLength"; + public static final String PREFERENCES_EQUALIZER_ON = "equalizerOn"; // Name of the preferences file. public static final String PREFERENCES_FILE_NAME = "github.daneren2005.dsub_preferences"; -- cgit v1.2.3 From 759aa73130818ed15d032571bdc064ff09658fdd Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 7 Feb 2013 21:59:38 -0800 Subject: Release Equalizer when user unchecked enabled and backs out --- .../daneren2005/dsub/activity/DownloadActivity.java | 19 +++++++++++-------- .../daneren2005/dsub/activity/EqualizerActivity.java | 4 ++++ .../daneren2005/dsub/audiofx/EqualizerController.java | 15 ++++++++++++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index 1c44fca1..a4222ce5 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -119,7 +119,6 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi private int swipeDistance; private int swipeVelocity; private VisualizerView visualizerView; - private boolean equalizerOn; private boolean nowPlaying = true; private ScheduledFuture hideControlsFuture; @@ -276,9 +275,14 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi equalizerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - equalizerOn = true; - startActivity(new Intent(DownloadActivity.this, EqualizerActivity.class)); - setControlsVisible(true); + DownloadService downloadService = getDownloadService(); + if(downloadService != null && downloadService.getEqualizerController() != null + && downloadService.getEqualizerController().getEqualizer() != null) { + startActivity(new Intent(DownloadActivity.this, EqualizerActivity.class)); + setControlsVisible(true); + } else { + Util.toast(DownloadActivity.this, "Failed to start equalizer. Try restarting."); + } } }); @@ -355,10 +359,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi if (!equalizerAvailable) { equalizerButton.setVisibility(View.GONE); - } else { - SharedPreferences prefs = Util.getPreferences(DownloadActivity.this); - equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false); - } + } if (!visualizerAvailable) { visualizerButton.setVisibility(View.GONE); } else { @@ -451,6 +452,8 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi } private void updateButtons() { + SharedPreferences prefs = Util.getPreferences(DownloadActivity.this); + boolean equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false); if(equalizerOn && getDownloadService() != null && getDownloadService().getEqualizerController() != null && getDownloadService().getEqualizerController().isEnabled()) { equalizerButton.setTextColor(COLOR_BUTTON_ENABLED); diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java index 2aa61945..b4bd0e33 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java @@ -86,6 +86,10 @@ public class EqualizerActivity extends Activity { protected void onPause() { super.onPause(); equalizerController.saveSettings(); + + if(!equalizer.getEnabled()) { + equalizerController.release(); + } } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java b/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java index f16ff968..0dcee863 100644 --- a/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java +++ b/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java @@ -38,6 +38,8 @@ public class EqualizerController { private final Context context; private Equalizer equalizer; + private boolean released = false; + private int audioSessionId = 0; // Class initialization fails when this throws an exception. static { @@ -58,7 +60,8 @@ public class EqualizerController { public EqualizerController(Context context, MediaPlayer mediaPlayer) { this.context = context; try { - equalizer = new Equalizer(0, mediaPlayer.getAudioSessionId()); + audioSessionId = mediaPlayer.getAudioSessionId(); + equalizer = new Equalizer(0, audioSessionId); } catch (Throwable x) { Log.w(TAG, "Failed to create equalizer.", x); } @@ -97,11 +100,21 @@ public class EqualizerController { public void release() { if (isAvailable()) { + released = true; equalizer.release(); } } public Equalizer getEqualizer() { + if(released) { + released = false; + try { + equalizer = new Equalizer(0, audioSessionId); + } catch (Throwable x) { + equalizer = null; + Log.w(TAG, "Failed to create equalizer.", x); + } + } return equalizer; } -- cgit v1.2.3 From 74dcc582f1e70ad6113da5d4dbcfbfb138dc5694 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 9 Feb 2013 19:45:29 -0800 Subject: Start of adding Master EQ level setting --- .../dsub/activity/EqualizerActivity.java | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java index b4bd0e33..2b2df35b 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java @@ -25,6 +25,7 @@ import android.app.Activity; import android.content.SharedPreferences; import android.media.audiofx.Equalizer; import android.os.Bundle; +import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.MenuItem; @@ -47,6 +48,7 @@ import github.daneren2005.dsub.util.Util; * @version $Id$ */ public class EqualizerActivity extends Activity { + private static final String TAG = EqualizerActivity.class.getSimpleName(); private static final int MENU_GROUP_PRESET = 100; @@ -135,8 +137,10 @@ public class EqualizerActivity extends Activity { short band = entry.getKey(); SeekBar bar = entry.getValue(); bar.setEnabled(equalizer.getEnabled()); - short minEQLevel = equalizer.getBandLevelRange()[0]; - bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + if(band >= (short)0) { + short minEQLevel = equalizer.getBandLevelRange()[0]; + bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + } } } @@ -145,6 +149,9 @@ public class EqualizerActivity extends Activity { final short minEQLevel = equalizer.getBandLevelRange()[0]; final short maxEQLevel = equalizer.getBandLevelRange()[1]; + + // Setup Pregain + initPregain(layout, equalizer.getBandLevel((short)0), minEQLevel, maxEQLevel); for (short i = 0; i < equalizer.getNumberOfBands(); i++) { final short band = i; @@ -184,6 +191,41 @@ public class EqualizerActivity extends Activity { layout.addView(bandBar); } } + + private void initPregain(LinearLayout layout, short level, final short minEQLevel, final short maxEQLevel) { + View bandBar = LayoutInflater.from(this).inflate(R.layout.equalizer_bar, null); + TextView freqTextView = (TextView) bandBar.findViewById(R.id.equalizer_frequency); + final TextView levelTextView = (TextView) bandBar.findViewById(R.id.equalizer_level); + SeekBar bar = (SeekBar) bandBar.findViewById(R.id.equalizer_bar); + + freqTextView.setText("Master"); + + bars.put((short)-1, bar); + bar.setMax(maxEQLevel - minEQLevel); + bar.setProgress(level - minEQLevel); + bar.setEnabled(equalizer.getEnabled()); + updateLevelText(levelTextView, (short)0); + + 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, level); + }*/ + updateLevelText(levelTextView, level); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + }); + layout.addView(bandBar); + } private void updateLevelText(TextView levelTextView, short level) { levelTextView.setText((level > 0 ? "+" : "") + level / 100 + " dB"); -- cgit v1.2.3 From da65a7f83b546477c0b00252c270352e0592cdae Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 10 Feb 2013 09:36:23 -0800 Subject: Fix crash when exiting Equalizer activity --- .../src/github/daneren2005/dsub/activity/EqualizerActivity.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java index 2b2df35b..78e7cc51 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java @@ -93,6 +93,13 @@ public class EqualizerActivity extends Activity { equalizerController.release(); } } + + @Override + protected void onResume() { + super.onResume(); + equalizerController = DownloadServiceImpl.getInstance().getEqualizerController(); + equalizer = equalizerController.getEqualizer(); + } @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { -- cgit v1.2.3 From 9d5e7dd4f1a19fb712bd27d764909ae57d10ac6d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 12 Feb 2013 21:44:31 -0800 Subject: Closes #59 Add Master control to EQ --- .../dsub/activity/EqualizerActivity.java | 50 ++++++++++++++++------ .../github/daneren2005/dsub/util/Constants.java | 1 + 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java index 78e7cc51..1dbe0f7c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java @@ -55,6 +55,7 @@ public class EqualizerActivity extends Activity { private final Map bars = new HashMap(); private EqualizerController equalizerController; private Equalizer equalizer; + private short masterLevel = 0; @Override public void onCreate(Bundle bundle) { @@ -139,16 +140,27 @@ public class EqualizerActivity extends Activity { } private void updateBars() { - + boolean isEnabled = equalizer.getEnabled(); + short minEQLevel = equalizer.getBandLevelRange()[0]; for (Map.Entry entry : bars.entrySet()) { short band = entry.getKey(); SeekBar bar = entry.getValue(); - bar.setEnabled(equalizer.getEnabled()); + bar.setEnabled(isEnabled); if(band >= (short)0) { - short minEQLevel = equalizer.getBandLevelRange()[0]; + equalizer.setBandLevel(band, (short)(equalizer.getBandLevel(band) - masterLevel)); bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + } else if(!isEnabled) { + bar.setProgress(-minEQLevel); } } + + if(!isEnabled) { + masterLevel = 0; + SharedPreferences prefs = Util.getPreferences(EqualizerActivity.this); + SharedPreferences.Editor editor = prefs.edit(); + editor.putInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, masterLevel); + editor.commit(); + } } private void initEqualizer() { @@ -158,7 +170,9 @@ public class EqualizerActivity extends Activity { final short maxEQLevel = equalizer.getBandLevelRange()[1]; // Setup Pregain - initPregain(layout, equalizer.getBandLevel((short)0), minEQLevel, maxEQLevel); + SharedPreferences prefs = Util.getPreferences(this); + masterLevel = (short)prefs.getInt(Constants.PREFERENCES_EQUALIZER_SETTINGS, 0); + initPregain(layout, minEQLevel, maxEQLevel); for (short i = 0; i < equalizer.getNumberOfBands(); i++) { final short band = i; @@ -173,6 +187,9 @@ public class EqualizerActivity extends Activity { bars.put(band, bar); bar.setMax(maxEQLevel - minEQLevel); short level = equalizer.getBandLevel(band); + if(equalizer.getEnabled()) { + level = (short) (level - masterLevel); + } bar.setProgress(level - minEQLevel); bar.setEnabled(equalizer.getEnabled()); updateLevelText(levelTextView, level); @@ -182,7 +199,7 @@ public class EqualizerActivity extends Activity { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { short level = (short) (progress + minEQLevel); if (fromUser) { - equalizer.setBandLevel(band, level); + equalizer.setBandLevel(band, (short)(level + masterLevel)); } updateLevelText(levelTextView, level); } @@ -199,7 +216,7 @@ public class EqualizerActivity extends Activity { } } - private void initPregain(LinearLayout layout, short level, final short minEQLevel, final short maxEQLevel) { + private void initPregain(LinearLayout layout, final short minEQLevel, final short maxEQLevel) { View bandBar = LayoutInflater.from(this).inflate(R.layout.equalizer_bar, null); TextView freqTextView = (TextView) bandBar.findViewById(R.id.equalizer_frequency); final TextView levelTextView = (TextView) bandBar.findViewById(R.id.equalizer_level); @@ -209,18 +226,25 @@ public class EqualizerActivity extends Activity { bars.put((short)-1, bar); bar.setMax(maxEQLevel - minEQLevel); - bar.setProgress(level - minEQLevel); + bar.setProgress(masterLevel - minEQLevel); bar.setEnabled(equalizer.getEnabled()); - updateLevelText(levelTextView, (short)0); + updateLevelText(levelTextView, masterLevel); 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, level); - }*/ - updateLevelText(levelTextView, level); + masterLevel = (short) (progress + minEQLevel); + if (fromUser) { + SharedPreferences prefs = Util.getPreferences(EqualizerActivity.this); + 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); } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index d633e7f0..3ee7d7e8 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -89,6 +89,7 @@ public final class Constants { public static final String PREFERENCES_KEY_KEEP_SCREEN_ON = "keepScreenOn"; public static final String PREFERENCES_KEY_BUFFER_LENGTH = "bufferLength"; public static final String PREFERENCES_EQUALIZER_ON = "equalizerOn"; + public static final String PREFERENCES_EQUALIZER_SETTINGS = "equalizerSettings"; // Name of the preferences file. public static final String PREFERENCES_FILE_NAME = "github.daneren2005.dsub_preferences"; -- cgit v1.2.3 From 0c3815da943621544b38076459b013a11d5a91de Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Wed, 13 Feb 2013 09:56:28 -0800 Subject: Increase amount of memory dedicated to image loading --- subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java index 9586e24d..35e24039 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java @@ -64,7 +64,7 @@ public class ImageLoader implements Runnable { public ImageLoader(Context context) { this.context = context; final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); - final int cacheSize = maxMemory / 4; + final int cacheSize = maxMemory / 2; cache = new LruCache(cacheSize) { @Override protected int sizeOf(String key, Bitmap bitmap) { -- cgit v1.2.3 From cb0fd5e3d8417f0540a19e183e2de613efa5d9d5 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 13 Feb 2013 21:42:47 -0800 Subject: Fix Master volume not working well with presets --- .../daneren2005/dsub/activity/EqualizerActivity.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java index 1dbe0f7c..e5de3858 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/EqualizerActivity.java @@ -126,7 +126,7 @@ public class EqualizerActivity extends Activity { public boolean onContextItemSelected(MenuItem menuItem) { short preset = (short) menuItem.getItemId(); equalizer.usePreset(preset); - updateBars(); + updateBars(false); return true; } @@ -136,10 +136,10 @@ public class EqualizerActivity extends Activity { editor.putBoolean(Constants.PREFERENCES_EQUALIZER_ON, enabled); editor.commit(); equalizer.setEnabled(enabled); - updateBars(); + updateBars(true); } - private void updateBars() { + private void updateBars(boolean changedEnabled) { boolean isEnabled = equalizer.getEnabled(); short minEQLevel = equalizer.getBandLevelRange()[0]; for (Map.Entry entry : bars.entrySet()) { @@ -147,8 +147,13 @@ public class EqualizerActivity extends Activity { SeekBar bar = entry.getValue(); bar.setEnabled(isEnabled); if(band >= (short)0) { - equalizer.setBandLevel(band, (short)(equalizer.getBandLevel(band) - masterLevel)); - bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + if(changedEnabled) { + equalizer.setBandLevel(band, (short)(equalizer.getBandLevel(band) - masterLevel)); + bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + } else { + bar.setProgress(equalizer.getBandLevel(band) - minEQLevel); + equalizer.setBandLevel(band, (short)(equalizer.getBandLevel(band) + masterLevel)); + } } else if(!isEnabled) { bar.setProgress(-minEQLevel); } -- cgit v1.2.3 From 7bcf28572bd75318a121f8591937a996ef48e7d0 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 15 Feb 2013 20:01:15 -0800 Subject: Upped Version 3.7.4 --- subsonic-android/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsonic-android/AndroidManifest.xml b/subsonic-android/AndroidManifest.xml index 44609b37..5ca6cf49 100644 --- a/subsonic-android/AndroidManifest.xml +++ b/subsonic-android/AndroidManifest.xml @@ -3,7 +3,7 @@ package="github.daneren2005.dsub" android:installLocation="internalOnly" android:versionCode="36" - android:versionName="3.7.3"> + android:versionName="3.7.4"> -- cgit v1.2.3 From b742b1974283d021678d25ea87064176c47e5095 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Fri, 15 Feb 2013 21:37:31 -0800 Subject: Update README --- README | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README b/README index c3cd2cda..c9e871cf 100644 --- a/README +++ b/README @@ -1,3 +1,13 @@ +Basic Instructions +Run these commands to grab dependent libraries: +git submodule init +git submodule update + +Go to both ActionBarSherlock/library and DragSortListView/library and build project files with: +android update project --path ./ + + + Roadmap of major planned features in rough order that I plan to work on them in (little features get sprinkled in wherever): Gapless Playback (may not be possible to get perfect) -- cgit v1.2.3 From e4ce03c6f1c3fb5ec48fcefbf814d83a1d5090f4 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 15 Feb 2013 21:45:52 -0800 Subject: Added drag-sort-listview library --- .gitignore | 10 ++++++---- .gitmodules | 5 ++++- subsonic-android/project.properties | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d466c271..2fdc3270 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -subsonic-android/.classpath -subsonic-android/.project -subsonic-android/bin/* -subsonic-android/gen/* \ No newline at end of file +subsonic-android/.classpath +subsonic-android/.project +subsonic-android/bin/* +subsonic-android/gen/* +/subsonic-android/libs/ActionBarSherlock/gen/ +/subsonic-android/private/* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 0303afcf..1d77a2e9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "ActionBarSherlock"] path = ActionBarSherlock - url = https://github.com/JakeWharton/ActionBarSherlock.git + url = https://github.com/JakeWharton/ActionBarSherlock.git +[submodule "DragSortListView"] + path = DragSortListView + url = https://github.com/bauerca/drag-sort-listview.git diff --git a/subsonic-android/project.properties b/subsonic-android/project.properties index 9b3b31a8..cd253d77 100644 --- a/subsonic-android/project.properties +++ b/subsonic-android/project.properties @@ -9,4 +9,5 @@ # Project target. target=android-16 -android.library.reference.1=../../ActionBarSherlock +android.library.reference.1=../ActionBarSherlock/library +android.library.reference.2=../DragSortListView/library \ No newline at end of file -- cgit v1.2.3 From fa9e77b8e90fa684e0374c8ac3237baadd38f7b6 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 17 Feb 2013 16:20:41 -0800 Subject: Added drag drop functionality to now playing tab --- subsonic-android/res/layout/download_playlist.xml | 25 ++++++++++++++++------ subsonic-android/res/layout/song_list_item.xml | 7 +++--- subsonic-android/res/values/ids.xml | 4 ++++ .../dsub/activity/DownloadActivity.java | 12 +++++++++-- .../daneren2005/dsub/service/DownloadService.java | 2 ++ .../dsub/service/DownloadServiceImpl.java | 16 ++++++++++++++ 6 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 subsonic-android/res/values/ids.xml diff --git a/subsonic-android/res/layout/download_playlist.xml b/subsonic-android/res/layout/download_playlist.xml index 8e92a984..8bd54877 100644 --- a/subsonic-android/res/layout/download_playlist.xml +++ b/subsonic-android/res/layout/download_playlist.xml @@ -19,11 +19,24 @@ android:layout_height="wrap_content" android:padding="10dip"/> - + \ No newline at end of file diff --git a/subsonic-android/res/layout/song_list_item.xml b/subsonic-android/res/layout/song_list_item.xml index 9bbfde94..0ff738d2 100644 --- a/subsonic-android/res/layout/song_list_item.xml +++ b/subsonic-android/res/layout/song_list_item.xml @@ -1,8 +1,9 @@ + android:id="@id/drag_handle" + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="?android:attr/listPreferredItemHeight"> + + + \ No newline at end of file diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index a4222ce5..e4578db1 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -81,6 +81,7 @@ import github.daneren2005.dsub.util.*; import github.daneren2005.dsub.view.AutoRepeatButton; import java.util.ArrayList; import java.util.concurrent.ScheduledFuture; +import com.mobeta.android.dslv.*; public class DownloadActivity extends SubsonicTabActivity implements OnGestureListener { private static final String TAG = DownloadActivity.class.getSimpleName(); @@ -95,7 +96,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi private TextView emptyTextView; private TextView songTitleTextView; private ImageView albumArtImageView; - private ListView playlistView; + private DragSortListView playlistView; private TextView positionTextView; private TextView durationTextView; private TextView statusTextView; @@ -145,7 +146,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi durationTextView = (TextView) findViewById(R.id.download_duration); statusTextView = (TextView) findViewById(R.id.download_status); progressBar = (HorizontalSlider) findViewById(R.id.download_progress_bar); - playlistView = (ListView) findViewById(R.id.download_list); + playlistView = (DragSortListView) findViewById(R.id.download_list); previousButton = (AutoRepeatButton)findViewById(R.id.download_previous); nextButton = (AutoRepeatButton)findViewById(R.id.download_next); pauseButton = findViewById(R.id.download_pause); @@ -344,6 +345,13 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi } } }); + playlistView.setDropListener(new DragSortListView.DropListener() { + @Override + public void drop(int from, int to) { + getDownloadService().swap(from, to); + onDownloadListChanged(); + } + }); registerForContextMenu(playlistView); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java index 0536c198..c086c258 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java @@ -130,4 +130,6 @@ public interface DownloadService { boolean getSleepTimer(); void setVolume(float volume); + + void swap(int from, int to); } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 9e6662cf..349252e0 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -981,6 +981,22 @@ public class DownloadServiceImpl extends Service implements DownloadService { mediaPlayer.setVolume(volume, volume); } } + + @Override + public void swap(int from, int to) { + int max = size(); + if(to >= max) { + to = max - 1; + } + else if(to < 0) { + to = 0; + } + + downloadList.add(to, downloadList.remove(from)); + if(jukeboxEnabled) { + updateJukeboxPlaylist(); + } + } private void handleError(Exception x) { Log.w(TAG, "Media player error: " + x, x); -- cgit v1.2.3 From 309926d441c4879eb1bcc6f50abce652a0466415 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 17 Feb 2013 21:31:42 -0800 Subject: Added fling remove option --- subsonic-android/res/layout/download_playlist.xml | 3 ++- .../src/github/daneren2005/dsub/activity/DownloadActivity.java | 7 +++++++ .../src/github/daneren2005/dsub/service/DownloadService.java | 2 ++ .../src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 7 ++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/subsonic-android/res/layout/download_playlist.xml b/subsonic-android/res/layout/download_playlist.xml index 8bd54877..d0602e8a 100644 --- a/subsonic-android/res/layout/download_playlist.xml +++ b/subsonic-android/res/layout/download_playlist.xml @@ -36,7 +36,8 @@ dslv:use_default_controller="true" dslv:drag_handle_id="@id/drag_handle" dslv:sort_enabled="true" - dslv:remove_enabled="false" + dslv:remove_enabled="true" + dslv:remove_mode="flingRemove" dslv:drag_start_mode="onDown"/> \ No newline at end of file diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index e4578db1..195d6001 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -352,6 +352,13 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi onDownloadListChanged(); } }); + playlistView.setRemoveListener(new DragSortListView.RemoveListener() { + @Override + public void remove(int which) { + getDownloadService().remove(which); + onDownloadListChanged(); + } + }); registerForContextMenu(playlistView); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java index c086c258..889d7d2b 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java @@ -60,6 +60,8 @@ public interface DownloadService { void clearIncomplete(); int size(); + + void remove(int which); void remove(DownloadFile downloadFile); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 349252e0..2ac55f66 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -420,6 +420,11 @@ public class DownloadServiceImpl extends Service implements DownloadService { } updateJukeboxPlaylist(); } + + @Override + public synchronized void remove(int which) { + downloadList.remove(which); + } @Override public synchronized void remove(DownloadFile downloadFile) { @@ -983,7 +988,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { } @Override - public void swap(int from, int to) { + public synchronized void swap(int from, int to) { int max = size(); if(to >= max) { to = max - 1; -- cgit v1.2.3 From bec14784af5ceef1f99d60e034981f1a7c1a2757 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 18 Feb 2013 11:00:10 -0800 Subject: Don't jump back to the top after moving items --- .../src/github/daneren2005/dsub/activity/DownloadActivity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index 195d6001..f7ee55d3 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -36,6 +36,7 @@ import android.graphics.Color; import android.graphics.Typeface; import android.os.Bundle; import android.os.Handler; +import android.os.Parcelable; import android.util.Log; import android.view.ContextMenu; import android.view.Display; @@ -816,9 +817,16 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi else emptyTextView.setText(R.string.download_empty); + // Save old position + Parcelable state = playlistView.onSaveInstanceState(); + // Set new items playlistView.setAdapter(new SongListAdapter(list)); + emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE); currentRevision = downloadService.getDownloadListUpdateRevision(); + + // Restore old position + playlistView.onRestoreInstanceState(state); switch (downloadService.getRepeatMode()) { case OFF: -- cgit v1.2.3 From 60668ced436a5c5b0d9ce6d29050a27a3d3f6747 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 18 Feb 2013 17:04:20 -0800 Subject: Don't allow fling remove, drag on long press --- subsonic-android/res/layout/download_playlist.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subsonic-android/res/layout/download_playlist.xml b/subsonic-android/res/layout/download_playlist.xml index d0602e8a..dc77826d 100644 --- a/subsonic-android/res/layout/download_playlist.xml +++ b/subsonic-android/res/layout/download_playlist.xml @@ -27,7 +27,7 @@ android:layout_weight="1" android:cacheColorHint="#00000000" dslv:drag_enabled="true" - dslv:collapsed_height="2dp" + dslv:collapsed_height="1dp" dslv:drag_scroll_start="1.0" dslv:max_drag_scroll_speed="2.0" dslv:float_alpha="0.6" @@ -36,8 +36,8 @@ dslv:use_default_controller="true" dslv:drag_handle_id="@id/drag_handle" dslv:sort_enabled="true" - dslv:remove_enabled="true" + dslv:remove_enabled="false" dslv:remove_mode="flingRemove" - dslv:drag_start_mode="onDown"/> + dslv:drag_start_mode="onLongPress"/> \ No newline at end of file -- cgit v1.2.3 From c30a37550b0732076935ffa658490b77efa65035 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Tue, 19 Feb 2013 15:03:31 -0800 Subject: Fix TransitionDrawable stack overflow error --- .../src/github/daneren2005/dsub/util/ImageLoader.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java index 35e24039..133f2c26 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java @@ -158,6 +158,15 @@ public class ImageLoader implements Runnable { emptyImage = Bitmap.createBitmap(imageSizeDefault, imageSizeDefault, Bitmap.Config.ARGB_8888); } existingDrawable = new BitmapDrawable(emptyImage); + } else { + // Try to get rid of old transitions + try { + TransitionDrawable tmp = (TransitionDrawable) existingDrawable; + int layers = tmp.getNumberOfLayers(); + existingDrawable = tmp.getDrawable(layers - 1;) + } catch(Exception e) { + // Do nothing, just means that the drawable is a flat image + } } Drawable[] layers = new Drawable[]{existingDrawable, drawable}; -- cgit v1.2.3 From ff7e20cf6481cf4d0c302650e7434a1a918ea0e8 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 19 Feb 2013 20:08:34 -0800 Subject: Fix typo --- subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java index 133f2c26..4c3b256b 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java @@ -163,7 +163,7 @@ public class ImageLoader implements Runnable { try { TransitionDrawable tmp = (TransitionDrawable) existingDrawable; int layers = tmp.getNumberOfLayers(); - existingDrawable = tmp.getDrawable(layers - 1;) + existingDrawable = tmp.getDrawable(layers - 1); } catch(Exception e) { // Do nothing, just means that the drawable is a flat image } -- cgit v1.2.3 From e5e48a73998db6b4546e41e80f558cb4792176ab Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 19 Feb 2013 21:16:21 -0800 Subject: Fix "java.lang.IllegalArgumentException: View not attached to window manager" --- .../github/daneren2005/dsub/util/ModalBackgroundTask.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ModalBackgroundTask.java b/subsonic-android/src/github/daneren2005/dsub/util/ModalBackgroundTask.java index 973f4ead..1954c474 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ModalBackgroundTask.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ModalBackgroundTask.java @@ -129,11 +129,13 @@ public abstract class ModalBackgroundTask extends BackgroundTask { @Override public void updateProgress(final String message) { - getHandler().post(new Runnable() { - @Override - public void run() { - progressDialog.setMessage(message); - } - }); + if(!cancelled) { + getHandler().post(new Runnable() { + @Override + public void run() { + progressDialog.setMessage(message); + } + }); + } } } -- cgit v1.2.3 From 8bd71e7179418925150ab9afc931868f25e20b80 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 20 Feb 2013 07:30:14 -0800 Subject: Made running updates safer and less likely to crash on startup --- .../src/github/daneren2005/dsub/updates/Updater.java | 10 +++++++++- .../src/github/daneren2005/dsub/updates/Updater373.java | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/updates/Updater.java b/subsonic-android/src/github/daneren2005/dsub/updates/Updater.java index a62920b9..69cdb642 100644 --- a/subsonic-android/src/github/daneren2005/dsub/updates/Updater.java +++ b/subsonic-android/src/github/daneren2005/dsub/updates/Updater.java @@ -60,10 +60,18 @@ public class Updater { } } + public String getName() { + return this.TAG; + } + private class BackgroundUpdate extends AsyncTask { @Override protected Void doInBackground(Updater... params) { - params[0].update(context); + try { + params[0].update(context); + } catch(Exception e) { + Log.w(TAG, "Failed to run update for " + params[0].getName()); + } return null; } } diff --git a/subsonic-android/src/github/daneren2005/dsub/updates/Updater373.java b/subsonic-android/src/github/daneren2005/dsub/updates/Updater373.java index 4df31580..b56c2731 100644 --- a/subsonic-android/src/github/daneren2005/dsub/updates/Updater373.java +++ b/subsonic-android/src/github/daneren2005/dsub/updates/Updater373.java @@ -29,9 +29,10 @@ import java.io.File; * * @author Scott */ -public class Updater373 extends Updater { +public class Updater373 extends Updater { public Updater373() { super(373); + TAG = Updater373.class.getSimpleName(); } @Override @@ -39,7 +40,9 @@ public class Updater373 extends Updater { // Rename cover.jpeg to cover.jpg Log.i(TAG, "Running Updater373: updating cover.jpeg to cover.jpg"); File dir = FileUtil.getMusicDirectory(context); - moveArt(dir); + if(dir != null) { + moveArt(dir); + } } private void moveArt(File dir) { -- cgit v1.2.3 From 52e389588f7c7403d2619db18631a959b877724a Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Thu, 21 Feb 2013 16:00:05 -0800 Subject: Don't allow media button events to propogate out --- .../github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subsonic-android/src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java b/subsonic-android/src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java index cdbe8c4d..9796971f 100644 --- a/subsonic-android/src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java +++ b/subsonic-android/src/github/daneren2005/dsub/receiver/MediaButtonIntentReceiver.java @@ -40,5 +40,11 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver { Intent serviceIntent = new Intent(context, DownloadServiceImpl.class); serviceIntent.putExtra(Intent.EXTRA_KEY_EVENT, event); context.startService(serviceIntent); + + try { + abortBroadcast(); + } catch (Exception x) { + // Ignored. + } } } -- cgit v1.2.3 From f03006ac5a13522085753c69562ea5c23f911309 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Thu, 21 Feb 2013 16:13:09 -0800 Subject: Attempt to fix both oom and recycled errors --- subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java index 4c3b256b..8e014afe 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java @@ -64,7 +64,7 @@ public class ImageLoader implements Runnable { public ImageLoader(Context context) { this.context = context; final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); - final int cacheSize = maxMemory / 2; + final int cacheSize = maxMemory / 4; cache = new LruCache(cacheSize) { @Override protected int sizeOf(String key, Bitmap bitmap) { @@ -253,7 +253,10 @@ public class ImageLoader implements Runnable { try { MusicService musicService = MusicServiceFactory.getMusicService(mContext); Bitmap bitmap = musicService.getCoverArt(mContext, mEntry, mSize, mSaveSize, null); - cache.put(getKey(mEntry.getCoverArt(), mSize), bitmap); + String key = getKey(mEntry.getCoverArt(), mSize); + cache.put(key, bitmap); + // Make sure key is the most recently "used" + cache.get(key); final Drawable drawable = Util.createDrawableFromBitmap(mContext, bitmap); mTaskHandler.setDrawable(drawable); -- cgit v1.2.3 From 587de188035dc7312268055dc723aa418cf274e2 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 21 Feb 2013 20:42:53 -0800 Subject: Override default debug.keystore with my own --- subsonic-android/debug.keystore | Bin 1267 -> 1268 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/subsonic-android/debug.keystore b/subsonic-android/debug.keystore index 1cb2c3d1..4e662d41 100644 Binary files a/subsonic-android/debug.keystore and b/subsonic-android/debug.keystore differ -- cgit v1.2.3 From 543bfb2a1aee38b0ccb5dabbf3416e69cb0566d1 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 Feb 2013 07:39:25 -0800 Subject: Don't go back to the top when removing a song from a playlist --- .../daneren2005/dsub/activity/SelectAlbumActivity.java | 11 ++++++++--- .../src/github/daneren2005/dsub/view/EntryAdapter.java | 13 +++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index 392401bf..926467ec 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -53,6 +53,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { private Button moreButton; private Boolean licenseValid; private boolean showHeader = true; + private EntryAdapter entryAdapter; /** * Called when the activity is first created. @@ -695,7 +696,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE); - entryList.setAdapter(new EntryAdapter(SelectAlbumActivity.this, getImageLoader(), entries, true)); + entryList.setAdapter(entryAdapter = new EntryAdapter(SelectAlbumActivity.this, getImageLoader(), entries, true)); licenseValid = result.getSecond(); invalidateOptionsMenu(); @@ -753,12 +754,16 @@ public class SelectAlbumActivity extends SubsonicTabActivity { @Override protected void done(Void result) { - refresh(); + for(int i = indexes.size() - 1; i >= 0; i--) { + entryList.setItemChecked(indexes.get(i) + 1, false); + entryAdapter.removeAt(indexes.get(i)); + } + entryAdapter.notifyDataSetChanged(); Util.toast(SelectAlbumActivity.this, getResources().getString(R.string.removed_playlist, indexes.size(), name)); } @Override - protected void error(Throwable error) { + protected void error(Throwable error) { String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); diff --git a/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java b/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java index 6d2c7a63..476d3478 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java @@ -37,13 +37,19 @@ public class EntryAdapter extends ArrayAdapter { private final SubsonicTabActivity activity; private final ImageLoader imageLoader; private final boolean checkable; + private List entries; public EntryAdapter(SubsonicTabActivity activity, ImageLoader imageLoader, List entries, boolean checkable) { super(activity, android.R.layout.simple_list_item_1, entries); + this.entries = entries; this.activity = activity; this.imageLoader = imageLoader; this.checkable = checkable; } + + public void removeAt(int position) { + entries.remove(position); + } @Override public View getView(int position, View convertView, ViewGroup parent) { @@ -51,12 +57,7 @@ public class EntryAdapter extends ArrayAdapter { if (entry.isDirectory()) { AlbumView view; - // TODO: Reuse AlbumView objects once cover art loading is working. -// if (convertView != null && convertView instanceof AlbumView) { -// view = (AlbumView) convertView; -// } else { - view = new AlbumView(activity); -// } + view = new AlbumView(activity); view.setAlbum(entry, imageLoader); return view; -- cgit v1.2.3 From ce6e1589188e6d008d1784a9165fddd1a44e1e7a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 Feb 2013 07:39:37 -0800 Subject: Don't go back to the top when removing a playlist --- .../github/daneren2005/dsub/activity/SelectPlaylistActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java index d7deb610..5870f286 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java @@ -43,6 +43,7 @@ import java.util.List; public class SelectPlaylistActivity extends SubsonicTabActivity implements AdapterView.OnItemClickListener { private ListView list; private View emptyTextView; + private PlaylistAdapter playlistAdapter; @Override public void onCreate(Bundle savedInstanceState) { @@ -116,7 +117,7 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt @Override protected void done(List result) { - list.setAdapter(new PlaylistAdapter(SelectPlaylistActivity.this, result)); + list.setAdapter(playlistAdapter = new PlaylistAdapter(SelectPlaylistActivity.this, result)); emptyTextView.setVisibility(result.isEmpty() ? View.VISIBLE : View.GONE); } }; @@ -206,7 +207,8 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt @Override protected void done(Void result) { - refresh(); + playlistAdapter.remove(playlist); + playlistAdapter.notifyDataSetChanged(); Util.toast(SelectPlaylistActivity.this, getResources().getString(R.string.menu_deleted_playlist, playlist.getName())); } -- cgit v1.2.3 From f0c10c774562401a09afcc556d441ce8fcc71637 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 Feb 2013 07:40:04 -0800 Subject: Don't go back to the top when changing now playing list --- .../dsub/activity/DownloadActivity.java | 27 +++++++++++++++------- .../dsub/service/DownloadServiceImpl.java | 8 ++----- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index a4222ce5..f7736375 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -121,6 +121,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi private VisualizerView visualizerView; private boolean nowPlaying = true; private ScheduledFuture hideControlsFuture; + private SongListAdapter songListAdapter; /** * Called when the activity is first created. @@ -783,25 +784,35 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi } } } - - private void onDownloadListChanged() { + private void onDownloadListChanged() { + onDownloadListChanged(false); + } + private void onDownloadListChanged(boolean refresh) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } List list; - if(nowPlaying) + if(nowPlaying) { list = downloadService.getSongs(); - else + } + else { list = downloadService.getBackgroundDownloads(); + } - if(downloadService.isShufflePlayEnabled()) + if(downloadService.isShufflePlayEnabled()) { emptyTextView.setText(R.string.download_shuffle_loading); - else + } + else { emptyTextView.setText(R.string.download_empty); + } - playlistView.setAdapter(new SongListAdapter(list)); + if(songListAdapter == null || refresh) { + playlistView.setAdapter(songListAdapter = new SongListAdapter(list)); + } else { + songListAdapter.notifyDataSetChanged(); + } emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE); currentRevision = downloadService.getDownloadListUpdateRevision(); @@ -1004,7 +1015,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi private void toggleNowPlaying() { nowPlaying = !nowPlaying; setTitle(nowPlaying ? "Now Playing" : "Downloading"); - onDownloadListChanged(); + onDownloadListChanged(true); } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 9e6662cf..c0275386 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -498,9 +498,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { @Override public synchronized List getSongs() { - List temp = new ArrayList(); - temp.addAll(downloadList); - return temp; + return downloadList; } @Override @@ -513,9 +511,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { @Override public synchronized List getBackgroundDownloads() { - List temp = new ArrayList(); - temp.addAll(backgroundDownloadList); - return temp; + return backgroundDownloadList; } /** Plays either the current song (resume) or the first/next one in queue. */ -- cgit v1.2.3 From c9959102e13c8085c33058fd0cfdb60600f541fe Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 Feb 2013 08:20:56 -0800 Subject: Revert previous jump to the top fix --- .../src/github/daneren2005/dsub/activity/DownloadActivity.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index f7ee55d3..3028a260 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -817,16 +817,9 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi else emptyTextView.setText(R.string.download_empty); - // Save old position - Parcelable state = playlistView.onSaveInstanceState(); - // Set new items playlistView.setAdapter(new SongListAdapter(list)); - emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE); currentRevision = downloadService.getDownloadListUpdateRevision(); - - // Restore old position - playlistView.onRestoreInstanceState(state); switch (downloadService.getRepeatMode()) { case OFF: -- cgit v1.2.3 From 21073a4b69fb8adbf84f8e778d495625767a55c0 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 Feb 2013 18:49:20 -0800 Subject: Added submodules --- DragSortListView | 1 + 1 file changed, 1 insertion(+) create mode 160000 DragSortListView diff --git a/DragSortListView b/DragSortListView new file mode 160000 index 00000000..c4166a8f --- /dev/null +++ b/DragSortListView @@ -0,0 +1 @@ +Subproject commit c4166a8fb4fd46688061ec915d4fa51de374e0a1 -- cgit v1.2.3 From 51b74087ae8a7dfcc28be123d58bff140c5c8d14 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 Feb 2013 18:52:07 -0800 Subject: Updated ActionBarSherlock --- ActionBarSherlock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ActionBarSherlock b/ActionBarSherlock index 9598f2bb..90939dc3 160000 --- a/ActionBarSherlock +++ b/ActionBarSherlock @@ -1 +1 @@ -Subproject commit 9598f2bb2ceed4a834cd5586a903f270ca4c0ccc +Subproject commit 90939dc3925ffaaa0de269bbbe1b35e274968ea1 -- cgit v1.2.3 From 9a87aa9c07ca165cc32680abbec7ae627e9f39fa Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 Feb 2013 18:58:26 -0800 Subject: Updated gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2fdc3270..eb01e9aa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ subsonic-android/.classpath subsonic-android/.project subsonic-android/bin/* subsonic-android/gen/* -/subsonic-android/libs/ActionBarSherlock/gen/ -/subsonic-android/private/* \ No newline at end of file +subsonic-android/private/* \ No newline at end of file -- cgit v1.2.3 From 8d6185dd174219f4058241b94c67451e9dfa29cd Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 Feb 2013 19:25:19 -0800 Subject: Async serializing playlist so it doesn't block main thread --- .../service/DownloadServiceLifecycleSupport.java | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 6ff45dee..e04fc00c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -30,6 +30,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.RemoteControlClient; +import android.os.AsyncTask; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log; @@ -181,15 +182,7 @@ public class DownloadServiceLifecycleSupport { } public void serializeDownloadQueue() { - State state = new State(); - for (DownloadFile downloadFile : downloadService.getSongs()) { - state.songs.add(downloadFile.getSong()); - } - state.currentPlayingIndex = downloadService.getCurrentPlayingIndex(); - state.currentPlayingPosition = downloadService.getPlayerPosition(); - - Log.i(TAG, "Serialized currentPlayingIndex: " + state.currentPlayingIndex + ", currentPlayingPosition: " + state.currentPlayingPosition); - FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER); + new SerializeTask().execute(); } private void deserializeDownloadQueue() { @@ -277,4 +270,22 @@ public class DownloadServiceLifecycleSupport { private int currentPlayingIndex; private int currentPlayingPosition; } + + private class SerializeTask extends AsyncTask { + @Override + protected Void doInBackground(Void... params) { + List songs = new ArrayList(downloadService.getSongs()); + State state = new State(); + for (DownloadFile downloadFile : songs) { + state.songs.add(downloadFile.getSong()); + } + state.currentPlayingIndex = downloadService.getCurrentPlayingIndex(); + state.currentPlayingPosition = downloadService.getPlayerPosition(); + + Log.i(TAG, "Serialized currentPlayingIndex: " + state.currentPlayingIndex + ", currentPlayingPosition: " + state.currentPlayingPosition); + FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER); + + return null; + } + } } \ No newline at end of file -- cgit v1.2.3 From 956c3119a1fe2dcdbdbfab90e72c606d2fac3a4b Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 23 Feb 2013 10:03:55 -0800 Subject: Work around for dslv to take up entire width --- subsonic-android/src/github/daneren2005/dsub/view/UpdateView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subsonic-android/src/github/daneren2005/dsub/view/UpdateView.java b/subsonic-android/src/github/daneren2005/dsub/view/UpdateView.java index fee37ff0..9cc627cc 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/UpdateView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/UpdateView.java @@ -21,6 +21,8 @@ package github.daneren2005.dsub.view; import android.content.Context; import android.os.Handler; import android.util.Log; +import android.view.ViewGroup; +import android.widget.AbsListView; import android.widget.LinearLayout; import java.util.WeakHashMap; @@ -32,6 +34,10 @@ public class UpdateView extends LinearLayout { public UpdateView(Context context) { super(context); + setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.FILL_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT)); + INSTANCES.put(this, null); int instanceCount = INSTANCES.size(); if (instanceCount > 50) { -- cgit v1.2.3