diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/ServerRowAdapter.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/ServerRowAdapter.kt index 85190acb..2b9e4be1 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/ServerRowAdapter.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/ServerRowAdapter.kt @@ -1,9 +1,7 @@ package org.moire.ultrasonic.fragment import android.content.Context -import android.graphics.Color import android.graphics.drawable.Drawable -import android.os.Build import android.view.LayoutInflater import android.view.Menu import android.view.MenuItem @@ -109,10 +107,8 @@ internal class ServerRowAdapter( } // Set colors - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - icon?.setTint(ServerColor.getForegroundColor(context, setting?.color)) - background?.setTint(ServerColor.getBackgroundColor(context, setting?.color)) - } + icon?.setTint(ServerColor.getForegroundColor(context, setting?.color)) + background?.setTint(ServerColor.getBackgroundColor(context, setting?.color)) // Set the final drawables image?.setImageDrawable(icon) @@ -120,32 +116,16 @@ internal class ServerRowAdapter( // Highlight the Active Server's row by changing its background if (index == activeServerProvider.getActiveServer().index) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - layout?.background = ContextCompat.getDrawable(context, R.drawable.select_ripple) - } else { - layout?.setBackgroundResource( - Util.getResourceFromAttribute(context, R.attr.list_selector_holo_selected) - ) - } + layout?.background = ContextCompat.getDrawable(context, R.drawable.select_ripple) } else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - layout?.background = ContextCompat.getDrawable(context, R.drawable.default_ripple) - } else { - layout?.setBackgroundResource( - Util.getResourceFromAttribute(context, R.attr.list_selector_holo) - ) - } + layout?.background = ContextCompat.getDrawable(context, R.drawable.default_ripple) } // Add the context menu for the row - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - serverMenu?.background = ContextCompat.getDrawable( - context, - R.drawable.select_ripple_circle - ) - } else { - serverMenu?.setBackgroundColor(Color.TRANSPARENT) - } + serverMenu?.background = ContextCompat.getDrawable( + context, + R.drawable.select_ripple_circle + ) serverMenu?.setOnClickListener { view -> serverMenuClick(view, index) } diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/AudioFocusHandler.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/AudioFocusHandler.kt index 2f36974a..34ad87cc 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/AudioFocusHandler.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/AudioFocusHandler.kt @@ -4,8 +4,6 @@ import android.content.Context import android.media.AudioAttributes import android.media.AudioManager import android.media.AudioManager.OnAudioFocusChangeListener -import android.os.Build -import androidx.annotation.RequiresApi import androidx.media.AudioAttributesCompat import androidx.media.AudioFocusRequestCompat import androidx.media.AudioManagerCompat @@ -109,7 +107,6 @@ class AudioFocusHandler(private val context: Context) { private var lowerFocus = false // TODO: This can be removed if we switch to androidx.media2.player - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) fun getAudioAttributes(): AudioAttributes { return AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_MEDIA) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/LocalMediaPlayer.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/LocalMediaPlayer.kt index d30b5d00..0b0a1b42 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/LocalMediaPlayer.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/LocalMediaPlayer.kt @@ -10,11 +10,9 @@ package org.moire.ultrasonic.service import android.content.Context import android.content.Context.POWER_SERVICE import android.content.Intent -import android.media.AudioManager import android.media.MediaPlayer import android.media.MediaPlayer.OnCompletionListener import android.media.audiofx.AudioEffect -import android.os.Build import android.os.Handler import android.os.Looper import android.os.PowerManager @@ -447,12 +445,7 @@ class LocalMediaPlayer : KoinComponent { } private fun setAudioAttributes(player: MediaPlayer) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - player.setAudioAttributes(AudioFocusHandler.getAudioAttributes()) - } else { - @Suppress("DEPRECATION") - player.setAudioStreamType(AudioManager.STREAM_MUSIC) - } + player.setAudioAttributes(AudioFocusHandler.getAudioAttributes()) } @Suppress("ComplexCondition") diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerLifecycleSupport.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerLifecycleSupport.kt index 1bcdfce5..c69b820b 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerLifecycleSupport.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerLifecycleSupport.kt @@ -12,7 +12,6 @@ import android.content.Context import android.content.Intent import android.content.IntentFilter import android.media.AudioManager -import android.os.Build import android.view.KeyEvent import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -165,12 +164,7 @@ class MediaPlayerLifecycleSupport : KoinComponent { } } - val headsetIntentFilter: IntentFilter = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - IntentFilter(AudioManager.ACTION_HEADSET_PLUG) - } else { - IntentFilter(Intent.ACTION_HEADSET_PLUG) - } + val headsetIntentFilter = IntentFilter(AudioManager.ACTION_HEADSET_PLUG) applicationContext().registerReceiver(headsetEventReceiver, headsetIntentFilter) }