mirror of
https://github.com/taigrr/crocgui
synced 2025-01-18 04:03:16 -08:00
working prototype
This commit is contained in:
parent
09f5686780
commit
5c15a5be22
25
AndroidManifest.xml
Normal file
25
AndroidManifest.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="com.github.howeyc.crocgui"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0.0">
|
||||||
|
|
||||||
|
<application android:label="Croc"
|
||||||
|
tools:targetApi="30"
|
||||||
|
>
|
||||||
|
<activity android:name="org.golang.app.GoNativeActivity"
|
||||||
|
android:label="Croc"
|
||||||
|
android:configChanges="orientation|keyboardHidden">
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="croc" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
</manifest>
|
13
LICENSE
Normal file
13
LICENSE
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Copyright (c) 2021 Chris Howey <chris@howey.me>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
13
Makefile
Normal file
13
Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.PHONY: clean all
|
||||||
|
|
||||||
|
all: crocgui.apk crocgui
|
||||||
|
|
||||||
|
crocgui.apk: main.go platforms_android.go AndroidManifest.xml
|
||||||
|
fyne package -os android -appID com.github.howeyc.crocgui -icon logo.png
|
||||||
|
|
||||||
|
crocgui: main.go platforms-all.go
|
||||||
|
go build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
go clean
|
||||||
|
rm crocgui.apk
|
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Croc GUI
|
||||||
|
|
||||||
|
A nice simple GUI for [croc](https://github.com/schollz/croc), designed for
|
||||||
|
mobile use.
|
1
go.mod
1
go.mod
@ -8,4 +8,3 @@ require (
|
|||||||
github.com/schollz/croc/v8 v8.6.7
|
github.com/schollz/croc/v8 v8.6.7
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/fyne-io/mobile v0.1.2 => ../mobile
|
|
||||||
|
1
go.sum
1
go.sum
@ -95,6 +95,7 @@ golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMx
|
|||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
|
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
|
||||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6 h1:Tus/Y4w3V77xDsGwKUC8a/QrV7jScpU557J77lFffNs=
|
||||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
golang.org/x/mobile v0.0.0-20210208171126-f462b3930c8f h1:aEcjdTsycgPqO/caTgnxfR9xwWOltP/21vtJyFztEy0=
|
golang.org/x/mobile v0.0.0-20210208171126-f462b3930c8f h1:aEcjdTsycgPqO/caTgnxfR9xwWOltP/21vtJyFztEy0=
|
||||||
golang.org/x/mobile v0.0.0-20210208171126-f462b3930c8f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
|
golang.org/x/mobile v0.0.0-20210208171126-f462b3930c8f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
|
||||||
|
56
main.go
56
main.go
@ -19,6 +19,11 @@ import (
|
|||||||
|
|
||||||
func sendTabItem(w fyne.Window) *container.TabItem {
|
func sendTabItem(w fyne.Window) *container.TabItem {
|
||||||
status := widget.NewLabel("")
|
status := widget.NewLabel("")
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
status.SetText(fmt.Sprint(r))
|
||||||
|
}
|
||||||
|
}()
|
||||||
prog := widget.NewProgressBar()
|
prog := widget.NewProgressBar()
|
||||||
prog.Hide()
|
prog.Hide()
|
||||||
topline := widget.NewLabel("Pick a file to send")
|
topline := widget.NewLabel("Pick a file to send")
|
||||||
@ -35,7 +40,7 @@ func sendTabItem(w fyne.Window) *container.TabItem {
|
|||||||
IsSender: true,
|
IsSender: true,
|
||||||
SharedSecret: randomName,
|
SharedSecret: randomName,
|
||||||
Debug: false,
|
Debug: false,
|
||||||
RelayAddress: "10.0.1.1:9009",
|
RelayAddress: "croc.schollz.com:9009",
|
||||||
RelayPorts: []string{"9009", "9010", "9011", "9012", "9013"},
|
RelayPorts: []string{"9009", "9010", "9011", "9012", "9013"},
|
||||||
RelayPassword: "pass123",
|
RelayPassword: "pass123",
|
||||||
Stdout: false,
|
Stdout: false,
|
||||||
@ -47,8 +52,14 @@ func sendTabItem(w fyne.Window) *container.TabItem {
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
} else if f != nil {
|
} else if f != nil {
|
||||||
status.SetText("Receive Code: " + randomName)
|
status.SetText("Receive Code: " + randomName)
|
||||||
fi, _ := os.Stat(f.URI().Path())
|
fpath := fixpath(f.URI().Path())
|
||||||
filename = filepath.Base(fi.Name())
|
|
||||||
|
fi, sterr := os.Stat(fpath)
|
||||||
|
if sterr != nil {
|
||||||
|
status.SetText(fmt.Sprintf("Stat error: %s - %s", fpath, sterr.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
filename = filepath.Base(fpath)
|
||||||
topline.SetText(fmt.Sprintf("Sending file: %s", filename))
|
topline.SetText(fmt.Sprintf("Sending file: %s", filename))
|
||||||
totalsize := fi.Size()
|
totalsize := fi.Size()
|
||||||
prog.Max = float64(totalsize)
|
prog.Max = float64(totalsize)
|
||||||
@ -66,18 +77,20 @@ func sendTabItem(w fyne.Window) *container.TabItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
serr := sender.Send(croc.TransferOptions{
|
go func() {
|
||||||
PathToFiles: []string{f.URI().Path()},
|
serr := sender.Send(croc.TransferOptions{
|
||||||
})
|
PathToFiles: []string{fpath},
|
||||||
donechan <- true
|
})
|
||||||
prog.Hide()
|
donechan <- true
|
||||||
prog.SetValue(0)
|
prog.Hide()
|
||||||
topline.SetText("Pick a file to send")
|
prog.SetValue(0)
|
||||||
if serr != nil {
|
topline.SetText("Pick a file to send")
|
||||||
log.Println("Send failed:", serr)
|
if serr != nil {
|
||||||
} else {
|
log.Println("Send failed:", serr)
|
||||||
status.SetText(fmt.Sprintf("Sent file %s", filename))
|
} else {
|
||||||
}
|
status.SetText(fmt.Sprintf("Sent file %s", filename))
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}, w)
|
}, w)
|
||||||
}),
|
}),
|
||||||
@ -88,6 +101,12 @@ func sendTabItem(w fyne.Window) *container.TabItem {
|
|||||||
|
|
||||||
func recvTabItem() *container.TabItem {
|
func recvTabItem() *container.TabItem {
|
||||||
status := widget.NewLabel("")
|
status := widget.NewLabel("")
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
status.SetText(fmt.Sprint(r))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
prog := widget.NewProgressBar()
|
prog := widget.NewProgressBar()
|
||||||
prog.Hide()
|
prog.Hide()
|
||||||
recvEntry := widget.NewEntry()
|
recvEntry := widget.NewEntry()
|
||||||
@ -101,7 +120,7 @@ func recvTabItem() *container.TabItem {
|
|||||||
IsSender: false,
|
IsSender: false,
|
||||||
SharedSecret: recvEntry.Text,
|
SharedSecret: recvEntry.Text,
|
||||||
Debug: false,
|
Debug: false,
|
||||||
RelayAddress: "10.0.1.1:9009",
|
RelayAddress: "croc.schollz.com:9009",
|
||||||
RelayPassword: "pass123",
|
RelayPassword: "pass123",
|
||||||
Stdout: false,
|
Stdout: false,
|
||||||
NoPrompt: true,
|
NoPrompt: true,
|
||||||
@ -133,6 +152,10 @@ func recvTabItem() *container.TabItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
cderr := os.Chdir(DEFAULT_DOWNLOAD_DIR)
|
||||||
|
if cderr != nil {
|
||||||
|
log.Println("Unable to change to download dir")
|
||||||
|
}
|
||||||
rerr := receiver.Receive()
|
rerr := receiver.Receive()
|
||||||
donechan <- true
|
donechan <- true
|
||||||
prog.Hide()
|
prog.Hide()
|
||||||
@ -155,5 +178,6 @@ func main() {
|
|||||||
w := a.NewWindow("croc")
|
w := a.NewWindow("croc")
|
||||||
|
|
||||||
w.SetContent(container.NewAppTabs(sendTabItem(w), recvTabItem()))
|
w.SetContent(container.NewAppTabs(sendTabItem(w), recvTabItem()))
|
||||||
|
w.Resize(fyne.NewSize(800, 600))
|
||||||
w.ShowAndRun()
|
w.ShowAndRun()
|
||||||
}
|
}
|
||||||
|
9
platforms-all.go
Normal file
9
platforms-all.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// +build !android
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
const DEFAULT_DOWNLOAD_DIR = "."
|
||||||
|
|
||||||
|
func fixpath(fpath string) string {
|
||||||
|
return fpath
|
||||||
|
}
|
18
platforms_android.go
Normal file
18
platforms_android.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const DEFAULT_DOWNLOAD_DIR = "/storage/emulated/0/Download"
|
||||||
|
|
||||||
|
func fixpath(fpath string) string {
|
||||||
|
if strings.Contains(fpath, "%3A") {
|
||||||
|
fpath, _ = url.PathUnescape(fpath)
|
||||||
|
colIdx := strings.Index(fpath, ":")
|
||||||
|
fpath = "/storage/emulated/0/" + fpath[colIdx+1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
return fpath
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user