mirror of
https://github.com/Michatec/Radio.git
synced 2026-01-31 07:20:40 +00:00
Some Bugfixes and Improvments
- Update the libary gson. - Deleted some unuseful Code. - added some locals to locales config.
This commit is contained in:
@@ -32,6 +32,7 @@ import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.PickVisualMediaRequest
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
@@ -40,6 +41,7 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.PlaybackException
|
||||
import androidx.media3.common.Player
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.session.MediaController
|
||||
import androidx.media3.session.SessionResult
|
||||
import androidx.media3.session.SessionToken
|
||||
@@ -395,6 +397,7 @@ class PlayerFragment : Fragment(),
|
||||
|
||||
|
||||
/* Initializes the MediaController - handles connection to PlayerService under the hood */
|
||||
@OptIn(UnstableApi::class)
|
||||
private fun initializeController() {
|
||||
controllerFuture = MediaController.Builder(
|
||||
activity as Context,
|
||||
|
||||
@@ -636,22 +636,6 @@ class PlayerService : MediaLibraryService() {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Defines the listener for changes in shared preferences
|
||||
*/
|
||||
private val sharedPreferenceChangeListener =
|
||||
SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
when (key) {
|
||||
Keys.PREF_LARGE_BUFFER_SIZE -> {
|
||||
bufferSizeMultiplier = PreferencesHelper.loadBufferSizeMultiplier()
|
||||
if (!player.isPlaying && !player.isLoading) {
|
||||
initializePlayer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Custom AnalyticsListener that enables AudioFX equalizer integration
|
||||
*/
|
||||
|
||||
@@ -25,8 +25,6 @@ import com.michatec.radio.helpers.PreferencesHelper.initPreferences
|
||||
*/
|
||||
class Radio : Application() {
|
||||
|
||||
/* Define log tag */
|
||||
private val TAG: String = Radio::class.java.simpleName
|
||||
|
||||
/* Implements onCreate */
|
||||
override fun onCreate() {
|
||||
|
||||
@@ -62,20 +62,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
|
||||
(activity as AppCompatActivity).supportActionBar?.show()
|
||||
(activity as AppCompatActivity).supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
(activity as AppCompatActivity).supportActionBar?.title = getString(R.string.fragment_settings_title)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// above Android Oreo
|
||||
(activity as AppCompatActivity).window.navigationBarColor = getColor(requireContext(), android.R.attr.colorBackground)
|
||||
} else {
|
||||
val nightMode = AppCompatDelegate.getDefaultNightMode()
|
||||
if (nightMode == AppCompatDelegate.MODE_NIGHT_YES) {
|
||||
// night mode is active, set navigation bar color to a suitable color for night mode
|
||||
(activity as AppCompatActivity).window.navigationBarColor = getColor(requireContext(), android.R.attr.colorBackground)
|
||||
} else {
|
||||
// night mode is not active, set navigation bar color to a suitable color for day mode
|
||||
(activity as AppCompatActivity).window.navigationBarColor = ContextCompat.getColor(requireContext(), android.R.color.black)
|
||||
}
|
||||
}
|
||||
(activity as AppCompatActivity).window.navigationBarColor = getColor(requireContext(), android.R.attr.colorBackground)
|
||||
}
|
||||
|
||||
/* Overrides onCreatePreferences from PreferenceFragmentCompat */
|
||||
|
||||
@@ -296,6 +296,7 @@ class CollectionAdapter(
|
||||
|
||||
|
||||
/* Shows / hides the edit view for a station */
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun toggleEditViews(position: Int, stationUuid: String) {
|
||||
when (stationUuid) {
|
||||
// CASE: this station's edit view is already expanded
|
||||
|
||||
@@ -42,10 +42,6 @@ class AddStationDialog (
|
||||
}
|
||||
|
||||
|
||||
/* Define log tag */
|
||||
private val TAG = AddStationDialog::class.java.simpleName
|
||||
|
||||
|
||||
/* Main class variables */
|
||||
private lateinit var dialog: AlertDialog
|
||||
private lateinit var stationSearchResultList: RecyclerView
|
||||
|
||||
@@ -46,9 +46,9 @@ class ErrorDialog {
|
||||
// get views
|
||||
val inflater: LayoutInflater = LayoutInflater.from(context)
|
||||
val view: View = inflater.inflate(R.layout.dialog_generic_with_details, null)
|
||||
val errorMessageView: TextView = view.findViewById(R.id.dialog_message) as TextView
|
||||
val errorDetailsLinkView: TextView = view.findViewById(R.id.dialog_details_link) as TextView
|
||||
val errorDetailsView: TextView = view.findViewById(R.id.dialog_details) as TextView
|
||||
val errorMessageView: TextView = view.findViewById(R.id.dialog_message)
|
||||
val errorDetailsLinkView: TextView = view.findViewById(R.id.dialog_details_link)
|
||||
val errorDetailsView: TextView = view.findViewById(R.id.dialog_details)
|
||||
|
||||
// set dialog view
|
||||
builder.setView(view)
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
package com.michatec.radio.helpers
|
||||
|
||||
import android.util.Log
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.media3.common.Metadata
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.extractor.metadata.icy.IcyHeaders
|
||||
import androidx.media3.extractor.metadata.icy.IcyInfo
|
||||
import com.michatec.radio.Keys
|
||||
@@ -33,6 +35,7 @@ object AudioHelper {
|
||||
|
||||
|
||||
/* Extract audio stream metadata */
|
||||
@OptIn(UnstableApi::class)
|
||||
fun getMetadataString(metadata: Metadata): String {
|
||||
var metadataString = String()
|
||||
for (i in 0 until metadata.length()) {
|
||||
|
||||
@@ -73,27 +73,15 @@ object ShortcutHelper {
|
||||
): IconCompat {
|
||||
val stationImageBitmap: Bitmap =
|
||||
ImageHelper.getScaledStationImage(context, stationImage.toUri(), 192)
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
IconCompat.createWithAdaptiveBitmap(
|
||||
ImageHelper.createSquareImage(
|
||||
context,
|
||||
stationImageBitmap,
|
||||
stationImageColor,
|
||||
192,
|
||||
true
|
||||
)
|
||||
)
|
||||
} else {
|
||||
IconCompat.createWithAdaptiveBitmap(
|
||||
ImageHelper.createSquareImage(
|
||||
context,
|
||||
stationImageBitmap,
|
||||
stationImageColor,
|
||||
192,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return IconCompat.createWithAdaptiveBitmap(
|
||||
ImageHelper.createSquareImage(
|
||||
context,
|
||||
stationImageBitmap,
|
||||
stationImageColor,
|
||||
192,
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,22 +209,16 @@ class SearchResultAdapter(
|
||||
// stop radio playback when one is active
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val audioAttributes = AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_MEDIA)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
||||
.build()
|
||||
val audioAttributes = AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_MEDIA)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
||||
.build()
|
||||
|
||||
val focusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT)
|
||||
.setAudioAttributes(audioAttributes)
|
||||
.build()
|
||||
val focusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT)
|
||||
.setAudioAttributes(audioAttributes)
|
||||
.build()
|
||||
|
||||
audioManager.requestAudioFocus(focusRequest)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
// For older versions where AudioFocusRequest is not available
|
||||
audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT)
|
||||
}
|
||||
audioManager.requestAudioFocus(focusRequest)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
<string name="toastmessage_preview_playback_started">Было запущено воспроизведение предварительного просмотра.</string>
|
||||
<string name="toastmessage_restored">Станции были успешно восстановлены.</string>
|
||||
<string name="toastmessage_save_m3u">Сохранение радиостанций как M3U…</string>
|
||||
<string name="toastmessage_save_pls">Сохранение радиостанций в формате PLS...</string>
|
||||
<string name="toastmessage_save_pls">Сохранение радиостанций в формате PLS</string>
|
||||
<string name="toastmessage_shortcut_created">Ярлык создан.</string>
|
||||
<string name="toastmessage_shortcut_not_created">Ярлык не создан. Устройство не позволяет создавать ярлыки.</string>
|
||||
<string name="toastmessage_sleep_timer_unable_to_start">Пожалуйста, запустите сперва воспроизведение.</string>
|
||||
|
||||
@@ -17,4 +17,6 @@
|
||||
<locale android:name="tr" />
|
||||
<locale android:name="uk" />
|
||||
<locale android:name="zh-rCN" />
|
||||
<locale android:name="da" />
|
||||
<locale android:name="ja" />
|
||||
</locale-config>
|
||||
Reference in New Issue
Block a user