on android app: send intent for PosLink (fixes #437)
This commit is contained in:
parent
303b1cc03a
commit
d3270f698c
@ -107,12 +107,16 @@ window.rangeLinkClick = function() {
|
||||
}
|
||||
|
||||
window.showPortalPosLinks = function(lat, lng) {
|
||||
if (android && android.intentPosLink) {
|
||||
android.intentPosLink('https://maps.google.com/?q='+lat+','+lng);
|
||||
} else {
|
||||
var qrcode = '<div id="qrcode"></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) {
|
||||
var t = 'Redirecting you to a Google Help Page.\n\nThe text box contains all necessary information. Press CTRL+C to copy it.';
|
||||
|
@ -2,10 +2,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cradle.iitc_mobile"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.2" >
|
||||
android:versionName="0.2.1" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
android:minSdkVersion="14"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
<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 IITC_WebViewClient webclient;
|
||||
private IITC_JSInterface js_interface;
|
||||
|
||||
// init web view
|
||||
private void iitc_init(Context c) {
|
||||
@ -21,6 +22,8 @@ public class IITC_WebView extends WebView {
|
||||
settings.setDomStorageEnabled(true);
|
||||
settings.setAllowFileAccess(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
|
||||
// allow access by default
|
||||
@ -59,4 +62,8 @@ public class IITC_WebView extends WebView {
|
||||
return this.webclient;
|
||||
}
|
||||
|
||||
public IITC_JSInterface getJSInterface() {
|
||||
return this.js_interface;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user