Skip to content

Commit

Permalink
refactor: use DeviceSpec to resolve the device name in BudsPopup.xaml.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Feb 16, 2024
1 parent dd97725 commit 05bd007
Show file tree
Hide file tree
Showing 24 changed files with 33 additions and 57 deletions.
32 changes: 3 additions & 29 deletions GalaxyBudsClient/Interface/Dialogs/BudsPopup.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,38 +155,12 @@ private void Window_OnPointerPressed(object? sender, PointerPressedEventArgs e)

public void UpdateSettings()
{
/* Load strings */
string modifier = string.Empty;

switch (BluetoothImpl.Instance.ActiveModel)
{
// TODO: put this in DeviceSpec
case Models.Buds:
break;
case Models.BudsPlus:
modifier = "+";
break;
case Models.BudsLive:
modifier = " Live";
break;
case Models.BudsPro:
modifier = " Pro";
break;
case Models.Buds2:
modifier = "2";
break;
case Models.Buds2Pro:
modifier = "2 Pro";
break;
}

string name = Environment.UserName.Split(' ')[0];

string title = SettingsProvider.Instance.Popup.CustomTitle == string.Empty
var name = Environment.UserName.Split(' ')[0];
var title = SettingsProvider.Instance.Popup.CustomTitle == string.Empty
? Loc.Resolve("connpopup_title")
: SettingsProvider.Instance.Popup.CustomTitle;

_header.Content = string.Format(title, name, modifier);
_header.Content = string.Format(title, name, BluetoothImpl.Instance.DeviceSpec.FriendlyName);

/* Header */
var grid = this.FindControl<Grid>("Grid");
Expand Down
14 changes: 7 additions & 7 deletions GalaxyBudsClient/Model/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,19 @@ public enum PopupPlacement
public enum Models
{
NULL = 0,
[ModelMetadata(Name = "Galaxy Buds (2019)", FwPattern = "R170", BuildPrefix = "R170")]
[ModelMetadata(Name = "Galaxy Buds", FwPattern = "R170", BuildPrefix = "R170")]
Buds = 1,
[ModelMetadata(Name = "Galaxy Buds+ (2020)", FwPattern = "SM-R175", BuildPrefix = "R175")]
[ModelMetadata(Name = "Galaxy Buds+", FwPattern = "SM-R175", BuildPrefix = "R175")]
BudsPlus = 2,
[ModelMetadata(Name = "Galaxy Buds Live (2020)", FwPattern = "SM-R180", BuildPrefix = "R180")]
[ModelMetadata(Name = "Galaxy Buds Live", FwPattern = "SM-R180", BuildPrefix = "R180")]
BudsLive = 3,
[ModelMetadata(Name = "Galaxy Buds Pro (2021)", FwPattern = "SM-R190", BuildPrefix = "R190")]
[ModelMetadata(Name = "Galaxy Buds Pro", FwPattern = "SM-R190", BuildPrefix = "R190")]
BudsPro = 4,
[ModelMetadata(Name = "Galaxy Buds2 (2021)", FwPattern = "SM-R177", BuildPrefix = "R177")]
[ModelMetadata(Name = "Galaxy Buds2", FwPattern = "SM-R177", BuildPrefix = "R177")]
Buds2 = 5,
[ModelMetadata(Name = "Galaxy Buds2 Pro (2022)", FwPattern = "SM-R510", BuildPrefix = "R510")]
[ModelMetadata(Name = "Galaxy Buds2 Pro", FwPattern = "SM-R510", BuildPrefix = "R510")]
Buds2Pro = 6,
[ModelMetadata(Name = "Galaxy Buds FE (2023)", FwPattern = "SM-R400N", BuildPrefix = "R400N")]
[ModelMetadata(Name = "Galaxy Buds FE", FwPattern = "SM-R400N", BuildPrefix = "R400N")]
BudsFe = 7
}

Expand Down
2 changes: 2 additions & 0 deletions GalaxyBudsClient/Model/Specifications/IDeviceSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.ObjectModel;

using GalaxyBudsClient.Message;
using GalaxyBudsClient.Model.Attributes;
using GalaxyBudsClient.Model.Constants;
using GalaxyBudsClient.Model.Touchpad;
using Serilog;
Expand Down Expand Up @@ -46,6 +47,7 @@ public enum Feature
public Dictionary<Feature, FeatureRule?> Rules { get; }
public Models Device { get; }
public string DeviceBaseName { get; }
public string FriendlyName => Device.GetModelMetadata()?.Name ?? "null";
public ITouchOption TouchMap { get; }
public Guid ServiceUuid { get; }
public IReadOnlyCollection<ItemType> TrayShortcuts { get; }
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/cn.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">底部左侧</sys:String>
<sys:String x:Key="connpopup_placement_bc">底部中心</sys:String>
<sys:String x:Key="connpopup_placement_br">底部右侧</sys:String>
<sys:String x:Key="connpopup_title">{0} 的 Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0} 的 {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/cz.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Dole vlevo</sys:String>
<sys:String x:Key="connpopup_placement_bc">Dole uprostřed</sys:String>
<sys:String x:Key="connpopup_placement_br">Dole vpravo</sys:String>
<sys:String x:Key="connpopup_title">Galaxy Buds{1} uživatele {0}</sys:String>
<sys:String x:Key="connpopup_title">{1} uživatele {0}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/de.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Unten links</sys:String>
<sys:String x:Key="connpopup_placement_bc">Unten mittig</sys:String>
<sys:String x:Key="connpopup_placement_br">Unten rechts</sys:String>
<sys:String x:Key="connpopup_title">{0}'s Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}'s {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Bottom left</sys:String>
<sys:String x:Key="connpopup_placement_bc">Bottom center</sys:String>
<sys:String x:Key="connpopup_placement_br">Bottom right</sys:String>
<sys:String x:Key="connpopup_title">{0}'s Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}'s {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/es.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<sys:String x:Key="connpopup_placement_bl">Abajo izquierda</sys:String>
<sys:String x:Key="connpopup_placement_bc">Abajo centro</sys:String>
<sys:String x:Key="connpopup_placement_br">Abajo derecha</sys:String>
<sys:String x:Key="connpopup_title">Galaxy Buds{1} de {0}</sys:String>
<sys:String x:Key="connpopup_title">{1} de {0}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/fr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">En bas à gauche</sys:String>
<sys:String x:Key="connpopup_placement_bc">En bas au centre</sys:String>
<sys:String x:Key="connpopup_placement_br">En bas à droite</sys:String>
<sys:String x:Key="connpopup_title">Galaxy Buds{1} de {0}</sys:String>
<sys:String x:Key="connpopup_title">{1} de {0}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/gr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Κάτω αριστερά</sys:String>
<sys:String x:Key="connpopup_placement_bc">Κάτω κεντρικά</sys:String>
<sys:String x:Key="connpopup_placement_br">Κάτω δεξιά</sys:String>
<sys:String x:Key="connpopup_title">Τα Galaxy Buds{1} του χρήστη {0}</sys:String>
<sys:String x:Key="connpopup_title">Τα {1} του χρήστη {0}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/hu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Bal alsó</sys:String>
<sys:String x:Key="connpopup_placement_bc">Középső alsó</sys:String>
<sys:String x:Key="connpopup_placement_br">Jobb alsó</sys:String>
<sys:String x:Key="connpopup_title">{0} Galaxy Buds-ja{1}</sys:String>
<sys:String x:Key="connpopup_title">{0} {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/il.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<sys:String x:Key="connpopup_placement_bl">שמאל למטה</sys:String>
<sys:String x:Key="connpopup_placement_bc">מרכז למטה</sys:String>
<sys:String x:Key="connpopup_placement_br">ימין למטה</sys:String>
<sys:String x:Key="connpopup_title">.{0} של Galaxy Buds{1}ה</sys:String>
<sys:String x:Key="connpopup_title">.{0} של {1}ה</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/in.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<sys:String x:Key="connpopup_placement_bl">Kiri bawah</sys:String>
<sys:String x:Key="connpopup_placement_bc">Tengah bawah</sys:String>
<sys:String x:Key="connpopup_placement_br">Kanan bawah</sys:String>
<sys:String x:Key="connpopup_title">{0}'s Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}'s {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/it.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<sys:String x:Key="connpopup_placement_bl">In basso a sinistra</sys:String>
<sys:String x:Key="connpopup_placement_bc">In basso al centro</sys:String>
<sys:String x:Key="connpopup_placement_br">In basso a destra</sys:String>
<sys:String x:Key="connpopup_title">Galaxy Buds{1} di {0}</sys:String>
<sys:String x:Key="connpopup_title">{1} di {0}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/ja.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<sys:String x:Key="connpopup_placement_bl">左下</sys:String>
<sys:String x:Key="connpopup_placement_bc">中央下</sys:String>
<sys:String x:Key="connpopup_placement_br">右下</sys:String>
<sys:String x:Key="connpopup_title">{0}の Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}の {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/ko.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<sys:String x:Key="connpopup_placement_bl">좌측 하단</sys:String>
<sys:String x:Key="connpopup_placement_bc">하단 중앙</sys:String>
<sys:String x:Key="connpopup_placement_br">우측 하단</sys:String>
<sys:String x:Key="connpopup_title">{0}의 Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}의 {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/nl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Linksonder</sys:String>
<sys:String x:Key="connpopup_placement_bc">Midden onder</sys:String>
<sys:String x:Key="connpopup_placement_br">Rechtsonder</sys:String>
<sys:String x:Key="connpopup_title">{0}'s Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}'s {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/pt.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<sys:String x:Key="connpopup_placement_bl">Inferior esquerdo</sys:String>
<sys:String x:Key="connpopup_placement_bc">Inferior central</sys:String>
<sys:String x:Key="connpopup_placement_br">Inferior direito</sys:String>
<sys:String x:Key="connpopup_title">Galaxy Buds{1} de {0}</sys:String>
<sys:String x:Key="connpopup_title">{1} de {0}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/ro.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Stânga jos</sys:String>
<sys:String x:Key="connpopup_placement_bc">Centru jos</sys:String>
<sys:String x:Key="connpopup_placement_br">Dreapta jos</sys:String>
<sys:String x:Key="connpopup_title">Galaxy Buds{1}-urile lui {0}</sys:String>
<sys:String x:Key="connpopup_title">{1}-urile lui {0}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/ru.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Снизу слева</sys:String>
<sys:String x:Key="connpopup_placement_bc">Снизу по центру</sys:String>
<sys:String x:Key="connpopup_placement_br">Снизу справа</sys:String>
<sys:String x:Key="connpopup_title">{0}'s Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}'s {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/tr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Sol alt</sys:String>
<sys:String x:Key="connpopup_placement_bc">Alt orta</sys:String>
<sys:String x:Key="connpopup_placement_br">Sağ alt</sys:String>
<sys:String x:Key="connpopup_title">{0}'s Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}'s {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/tw.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">左下方</sys:String>
<sys:String x:Key="connpopup_placement_bc">底部中心</sys:String>
<sys:String x:Key="connpopup_placement_br">右下方</sys:String>
<sys:String x:Key="connpopup_title">{0} 的 Galaxy Buds {1}</sys:String>
<sys:String x:Key="connpopup_title">{0} 的 {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/ua.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Знизу ліворуч</sys:String>
<sys:String x:Key="connpopup_placement_bc">Знизу по центру</sys:String>
<sys:String x:Key="connpopup_placement_br">Знизу праворуч</sys:String>
<sys:String x:Key="connpopup_title">{0}'s Galaxy Buds{1}</sys:String>
<sys:String x:Key="connpopup_title">{0}'s {1}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/i18n/vn.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sys:String x:Key="connpopup_placement_bl">Dưới trái</sys:String>
<sys:String x:Key="connpopup_placement_bc">Dưới giữa</sys:String>
<sys:String x:Key="connpopup_placement_br">Dưới phải</sys:String>
<sys:String x:Key="connpopup_title">Galaxy Buds{1} của {0}</sys:String>
<sys:String x:Key="connpopup_title">{1} của {0}</sys:String>
<!--Note: If a pair of Buds+ is connected then a plus sign will be appended to connpopup_title-->

<!--Placement (Buds+)-->
Expand Down

0 comments on commit 05bd007

Please sign in to comment.