Use custom Log

This commit is contained in:
fkloft 2014-01-03 17:16:08 +01:00
parent 14d3fe82c2
commit ab572055e3
9 changed files with 63 additions and 39 deletions

View File

@ -5,7 +5,6 @@ import android.content.res.AssetManager;
import android.net.Uri; import android.net.Uri;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.webkit.WebResourceResponse; import android.webkit.WebResourceResponse;
import org.json.JSONObject; import org.json.JSONObject;
@ -131,7 +130,7 @@ public class IITC_FileManager {
private WebResourceResponse getUserPlugin(Uri uri) { private WebResourceResponse getUserPlugin(Uri uri) {
if (!mPrefs.getBoolean(uri.getPath(), false)) { if (!mPrefs.getBoolean(uri.getPath(), false)) {
Log.e("iitcm", "Attempted to inject user script that is not enabled by user: " + uri.getPath()); Log.e("Attempted to inject user script that is not enabled by user: " + uri.getPath());
return EMPTY; return EMPTY;
} }
@ -193,7 +192,7 @@ public class IITC_FileManager {
if ("user-plugin".equals(host)) if ("user-plugin".equals(host))
return getUserPlugin(uri); return getUserPlugin(uri);
Log.e("iitcm", "could not generate response for url: " + url); Log.e("could not generate response for url: " + url);
return EMPTY; return EMPTY;
} }
} }

View File

@ -6,7 +6,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.util.Log;
import android.webkit.JavascriptInterface; import android.webkit.JavascriptInterface;
import android.widget.Toast; import android.widget.Toast;
@ -47,7 +46,7 @@ public class IITC_JSInterface {
// prevent the spinner from closing automatically // prevent the spinner from closing automatically
@JavascriptInterface @JavascriptInterface
public void spinnerEnabled(boolean en) { public void spinnerEnabled(boolean en) {
Log.d("iitcm", "disableJS? " + en); Log.d("disableJS? " + en);
mIitc.getWebView().disableJS(en); mIitc.getWebView().disableJS(en);
} }
@ -116,7 +115,7 @@ public class IITC_JSInterface {
@JavascriptInterface @JavascriptInterface
public void bootFinished() { public void bootFinished() {
Log.d("iitcm", "...boot finished"); Log.d("...boot finished");
mIitc.runOnUiThread(new Runnable() { mIitc.runOnUiThread(new Runnable() {
@Override @Override

View File

@ -17,7 +17,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -190,12 +189,12 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
String action = intent.getAction(); String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) { if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = intent.getData(); Uri uri = intent.getData();
Log.d("iitcm", "intent received url: " + uri.toString()); Log.d("intent received url: " + uri.toString());
if (uri.getScheme().equals("http") || uri.getScheme().equals("https")) { if (uri.getScheme().equals("http") || uri.getScheme().equals("https")) {
if (uri.getHost() != null if (uri.getHost() != null
&& (uri.getHost().equals("ingress.com") || uri.getHost().endsWith(".ingress.com"))) { && (uri.getHost().equals("ingress.com") || uri.getHost().endsWith(".ingress.com"))) {
Log.d("iitcm", "loading url..."); Log.d("loading url...");
this.loadUrl(uri.toString()); this.loadUrl(uri.toString());
return; return;
} }
@ -288,13 +287,13 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
super.onStart(); super.onStart();
if (mReloadNeeded) { if (mReloadNeeded) {
Log.d("iitcm", "preference had changed...reload needed"); Log.d("preference had changed...reload needed");
reloadIITC(); reloadIITC();
} else { } else {
// iitc is not fully booted...timer will be reset by the script itself // iitc is not fully booted...timer will be reset by the script itself
if (findViewById(R.id.imageLoading).getVisibility() == View.GONE) { if (findViewById(R.id.imageLoading).getVisibility() == View.GONE) {
// enough idle...let's do some work // enough idle...let's do some work
Log.d("iitcm", "resuming...reset idleTimer"); Log.d("resuming...reset idleTimer");
mIitcWebView.loadUrl("javascript: window.idleReset();"); mIitcWebView.loadUrl("javascript: window.idleReset();");
} }
} }
@ -319,7 +318,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
@Override @Override
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
Log.d("iitcm", "stopping iitcm"); Log.d("stopping iitcm");
mIitcWebView.loadUrl("javascript: window.idleSet();"); mIitcWebView.loadUrl("javascript: window.idleSet();");
mUserLocation.onStop(); mUserLocation.onStop();
} }
@ -336,7 +335,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
mNavigationHelper.onConfigurationChanged(newConfig); mNavigationHelper.onConfigurationChanged(newConfig);
Log.d("iitcm", "configuration changed...restoring...reset idleTimer"); Log.d("configuration changed...restoring...reset idleTimer");
mIitcWebView.loadUrl("javascript: window.idleTime = 0"); mIitcWebView.loadUrl("javascript: window.idleTime = 0");
mIitcWebView.loadUrl("javascript: window.renderUpdateStatus()"); mIitcWebView.loadUrl("javascript: window.renderUpdateStatus()");
} }
@ -615,7 +614,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
// to ensure it is the last element of the list // to ensure it is the last element of the list
// focused dialogs should be closed first // focused dialogs should be closed first
public void setFocusedDialog(String id) { public void setFocusedDialog(String id) {
Log.d("iitcm", "Dialog " + id + " focused"); Log.d("Dialog " + id + " focused");
mDialogStack.remove(id); mDialogStack.remove(id);
mDialogStack.push(id); mDialogStack.push(id);
} }
@ -623,10 +622,10 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
// called by the javascript interface // called by the javascript interface
public void dialogOpened(String id, boolean open) { public void dialogOpened(String id, boolean open) {
if (open) { if (open) {
Log.d("iitcm", "Dialog " + id + " added"); Log.d("Dialog " + id + " added");
mDialogStack.push(id); mDialogStack.push(id);
} else { } else {
Log.d("iitcm", "Dialog " + id + " closed"); Log.d("Dialog " + id + " closed");
mDialogStack.remove(id); mDialogStack.remove(id);
} }
} }

View File

@ -6,7 +6,6 @@ import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -52,7 +51,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
// since the plugins container is static, // since the plugins container is static,
// it is enough to parse the plugin only on first start. // it is enough to parse the plugin only on first start.
if (sPlugins == null) { if (sPlugins == null) {
Log.d("iitcm", "opened plugin prefs the first time since app start -> parse plugins"); Log.d("opened plugin prefs the first time since app start -> parse plugins");
sPlugins = new TreeMap<String, ArrayList<IITC_PluginPreference>>(); sPlugins = new TreeMap<String, ArrayList<IITC_PluginPreference>>();
setUpPluginPreferenceScreen(); setUpPluginPreferenceScreen();
} else { } else {
@ -148,7 +147,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
numPlugins += entry.getValue().size(); numPlugins += entry.getValue().size();
} }
if ((user.length + official.length) != (numPlugins + mDeletedPlugins)) { if ((user.length + official.length) != (numPlugins + mDeletedPlugins)) {
Log.d("iitcm", "new or less plugins found since last start, rebuild preferences"); Log.d("new or less plugins found since last start, rebuild preferences");
sPlugins.clear(); sPlugins.clear();
setUpPluginPreferenceScreen(); setUpPluginPreferenceScreen();
} }
@ -186,7 +185,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
s = new Scanner(file).useDelimiter("\\A"); s = new Scanner(file).useDelimiter("\\A");
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
Log.d("iitcm", "failed to parse file " + file); Log.d("failed to parse file " + file);
} }
if (s != null) { if (s != null) {
src = s.hasNext() ? s.next() : ""; src = s.hasNext() ? s.next() : "";
@ -225,7 +224,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
// first check if we need a new category // first check if we need a new category
if (!sPlugins.containsKey(plugin_cat)) { if (!sPlugins.containsKey(plugin_cat)) {
sPlugins.put(plugin_cat, new ArrayList<IITC_PluginPreference>()); sPlugins.put(plugin_cat, new ArrayList<IITC_PluginPreference>());
Log.d("iitcm", "create " + plugin_cat + " and add " + plugin_name); Log.d("create " + plugin_cat + " and add " + plugin_name);
} }
// now build a new checkable preference for the plugin // now build a new checkable preference for the plugin

View File

@ -9,7 +9,6 @@ import android.net.NetworkInfo;
import android.os.Build; import android.os.Build;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.WindowManager; import android.view.WindowManager;
import android.webkit.WebSettings; import android.webkit.WebSettings;
@ -112,7 +111,7 @@ public class IITC_WebView extends WebView {
if (url.startsWith("javascript:")) { if (url.startsWith("javascript:")) {
// do nothing if script is enabled; // do nothing if script is enabled;
if (mDisableJs) { if (mDisableJs) {
Log.d("iitcm", "javascript injection disabled...return"); Log.d("javascript injection disabled...return");
return; return;
} }
loadJS(url.substring("javascript:".length())); loadJS(url.substring("javascript:".length()));
@ -128,7 +127,7 @@ public class IITC_WebView extends WebView {
// disable splash screen if a http error code is responded // disable splash screen if a http error code is responded
new CheckHttpResponse(mIitc).execute(url); new CheckHttpResponse(mIitc).execute(url);
Log.d("iitcm", "loading url: " + url); Log.d("loading url: " + url);
super.loadUrl(url); super.loadUrl(url);
} }
} }
@ -145,7 +144,7 @@ public class IITC_WebView extends WebView {
// window.show(...) is called if one of the action bar buttons // window.show(...) is called if one of the action bar buttons
// is clicked // is clicked
if (!js.startsWith("window.show(")) { if (!js.startsWith("window.show(")) {
Log.d("iitcm", "in insert mode. do not load script."); Log.d("in insert mode. do not load script.");
return; return;
} }
} }
@ -258,7 +257,7 @@ public class IITC_WebView extends WebView {
public void setUserAgent() { public void setUserAgent() {
String ua = mSharedPrefs.getBoolean("pref_fake_user_agent", false) ? mDesktopUserAgent : mDefaultUserAgent; String ua = mSharedPrefs.getBoolean("pref_fake_user_agent", false) ? mDesktopUserAgent : mDefaultUserAgent;
Log.d("iitcm", "setting user agent to: " + ua); Log.d("setting user agent to: " + ua);
mSettings.setUserAgentString(ua); mSettings.setUserAgentString(ua);
} }
} }

View File

@ -7,7 +7,6 @@ import android.net.http.SslError;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.webkit.SslErrorHandler; import android.webkit.SslErrorHandler;
import android.webkit.WebResourceResponse; import android.webkit.WebResourceResponse;
import android.webkit.WebView; import android.webkit.WebView;
@ -54,7 +53,7 @@ public class IITC_WebViewClient extends WebViewClient {
if (url.startsWith("http://www.ingress.com/intel") if (url.startsWith("http://www.ingress.com/intel")
|| url.startsWith("https://www.ingress.com/intel")) { || url.startsWith("https://www.ingress.com/intel")) {
if (mIitcInjected) return; if (mIitcInjected) return;
Log.d("iitcm", "injecting iitc.."); Log.d("injecting iitc..");
loadScripts((IITC_WebView) view); loadScripts((IITC_WebView) view);
mIitcInjected = true; mIitcInjected = true;
} }
@ -158,16 +157,12 @@ public class IITC_WebViewClient extends WebViewClient {
// reload iitc if a poslink is clicked inside the app // reload iitc if a poslink is clicked inside the app
if (url.contains("intel?ll=") if (url.contains("intel?ll=")
|| (url.contains("latE6") && url.contains("lngE6"))) { || (url.contains("latE6") && url.contains("lngE6"))) {
Log.d("iitcm", Log.d("should be an internal clicked position link...reload script for: " + url);
"should be an internal clicked position link...reload script for: "
+ url);
mIitc.loadUrl(url); mIitc.loadUrl(url);
} }
return false; return false;
} else { } else {
Log.d("iitcm", Log.d("no ingress intel link, start external app to load url: " + url);
"no ingress intel link, start external app to load url: "
+ url);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
mIitc.startActivity(intent); mIitc.startActivity(intent);
return true; return true;

View File

@ -44,12 +44,18 @@ public final class Log {
d(DEFAULT_TAG, msg); d(DEFAULT_TAG, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.d}
*/
@Deprecated @Deprecated
public static void d(String tag, String msg) { public static void d(String tag, String msg) {
log(android.util.Log.DEBUG, tag, msg, null); log(android.util.Log.DEBUG, tag, msg, null);
android.util.Log.d(tag, msg); android.util.Log.d(tag, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.d}
*/
@Deprecated @Deprecated
public static void d(String tag, String msg, Throwable tr) { public static void d(String tag, String msg, Throwable tr) {
log(android.util.Log.DEBUG, tag, msg, tr); log(android.util.Log.DEBUG, tag, msg, tr);
@ -64,12 +70,18 @@ public final class Log {
e(DEFAULT_TAG, msg); e(DEFAULT_TAG, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.e}
*/
@Deprecated @Deprecated
public static void e(String tag, String msg) { public static void e(String tag, String msg) {
log(android.util.Log.ERROR, tag, msg, null); log(android.util.Log.ERROR, tag, msg, null);
android.util.Log.e(tag, msg); android.util.Log.e(tag, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.e}
*/
@Deprecated @Deprecated
public static void e(String tag, String msg, Throwable tr) { public static void e(String tag, String msg, Throwable tr) {
log(android.util.Log.ERROR, tag, msg, tr); log(android.util.Log.ERROR, tag, msg, tr);
@ -84,12 +96,18 @@ public final class Log {
i(DEFAULT_TAG, msg); i(DEFAULT_TAG, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.i}
*/
@Deprecated @Deprecated
public static void i(String tag, String msg) { public static void i(String tag, String msg) {
log(android.util.Log.INFO, tag, msg, null); log(android.util.Log.INFO, tag, msg, null);
android.util.Log.i(tag, msg); android.util.Log.i(tag, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.i}
*/
@Deprecated @Deprecated
public static void i(String tag, String msg, Throwable tr) { public static void i(String tag, String msg, Throwable tr) {
log(android.util.Log.INFO, tag, msg, tr); log(android.util.Log.INFO, tag, msg, tr);
@ -122,6 +140,9 @@ public final class Log {
return println(priority, DEFAULT_TAG, msg); return println(priority, DEFAULT_TAG, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.println}
*/
@Deprecated @Deprecated
public static int println(int priority, String tag, String msg) { public static int println(int priority, String tag, String msg) {
log(priority, tag, msg, null); log(priority, tag, msg, null);
@ -132,12 +153,18 @@ public final class Log {
v(DEFAULT_TAG, msg); v(DEFAULT_TAG, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.v}
*/
@Deprecated @Deprecated
public static void v(String tag, String msg) { public static void v(String tag, String msg) {
log(android.util.Log.VERBOSE, tag, msg, null); log(android.util.Log.VERBOSE, tag, msg, null);
android.util.Log.v(tag, msg); android.util.Log.v(tag, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.v}
*/
@Deprecated @Deprecated
public static void v(String tag, String msg, Throwable tr) { public static void v(String tag, String msg, Throwable tr) {
log(android.util.Log.VERBOSE, tag, msg, tr); log(android.util.Log.VERBOSE, tag, msg, tr);
@ -152,12 +179,18 @@ public final class Log {
w(DEFAULT_TAG, msg); w(DEFAULT_TAG, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.w}
*/
@Deprecated @Deprecated
public static void w(String tag, String msg) { public static void w(String tag, String msg) {
log(android.util.Log.WARN, tag, msg, null); log(android.util.Log.WARN, tag, msg, null);
android.util.Log.w(tag, msg); android.util.Log.w(tag, msg);
} }
/**
* @deprecated A default tag is provided by {@link Log.w}
*/
@Deprecated @Deprecated
public static void w(String tag, String msg, Throwable tr) { public static void w(String tag, String msg, Throwable tr) {
log(android.util.Log.WARN, tag, msg, tr); log(android.util.Log.WARN, tag, msg, tr);

View File

@ -3,9 +3,9 @@ package com.cradle.iitc_mobile.async;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log;
import com.cradle.iitc_mobile.IITC_Mobile; import com.cradle.iitc_mobile.IITC_Mobile;
import com.cradle.iitc_mobile.Log;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
@ -38,7 +38,7 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
response = httpclient.execute(httpRequest); response = httpclient.execute(httpRequest);
int code = response.getStatusLine().getStatusCode(); int code = response.getStatusLine().getStatusCode();
if (code != HttpStatus.SC_OK) { if (code != HttpStatus.SC_OK) {
Log.d("iitcm", "received error code: " + code); Log.d("received error code: " + code);
mIitc.runOnUiThread(new Runnable() { mIitc.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -62,7 +62,7 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
@Override @Override
protected void onPostExecute(Boolean aBoolean) { protected void onPostExecute(Boolean aBoolean) {
if (aBoolean) { if (aBoolean) {
Log.d("iitcm", "google auth error, redirecting to work-around page"); Log.d("google auth error, redirecting to work-around page");
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mIitc); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mIitc);
// set title // set title

View File

@ -1,7 +1,8 @@
package com.cradle.iitc_mobile.async; package com.cradle.iitc_mobile.async;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log;
import com.cradle.iitc_mobile.Log;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -31,7 +32,7 @@ public class DownloadTile extends AsyncTask<String, Void, Boolean> {
if (conn.getLastModified() < file.lastModified()) return true; if (conn.getLastModified() < file.lastModified()) return true;
InputStream is = null; InputStream is = null;
is = conn.getInputStream(); is = conn.getInputStream();
Log.d("iitcm", "writing to file: " + file.toString()); Log.d("writing to file: " + file.toString());
writeTileToFile(is, file); writeTileToFile(is, file);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();