-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
FileDialog SetFilter does not work on Android devices #2353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you please expand on what "does not work" means? |
It would also have been useful with a full code example (like the issue template mentions) to make it easier to reproduce. |
Apologies, Here is the code in question: https://github.com/alexballas/go2tv/blob/main/internal/gui/gui.go#L197-L236 fd := dialog.NewFileOpen(func(reader fyne.URIReadCloser, err error) {
check(w, err)
if reader == nil {
return
}
defer reader.Close()
vfile := reader.URI().Path()
absVideoFile, err := filepath.Abs(vfile)
check(w, err)
videoFileURLencoded := &url.URL{Path: filepath.Base(absVideoFile)}
screen.VideoText.Text = filepath.Base(vfile)
screen.videofile = filestruct{
abs: absVideoFile,
urlEncoded: videoFileURLencoded.String(),
}
if !screen.CustomSubsCheck.Checked {
selectSubs(absVideoFile, screen)
}
// Remember the last file location.
screen.currentvfolder = filepath.Dir(absVideoFile)
screen.VideoText.Refresh()
}, w)
fd.SetFilter(storage.NewExtensionFileFilter(screen.videoFormats))
if screen.currentvfolder != "" {
vfileURI := storage.NewFileURI(screen.currentvfolder)
vfileLister, err := storage.ListerForURI(vfileURI)
check(w, err)
fd.SetLocation(vfileLister)
}
fd.Resize(fyne.NewSize(w.Canvas().Size().Width*1.4, w.Canvas().Size().Height*1.6))
fd.Show() When If I completely remove it and recompile it and click again the same button I correctly get Image here Please let me know if you'd like more info |
Can you please try to put together a "short and concise" example code? We prefer small example codes (not snippets out of big projects) which makes it much easier to replicate. |
Can you please use this standalone example? package main
import (
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/widget"
)
func main() {
myApp := app.New()
myWindow := myApp.NewWindow("Test Android File Dialog")
content := widget.NewButton("Open File Dialog", func() {
go videoAction(myWindow)
})
myWindow.SetContent(content)
myWindow.ShowAndRun()
}
func videoAction(w fyne.Window) {
fd := dialog.NewFileOpen(func(reader fyne.URIReadCloser, err error) {
fmt.Println(reader)
}, w)
fd.SetFilter(storage.NewExtensionFileFilter([]string{".mp4", ".avi", ".mkv", ".mpeg", ".mov", ".webm", ".m4v", ".mpv"}))
fd.Show()
} You can replicate the issue by commenting out the fd.SetFilter line. |
Thanks. That example code is more than good enough in my opinion :) |
From
|
The issue was that more than one unknown file type would generate an invalid mime type list. |
Describe the bug:
When I define a file FileDialog Filter like the following
fd.SetFilter(storage.NewExtensionFileFilter([]string{".mp4", ".avi", ".mkv", ".mpeg", ".mov", ".webm", ".m4v", ".mpv"}))
dialog.NewFileOpen
does not work on an Android device.When I remove the filter line,
dialog.NewFileOpen
will then correctly prompt to select a file managerDevice (please complete the following information):
The text was updated successfully, but these errors were encountered: