Remove SDK < 19 code paths

This commit is contained in:
Andrew Rabert 2017-03-05 12:01:13 -05:00
parent a1f5a60b8f
commit c101be0bc9
7 changed files with 14 additions and 49 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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;

View File

@ -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() {

View File

@ -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);
}
}
}