aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-08-31 10:38:50 -0700
committerScott Jackson <daneren2005@gmail.com>2014-08-31 10:38:50 -0700
commit1e45bffc1766c1ca71beac3c30410193725256ae (patch)
tree91883a528edcc132f0508ad45343cb158612be87 /src
parentca44dbc7ef9c9657c4b96add002a3149f0cb1c7e (diff)
downloaddsub-1e45bffc1766c1ca71beac3c30410193725256ae.tar.gz
dsub-1e45bffc1766c1ca71beac3c30410193725256ae.tar.bz2
dsub-1e45bffc1766c1ca71beac3c30410193725256ae.zip
Just remove visualizer. It sucks anyways.
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/audiofx/AudioEffectsController.java13
-rw-r--r--src/github/daneren2005/dsub/audiofx/VisualizerController.java103
-rw-r--r--src/github/daneren2005/dsub/fragments/NowPlayingFragment.java46
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java21
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--src/github/daneren2005/dsub/view/VisualizerView.java135
6 files changed, 0 insertions, 319 deletions
diff --git a/src/github/daneren2005/dsub/audiofx/AudioEffectsController.java b/src/github/daneren2005/dsub/audiofx/AudioEffectsController.java
index f53a4dff..1933bd64 100644
--- a/src/github/daneren2005/dsub/audiofx/AudioEffectsController.java
+++ b/src/github/daneren2005/dsub/audiofx/AudioEffectsController.java
@@ -34,7 +34,6 @@ public class AudioEffectsController {
private boolean available = false;
private EqualizerController equalizerController;
- private VisualizerController visualizerController;
public AudioEffectsController(Context context, int audioSessionId) {
this.context = context;
@@ -53,9 +52,6 @@ public class AudioEffectsController {
if(equalizerController != null) {
equalizerController.release();
}
- if(visualizerController != null) {
- visualizerController.release();
- }
}
public EqualizerController getEqualizerController() {
@@ -69,14 +65,5 @@ public class AudioEffectsController {
}
return equalizerController;
}
- public VisualizerController getVisualizerController() {
- if (available && visualizerController == null) {
- visualizerController = new VisualizerController(context, audioSessionId);
- if (!visualizerController.isAvailable()) {
- visualizerController = null;
- }
- }
- return visualizerController;
- }
}
diff --git a/src/github/daneren2005/dsub/audiofx/VisualizerController.java b/src/github/daneren2005/dsub/audiofx/VisualizerController.java
deleted file mode 100644
index 92e3712c..00000000
--- a/src/github/daneren2005/dsub/audiofx/VisualizerController.java
+++ /dev/null
@@ -1,103 +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 2011 (C) Sindre Mehus
- */
-package github.daneren2005.dsub.audiofx;
-
-import android.content.Context;
-import android.media.audiofx.Visualizer;
-import android.util.Log;
-
-/**
- * Backward-compatible wrapper for {@link Visualizer}, which is API Level 9.
- *
- * @author Sindre Mehus
- * @version $Id$
- */
-public class VisualizerController {
-
- private static final String TAG = VisualizerController.class.getSimpleName();
- private static final int PREFERRED_CAPTURE_SIZE = 128; // Must be a power of two.
-
- private final Context context;
- private Visualizer visualizer;
- private boolean released = false;
- private int audioSessionId = 0;
-
- // Class initialization fails when this throws an exception.
- static {
- try {
- Class.forName("android.media.audiofx.Visualizer");
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Throws an exception if the {@link Visualizer} class is not available.
- */
- public static void checkAvailable() throws Throwable {
- // Calling here forces class initialization.
- }
-
- public VisualizerController(Context context, int audioSessionId) {
- this.context = context;
- try {
- this.audioSessionId = audioSessionId;
- visualizer = new Visualizer(audioSessionId);
- } catch (Throwable x) {
- Log.w(TAG, "Failed to create visualizer.", x);
- }
-
- if (visualizer != null) {
- int[] captureSizeRange = Visualizer.getCaptureSizeRange();
- int captureSize = Math.max(PREFERRED_CAPTURE_SIZE, captureSizeRange[0]);
- captureSize = Math.min(captureSize, captureSizeRange[1]);
- visualizer.setCaptureSize(captureSize);
- }
- }
-
- public boolean isAvailable() {
- return visualizer != null;
- }
-
- public boolean isEnabled() {
- return isAvailable() && visualizer.getEnabled();
- }
-
- 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/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index 150c11b3..c087df5a 100644
--- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -71,7 +71,6 @@ import github.daneren2005.dsub.view.DownloadFileAdapter;
import github.daneren2005.dsub.view.FadeOutAnimation;
import github.daneren2005.dsub.view.UpdateView;
import github.daneren2005.dsub.util.Util;
-import github.daneren2005.dsub.view.VisualizerView;
import static github.daneren2005.dsub.domain.MusicDirectory.Entry;
import static github.daneren2005.dsub.domain.PlayerState.*;
@@ -111,7 +110,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
private View stopButton;
private View startButton;
private ImageButton repeatButton;
- private Button visualizerButton;
private View toggleListButton;
private ImageButton starButton;
private ImageButton bookmarkButton;
@@ -123,7 +121,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
private long currentRevision;
private int swipeDistance;
private int swipeVelocity;
- private VisualizerView visualizerView;
private ScheduledFuture<?> hideControlsFuture;
private List<DownloadFile> songList;
private DownloadFileAdapter songListAdapter;
@@ -186,11 +183,9 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
stopButton =rootView.findViewById(R.id.download_stop);
startButton =rootView.findViewById(R.id.download_start);
repeatButton = (ImageButton)rootView.findViewById(R.id.download_repeat);
- visualizerButton = (Button)rootView.findViewById(R.id.download_visualizer);
bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark);
rateBadButton = (ImageButton) rootView.findViewById(R.id.download_rating_bad);
rateGoodButton = (ImageButton) rootView.findViewById(R.id.download_rating_good);
- LinearLayout visualizerViewLayout = (LinearLayout)rootView.findViewById(R.id.download_visualizer_view_layout);
toggleListButton =rootView.findViewById(R.id.download_toggle_list);
starButton = (ImageButton)rootView.findViewById(R.id.download_star);
@@ -219,7 +214,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
pauseButton.setOnTouchListener(touchListener);
stopButton.setOnTouchListener(touchListener);
startButton.setOnTouchListener(touchListener);
- visualizerButton.setOnTouchListener(touchListener);
bookmarkButton.setOnTouchListener(touchListener);
rateBadButton.setOnTouchListener(touchListener);
rateGoodButton.setOnTouchListener(touchListener);
@@ -369,23 +363,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
}
});
- visualizerButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- boolean active = !visualizerView.isActive();
- visualizerView.setActive(active);
- boolean isActive = visualizerView.isActive();
- getDownloadService().setShowVisualization(isActive);
- updateButtons();
- if(active == isActive) {
- Util.toast(context, active ? R.string.download_visualizer_on : R.string.download_visualizer_off);
- } else {
- Util.toast(context, "Failed to start visualizer. Try restarting.");
- }
- setControlsVisible(true);
- }
- });
-
bookmarkButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -519,18 +496,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
downloadService.setShufflePlayEnabled(true);
}
- boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerAvailable();
-
- if (!equalizerAvailable) {
- visualizerButton.setVisibility(View.GONE);
- } else {
- visualizerView = new VisualizerView(context);
- if(downloadService.getShowVisualization()) {
- visualizerView.setActive(true);
- }
- visualizerViewLayout.addView(visualizerView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
- }
-
if(Build.MODEL.equals("Nexus 4")) {
View slider = rootView.findViewById(R.id.download_slider);
slider.setPadding(0, 0, 0, 0);
@@ -842,10 +807,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
context.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
- if (visualizerView != null && downloadService != null && downloadService.getShowVisualization()) {
- visualizerView.setActive(true);
- }
-
updateButtons();
if(currentPlaying == null && downloadService != null && currentPlaying == downloadService.getCurrentPlaying()) {
@@ -860,9 +821,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
public void onPause() {
super.onPause();
executorService.shutdown();
- if (visualizerView != null && visualizerView.isActive()) {
- visualizerView.setActive(false);
- }
if(getDownloadService() != null) {
getDownloadService().stopRemoteScan();
}
@@ -918,10 +876,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
if(context == null) {
return;
}
-
- if (visualizerView != null) {
- visualizerButton.setTextColor(visualizerView.isActive() ? COLOR_BUTTON_ENABLED : COLOR_BUTTON_DISABLED);
- }
if(Util.isOffline(context)) {
bookmarkButton.setVisibility(View.GONE);
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index e5495bc2..b3198f3d 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -32,7 +32,6 @@ import static github.daneren2005.dsub.domain.PlayerState.STOPPED;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.audiofx.AudioEffectsController;
import github.daneren2005.dsub.audiofx.EqualizerController;
-import github.daneren2005.dsub.audiofx.VisualizerController;
import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PlayerState;
@@ -137,7 +136,6 @@ public class DownloadService extends Service {
private boolean downloadOngoing = false;
private AudioEffectsController effectsController;
- private boolean showVisualization;
private RemoteControlState remoteState = RemoteControlState.LOCAL;
private PositionCache positionCache;
private BufferProxy proxy;
@@ -187,10 +185,6 @@ public class DownloadService extends Service {
if(prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false)) {
getEqualizerController();
}
- if(prefs.getBoolean(Constants.PREFERENCES_VISUALIZER_ON, false)) {
- getVisualizerController();
- showVisualization = true;
- }
mediaPlayerLooper = Looper.myLooper();
mediaPlayerHandler = new Handler(mediaPlayerLooper);
@@ -477,17 +471,6 @@ public class DownloadService extends Service {
editor.commit();
}
- public boolean getShowVisualization() {
- return showVisualization;
- }
-
- public void setShowVisualization(boolean showVisualization) {
- this.showVisualization = showVisualization;
- SharedPreferences.Editor editor = Util.getPreferences(this).edit();
- editor.putBoolean(Constants.PREFERENCES_VISUALIZER_ON, showVisualization);
- editor.commit();
- }
-
public synchronized DownloadFile forSong(MusicDirectory.Entry song) {
DownloadFile returnFile = null;
for (DownloadFile downloadFile : downloadList) {
@@ -1180,10 +1163,6 @@ public class DownloadService extends Service {
return effectsController.getEqualizerController();
}
- public VisualizerController getVisualizerController() {
- return effectsController.getVisualizerController();
- }
-
public MediaRouteSelector getRemoteSelector() {
return mediaRouter.getSelector();
}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index 5fb872f2..48f0d2f3 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -108,7 +108,6 @@ 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_EQUALIZER_ON = "equalizerOn";
- public static final String PREFERENCES_VISUALIZER_ON = "visualizerOn";
public static final String PREFERENCES_EQUALIZER_SETTINGS = "equalizerSettings";
public static final String PREFERENCES_KEY_PERSISTENT_NOTIFICATION = "persistentNotification";
public static final String PREFERENCES_KEY_GAPLESS_PLAYBACK = "gaplessPlayback";
diff --git a/src/github/daneren2005/dsub/view/VisualizerView.java b/src/github/daneren2005/dsub/view/VisualizerView.java
deleted file mode 100644
index aa921930..00000000
--- a/src/github/daneren2005/dsub/view/VisualizerView.java
+++ /dev/null
@@ -1,135 +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 2011 (C) Sindre Mehus
- */
-package github.daneren2005.dsub.view;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.media.audiofx.Visualizer;
-import android.view.View;
-import github.daneren2005.dsub.audiofx.VisualizerController;
-import github.daneren2005.dsub.domain.PlayerState;
-import github.daneren2005.dsub.service.DownloadService;
-
-/**
- * A simple class that draws waveform data received from a
- * {@link Visualizer.OnDataCaptureListener#onWaveFormDataCapture}
- *
- * @author Sindre Mehus
- * @version $Id$
- */
-public class VisualizerView extends View {
-
- private static final int PREFERRED_CAPTURE_RATE_MILLIHERTZ = 20000;
-
- private final Paint paint = new Paint();
-
- private byte[] data;
- private float[] points;
- private boolean active = false;
-
- public VisualizerView(Context context) {
- super(context);
-
- paint.setStrokeWidth(2f);
- paint.setAntiAlias(true);
- paint.setColor(Color.rgb(51, 181, 229));
- }
-
- public boolean isActive() {
- return active;
- }
-
- public void setActive(boolean active) {
- this.active = active;
- VisualizerController visualizerController = getVizualiser();
- Visualizer visualizer = visualizerController == null ? null : visualizerController.getVisualizer();
- if (visualizer == null) {
- this.active = false;
- return;
- }
-
- int captureRate = Math.min(PREFERRED_CAPTURE_RATE_MILLIHERTZ, Visualizer.getMaxCaptureRate());
- if (active) {
- visualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
- @Override
- public void onWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate) {
- updateVisualizer(waveform);
- }
-
- @Override
- public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate) {
- }
- }, captureRate, true, false);
- } else {
- visualizer.setDataCaptureListener(null, captureRate, false, false);
- }
-
- visualizer.setEnabled(active);
- if(!active) {
- visualizerController.release();
- }
- invalidate();
- }
-
- private VisualizerController getVizualiser() {
- DownloadService downloadService = DownloadService.getInstance();
- VisualizerController visualizerController = downloadService == null ? null : downloadService.getVisualizerController();
- return visualizerController;
- }
-
- private void updateVisualizer(byte[] waveform) {
- this.data = waveform;
- invalidate();
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- if (!active) {
- return;
- }
- DownloadService downloadService = DownloadService.getInstance();
- if (downloadService != null && downloadService.getPlayerState() != PlayerState.STARTED) {
- return;
- }
-
- if (data == null) {
- return;
- }
-
- if (points == null || points.length < data.length * 4) {
- points = new float[data.length * 4];
- }
-
- int w = getWidth();
- int h = getHeight();
-
- for (int i = 0; i < data.length - 1; i++) {
- points[i * 4] = w * i / (data.length - 1);
- points[i * 4 + 1] = h / 2 + ((byte) (data[i] + 128)) * (h / 2) / 128;
- points[i * 4 + 2] = w * (i + 1) / (data.length - 1);
- points[i * 4 + 3] = h / 2 + ((byte) (data[i + 1] + 128)) * (h / 2) / 128;
- }
-
- canvas.drawLines(points, paint);
- }
-}