gui filebrowser on android

  • 8 Replies
  • 197 Views
*

RobertMeI

  • Novice
  • *
  • 17
gui filebrowser on android
« on: March 20, 2017, 01:10:43 »
have a small program that uses kind :  filebrowser 
built for windows and android
The windows version works as expected.  Easy to use and runs like I want it to.
The android version displays the filebrowser, image and edit objects correctly, but the filebrowser only allows me to 'see'   /,  Home Folder and Desktop  but I cannot find and file structure that I recognise, and the three displayed options don't go anywhere.
The program looks for image files and txt files with the same names, and displays the image and text in a kind : image and kind : edit objects (jpg attached win version and android version)
Any help in understanding android file access and structures ?
« Last Edit: March 21, 2017, 05:58:04 by RobertMeI »

*

ron

  • Administrator
  • Guru
  • *****
  • 3,243
Re: gui filebrowser on android
« Reply #1 on: March 20, 2017, 04:40:45 »
Glad to see someone doing Android work!

Do you have the READ_EXTERNAL_STORAGE permission set?  That might be the issue.  Because the / option should see '/sdcard' for instance.

If setting that permission doesn't cure the problem, please register a bug and I'll look into it.  Thanks!

*

d.k

  • Apprentice
  • **
  • 32
Re: gui filebrowser on android
« Reply #2 on: March 20, 2017, 17:36:03 »
@RobertMeI Do you mind changing the example picture?  :-\

Best regards, d.k ;)

*

RobertMeI

  • Novice
  • *
  • 17
Re: gui filebrowser on android
« Reply #3 on: March 21, 2017, 06:08:18 »
Thanks Ron, that was the problem, but I have run into another issue.  The filebrowser filter is set to *.jpg and when clicked the code loads the image into the image g:obj, then replaces the last 3 chrs (jpg) with txt and tries to load the text file of same name, that carries the explanation of the image.  Works on windows but crashes on android.
     So I wrote another smaller version to filter *.txt and load directly into the text g:obj.  Again it works fine in windows but fails to load anything on android. It lists the *.txt files but on clicking nothing loads.  Doesn't crash either !
     This is the code
: readTextfile   \  s -- s'   s=filename  s'=text read
      f:open
      null? if   \ "f:open failed" . bye then                \ I suspect this is the android path even when file clicked, but don't know why
            "Failed to open file - readTextfile  " log .s
            \ clear text edit object first
            drop ""
      else   
         ""       \ f s --   "" is the accumulating string
         swap    \ s f --
         repeat
            f:getline    \ s f s' --  or s null
            null?       \ s f s' f   or s t
               if break then   \ exit loop
            swap       \ s s' f --
            >r          \ s s' --
            s:+         \ s --
            "\n" s:+   \ s --    add carriage return
            r>         \ s f --
         again
      f:close
      then
   ;
   
   
: file-clicked   \   -- g s   txt files-selected
   readTextfile   \ -- s   s=text read in
   \ insert into myEdit
   gui @ "myEdit" g:child
   swap g:text   
   ;

*

ron

  • Administrator
  • Guru
  • *****
  • 3,243
Re: gui filebrowser on android
« Reply #4 on: March 21, 2017, 06:12:55 »
OK, thanks.  Can you please add this to the bug database so I can look into it in an organized manner?
Thank you!

*

ron

  • Administrator
  • Guru
  • *****
  • 3,243
Re: gui filebrowser on android
« Reply #5 on: March 23, 2017, 15:19:01 »
Hmm.  It works for me.

If you put a log statement in the 'file-clicked' word to see what it's getting, you can see that the proper file name is given.

The reason you get a 'null' sometimes is because f:open won't open a directory.  I successfully opened a regular text file (test.txt) which I'd put in the Download folder on my Android device.

*

RobertMeI

  • Novice
  • *
  • 17
Re: gui filebrowser on android
« Reply #6 on: March 28, 2017, 04:25:18 »
I am using a Galaxy Tab and have my files on an SD card, not on the tablet.  Like this the app is able to navigate via the \storage\8th\rbh in the filebrowser to the images and text files located on the card. It successfully loads the images but not the text files, causing 8th to crash.

After you got yours to work I thought it may be the card causing the problem so I copied the subdir onto the tablet and hey presto it works correctly.

So it looks like the f:open is not working the same for txt files on the tablet, versus on the card.
On my Galaxy I cannot integrate the SD card and tablet memory into one system like I can on my Motor G4 phone.

*

RobertMeI

  • Novice
  • *
  • 17
Re: gui filebrowser on android
« Reply #7 on: March 28, 2017, 04:50:40 »
Tried it on my Moto G4 where the card has been integrated with the phone memory, and it works fine.  So the only place it doesn't work is on the Galaxy and when the files are on the card and not the tablet memory.

*

ron

  • Administrator
  • Guru
  • *****
  • 3,243
Re: gui filebrowser on android
« Reply #8 on: March 28, 2017, 04:57:01 »
OK, that's good information.  Please update the bug report and I'll take a further look.