Skip to content

Commit

Permalink
Merge pull request #83 from alexballas/devel
Browse files Browse the repository at this point in the history
v1.16.1
  • Loading branch information
alexballas committed May 9, 2024
2 parents bb979f3 + c91e543 commit b53ebd1
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 128 deletions.
6 changes: 2 additions & 4 deletions cmd/go2tv-lite/go2tv.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ func main() {
os.Exit(0)
}

if err != nil {
fmt.Fprintf(os.Stderr, "Encountered error(s): %s\n", err)
os.Exit(1)
}
fmt.Fprintf(os.Stderr, "Encountered error(s): %s\n", err)
os.Exit(1)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/go2tv-lite/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.0
1.16.1
2 changes: 1 addition & 1 deletion cmd/go2tv/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.0
1.16.1
10 changes: 5 additions & 5 deletions internal/gui/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"time"

fyne "fyne.io/fyne/v2"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
Expand Down Expand Up @@ -90,7 +90,7 @@ func checkVersion(s *NewScreen) {
}

client := &http.Client{
Timeout: time.Duration(3 * time.Second),
Timeout: 3 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return errRedirectChecker
},
Expand All @@ -105,12 +105,12 @@ func checkVersion(s *NewScreen) {
defer response.Body.Close()

if errors.Is(err, errRedirectChecker) {
url, err := response.Location()
responceUrl, err := response.Location()
if err != nil {
dialog.ShowError(errVersionGet, s.Current)
return
}
str := strings.Trim(filepath.Base(url.Path), "v")
str := strings.Trim(filepath.Base(responceUrl.Path), "v")
str = strings.ReplaceAll(str, ".", "")
chversion, err := strconv.Atoi(str)
if err != nil {
Expand All @@ -120,7 +120,7 @@ func checkVersion(s *NewScreen) {

switch {
case chversion > currversion:
dialog.ShowInformation("Version checker", "New version: "+strings.Trim(filepath.Base(url.Path), "v"), s.Current)
dialog.ShowInformation("Version checker", "New version: "+strings.Trim(filepath.Base(responceUrl.Path), "v"), s.Current)
return
default:
dialog.ShowInformation("Version checker", "No new version", s.Current)
Expand Down
8 changes: 4 additions & 4 deletions internal/gui/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func muteAction(screen *NewScreen) {
return
}

if screen.MuteUnmute.Icon == theme.VolumeUpIcon() {
if screen.MuteUnmute.Icon == theme.VolumeMuteIcon() {
unmuteAction(screen)
return
}
Expand Down Expand Up @@ -476,9 +476,9 @@ func skipNextAction(screen *NewScreen) {
return
}

name, path := getNextMedia(screen)
name, nextMediaPath := getNextMedia(screen)
screen.MediaText.Text = name
screen.mediafile = path
screen.mediafile = nextMediaPath
screen.MediaText.Refresh()

if !screen.CustomSubsCheck.Checked {
Expand Down Expand Up @@ -614,7 +614,7 @@ func queueNext(screen *NewScreen, clear bool) (*soapcalls.TVPayload, error) {
}

fname, fpath := getNextMedia(screen)
_, spath := getNextPossibleSubs(fname, screen)
_, spath := getNextPossibleSubs(fname)

var mediaType string
var isSeek bool
Expand Down
2 changes: 1 addition & 1 deletion internal/gui/actions_mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func muteAction(screen *NewScreen) {
return
}

if screen.MuteUnmute.Icon == theme.VolumeUpIcon() {
if screen.MuteUnmute.Icon == theme.VolumeMuteIcon() {
unmuteAction(screen)
return
}
Expand Down
19 changes: 8 additions & 11 deletions internal/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"sync"

fyne "fyne.io/fyne/v2"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
Expand Down Expand Up @@ -101,8 +101,8 @@ func Start(ctx context.Context, s *NewScreen) {

s.Hotkeys = true
tabs.OnSelected = func(t *container.TabItem) {
theme := fyne.CurrentApp().Preferences().StringWithFallback("Theme", "Default")
fyne.CurrentApp().Settings().SetTheme(go2tvTheme{theme})
currentTheme := fyne.CurrentApp().Preferences().StringWithFallback("Theme", "Default")
fyne.CurrentApp().Settings().SetTheme(go2tvTheme{currentTheme})

if t.Text == "Go2TV" {
s.Hotkeys = true
Expand Down Expand Up @@ -201,21 +201,18 @@ func (p *NewScreen) Fini() {
func InitFyneNewScreen(v string) *NewScreen {
go2tv := app.NewWithID("com.alexballas.go2tv")
w := go2tv.NewWindow("Go2TV")
currentdir, err := os.Getwd()
currentDir, err := os.Getwd()
if err != nil {
currentdir = ""
currentDir = ""
}

theme := fyne.CurrentApp().Preferences().StringWithFallback("Theme", "Default")
fyne.CurrentApp().Settings().SetTheme(go2tvTheme{theme})

dw := &debugWriter{
ring: ring.New(1000),
}

return &NewScreen{
Current: w,
currentmfolder: currentdir,
currentmfolder: currentDir,
mediaFormats: []string{".mp4", ".avi", ".mkv", ".mpeg", ".mov", ".webm", ".m4v", ".mpv", ".dv", ".mp3", ".flac", ".wav", ".m4a", ".jpg", ".jpeg", ".png"},
version: v,
Debug: dw,
Expand Down Expand Up @@ -304,13 +301,13 @@ func getNextMedia(screen *NewScreen) (string, string) {
}

func autoSelectNextSubs(v string, screen *NewScreen) {
name, path := getNextPossibleSubs(v, screen)
name, path := getNextPossibleSubs(v)
screen.SubsText.Text = name
screen.subsfile = path
screen.SubsText.Refresh()
}

func getNextPossibleSubs(v string, screen *NewScreen) (string, string) {
func getNextPossibleSubs(v string) (string, string) {
var name, path string

possibleSub := v[0:len(v)-
Expand Down
4 changes: 2 additions & 2 deletions internal/gui/gui_mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"sync"

fyne "fyne.io/fyne/v2"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
Expand Down Expand Up @@ -123,7 +123,7 @@ func (p *NewScreen) Fini() {
// InitFyneNewScreen .
func InitFyneNewScreen(v string) *NewScreen {
go2tv := app.NewWithID("com.alexballas.go2tv")
go2tv.Settings().SetTheme(theme.DarkTheme())
go2tv.Settings().SetTheme(go2tvTheme{"Dark"})

w := go2tv.NewWindow("Go2TV")

Expand Down
16 changes: 8 additions & 8 deletions internal/gui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,39 +527,39 @@ func refreshDevList(s *NewScreen, data *[]devType) {
}

for range refreshDevices.C {
datanew, _ := getDevices(2)
newDevices, _ := getDevices(2)

outer:
for _, old := range *data {
oldAddress, _ := url.Parse(old.addr)
for _, new := range datanew {
newAddress, _ := url.Parse(new.addr)
for _, device := range newDevices {
newAddress, _ := url.Parse(device.addr)
if newAddress.Host == oldAddress.Host {
continue outer
}
}

if utils.HostPortIsAlive(oldAddress.Host) {
datanew = append(datanew, old)
newDevices = append(newDevices, old)
}

sort.Slice(datanew, func(i, j int) bool {
return (datanew)[i].name < (datanew)[j].name
sort.Slice(newDevices, func(i, j int) bool {
return (newDevices)[i].name < (newDevices)[j].name
})
}

// check to see if the new refresh includes
// one of the already selected devices
var includes bool
u, _ := url.Parse(s.controlURL)
for _, d := range datanew {
for _, d := range newDevices {
n, _ := url.Parse(d.addr)
if n.Host == u.Host {
includes = true
}
}

*data = datanew
*data = newDevices

if !includes && !utils.HostPortIsAlive(u.Host) {
s.controlURL = ""
Expand Down
69 changes: 4 additions & 65 deletions internal/gui/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package gui

import (
"image/color"
"sync"
"time"

"fyne.io/fyne/v2"
Expand All @@ -16,65 +14,6 @@ import (
"fyne.io/fyne/v2/widget"
)

type go2tvTheme struct {
Theme string
}

var _ fyne.Theme = go2tvTheme{}
var SystemVariant fyne.ThemeVariant = 999
var once sync.Once

func (m go2tvTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
switch m.Theme {
case "GrabVariant":
once.Do(func() {
SystemVariant = variant
})

case "Dark":
variant = theme.VariantDark
switch name {
case theme.ColorNameDisabled:
return color.NRGBA{R: 0x55, G: 0x55, B: 0x55, A: 0xff}
case theme.ColorNameBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
case theme.ColorNameButton:
return color.NRGBA{R: 0x44, G: 0x44, B: 0x44, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0x26, G: 0x26, B: 0x26, A: 0xff}
case theme.ColorNameOverlayBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
case theme.ColorNameMenuBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
}

case "Light":
variant = theme.VariantLight
switch name {
case theme.ColorNameDisabled:
return color.NRGBA{R: 0xab, G: 0xab, B: 0xab, A: 0xff}
case theme.ColorNameInputBorder:
return color.NRGBA{R: 0xf3, G: 0xf3, B: 0xf3, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0xe5, G: 0xe5, B: 0xe5, A: 0xff}
}
}
theme.InnerPadding()
return theme.DefaultTheme().Color(name, variant)
}

func (m go2tvTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
return theme.DefaultTheme().Icon(name)
}

func (m go2tvTheme) Font(style fyne.TextStyle) fyne.Resource {
return theme.DefaultTheme().Font(style)
}

func (m go2tvTheme) Size(name fyne.ThemeSizeName) float32 {
return theme.DefaultTheme().Size(name)
}

func settingsWindow(s *NewScreen) fyne.CanvasObject {
w := s.Current

Expand All @@ -84,15 +23,15 @@ func settingsWindow(s *NewScreen) fyne.CanvasObject {
switch themeName {
case "Light":
dropdown.PlaceHolder = "Light"
parseTheme("Light")
case "Dark":
dropdown.PlaceHolder = "Dark"
parseTheme("Dark")
case "GrabVariant", "Default":
fyne.CurrentApp().Settings().SetTheme(go2tvTheme{"GrabVariant"})

// Wait for SystemVariant to get the correct variant from the command above
for SystemVariant == 999 {
time.Sleep(time.Millisecond)
}
// Wait for the SystemVariant variable to change
<-signalSystemVariantChange

switch SystemVariant {
case theme.VariantDark:
Expand Down
74 changes: 74 additions & 0 deletions internal/gui/theme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package gui

import (
"image/color"
"sync"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)

type go2tvTheme struct {
Theme string
}

var (
_ fyne.Theme = go2tvTheme{}
SystemVariant fyne.ThemeVariant = 999
signalSystemVariantChange = make(chan struct{})
once sync.Once
)

func (m go2tvTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
switch m.Theme {
case "GrabVariant":
once.Do(func() {
SystemVariant = variant
go func() {
signalSystemVariantChange <- struct{}{}
}()
})

case "Dark":
variant = theme.VariantDark
switch name {
case theme.ColorNameDisabled:
return color.NRGBA{R: 0x55, G: 0x55, B: 0x55, A: 0xff}
case theme.ColorNameBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
case theme.ColorNameButton:
return color.NRGBA{R: 0x44, G: 0x44, B: 0x44, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0x26, G: 0x26, B: 0x26, A: 0xff}
case theme.ColorNameOverlayBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
case theme.ColorNameMenuBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
}

case "Light":
variant = theme.VariantLight
switch name {
case theme.ColorNameDisabled:
return color.NRGBA{R: 0xab, G: 0xab, B: 0xab, A: 0xff}
case theme.ColorNameInputBorder:
return color.NRGBA{R: 0xf3, G: 0xf3, B: 0xf3, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0xe5, G: 0xe5, B: 0xe5, A: 0xff}
}
}
theme.InnerPadding()
return theme.DefaultTheme().Color(name, variant)
}

func (m go2tvTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
return theme.DefaultTheme().Icon(name)
}

func (m go2tvTheme) Font(style fyne.TextStyle) fyne.Resource {
return theme.DefaultTheme().Font(style)
}

func (m go2tvTheme) Size(name fyne.ThemeSizeName) float32 {
return theme.DefaultTheme().Size(name)
}
Loading

0 comments on commit b53ebd1

Please sign in to comment.