[Android] Fix audio play icon state upon orientation change

Nicolas Pomepuy git at videolan.org
Thu Jun 27 11:02:36 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Jun 27 07:33:47 2019 +0200| [e73946b38b58869341178985405338a0233495e8] | committer: Nicolas Pomepuy

Fix audio play icon state upon orientation change

> https://code.videolan.org/videolan/vlc-android/commit/e73946b38b58869341178985405338a0233495e8
---

 vlc-android/res/drawable/anim_pause_play.xml              | 10 +++++-----
 vlc-android/res/drawable/anim_play_pause.xml              | 10 +++++-----
 vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt |  9 ++++++---
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/vlc-android/res/drawable/anim_pause_play.xml b/vlc-android/res/drawable/anim_pause_play.xml
index 70d7ffbde..f88177299 100644
--- a/vlc-android/res/drawable/anim_pause_play.xml
+++ b/vlc-android/res/drawable/anim_pause_play.xml
@@ -12,11 +12,11 @@
                 android:pivotX="18"
                 android:pivotY="18">
                 <path
-                    android:name="path_1"
-                    android:pathData="M 6.879 9.879 C 6.316 10.441 6 11.205 6 12 C 6 12.795 6.316 13.559 6.879 14.121 C 7.441 14.684 8.205 15 9 15 L 27 15 C 27.795 15 28.559 14.684 29.121 14.121 C 29.684 13.559 30 12.795 30 12 C 30 11.205 29.684 10.441 29.121 9.879 C 28.559 9.316 27.795 9 27 9 L 9 9 C 8.205 9 7.441 9.316 6.879 9.879 M 6.879 21.879 C 6.316 22.441 6 23.205 6 24 C 6 24.795 6.316 25.559 6.879 26.121 C 7.441 26.684 8.205 27 9 27 L 27 27 C 27.795 27 28.559 26.684 29.121 26.121 C 29.684 25.559 30 24.795 30 24 C 30 23.205 29.684 22.441 29.121 21.879 C 28.559 21.316 27.795 21 27 21 L 9 21 C 8.205 21 7.441 21.316 6.879 21.879"
-                    android:fillColor="?attr/player_icon_color"
-                    android:strokeWidth="1"
-                    android:fillType="evenOdd" />
+                        android:name="path_1"
+                        android:pathData="M 6.66 3.001 C 6.66 3.001 6.66 3.001 6.66 3.001 C 5.869 3.049 5.251 3.705 5.251 4.498 C 5.251 8.922 5.251 13.347 5.251 17.771 L 18 17.907 C 22.249 17.952 26.499 17.998 30.748 18.043 C 30.763 17.531 30.521 17.012 30.021 16.712 C 27.521 15.212 25.021 13.712 22.521 12.212 C 20.021 10.712 17.521 9.212 15.021 7.712 L 7.522 3.212 C 7.262 3.057 6.962 2.983 6.66 3.001 M 5.251 24.634 C 5.251 26.922 5.251 29.209 5.251 31.497 C 5.25 32.663 6.521 33.385 7.522 32.786 C 9.397 31.661 11.271 30.536 13.146 29.411 L 18.771 26.035 C 20.646 24.91 22.521 23.785 24.396 22.66 C 26.271 21.534 28.146 20.409 30.021 19.284 C 30.491 19.001 30.734 18.525 30.748 18.043 C 26.499 17.998 22.249 17.952 18 17.907 L 5.251 17.771 C 5.251 20.059 5.251 22.346 5.251 24.634"
+                        android:fillColor="?attr/player_icon_color"
+                        android:strokeWidth="1"
+                        android:fillType="evenOdd" />
             </group>
         </vector>
     </aapt:attr>
