Himalayan-Academy / Siva-Siva-App

Code Repository for the Siva Siva Mobile App
11 stars 3 forks source link

External Assets: We can't access specialFolderPath("resources" #316

Open Brahmanathaswami opened 3 years ago

Brahmanathaswami commented 3 years ago

I don't think it has any to do with put getNavigationMap() into tMap

or the model_SivaSiva.json

Now, I may be mixed up!= But here goes to "round to ring"

:-)

  1. I changed: assets TO _assets, just to be SURE it was NOT from specialFolderPath("resources")
2021-09-19_09-43-51
  1. on /module/updater behavior_updater.livecodescript updater.livecode

    case "expanded" hide widget "spinner" send "continue_AppInitialization" to card "InitializeApp" of stack "Siva-Siva-App" in 50 millisecs close this stack break

  2. command continue_AppInitialization portal_SetLastStack "Siva-Siva-App"

    logging the documents folder

  3. we DON'T get a breakpoint on Desktop for command copyAssetsFrom pFolder breakpoint put folders(specialFolderPath("resources") & "/assets/" & pFolder) into tFolders filter lines of tFolders without ".." filter lines of tFolders without "." put files(specialFolderPath("resources") & "/assets/" & pFolder) into tFiles repeat for each line tFile in tFiles log "copying" && ("/assets/" & pFolder & "/" & tFile) createFolders (specialfolderPath("documents") & "/assets/" & pFolder & "/" & tFile) put url ("binfile:" & specialFolderPath("resources") & "/assets/" & pFolder & "/" & tFile) into url ("binfile:" & specialfolderPath("documents") & "/assets/" & pFolder & "/" & tFile) if the result is not empty then log "error:" && the result end if end repeat

we DO for Mobile !

command copyAssetsFrom pFolder breakpoint put folders(specialFolderPath("resources") & "/assets/" & pFolder) into tFolders filter lines of tFolders without "

  1. is has to be lib_DownloadingManager.livacodescript

and where say

put the documents folder & "/assets.txt" into tZipManifest

where as it should say

put specialfolderPath("documents") & "/assets.txt" into tZipManifest

command verifyAndExpandAssets cancel sCheckStatusMsgID

saveAssetsChecksum

-- put the documents folder & "/assets.zip" into tZipPath -- put the documents folder & "/assets.txt" into tZipManifest

put specialfolderPath("documents") & "/assets.zip" into tZipPath put specialfolderPath("documents") & "/assets.txt" into tZipManifest

if there is a file tZipPath then revZipOpenArchive tZipPath, "read" if the result is not empty then dispatch sConfigA["handler"] to sConfigA["target"] with ("expanderr," & the result) end if

  if there is not a folder (the documents folder & "/assets") then
     create folder (the documents folder & "/assets")
  end if

  put revZipEnumerateItems(tZipPath) into tFileList
  dispatch sConfigA["handler"] to sConfigA["target"] with ("expanding 0" && the number of lines in tFileList )
  repeat with x = 1 to the number of lines in tFileList
     put line x of tFileList into tFile
     put (the documents folder & "/assets/" & tFile) into tDestinationFile
     replace "./" with empty in tDestinationFile

     createFolders tDestinationFile

     revZipExtractItemToFile tZipPath, tFile, tDestinationFile
     if the result is not empty then
        dispatch sConfigA["handler"] to sConfigA["target"] with the result
        exit repeat
     else
        dispatch sConfigA["handler"] to sConfigA["target"] with ("expanding" && x && the number of lines in tFileList )
     end if
     wait 50 millisecs with messages
  end repeat
  dispatch sConfigA["handler"] to sConfigA["target"] with ("expanded" && x && the number of lines in tFileList )

else dispatch sConfigA["handler"] to sConfigA["target"] with ("expanderr,no assets.zip") end if end verifyAndExpandAssets

  1. On the desktop we get going on the

behavior_InitSivaSivaProject.livecodescript

command copyAssetsFrom pFolder
   put folders(specialFolderPath("resources") & "/assets/" & pFolder) into tFolders
   filter lines of tFolders without ".."
   filter lines of tFolders without "."
   put files(specialFolderPath("resources") & "/assets/" & pFolder) into tFiles
   repeat for each line tFile in tFiles
      log "copying" && ("/assets/" & pFolder & "/" & tFile)
      createFolders  (specialfolderPath("documents") & "/assets/" & pFolder & "/" & tFile)
      put url ("binfile:" & specialFolderPath("resources") & "/assets/" & pFolder & "/" & tFile) into url ("binfile:" & specialfolderPath("documents") & "/assets/" & pFolder & "/" & tFile)
      if the result is not empty then
         log "error:" && the result
      end if
   end repeat

All is working. We have specialfolderPath("documents") folder

where it called "assets"

2021-09-18_16-56-16

BUT on iOS and on Android we go straight to the

specialFolderPath("resources")

where it can't find it. Why? because I have changed it name to "_assets"

2021-09-18_16-59-25

AND /libraries/lib_SivaSiva

may have some to do with it

it may called for assets

function path_HomeLocal if isMobile() then return specialFolderPath("resources") & slash else -- desktop set the itemdel to slash return (item 1 to -2 of the filename of stack "Siva-Siva-App") & slash end if end path_HomeLocal

function path_Assets local tPath put path_HomeLocal() into tPath put "assets/" after tPath return (the documents folder & "/assets/") --return tPath end path_Assets

well, it could be a simple change

function path_Documents local tPath put specialFolderPath("documents") into tPath put "/" after tPath

remember not to precede path strings to follow with a slash in your

final slashes are added here

handlers, double // works on desktop but not on mobile, especially not on Android

if not isMobile() then

We may have a desktop version in which case we want all content related to the app to go into a proper folder

  # in the Users/SomeUser/Documents
  put "SivaSivaApp/" after tPath 
  if not (there is a folder tPath) then  # need for first run ... 
     create folder tPath
  end if

end if
return tPath end path_Documents

function path_Assets local tPath put path_Documentsl() into tPath put "assets/" after tPath return (the documents folder & "/assets/") --return tPath end path_Assets

:-)

.

Brahmanathaswami commented 3 years ago

Well "darn it!"

put path_Documentsl() into tPath put "assets/" after tPath

we don't

2021-09-18_16-59-25

but we DO get

getNavigationMap!