added getLocation/clear cache and print version buttons to menu
This commit is contained in:
parent
478ff1cc0b
commit
3c039b838f
@ -2,13 +2,14 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cradle.iitc_mobile"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
android:versionName="0.1.5" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="10" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -4,4 +4,19 @@
|
||||
android:showAsAction="never"
|
||||
android:title="@string/reload"></item>
|
||||
|
||||
<item android:id="@+id/version_num"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/version"></item>
|
||||
|
||||
<item android:id="@+id/cache_clear"
|
||||
android:orderInCategory="90"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/cache_clear"></item>
|
||||
|
||||
<item android:id="@+id/locate"
|
||||
android:orderInCategory="80"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/locate"></item>
|
||||
|
||||
</menu>
|
@ -4,5 +4,8 @@
|
||||
<string name="app_name">IITC mobile</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="reload">Reload IITC</string>
|
||||
<string name="version">Print Version</string>
|
||||
<string name="cache_clear">Clear Cache</string>
|
||||
<string name="locate">Get Location</string>
|
||||
|
||||
</resources>
|
@ -5,12 +5,13 @@ import com.cradle.iitc_mobile.R;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.app.Activity;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class IITC_Mobile extends Activity {
|
||||
@ -31,7 +32,6 @@ public class IITC_Mobile extends Activity {
|
||||
else {
|
||||
// load new iitc web view with ingress intel page
|
||||
iitc_view= (IITC_WebView) findViewById(R.id.webview);
|
||||
iitc_view.setWebChromeClient(new WebChromeClient());
|
||||
iitc_view.loadUrl("https://www.ingress.com/intel");
|
||||
|
||||
// listen to touches (think we need this)
|
||||
@ -95,6 +95,27 @@ public class IITC_Mobile extends Activity {
|
||||
case R.id.reload_button:
|
||||
iitc_view.reload();
|
||||
return true;
|
||||
// print version number
|
||||
case R.id.version_num:
|
||||
PackageInfo pinfo;
|
||||
try {
|
||||
pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
Toast.makeText(this, "Build version: " + pinfo.versionName, Toast.LENGTH_SHORT).show();
|
||||
} catch (NameNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
// clear cache
|
||||
case R.id.cache_clear:
|
||||
iitc_view.clearHistory();
|
||||
iitc_view.clearFormData();
|
||||
iitc_view.clearCache(true);
|
||||
return true;
|
||||
// clear cache
|
||||
case R.id.locate:
|
||||
iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 13});");
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -3,8 +3,10 @@ package com.cradle.iitc_mobile;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.GeolocationPermissions;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public class IITC_WebView extends WebView {
|
||||
@ -18,6 +20,16 @@ public class IITC_WebView extends WebView {
|
||||
settings.setJavaScriptEnabled(true);
|
||||
settings.setDomStorageEnabled(true);
|
||||
settings.setAllowFileAccess(true);
|
||||
settings.setGeolocationEnabled(true);
|
||||
|
||||
// our webchromeclient should share geolocation with the iitc script
|
||||
// allow access by default
|
||||
this.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
|
||||
callback.invoke(origin, true, false);
|
||||
}
|
||||
});
|
||||
|
||||
webclient = new IITC_WebViewClient();
|
||||
this.setWebViewClient(webclient);
|
||||
|
Loading…
x
Reference in New Issue
Block a user