Browse Source

Merge branch 'tsumugi/devel' into tsumugi/master

yattoz 5 years ago
parent
commit
1e5c72854a

+ 9 - 0
app/src/main/java/fr/forum_thalie/tsumugi/MainActivity.kt View File

15
 
15
 
16
 import java.util.Timer
16
 import java.util.Timer
17
 import android.view.MenuItem
17
 import android.view.MenuItem
18
+import com.google.android.material.snackbar.Snackbar
18
 import fr.forum_thalie.tsumugi.alarm.RadioAlarm
19
 import fr.forum_thalie.tsumugi.alarm.RadioAlarm
19
 import fr.forum_thalie.tsumugi.planning.Planning
20
 import fr.forum_thalie.tsumugi.planning.Planning
20
 
21
 
86
                 true
87
                 true
87
             }
88
             }
88
             */
89
             */
90
+            R.id.action_refresh -> {
91
+                PlayerStore.instance.queue.clear()
92
+                //PlayerStore.instance.lp.clear()
93
+                PlayerStore.instance.initApi()
94
+                val s = Snackbar.make(findViewById(R.id.nav_host_container), getString(R.string.refreshing) as CharSequence, Snackbar.LENGTH_LONG)
95
+                s.show()
96
+                true
97
+            }
89
             R.id.action_settings -> {
98
             R.id.action_settings -> {
90
                 val i = Intent(this, ParametersActivity::class.java)
99
                 val i = Intent(this, ParametersActivity::class.java)
91
                 startActivity(i)
100
                 startActivity(i)

+ 2 - 2
app/src/main/java/fr/forum_thalie/tsumugi/playerstore/PlayerStore.kt View File

127
             {
127
             {
128
                 updateApi(result)
128
                 updateApi(result)
129
                 currentSongBackup.copy(currentSong)
129
                 currentSongBackup.copy(currentSong)
130
-
130
+                fetchLastRequest()
131
                 isQueueUpdated.value = true
131
                 isQueueUpdated.value = true
132
 
132
 
133
                 isLpUpdated.value = true
133
                 isLpUpdated.value = true
229
                     val queueJSON =
229
                     val queueJSON =
230
                         resMain.getJSONObject("next")
230
                         resMain.getJSONObject("next")
231
                     val t = extractSong(queueJSON)
231
                     val t = extractSong(queueJSON)
232
-                    if (queue.isNotEmpty() && t == queue.last())
232
+                    if (queue.isNotEmpty() && (t == queue.last() || t == currentSong))
233
                     {
233
                     {
234
                         //[REMOVE LOG CALLS]Log.d((tag, playerStoreTag +  "Song already in there: $t")
234
                         //[REMOVE LOG CALLS]Log.d((tag, playerStoreTag +  "Song already in there: $t")
235
                         Async(sleepScrape, post)
235
                         Async(sleepScrape, post)

+ 4 - 3
app/src/main/java/fr/forum_thalie/tsumugi/playerstore/Song.kt View File

1
 package fr.forum_thalie.tsumugi.playerstore
1
 package fr.forum_thalie.tsumugi.playerstore
2
 
2
 
3
+import androidx.core.text.HtmlCompat
3
 import androidx.lifecycle.MutableLiveData
4
 import androidx.lifecycle.MutableLiveData
4
 import fr.forum_thalie.tsumugi.noConnectionValue
5
 import fr.forum_thalie.tsumugi.noConnectionValue
5
 
6
 
24
         return "id=$id | ${artist.value} - ${title.value} | type=${type.value} | times ${startTime.value} - ${stopTime.value}\n"
25
         return "id=$id | ${artist.value} - ${title.value} | type=${type.value} | times ${startTime.value} - ${stopTime.value}\n"
25
     }
26
     }
26
 
27
 
27
-    fun setTitleArtist(data: String)
28
+    fun setTitleArtist(dataHtml: String)
28
     {
29
     {
30
+        val data = HtmlCompat.fromHtml(dataHtml, HtmlCompat.FROM_HTML_MODE_LEGACY).toString()
29
         val hyphenPos = data.indexOf(" - ")
31
         val hyphenPos = data.indexOf(" - ")
30
         try {
32
         try {
31
             if (hyphenPos < 0)
33
             if (hyphenPos < 0)
50
     }
52
     }
51
 
53
 
52
     fun copy(song: Song) {
54
     fun copy(song: Song) {
53
-        this.title.value = song.title.value
54
-        this.artist.value = song.artist.value
55
+        this.setTitleArtist(song.artist.value + " - " + song.title.value)
55
         this.startTime.value = song.startTime.value
56
         this.startTime.value = song.startTime.value
56
         this.stopTime.value = song.stopTime.value
57
         this.stopTime.value = song.stopTime.value
57
         this.type.value = song.type.value
58
         this.type.value = song.type.value

+ 2 - 7
app/src/main/java/fr/forum_thalie/tsumugi/ui/nowplaying/NowPlayingFragment.kt View File

6
 import androidx.lifecycle.ViewModelProviders
6
 import androidx.lifecycle.ViewModelProviders
7
 import android.os.Bundle
7
 import android.os.Bundle
8
 import android.support.v4.media.session.PlaybackStateCompat
8
 import android.support.v4.media.session.PlaybackStateCompat
9
-import android.util.Log
10
-import android.util.TypedValue
11
 import androidx.fragment.app.Fragment
9
 import androidx.fragment.app.Fragment
12
 import android.view.LayoutInflater
10
 import android.view.LayoutInflater
13
 import android.view.View
11
 import android.view.View
15
 import android.widget.*
13
 import android.widget.*
16
 import androidx.constraintlayout.widget.ConstraintLayout
14
 import androidx.constraintlayout.widget.ConstraintLayout
17
 import androidx.constraintlayout.widget.ConstraintSet
15
 import androidx.constraintlayout.widget.ConstraintSet
18
-import androidx.core.widget.TextViewCompat
19
 import androidx.lifecycle.Observer
16
 import androidx.lifecycle.Observer
20
 import com.google.android.material.snackbar.BaseTransientBottomBar
17
 import com.google.android.material.snackbar.BaseTransientBottomBar
21
 import com.google.android.material.snackbar.Snackbar
18
 import com.google.android.material.snackbar.Snackbar
24
 import fr.forum_thalie.tsumugi.planning.Planning
21
 import fr.forum_thalie.tsumugi.planning.Planning
25
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
22
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
26
 import fr.forum_thalie.tsumugi.playerstore.Song
23
 import fr.forum_thalie.tsumugi.playerstore.Song
27
-import kotlinx.android.synthetic.main.fragment_nowplaying.*
28
 
24
 
29
 
25
 
30
 class NowPlayingFragment : Fragment() {
26
 class NowPlayingFragment : Fragment() {
49
         val volumeText: TextView = root.findViewById(R.id.volume_text)
45
         val volumeText: TextView = root.findViewById(R.id.volume_text)
50
         val progressBar: ProgressBar = root.findViewById(R.id.progressBar)
46
         val progressBar: ProgressBar = root.findViewById(R.id.progressBar)
51
         val volumeIconImage : ImageView = root.findViewById(R.id.volume_icon)
47
         val volumeIconImage : ImageView = root.findViewById(R.id.volume_icon)
52
-        val currentProgrammeText: TextView  = root.findViewById(R.id.text_current_programme)
48
+        val currentProgrammeText: TextView  = root.findViewById(R.id.current_programme)
53
         val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture)
49
         val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture)
54
 
50
 
55
         // Note: these values are not used in the generic app, but if you want to, you can use them.
51
         // Note: these values are not used in the generic app, but if you want to, you can use them.
69
             listenersText,8, 16, 2, TypedValue.COMPLEX_UNIT_SP)
65
             listenersText,8, 16, 2, TypedValue.COMPLEX_UNIT_SP)
70
          */
66
          */
71
 
67
 
72
-
73
         // trick : I can't observe the queue because it's an ArrayDeque that doesn't trigger any change...
68
         // trick : I can't observe the queue because it's an ArrayDeque that doesn't trigger any change...
74
         // so I observe a dedicated Mutable that gets set when the queue is updated.
69
         // so I observe a dedicated Mutable that gets set when the queue is updated.
75
         PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer {
70
         PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer {
94
 
89
 
95
 
90
 
96
         Planning.instance.currentProgramme.observe(viewLifecycleOwner, Observer {
91
         Planning.instance.currentProgramme.observe(viewLifecycleOwner, Observer {
97
-            currentProgrammeText.text = it
92
+            currentProgrammeText.text = "${context!!.getString(R.string.current_programme)} $it"
98
         })
93
         })
99
 
94
 
100
 
95
 

+ 60 - 33
app/src/main/res/layout/fragment_nowplaying.xml View File

49
             android:layout_width="wrap_content"
49
             android:layout_width="wrap_content"
50
             android:layout_height="wrap_content"
50
             android:layout_height="wrap_content"
51
             android:orientation="vertical"
51
             android:orientation="vertical"
52
-            app:layout_constraintGuide_percent="0.68" />
52
+            app:layout_constraintGuide_percent="0.71" />
53
 
53
 
54
         <androidx.constraintlayout.widget.Guideline
54
         <androidx.constraintlayout.widget.Guideline
55
             android:id="@+id/imageLeftGuideline"
55
             android:id="@+id/imageLeftGuideline"
140
         <ImageView
140
         <ImageView
141
             android:id="@+id/volume_icon"
141
             android:id="@+id/volume_icon"
142
             android:layout_width="wrap_content"
142
             android:layout_width="wrap_content"
143
-            android:layout_height="24dp"
143
+            android:layout_height="20dp"
144
             android:contentDescription="@string/volume"
144
             android:contentDescription="@string/volume"
145
             android:src="@drawable/ic_volume_high"
145
             android:src="@drawable/ic_volume_high"
146
             android:textSize="12sp"
146
             android:textSize="12sp"
156
             android:layout_height="0dp"
156
             android:layout_height="0dp"
157
             android:fillViewport="true"
157
             android:fillViewport="true"
158
             android:layout_marginBottom="4dp"
158
             android:layout_marginBottom="4dp"
159
-            app:layout_constraintBottom_toTopOf="@id/text_current_programme"
159
+            app:layout_constraintBottom_toTopOf="@id/scrollProgramme"
160
             app:layout_constraintEnd_toStartOf="@id/streamerPicture"
160
             app:layout_constraintEnd_toStartOf="@id/streamerPicture"
161
             app:layout_constraintStart_toStartOf="parent"
161
             app:layout_constraintStart_toStartOf="parent"
162
-            app:layout_constraintTop_toBottomOf="@id/seek_bar_volume">
162
+            app:layout_constraintTop_toBottomOf="@id/seek_bar_volume"
163
+            app:layout_constraintVertical_weight="3">
163
 
164
 
164
 
165
 
165
             <androidx.constraintlayout.widget.ConstraintLayout
166
             <androidx.constraintlayout.widget.ConstraintLayout
193
                     android:text=""
194
                     android:text=""
194
                     android:textAlignment="center"
195
                     android:textAlignment="center"
195
                     android:textColor="@color/whited3"
196
                     android:textColor="@color/whited3"
196
-                    android:textSize="14sp"
197
+                    android:textSize="16sp"
197
                     app:layout_constraintStart_toStartOf="parent"
198
                     app:layout_constraintStart_toStartOf="parent"
198
                     app:layout_constraintTop_toBottomOf="@id/upNext"
199
                     app:layout_constraintTop_toBottomOf="@id/upNext"
199
                     android:visibility="visible"/>
200
                     android:visibility="visible"/>
206
                     android:text=""
207
                     android:text=""
207
                     android:textAlignment="center"
208
                     android:textAlignment="center"
208
                     android:textColor="@color/whited"
209
                     android:textColor="@color/whited"
209
-                    android:textSize="14sp"
210
+                    android:textSize="16sp"
210
                     app:layout_constraintStart_toStartOf="parent"
211
                     app:layout_constraintStart_toStartOf="parent"
211
                     app:layout_constraintTop_toBottomOf="@id/text_song_artist_next"
212
                     app:layout_constraintTop_toBottomOf="@id/text_song_artist_next"
212
                     android:visibility="visible" />
213
                     android:visibility="visible" />
214
             </androidx.constraintlayout.widget.ConstraintLayout>
215
             </androidx.constraintlayout.widget.ConstraintLayout>
215
         </ScrollView>
216
         </ScrollView>
216
 
217
 
217
-        <TextView
218
-            android:id="@+id/current_programme"
219
-            android:layout_width="wrap_content"
220
-            android:layout_height="wrap_content"
221
-            android:gravity="bottom"
222
-            android:text="@string/current_programme"
223
-            android:textAlignment="center"
224
-            android:textColor="@color/whited3"
225
-            android:textSize="14sp"
218
+        <ScrollView
219
+            android:id="@+id/scrollProgramme"
220
+            android:layout_width="0dp"
221
+            android:layout_height="0dp"
222
+            android:fillViewport="true"
223
+            android:layout_marginBottom="0dp"
224
+            app:layout_constraintEnd_toEndOf="parent"
226
             app:layout_constraintStart_toStartOf="parent"
225
             app:layout_constraintStart_toStartOf="parent"
226
+            app:layout_constraintTop_toBottomOf="@id/scrollViewMetadataNext"
227
             app:layout_constraintBottom_toBottomOf="@id/topInfoGuideline"
227
             app:layout_constraintBottom_toBottomOf="@id/topInfoGuideline"
228
-            android:visibility="visible" />
228
+            app:layout_constraintVertical_weight="1">
229
 
229
 
230
-        <TextView
231
-            android:id="@+id/text_current_programme"
232
-            android:layout_width="0dp"
230
+
231
+        <androidx.constraintlayout.widget.ConstraintLayout
232
+            android:layout_width="match_parent"
233
             android:layout_height="wrap_content"
233
             android:layout_height="wrap_content"
234
-            android:text=""
235
-            android:layout_marginStart="8sp"
236
-            android:layout_marginLeft="8sp"
237
-            android:gravity="start|bottom"
238
-            android:textAlignment="textStart"
239
-            android:textColor="@color/whited"
240
-            android:textSize="14sp"
241
-            app:layout_constraintStart_toEndOf="@id/current_programme"
242
-            app:layout_constraintEnd_toEndOf="parent"
243
-            app:layout_constraintBottom_toBottomOf="@id/topInfoGuideline"
234
+            android:orientation="vertical"
235
+            android:layout_marginEnd="8dp"
236
+            android:layout_marginRight="8dp"
244
             android:visibility="visible"
237
             android:visibility="visible"
245
-             />
238
+            >
239
+
240
+            <TextView
241
+                android:id="@+id/current_programme"
242
+                android:layout_width="match_parent"
243
+                android:layout_height="wrap_content"
244
+                android:gravity="top|center_horizontal"
245
+                android:text="@string/current_programme"
246
+                android:textAlignment="center"
247
+                android:textColor="@color/whited3"
248
+                android:textSize="16sp"
249
+                app:layout_constraintStart_toStartOf="parent"
250
+                app:layout_constraintEnd_toEndOf="parent"
251
+                app:layout_constraintTop_toTopOf="parent"
252
+                android:visibility="visible" />
253
+
254
+            <TextView
255
+                android:id="@+id/text_current_programme"
256
+                android:layout_width="0dp"
257
+                android:layout_height="wrap_content"
258
+                android:text=""
259
+                android:layout_marginStart="8sp"
260
+                android:layout_marginLeft="8sp"
261
+                android:gravity="start|center_horizontal"
262
+                android:textAlignment="textStart"
263
+                android:textColor="@color/whited"
264
+                android:textSize="16sp"
265
+                app:layout_constraintStart_toEndOf="@id/current_programme"
266
+                app:layout_constraintEnd_toEndOf="parent"
267
+                app:layout_constraintTop_toTopOf="parent"
268
+                android:visibility="gone"
269
+                />
270
+
271
+        </androidx.constraintlayout.widget.ConstraintLayout>
272
+        </ScrollView>
246
 
273
 
247
         <androidx.constraintlayout.widget.Guideline
274
         <androidx.constraintlayout.widget.Guideline
248
             android:id="@+id/topInfoGuideline"
275
             android:id="@+id/topInfoGuideline"
298
                     android:text=""
325
                     android:text=""
299
                     android:textAlignment="center"
326
                     android:textAlignment="center"
300
                     android:textColor="@color/whited"
327
                     android:textColor="@color/whited"
301
-                    android:textSize="18sp"
328
+                    android:textSize="20sp"
302
                     app:layout_constraintBottom_toBottomOf="parent"
329
                     app:layout_constraintBottom_toBottomOf="parent"
303
                     app:layout_constraintStart_toStartOf="parent" />
330
                     app:layout_constraintStart_toStartOf="parent" />
304
 
331
 
310
                     android:text=""
337
                     android:text=""
311
                     android:textAlignment="center"
338
                     android:textAlignment="center"
312
                     android:textColor="@color/whited3"
339
                     android:textColor="@color/whited3"
313
-                    android:textSize="18sp"
340
+                    android:textSize="20sp"
314
                     app:layout_constraintBottom_toTopOf="@id/text_song_title"
341
                     app:layout_constraintBottom_toTopOf="@id/text_song_title"
315
                     app:layout_constraintStart_toStartOf="parent" />
342
                     app:layout_constraintStart_toStartOf="parent" />
316
 
343
 
376
             android:layout_width="wrap_content"
403
             android:layout_width="wrap_content"
377
             android:layout_height="wrap_content"
404
             android:layout_height="wrap_content"
378
             android:orientation="horizontal"
405
             android:orientation="horizontal"
379
-            app:layout_constraintGuide_percent="0.58" />
406
+            app:layout_constraintGuide_percent="0.63" />
380
 
407
 
381
 
408
 
382
         <ImageButton
409
         <ImageButton

+ 6 - 7
app/src/main/res/menu/toolbar_menu.xml View File

15
         app:showAsAction="ifRoom"/>
15
         app:showAsAction="ifRoom"/>
16
 
16
 
17
     <!--
17
     <!--
18
-    <item
19
-        android:id="@+id/action_refresh"
20
-        android:title="@string/action_refresh"
21
-        app:showAsAction="never"/>
22
-    -->
23
 
18
 
24
-    <!--
25
     <item
19
     <item
26
         android:id="@+id/action_bug_submit"
20
         android:id="@+id/action_bug_submit"
27
         android:title="@string/action_bug_submit"
21
         android:title="@string/action_bug_submit"
28
         app:showAsAction="never"/>
22
         app:showAsAction="never"/>
29
     -->
23
     -->
30
 
24
 
25
+    <item
26
+        android:id="@+id/action_refresh"
27
+        android:title="@string/action_refresh"
28
+        app:showAsAction="never"/>
29
+
31
     <item android:id="@+id/action_settings"
30
     <item android:id="@+id/action_settings"
32
         android:title="@string/action_settings"
31
         android:title="@string/action_settings"
33
         android:icon="@drawable/ic_settings"
32
         android:icon="@drawable/ic_settings"
34
-        app:showAsAction="ifRoom"/>
33
+        app:showAsAction="never"/>
35
 
34
 
36
 
35
 
37
 </menu>
36
 </menu>

+ 4 - 2
app/src/main/res/values-fr/strings.xml View File

10
 
10
 
11
     <string name="volume">Volume : </string>
11
     <string name="volume">Volume : </string>
12
 
12
 
13
-    <string name="up_next">Prochain titre :</string>
14
-    <string name="current_programme">Émission en cours : </string>
13
+    <string name="up_next">À suivre :</string>
14
+    <string name="current_programme">Émission : </string>
15
     <string name="now_streaming">En cours</string>
15
     <string name="now_streaming">En cours</string>
16
     <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>
16
     <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>
17
     <string name="action_settings">Paramètres</string>
17
     <string name="action_settings">Paramètres</string>
52
     <string name="setSleepDuration">Choisir une durée (en minutes)</string>
52
     <string name="setSleepDuration">Choisir une durée (en minutes)</string>
53
     <string name="willCloseIn">Extinction dans %1$d minutes</string>
53
     <string name="willCloseIn">Extinction dans %1$d minutes</string>
54
     <string name="fetchPeriod">Choisir la fréquence de mise à jour quand la radio est stoppée</string>
54
     <string name="fetchPeriod">Choisir la fréquence de mise à jour quand la radio est stoppée</string>
55
+    <string name="refreshing">Actualisation…</string>
56
+    <string name="action_refresh">Raffraîchir les données</string>
55
 
57
 
56
 </resources>
58
 </resources>

+ 2 - 0
app/src/main/res/values/strings.xml View File

72
     <string name="setSleepDuration">Set duration (minutes)</string>
72
     <string name="setSleepDuration">Set duration (minutes)</string>
73
     <string name="willCloseIn">Will close in %1$d minutes</string>
73
     <string name="willCloseIn">Will close in %1$d minutes</string>
74
     <string name="fetchPeriod">Set update period when stopped</string>
74
     <string name="fetchPeriod">Set update period when stopped</string>
75
+    <string name="refreshing">Refreshing data…</string>
76
+    <string name="action_refresh">Refresh data</string>
75
 
77
 
76
 </resources>
78
 </resources>