Skip to content

Commit cea30da

Browse files
committed
add warning message for advanced shortcut
1 parent 3525620 commit cea30da

8 files changed

Lines changed: 67 additions & 10 deletions

File tree

‎README.md‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,17 @@ L'application communique avec le véhicule via le SDK propriétaire SAIC, en acc
7878
- **SWI69 / SWI131** : Anti-collision avant (AEB) — On / Off + mode Alerte uniquement / Alerte + Freinage
7979
- **SWI165** : Désactiver / ACC / TJA + Anti-collision avant (AEB) On/Off + mode Alerte / Alerte+Freinage + avertissement sonore
8080

81-
### Raccourcis volant
81+
### Raccourcis sur boutons physiques
8282

8383
Deux systèmes coexistent, réglés dans le même écran :
8484

8585
- **Raccourcis classiques** — boutons ★ gauche et droit, en appui simple ou long. Ils reposent sur
8686
le broadcast émis par le véhicule : si le launcher officiel utilise déjà le bouton, il reste
8787
prioritaire.
88-
- **Raccourcis avancés** — n'importe quelle touche du volant, en appui **court, long ou double**,
89-
via un **service d'accessibilité** que l'utilisateur active lui-même dans Android. MG4Control
90-
voit alors la touche **avant** le launcher et peut la consommer.
88+
- **Raccourcis avancés** — n'importe quelle touche physique, au volant **comme sur la façade
89+
sous l'écran**, en appui **court, long ou double**, via un **service d'accessibilité** que
90+
l'utilisateur active lui-même dans Android. MG4Control voit alors la touche **avant** le
91+
launcher et peut la consommer.
9192

9293
L'appui long part **dès le seuil de 500 ms atteint**, sans attendre le relâchement : l'action se
9394
déclenche toujours au même moment, la touche encore enfoncée. Le double appui, lui, a un coût à
@@ -782,15 +783,16 @@ The app communicates with the vehicle through the proprietary SAIC SDK, accessin
782783
- **SWI69 / SWI131**: Forward Collision Warning (AEB) — On / Off + mode Alert only / Alert + Emergency Braking
783784
- **SWI165**: Disable / ACC / TJA + Forward Collision Warning (AEB) On/Off + Alert / Alert+Braking mode + audible warning
784785

785-
### Steering Wheel Shortcuts
786+
### Physical Button Shortcuts
786787

787788
Two systems live side by side, configured from the same screen:
788789

789790
- **Classic shortcuts** — the left and right ★ buttons, short or long press. They rely on the
790791
broadcast the vehicle emits: if the stock launcher already uses that button, the launcher wins.
791-
- **Advanced shortcuts** — any steering wheel key, as a **short, long or double** press, through
792-
an **accessibility service** the user enables themselves in Android. MG4Control then sees the key
793-
**before** the launcher and can consume it.
792+
- **Advanced shortcuts** — any physical key, on the steering wheel **as well as on the panel
793+
below the screen**, as a **short, long or double** press, through an **accessibility service**
794+
the user enables themselves in Android. MG4Control then sees the key **before** the launcher and
795+
can consume it.
794796

795797
A long press fires **as soon as the 500 ms threshold is reached**, without waiting for the release:
796798
the action always happens at the same moment, while the key is still held. A double press has a

‎app/src/main/java/com/mg4/control/ui/ShortcutsFragment.kt‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,35 @@ class ShortcutsFragment : Fragment() {
256256
refreshAdvancedList(view)
257257
}
258258