diff --git a/vlc-android/res/drawable/anim_play_pause.xml b/vlc-android/res/drawable/anim_play_pause.xml
index 2884624f1..3c6359b2f 100644
--- a/vlc-android/res/drawable/anim_play_pause.xml
+++ b/vlc-android/res/drawable/anim_play_pause.xml
@@ -12,11 +12,11 @@
                 android:pivotX="18"
                 android:pivotY="18">
                 <path
-                    android:name="path_1"
-                    android:pathData="M 6.879 9.879 C 6.316 10.441 6 11.205 6 12 C 6 12.795 6.316 13.559 6.879 14.121 C 7.441 14.684 8.205 15 9 15 L 27 15 C 27.795 15 28.559 14.684 29.121 14.121 C 29.684 13.559 30 12.795 30 12 C 30 11.205 29.684 10.441 29.121 9.879 C 28.559 9.316 27.795 9 27 9 L 9 9 C 8.205 9 7.441 9.316 6.879 9.879 M 6.879 21.879 C 6.316 22.441 6 23.205 6 24 C 6 24.795 6.316 25.559 6.879 26.121 C 7.441 26.684 8.205 27 9 27 L 27 27 C 27.795 27 28.559 26.684 29.121 26.121 C 29.684 25.559 30 24.795 30 24 C 30 23.205 29.684 22.441 29.121 21.879 C 28.559 21.316 27.795 21 27 21 L 9 21 C 8.205 21 7.441 21.316 6.879 21.879"
-                    android:fillColor="?attr/player_icon_color"
-                    android:strokeWidth="1"
-                    android:fillType="evenOdd" />
+                        android:name="path_1"
+                        android:pathData="M 24 30 C 23.205 30 22.441 29.684 21.879 29.121 C 21.316 28.559 21 27.795 21 27 L 21 9 C 21 8.205 21.316 7.441 21.879 6.879 C 22.441 6.316 23.205 6 24 6 C 24.795 6 25.559 6.316 26.121 6.879 C 26.684 7.441 27 8.205 27 9 L 27 27 C 27 27.795 26.684 28.559 26.121 29.121 C 25.559 29.684 24.795 30 24 30 M 12 30 C 11.205 30 10.441 29.684 9.879 29.121 C 9.316 28.559 9 27.795 9 27 L 9 9 C 9 8.205 9.316 7.441 9.879 6.879 C 10.441 6.316 11.205 6 12 6 C 12.795 6 13.559 6.316 14.121 6.879 C 14.684 7.441 15 8.205 15 9 L 15 27 C 15 27.795 14.684 28.559 14.121 29.121 C 13.559 29.684 12.795 30 12 30"
+                        android:fillColor="?attr/player_icon_color"
+                        android:strokeWidth="1"
+                        android:fillType="evenOdd" />
             </group>
         </vector>
     </aapt:attr>
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index 710719e9b..15ac8ee70 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -112,7 +112,10 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, CoroutineS
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
-        savedInstanceState?.let { playerState = it.getInt("player_state") }
+        savedInstanceState?.let {
+            playerState = it.getInt("player_state")
+            wasPlaying = it.getBoolean("was_playing")
+        }
         playlistAdapter = PlaylistAdapter(this)
         settings = Settings.getInstance(requireContext())
         playlistModel = PlaylistModel.get(this)
@@ -171,6 +174,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, CoroutineS
     override fun onSaveInstanceState(outState: Bundle) {
         super.onSaveInstanceState(outState)
         outState.putInt("player_state", playerState)
+        outState.putBoolean("was_playing", wasPlaying)
     }
 
     private val ctxReceiver: CtxActionReceiver = object : CtxActionReceiver {
@@ -212,10 +216,9 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, CoroutineS
         updateBackground()
     }
 
-    private var wasPlaying = false
+    private var wasPlaying = true
     private fun updatePlayPause() {
         val playing = playlistModel.playing
-        if (playing == wasPlaying) return
         val text = getString(if (playing) R.string.pause else R.string.play)
 
         val drawable = if (playing) playToPause else pauseToPlay



More information about the Android mailing list