diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/MainActivity.kt b/app/src/main/java/fr/forum_thalie/tsumugi/MainActivity.kt index fb02746..91fd2c7 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/MainActivity.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/MainActivity.kt @@ -15,6 +15,7 @@ import fr.forum_thalie.tsumugi.playerstore.PlayerStore import java.util.Timer import android.view.MenuItem +import com.google.android.material.snackbar.Snackbar import fr.forum_thalie.tsumugi.alarm.RadioAlarm import fr.forum_thalie.tsumugi.planning.Planning @@ -86,6 +87,14 @@ class MainActivity : BaseActivity() { true } */ + R.id.action_refresh -> { + PlayerStore.instance.queue.clear() + //PlayerStore.instance.lp.clear() + PlayerStore.instance.initApi() + val s = Snackbar.make(findViewById(R.id.nav_host_container), getString(R.string.refreshing) as CharSequence, Snackbar.LENGTH_LONG) + s.show() + true + } R.id.action_settings -> { val i = Intent(this, ParametersActivity::class.java) startActivity(i) diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/playerstore/PlayerStore.kt b/app/src/main/java/fr/forum_thalie/tsumugi/playerstore/PlayerStore.kt index 94e16ac..df4c151 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/playerstore/PlayerStore.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/playerstore/PlayerStore.kt @@ -127,7 +127,7 @@ class PlayerStore { { updateApi(result) currentSongBackup.copy(currentSong) - + fetchLastRequest() isQueueUpdated.value = true isLpUpdated.value = true @@ -229,7 +229,7 @@ class PlayerStore { val queueJSON = resMain.getJSONObject("next") val t = extractSong(queueJSON) - if (queue.isNotEmpty() && t == queue.last()) + if (queue.isNotEmpty() && (t == queue.last() || t == currentSong)) { //[REMOVE LOG CALLS]Log.d((tag, playerStoreTag + "Song already in there: $t") Async(sleepScrape, post) diff --git a/app/src/main/java/fr/forum_thalie/tsumugi/playerstore/Song.kt b/app/src/main/java/fr/forum_thalie/tsumugi/playerstore/Song.kt index b0e8526..ea97982 100644 --- a/app/src/main/java/fr/forum_thalie/tsumugi/playerstore/Song.kt +++ b/app/src/main/java/fr/forum_thalie/tsumugi/playerstore/Song.kt @@ -1,5 +1,6 @@ package fr.forum_thalie.tsumugi.playerstore +import androidx.core.text.HtmlCompat import androidx.lifecycle.MutableLiveData import fr.forum_thalie.tsumugi.noConnectionValue @@ -24,8 +25,9 @@ class Song(artistTitle: String = "", _id : Int = 0) { return "id=$id | ${artist.value} - ${title.value} | type=${type.value} | times ${startTime.value} - ${stopTime.value}\n" } - fun setTitleArtist(data: String) + fun setTitleArtist(dataHtml: String) { + val data = HtmlCompat.fromHtml(dataHtml, HtmlCompat.FROM_HTML_MODE_LEGACY).toString() val hyphenPos = data.indexOf(" - ") try { if (hyphenPos < 0) @@ -50,8 +52,7 @@ class Song(artistTitle: String = "", _id : Int = 0) { } fun copy(song: Song) { - this.title.value = song.title.value - this.artist.value = song.artist.value + this.setTitleArtist(song.artist.value + " - " + song.title.value) this.startTime.value = song.startTime.value this.stopTime.value = song.stopTime.value this.type.value = song.type.value 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 c2357e9..1e306ac 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 @@ -6,8 +6,6 @@ import android.content.Context import androidx.lifecycle.ViewModelProviders import android.os.Bundle import android.support.v4.media.session.PlaybackStateCompat -import android.util.Log -import android.util.TypedValue import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View @@ -15,7 +13,6 @@ import android.view.ViewGroup import android.widget.* import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet -import androidx.core.widget.TextViewCompat import androidx.lifecycle.Observer import com.google.android.material.snackbar.BaseTransientBottomBar import com.google.android.material.snackbar.Snackbar @@ -24,7 +21,6 @@ import fr.forum_thalie.tsumugi.alarm.RadioSleeper import fr.forum_thalie.tsumugi.planning.Planning import fr.forum_thalie.tsumugi.playerstore.PlayerStore import fr.forum_thalie.tsumugi.playerstore.Song -import kotlinx.android.synthetic.main.fragment_nowplaying.* class NowPlayingFragment : Fragment() { @@ -49,7 +45,7 @@ class NowPlayingFragment : Fragment() { 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) - val currentProgrammeText: TextView = root.findViewById(R.id.text_current_programme) + val currentProgrammeText: TextView = root.findViewById(R.id.current_programme) val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture) // Note: these values are not used in the generic app, but if you want to, you can use them. @@ -69,7 +65,6 @@ class NowPlayingFragment : Fragment() { listenersText,8, 16, 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 { @@ -94,7 +89,7 @@ class NowPlayingFragment : Fragment() { Planning.instance.currentProgramme.observe(viewLifecycleOwner, Observer { - currentProgrammeText.text = it + currentProgrammeText.text = "${context!!.getString(R.string.current_programme)} $it" }) diff --git a/app/src/main/res/layout/fragment_nowplaying.xml b/app/src/main/res/layout/fragment_nowplaying.xml index 1c6823a..efaee16 100644 --- a/app/src/main/res/layout/fragment_nowplaying.xml +++ b/app/src/main/res/layout/fragment_nowplaying.xml @@ -49,7 +49,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" - app:layout_constraintGuide_percent="0.68" /> + app:layout_constraintGuide_percent="0.71" /> + app:layout_constraintTop_toBottomOf="@id/seek_bar_volume" + app:layout_constraintVertical_weight="3"> @@ -206,7 +207,7 @@ android:text="" android:textAlignment="center" android:textColor="@color/whited" - android:textSize="14sp" + android:textSize="16sp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/text_song_artist_next" android:visibility="visible" /> @@ -214,35 +215,61 @@ - - - + + + + > + + + + + + + @@ -310,7 +337,7 @@ android:text="" android:textAlignment="center" android:textColor="@color/whited3" - android:textSize="18sp" + android:textSize="20sp" app:layout_constraintBottom_toTopOf="@id/text_song_title" app:layout_constraintStart_toStartOf="parent" /> @@ -376,7 +403,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" - app:layout_constraintGuide_percent="0.58" /> + app:layout_constraintGuide_percent="0.63" /> - + + + app:showAsAction="never"/> \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 323a71d..0a381f0 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -10,8 +10,8 @@ Volume : - Prochain titre : - Émission en cours : + À suivre : + Émission : En cours Erreur du chargement de WebView. Téléchargez Google Chrome sur le Play Store, ou activez le si vous l\'avez désactivé. Paramètres @@ -52,5 +52,7 @@ Choisir une durée (en minutes) Extinction dans %1$d minutes Choisir la fréquence de mise à jour quand la radio est stoppée + Actualisation… + Raffraîchir les données diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d2a4652..6408717 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -72,5 +72,7 @@ Set duration (minutes) Will close in %1$d minutes Set update period when stopped + Refreshing data… + Refresh data