Explorar el Código

Merge branch 'tsumugi/devel' into tsumugi/master

yattoz hace 5 años
padre
commit
1e5c72854a

+ 9 - 0
app/src/main/java/fr/forum_thalie/tsumugi/MainActivity.kt Ver fichero

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

+ 2 - 2
app/src/main/java/fr/forum_thalie/tsumugi/playerstore/PlayerStore.kt Ver fichero

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

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

@@ -1,5 +1,6 @@
1 1
 package fr.forum_thalie.tsumugi.playerstore
2 2
 
3
+import androidx.core.text.HtmlCompat
3 4
 import androidx.lifecycle.MutableLiveData
4 5
 import fr.forum_thalie.tsumugi.noConnectionValue
5 6
 
@@ -24,8 +25,9 @@ class Song(artistTitle: String = "", _id : Int = 0) {
24 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 31
         val hyphenPos = data.indexOf(" - ")
30 32
         try {
31 33
             if (hyphenPos < 0)
@@ -50,8 +52,7 @@ class Song(artistTitle: String = "", _id : Int = 0) {
50 52
     }
51 53
 
52 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 56
         this.startTime.value = song.startTime.value
56 57
         this.stopTime.value = song.stopTime.value
57 58
         this.type.value = song.type.value

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

@@ -6,8 +6,6 @@ import android.content.Context
6 6
 import androidx.lifecycle.ViewModelProviders
7 7
 import android.os.Bundle
8 8
 import android.support.v4.media.session.PlaybackStateCompat
9
-import android.util.Log
10
-import android.util.TypedValue
11 9
 import androidx.fragment.app.Fragment
12 10
 import android.view.LayoutInflater
13 11
 import android.view.View
@@ -15,7 +13,6 @@ import android.view.ViewGroup
15 13
 import android.widget.*
16 14
 import androidx.constraintlayout.widget.ConstraintLayout
17 15
 import androidx.constraintlayout.widget.ConstraintSet
18
-import androidx.core.widget.TextViewCompat
19 16
 import androidx.lifecycle.Observer
20 17
 import com.google.android.material.snackbar.BaseTransientBottomBar
21 18
 import com.google.android.material.snackbar.Snackbar
@@ -24,7 +21,6 @@ import fr.forum_thalie.tsumugi.alarm.RadioSleeper
24 21
 import fr.forum_thalie.tsumugi.planning.Planning
25 22
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
26 23
 import fr.forum_thalie.tsumugi.playerstore.Song
27
-import kotlinx.android.synthetic.main.fragment_nowplaying.*
28 24
 
29 25
 
30 26
 class NowPlayingFragment : Fragment() {
@@ -49,7 +45,7 @@ class NowPlayingFragment : Fragment() {
49 45
         val volumeText: TextView = root.findViewById(R.id.volume_text)
50 46
         val progressBar: ProgressBar = root.findViewById(R.id.progressBar)
51 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 49
         val streamerPictureImageView: ImageView = root.findViewById(R.id.streamerPicture)
54 50
 
55 51
         // 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() {
69 65
             listenersText,8, 16, 2, TypedValue.COMPLEX_UNIT_SP)
70 66
          */
71 67
 
72
-
73 68
         // trick : I can't observe the queue because it's an ArrayDeque that doesn't trigger any change...
74 69
         // so I observe a dedicated Mutable that gets set when the queue is updated.
75 70
         PlayerStore.instance.isQueueUpdated.observe(viewLifecycleOwner, Observer {
@@ -94,7 +89,7 @@ class NowPlayingFragment : Fragment() {
94 89
 
95 90
 
96 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 Ver fichero

@@ -49,7 +49,7 @@
49 49
             android:layout_width="wrap_content"
50 50
             android:layout_height="wrap_content"
51 51
             android:orientation="vertical"
52
-            app:layout_constraintGuide_percent="0.68" />
52
+            app:layout_constraintGuide_percent="0.71" />
53 53
 
54 54
         <androidx.constraintlayout.widget.Guideline
55 55
             android:id="@+id/imageLeftGuideline"
@@ -140,7 +140,7 @@
140 140
         <ImageView
141 141
             android:id="@+id/volume_icon"
142 142
             android:layout_width="wrap_content"
143
-            android:layout_height="24dp"
143
+            android:layout_height="20dp"
144 144
             android:contentDescription="@string/volume"
145 145
             android:src="@drawable/ic_volume_high"
146 146
             android:textSize="12sp"
@@ -156,10 +156,11 @@
156 156
             android:layout_height="0dp"
157 157
             android:fillViewport="true"
158 158
             android:layout_marginBottom="4dp"
159
-            app:layout_constraintBottom_toTopOf="@id/text_current_programme"
159
+            app:layout_constraintBottom_toTopOf="@id/scrollProgramme"
160 160
             app:layout_constraintEnd_toStartOf="@id/streamerPicture"
161 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 166
             <androidx.constraintlayout.widget.ConstraintLayout
@@ -193,7 +194,7 @@
193 194
                     android:text=""
194 195
                     android:textAlignment="center"
195 196
                     android:textColor="@color/whited3"
196
-                    android:textSize="14sp"
197
+                    android:textSize="16sp"
197 198
                     app:layout_constraintStart_toStartOf="parent"
198 199
                     app:layout_constraintTop_toBottomOf="@id/upNext"
199 200
                     android:visibility="visible"/>
@@ -206,7 +207,7 @@
206 207
                     android:text=""
207 208
                     android:textAlignment="center"
208 209
                     android:textColor="@color/whited"
209
-                    android:textSize="14sp"
210
+                    android:textSize="16sp"
210 211
                     app:layout_constraintStart_toStartOf="parent"
211 212
                     app:layout_constraintTop_toBottomOf="@id/text_song_artist_next"
212 213
                     android:visibility="visible" />
@@ -214,35 +215,61 @@
214 215
             </androidx.constraintlayout.widget.ConstraintLayout>
215 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 225
             app:layout_constraintStart_toStartOf="parent"
226
+            app:layout_constraintTop_toBottomOf="@id/scrollViewMetadataNext"
227 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 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 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 274
         <androidx.constraintlayout.widget.Guideline
248 275
             android:id="@+id/topInfoGuideline"
@@ -298,7 +325,7 @@
298 325
                     android:text=""
299 326
                     android:textAlignment="center"
300 327
                     android:textColor="@color/whited"
301
-                    android:textSize="18sp"
328
+                    android:textSize="20sp"
302 329
                     app:layout_constraintBottom_toBottomOf="parent"
303 330
                     app:layout_constraintStart_toStartOf="parent" />
304 331
 
@@ -310,7 +337,7 @@
310 337
                     android:text=""
311 338
                     android:textAlignment="center"
312 339
                     android:textColor="@color/whited3"
313
-                    android:textSize="18sp"
340
+                    android:textSize="20sp"
314 341
                     app:layout_constraintBottom_toTopOf="@id/text_song_title"
315 342
                     app:layout_constraintStart_toStartOf="parent" />
316 343
 
@@ -376,7 +403,7 @@
376 403
             android:layout_width="wrap_content"
377 404
             android:layout_height="wrap_content"
378 405
             android:orientation="horizontal"
379
-            app:layout_constraintGuide_percent="0.58" />
406
+            app:layout_constraintGuide_percent="0.63" />
380 407
 
381 408
 
382 409
         <ImageButton

+ 6 - 7
app/src/main/res/menu/toolbar_menu.xml Ver fichero

@@ -15,23 +15,22 @@
15 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 19
     <item
26 20
         android:id="@+id/action_bug_submit"
27 21
         android:title="@string/action_bug_submit"
28 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 30
     <item android:id="@+id/action_settings"
32 31
         android:title="@string/action_settings"
33 32
         android:icon="@drawable/ic_settings"
34
-        app:showAsAction="ifRoom"/>
33
+        app:showAsAction="never"/>
35 34
 
36 35
 
37 36
 </menu>

+ 4 - 2
app/src/main/res/values-fr/strings.xml Ver fichero

@@ -10,8 +10,8 @@
10 10
 
11 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 15
     <string name="now_streaming">En cours</string>
16 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 17
     <string name="action_settings">Paramètres</string>
@@ -52,5 +52,7 @@
52 52
     <string name="setSleepDuration">Choisir une durée (en minutes)</string>
53 53
     <string name="willCloseIn">Extinction dans %1$d minutes</string>
54 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 58
 </resources>

+ 2 - 0
app/src/main/res/values/strings.xml Ver fichero

@@ -72,5 +72,7 @@
72 72
     <string name="setSleepDuration">Set duration (minutes)</string>
73 73
     <string name="willCloseIn">Will close in %1$d minutes</string>
74 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 78
 </resources>