mirror of
https://github.com/Michatec/Radio.git
synced 2026-05-31 00:42:40 +02:00
Compare commits
22 Commits
14.5
...
f7ddc30127
| Author | SHA1 | Date | |
|---|---|---|---|
| f7ddc30127 | |||
| bc0eb60e04 | |||
| dcae7bafb5 | |||
| cf3fd0bc56 | |||
| 7d6b0fe136 | |||
| 0faeea7631 | |||
| c45adf07c8 | |||
| acd1b067b3 | |||
| e3a325f568 | |||
| b537df898b | |||
| 61675601f3 | |||
| 6dc5c47b86 | |||
| c40ad0cc4a | |||
| 066206c6dc | |||
| e8e66c24ef | |||
| 56647e7f02 | |||
| a7e0efc913 | |||
| 0569bed475 | |||
| 6e3b187b56 | |||
| c8c0d1783b | |||
| 4974514a81 | |||
| afd34c6485 |
@@ -5,14 +5,14 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace = "com.michatec.radio"
|
||||
compileSdk = 36
|
||||
compileSdk = 37
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.michatec.radio"
|
||||
minSdk = 28
|
||||
targetSdk = 36
|
||||
versionCode = 145
|
||||
versionName = "14.5"
|
||||
targetSdk = 37
|
||||
versionCode = 146
|
||||
versionName = "14.6"
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<activity
|
||||
android:name=".ExpandedControllerActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/CustomCastExpandedControllerStyle"
|
||||
android:launchMode="singleTask" />
|
||||
|
||||
<!-- Main activity for radio station playback on phone and TV -->
|
||||
@@ -136,6 +137,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="androidx.media3.session.MediaSessionService" />
|
||||
<action android:name="android.media.browse.MediaBrowserService" />
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
<action android:name="com.michatec.radio.action.START_PLAYER_SERVICE" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
@@ -148,14 +150,6 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name="androidx.media.session.MediaButtonReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
|
||||
@@ -120,7 +120,7 @@ class AddStationFragment : Fragment(),
|
||||
if (searchEditText != null) {
|
||||
searchEditText.requestFocus()
|
||||
val imm = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.showSoftInput(searchEditText, InputMethodManager.SHOW_IMPLICIT)
|
||||
imm.showSoftInput(searchEditText, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.media.MediaBrowserServiceCompat.BrowserRoot.EXTRA_RECENT
|
||||
import androidx.media3.cast.CastPlayer
|
||||
import androidx.media3.common.*
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
@@ -29,6 +28,7 @@ import com.google.common.collect.ImmutableList
|
||||
import com.google.common.util.concurrent.Futures
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import com.michatec.radio.core.Collection
|
||||
import com.michatec.radio.core.Station
|
||||
import com.michatec.radio.helpers.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
@@ -132,7 +132,7 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
|
||||
context: Context,
|
||||
enableFloatOutput: Boolean,
|
||||
enableAudioTrackPlaybackParams: Boolean
|
||||
): AudioSink? {
|
||||
): AudioSink {
|
||||
return DefaultAudioSink.Builder(context)
|
||||
.setAudioProcessors(arrayOf(nativeAudioProcessor))
|
||||
.build()
|
||||
@@ -170,6 +170,14 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
|
||||
override fun getDuration(): Long {
|
||||
return C.TIME_UNSET // this will hide progress bar for HLS stations in the notification
|
||||
}
|
||||
|
||||
override fun seekToNext() {
|
||||
playNextStation()
|
||||
}
|
||||
|
||||
override fun seekToPrevious() {
|
||||
playPreviousStation()
|
||||
}
|
||||
}
|
||||
player.addListener(playerListener)
|
||||
}
|
||||
@@ -347,6 +355,37 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
|
||||
}
|
||||
|
||||
|
||||
/* Switches to the next radio station in collection */
|
||||
private fun playNextStation() {
|
||||
val currentMediaId = player.currentMediaItem?.mediaId ?: PreferencesHelper.loadLastPlayedStationUuid()
|
||||
val currentPosition = CollectionHelper.getStationPosition(collection, currentMediaId)
|
||||
if (currentPosition != -1) {
|
||||
val nextPosition = if (currentPosition < collection.stations.size - 1) currentPosition + 1 else 0
|
||||
playStation(collection.stations[nextPosition])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Switches to the previous radio station in collection */
|
||||
private fun playPreviousStation() {
|
||||
val currentMediaId = player.currentMediaItem?.mediaId ?: PreferencesHelper.loadLastPlayedStationUuid()
|
||||
val currentPosition = CollectionHelper.getStationPosition(collection, currentMediaId)
|
||||
if (currentPosition != -1) {
|
||||
val previousPosition = if (currentPosition > 0) currentPosition - 1 else collection.stations.size - 1
|
||||
playStation(collection.stations[previousPosition])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Starts playback of a radio station */
|
||||
private fun playStation(station: Station) {
|
||||
val mediaItem = CollectionHelper.buildMediaItem(this, station)
|
||||
player.setMediaItem(mediaItem)
|
||||
player.prepare()
|
||||
player.play()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Custom MediaSession Callback that handles player commands
|
||||
*/
|
||||
@@ -407,8 +446,8 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
|
||||
browser: MediaSession.ControllerInfo,
|
||||
params: LibraryParams?
|
||||
): ListenableFuture<LibraryResult<MediaItem>> {
|
||||
return if (params?.extras?.containsKey(EXTRA_RECENT) == true) {
|
||||
// special case: system requested media resumption via EXTRA_RECENT
|
||||
return if (params?.isRecent == true) {
|
||||
// special case: system requested media resumption via isRecent
|
||||
playLastStation = true
|
||||
Futures.immediateFuture(LibraryResult.ofItem(CollectionHelper.getRecent(this@PlayerService, collection), params))
|
||||
} else {
|
||||
@@ -552,8 +591,7 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
|
||||
stopSelf()
|
||||
}
|
||||
Player.STATE_READY -> {
|
||||
// Playback is paused. For radio, we can stop the service to remove the notification.
|
||||
stopSelf()
|
||||
// Playback is paused. For radio, we keep the service running to allow resumption from headphones.
|
||||
}
|
||||
Player.STATE_BUFFERING -> {
|
||||
// DO NOT stop the service while buffering (especially important for Cast)
|
||||
@@ -562,17 +600,6 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPlayWhenReadyChanged(playWhenReady: Boolean, reason: Int) {
|
||||
super.onPlayWhenReadyChanged(playWhenReady, reason)
|
||||
if (!playWhenReady) {
|
||||
// Only stop if not buffering and not ready to play (i.e. truly stopped/paused)
|
||||
if (player.playbackState != Player.STATE_BUFFERING) {
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onPlayerError(error: PlaybackException) {
|
||||
super.onPlayerError(error)
|
||||
Log.d(TAG, "PlayerError occurred: ${error.errorCodeName}")
|
||||
|
||||
@@ -149,7 +149,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
|
||||
|
||||
|
||||
// set up "Buffer Size" preference
|
||||
val preferenceBufferSize = SwitchPreferenceCompat(activity as Context)
|
||||
val preferenceBufferSize = MarqueeSwitchPreference(context)
|
||||
preferenceBufferSize.title = getString(R.string.pref_buffer_size_title)
|
||||
preferenceBufferSize.setIcon(R.drawable.ic_network_check_24dp)
|
||||
preferenceBufferSize.key = Keys.PREF_LARGE_BUFFER_SIZE
|
||||
@@ -159,7 +159,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
|
||||
|
||||
|
||||
// set up "Edit Stream Address" preference
|
||||
val preferenceEnableEditingStreamUri = SwitchPreferenceCompat(activity as Context)
|
||||
val preferenceEnableEditingStreamUri = MarqueeSwitchPreference(context)
|
||||
preferenceEnableEditingStreamUri.title = getString(R.string.pref_edit_station_stream_title)
|
||||
preferenceEnableEditingStreamUri.setIcon(R.drawable.ic_music_note_24dp)
|
||||
preferenceEnableEditingStreamUri.key = Keys.PREF_EDIT_STREAMS_URIS
|
||||
@@ -174,7 +174,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
|
||||
|
||||
|
||||
// set up "Edit Stations" preference
|
||||
val preferenceEnableEditingGeneral = SwitchPreferenceCompat(activity as Context)
|
||||
val preferenceEnableEditingGeneral = MarqueeSwitchPreference(context)
|
||||
preferenceEnableEditingGeneral.title = getString(R.string.pref_edit_station_title)
|
||||
preferenceEnableEditingGeneral.setIcon(R.drawable.ic_edit_24dp)
|
||||
preferenceEnableEditingGeneral.key = Keys.PREF_EDIT_STATIONS
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.widget.FrameLayout
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import com.michatec.radio.R
|
||||
import androidx.core.view.isEmpty
|
||||
|
||||
class ExtrasHelper {
|
||||
companion object {
|
||||
@@ -69,7 +70,7 @@ class ExtrasHelper {
|
||||
if (currentParent != container) {
|
||||
currentParent?.removeView(visualizerView)
|
||||
// If we injected into a standard preference, don't clear everything, just add
|
||||
if (container is FrameLayout || container.childCount == 0) {
|
||||
if (container is FrameLayout || container.isEmpty()) {
|
||||
container.removeAllViews()
|
||||
}
|
||||
container.addView(visualizerView)
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.michatec.radio.helpers
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.util.Log
|
||||
import com.michatec.radio.R
|
||||
import java.util.Locale
|
||||
|
||||
@@ -16,7 +16,7 @@ class MarqueeSwitchPreference(context: Context) : SwitchPreferenceCompat(context
|
||||
val title = holder.findViewById(android.R.id.title) as? TextView
|
||||
title?.apply {
|
||||
ellipsize = TextUtils.TruncateAt.MARQUEE
|
||||
setSingleLine(true)
|
||||
isSingleLine = true
|
||||
marqueeRepeatLimit = -1 // Repeat indefinitely
|
||||
isSelected = true // Required for marquee to start
|
||||
setHorizontallyScrolling(true)
|
||||
|
||||
@@ -171,7 +171,7 @@ class SearchResultAdapter(
|
||||
context: Context,
|
||||
enableFloatOutput: Boolean,
|
||||
enableAudioTrackPlaybackParams: Boolean
|
||||
): AudioSink? {
|
||||
): AudioSink {
|
||||
return DefaultAudioSink.Builder(context)
|
||||
.setAudioProcessors(arrayOf(nativeAudioProcessor))
|
||||
.build()
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
[versions]
|
||||
activityKtx = "1.13.0"
|
||||
agp = "9.1.1"
|
||||
agp = "9.2.1"
|
||||
coreKtx = "1.18.0"
|
||||
freedroidwarn = "V1.11"
|
||||
gson = "2.13.2"
|
||||
kotlin = "2.3.20"
|
||||
freedroidwarn = "V1.13"
|
||||
gson = "2.14.0"
|
||||
kotlin = "2.3.21"
|
||||
leanback = "1.2.0"
|
||||
material = "1.13.0"
|
||||
material3 = "1.4.0"
|
||||
media = "1.7.1"
|
||||
media = "1.8.0"
|
||||
media3 = "1.10.0"
|
||||
navigation = "2.9.7"
|
||||
navigation = "2.9.8"
|
||||
paletteKtx = "1.0.0"
|
||||
preferenceKtx = "1.2.1"
|
||||
volley = "1.2.1"
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,7 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
||||
Vendored
+10
-21
@@ -23,8 +23,8 @@
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@@ -51,7 +51,7 @@ echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
@@ -65,7 +65,7 @@ echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
@@ -73,21 +73,10 @@ goto fail
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
|
||||
Reference in New Issue
Block a user