fyne icon indicating copy to clipboard operation
fyne copied to clipboard

Android folder in folder doesn't work

Open camerondugan opened this issue 11 months ago • 0 comments

Checklist

  • [X] I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • [X] This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Android builds when I use storage.List() always return top level entries of a directory and nothing else, even when I ask for it to List the entries a sub-folder. Linux builds properly return the contents of folders. Possibly an android permissions issue? Was told to make this issue request from the discord after I couldn't find anyone else with this issue or a solution.

How to reproduce

The code provided is close to what you need if not exactly what you need to reproduce.

  1. Use dialog.NewFolderOpen()
  2. Use the provided search method to deep search
  3. Watch the command never finish on android builds, but it finishes on Linux builds

Screenshots

No response

Example code

func main() {
	a := app.NewWithID("com.example.appname")
	w := a.NewWindow("example")

	notesFolder := binding.NewString() // binding is for values that can change
	notesFolder.Set(a.Preferences().StringWithFallback("NotesFolder", "No Folder Selected"))
	onChoice := func(folderSelected fyne.ListableURI, err error) {
                check(err)
		if folderSelected != nil {
			notesFolder.Set(folderSelected.String())
		} 
	}
	folderDialog := dialog.NewFolderOpen(onChoice, window)
	onButton := func() {
		folderDialog.Show()
	}

	button := widget.NewButton("click me", onButton)
	folderLabel := widget.NewLabelWithData(notesFolder)
	w.SetContent(container.NewVBox(folderLabel, button)
	w.ShowAndRun()
}
// recursive folder search (the star of the show)
func searchFolder(uriFolder fyne.URI) {
	canRead, err := storage.CanRead(uriFolder)
	check(err)
	if !canRead {
		fyne.CurrentApp().SendNotification(fyne.NewNotification("can't read folder", ""))
		return
	}

	isFolder, err := storage.CanList(uriFolder)
	check(err)
	if !isFolder {
		return
	}

	entries, err := storage.List(uriFolder)
	check(err)

	for _, entry := range entries {
		check(err)
                log.Println(entry.String())
		searchFolder(entry)
	}
}
func check(e error) {
	if e != nil {
		panic(e)
	}
}

Fyne version

2.4.4

Go compiler version

1.21.7 linux/amd64

Operating system and version

Nixos

Additional Information

I'm using this nix flake I tweaked to create my build-env. If you don't feel like setting up fyne for android development to test this bug, copy this file and this file to your test folder and make sure you have nix installed, then run to be placed into an identical shell to what I'm running.

nix  --experimental-features 'nix-command flakes' develop

camerondugan avatar Mar 07 '24 00:03 camerondugan