259+
// ⚠️ L'état est posé AVANT l'écouteur : sinon l'avertissement d'activation ci-dessous
260+
// s'afficherait à chaque ouverture de l'écran, sans que l'utilisateur ait rien demandé.
259261
sw.isChecked = AdvancedShortcuts.isEnabled(requireContext())
260262
sw.setOnCheckedChangeListener { _, checked ->
261-
AdvancedShortcuts.setEnabled(requireContext(), checked)
262-
majEtat()
263+
// Désactivation : rien à expliquer, les touches sont rendues au système.
264+
if (!checked) {
265+
AdvancedShortcuts.setEnabled(requireContext(), false)
266+
majEtat()
267+
return@setOnCheckedChangeListener
268+
}
269+
270+
// Activation : on prévient AVANT d'armer quoi que ce soit. Qu'un bouton du volant
271+
// perde sa fonction d'origine ne se devine pas depuis un interrupteur, et se
272+
// découvrirait au volant — c'est exactement ce qui est arrivé à un testeur avec la
273+
// touche Accueil, qui a cru à un plantage.
274+
//
275+
// Rien n'est enregistré tant que l'utilisateur n'a pas confirmé : annuler, ou fermer
276+
// la boîte de dialogue, remet l'interrupteur sur off — ce qui repasse par ce même
277+
// écouteur avec `checked = false`, donc par la désactivation propre ci-dessus.
278+
AlertDialog.Builder(requireContext())
279+
.setTitle(R.string.adv_sc_enable_warn_title)
280+
.setMessage(R.string.adv_sc_enable_warn_msg)
281+
.setPositiveButton(R.string.adv_sc_enable_warn_ok) { _, _ ->
282+
AdvancedShortcuts.setEnabled(requireContext(), true)
283+
majEtat()
284+
}
285+
.setNegativeButton(android.R.string.cancel) { _, _ -> sw.isChecked = false }
286+
.setOnCancelListener { _ -> sw.isChecked = false }
287+
.show()
263288
}
264289

