Compare commits
7 Commits
v0.0.3
...
b15cbb6349
| Author | SHA1 | Date | |
|---|---|---|---|
| b15cbb6349 | |||
| 843e369bab | |||
| eec7a3db48 | |||
| c23201e18c | |||
| 4bc6eb9d41 | |||
| 2a59e74a2c | |||
| df743cca96 |
@@ -12,7 +12,7 @@
|
||||
### Features
|
||||
|
||||
- Notification relay
|
||||
- Notificstion transliteration
|
||||
- Notification transliteration
|
||||
- Music control
|
||||
- Get info from watch (HRM, Battery level, Firmware version)
|
||||
- Set current time
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"path/filepath"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
@@ -18,11 +19,12 @@ import (
|
||||
|
||||
func upgradeTab(parent fyne.Window) *fyne.Container {
|
||||
var (
|
||||
archivePath string
|
||||
fiwmarePath string
|
||||
initPktPath string
|
||||
archivePath string
|
||||
firmwarePath string
|
||||
initPktPath string
|
||||
)
|
||||
|
||||
var archiveBtn *widget.Button
|
||||
// Create archive selection dialog
|
||||
archiveDialog := dialog.NewFileOpen(func(uc fyne.URIReadCloser, e error) {
|
||||
if e != nil || uc == nil {
|
||||
@@ -30,25 +32,29 @@ func upgradeTab(parent fyne.Window) *fyne.Container {
|
||||
}
|
||||
uc.Close()
|
||||
archivePath = uc.URI().Path()
|
||||
archiveBtn.SetText(fmt.Sprintf("Select archive (.zip) [%s]", filepath.Base(archivePath)))
|
||||
}, parent)
|
||||
// Limit dialog to .zip files
|
||||
archiveDialog.SetFilter(storage.NewExtensionFileFilter([]string{".zip"}))
|
||||
// Create button to show dialog
|
||||
archiveBtn := widget.NewButton("Select archive (.zip)", archiveDialog.Show)
|
||||
archiveBtn = widget.NewButton("Select archive (.zip)", archiveDialog.Show)
|
||||
|
||||
var firmwareBtn *widget.Button
|
||||
// Create firmware selection dialog
|
||||
firmwareDialog := dialog.NewFileOpen(func(uc fyne.URIReadCloser, e error) {
|
||||
if e != nil || uc == nil {
|
||||
return
|
||||
}
|
||||
uc.Close()
|
||||
fiwmarePath = uc.URI().Path()
|
||||
firmwarePath = uc.URI().Path()
|
||||
firmwareBtn.SetText(fmt.Sprintf("Select firmware (.bin) [%s]", filepath.Base(firmwarePath)))
|
||||
}, parent)
|
||||
// Limit dialog to .bin files
|
||||
firmwareDialog.SetFilter(storage.NewExtensionFileFilter([]string{".bin"}))
|
||||
// Create button to show dialog
|
||||
firmwareBtn := widget.NewButton("Select init packet (.bin)", firmwareDialog.Show)
|
||||
firmwareBtn = widget.NewButton("Select firmware (.bin)", firmwareDialog.Show)
|
||||
|
||||
var initPktBtn *widget.Button
|
||||
// Create init packet selection dialog
|
||||
initPktDialog := dialog.NewFileOpen(func(uc fyne.URIReadCloser, e error) {
|
||||
if e != nil || uc == nil {
|
||||
@@ -56,11 +62,12 @@ func upgradeTab(parent fyne.Window) *fyne.Container {
|
||||
}
|
||||
uc.Close()
|
||||
initPktPath = uc.URI().Path()
|
||||
initPktBtn.SetText(fmt.Sprintf("Select init packet (.dat) [%s]", filepath.Base(initPktPath)))
|
||||
}, parent)
|
||||
// Limit dialog to .dat files
|
||||
initPktDialog.SetFilter(storage.NewExtensionFileFilter([]string{".dat"}))
|
||||
// Create button to show dialog
|
||||
initPktBtn := widget.NewButton("Select init packet (.dat)", initPktDialog.Show)
|
||||
initPktBtn = widget.NewButton("Select init packet (.dat)", initPktDialog.Show)
|
||||
|
||||
// Hide init packet and firmware buttons
|
||||
initPktBtn.Hide()
|
||||
@@ -91,7 +98,7 @@ func upgradeTab(parent fyne.Window) *fyne.Container {
|
||||
startBtn := widget.NewButton("Start", func() {
|
||||
// If archive path does not exist and both init packet and firmware paths
|
||||
// also do not exist, return error
|
||||
if archivePath == "" && (initPktPath == "" && fiwmarePath == "") {
|
||||
if archivePath == "" && (initPktPath == "" && firmwarePath == "") {
|
||||
guiErr(nil, "Upgrade requires archive or files selected", false, parent)
|
||||
return
|
||||
}
|
||||
@@ -119,7 +126,7 @@ func upgradeTab(parent fyne.Window) *fyne.Container {
|
||||
files = append(files, archivePath)
|
||||
case "Files":
|
||||
fwUpgType = types.UpgradeTypeFiles
|
||||
files = append(files, initPktPath, fiwmarePath)
|
||||
files = append(files, initPktPath, firmwarePath)
|
||||
}
|
||||
|
||||
// Dial itd UNIX socket
|
||||
|
||||
2
go.mod
2
go.mod
@@ -21,7 +21,7 @@ require (
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/spf13/cobra v1.2.1
|
||||
github.com/spf13/viper v1.8.1
|
||||
go.arsenm.dev/infinitime v0.0.0-20210825051734-745b4bd37cf4
|
||||
go.arsenm.dev/infinitime v0.0.0-20211007000821-a1e08ed862f1
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
|
||||
golang.org/x/text v0.3.7
|
||||
)
|
||||
|
||||
4
go.sum
4
go.sum
@@ -315,8 +315,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.arsenm.dev/infinitime v0.0.0-20210825051734-745b4bd37cf4 h1:XZyynxrvGxP0mwyhdiuMrvj5SkiK6N+MDiC6DiGzgWU=
|
||||
go.arsenm.dev/infinitime v0.0.0-20210825051734-745b4bd37cf4/go.mod h1:gaepaueUz4J5FfxuV19B4w5pi+V3mD0LTef50ryxr/Q=
|
||||
go.arsenm.dev/infinitime v0.0.0-20211007000821-a1e08ed862f1 h1:URdmeEE9G0vycCt7oLDHH9IV3Nz5L5guPwcBWb5ztrU=
|
||||
go.arsenm.dev/infinitime v0.0.0-20211007000821-a1e08ed862f1/go.mod h1:gaepaueUz4J5FfxuV19B4w5pi+V3mD0LTef50ryxr/Q=
|
||||
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
|
||||
|
||||
@@ -36,7 +36,7 @@ import (
|
||||
)
|
||||
|
||||
func startSocket(dev *infinitime.Device) error {
|
||||
// Make socket directory if non-existent
|
||||
// Make socket directory if non-existant
|
||||
err := os.MkdirAll(filepath.Dir(viper.GetString("socket.path")), 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -4,7 +4,9 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ArmenianTranslit struct{}
|
||||
type ArmenianTranslit struct {
|
||||
initComplete bool
|
||||
}
|
||||
|
||||
var armenianMap = []string{
|
||||
"աու", "au",
|
||||
@@ -120,16 +122,26 @@ var armenianMap = []string{
|
||||
"ւ", "",
|
||||
}
|
||||
|
||||
func init() {
|
||||
lower := armenianMap
|
||||
for i, val := range lower {
|
||||
if i%2 == 1 {
|
||||
continue
|
||||
}
|
||||
capital := strings.Title(val)
|
||||
if capital != val {
|
||||
armenianMap = append(armenianMap, capital, strings.Title(armenianMap[i+1]))
|
||||
func (at *ArmenianTranslit) Init() {
|
||||
if !at.initComplete {
|
||||
// Copy map as original will be changed
|
||||
lower := armenianMap
|
||||
// For every value in copied map
|
||||
for i, val := range lower {
|
||||
// If index is odd, skip
|
||||
if i%2 == 1 {
|
||||
continue
|
||||
}
|
||||
// Capitalize first letter
|
||||
capital := strings.Title(val)
|
||||
// If capital is not the same as lowercase
|
||||
if capital != val {
|
||||
// Add capital to map
|
||||
armenianMap = append(armenianMap, capital, strings.Title(armenianMap[i+1]))
|
||||
}
|
||||
}
|
||||
// Set init complete to true so it is not run again
|
||||
at.initComplete = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
// conversion library.
|
||||
type ChineseTranslit struct{}
|
||||
|
||||
func (ChineseTranslit) Init() {}
|
||||
|
||||
func (ct *ChineseTranslit) Transliterate(s string) string {
|
||||
// Create buffer for final output
|
||||
outBuf := &bytes.Buffer{}
|
||||
@@ -37,6 +39,15 @@ func (ct *ChineseTranslit) Transliterate(s string) string {
|
||||
outBuf.WriteRune(char)
|
||||
}
|
||||
}
|
||||
// If buffer contains characters
|
||||
if tmpBuf.Len() > 0 {
|
||||
// Convert to pinyin (without tones)
|
||||
out := pinyin.LazyConvert(tmpBuf.String(), nil)
|
||||
// Write space-separated string to output
|
||||
outBuf.WriteString(strings.Join(out, " "))
|
||||
// Reset temporary buffer
|
||||
tmpBuf.Reset()
|
||||
}
|
||||
// Return output string
|
||||
return outBuf.String()
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ var compatJamoBlock = &unicode.RangeTable{
|
||||
// This was translated to Go from the code in https://codeberg.org/Freeyourgadget/Gadgetbridge
|
||||
type KoreanTranslit struct{}
|
||||
|
||||
func (KoreanTranslit) Init() {}
|
||||
|
||||
// User input consisting of isolated jamo is usually mapped to the KS X 1001 compatibility
|
||||
// block, but jamo resulting from decomposed syllables are mapped to the modern one. This
|
||||
// function maps compat jamo to modern ones where possible and returns all other characters
|
||||
|
||||
@@ -9,9 +9,9 @@ func Transliterate(s string, useMaps ...string) string {
|
||||
// Create variable to store modified string
|
||||
out := s
|
||||
// If custom map exists
|
||||
if customMap, ok := Transliterators["custom"]; ok {
|
||||
if custom, ok := Transliterators["custom"]; ok {
|
||||
// Perform transliteration with it
|
||||
out = customMap.Transliterate(out)
|
||||
out = custom.Transliterate(out)
|
||||
}
|
||||
// For every map to use
|
||||
for _, useMap := range useMaps {
|
||||
@@ -20,12 +20,13 @@ func Transliterate(s string, useMaps ...string) string {
|
||||
continue
|
||||
}
|
||||
// Get requested map
|
||||
translitMap, ok := Transliterators[useMap]
|
||||
transliterator, ok := Transliterators[useMap]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
transliterator.Init()
|
||||
// Perform transliteration
|
||||
out = translitMap.Transliterate(out)
|
||||
out = transliterator.Transliterate(out)
|
||||
}
|
||||
// Return result
|
||||
return out
|
||||
@@ -36,10 +37,11 @@ func Transliterate(s string, useMaps ...string) string {
|
||||
// and returns the resulting string.
|
||||
type Transliterator interface {
|
||||
Transliterate(string) string
|
||||
Init()
|
||||
}
|
||||
|
||||
// Map implements Transliterator using a slice where
|
||||
// every odd element is a key and every even one is a value
|
||||
// every even element is a key and every odd one is a value
|
||||
// which replaces the key.
|
||||
type Map []string
|
||||
|
||||
@@ -47,6 +49,8 @@ func (mt Map) Transliterate(s string) string {
|
||||
return strings.NewReplacer(mt...).Replace(s)
|
||||
}
|
||||
|
||||
func (Map) Init() {}
|
||||
|
||||
// Transliterators stores transliterator implementations for each supported language.
|
||||
// Some of these were sourced from https://codeberg.org/Freeyourgadget/Gadgetbridge
|
||||
var Transliterators = map[string]Transliterator{
|
||||
@@ -151,7 +155,7 @@ var Transliterators = map[string]Transliterator{
|
||||
"Ζ", "Z",
|
||||
"Η", "I",
|
||||
"Ή", "I",
|
||||
"Θ", "TH",
|
||||
"Θ", "Th",
|
||||
"Ι", "I",
|
||||
"Ί", "I",
|
||||
"Ϊ", "I",
|
||||
@@ -159,7 +163,7 @@ var Transliterators = map[string]Transliterator{
|
||||
"Λ", "L",
|
||||
"Μ", "M",
|
||||
"Ν", "N",
|
||||
"Ξ", "KS",
|
||||
"Ξ", "Ks",
|
||||
"Ο", "O",
|
||||
"Ό", "O",
|
||||
"Π", "P",
|
||||
@@ -170,8 +174,8 @@ var Transliterators = map[string]Transliterator{
|
||||
"Ύ", "Y",
|
||||
"Ϋ", "Y",
|
||||
"Φ", "F",
|
||||
"Χ", "CH",
|
||||
"Ψ", "PS",
|
||||
"Χ", "Ch",
|
||||
"Ψ", "Ps",
|
||||
"Ω", "O",
|
||||
"Ώ", "O",
|
||||
},
|
||||
@@ -184,8 +188,8 @@ var Transliterators = map[string]Transliterator{
|
||||
"є", "je",
|
||||
"і", "i",
|
||||
"ї", "ji",
|
||||
"Ґ", "GH",
|
||||
"Є", "JE",
|
||||
"Ґ", "Gh",
|
||||
"Є", "Je",
|
||||
"І", "I",
|
||||
"Ї", "JI",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user