mirror of
https://github.com/taigrr/crocgui
synced 2025-01-18 04:03:16 -08:00
use temp files
This commit is contained in:
parent
5e9d2a114b
commit
f80c572905
@ -3,8 +3,8 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.github.howeyc.crocgui"
|
package="com.github.howeyc.crocgui"
|
||||||
android:versionCode="5"
|
android:versionCode="6"
|
||||||
android:versionName="1.2.0">
|
android:versionName="1.3.0">
|
||||||
|
|
||||||
<application android:label="Croc"
|
<application android:label="Croc"
|
||||||
tools:targetApi="30"
|
tools:targetApi="30"
|
||||||
|
1
metadata/en-US/changelogs/6.txt
Normal file
1
metadata/en-US/changelogs/6.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
- User request of permissions no longer necessary to send files, uses android URI and temp files instead
|
15
send.go
15
send.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -36,6 +37,8 @@ func sendTabItem(a fyne.App, w fyne.Window) *container.TabItem {
|
|||||||
})
|
})
|
||||||
copyCodeButton.Hide()
|
copyCodeButton.Hide()
|
||||||
|
|
||||||
|
sendDir, _ := os.MkdirTemp("", "crocgui")
|
||||||
|
|
||||||
boxholder := container.NewVBox()
|
boxholder := container.NewVBox()
|
||||||
fileentries := make(map[string]*fyne.Container)
|
fileentries := make(map[string]*fyne.Container)
|
||||||
|
|
||||||
@ -46,6 +49,15 @@ func sendTabItem(a fyne.App, w fyne.Window) *container.TabItem {
|
|||||||
}
|
}
|
||||||
if f != nil {
|
if f != nil {
|
||||||
fpath := fixpath(f.URI().Path())
|
fpath := fixpath(f.URI().Path())
|
||||||
|
nfile, oerr := os.Create(filepath.Join(sendDir, filepath.Base(fpath)))
|
||||||
|
if oerr != nil {
|
||||||
|
status.SetText(fmt.Sprintf("Unable to copy file, error: %s - %s", sendDir, oerr.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
io.Copy(nfile, f)
|
||||||
|
nfile.Close()
|
||||||
|
fpath = nfile.Name()
|
||||||
|
|
||||||
_, sterr := os.Stat(fpath)
|
_, sterr := os.Stat(fpath)
|
||||||
if sterr != nil {
|
if sterr != nil {
|
||||||
status.SetText(fmt.Sprintf("Stat error: %s - %s", fpath, sterr.Error()))
|
status.SetText(fmt.Sprintf("Stat error: %s - %s", fpath, sterr.Error()))
|
||||||
@ -55,6 +67,7 @@ func sendTabItem(a fyne.App, w fyne.Window) *container.TabItem {
|
|||||||
newentry := container.NewHBox(labelFile, layout.NewSpacer(), widget.NewButtonWithIcon("", theme.CancelIcon(), func() {
|
newentry := container.NewHBox(labelFile, layout.NewSpacer(), widget.NewButtonWithIcon("", theme.CancelIcon(), func() {
|
||||||
if fe, ok := fileentries[fpath]; ok {
|
if fe, ok := fileentries[fpath]; ok {
|
||||||
boxholder.Remove(fe)
|
boxholder.Remove(fe)
|
||||||
|
os.Remove(fpath)
|
||||||
delete(fileentries, fpath)
|
delete(fileentries, fpath)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@ -130,9 +143,11 @@ func sendTabItem(a fyne.App, w fyne.Window) *container.TabItem {
|
|||||||
for _, fpath := range filepaths {
|
for _, fpath := range filepaths {
|
||||||
if fe, ok := fileentries[fpath]; ok {
|
if fe, ok := fileentries[fpath]; ok {
|
||||||
boxholder.Remove(fe)
|
boxholder.Remove(fe)
|
||||||
|
os.Remove(fpath)
|
||||||
delete(fileentries, fpath)
|
delete(fileentries, fpath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
topline.SetText("Pick a file to send")
|
topline.SetText("Pick a file to send")
|
||||||
addFileButton.Show()
|
addFileButton.Show()
|
||||||
if serr != nil {
|
if serr != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user