From c101be0bc953868cd88bd0da4fb48a80c5c856b5 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sun, 5 Mar 2017 12:01:13 -0500 Subject: [PATCH] Remove SDK < 19 code paths --- .../audinaut/activity/SubsonicActivity.java | 2 -- .../audiofx/AudioEffectsController.java | 18 ++---------------- .../audinaut/fragments/NowPlayingFragment.java | 3 +-- .../audinaut/service/DownloadService.java | 15 ++++----------- .../nullsum/audinaut/util/Notifications.java | 11 +++++------ .../java/net/nullsum/audinaut/util/Util.java | 8 ++------ .../net/nullsum/audinaut/view/CardView.java | 6 ------ 7 files changed, 14 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java b/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java index b0a7956..03bd2c3 100644 --- a/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java +++ b/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java @@ -839,8 +839,6 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; getWindow().getDecorView().setSystemUiVisibility(flags); - } else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - getWindow().requestFeature(Window.FEATURE_NO_TITLE); } getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } diff --git a/app/src/main/java/net/nullsum/audinaut/audiofx/AudioEffectsController.java b/app/src/main/java/net/nullsum/audinaut/audiofx/AudioEffectsController.java index c23721f..a63eed7 100644 --- a/app/src/main/java/net/nullsum/audinaut/audiofx/AudioEffectsController.java +++ b/app/src/main/java/net/nullsum/audinaut/audiofx/AudioEffectsController.java @@ -31,23 +31,13 @@ public class AudioEffectsController { private final Context context; private int audioSessionId = 0; - private boolean available = false; - private EqualizerController equalizerController; public AudioEffectsController(Context context, int audioSessionId) { this.context = context; this.audioSessionId = audioSessionId; - - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - available = true; - } } - public boolean isAvailable() { - return available; - } - public void release() { if(equalizerController != null) { equalizerController.release(); @@ -55,13 +45,9 @@ public class AudioEffectsController { } public EqualizerController getEqualizerController() { - if (available && equalizerController == null) { + if (equalizerController == null) { equalizerController = new EqualizerController(context, audioSessionId); - if (!equalizerController.isAvailable()) { - equalizerController = null; - } else { - equalizerController.loadSettings(); - } + equalizerController.loadSettings(); } return equalizerController; } diff --git a/app/src/main/java/net/nullsum/audinaut/fragments/NowPlayingFragment.java b/app/src/main/java/net/nullsum/audinaut/fragments/NowPlayingFragment.java index 00f2716..3655924 100644 --- a/app/src/main/java/net/nullsum/audinaut/fragments/NowPlayingFragment.java +++ b/app/src/main/java/net/nullsum/audinaut/fragments/NowPlayingFragment.java @@ -393,8 +393,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis menu.findItem(R.id.menu_remove_played).setChecked(true); } - boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerAvailable(); - if(equalizerAvailable) { + if(downloadService != null) { SharedPreferences prefs = Util.getPreferences(context); boolean equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false); if (equalizerOn && downloadService != null) { diff --git a/app/src/main/java/net/nullsum/audinaut/service/DownloadService.java b/app/src/main/java/net/nullsum/audinaut/service/DownloadService.java index 2a2ef05..6ff07ba 100644 --- a/app/src/main/java/net/nullsum/audinaut/service/DownloadService.java +++ b/app/src/main/java/net/nullsum/audinaut/service/DownloadService.java @@ -251,7 +251,7 @@ public class DownloadService extends Service { @Override public void onTrimMemory(int level) { ImageLoader imageLoader = SubsonicActivity.getStaticImageLoader(this); - if(imageLoader != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + if(imageLoader != null) { Log.i(TAG, "Memory Trim Level: " + level); if (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) { if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) { @@ -1133,7 +1133,6 @@ public class DownloadService extends Service { } } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public synchronized void reset() { if (bufferTask != null) { bufferTask.cancel(); @@ -1143,7 +1142,7 @@ public class DownloadService extends Service { setPlayerState(IDLE); mediaPlayer.setOnErrorListener(null); mediaPlayer.setOnCompletionListener(null); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && nextSetup) { + if(nextSetup) { mediaPlayer.setNextMediaPlayer(null); nextSetup = false; } @@ -1154,11 +1153,10 @@ public class DownloadService extends Service { } } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public synchronized void resetNext() { try { if (nextMediaPlayer != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && nextSetup) { + if (nextSetup) { mediaPlayer.setNextMediaPlayer(null); } nextSetup = false; @@ -1366,10 +1364,6 @@ public class DownloadService extends Service { return suggestedPlaylistId; } - public boolean getEqualizerAvailable() { - return effectsController.isAvailable(); - } - public EqualizerController getEqualizerController() { EqualizerController controller = null; try { @@ -1532,7 +1526,6 @@ public class DownloadService extends Service { } } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private synchronized void setupNext(final DownloadFile downloadFile) { try { final File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile(); @@ -1558,7 +1551,7 @@ public class DownloadService extends Service { try { setNextPlayerState(PREPARED); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && (playerState == PlayerState.STARTED || playerState == PlayerState.PAUSED)) { + if(playerState == PlayerState.STARTED || playerState == PlayerState.PAUSED) { mediaPlayer.setNextMediaPlayer(nextMediaPlayer); nextSetup = true; } diff --git a/app/src/main/java/net/nullsum/audinaut/util/Notifications.java b/app/src/main/java/net/nullsum/audinaut/util/Notifications.java index 9a0e8e7..370580f 100644 --- a/app/src/main/java/net/nullsum/audinaut/util/Notifications.java +++ b/app/src/main/java/net/nullsum/audinaut/util/Notifications.java @@ -65,12 +65,11 @@ public final class Notifications { if(playing) { notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; } - if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.JELLY_BEAN){ - RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded); - setupViews(expandedContentView ,context, song, true, playing); - notification.bigContentView = expandedContentView; - notification.priority = Notification.PRIORITY_HIGH; - } + RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded); + setupViews(expandedContentView ,context, song, true, playing); + notification.bigContentView = expandedContentView; + notification.priority = Notification.PRIORITY_HIGH; + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { notification.visibility = Notification.VISIBILITY_PUBLIC; diff --git a/app/src/main/java/net/nullsum/audinaut/util/Util.java b/app/src/main/java/net/nullsum/audinaut/util/Util.java index b000101..4c75c0a 100644 --- a/app/src/main/java/net/nullsum/audinaut/util/Util.java +++ b/app/src/main/java/net/nullsum/audinaut/util/Util.java @@ -1218,7 +1218,7 @@ public final class Util { @TargetApi(8) public static void requestAudioFocus(final Context context) { - if (Build.VERSION.SDK_INT >= 8 && focusListener == null) { + if (focusListener == null) { final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.requestAudioFocus(focusListener = new OnAudioFocusChangeListener() { public void onAudioFocusChange(int focusChange) { @@ -1372,11 +1372,7 @@ public final class Util { public static WifiManager.WifiLock createWifiLock(Context context, String tag) { WifiManager wm = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); - int lockType = WifiManager.WIFI_MODE_FULL; - if (Build.VERSION.SDK_INT >= 12) { - lockType = 3; - } - return wm.createWifiLock(lockType, tag); + return wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, tag); } public static Random getRandom() { diff --git a/app/src/main/java/net/nullsum/audinaut/view/CardView.java b/app/src/main/java/net/nullsum/audinaut/view/CardView.java index 74160a9..cf8e8b1 100644 --- a/app/src/main/java/net/nullsum/audinaut/view/CardView.java +++ b/app/src/main/java/net/nullsum/audinaut/view/CardView.java @@ -57,11 +57,5 @@ public class CardView extends FrameLayout{ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setElevation(getResources().getInteger(R.integer.Card_Elevation)); } - - // clipPath is not supported with Hardware Acceleration before API 18 - // http://stackoverflow.com/questions/8895677/work-around-canvas-clippath-that-is-not-supported-in-android-any-more/8895894#8895894 - if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 && isHardwareAccelerated()) { - setLayerType(View.LAYER_TYPE_SOFTWARE, null); - } } }