Merge branch 'tsumugi/devel' into tsumugi/master

remotes/origin/devel
yattoz 2020-01-12 14:53:00 +01:00
commit 1e5c72854a
8 changed files with 90 additions and 55 deletions

View File

@ -15,6 +15,7 @@ import fr.forum_thalie.tsumugi.playerstore.PlayerStore
import java.util.Timer import java.util.Timer
import android.view.MenuItem import android.view.MenuItem
import com.google.android.material.snackbar.Snackbar
import fr.forum_thalie.tsumugi.alarm.RadioAlarm import fr.forum_thalie.tsumugi.alarm.RadioAlarm
import fr.forum_thalie.tsumugi.planning.Planning import fr.forum_thalie.tsumugi.planning.Planning
@ -86,6 +87,14 @@ class MainActivity : BaseActivity() {
true 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 -> { R.id.action_settings -> {
val i = Intent(this, ParametersActivity::class.java) val i = Intent(this, ParametersActivity::class.java)
startActivity(i) startActivity(i)

View File

@ -127,7 +127,7 @@ class PlayerStore {
{ {
updateApi(result) updateApi(result)
currentSongBackup.copy(currentSong) currentSongBackup.copy(currentSong)
fetchLastRequest()
isQueueUpdated.value = true isQueueUpdated.value = true
isLpUpdated.value = true isLpUpdated.value = true
@ -229,7 +229,7 @@ class PlayerStore {
val queueJSON = val queueJSON =
resMain.getJSONObject("next") resMain.getJSONObject("next")
val t = extractSong(queueJSON) 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") //[REMOVE LOG CALLS]Log.d((tag, playerStoreTag + "Song already in there: $t")
Async(sleepScrape, post) Async(sleepScrape, post)

View File

@ -1,5 +1,6 @@
package fr.forum_thalie.tsumugi.playerstore package fr.forum_thalie.tsumugi.playerstore
import androidx.core.text.HtmlCompat
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import fr.forum_thalie.tsumugi.noConnectionValue 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" 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(" - ") val hyphenPos = data.indexOf(" - ")
try { try {
if (hyphenPos < 0) if (hyphenPos < 0)
@ -50,8 +52,7 @@ class Song(artistTitle: String = "", _id : Int = 0) {
} }
fun copy(song: Song) { fun copy(song: Song) {
this.title.value = song.title.value this.setTitleArtist(song.artist.value + " - " + song.title.value)
this.artist.value = song.artist.value
this.startTime.value = song.startTime.value this.startTime.value = song.startTime.value
this.stopTime.value = song.stopTime.value this.stopTime.value = song.stopTime.value
this.type.value = song.type.value this.type.value = song.type.value

View File

@ -6,8 +6,6 @@ import android.content.Context
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import android.os.Bundle import android.os.Bundle
import android.support.v4.media.session.PlaybackStateCompat import android.support.v4.media.session.PlaybackStateCompat
import android.util.Log
import android.util.TypedValue
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -15,7 +13,6 @@ import android.view.ViewGroup
import android.widget.* import android.widget.*
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.widget.TextViewCompat
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import com.google.android.material.snackbar.BaseTransientBottomBar import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar 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.planning.Planning
import fr.forum_thalie.tsumugi.playerstore.PlayerStore import fr.forum_thalie.tsumugi.playerstore.PlayerStore
import fr.forum_thalie.tsumugi.playerstore.Song import fr.forum_thalie.tsumugi.playerstore.Song
import kotlinx.android.synthetic.main.fragment_nowplaying.*
class NowPlayingFragment : Fragment() { class NowPlayingFragment : Fragment() {
@ -49,7 +45,7 @@ class NowPlayingFragment : Fragment() {
val volumeText: TextView = root.findViewById(R.id.volume_text) val volumeText: TextView = root.findViewById(R.id.volume_text)
val progressBar: ProgressBar = root.findViewById(R.id.progressBar) val progressBar: ProgressBar = root.findViewById(R.id.progressBar)
val volumeIconImage : ImageView = root.findViewById(R.id.volume_icon) 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) 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. // 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) 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... // 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. // so I observe a dedicated Mutable that gets set when the queue is updated.
PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer { PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer {
@ -94,7 +89,7 @@ class NowPlayingFragment : Fragment() {
Planning.instance.currentProgramme.observe(viewLifecycleOwner, Observer { Planning.instance.currentProgramme.observe(viewLifecycleOwner, Observer {
currentProgrammeText.text = it currentProgrammeText.text = "${context!!.getString(R.string.current_programme)} $it"
}) })

View File

@ -49,7 +49,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintGuide_percent="0.68" /> app:layout_constraintGuide_percent="0.71" />
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/imageLeftGuideline" android:id="@+id/imageLeftGuideline"
@ -140,7 +140,7 @@
<ImageView <ImageView
android:id="@+id/volume_icon" android:id="@+id/volume_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="24dp" android:layout_height="20dp"
android:contentDescription="@string/volume" android:contentDescription="@string/volume"
android:src="@drawable/ic_volume_high" android:src="@drawable/ic_volume_high"
android:textSize="12sp" android:textSize="12sp"
@ -156,10 +156,11 @@
android:layout_height="0dp" android:layout_height="0dp"
android:fillViewport="true" android:fillViewport="true"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
app:layout_constraintBottom_toTopOf="@id/text_current_programme" app:layout_constraintBottom_toTopOf="@id/scrollProgramme"
app:layout_constraintEnd_toStartOf="@id/streamerPicture" app:layout_constraintEnd_toStartOf="@id/streamerPicture"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/seek_bar_volume"> app:layout_constraintTop_toBottomOf="@id/seek_bar_volume"
app:layout_constraintVertical_weight="3">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
@ -193,7 +194,7 @@
android:text="" android:text=""
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/whited3" android:textColor="@color/whited3"
android:textSize="14sp" android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/upNext" app:layout_constraintTop_toBottomOf="@id/upNext"
android:visibility="visible"/> android:visibility="visible"/>
@ -206,7 +207,7 @@
android:text="" android:text=""
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/whited" android:textColor="@color/whited"
android:textSize="14sp" android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_song_artist_next" app:layout_constraintTop_toBottomOf="@id/text_song_artist_next"
android:visibility="visible" /> android:visibility="visible" />
@ -214,35 +215,61 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>
<TextView <ScrollView
android:id="@+id/current_programme" android:id="@+id/scrollProgramme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:text="@string/current_programme"
android:textAlignment="center"
android:textColor="@color/whited3"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="@id/topInfoGuideline"
android:visibility="visible" />
<TextView
android:id="@+id/text_current_programme"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="0dp"
android:text="" android:fillViewport="true"
android:layout_marginStart="8sp" android:layout_marginBottom="0dp"
android:layout_marginLeft="8sp"
android:gravity="start|bottom"
android:textAlignment="textStart"
android:textColor="@color/whited"
android:textSize="14sp"
app:layout_constraintStart_toEndOf="@id/current_programme"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/scrollViewMetadataNext"
app:layout_constraintBottom_toBottomOf="@id/topInfoGuideline" app:layout_constraintBottom_toBottomOf="@id/topInfoGuideline"
app:layout_constraintVertical_weight="1">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:visibility="visible" android:visibility="visible"
/> >
<TextView
android:id="@+id/current_programme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center_horizontal"
android:text="@string/current_programme"
android:textAlignment="center"
android:textColor="@color/whited3"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:visibility="visible" />
<TextView
android:id="@+id/text_current_programme"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text=""
android:layout_marginStart="8sp"
android:layout_marginLeft="8sp"
android:gravity="start|center_horizontal"
android:textAlignment="textStart"
android:textColor="@color/whited"
android:textSize="16sp"
app:layout_constraintStart_toEndOf="@id/current_programme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/topInfoGuideline" android:id="@+id/topInfoGuideline"
@ -298,7 +325,7 @@
android:text="" android:text=""
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/whited" android:textColor="@color/whited"
android:textSize="18sp" android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
@ -310,7 +337,7 @@
android:text="" android:text=""
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/whited3" android:textColor="@color/whited3"
android:textSize="18sp" android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@id/text_song_title" app:layout_constraintBottom_toTopOf="@id/text_song_title"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
@ -376,7 +403,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintGuide_percent="0.58" /> app:layout_constraintGuide_percent="0.63" />
<ImageButton <ImageButton

View File

@ -15,23 +15,22 @@
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<!-- <!--
<item
android:id="@+id/action_refresh"
android:title="@string/action_refresh"
app:showAsAction="never"/>
-->
<!--
<item <item
android:id="@+id/action_bug_submit" android:id="@+id/action_bug_submit"
android:title="@string/action_bug_submit" android:title="@string/action_bug_submit"
app:showAsAction="never"/> app:showAsAction="never"/>
--> -->
<item
android:id="@+id/action_refresh"
android:title="@string/action_refresh"
app:showAsAction="never"/>
<item android:id="@+id/action_settings" <item android:id="@+id/action_settings"
android:title="@string/action_settings" android:title="@string/action_settings"
android:icon="@drawable/ic_settings" android:icon="@drawable/ic_settings"
app:showAsAction="ifRoom"/> app:showAsAction="never"/>
</menu> </menu>

View File

@ -10,8 +10,8 @@
<string name="volume">Volume : </string> <string name="volume">Volume : </string>
<string name="up_next">Prochain titre :</string> <string name="up_next">À suivre :</string>
<string name="current_programme">Émission en cours : </string> <string name="current_programme">Émission : </string>
<string name="now_streaming">En cours</string> <string name="now_streaming">En cours</string>
<string name="error_webView">Erreur du chargement de WebView. Téléchargez Google Chrome sur le Play Store, ou activez le si vous l\'avez désactivé.</string> <string name="error_webView">Erreur du chargement de WebView. Téléchargez Google Chrome sur le Play Store, ou activez le si vous l\'avez désactivé.</string>
<string name="action_settings">Paramètres</string> <string name="action_settings">Paramètres</string>
@ -52,5 +52,7 @@
<string name="setSleepDuration">Choisir une durée (en minutes)</string> <string name="setSleepDuration">Choisir une durée (en minutes)</string>
<string name="willCloseIn">Extinction dans %1$d minutes</string> <string name="willCloseIn">Extinction dans %1$d minutes</string>
<string name="fetchPeriod">Choisir la fréquence de mise à jour quand la radio est stoppée</string> <string name="fetchPeriod">Choisir la fréquence de mise à jour quand la radio est stoppée</string>
<string name="refreshing">Actualisation…</string>
<string name="action_refresh">Raffraîchir les données</string>
</resources> </resources>

View File

@ -72,5 +72,7 @@
<string name="setSleepDuration">Set duration (minutes)</string> <string name="setSleepDuration">Set duration (minutes)</string>
<string name="willCloseIn">Will close in %1$d minutes</string> <string name="willCloseIn">Will close in %1$d minutes</string>
<string name="fetchPeriod">Set update period when stopped</string> <string name="fetchPeriod">Set update period when stopped</string>
<string name="refreshing">Refreshing data…</string>
<string name="action_refresh">Refresh data</string>
</resources> </resources>