Skip to content

Commit 66f1c08

Browse files
committed
rework of the interface of A/C automation
1 parent faedd26 commit 66f1c08

18 files changed

Lines changed: 1621 additions & 715 deletions

File tree

‎app/src/main/java/com/mg4/control/automation/ClimateAutomationSettings.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ object ClimateAutomationSettings {
4444
const val MIN_TARGET = 15
4545
const val MAX_TARGET = 33
4646
const val MIN_FAN = 1
47-
const val MAX_FAN = 10
47+
/** Onze crans sur les firmwares A9, sept sur l'ancien SDK : le plus grand des deux. */
48+
const val MAX_FAN = 11
4849

4950
/** Une règle : sa condition de déclenchement et les réglages clim à appliquer. */
5051
data class Rule(
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.mg4.control.automation
2+
3+
/**
4+
* Carte « A/C selon la température » : ce que ses curseurs et ses boutons enregistrent — la partie
5+
* sans vue, donc testable.
6+
*
7+
* La carte est passée des champs de saisie aux curseurs sans toucher à [ClimateAutomationSettings] :
8+
* mêmes clés, mêmes valeurs, aucune reprise à faire chez ceux qui l'avaient déjà réglée.
9+
*/
10+
object ClimateRuleEditor {
11+
12+
// ── Recirculation ────────────────────────────────────────────────────────
13+
// Un seul choix à quatre positions remplace la case « Forcer la recirculation » et ses trois
14+
// boutons : 0 = inchangée (la case décochée), puis 1 = intérieur, 2 = extérieur, 3 = auto —
15+
// soit le mode de la voiture (0, 1, 2) décalé d'un rang.
16+
17+
/** Position à allumer pour les réglages enregistrés. */
18+
fun recircChoice(force: Boolean, mode: Int): Int = if (force) mode.coerceIn(0, 2) + 1 else 0
19+
20+
/** Vrai si le choix demande à piloter la recirculation. */
21+
fun recircForce(choice: Int): Boolean = choice != 0
22+
23+
/**
24+
* Mode à enregistrer, ou `null` pour « inchangée » : le mode déjà enregistré reste alors en
25+
* place, comme quand on décochait la case.
26+
*/
27+
fun recircMode(choice: Int): Int? = if (choice in 1..3) choice - 1 else null
28+
29+
// ── Seuils ───────────────────────────────────────────────────────────────
30+
// Le seuil froid reste sous le seuil chaud. Croisés, ils déclenchent les deux règles à la
31+
// fois et [ClimateAutomationDecision] retient « chaud » — ce que rien à l'écran ne disait.
32+
33+
/** Seuil chaud à retenir quand l'utilisateur vise [wanted], le seuil froid étant à [cold]. */
34+
fun hotThreshold(wanted: Int, cold: Int): Int =
35+
maxOf(wanted, cold + 1).coerceIn(ClimateAutomationSettings.MIN_TEMP, ClimateAutomationSettings.MAX_TEMP)
36+
37+
/** Seuil froid à retenir quand l'utilisateur vise [wanted], le seuil chaud étant à [hot]. */
38+
fun coldThreshold(wanted: Int, hot: Int): Int =
39+
minOf(wanted, hot - 1).coerceIn(ClimateAutomationSettings.MIN_TEMP, ClimateAutomationSettings.MAX_TEMP)
40+
41+
// ── Curseurs ─────────────────────────────────────────────────────────────
42+
43+
/**
44+
* Valeur à poser sur un curseur borné à [min]..[max]. Les bornes sont celles de la voiture
45+
* (16–32 °C et 7 crans sur l'ancien SDK, 17–33 °C et 11 crans sur A9) : une valeur saisie
46+
* autrefois peut en sortir, et un Slider posé hors de ses bornes fait planter l'écran.
47+
*/
48+
fun sliderValue(stored: Int, min: Int, max: Int): Int = stored.coerceIn(min, maxOf(min, max))
49+
50+
/** Seuil tel qu'il se lit à droite de son curseur : « ≥ 28 °C » ou « ≤ 5 °C ». */
51+
fun thresholdLabel(hot: Boolean, value: Int): String = (if (hot) "\u2265 " else "\u2264 ") + value + " °C"
52+
53+
// ── Boutons de recirculation ─────────────────────────────────────────────
54+
55+
/** Largeur en dessous de laquelle un bouton ne tient plus son libellé dans les sept langues. */
56+
const val MIN_BUTTON_DP = 130f
57+
58+
/**
59+
* Nombre de boutons par ligne pour une rangée de [rowWidthDp] : les quatre côte à côte quand
60+
* la place le permet, sinon trois — « Auto » passe alors dessous, sous « Inchangée ».
61+
*/
62+
fun recircColumns(rowWidthDp: Float): Int = if (rowWidthDp >= 4 * MIN_BUTTON_DP) 4 else 3
63+
}

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

Lines changed: 255 additions & 156 deletions
Large diffs are not rendered by default.

‎app/src/main/res/layout/fragment_automation.xml‎

Lines changed: 938 additions & 372 deletions
Large diffs are not rendered by default.

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,18 @@
365365
<!-- Klima-Automatisierung -->
366366
<string name="ac_auto_title">Klimaanlage über die Temperatur auslösen</string>
367367
<string name="ac_auto_desc">Klimaanlage nach der Außentemperatur einstellen</string>
368-
<string name="ac_auto_hot">Temperatur darüber</string>
369-
<string name="ac_auto_cold">Temperatur darunter</string>
370-
<string name="ac_auto_threshold_hot_label">Auslöseschwelle (°C)</string>
371-
<string name="ac_auto_threshold_cold_label">Auslöseschwelle (°C)</string>
372-
<string name="ac_auto_threshold_hint">-20–60</string>
373-
<string name="ac_auto_target_label">Zieltemperatur (°C)</string>
374-
<string name="ac_auto_target_hint">15–33</string>
368+
<string name="ac_auto_hot">Wenn es heiß ist</string>
369+
<string name="ac_auto_cold">Wenn es kalt ist</string>
370+
<string name="ac_auto_threshold_hot_label">Außen, ab</string>
371+
<string name="ac_auto_threshold_cold_label">Außen, bis</string>
372+
<string name="ac_auto_target_label">Klima auf</string>
375373
<string name="ac_auto_fan_label">Gebläsestufe</string>
376-
<string name="ac_auto_fan_hint">1–10</string>
374+
<string name="ac_auto_fan_manual">Manuell</string>
375+
<string name="ac_auto_fan_level">Stufe</string>
376+
<string name="ac_auto_defrost">Scheibenheizung</string>
377+
<string name="ac_auto_defrost_front">Vorne</string>
378+
<string name="ac_auto_defrost_rear">Hinten</string>
379+
<string name="ac_auto_rule_off">Regel deaktiviert</string>
377380
<string name="ac_auto_def_front">Frontscheibenheizung</string>
378381
<string name="ac_auto_def_rear">Heckscheibenheizung</string>
379382
<string name="ac_auto_note">Wird beim Start des Fahrzeugs angewendet: Klimaanlage und A/C werden eingeschaltet, dann werden die obigen Einstellungen gesendet.</string>
@@ -444,8 +447,6 @@
444447
<string name="common_off">OFF</string>
445448

446449
<!-- Automatisation clim : mode auto + recyclage -->
447-
<string name="ac_auto_auto_mode">Automatikmodus</string>
448-
<string name="ac_auto_recirc_force">Luftumwälzung erzwingen</string>
449450
<string name="recirc_inner">Innen</string>
450451
<string name="recirc_outside">Außen</string>
451452
<string name="recirc_auto">Auto</string>

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,18 @@
365365
<!-- A/C automation -->
366366
<string name="ac_auto_title">Trigger A/C based on temperature</string>
367367
<string name="ac_auto_desc">Set the climate control according to the outside temperature</string>
368-
<string name="ac_auto_hot">Temperature above</string>
369-
<string name="ac_auto_cold">Temperature below</string>
370-
<string name="ac_auto_threshold_hot_label">Trigger threshold (°C)</string>
371-
<string name="ac_auto_threshold_cold_label">Trigger threshold (°C)</string>
372-
<string name="ac_auto_threshold_hint">-20–60</string>
373-
<string name="ac_auto_target_label">Target temperature (°C)</string>
374-
<string name="ac_auto_target_hint">15–33</string>
368+
<string name="ac_auto_hot">When it is hot</string>
369+
<string name="ac_auto_cold">When it is cold</string>
370+
<string name="ac_auto_threshold_hot_label">Outside, from</string>
371+
<string name="ac_auto_threshold_cold_label">Outside, up to</string>
372+
<string name="ac_auto_target_label">Climate set to</string>
375373
<string name="ac_auto_fan_label">Fan speed</string>
376-
<string name="ac_auto_fan_hint">1–10</string>
374+
<string name="ac_auto_fan_manual">Manual</string>
375+
<string name="ac_auto_fan_level">Level</string>
376+
<string name="ac_auto_defrost">Defrost</string>
377+
<string name="ac_auto_defrost_front">Front</string>
378+
<string name="ac_auto_defrost_rear">Rear</string>
379+
<string name="ac_auto_rule_off">Rule disabled</string>
377380
<string name="ac_auto_def_front">Front defrost</string>
378381
<string name="ac_auto_def_rear">Rear defrost</string>
379382
<string name="ac_auto_note">Applied when the vehicle starts: climate control and A/C are turned on, then the settings above are sent.</string>
@@ -444,8 +447,6 @@
444447
<string name="common_off">OFF</string>
445448

446449
<!-- Automatisation clim : mode auto + recyclage -->
447-
<string name="ac_auto_auto_mode">Automatic mode</string>
448-
<string name="ac_auto_recirc_force">Force air recirculation</string>
449450
<string name="recirc_inner">Inner</string>
450451
<string name="recirc_outside">Outside</string>
451452
<string name="recirc_auto">Auto</string>

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,18 @@
365365
<!-- Automatización del A/A -->
366366
<string name="ac_auto_title">Activación del A/A según la temperatura</string>
367367
<string name="ac_auto_desc">Ajustar la climatización según la temperatura exterior</string>
368-
<string name="ac_auto_hot">Temperatura superior</string>
369-
<string name="ac_auto_cold">Temperatura inferior</string>
370-
<string name="ac_auto_threshold_hot_label">Umbral de activación (°C)</string>
371-
<string name="ac_auto_threshold_cold_label">Umbral de activación (°C)</string>
372-
<string name="ac_auto_threshold_hint">-20–60</string>
373-
<string name="ac_auto_target_label">Temperatura objetivo (°C)</string>
374-
<string name="ac_auto_target_hint">15–33</string>
368+
<string name="ac_auto_hot">Cuando hace calor</string>
369+
<string name="ac_auto_cold">Cuando hace frío</string>
370+
<string name="ac_auto_threshold_hot_label">Fuera, desde</string>
371+
<string name="ac_auto_threshold_cold_label">Fuera, hasta</string>
372+
<string name="ac_auto_target_label">Clima ajustado a</string>
375373
<string name="ac_auto_fan_label">Ventilación</string>
376-
<string name="ac_auto_fan_hint">1–10</string>
374+
<string name="ac_auto_fan_manual">Manual</string>
375+
<string name="ac_auto_fan_level">Nivel</string>
376+
<string name="ac_auto_defrost">Desempañador</string>
377+
<string name="ac_auto_defrost_front">Delantero</string>
378+
<string name="ac_auto_defrost_rear">Trasero</string>
379+
<string name="ac_auto_rule_off">Regla desactivada</string>
377380
<string name="ac_auto_def_front">Desempañador delantero</string>
378381
<string name="ac_auto_def_rear">Desempañador trasero</string>
379382
<string name="ac_auto_note">Se aplica al arrancar el vehículo: se encienden la climatización y el A/A, y luego se envían los ajustes anteriores.</string>
@@ -444,8 +447,6 @@
444447
<string name="common_off">OFF</string>
445448

446449
<!-- Automatisation clim : mode auto + recyclage -->
447-
<string name="ac_auto_auto_mode">Modo automático</string>
448-
<string name="ac_auto_recirc_force">Forzar la recirculación de aire</string>
449450
<string name="recirc_inner">Interior</string>
450451
<string name="recirc_outside">Exterior</string>
451452
<string name="recirc_auto">Auto</string>

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,18 @@
365365
<!-- Automazione A/C -->
366366
<string name="ac_auto_title">Attivazione A/C in base alla temperatura</string>
367367
<string name="ac_auto_desc">Regolare il climatizzatore in base alla temperatura esterna</string>
368-
<string name="ac_auto_hot">Temperatura superiore</string>
369-
<string name="ac_auto_cold">Temperatura inferiore</string>
370-
<string name="ac_auto_threshold_hot_label">Soglia di attivazione (°C)</string>
371-
<string name="ac_auto_threshold_cold_label">Soglia di attivazione (°C)</string>
372-
<string name="ac_auto_threshold_hint">-20–60</string>
373-
<string name="ac_auto_target_label">Temperatura desiderata (°C)</string>
374-
<string name="ac_auto_target_hint">15–33</string>
368+
<string name="ac_auto_hot">Quando fa caldo</string>
369+
<string name="ac_auto_cold">Quando fa freddo</string>
370+
<string name="ac_auto_threshold_hot_label">Fuori, da</string>
371+
<string name="ac_auto_threshold_cold_label">Fuori, fino a</string>
372+
<string name="ac_auto_target_label">Clima impostato su</string>
375373
<string name="ac_auto_fan_label">Ventilazione</string>
376-
<string name="ac_auto_fan_hint">1–10</string>
374+
<string name="ac_auto_fan_manual">Manuale</string>
375+
<string name="ac_auto_fan_level">Livello</string>
376+
<string name="ac_auto_defrost">Sbrinamento</string>
377+
<string name="ac_auto_defrost_front">Anteriore</string>
378+
<string name="ac_auto_defrost_rear">Posteriore</string>
379+
<string name="ac_auto_rule_off">Regola disattivata</string>
377380
<string name="ac_auto_def_front">Sbrinamento anteriore</string>
378381
<string name="ac_auto_def_rear">Sbrinamento posteriore</string>
379382
<string name="ac_auto_note">Applicato all\'avvio del veicolo: il climatizzatore e l\'A/C vengono accesi, poi vengono inviate le impostazioni sopra.</string>
@@ -444,8 +447,6 @@
444447
<string name="common_off">OFF</string>
445448

446449
<!-- Automatisation clim : mode auto + recyclage -->
447-
<string name="ac_auto_auto_mode">Modalità automatica</string>
448-
<string name="ac_auto_recirc_force">Forza il ricircolo d\'aria</string>
449450
<string name="recirc_inner">Interno</string>
450451
<string name="recirc_outside">Esterno</string>
451452
<string name="recirc_auto">Auto</string>

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,18 @@
365365
<!-- Automação do A/C -->
366366
<string name="ac_auto_title">Ativação do A/C consoante a temperatura</string>
367367
<string name="ac_auto_desc">Regular a climatização consoante a temperatura exterior</string>
368-
<string name="ac_auto_hot">Temperatura superior</string>
369-
<string name="ac_auto_cold">Temperatura inferior</string>
370-
<string name="ac_auto_threshold_hot_label">Limiar de ativação (°C)</string>
371-
<string name="ac_auto_threshold_cold_label">Limiar de ativação (°C)</string>
372-
<string name="ac_auto_threshold_hint">-20–60</string>
373-
<string name="ac_auto_target_label">Temperatura pretendida (°C)</string>
374-
<string name="ac_auto_target_hint">15–33</string>
368+
<string name="ac_auto_hot">Quando está calor</string>
369+
<string name="ac_auto_cold">Quando está frio</string>
370+
<string name="ac_auto_threshold_hot_label">Lá fora, desde</string>
371+
<string name="ac_auto_threshold_cold_label">Lá fora, até</string>
372+
<string name="ac_auto_target_label">Clima regulado para</string>
375373
<string name="ac_auto_fan_label">Ventilação</string>
376-
<string name="ac_auto_fan_hint">1–10</string>
374+
<string name="ac_auto_fan_manual">Manual</string>
375+
<string name="ac_auto_fan_level">Nível</string>
376+
<string name="ac_auto_defrost">Desembaciamento</string>
377+
<string name="ac_auto_defrost_front">Dianteiro</string>
378+
<string name="ac_auto_defrost_rear">Traseiro</string>
379+
<string name="ac_auto_rule_off">Regra desativada</string>
377380
<string name="ac_auto_def_front">Desembaciamento dianteiro</string>
378381
<string name="ac_auto_def_rear">Desembaciamento traseiro</string>
379382
<string name="ac_auto_note">Aplicado ao arrancar o veículo: a climatização e o A/C são ligados e depois as definições acima são enviadas.</string>
@@ -444,8 +447,6 @@
444447
<string name="common_off">OFF</string>
445448

446449
<!-- Automatisation clim : mode auto + recyclage -->
447-
<string name="ac_auto_auto_mode">Modo automático</string>
448-
<string name="ac_auto_recirc_force">Forçar a recirculação de ar</string>
449450
<string name="recirc_inner">Interior</string>
450451
<string name="recirc_outside">Exterior</string>
451452
<string name="recirc_auto">Auto</string>

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,18 @@
365365
<!-- A/C automation -->
366366
<string name="ac_auto_title">Sıcaklığa göre klimayı tetikle</string>
367367
<string name="ac_auto_desc">Klimayı dış sıcaklığa göre ayarlar</string>
368-
<string name="ac_auto_hot">Sıcaklık şunun üstünde</string>
369-
<string name="ac_auto_cold">Sıcaklık şunun altında</string>
370-
<string name="ac_auto_threshold_hot_label">Tetikleme eşiği (°C)</string>
371-
<string name="ac_auto_threshold_cold_label">Tetikleme eşiği (°C)</string>
372-
<string name="ac_auto_threshold_hint">-20–60</string>
373-
<string name="ac_auto_target_label">Hedef sıcaklık (°C)</string>
374-
<string name="ac_auto_target_hint">15–33</string>
368+
<string name="ac_auto_hot">Hava sıcakken</string>
369+
<string name="ac_auto_cold">Hava soğukken</string>
370+
<string name="ac_auto_threshold_hot_label">Dışarısı, en az</string>
371+
<string name="ac_auto_threshold_cold_label">Dışarısı, en çok</string>
372+
<string name="ac_auto_target_label">Klima ayarı</string>
375373
<string name="ac_auto_fan_label">Fan hızı</string>
376-
<string name="ac_auto_fan_hint">1–10</string>
374+
<string name="ac_auto_fan_manual">Manuel</string>
375+
<string name="ac_auto_fan_level">Seviye</string>
376+
<string name="ac_auto_defrost">Buz çözme</string>
377+
<string name="ac_auto_defrost_front">Ön cam</string>
378+
<string name="ac_auto_defrost_rear">Arka cam</string>
379+
<string name="ac_auto_rule_off">Kural kapalı</string>
377380
<string name="ac_auto_def_front">Ön cam buz çözme</string>
378381
<string name="ac_auto_def_rear">Arka cam buz çözme</string>
379382
<string name="ac_auto_note">Araç çalıştığında uygulanır: klima ve A/C açılır, ardından yukarıdaki ayarlar gönderilir.</string>
@@ -444,8 +447,6 @@
444447
<string name="common_off">KAPALI</string>
445448

446449
<!-- Automatisation clim : mode auto + recyclage -->
447-
<string name="ac_auto_auto_mode">Otomatik mod</string>
448-
<string name="ac_auto_recirc_force">İç hava sirkülasyonunu zorla</string>
449450
<string name="recirc_inner">İç hava</string>
450451
<string name="recirc_outside">Dış hava</string>
451452
<string name="recirc_auto">Oto</string>

0 commit comments

Comments
 (0)