265290
btnAcc.setOnClickListener {

‎app/src/main/res/values-de/strings.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,9 @@
458458
<string name="adv_sc_replace_msg">%1$s bei %2$s löst bereits aus: %3$s.\n\nDurch die neue Funktion ersetzen?</string>
459459
<string name="adv_sc_replace_ok">Ersetzen</string>
460460
<string name="adv_sc_press_double">Doppelter Druck</string>
461+
462+
<!-- Avertissement a l'activation des raccourcis avances -->
463+
<string name="adv_sc_enable_warn_title">Belegte Taste ändert ihre Rolle</string>
464+
<string name="adv_sc_enable_warn_msg">Eine belegte Taste verliert ihre ursprüngliche Funktion: MG4Control fängt die Taste vor dem Launcher ab, der sie gar nicht mehr sieht.\n\nBeispiel: Wird die Home-Taste belegt, führt sie nicht mehr zum MG-Launcher zurück. Um das wiederherzustellen, weisen Sie ihr die Aktion App starten zu und wählen Sie den Launcher.\n\nDie Taste wird komplett beansprucht: Wird nur der lange Druck belegt, sind auch kurzer und doppelter Druck wirkungslos.\n\nAlles wird wieder normal, sobald die Verknüpfung in der Kürzelliste gelöscht wird.</string>
465+
<string name="adv_sc_enable_warn_ok">Aktivieren</string>
461466
</resources>

‎app/src/main/res/values-en/strings.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,9 @@
458458
<string name="adv_sc_replace_msg">%1$s on %2$s already runs: %3$s.\n\nReplace it with the new action?</string>
459459
<string name="adv_sc_replace_ok">Replace</string>
460460
<string name="adv_sc_press_double">Double press</string>
461+
462+
<!-- Avertissement a l'activation des raccourcis avances -->
463+
<string name="adv_sc_enable_warn_title">Assigned buttons change role</string>
464+
<string name="adv_sc_enable_warn_msg">A button assigned to an advanced shortcut loses its original function: MG4Control intercepts the key before the launcher, which no longer sees it at all.\n\nExample: assign the Home button and it no longer returns to the MG launcher. To get that back, give it the Launch an app action and pick the launcher.\n\nThe key is claimed as a whole: assigning only the long press also neutralises the short press and the double press.\n\nEverything returns to normal once the shortcut is deleted from Shortcut list.</string>
465+
<string name="adv_sc_enable_warn_ok">Enable</string>
461466
</resources>

‎app/src/main/res/values-es/strings.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,9 @@
458458
<string name="adv_sc_replace_msg">%1$s en %2$s ya ejecuta: %3$s.\n\n¿Reemplazar por la nueva función?</string>
459459
<string name="adv_sc_replace_ok">Reemplazar</string>
460460
<string name="adv_sc_press_double">Doble pulsación</string>
461+
462+
<!-- Avertissement a l'activation des raccourcis avances -->
463+
<string name="adv_sc_enable_warn_title">El botón asignado cambia de función</string>
464+
<string name="adv_sc_enable_warn_msg">Un botón asignado a un atajo avanzado pierde su función original: MG4Control intercepta la tecla antes que el launcher, que ya no la recibe.\n\nEjemplo: si asigna el botón Inicio, dejará de volver al launcher de MG. Para recuperarlo, asígnele la acción « Iniciar una app » y elija el launcher.\n\nLa tecla se reserva por completo: asignar solo la pulsación larga anula también la corta y la doble.\n\nTodo vuelve a la normalidad al eliminar el atajo en « Lista de atajos ».</string>
465+
<string name="adv_sc_enable_warn_ok">Activar</string>
461466
</resources>

‎app/src/main/res/values-it/strings.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,9 @@
458458
<string name="adv_sc_replace_msg">%1$s con %2$s esegue già: %3$s.\n\nSostituire con la nuova funzione?</string>
459459
<string name="adv_sc_replace_ok">Sostituisci</string>
460460
<string name="adv_sc_press_double">Doppia pressione</string>
461+
462+
<!-- Avertissement a l'activation des raccourcis avances -->
463+
<string name="adv_sc_enable_warn_title">Il pulsante assegnato cambia ruolo</string>
464+
<string name="adv_sc_enable_warn_msg">Un pulsante assegnato a una scorciatoia avanzata perde la sua funzione originale: MG4Control intercetta il tasto prima del launcher, che non lo riceve più.\n\nEsempio: se assegni il pulsante Home, non riporterà più al launcher MG. Per recuperarlo, assegnagli l\'azione « Avvia un\'app » e scegli il launcher.\n\nIl tasto è riservato per intero: assegnare solo la pressione lunga annulla anche quella breve e quella doppia.\n\nTutto torna normale eliminando la scorciatoia in « Elenco scorciatoie ».</string>
465+
<string name="adv_sc_enable_warn_ok">Attiva</string>
461466
</resources>

‎app/src/main/res/values-pt/strings.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,9 @@
458458
<string name="adv_sc_replace_msg">%1$s em %2$s já executa: %3$s.\n\nSubstituir pela nova função?</string>
459459
<string name="adv_sc_replace_ok">Substituir</string>
460460
<string name="adv_sc_press_double">Pressão dupla</string>
461+
462+
<!-- Avertissement a l'activation des raccourcis avances -->
463+
<string name="adv_sc_enable_warn_title">O botão atribuído muda de função</string>
464+
<string name="adv_sc_enable_warn_msg">Um botão atribuído a um atalho avançado perde a sua função original: o MG4Control intercepta a tecla antes do launcher, que deixa de a receber.\n\nExemplo: se atribuir o botão Início, deixará de voltar ao launcher MG. Para o recuperar, atribua-lhe a ação « Iniciar um app » e escolha o launcher.\n\nA tecla é reservada por completo: atribuir apenas a pressão longa anula também a curta e a dupla.\n\nTudo volta ao normal ao eliminar o atalho em « Lista de atalhos ».</string>
465+
<string name="adv_sc_enable_warn_ok">Ativar</string>
461466
</resources>

‎app/src/main/res/values/strings.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,9 @@
460460
<string name="adv_sc_replace_msg">%1$s en %2$s déclenche déjà : %3$s.\n\nRemplacer par la nouvelle fonction ?</string>
461461
<string name="adv_sc_replace_ok">Remplacer</string>
462462
<string name="adv_sc_press_double">Double appui</string>
463+
464+
<!-- Avertissement a l'activation des raccourcis avances -->
465+
<string name="adv_sc_enable_warn_title">Le bouton attribué change de rôle</string>
466+
<string name="adv_sc_enable_warn_msg">Un bouton attribué à un raccourci avancé perd sa fonction d\'origine : MG4Control intercepte la touche avant le launcher, qui ne la voit plus du tout.\n\nExemple : si vous attribuez le bouton Accueil, il ne ramènera plus au launcher MG. Pour retrouver ce comportement, donnez-lui l\'action « Lancer une application » et choisissez le launcher.\n\nLa touche est réclamée en entier : n\'attribuer que l\'appui long neutralise aussi l\'appui court et le double appui.\n\nTout redevient normal en supprimant le raccourci dans « Liste des raccourcis ».</string>
467+
<string name="adv_sc_enable_warn_ok">Activer</string>
463468
</resources>

0 commit comments

Comments
 (0)