From ab572055e326bddba5d3666c26a3f07e6e8d034c Mon Sep 17 00:00:00 2001 From: fkloft Date: Fri, 3 Jan 2014 17:16:08 +0100 Subject: [PATCH] Use custom Log --- .../cradle/iitc_mobile/IITC_FileManager.java | 5 ++- .../cradle/iitc_mobile/IITC_JSInterface.java | 5 ++- .../com/cradle/iitc_mobile/IITC_Mobile.java | 19 +++++------ .../IITC_PluginPreferenceActivity.java | 9 +++-- .../com/cradle/iitc_mobile/IITC_WebView.java | 9 +++-- .../iitc_mobile/IITC_WebViewClient.java | 11 ++----- mobile/src/com/cradle/iitc_mobile/Log.java | 33 +++++++++++++++++++ .../iitc_mobile/async/CheckHttpResponse.java | 6 ++-- .../iitc_mobile/async/DownloadTile.java | 5 +-- 9 files changed, 63 insertions(+), 39 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_FileManager.java b/mobile/src/com/cradle/iitc_mobile/IITC_FileManager.java index a1a0bdce..b28bb735 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_FileManager.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_FileManager.java @@ -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; } } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java index 7d1f2b7b..fbfcc177 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java @@ -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 diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 287d7bbf..6e7b365c 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -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); } } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java index 14681ecc..0901fb66 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java @@ -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>(); 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()); - 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 diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index 00cd0464..8a06ba23 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -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); } } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index c2337785..885ba36c 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -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; diff --git a/mobile/src/com/cradle/iitc_mobile/Log.java b/mobile/src/com/cradle/iitc_mobile/Log.java index e7740d07..0ae0bd26 100644 --- a/mobile/src/com/cradle/iitc_mobile/Log.java +++ b/mobile/src/com/cradle/iitc_mobile/Log.java @@ -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); diff --git a/mobile/src/com/cradle/iitc_mobile/async/CheckHttpResponse.java b/mobile/src/com/cradle/iitc_mobile/async/CheckHttpResponse.java index 619c6c11..351187c6 100644 --- a/mobile/src/com/cradle/iitc_mobile/async/CheckHttpResponse.java +++ b/mobile/src/com/cradle/iitc_mobile/async/CheckHttpResponse.java @@ -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 { 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 { @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 diff --git a/mobile/src/com/cradle/iitc_mobile/async/DownloadTile.java b/mobile/src/com/cradle/iitc_mobile/async/DownloadTile.java index 8646f880..ebf99d73 100644 --- a/mobile/src/com/cradle/iitc_mobile/async/DownloadTile.java +++ b/mobile/src/com/cradle/iitc_mobile/async/DownloadTile.java @@ -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 { 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();