gui filebrowser on android

  • 5 Replies
  • 54 Views
*

RobertMeI

  • Novice
  • *
  • 15
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,195
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

  • Novice
  • *
  • 19
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
  • *
  • 15
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,195
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,195
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.