diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index d7457937..ed2e7199 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="29" + android:versionName="0.4.8"> { } private Account mAccount; - private AccountAdapter mAccountAdapter; - private AccountManager mAccountManager; + private final AccountAdapter mAccountAdapter; + private final AccountManager mAccountManager; private Account[] mAccounts; - private IITC_Mobile mActivity; + private final IITC_Mobile mActivity; private String mAuthToken; - private AlertDialog mProgressbar; - private WebView mWebView; + private final AlertDialog mProgressbar; + private final WebView mWebView; /** - * This listener is invoked when an item in the account list is selected. (It is also used when the 'cancel' button - * is clicked, (in which case `index` is <0) + * This listener is invoked when an item in the account list is selected. + * (It is also used when the 'cancel' button is clicked, (in which case `index` is <0) */ - private DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() { + private final DialogInterface.OnClickListener onClickListener = + new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int index) { if (index >= 0 && index < mAccounts.length) { @@ -77,7 +78,8 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback { } }; - public IITC_DeviceAccountLogin(IITC_Mobile activity, WebView webView, WebViewClient webViewClient) { + public IITC_DeviceAccountLogin(IITC_Mobile activity, WebView webView, + WebViewClient webViewClient) { mActivity = activity; mWebView = webView; mAccountManager = AccountManager.get(activity); @@ -112,7 +114,7 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback { /** * called to start authenticating using AccountManager. - * + *

* After a token is created, AccountManager will call the run() method. */ private void startAuthentication() { @@ -142,16 +144,17 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback { try { Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT); if (launch != null) { - // There is a reason we need to start the given activity if we want an authentication token. - // (Could be user confirmation or something else. Whatever, we have to start it) - // IITC_Mobile will call it using startActivityForResult + // There is a reason we need to start the given activity if we want an + // authentication token. (Could be user confirmation or something else. Whatever, + // we have to start it) IITC_Mobile will call it using startActivityForResult mActivity.startLoginActivity(launch); return; } String result = value.getResult().getString(AccountManager.KEY_AUTHTOKEN); if (result != null) { - // authentication succeded, we can load the given url, which will redirect back to the intel map + // authentication succeded, we can load the given url, which will redirect + // back to the intel map mWebView.loadUrl(result); mActivity.loginSucceeded(); } else { @@ -164,9 +167,9 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback { /** * start authentication - * - * if we already have a username (e.g. because the existing login has timed out), we can directly start - * authentication if an account with that username is found. + *

+ * if we already have a username (e.g. because the existing login has timed out), + * we can directly start authentication if an account with that username is found. */ public void startLogin(String realm, String accountName, String args) { mAccounts = mAccountManager.getAccountsByType(realm); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java index fc6a7177..8c1527af 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java @@ -1,10 +1,5 @@ package com.cradle.iitc_mobile; -import java.util.HashMap; - -import org.json.JSONArray; -import org.json.JSONException; - import android.app.AlertDialog; import android.content.ClipData; import android.content.ClipboardManager; @@ -18,17 +13,22 @@ import android.util.Log; import android.webkit.JavascriptInterface; import android.widget.Toast; +import org.json.JSONArray; +import org.json.JSONException; + +import java.util.HashMap; + // provide communication between IITC script and android app public class IITC_JSInterface { // context of main activity - Context context; - HashMap layer_ids; - boolean[] overlay_is_active; - int active_base_layer; - String[] overlay_layers, base_layers; - int num_base_layers; - int num_overlay_layers; + private final Context context; + private final HashMap layer_ids; + private boolean[] overlay_is_active; + private int active_base_layer; + private String[] overlay_layers, base_layers; + private int num_base_layers; + private int num_overlay_layers; IITC_JSInterface(Context c) { layer_ids = new HashMap(); @@ -74,28 +74,22 @@ public class IITC_JSInterface { if (id.equals("map")) { button_id = android.R.id.home; title = iitcm.getString(R.string.app_name); - } - else if (id.equals("info")) { + } else if (id.equals("info")) { button_id = R.id.menu_info; title = "Info"; - } - else if (id.equals("full")) { + } else if (id.equals("full")) { button_id = R.id.menu_full; title = "Full"; - } - else if (id.equals("compact")) { + } else if (id.equals("compact")) { button_id = R.id.menu_compact; title = "Compact"; - } - else if (id.equals("public")) { + } else if (id.equals("public")) { button_id = R.id.menu_public; title = "Public"; - } - else if (id.equals("faction")) { + } else if (id.equals("faction")) { button_id = R.id.menu_faction; title = "Faction"; - } - else if (id.equals("debug")) { + } else if (id.equals("debug")) { button_id = R.id.menu_debug; title = "Debug"; } @@ -126,7 +120,8 @@ public class IITC_JSInterface { /* * the layer strings have a form like: - * [{"layerId":27,"name":"MapQuest OSM","active":true},{"layerId":28,"name":"Default Ingress Map","active":false}] + * [{"layerId":27,"name":"MapQuest OSM","active":true}, + * {"layerId":28,"name":"Default Ingress Map","active":false}] * Put it in a JSONArray and parse it */ JSONArray base_layersJSON = null; @@ -167,8 +162,8 @@ public class IITC_JSInterface { String id = ""; String name = ""; boolean isActive = false; - for (int j = 0; j < layers.length; ++j) { - String[] values = layers[j].split(":"); + for (String b_layer : layers) { + String[] values = b_layer.split(":"); if (values[0].contains("active")) isActive = values[1].equals("true"); if (values[0].contains("layerId")) id = values[1]; if (values[0].contains("name")) name = values[1]; @@ -193,8 +188,8 @@ public class IITC_JSInterface { String id = ""; String name = ""; boolean isActive = false; - for (int j = 0; j < layers.length; ++j) { - String[] values = layers[j].split(":"); + for (String o_layer : layers) { + String[] values = o_layer.split(":"); if (values[0].contains("active")) isActive = values[1].equals("true"); if (values[0].contains("layerId")) id = values[1]; if (values[0].contains("name")) name = values[1]; @@ -215,32 +210,33 @@ public class IITC_JSInterface { // show all overlay layers in a multi selection list dialog private void show_multi_selection() { // build the layer chooser dialog - AlertDialog.Builder d_m = new AlertDialog.Builder(context); + AlertDialog.Builder d_m = new AlertDialog.Builder(context); OnMultiChoiceClickListener m_listener = new OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { // activate clicked layer - ((IITC_Mobile) context).getWebView().loadUrl("javascript: window.layerChooser.showLayer(" + ((IITC_Mobile) context).getWebView().loadUrl("javascript: " + + "window.layerChooser.showLayer(" + layer_ids.get(overlay_layers[which]) + "," + overlay_is_active[which] + ");"); } }; - d_m.setMultiChoiceItems(overlay_layers, overlay_is_active , m_listener); + d_m.setMultiChoiceItems(overlay_layers, overlay_is_active, m_listener); // switch to base layers d_m.setPositiveButton("Base Layers", new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - show_single_selection(); - dialog.cancel(); - } + @Override + public void onClick(DialogInterface dialog, int which) { + show_single_selection(); + dialog.cancel(); + } }); d_m.setNegativeButton("Close", new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.cancel(); - } + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); + } }); d_m.setTitle("Overlay Layers"); d_m.show(); @@ -252,11 +248,12 @@ public class IITC_JSInterface { @Override public void onClick(DialogInterface dialog, int which) { // activate clicked layer - ((IITC_Mobile) context).getWebView().loadUrl("javascript: window.layerChooser.showLayer(" + ((IITC_Mobile) context).getWebView().loadUrl("javascript: " + + "window.layerChooser.showLayer(" + layer_ids.get(base_layers[which]) + "," + true + ");"); active_base_layer = which; - } + } }; AlertDialog.Builder d_s = new AlertDialog.Builder(context); d_s.setSingleChoiceItems(base_layers, active_base_layer, s_listener); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 3ef78e20..908dd98c 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -1,8 +1,5 @@ package com.cradle.iitc_mobile; -import java.io.IOException; -import java.util.ArrayList; - import android.app.ActionBar; import android.app.Activity; import android.app.SearchManager; @@ -31,13 +28,16 @@ import android.webkit.WebView; import android.widget.SearchView; import android.widget.Toast; +import java.io.IOException; +import java.util.ArrayList; + public class IITC_Mobile extends Activity { private static final int REQUEST_LOGIN = 1; private IITC_WebView iitc_view; private OnSharedPreferenceChangeListener listener; - String intel_url = "https://www.ingress.com/intel"; + private final String intel_url = "https://www.ingress.com/intel"; private boolean is_loc_enabled = false; private Location last_location = null; private LocationManager loc_mngr = null; @@ -49,11 +49,11 @@ public class IITC_Mobile extends Activity { private MenuItem searchMenuItem; private boolean desktop = false; private boolean reload_needed = false; - private ArrayList dialogStack = new ArrayList(); + private final ArrayList dialogStack = new ArrayList(); private SharedPreferences sharedPref; // Used for custom back stack handling - private ArrayList backStack = new ArrayList(); + private final ArrayList backStack = new ArrayList(); private boolean backStack_push = true; private int currentPane = android.R.id.home; private boolean back_button_pressed = false; @@ -92,8 +92,7 @@ public class IITC_Mobile extends Activity { if (desktop) { setActionBarHomeEnabledWithUp(false); actionBar.setTitle(getString(R.string.app_name)); - } - else actionBar.setHomeButtonEnabled(true); + } else actionBar.setHomeButtonEnabled(true); invalidateOptionsMenu(); } if (key.equals("pref_user_loc")) @@ -144,7 +143,7 @@ public class IITC_Mobile extends Activity { }; is_loc_enabled = sharedPref.getBoolean("pref_user_loc", false); - if (is_loc_enabled == true) { + if (is_loc_enabled) { // Register the listener with the Location Manager to receive // location updates loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, @@ -206,7 +205,7 @@ public class IITC_Mobile extends Activity { iitc_view.loadUrl("javascript: window.renderUpdateStatus()"); iitc_view.updateCaching(); - if (is_loc_enabled == true) { + if (is_loc_enabled) { // Register the listener with the Location Manager to receive // location updates loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, @@ -224,7 +223,8 @@ public class IITC_Mobile extends Activity { @Override protected void onStop() { - ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager conMan = + (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mobile = conMan .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); @@ -257,7 +257,7 @@ public class IITC_Mobile extends Activity { } Log.d("iitcm", "stopping iitcm"); - if (is_loc_enabled == true) + if (is_loc_enabled) loc_mngr.removeUpdates(loc_listener); super.onStop(); @@ -285,7 +285,8 @@ public class IITC_Mobile extends Activity { "selector.remove();"); return; } - // exit fullscreen mode if it is enabled and action bar is disabled or the back stack is empty + // exit fullscreen mode if it is enabled and action bar is disabled + // or the back stack is empty if (fullscreen_mode && (backStack.isEmpty() || fullscreen_actionbar)) { this.toggleFullscreen(); } else if (!backStack.isEmpty()) { @@ -301,7 +302,7 @@ public class IITC_Mobile extends Activity { new Handler().postDelayed(new Runnable() { @Override public void run() { - back_button_pressed=false; + back_button_pressed = false; } }, 2000); } @@ -375,8 +376,7 @@ public class IITC_Mobile extends Activity { // Handle item selection final int itemId = item.getItemId(); boolean result = handleMenuItemSelected(itemId); - if (!result) return super.onOptionsItemSelected(item); - return true; + return result || super.onOptionsItemSelected(item); } public boolean handleMenuItemSelected(int itemId) { @@ -407,8 +407,9 @@ public class IITC_Mobile extends Activity { iitc_view.loadUrl("javascript: window.show('map');"); // get location from network by default if (!is_loc_enabled) { - iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 15});"); - // if gps location is displayed we can use a better location without any costs + iitc_view.loadUrl("javascript: " + + "window.map.locate({setView : true, maxZoom: 15});"); + // if gps location is displayed we can use a better location without any costs } else { if (last_location != null) iitc_view.loadUrl("javascript: window.map.setView(new L.LatLng(" + @@ -510,8 +511,8 @@ public class IITC_Mobile extends Activity { } /** - * It can occur that in order to authenticate, an external activity has to be launched. (This could for example be a - * confirmation dialog.) + * It can occur that in order to authenticate, an external activity has to be launched. + * (This could for example be a confirmation dialog.) */ public void startLoginActivity(Intent launch) { startActivityForResult(launch, REQUEST_LOGIN); // REQUEST_LOGIN is to recognize the result diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java b/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java index 99cb6424..4ac7efe6 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java @@ -29,7 +29,7 @@ public class IITC_Settings extends Activity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // exit settings when home button (iitc icon) is pressed - case android.R.id.home : + case android.R.id.home: onBackPressed(); return true; default: diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java index 57b46833..f5fab725 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java @@ -6,7 +6,6 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.AssetManager; import android.os.Bundle; import android.os.Environment; -import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; @@ -22,7 +21,7 @@ import java.util.Scanner; public class IITC_SettingsFragment extends PreferenceFragment { - String iitc_version; + private String iitc_version; @Override public void onCreate(Bundle savedInstanceState) { @@ -58,9 +57,9 @@ public class IITC_SettingsFragment extends PreferenceFragment { .setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, - Object newValue) { + Object newValue) { preference.setSummary(getString(R.string.pref_select_iitc_sum) + - " " + (CharSequence) newValue); + " " + newValue); // TODO: update iitc_version when iitc source has // changed return true; @@ -88,12 +87,12 @@ public class IITC_SettingsFragment extends PreferenceFragment { e.printStackTrace(); } - for (int i = 0; i < asset_array.length; i++) { + for (String anAsset_array : asset_array) { // find user plugin name for user readable entries Scanner s = null; String src = ""; try { - s = new Scanner(am.open("plugins/" + asset_array[i])) + s = new Scanner(am.open("plugins/" + anAsset_array)) .useDelimiter("\\A"); } catch (IOException e2) { // TODO Auto-generated catch block @@ -102,7 +101,7 @@ public class IITC_SettingsFragment extends PreferenceFragment { if (s != null) src = s.hasNext() ? s.next() : ""; // now we have all stuff together and can build the pref screen - addPluginPreference(root, src, asset_array[i], false); + addPluginPreference(root, src, anAsset_array, false); } // load additional plugins from /IITC_Mobile/plugins/ @@ -113,23 +112,24 @@ public class IITC_SettingsFragment extends PreferenceFragment { if (files != null) { Scanner s = null; String src = ""; - for (int i = 0; i < files.length; ++i) { + for (File file : files) { try { - s = new Scanner(files[i]).useDelimiter("\\A"); + s = new Scanner(file).useDelimiter("\\A"); } catch (FileNotFoundException e) { e.printStackTrace(); - Log.d("iitcm", "failed to parse file " + files[i]); + Log.d("iitcm", "failed to parse file " + file); } if (s != null) src = s.hasNext() ? s.next() : ""; // now we have all stuff together and can build the pref screen - addPluginPreference(root, src, files[i].toString(), true); + addPluginPreference(root, src, file.toString(), true); } } } - void addPluginPreference(PreferenceScreen root, String src, String plugin_key, boolean additional) { + void addPluginPreference(PreferenceScreen root, String src, String plugin_key, + boolean additional) { // now parse plugin name, description and category String header = src.substring(src.indexOf("==UserScript=="), diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index 2a910f2a..7da1058a 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -11,10 +11,10 @@ import android.os.Build; import android.preference.PreferenceManager; import android.util.AttributeSet; import android.util.Log; +import android.webkit.GeolocationPermissions; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; -import android.webkit.GeolocationPermissions; @SuppressLint("SetJavaScriptEnabled") public class IITC_WebView extends WebView { @@ -26,7 +26,7 @@ public class IITC_WebView extends WebView { // init web view private void iitc_init(Context c) { - if ( this.isInEditMode() ) return; + if (this.isInEditMode()) return; settings = this.getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); @@ -44,12 +44,12 @@ public class IITC_WebView extends WebView { this.setWebChromeClient(new WebChromeClient() { /** * our webchromeclient should share geolocation with the iitc script - * + * * allow access by default */ @Override public void onGeolocationPermissionsShowPrompt(String origin, - GeolocationPermissions.Callback callback) { + GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } @@ -95,8 +95,8 @@ public class IITC_WebView extends WebView { public void loadUrl(String url) { // if in edit text mode, don't load javascript otherwise the keyboard closes. HitTestResult testResult = this.getHitTestResult(); - if (url.startsWith("javascript:") && testResult != null && testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) - { + if (url.startsWith("javascript:") && testResult != null && + testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) { // let window.show(...) interupt input // window.show(...) is called if one of the action bar buttons // is clicked @@ -106,7 +106,7 @@ public class IITC_WebView extends WebView { } } // do nothing if script is enabled; - if (this.disableJS == true) { + if (this.disableJS) { Log.d("iitcm", "javascript injection disabled...return"); return; } @@ -152,7 +152,8 @@ public class IITC_WebView extends WebView { // is ticked as mobile hotspot or not. // --> IITC_WebView.isConnectedToWifi should return 'false' if connected to mobile hotspot if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - return ((wifi.getState() == NetworkInfo.State.CONNECTED) && !conMan.isActiveNetworkMetered()); + return ((wifi.getState() == NetworkInfo.State.CONNECTED) && + !conMan.isActiveNetworkMetered()); } return (wifi.getState() == NetworkInfo.State.CONNECTED); } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 5912002d..993d0e7a 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.net.URL; import java.util.Map; import java.util.Scanner; -import java.util.Set; public class IITC_WebViewClient extends WebViewClient { private static final ByteArrayInputStream style = new ByteArrayInputStream( @@ -35,7 +34,7 @@ public class IITC_WebViewClient extends WebViewClient { private WebResourceResponse iitcjs; private String js = null; private String iitc_path = null; - Context context; + private final Context context; public IITC_WebViewClient(Context c) { this.context = c; @@ -77,7 +76,7 @@ public class IITC_WebViewClient extends WebViewClient { js = this.fileToString(iitc_path + "dev/total-conversion-build.user.js", false); if (js.equals("false")) { - Toast.makeText( context, "File " + iitc_path + + Toast.makeText(context, "File " + iitc_path + "dev/total-conversion-build.user.js not found. " + "Disable developer mode or add iitc files to the dev folder.", Toast.LENGTH_LONG).show(); @@ -126,14 +125,14 @@ public class IITC_WebViewClient extends WebViewClient { iitcjs = new WebResourceResponse("text/javascript", "UTF-8", new ByteArrayInputStream(js.getBytes())); - }; + } // enable https @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, - SslError error) { + SslError error) { handler.proceed(); - }; + } /** * this method is called automatically when the Google login form is opened. @@ -162,15 +161,14 @@ public class IITC_WebViewClient extends WebViewClient { // get the plugin preferences SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(context); - Set plugin_list = sharedPref.getStringSet("pref_plugins", null); boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", false); Map all_prefs = sharedPref.getAll(); // iterate through all plugins - for(Map.Entry entry : all_prefs.entrySet()){ + for (Map.Entry entry : all_prefs.entrySet()) { String plugin = entry.getKey(); - if (plugin.endsWith("user.js") && entry.getValue().toString() == "true") { + if (plugin.endsWith("user.js") && entry.getValue().toString().equals("true")) { // load default iitc plugins if (!plugin.startsWith(iitc_path)) { Log.d("iitcm", "adding plugin " + plugin); @@ -258,15 +256,15 @@ public class IITC_WebViewClient extends WebViewClient { public String removePluginWrapper(String file, boolean asset) { if (!file.endsWith("user.js")) return ""; String js = fileToString(file, asset); - if (js == "false") return ""; + if (js.equals("false")) return ""; js = js.replaceAll("\r\n", "\n"); //convert CR-LF pairs to LF - windows format text files js = js.replaceAll("\r", "\n"); //convert remaining CR to LF - Mac format files(?) String wrapper_start = "function wrapper() {"; String wrapper_end = "} // wrapper end"; String injection_code = "// inject code into site context\n" + - "var script = document.createElement('script');\n" + - "script.appendChild(document.createTextNode('('+ wrapper +')();'));\n" + - "(document.body || document.head || document.documentElement).appendChild(script);"; + "var script = document.createElement('script');\n" + + "script.appendChild(document.createTextNode('('+ wrapper +')();'));\n" + + "(document.body || document.head || document.documentElement).appendChild(script);"; if (js.contains(wrapper_start) && js.contains(wrapper_end) && js.contains(injection_code)) { js = js.replace(wrapper_start, ""); // remove the wrapper function @@ -279,6 +277,7 @@ public class IITC_WebViewClient extends WebViewClient { } return js; } + // Check every external resource if it’s okay to load it and maybe replace // it // with our own content. This is used to block loading Niantic resources @@ -286,7 +285,7 @@ public class IITC_WebViewClient extends WebViewClient { // via http://stackoverflow.com/a/8274881/1684530 @Override public WebResourceResponse shouldInterceptRequest(final WebView view, - String url) { + String url) { if (url.contains("/css/common.css")) { return new WebResourceResponse("text/css", "UTF-8", style); } else if (url.contains("gen_dashboard.js")) { diff --git a/plugins/bookmarks-by-zaso.user.js b/plugins/bookmarks-by-zaso.user.js index 56c06303..b8396a9b 100644 --- a/plugins/bookmarks-by-zaso.user.js +++ b/plugins/bookmarks-by-zaso.user.js @@ -303,18 +303,12 @@ // If it's a map if(typeList == 'bkmrk_maps'){ if(bkmrk['label']==''){ label = bkmrk['latlng']+' ['+bkmrk['z']+']'; } - if (!window.isSmartphone()) - btn_link = ''+label+''; - else - btn_link = ''+label+''; + btn_link = ''+label+''; } // If it's a portal else if(typeList == 'bkmrk_portals'){ var guid = bkmrk['guid']; - if (!window.isSmartphone()) - var btn_link = ''+label+''; - else - var btn_link = ''+label+''; + var btn_link = ''+label+''; } // Create the bookmark elementTemp += '

  • '+btn_remove+btn_link+'
  • ';