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.os.Environment;
import android.preference.PreferenceManager;
import android.util.Log;
import android.webkit.WebResourceResponse;
import org.json.JSONObject;
@ -131,7 +130,7 @@ public class IITC_FileManager {
private WebResourceResponse getUserPlugin(Uri uri) {
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;
}
@ -193,7 +192,7 @@ public class IITC_FileManager {
if ("user-plugin".equals(host))
return getUserPlugin(uri);
Log.e("iitcm", "could not generate response for url: " + url);
Log.e("could not generate response for url: " + url);
return EMPTY;
}
}

View File

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

View File

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

View File

@ -6,7 +6,6 @@ import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -52,7 +51,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
// since the plugins container is static,
// it is enough to parse the plugin only on first start.
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>>();
setUpPluginPreferenceScreen();
} else {
@ -148,7 +147,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
numPlugins += entry.getValue().size();
}
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();
setUpPluginPreferenceScreen();
}
@ -186,7 +185,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
s = new Scanner(file).useDelimiter("\\A");
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.d("iitcm", "failed to parse file " + file);
Log.d("failed to parse file " + file);
}
if (s != null) {
src = s.hasNext() ? s.next() : "";
@ -225,7 +224,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
// first check if we need a new category
if (!sPlugins.containsKey(plugin_cat)) {
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

View File

@ -9,7 +9,6 @@ import android.net.NetworkInfo;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.webkit.WebSettings;
@ -112,7 +111,7 @@ public class IITC_WebView extends WebView {
if (url.startsWith("javascript:")) {
// do nothing if script is enabled;
if (mDisableJs) {
Log.d("iitcm", "javascript injection disabled...return");
Log.d("javascript injection disabled...return");
return;
}
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
new CheckHttpResponse(mIitc).execute(url);
Log.d("iitcm", "loading url: " + url);
Log.d("loading url: " + 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
// is clicked
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;
}
}
@ -258,7 +257,7 @@ public class IITC_WebView extends WebView {
public void setUserAgent() {
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);
}
}

View File

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

View File

@ -44,12 +44,18 @@ public final class Log {
d(DEFAULT_TAG, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.d}
*/
@Deprecated
public static void d(String tag, String msg) {
log(android.util.Log.DEBUG, tag, msg, null);
android.util.Log.d(tag, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.d}
*/
@Deprecated
public static void d(String tag, String msg, Throwable tr) {
log(android.util.Log.DEBUG, tag, msg, tr);
@ -64,12 +70,18 @@ public final class Log {
e(DEFAULT_TAG, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.e}
*/
@Deprecated
public static void e(String tag, String msg) {
log(android.util.Log.ERROR, tag, msg, null);
android.util.Log.e(tag, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.e}
*/
@Deprecated
public static void e(String tag, String msg, Throwable tr) {
log(android.util.Log.ERROR, tag, msg, tr);
@ -84,12 +96,18 @@ public final class Log {
i(DEFAULT_TAG, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.i}
*/
@Deprecated
public static void i(String tag, String msg) {
log(android.util.Log.INFO, tag, msg, null);
android.util.Log.i(tag, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.i}
*/
@Deprecated
public static void i(String tag, String msg, Throwable tr) {
log(android.util.Log.INFO, tag, msg, tr);
@ -122,6 +140,9 @@ public final class Log {
return println(priority, DEFAULT_TAG, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.println}
*/
@Deprecated
public static int println(int priority, String tag, String msg) {
log(priority, tag, msg, null);
@ -132,12 +153,18 @@ public final class Log {
v(DEFAULT_TAG, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.v}
*/
@Deprecated
public static void v(String tag, String msg) {
log(android.util.Log.VERBOSE, tag, msg, null);
android.util.Log.v(tag, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.v}
*/
@Deprecated
public static void v(String tag, String msg, Throwable tr) {
log(android.util.Log.VERBOSE, tag, msg, tr);
@ -152,12 +179,18 @@ public final class Log {
w(DEFAULT_TAG, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.w}
*/
@Deprecated
public static void w(String tag, String msg) {
log(android.util.Log.WARN, tag, msg, null);
android.util.Log.w(tag, msg);
}
/**
* @deprecated A default tag is provided by {@link Log.w}
*/
@Deprecated
public static void w(String tag, String msg, Throwable 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.content.DialogInterface;
import android.os.AsyncTask;
import android.util.Log;
import com.cradle.iitc_mobile.IITC_Mobile;
import com.cradle.iitc_mobile.Log;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
@ -38,7 +38,7 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
response = httpclient.execute(httpRequest);
int code = response.getStatusLine().getStatusCode();
if (code != HttpStatus.SC_OK) {
Log.d("iitcm", "received error code: " + code);
Log.d("received error code: " + code);
mIitc.runOnUiThread(new Runnable() {
@Override
public void run() {
@ -62,7 +62,7 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
@Override
protected void onPostExecute(Boolean 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);
// set title

View File

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