diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/Actions.kt b/app/src/main/java/fr/forum_thalie/tsumugi/Actions.kt index fb017c3..ee6a7a5 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/Actions.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/Actions.kt @@ -23,5 +23,4 @@ enum class ActionOpenParam { SLEEP, ALARM, CUSTOMIZE, - STREAMER_NOTIFICATION_SERVICE } \ No newline at end of file diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/Async.kt b/app/src/main/java/fr/forum_thalie/tsumugi/Async.kt index 6488ad2..b174712 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/Async.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/Async.kt @@ -23,6 +23,7 @@ class Async(val handler: (Any?) -> Any?, val post: (Any?) -> Unit = {}, ActionOnError.RESET -> resetPlayerStateOnNetworkError() ActionOnError.NOTIFY -> return } + e.printStackTrace() } private fun resetPlayerStateOnNetworkError() { diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/BaseNotification.kt b/app/src/main/java/fr/forum_thalie/tsumugi/BaseNotification.kt index c236c7f..3e0a580 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/BaseNotification.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/BaseNotification.kt @@ -23,7 +23,7 @@ abstract class BaseNotification(private val notificationChannelId: String, // Define the notification in android's swipe-down menu lateinit var notification: Notification - protected lateinit var notificationManager: NotificationManager + private lateinit var notificationManager: NotificationManager protected lateinit var builder: NotificationCompat.Builder @RequiresApi(api = Build.VERSION_CODES.O) diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/NowPlayingNotification.kt b/app/src/main/java/fr/forum_thalie/tsumugi/NowPlayingNotification.kt index 9e65a6f..2c8d0d4 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/NowPlayingNotification.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/NowPlayingNotification.kt @@ -7,7 +7,6 @@ import android.support.v4.media.session.MediaSessionCompat import android.support.v4.media.session.PlaybackStateCompat import androidx.core.app.NotificationCompat import fr.forum_thalie.tsumugi.playerstore.PlayerStore -import fr.forum_thalie.tsumugi.BootBroadcastReceiver class NowPlayingNotification( notificationChannelId: String, @@ -27,7 +26,7 @@ class NowPlayingNotification( // ###### NOW PLAYING NOTIFICATION ######## // ######################################## - lateinit var mediaStyle: androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle + private lateinit var mediaStyle: androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle fun create(c: Context, m: MediaSessionCompat) { super.create(c) diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/Tickers.kt b/app/src/main/java/fr/forum_thalie/tsumugi/Tickers.kt index 40049a5..512c132 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/Tickers.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/Tickers.kt @@ -1,7 +1,5 @@ package fr.forum_thalie.tsumugi -import android.support.v4.media.session.PlaybackStateCompat -import fr.forum_thalie.tsumugi.alarm.RadioSleeper import fr.forum_thalie.tsumugi.playerstore.PlayerStore import java.util.* diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/ui/news/NewsFragment.kt b/app/src/main/java/fr/forum_thalie/tsumugi/ui/news/NewsFragment.kt index 4c60b6c..4251167 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/ui/news/NewsFragment.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/ui/news/NewsFragment.kt @@ -33,12 +33,12 @@ class NewsFragment : Fragment() { if (!newsViewModel.isWebViewLoaded) { try { - newsViewModel.root = inflater.inflate(R.layout.fragment_chat, container, false) + newsViewModel.root = inflater.inflate(R.layout.fragment_news, container, false) newsViewModel.webView = newsViewModel.root.findViewById(R.id.news_webview) newsViewModel.webViewNews = WebViewNews(newsViewModel.webView as WebView) newsViewModel.webViewNews!!.start() } catch (e: Exception) { - newsViewModel.root = inflater.inflate(R.layout.fragment_error_chat, container, false) + newsViewModel.root = inflater.inflate(R.layout.fragment_error_webview, container, false) } newsViewModel.isWebViewLoaded = true diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/ui/nowplaying/NowPlayingFragment.kt b/app/src/main/java/fr/forum_thalie/tsumugi/ui/nowplaying/NowPlayingFragment.kt index e92a6cc..3c62a53 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/ui/nowplaying/NowPlayingFragment.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/ui/nowplaying/NowPlayingFragment.kt @@ -46,25 +46,44 @@ class NowPlayingFragment : Fragment() { val seekBarVolume: SeekBar = root.findViewById(R.id.seek_bar_volume) val volumeText: TextView = root.findViewById(R.id.volume_text) val progressBar: ProgressBar = root.findViewById(R.id.progressBar) + val volumeIconImage : ImageView = root.findViewById(R.id.volume_icon) + + // Note: these values are not used in the generic app val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture) + /* val streamerNameText : TextView = root.findViewById(R.id.streamerName) val songTitleNextText: TextView = root.findViewById(R.id.text_song_title_next) val songArtistNextText: TextView = root.findViewById(R.id.text_song_artist_next) - val volumeIconImage : ImageView = root.findViewById(R.id.volume_icon) val listenersText : TextView = root.findViewById(R.id.listenersCount) + */ + /* TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration( streamerNameText,8, 20, 2, TypedValue.COMPLEX_UNIT_SP) TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration( listenersText,8, 16, 2, TypedValue.COMPLEX_UNIT_SP) - /* - TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration( - songTitleText,4, 24, 2, TypedValue.COMPLEX_UNIT_SP) - TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration( - songArtistText,4, 24, 2, TypedValue.COMPLEX_UNIT_SP) */ + /* + // trick : I can't observe the queue because it's an ArrayDeque that doesn't trigger any change... + // so I observe a dedicated Mutable that gets set when the queue is updated. + PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer { + val t = if (PlayerStore.instance.queue.size > 0) PlayerStore.instance.queue[0] else Song("No queue - ") // (it.peekFirst != null ? it.peekFirst : Song() ) + songTitleNextText.text = t.title.value + songArtistNextText.text = t.artist.value + }) + + PlayerStore.instance.streamerName.observe(viewLifecycleOwner, Observer { + streamerNameText.text = it + }) + + PlayerStore.instance.listenersCount.observe(viewLifecycleOwner, Observer { + listenersText.text = "${getString(R.string.listeners)}: $it" + }) + */ + + PlayerStore.instance.currentSong.title.observe(viewLifecycleOwner, Observer { songTitleText.text = it }) @@ -77,13 +96,6 @@ class NowPlayingFragment : Fragment() { syncPlayPauseButtonImage(root) }) - // trick : I can't observe the queue because it's an ArrayDeque that doesn't trigger any change... - // so I observe a dedicated Mutable that gets set when the queue is updated. - PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer { - val t = if (PlayerStore.instance.queue.size > 0) PlayerStore.instance.queue[0] else Song("No queue - ") // (it.peekFirst != null ? it.peekFirst : Song() ) - songTitleNextText.text = t.title.value - songArtistNextText.text = t.artist.value - }) fun volumeIcon(it: Int) { @@ -113,14 +125,6 @@ class NowPlayingFragment : Fragment() { streamerPictureImageView.setImageBitmap(pic) }) - PlayerStore.instance.streamerName.observe(viewLifecycleOwner, Observer { - streamerNameText.text = it - }) - - PlayerStore.instance.listenersCount.observe(viewLifecycleOwner, Observer { - listenersText.text = "${getString(R.string.listeners)}: $it" - }) - // fuck it, do it on main thread PlayerStore.instance.currentTime.observe(viewLifecycleOwner, Observer { val dd = (PlayerStore.instance.currentTime.value!! - PlayerStore.instance.currentSong.startTime.value!!).toInt() @@ -173,18 +177,6 @@ class NowPlayingFragment : Fragment() { PlayerStore.instance.isPlaying.value = PlayerStore.instance.playbackState.value == PlaybackStateCompat.STATE_STOPPED } - /* - /* TODO : disabled volumeIconImage click listener, it creates weird behaviors when switching fragments. - in particular, the mute state isn't retained when switching fragments, and it creates visual error - (displaying the mute icon when it's not muted). - So for the moment it's safer to disable it altogether. - */ - volumeIconImage.setOnClickListener{ - PlayerStore.instance.isMuted.value = !PlayerStore.instance.isMuted.value!! - } - - */ - val setClipboardListener: View.OnLongClickListener = View.OnLongClickListener { val text = PlayerStore.instance.currentSong.artist.value + " - " + PlayerStore.instance.currentSong.title.value val clipboard = context!!.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/ui/songs/SongsFragment.kt b/app/src/main/java/fr/forum_thalie/tsumugi/ui/songs/SongsFragment.kt index 2ebc21d..008f8c2 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/ui/songs/SongsFragment.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/ui/songs/SongsFragment.kt @@ -29,7 +29,7 @@ class SongsFragment : Fragment() { adapter = SongsPagerAdapter(childFragmentManager, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) adapter.addFragment(LastPlayedFragment.newInstance(), "last played") - //adapter.addFragment(QueueFragment.newInstance(), "queue") + // You can add more fragments to the adapter, to display more information (for example with R/a/dio, queue, request, faves...) viewPager.adapter = adapter diff --git a/app/src/main/res/layout/button_load_more.xml b/app/src/main/res/layout/button_load_more.xml deleted file mode 100644 index 89b145d..0000000 --- a/app/src/main/res/layout/button_load_more.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - -