Merge branch 'master' into highlighter

This commit is contained in:
vita10gy
2013-04-12 22:38:46 -05:00
18 changed files with 216 additions and 66 deletions

View File

@ -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="7"
android:versionName="0.2.6" >
android:versionCode="9"
android:versionName="0.2.8" >
<uses-sdk
android:minSdkVersion="14"

View File

@ -14,7 +14,7 @@
<string name="about">About</string>
<string name="pref_about_title">About IITC Mobile</string>
<!-- Use CDATA to prevent android from parsin html tags....we are doing this with Html.fromHtml() -->
<!-- Use CDATA to prevent android from parsing html tags....we are doing this with Html.fromHtml() -->
<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>

View File

@ -34,7 +34,7 @@ public class IITC_AboutDialogPreference extends DialogPreference{
message.setMovementMethod(LinkMovementMethod.getInstance());
builder.setView(message)
.setTitle(R.string.about)
.setIcon(R.drawable.ic_stat_about)
.setIcon(android.R.drawable.ic_dialog_info)
.setNeutralButton(R.string.close, new OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();

View File

@ -6,7 +6,6 @@ import com.cradle.iitc_mobile.R;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@ -85,17 +84,29 @@ public class IITC_Mobile extends Activity {
protected void onStop() {
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
State mobile = conMan.getNetworkInfo(0).getState();
State wifi = conMan.getNetworkInfo(1).getState();
NetworkInfo mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
NetworkInfo wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING) {
// cancel all current requests
iitc_view.loadUrl("javascript: window.requests.abort()");
// set idletime to maximum...no need for more
iitc_view.loadUrl("javascript: window.idleTime = 999");
} else if (wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING) {
iitc_view.loadUrl("javascript: window.idleTime = 999");
// check if Mobile or Wifi module is available..then handle states
// TODO: theory...we do not have to check for a Wifi module...every android device should have one
if (mobile != null) {
Log.d("iitcm", "mobile internet module detected...check states");
if (mobile.getState() == NetworkInfo.State.CONNECTED || mobile.getState() == NetworkInfo.State.CONNECTING) {
Log.d("iitcm", "connected to mobile net...abort all running requests");
// cancel all current requests
iitc_view.loadUrl("javascript: window.requests.abort()");
// set idletime to maximum...no need for more
iitc_view.loadUrl("javascript: window.idleTime = 999");
} else if (wifi.getState() == NetworkInfo.State.CONNECTED || wifi.getState() == NetworkInfo.State.CONNECTING) {
iitc_view.loadUrl("javascript: window.idleTime = 999");
}
} else {
Log.d("iitcm", "no mobile internet module detected...check wifi state");
if (wifi.getState() == NetworkInfo.State.CONNECTED || wifi.getState() == NetworkInfo.State.CONNECTING) {
iitc_view.loadUrl("javascript: window.idleTime = 999");
}
}
Log.d("iitcm", "stopping iitcm");
super.onStop();
}

View File

@ -1,9 +1,12 @@
package com.cradle.iitc_mobile;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.net.http.SslError;
import android.preference.PreferenceManager;
import android.util.Log;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
@ -22,8 +25,10 @@ public class IITC_WebViewClient extends WebViewClient {
private WebResourceResponse iitcjs;
private String js = null;
Context context;
public IITC_WebViewClient(Context c) {
this.context = c;
try {
loadIITC_JS(c);
} catch(IOException e) {
@ -109,4 +114,17 @@ public class IITC_WebViewClient extends WebViewClient {
return super.shouldInterceptRequest(view, url);
}
}
// start non-ingress-intel-urls in another app...
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("ingress.com")) {
return false;
} else {
Log.d("iitcm", "no ingress intel link, start external app to load url: " + url);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(intent);
return true;
}
}
}