Skip to content

Commit

Permalink
add beep notification sound
Browse files Browse the repository at this point in the history
* remove reminder dialog from user agent and connect to peer
* rename user agent to custom user agent
* add user agent placeholder when its set
* implement wallet setting beep for new blocks feature
* set beeep notification frequency and timing to 5,1:§
  • Loading branch information
Sirmorrison committed Feb 6, 2021
1 parent c9afc44 commit 903a100
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 72 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/decred/dcrd/dcrutil v1.4.0
github.com/decred/dcrd/dcrutil/v2 v2.0.1
github.com/decred/slog v1.1.0
github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28
github.com/jessevdk/go-flags v1.4.1-0.20200711081900-c17162fe8fd7
github.com/jrick/logrotate v1.0.0
github.com/markbates/pkger v0.17.1
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,13 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28 h1:M2Zt3G2w6Q57GZndOYk42p7RvMeO8izO8yKTfIxGqxA=
github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28/go.mod h1:ElSskYZe3oM8kThaHGJ+kiN2yyUMVXMZ7WxF9QqLDS8=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10=
github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI=
github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand All @@ -201,6 +205,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherwasm v1.1.0/go.mod h1:SkZ8z7CWBz5VXbhJel8TxCmAcsQqzgWGR/8nMhyhZSI=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
Expand Down Expand Up @@ -237,6 +243,7 @@ github.com/markbates/pkger v0.17.1 h1:/MKEtWqtc0mZvu9OinB9UzVN9iYCwLWuyUv4Bw+PCn
github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down Expand Up @@ -275,6 +282,7 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk=
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
Expand Down Expand Up @@ -350,6 +358,7 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ=
Expand Down
44 changes: 1 addition & 43 deletions ui/modal_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ const RemoveStartupPasswordTemplate = "RemoveStartupPassword"
const UnlockWalletTemplate = "UnlockWallet"
const ConnectToSpecificPeerTemplate = "ConnectToSpecificPeer"
const ChangeSpecificPeerTemplate = "ChangeSpecificPeer"
const RemoveSpecificPeerTemplate = "RemoveSpecificPeer"
const UserAgentTemplate = "UserAgent"
const RemoveUserAgentTemplate = "RemoveUserAgent"
const ConfirmSetupMixerTemplate = "ConfirmSetupMixer"
const ConfirmSetupMixerAcctTemplate = "SetupMixerAcctTemplate"
const ConfirmMixerAcctExistTemplate = "MixerAcctExistTemplate"
Expand Down Expand Up @@ -155,26 +153,6 @@ func (m *ModalTemplate) removeWallet(th *decredmaterial.Theme) []func(gtx C) D {
}
}

func (m *ModalTemplate) removeConnectToPeer(th *decredmaterial.Theme) []func(gtx C) D {
return []func(gtx C) D{
func(gtx C) D {
info := th.Body1("This will forget the current specified peer and disconnect from it.")
info.Color = th.Color.Gray
return info.Layout(gtx)
},
}
}

func (m *ModalTemplate) removeUserAgent(th *decredmaterial.Theme) []func(gtx C) D {
return []func(gtx C) D{
func(gtx C) D {
info := th.Body1("This will forget the current user agent.")
info.Color = th.Color.Gray
return info.Layout(gtx)
},
}
}

