Accessing images in .rb file using RubyMotion Android - image

I am trying to access images from resources folder by using Android::R::Drawable::. It is showing "false" value.How can I get image id in .rb file, but in .xml file it is working.
All suggestions are acceptable
Thanks in advance.

After Struggling a lot i found an answer.
In java after compilation .R file will generate in that all id's of resources file will be there but in RubyMotion no .R file will get create. So, you have to use below snippet.
Suppose you have "ecollect.png" in drawable folder.If you want to access in .rb file you have to use below code.
resources.getIdentifier("ecollect", "drawable", self.getPackageName)
Enjoy :)

Related

I cant load HTML file into WebView from app specific storage since Android 11 (SDK30)

My App has the following use case:
We download a geojson file, a html file and some audio files from a server for a specific language a user has chosen and we are saving this in the app specific file directory.
The directory path is the following for each use case:
For the HTML file we have:
/storage/emulated/0/Android/data/my.example.com/files/ExampleApp/EnginePayload/de/html-file.html
For the json file we have:
/storage/emulated/0/Android/data/my.example.com/files/ExampleApp/LocationPayload/de/geojson-file.geojson
Audiodata:
/storage/emulated/0/Android/data/my.example.com/files/ExampleApp/Audio/de/intro.mp3
/storage/emulated/0/Android/data/my.example.com/files/ExampleApp/Audio/de/outro.mp3
and so on...
Since i have to change the minSDK and compileSDK to 30 i don't get the files to work.
I load the html-file.getAbsolutePath() to the webView but the webview client does not call ANY callback!
The audio files will not be started, because we use javascript functions to do that.
As i unterstand it, the app specific directory does not have to be changed because even on Android 11, the app has permission to read and write its own created files.
The moment i change it back to SDK 29, everything is working.
I don't know what to do. Can someone help me please?
I fixed it myself after hours!
My assumptions were right. The app had access to the files, because the app created them itself. so there was not an issue here to read the files...
Here is my fix and i hope it will help someone in the future:
There was something missing in the settings for the WebView.
webView.getSettings().setAllowFileAccess(true);
This allows me now to load a html file (with absolute Path) from the app specific directory for Android 11.
Here is my code:
webView.getSettings().setAllowFileAccess(true);
File extDir = cxt.getExternalFilesDir(null);
//htmlPath is something like this: "ExampleApp/EnginePayload/de/html-file.html"
File twine = new File(extDir.toString() + "/" + htmlPath);
webView.loadUrl(twine.getAbsolutePath());

See images one FPDF - Laravel

I'm using Laravel and I install Anouar for export to PDF
It is working well, but i can't put images in my pdf files.
In what file do I have to put the image to see it, or how can Ipdf get the route to this file?
Is in public/src/images/timbreCDDOC.png
$pdf::Image('images/timbreCDDOC.png',10,6,30);
Do I have to put the image in some special folder?
If someone have the same problem...
$pdf::Image(URL::to('src/images/timbreCDDOC.png'),10,6,30)

Comfortable mexican sofa - upload file to specific path

At this moment when I upload file into CMS it is being stored in location like:
/system/comfy/cms/files/files/000/000/004/original/logo.jpg
I would like to be able to specify that logo category files will be stored in path
/system/logo/logo.jpg
and files of category images in:
/system/images/image.jpg
Where should I start? Im pretty sure that this is impossible to achieve using only comfy GUI however I am quite not experienced in working with this cms, can anyone give me a hint how I can do that?
It's right that Paperclip handles that.
However you can set the upload path changing the value of config.upload_file_options entry in the /config/initializers/comfortable_mexican_sofa.rb file

Ruby app running on Sinatra using HAML, can't access files in uploads directory?

I have a Ruby app which is an Image Resizer. It uses the RMagick gem to do this. The app asks the user to upload a file, and then resizes it and saves the newly generated file.
It seems that Sinatra by default puts all uploaded files into the 'uploads' directory, and the newly generated file also seems to be saved there. I am assuming this is default behavior, not sure how to change this, but it isn't an immediate problem at the moment (although if you know how to do this, that would be appreciated too).
Now, in my 'success.haml' page which is displayed after the file is generated correctly, I am trying to display the newly generated image with a simple img tag. The path to the file is found in #filepath, so when I did:
%img(src=#filepath)
the HTML rendered (when inspected using Firebug) is correctly showing
<img src="uploads/filename.jpg">
and this file does indeed exist in my folder structure. However, the image appears broken.
Any ideas on how to overcome this problem?
Thank you.
Relative urls (uploads/filename.jpg) are called so because they are relative to web root. In Sinatra this is the public folder. By default it's located in your app directory and called public. But you can override that.
set :public_folder, 'my_root' # this will make my_root dir the web root.
So, to make your uploads visible to the internet, put them into your public folder.
Read this for more Sinatra settings and customizations.

How to add an external stylesheet/js file to a UIWebView without having it stored?

I want to change some CSS properties and HTML content from a random web, so I download and save the html file in the device and load it in a UIWebView to modify it.
The problem occurs when the html has referenced stylesheet/javascript files and they aren't loaded in the UIWebView.
Is there a way to access automatically to these files?
I've thought of getting the path through javascript and add the web url to it, and then download... but first I'll have to check if the path is relative or absolute and that...
Is there an easy and clean way to do this?
(I have the same problem with the images that are not url linked...)
Any idea would be appreciated :)

Resources