Merge branch 'master' into highlighter
1
mobile/.gitignore
vendored
@ -7,4 +7,5 @@ libs/
|
||||
proguard-project.txt
|
||||
local.properties
|
||||
assets/iitc.js
|
||||
assets/user-location.user.js
|
||||
assets/plugins/
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cradle.iitc_mobile"
|
||||
android:versionCode="12"
|
||||
android:versionName="0.3.1" >
|
||||
android:versionCode="13"
|
||||
android:versionName="0.3.2" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/iitc_icon"
|
||||
android:icon="@drawable/ic_iitcm"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
|
BIN
mobile/res/drawable-hdpi/ic_iitcm.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 2.8 KiB |
BIN
mobile/res/drawable-ldpi/ic_iitcm.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 1.5 KiB |
BIN
mobile/res/drawable-mdpi/ic_iitcm.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.9 KiB |
BIN
mobile/res/drawable-xhdpi/ic_iitcm.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 3.8 KiB |
BIN
mobile/res/drawable-xxhdpi/ic_iitcm.png
Normal file
After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 5.6 KiB |
@ -18,7 +18,7 @@
|
||||
<string name="pref_about_msg">
|
||||
<![CDATA[<big><b>Ingress Intel Total Conversion Mobile</b></big><br><br>
|
||||
<b>by <a href="https://github.com/leCradle">cradle</a></b><br><br>
|
||||
<b>Icon by <a href="https://twitter.com/machtwerk">machtwerk</a></b><br><br>
|
||||
<b>Icon by <a href="http://www.ludolab.net">Giuseppe Lucido</a></b><br><br>
|
||||
IITC Mobile is an optimized mobile browser for the
|
||||
Ingress Intel Total Conversion (IITC) userscript by <a href="https://github.com/breunigs"><b>breunigs</b></a>.
|
||||
After Niantic asked the main developer to shut down his github project, development
|
||||
@ -36,6 +36,8 @@
|
||||
<string name="pref_plugins_title">Available plugins</string>
|
||||
<string name="pref_force_desktop">Force desktop mode</string>
|
||||
<string name="pref_force_desktop_sum">Nice for tablets, looks awful on smartphones</string>
|
||||
<string name="pref_user_loc">Display user location</string>
|
||||
<string name="pref_user_loc_sum">Show users position on map</string>
|
||||
<string name="pref_developer_options">Developer options</string>
|
||||
<string name="pref_select_iitc">IITC source</string>
|
||||
|
||||
|
@ -17,6 +17,11 @@
|
||||
android:title="@string/pref_force_desktop"
|
||||
android:summary="@string/pref_force_desktop_sum"
|
||||
android:defaultValue="false" />
|
||||
<CheckBoxPreference
|
||||
android:key="pref_user_loc"
|
||||
android:title="@string/pref_user_loc"
|
||||
android:summary="@string/pref_user_loc_sum"
|
||||
android:defaultValue="false" />
|
||||
<MultiSelectListPreference
|
||||
android:key="pref_plugins"
|
||||
android:title="@string/pref_plugins"
|
||||
|
@ -4,6 +4,9 @@ import java.io.IOException;
|
||||
|
||||
import com.cradle.iitc_mobile.R;
|
||||
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
@ -20,6 +23,7 @@ import android.content.res.Configuration;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class IITC_Mobile extends Activity {
|
||||
@ -29,6 +33,10 @@ public class IITC_Mobile extends Activity {
|
||||
private boolean desktop = false;
|
||||
private OnSharedPreferenceChangeListener listener;
|
||||
private String intel_url = "https://www.ingress.com/intel";
|
||||
private boolean user_loc = false;
|
||||
private LocationManager loc_mngr = null;
|
||||
private LocationListener loc_listener = null;
|
||||
private boolean keyboad_open = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -45,11 +53,53 @@ public class IITC_Mobile extends Activity {
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals("pref_force_desktop"))
|
||||
desktop = sharedPreferences.getBoolean("pref_force_desktop", false);
|
||||
if (key.equals("pref_user_loc")) {
|
||||
user_loc = sharedPreferences.getBoolean("pref_user_loc", false);
|
||||
}
|
||||
IITC_Mobile.this.loadUrl(intel_url);
|
||||
}
|
||||
};
|
||||
sharedPref.registerOnSharedPreferenceChangeListener(listener);
|
||||
|
||||
// we need this one to prevent location updates to javascript when keyboard is open
|
||||
// it closes on updates
|
||||
iitc_view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if ((iitc_view.getRootView().getHeight() - iitc_view.getHeight()) >
|
||||
iitc_view.getRootView().getHeight()/3) {
|
||||
Log.d("iitcm", "Open Keyboard...");
|
||||
IITC_Mobile.this.keyboad_open = true;
|
||||
} else {
|
||||
Log.d("iitcm", "Close Keyboard...");
|
||||
IITC_Mobile.this.keyboad_open = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
// Acquire a reference to the system Location Manager
|
||||
loc_mngr = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
// Define a listener that responds to location updates
|
||||
loc_listener = new LocationListener() {
|
||||
public void onLocationChanged(Location location) {
|
||||
// Called when a new location is found by the network location provider.
|
||||
drawMarker(location);
|
||||
}
|
||||
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
public void onProviderEnabled(String provider) {}
|
||||
|
||||
public void onProviderDisabled(String provider) {}
|
||||
};
|
||||
|
||||
user_loc = sharedPref.getBoolean("pref_user_loc", false);
|
||||
if (user_loc == true) {
|
||||
// Register the listener with the Location Manager to receive location updates
|
||||
loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, loc_listener);
|
||||
loc_mngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, loc_listener);
|
||||
}
|
||||
|
||||
// load new iitc web view with ingress intel page
|
||||
Intent intent = getIntent();
|
||||
String action = intent.getAction();
|
||||
@ -78,6 +128,12 @@ public class IITC_Mobile extends Activity {
|
||||
Log.d("iitcm", "resuming...setting reset idleTimer");
|
||||
iitc_view.loadUrl("javascript: window.idleTime = 0");
|
||||
iitc_view.loadUrl("javascript: window.renderUpdateStatus()");
|
||||
|
||||
if (user_loc == true) {
|
||||
// Register the listener with the Location Manager to receive location updates
|
||||
loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, loc_listener);
|
||||
loc_mngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, loc_listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,6 +163,10 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
}
|
||||
Log.d("iitcm", "stopping iitcm");
|
||||
|
||||
if (user_loc == true)
|
||||
loc_mngr.removeUpdates(loc_listener);
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@ -185,6 +245,7 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
// vp=f enables desktop mode...vp=m is the defaul mobile view
|
||||
private String addUrlParam(String url) {
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
this.desktop = sharedPref.getBoolean("pref_force_desktop", false);
|
||||
@ -195,6 +256,8 @@ public class IITC_Mobile extends Activity {
|
||||
return (url + "?vp=m");
|
||||
}
|
||||
|
||||
// inject the iitc-script and load the intel url
|
||||
// plugins are injected onPageFinished
|
||||
public void loadUrl(String url) {
|
||||
url = addUrlParam(url);
|
||||
Log.d("iitcm", "injecting js...");
|
||||
@ -202,4 +265,17 @@ public class IITC_Mobile extends Activity {
|
||||
Log.d("iitcm", "loading url: " + url);
|
||||
iitc_view.loadUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
// update the user location marker on the map
|
||||
public void drawMarker(Location loc) {
|
||||
// throw away all positions with accuracy > 100 meters
|
||||
// should avoid gps glitches
|
||||
if (loc.getAccuracy() < 100) {
|
||||
if (keyboad_open == false) {
|
||||
iitc_view.loadUrl("javascript: " +
|
||||
"window.plugin.userLocation.updateLocation( " +
|
||||
loc.getLatitude() + ", " + loc.getLongitude() + ");");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -124,6 +124,25 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// inject the user location script if enabled in settings
|
||||
if (sharedPref.getBoolean("pref_user_loc", false))
|
||||
enableTracking(view);
|
||||
}
|
||||
|
||||
public void enableTracking(WebView view) {
|
||||
Log.d("iitcm", "enable tracking...");
|
||||
AssetManager am = context.getAssets();
|
||||
Scanner s = null;
|
||||
String src = "";
|
||||
try {
|
||||
s = new Scanner(am.open("user-location.user.js")).useDelimiter("\\A");
|
||||
} catch (IOException e2) {
|
||||
// TODO Auto-generated catch block
|
||||
e2.printStackTrace();
|
||||
}
|
||||
if (s != null) src = s.hasNext() ? s.next() : "";
|
||||
view.loadUrl("javascript:" + src);
|
||||
}
|
||||
|
||||
// Check every external resource if it’s okay to load it and maybe replace it
|
||||
@ -153,7 +172,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
// start non-ingress-intel-urls in another app...
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
if (url.contains("ingress.com")) {
|
||||
if (url.contains("ingress.com") || url.contains("appengine.google.com")) {
|
||||
// reload iitc if a poslink is clicked inside the app
|
||||
if (url.contains("intel?ll=") || (url.contains("latE6") && url.contains("lngE6"))) {
|
||||
Log.d("iitcm", "should be an internal clicked position link...reload script for: " + url);
|
||||
|
69
mobile/user-location.user.js
Normal file
@ -0,0 +1,69 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-user-location@cradle
|
||||
// @name IITC plugin: User Location
|
||||
// @version 0.1.0.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Show user location marker on map
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
// @match https://www.ingress.com/intel*
|
||||
// @match http://www.ingress.com/intel*
|
||||
// ==/UserScript==
|
||||
|
||||
function wrapper() {
|
||||
// ensure plugin framework is there, even if iitc is not yet loaded
|
||||
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||
|
||||
|
||||
// PLUGIN START ////////////////////////////////////////////////////////
|
||||
|
||||
window.plugin.userLocation = function() {};
|
||||
|
||||
window.plugin.userLocation.marker = {};
|
||||
window.plugin.userLocation.locationLayer = new L.LayerGroup();
|
||||
|
||||
window.plugin.userLocation.setup = function() {
|
||||
|
||||
var iconImage = '@@INCLUDEIMAGE:images/marker-icon.png@@';
|
||||
var iconRetImage = '@@INCLUDEIMAGE:images/marker-icon_2x.png@@';
|
||||
|
||||
plugin.userLocation.icon = L.Icon.Default.extend({options: {
|
||||
iconUrl: iconImage,
|
||||
iconRetinaUrl: iconRetImage
|
||||
}});
|
||||
|
||||
var marker = L.marker(window.map.getCenter(), {
|
||||
title: "User Location",
|
||||
icon: new plugin.userLocation.icon()
|
||||
});
|
||||
plugin.userLocation.marker = marker;
|
||||
marker.addTo(window.map);
|
||||
// jQueryUI doesn’t automatically notice the new markers
|
||||
window.setupTooltips($(marker._icon));
|
||||
};
|
||||
|
||||
window.plugin.userLocation.updateLocation = function(lat, lng) {
|
||||
var latlng = new L.LatLng(lat, lng);
|
||||
window.plugin.userLocation.marker.setLatLng(latlng);
|
||||
}
|
||||
|
||||
var setup = window.plugin.userLocation.setup;
|
||||
|
||||
// PLUGIN END //////////////////////////////////////////////////////////
|
||||
|
||||
if(window.iitcLoaded && typeof setup === 'function') {
|
||||
setup();
|
||||
} else {
|
||||
if(window.bootPlugins)
|
||||
window.bootPlugins.push(setup);
|
||||
else
|
||||
window.bootPlugins = [setup];
|
||||
}
|
||||
} // wrapper end
|
||||
// inject code into site context
|
||||
var script = document.createElement('script');
|
||||
script.appendChild(document.createTextNode('('+ wrapper +')();'));
|
||||
(document.body || document.head || document.documentElement).appendChild(script);
|
||||
|