on android app: send intent for PosLink (fixes #437)
This commit is contained in:
parent
303b1cc03a
commit
d3270f698c
@ -107,11 +107,15 @@ window.rangeLinkClick = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.showPortalPosLinks = function(lat, lng) {
|
window.showPortalPosLinks = function(lat, lng) {
|
||||||
var qrcode = '<div id="qrcode"></div>';
|
if (android && android.intentPosLink) {
|
||||||
var script = '<script>$(\'#qrcode\').qrcode({text:\'GEO:'+lat+','+lng+'\'});</script>';
|
android.intentPosLink('https://maps.google.com/?q='+lat+','+lng);
|
||||||
var gmaps = '<a href="https://maps.google.com/?q='+lat+','+lng+'">gmaps</a>';
|
} else {
|
||||||
var osm = '<a href="http://www.openstreetmap.org/?mlat='+lat+'&mlon='+lng+'&zoom=16">OSM</a>';
|
var qrcode = '<div id="qrcode"></div>';
|
||||||
alert('<div style="text-align: center;">' + qrcode + script + gmaps + ' ' + osm + '</div>');
|
var script = '<script>$(\'#qrcode\').qrcode({text:\'GEO:'+lat+','+lng+'\'});</script>';
|
||||||
|
var gmaps = '<a href="https://maps.google.com/?q='+lat+','+lng+'">gmaps</a>';
|
||||||
|
var osm = '<a href="http://www.openstreetmap.org/?mlat='+lat+'&mlon='+lng+'&zoom=16">OSM</a>';
|
||||||
|
alert('<div style="text-align: center;">' + qrcode + script + gmaps + ' ' + osm + '</div>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.reportPortalIssue = function(info) {
|
window.reportPortalIssue = function(info) {
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.cradle.iitc_mobile"
|
package="com.cradle.iitc_mobile"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="0.2" >
|
android:versionName="0.2.1" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="11"
|
android:minSdkVersion="14"
|
||||||
android:targetSdkVersion="17" />
|
android:targetSdkVersion="17" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
25
mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java
Normal file
25
mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.cradle.iitc_mobile;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.webkit.JavascriptInterface;
|
||||||
|
|
||||||
|
// provide communication between IITC script and android app
|
||||||
|
public class IITC_JSInterface {
|
||||||
|
|
||||||
|
// context of main activity
|
||||||
|
Context context;
|
||||||
|
|
||||||
|
IITC_JSInterface(Context c) {
|
||||||
|
context = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
// send intent for gmaps link
|
||||||
|
@JavascriptInterface
|
||||||
|
public void intentPosLink(String s) {
|
||||||
|
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
|
||||||
|
Uri.parse(s));
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ public class IITC_WebView extends WebView {
|
|||||||
|
|
||||||
private WebSettings settings;
|
private WebSettings settings;
|
||||||
private IITC_WebViewClient webclient;
|
private IITC_WebViewClient webclient;
|
||||||
|
private IITC_JSInterface js_interface;
|
||||||
|
|
||||||
// init web view
|
// init web view
|
||||||
private void iitc_init(Context c) {
|
private void iitc_init(Context c) {
|
||||||
@ -21,6 +22,8 @@ public class IITC_WebView extends WebView {
|
|||||||
settings.setDomStorageEnabled(true);
|
settings.setDomStorageEnabled(true);
|
||||||
settings.setAllowFileAccess(true);
|
settings.setAllowFileAccess(true);
|
||||||
settings.setGeolocationEnabled(true);
|
settings.setGeolocationEnabled(true);
|
||||||
|
this.js_interface = new IITC_JSInterface(c);
|
||||||
|
this.addJavascriptInterface(js_interface, "android");
|
||||||
|
|
||||||
// our webchromeclient should share geolocation with the iitc script
|
// our webchromeclient should share geolocation with the iitc script
|
||||||
// allow access by default
|
// allow access by default
|
||||||
@ -59,4 +62,8 @@ public class IITC_WebView extends WebView {
|
|||||||
return this.webclient;
|
return this.webclient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IITC_JSInterface getJSInterface() {
|
||||||
|
return this.js_interface;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user