Selaa lähdekoodia

Fix : autoplay as setting, sensor to fullUser, close button, keep volume

yattoz 4 vuotta sitten
vanhempi
commit
f2f338f1d4

+ 1 - 1
app/src/main/AndroidManifest.xml Näytä tiedosto

48
             android:configChanges="orientation|screenSize"
48
             android:configChanges="orientation|screenSize"
49
             android:label="@string/app_name"
49
             android:label="@string/app_name"
50
             android:launchMode="singleTask"
50
             android:launchMode="singleTask"
51
-            android:screenOrientation="fullSensor">
51
+            android:screenOrientation="fullUser">
52
             <intent-filter>
52
             <intent-filter>
53
                 <action android:name="android.intent.action.MAIN" />
53
                 <action android:name="android.intent.action.MAIN" />
54
 
54
 

+ 2 - 2
app/src/main/java/fr/forum_thalie/tsumugi/NowPlayingNotification.kt Näytä tiedosto

39
 
39
 
40
         mediaStyle = androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle().also {
40
         mediaStyle = androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle().also {
41
             it.setMediaSession(m.sessionToken)
41
             it.setMediaSession(m.sessionToken)
42
-            it.setShowActionsInCompactView(0) // index 0 = show actions 0 and 1 (show action #0 (play/pause))
42
+            it.setShowActionsInCompactView(0, 1) // index 0 = show actions 0 and 1 (show action #0 (play/pause))
43
             it.setCancelButtonIntent(deleteIntent)
43
             it.setCancelButtonIntent(deleteIntent)
44
         }
44
         }
45
         builder.setStyle(mediaStyle)
45
         builder.setStyle(mediaStyle)
83
             val intent2 = Intent(c, RadioService::class.java)
83
             val intent2 = Intent(c, RadioService::class.java)
84
             intent2.putExtra("action", Actions.KILL.name)
84
             intent2.putExtra("action", Actions.KILL.name)
85
             val pendingButtonIntent = PendingIntent.getService(c, 2, intent2, PendingIntent.FLAG_UPDATE_CURRENT)
85
             val pendingButtonIntent = PendingIntent.getService(c, 2, intent2, PendingIntent.FLAG_UPDATE_CURRENT)
86
-            val stopAction = NotificationCompat.Action.Builder(R.drawable.ic_stop,"Stop", pendingButtonIntent).build()
86
+            val stopAction = NotificationCompat.Action.Builder(R.drawable.ic_close,"Stop", pendingButtonIntent).build()
87
             builder.addAction(stopAction)
87
             builder.addAction(stopAction)
88
 
88
 
89
             if (isRinging) {
89
             if (isRinging) {

+ 1 - 1
app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt Näytä tiedosto

72
                 }
72
                 }
73
                 1 -> {
73
                 1 -> {
74
                     //[REMOVE LOG CALLS]Log.d(tag, radioTag + "Headset is plugged")
74
                     //[REMOVE LOG CALLS]Log.d(tag, radioTag + "Headset is plugged")
75
-                    headsetPluggedIn = true
75
+                    headsetPluggedIn = true && PreferenceManager.getDefaultSharedPreferences(context).getBoolean("autoStartOnPlug", false)
76
                 }
76
                 }
