File picker locations doesn't show images - xamarin.forms

I do this on the simulator using Xamarin.Plugin.FilePicker...
var file = await CrossFilePicker.Current.PickFile();
And it shows this...
How do I navigate to images, of which there are some on the simulator?

Related

fastest way to get all links and images from a webpage?

So this isn't relly a problem but more like automate thingy...
I built a website and had to copy loads of content from previous webpage. I did that by copy-pasting the content from old page to the new page made with wordpress.
All link and images in the content still point to the old page. So I'd like to find something like a webscraping tools which would analyze list of selected links and then output would be all link pointing outside of my webpage and list of all images that I have to download
Considering that your old and new websites are going to have the same URL structure, here is a bookmarklet that you can save as a bookmark to your toolbar.
To make your job easy, open an old website page, and simply click on the bookmarklet button you've saved (code below). This code will replace the links from old website to new website. The images will be treated similarly. Next, you can copy the updated content and paste it into the editor of your new website (wordpress admin).
On the developer's console (F12 key), you will get a list of all the images that you have to download.
javascript:(function(){
var jqscript = document.createElement('script');
jqscript.onload = function() {
// treat the <a> tags
jQuery('#my-content-container').find('a[href^="http://my-old-website.com"]').each(function(i, anchor) {
jQuery(anchor).attr('href', jQuery(anchor).attr('href').replace('http://my-old-website.com', 'http://my-new-website.com/new-directory'));
});
// treat the <img> tags, and make a list of images to download
var images_to_download = [];
jQuery('#my-content-container').find('img').each(function(i, image) {
images_to_download.push(jQuery(image).attr('src'));
jQuery(image).attr('src', jQuery(image).attr('src').replace('http://my-old-website.com', 'http://my-new-website.com/new-directory'));
});
// output a list of images to the developer console
console.log(images_to_download);
};
jqscript.src = "//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js";
}());
P.S. To save this bookmarklet code, rightclick the toolbar of your browser and create a new bookmark, and enter the above code as the Location/URL.
This is just an option you should think about: You could use absolute path instead of Relative path, this will help you reuse code without to have to remap every link in it.
Relatif Path :
Read about my Tahiti vacation.
Absolute path :
Read about my Tahiti vacation.

Meteor - phantomjs rendering of public assets

