Code formatting, add final modifiers
This commit is contained in:
@ -25,25 +25,25 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
private static final ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes());
|
||||
private static final String DOMAIN = IITC_FileManager.DOMAIN;
|
||||
|
||||
private String mIitcPath;
|
||||
private final String mIitcPath;
|
||||
private boolean mIitcInjected = false;
|
||||
private final IITC_Mobile mIitc;
|
||||
private final IITC_TileManager mTileManager;
|
||||
|
||||
public IITC_WebViewClient(IITC_Mobile iitc) {
|
||||
this.mIitc = iitc;
|
||||
this.mTileManager = new IITC_TileManager(mIitc);
|
||||
this.mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/";
|
||||
public IITC_WebViewClient(final IITC_Mobile iitc) {
|
||||
mIitc = iitc;
|
||||
mTileManager = new IITC_TileManager(mIitc);
|
||||
mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/";
|
||||
}
|
||||
|
||||
// enable https
|
||||
@Override
|
||||
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
||||
public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) {
|
||||
handler.proceed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
public void onPageFinished(final WebView view, final String url) {
|
||||
if (url.startsWith("http://www.ingress.com/intel")
|
||||
|| url.startsWith("https://www.ingress.com/intel")) {
|
||||
if (mIitcInjected) return;
|
||||
@ -54,18 +54,18 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
super.onPageFinished(view, url);
|
||||
}
|
||||
|
||||
private void loadScripts(IITC_WebView view) {
|
||||
List<String> scripts = new LinkedList<String>();
|
||||
private void loadScripts(final IITC_WebView view) {
|
||||
final List<String> scripts = new LinkedList<String>();
|
||||
|
||||
scripts.add("script" + DOMAIN + "/total-conversion-build.user.js");
|
||||
|
||||
// get the plugin preferences
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mIitc);
|
||||
Map<String, ?> all_prefs = sharedPref.getAll();
|
||||
final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mIitc);
|
||||
final Map<String, ?> all_prefs = sharedPref.getAll();
|
||||
|
||||
// iterate through all plugins
|
||||
for (Map.Entry<String, ?> entry : all_prefs.entrySet()) {
|
||||
String plugin = entry.getKey();
|
||||
for (final Map.Entry<String, ?> entry : all_prefs.entrySet()) {
|
||||
final String plugin = entry.getKey();
|
||||
if (plugin.endsWith(".user.js") && entry.getValue().toString().equals("true")) {
|
||||
if (plugin.startsWith(mIitcPath)) {
|
||||
scripts.add("user-plugin" + DOMAIN + plugin);
|
||||
@ -80,7 +80,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
scripts.add("script" + DOMAIN + "/user-location.user.js");
|
||||
}
|
||||
|
||||
String js = "(function(){['" + TextUtils.join("','", scripts) + "'].forEach(function(src) {" +
|
||||
final String js = "(function(){['" + TextUtils.join("','", scripts) + "'].forEach(function(src) {" +
|
||||
"var script = document.createElement('script');script.src = '//'+src;" +
|
||||
"(document.body || document.head || document.documentElement).appendChild(script);" +
|
||||
"});})();";
|
||||
@ -92,7 +92,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
* this method is called automatically when the Google login form is opened.
|
||||
*/
|
||||
@Override
|
||||
public void onReceivedLoginRequest(WebView view, String realm, String account, String args) {
|
||||
public void onReceivedLoginRequest(final WebView view, final String realm, final String account, final String args) {
|
||||
mIitcInjected = false;
|
||||
// Log.d("iitcm", "Login requested: " + realm + " " + account + " " + args);
|
||||
// ((IITC_Mobile) mContext).onReceivedLoginRequest(this, view, realm, account, args);
|
||||
@ -104,7 +104,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
* via http://stackoverflow.com/a/8274881/1684530
|
||||
*/
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(final WebView view, String url) {
|
||||
public WebResourceResponse shouldInterceptRequest(final WebView view, final String url) {
|
||||
// if any tiles are requested, handle it with IITC_TileManager
|
||||
if (url.matches(".*tile.*jpg.*") // mapquest tiles | ovi tiles
|
||||
|| url.matches(".*tile.*png.*") // cloudmade tiles
|
||||
@ -115,7 +115,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
) {
|
||||
try {
|
||||
return mTileManager.getTile(url);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
Log.w(e);
|
||||
return super.shouldInterceptRequest(view, url);
|
||||
}
|
||||
@ -140,8 +140,8 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
return new WebResourceResponse("text/plain", "UTF-8", EMPTY);
|
||||
}
|
||||
|
||||
Uri uri = Uri.parse(url);
|
||||
if (uri.getHost()!=null && uri.getHost().endsWith(DOMAIN) &&
|
||||
final Uri uri = Uri.parse(url);
|
||||
if (uri.getHost() != null && uri.getHost().endsWith(DOMAIN) &&
|
||||
("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())))
|
||||
return mIitc.getFileManager().getResponse(uri);
|
||||
|
||||
@ -150,7 +150,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
|
||||
// start non-ingress-intel-urls in another app...
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
|
||||
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=")
|
||||
@ -161,7 +161,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
return false;
|
||||
} else {
|
||||
Log.d("no ingress intel link, start external app to load url: " + url);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
mIitc.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user