mirror of
https://github.com/nvllsvm/Audinaut
synced 2025-02-16 11:31:21 +01:00
Remove SDK < 19 code paths
This commit is contained in:
parent
a1f5a60b8f
commit
c101be0bc9
@ -839,8 +839,6 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
|
|||||||
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||||
|
|
||||||
getWindow().getDecorView().setSystemUiVisibility(flags);
|
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);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
@ -31,23 +31,13 @@ public class AudioEffectsController {
|
|||||||
private final Context context;
|
private final Context context;
|
||||||
private int audioSessionId = 0;
|
private int audioSessionId = 0;
|
||||||
|
|
||||||
private boolean available = false;
|
|
||||||
|
|
||||||
private EqualizerController equalizerController;
|
private EqualizerController equalizerController;
|
||||||
|
|
||||||
public AudioEffectsController(Context context, int audioSessionId) {
|
public AudioEffectsController(Context context, int audioSessionId) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.audioSessionId = audioSessionId;
|
this.audioSessionId = audioSessionId;
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
|
||||||
available = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAvailable() {
|
|
||||||
return available;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void release() {
|
public void release() {
|
||||||
if(equalizerController != null) {
|
if(equalizerController != null) {
|
||||||
equalizerController.release();
|
equalizerController.release();
|
||||||
@ -55,13 +45,9 @@ public class AudioEffectsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EqualizerController getEqualizerController() {
|
public EqualizerController getEqualizerController() {
|
||||||
if (available && equalizerController == null) {
|
if (equalizerController == null) {
|
||||||
equalizerController = new EqualizerController(context, audioSessionId);
|
equalizerController = new EqualizerController(context, audioSessionId);
|
||||||
if (!equalizerController.isAvailable()) {
|
equalizerController.loadSettings();
|
||||||
equalizerController = null;
|
|
||||||
} else {
|
|
||||||
equalizerController.loadSettings();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return equalizerController;
|
return equalizerController;
|
||||||
}
|
}
|
||||||
|
@ -393,8 +393,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
|
|||||||
menu.findItem(R.id.menu_remove_played).setChecked(true);
|
menu.findItem(R.id.menu_remove_played).setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerAvailable();
|
if(downloadService != null) {
|
||||||
if(equalizerAvailable) {
|
|
||||||
SharedPreferences prefs = Util.getPreferences(context);
|
SharedPreferences prefs = Util.getPreferences(context);
|
||||||
boolean equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false);
|
boolean equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false);
|
||||||
if (equalizerOn && downloadService != null) {
|
if (equalizerOn && downloadService != null) {
|
||||||
|
@ -251,7 +251,7 @@ public class DownloadService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onTrimMemory(int level) {
|
public void onTrimMemory(int level) {
|
||||||
ImageLoader imageLoader = SubsonicActivity.getStaticImageLoader(this);
|
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);
|
Log.i(TAG, "Memory Trim Level: " + level);
|
||||||
if (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
|
if (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
|
||||||
if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
|
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() {
|
public synchronized void reset() {
|
||||||
if (bufferTask != null) {
|
if (bufferTask != null) {
|
||||||
bufferTask.cancel();
|
bufferTask.cancel();
|
||||||
@ -1143,7 +1142,7 @@ public class DownloadService extends Service {
|
|||||||
setPlayerState(IDLE);
|
setPlayerState(IDLE);
|
||||||
mediaPlayer.setOnErrorListener(null);
|
mediaPlayer.setOnErrorListener(null);
|
||||||
mediaPlayer.setOnCompletionListener(null);
|
mediaPlayer.setOnCompletionListener(null);
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && nextSetup) {
|
if(nextSetup) {
|
||||||
mediaPlayer.setNextMediaPlayer(null);
|
mediaPlayer.setNextMediaPlayer(null);
|
||||||
nextSetup = false;
|
nextSetup = false;
|
||||||
}
|
}
|
||||||
@ -1154,11 +1153,10 @@ public class DownloadService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
|
||||||
public synchronized void resetNext() {
|
public synchronized void resetNext() {
|
||||||
try {
|
try {
|
||||||
if (nextMediaPlayer != null) {
|
if (nextMediaPlayer != null) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && nextSetup) {
|
if (nextSetup) {
|
||||||
mediaPlayer.setNextMediaPlayer(null);
|
mediaPlayer.setNextMediaPlayer(null);
|
||||||
}
|
}
|
||||||
nextSetup = false;
|
nextSetup = false;
|
||||||
@ -1366,10 +1364,6 @@ public class DownloadService extends Service {
|
|||||||
return suggestedPlaylistId;
|
return suggestedPlaylistId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getEqualizerAvailable() {
|
|
||||||
return effectsController.isAvailable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public EqualizerController getEqualizerController() {
|
public EqualizerController getEqualizerController() {
|
||||||
EqualizerController controller = null;
|
EqualizerController controller = null;
|
||||||
try {
|
try {
|
||||||
@ -1532,7 +1526,6 @@ public class DownloadService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
|
||||||
private synchronized void setupNext(final DownloadFile downloadFile) {
|
private synchronized void setupNext(final DownloadFile downloadFile) {
|
||||||
try {
|
try {
|
||||||
final File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile();
|
final File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile();
|
||||||
@ -1558,7 +1551,7 @@ public class DownloadService extends Service {
|
|||||||
try {
|
try {
|
||||||
setNextPlayerState(PREPARED);
|
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);
|
mediaPlayer.setNextMediaPlayer(nextMediaPlayer);
|
||||||
nextSetup = true;
|
nextSetup = true;
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,11 @@ public final class Notifications {
|
|||||||
if(playing) {
|
if(playing) {
|
||||||
notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
|
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);
|
||||||
RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded);
|
setupViews(expandedContentView ,context, song, true, playing);
|
||||||
setupViews(expandedContentView ,context, song, true, playing);
|
notification.bigContentView = expandedContentView;
|
||||||
notification.bigContentView = expandedContentView;
|
notification.priority = Notification.PRIORITY_HIGH;
|
||||||
notification.priority = Notification.PRIORITY_HIGH;
|
|
||||||
}
|
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
notification.visibility = Notification.VISIBILITY_PUBLIC;
|
notification.visibility = Notification.VISIBILITY_PUBLIC;
|
||||||
|
|
||||||
|
@ -1218,7 +1218,7 @@ public final class Util {
|
|||||||
|
|
||||||
@TargetApi(8)
|
@TargetApi(8)
|
||||||
public static void requestAudioFocus(final Context context) {
|
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);
|
final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
audioManager.requestAudioFocus(focusListener = new OnAudioFocusChangeListener() {
|
audioManager.requestAudioFocus(focusListener = new OnAudioFocusChangeListener() {
|
||||||
public void onAudioFocusChange(int focusChange) {
|
public void onAudioFocusChange(int focusChange) {
|
||||||
@ -1372,11 +1372,7 @@ public final class Util {
|
|||||||
|
|
||||||
public static WifiManager.WifiLock createWifiLock(Context context, String tag) {
|
public static WifiManager.WifiLock createWifiLock(Context context, String tag) {
|
||||||
WifiManager wm = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
WifiManager wm = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||||
int lockType = WifiManager.WIFI_MODE_FULL;
|
return wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, tag);
|
||||||
if (Build.VERSION.SDK_INT >= 12) {
|
|
||||||
lockType = 3;
|
|
||||||
}
|
|
||||||
return wm.createWifiLock(lockType, tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Random getRandom() {
|
public static Random getRandom() {
|
||||||
|
@ -57,11 +57,5 @@ public class CardView extends FrameLayout{
|
|||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
setElevation(getResources().getInteger(R.integer.Card_Elevation));
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user