I am working on a Meteor project where I need to generate a PDF export of a section from the page.
I use webshot to generate the export.
A recent requirement is to use a public static asset - a logo image - in the export.
I worked around making css assets available to phantomjs by reading all the css files and copying their content into style tags in the HTML doc I let webshot consume. That works fine.
For the images, I replace the "./images/" pattern in the HTML with the full path to the images folder on the server using
const buildPath = path.resolve('.').split(path.sep + 'server')[0];
const imagePath = buildPath + '/web.browser/app/images/';
which runs on the server. The image doesn't show up.
When I open the generated HTML (I save it for debugging) at any place on my dev machine, the image path is resolved fine, and I get the image.
What is the right way to access those static assets in phantomjs?
I figured that out - I was missing a fully qualified protocol in the src attribute of the img tag. While Chrome is smart and forgiving, phantomjs is not.
So basically I had to add 'file:///' before the full path to the image.
It now looks like:
const buildPath = path.resolve('.').split(path.sep + 'server')[0].replace(/\\/g, '/');
const imagePath = buildPath + '/web.browser/app/images/';
html = html.replace(/src="\.\/images\//g, 'src="file:///' + imagePath);
And as for the comment regarding time, I do give full 1 sec delay for rendering, but didn't check if it works without it.

Open PDF in the PhoneGap App that is made in HTML and CSS

I have a strange problem with my iPad App in Phone Gap. The problem is that I have to open PDF document in my app through links and when I click the link which opens the PDF, it shows me the PDF document with no back link.
Hence, when I open the PDF document in my app through a link, it takes me to a dead end and there is no way I can go back to the main page of my app.
My question is that how can I have a Top-Bar, when I open a PDF which could take me back to my home page? Any internal element for the iPad may be?
Thanks a lot.
Try using the In App Browser plugin.
If you're using a later Phonegap / Cordova version (2.8.0, 2.9.0 etc) it should come with it - nothing else to install.
http://docs.phonegap.com/en/2.9.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser
It will allow you to open the PDF in the a new 'window' that overlays your app. It has a 'Done' button that users can use to close it and return to your app when they are finished.
You would open the PDF using the In-App Browser, using something like this:
window.open('http://whitelisted-url.com/pdftoopen.pdf', '_blank');
I.e. the _blank option triggers the In-App Browser plugin. If you were to use _system instead it might open it in iBooks (just guessing there - not 100% sure if it would use iBooks).
Try prefixing https://docs.google.com/viewer?url= in the URL
like, window.open('https://docs.google.com/viewer?url=http://www.example.com/example.pdf&embedded=true', '_blank', 'location=yes');
Try this to open any kind of documents from URL using following steps:
install this plugin : cordova plugin add https://github.com/ti8m/DocumentHandler
use this code :
handleDocumentWithURL(function() { console.log('success'); }, function(error) { console.log('failure'); if (error == 53) { console.log('No app that handles this file type.'); } }, 'http://www.example.com/path/to/document.pdf');
It works for me both on Android and IOS. I used it for open images and PDF files.
Android : It opens files using system apps if available, otherwise it give an error, which you can handle.
IOS : It opens files in popup like view with Done button and Option button.
It doesn't show your docs URL.
Source is available here : https://github.com/ti8m/DocumentHandler
Thanks asgeo1,
I solved it by using window.open().
<img src="images/samplens.jpg" border="0" />
Hope it helps.
I've ended up using WebIntent
as described here. The tricky part was to modify WebIntent.java to properly identify file type:
String type = obj.has("type") ? obj.getString("type") : null;
// New code starts
Uri uri = obj.has("url") ? Uri.parse(obj.getString("url")) : null;
String extension = MimeTypeMap.getFileExtensionFromUrl(obj.getString("url"));
if(extension != null){
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
type = mimeTypeMap.getMimeTypeFromExtension(extension);
}
// New code ends
JSONObject extras = obj.has("extras") ? obj.getJSONObject("extras") : null;

How to launch Google Earth plugin within Chrome

I have the Google Earth plugin installed and it seems to work fine.
What I would like to do is open a KML file (exported from MyTracks on Android) in it.
But, I can find no option to open the KML file, or launch the GE plugin.
Is this possible ?
To launch the plugin take a look at the 'Using the Google Earth Api' section in the developer's guide.
For loading KML files, take a look at the following documentation https://developers.google.com/earth/documentation/kml
It give examples of how to fetchKml and parseKml as well as linking to a working example.
var href = 'http://code.google.com/'
+ 'apis/earth/documentation/samples/kml_example.kml';
google.earth.fetchKml(ge, href, function(kmlObject) {
if (kmlObject) {
ge.getFeatures().appendChild(kmlObject);
}
});
You can also use a KmlNetworkLink to load the data again the document links to a working example of this.
var link = ge.createLink('');
var href = 'http://code.google.com/'
+ 'apis/earth/documentation/samples/kml_example.kml'
link.setHref(href);
var networkLink = ge.createNetworkLink('');
networkLink.set(link, true, true); // Sets the link, refreshVisibility, and flyToView
ge.getFeatures().appendChild(networkLink);

add photos to iPhone simulator

I need than on button click opens iPhone's default album and I'll can chose a photo.
I read a lot about this, but still don't works.
I do the following:
~/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE/
I'm storing two pictures IMG_0000.JPG (300 on 300 px) and IMG_0000.THM (75 on 75px)
In my app I do the following on button click:
- (IBAction) btnOpenAlbum
{
album = [[UIImagePickerController alloc] init];
album.delegate = self;
album.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController: album animated:YES];
}
I tried also UIImagePickerControllerSourceTypePhotoAlbum and still no photos in album.
AI solved it in such a way:
Opened iPhone simulator.
Drag there photos. And it automatically copy it to folder ~/Library/Application Support/iPhone Simulator/4.1/Media/DCIM/100APPLE and named them as IMG_0001.PNG IMG_0002.PNG and so on.
After that all works fine, but:
When I tried to copy item directly to that folder, and give them suitable names, iphone didn't recognized them. And also, when I deleted them from that folder and run simulator - photos where on simulator, but in folder they were not.
What it can be? Thanx.
AI solved it in such a way:
Opened iPhone simulator. Drag there photos. And it automatically copy it to folder ~/Library/Application Support/iPhone Simulator/4.1/Media/DCIM/100APPLE and named them as IMG_0001.PNG IMG_0002.PNG and so on. After that all works fine, but: When I tried to copy item directly to that folder, and give them suitable names, iphone didn't recognized them. And also, when I deleted them from that folder and run simulator - photos where on simulator, but in folder they were not.

Resources