77
                 else -> {
77
                 else -> {
78
                     //[REMOVE LOG CALLS]Log.d(tag, radioTag + "I have no idea what the headset state is")
78
                     //[REMOVE LOG CALLS]Log.d(tag, radioTag + "I have no idea what the headset state is")

+ 6 - 0
app/src/main/java/fr/forum_thalie/tsumugi/ui/nowplaying/NowPlayingViewModel.kt Näytä tiedosto

1
 package fr.forum_thalie.tsumugi.ui.nowplaying
1
 package fr.forum_thalie.tsumugi.ui.nowplaying
2
 
2
 
3
 import android.widget.SeekBar
3
 import android.widget.SeekBar
4
+import androidx.core.content.edit
4
 import androidx.lifecycle.MutableLiveData
5
 import androidx.lifecycle.MutableLiveData
5
 import androidx.lifecycle.ViewModel
6
 import androidx.lifecycle.ViewModel
6
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
7
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
8
+import fr.forum_thalie.tsumugi.preferenceStore
7
 
9
 
8
 class NowPlayingViewModel: ViewModel() {
10
 class NowPlayingViewModel: ViewModel() {
9
 
11
 
21
             override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
23
             override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
22
                 // updated continuously as the user slides the thumb
24
                 // updated continuously as the user slides the thumb
23
                 PlayerStore.instance.volume.value = progress
25
                 PlayerStore.instance.volume.value = progress
26
+                preferenceStore.edit {
27
+                    putInt("volume", progress)
28
+                    commit()
29
+                }
24
             }
30
             }
25
 
31
 
26
             override fun onStartTrackingTouch(seekBar: SeekBar) {
32
             override fun onStartTrackingTouch(seekBar: SeekBar) {

+ 11 - 0
app/src/main/res/drawable-anydpi/ic_close.xml Näytä tiedosto

1
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+    android:width="24dp"
3
+    android:height="24dp"
4
+    android:viewportWidth="24"
5
+    android:viewportHeight="24"
6
+    android:tint="#FFFFFF"
7
+    android:alpha="0.8">
8
+    <path
9
+        android:fillColor="#FF000000"
10
+        android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
11
+</vector>

BIN
app/src/main/res/drawable-hdpi/ic_close.png Näytä tiedosto


BIN
app/src/main/res/drawable-mdpi/ic_close.png Näytä tiedosto


BIN
app/src/main/res/drawable-xhdpi/ic_close.png Näytä tiedosto


BIN
app/src/main/res/drawable-xxhdpi/ic_close.png Näytä tiedosto


+ 1 - 0
app/src/main/res/values-fr/strings.xml Näytä tiedosto

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>
55
     <string name="refreshing">Actualisation…</string>
56
     <string name="action_refresh">Raffraîchir les données</string>
56
     <string name="action_refresh">Raffraîchir les données</string>
57
+    <string name="autoPlay">\"Play\" au branchement de la prise casque</string>
57
 
58
 
58
 </resources>
59
 </resources>

+ 1 - 0
app/src/main/res/values/strings.xml Näytä tiedosto

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>
75
     <string name="refreshing">Refreshing data…</string>
76
     <string name="action_refresh">Refresh data</string>
76
     <string name="action_refresh">Refresh data</string>
77
+    <string name="autoPlay">Auto play when plugging headphones</string>
77
 
78
 
78
 </resources>
79
 </resources>

+ 9 - 1
app/src/main/res/xml/customize_preferences.xml Näytä tiedosto

1
 <?xml version="1.0" encoding="utf-8"?>
1
 <?xml version="1.0" encoding="utf-8"?>
2
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
2
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
3
     xmlns:app="http://schemas.android.com/apk/res-auto">
3
     xmlns:app="http://schemas.android.com/apk/res-auto">
4
-
4
+<!--
5
     <SeekBarPreference
5
     <SeekBarPreference
6
         app:key="volume"
6
         app:key="volume"
7
         app:iconSpaceReserved="false"
7
         app:iconSpaceReserved="false"
12
         android:defaultValue="100"
12
         android:defaultValue="100"
13
         app:showSeekBarValue="true"
13
         app:showSeekBarValue="true"
14
         />
14
         />
15
+-->
16
+    <SwitchPreferenceCompat
17
+        app:key="autoStartOnPlug"
18
+        app:iconSpaceReserved="false"
19
+        app:title="@string/autoPlay"
20
+        app:singleLineTitle="false"
21
+        app:defaultValue="false"
22
+    />
15
 
23
 
16
     <SwitchPreferenceCompat
24
     <SwitchPreferenceCompat
17
         app:key="splitLayout"
25
         app:key="splitLayout"