func (m *ModalTemplate) Password() []func(gtx C) D {
return []func(gtx C) D{
func(gtx C) D {
Expand Down Expand Up @@ -386,7 +364,7 @@ func (m *ModalTemplate) actions(th *decredmaterial.Theme, load *modalLoad) []fun
if load.template == ConfirmRemoveTemplate {
m.confirm.Background, m.confirm.Color = th.Color.Surface, th.Color.Danger
}
if load.template == RescanWalletTemplate || load.template == RemoveSpecificPeerTemplate || load.template == RemoveUserAgentTemplate {
if load.template == RescanWalletTemplate {
m.confirm.Background, m.confirm.Color = th.Color.Surface, th.Color.Primary
}
return m.confirm.Layout(gtx)
Expand Down Expand Up @@ -556,26 +534,6 @@ func (m *ModalTemplate) handle(th *decredmaterial.Theme, load *modalLoad) (templ

template = m.setStartupPassword()
return
case RemoveSpecificPeerTemplate:
if m.confirm.Button.Clicked() {
load.confirm.(func())()
}
if m.cancel.Button.Clicked() {
load.cancel.(func())()
}

template = m.removeConnectToPeer(th)
return
case RemoveUserAgentTemplate:
if m.confirm.Button.Clicked() {
load.confirm.(func())()
}
if m.cancel.Button.Clicked() {
load.cancel.(func())()
}

template = m.removeUserAgent(th)
return
case ConfirmSetupMixerTemplate:
if m.confirm.Button.Clicked() {
load.confirm.(func())()
Expand Down
45 changes: 16 additions & 29 deletions ui/settings_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type settingsPage struct {
connectToPeer *widget.Bool
userAgent *widget.Bool

peerLabel decredmaterial.Label
peerLabel, agentLabel decredmaterial.Label

line *decredmaterial.Line

Expand Down Expand Up @@ -72,6 +72,9 @@ func (win *Window) SettingsPage(common pageCommon) layout.Widget {
pg.peerLabel = common.theme.Body1("")
pg.peerLabel.Color = common.theme.Color.Gray

pg.agentLabel = common.theme.Body1("")
pg.agentLabel.Color = common.theme.Color.Gray

pg.currencyConversion.Color, pg.currencyConversion.Inset = color, zeroInset
pg.updateConnectToPeer.Color, pg.updateConnectToPeer.Inset = color, zeroInset
pg.updateUserAgent.Color, pg.updateUserAgent.Inset = color, zeroInset
Expand Down Expand Up @@ -206,7 +209,7 @@ func (pg *settingsPage) agent() layout.Widget {
return layout.Flex{}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(pg.subSectionLabel("User agent")),
layout.Rigid(pg.subSectionLabel("Custom user agent")),
layout.Rigid(func(gtx C) D {
txt := pg.theme.Body2("For exchange rate fetching")
txt.Color = pg.theme.Color.Gray
Expand All @@ -229,7 +232,14 @@ func (pg *settingsPage) agent() layout.Widget {
if pg.agentValue != "" {
return pg.conditionalDisplay(gtx, func(gtx C) D {
return pg.subSection(gtx, "Change user agent", func(gtx C) D {
return pg.updateUserAgent.Layout(gtx)
return layout.Flex{}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return pg.agentLabel.Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
return pg.updateUserAgent.Layout(gtx)
}),
)
})
})
}
Expand Down Expand Up @@ -371,19 +381,7 @@ func (pg *settingsPage) handle(common pageCommon) {
}()
return
}
go func() {
common.modalReceiver <- &modalLoad{
template: RemoveSpecificPeerTemplate,
title: "Turn off connect to specific peer?",
confirm: func() {
pg.wal.RemoveUserConfigValueForKey(specificPeerKey)
common.closeModal()
},
confirmText: "Turn off",
cancel: common.closeModal,
cancelText: "Cancel",
}
}()
pg.wal.RemoveUserConfigValueForKey(specificPeerKey)
}

for pg.updateConnectToPeer.Button.Clicked() {
Expand Down Expand Up @@ -444,19 +442,7 @@ func (pg *settingsPage) handle(common pageCommon) {
}()
return
}
go func() {
common.modalReceiver <- &modalLoad{
template: RemoveUserAgentTemplate,
title: "Turn off user agent?",
confirm: func() {
pg.wal.RemoveUserConfigValueForKey(userAgentKey)
common.closeModal()
},
confirmText: "Turn off",
cancel: common.closeModal,
cancelText: "Cancel",
}
}()
pg.wal.RemoveUserConfigValueForKey(userAgentKey)
}

select {
Expand Down Expand Up @@ -502,6 +488,7 @@ func (pg *settingsPage) updateSettingOptions() {
pg.agentValue = pg.wal.ReadStringConfigValueForKey(dcrlibwallet.UserAgentConfigKey)
pg.userAgent.Value = false
if pg.agentValue != "" {
pg.agentLabel.Text = pg.agentValue
pg.userAgent.Value = true
}
}
10 changes: 10 additions & 0 deletions ui/sync.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ui

import (
"github.com/gen2brain/beeep"
"github.com/planetdecred/dcrlibwallet"
"github.com/planetdecred/godcr/wallet"
)

Expand Down Expand Up @@ -42,6 +44,14 @@ func (win Window) updateSyncProgress(report interface{}) {
break
}
}

beep := win.wallet.ReadBoolConfigValueForKey(dcrlibwallet.BeepNewBlocksConfigKey)
if beep {
err := beeep.Beep(5, 1)
if err != nil {
log.Error(err.Error())
}
}
case wallet.TxConfirmed:
if t.Hash != "" {
win.wallet.GetAllTransactions(0, 0, 0)
Expand Down
11 changes: 11 additions & 0 deletions ui/wallet_settings_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"gioui.org/layout"
"gioui.org/widget"

"github.com/planetdecred/dcrlibwallet"
"github.com/planetdecred/godcr/ui/decredmaterial"
"github.com/planetdecred/godcr/ui/values"
"github.com/planetdecred/godcr/wallet"
Expand Down Expand Up @@ -56,6 +57,12 @@ func (win *Window) WalletSettingsPage(common pageCommon) layout.Widget {
}

func (pg *walletSettingsPage) Layout(gtx layout.Context, common pageCommon) layout.Dimensions {
beep := pg.wal.ReadBoolConfigValueForKey(dcrlibwallet.BeepNewBlocksConfigKey)
pg.notificationW.Value = false
if beep {
pg.notificationW.Value = true
}

body := func(gtx C) D {
page := SubPage{
title: "Settings",
Expand Down Expand Up @@ -210,6 +217,10 @@ func (pg *walletSettingsPage) handle(common pageCommon) {
break
}

if pg.notificationW.Changed() {
pg.wal.SaveConfigValueForKey(dcrlibwallet.BeepNewBlocksConfigKey, pg.notificationW.Value)
}

for pg.deleteWallet.Button.Clicked() {
go func() {
common.modalReceiver <- &modalLoad{
Expand Down

0 comments on commit 903a100

Please sign in to comment.