From 437a33f1d5f57f2e2d65b9842d887aa8b5821908 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 22 Oct 2013 12:12:17 +0200 Subject: [PATCH 1/5] added option: move cache to external storage --- mobile/AndroidManifest.xml | 2 ++ mobile/res/values/strings.xml | 2 ++ mobile/res/xml/preferences.xml | 5 +++++ .../cradle/iitc_mobile/IITC_Application.java | 17 +++++++++++++++++ .../src/com/cradle/iitc_mobile/IITC_Mobile.java | 9 ++++++++- .../com/cradle/iitc_mobile/IITC_WebView.java | 6 ++---- 6 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 mobile/src/com/cradle/iitc_mobile/IITC_Application.java diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index bafbfa1b..e09e2f20 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -14,8 +14,10 @@ + Nice for tablets, looks awful on smartphones Force https Disabling may improve performance + Move cache to external storage + Restart required! Write cache to sdCard. Saves internal storage. External storage has to be mounted. Press back button twice to exit Avoids accidental exits Advanced settings diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index 4e743e35..11729aef 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -56,6 +56,11 @@ android:title="@string/pref_force_https" android:summary="@string/pref_force_https_sum" android:defaultValue="true" /> + Date: Tue, 22 Oct 2013 12:52:11 +0200 Subject: [PATCH 2/5] - changed build script. get rid of mobile-test shell scripts - use git hash as version number for test builds --- mobile-test-revert | 7 ---- mobile-test-setup | 14 ------- mobile/build.xml | 76 +++++++++++++++++++++++++++++++++- mobile/res/values/strings.xml | 8 ++-- mobile/res/xml/preferences.xml | 2 +- 5 files changed, 80 insertions(+), 27 deletions(-) delete mode 100755 mobile-test-revert delete mode 100755 mobile-test-setup diff --git a/mobile-test-revert b/mobile-test-revert deleted file mode 100755 index 902956ab..00000000 --- a/mobile-test-revert +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# reverse of mobile-test-setup - reverts the changes made to AndroidManifest.xml and any resource files - -mv mobile/res/values/strings.xml~ mobile/res/values/strings.xml -mv mobile/res/xml/preferences.xml~ mobile/res/xml/preferences.xml - diff --git a/mobile-test-setup b/mobile-test-setup deleted file mode 100755 index f9a1d1e0..00000000 --- a/mobile-test-setup +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# quick-n-dirty script to rename the mobile build for tests - -# rename the app title -test -f mobile/res/values/strings.xml~ || cp mobile/res/values/strings.xml mobile/res/values/strings.xml~ -test -f mobile/res/xml/preferences.xml~ || cp mobile/res/xml/preferences.xml mobile/res/xml/preferences.xml~ -sed -e 's/IITC Mobile/IITCm Test/' mobile/res/values/strings.xml~ > mobile/res/values/strings.xml -sed -e 's/targetPackage="com.cradle.iitc_mobile/targetPackage="com.cradle.iitc_mobile.test/' mobile/res/xml/preferences.xml~ > mobile/res/xml/preferences.xml - - -# also, you'll need to build with -# ant -Doverride.package.name=com.cradle.iitc_mobile.test ... -# or similar diff --git a/mobile/build.xml b/mobile/build.xml index b5dff7df..6584fcbd 100644 --- a/mobile/build.xml +++ b/mobile/build.xml @@ -88,7 +88,7 @@ --> - + + + + + + + + + + + + + git.commits: ${git.commits} + + + + + + git.version: ${git.version} + + + + Creating backup of AndroidManifest.xml + + + + + + + + + Restoring backup of AndroidManifest.xml + + + + + Creating backup of strings.xml and preferences.xml + + + + + + + + Restoring backup of strings.xml and preferences.xml + + + + diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml index b7fc6d6c..f7b2feaf 100644 --- a/mobile/res/values/strings.xml +++ b/mobile/res/values/strings.xml @@ -1,8 +1,8 @@ - IITC Mobile - IITC Mobile Settings + IITCm Test + IITCm Test Settings IITC Plugins Share using… Copy to clipboard @@ -20,13 +20,13 @@ IITC Version About - About IITC Mobile + About IITCm Test Ingress Intel Total Conversion Mobile

by cradle and contributors

Icon by Giuseppe Lucido

- IITC Mobile is an optimized mobile browser for the + IITCm Test is an optimized mobile browser for the Ingress Intel Total Conversion (IITC) userscript by breunigs. After Niantic asked the main developer to shut down his github project, development is continued on a fork of jonatkins.

diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index 11729aef..41baa5c0 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -48,7 +48,7 @@ android:title="@string/pref_plugins" android:persistent="false"> Date: Tue, 22 Oct 2013 13:09:55 +0200 Subject: [PATCH 3/5] - removed test stuff from build.xml - added new build-test.xml for test builds --- mobile/build-test.xml | 205 ++++++++++++++++++++++++++++++++++++++++++ mobile/build.xml | 112 ----------------------- 2 files changed, 205 insertions(+), 112 deletions(-) create mode 100644 mobile/build-test.xml diff --git a/mobile/build-test.xml b/mobile/build-test.xml new file mode 100644 index 00000000..6584fcbd --- /dev/null +++ b/mobile/build-test.xml @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + git.commits: ${git.commits} + + + + + + git.version: ${git.version} + + + + Creating backup of AndroidManifest.xml + + + + + + + + + Restoring backup of AndroidManifest.xml + + + + + Creating backup of strings.xml and preferences.xml + + + + + + + + Restoring backup of strings.xml and preferences.xml + + + + + + + + diff --git a/mobile/build.xml b/mobile/build.xml index 6584fcbd..b8f279b5 100644 --- a/mobile/build.xml +++ b/mobile/build.xml @@ -87,118 +87,6 @@ in order to avoid having your file be overridden by tools such as "android update project" --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - git.commits: ${git.commits} - - - - - - git.version: ${git.version} - - - - Creating backup of AndroidManifest.xml - - - - - - - - - Restoring backup of AndroidManifest.xml - - - - - Creating backup of strings.xml and preferences.xml - - - - - - - - Restoring backup of strings.xml and preferences.xml - - - - From 6f159f6c71302aedbfe2eba2b565f7650e1dba5d Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 22 Oct 2013 13:18:41 +0200 Subject: [PATCH 4/5] reverted wrong commited files --- mobile/res/values/strings.xml | 8 ++++---- mobile/res/xml/preferences.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml index f7b2feaf..b7fc6d6c 100644 --- a/mobile/res/values/strings.xml +++ b/mobile/res/values/strings.xml @@ -1,8 +1,8 @@ - IITCm Test - IITCm Test Settings + IITC Mobile + IITC Mobile Settings IITC Plugins Share using… Copy to clipboard @@ -20,13 +20,13 @@ IITC Version About - About IITCm Test + About IITC Mobile Ingress Intel Total Conversion Mobile

by cradle and contributors

Icon by Giuseppe Lucido

- IITCm Test is an optimized mobile browser for the + IITC Mobile is an optimized mobile browser for the Ingress Intel Total Conversion (IITC) userscript by breunigs. After Niantic asked the main developer to shut down his github project, development is continued on a fork of jonatkins.

diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index 41baa5c0..11729aef 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -48,7 +48,7 @@ android:title="@string/pref_plugins" android:persistent="false"> Date: Tue, 22 Oct 2013 20:05:58 +0200 Subject: [PATCH 5/5] reformat code --- build.py | 2 +- .../iitc_mobile/IITC_DeviceAccountLogin.java | 6 ++- .../cradle/iitc_mobile/IITC_MapSettings.java | 23 ++++++--- .../com/cradle/iitc_mobile/IITC_Mobile.java | 29 +++++++---- .../iitc_mobile/IITC_NavigationHelper.java | 49 ++++++++++++------- .../IITC_PluginPreferenceActivity.java | 21 +++++--- .../com/cradle/iitc_mobile/IITC_WebView.java | 15 +++--- .../iitc_mobile/IITC_WebViewClient.java | 14 ++++-- .../iitc_mobile/fragments/MainSettings.java | 3 +- .../iitc_mobile/share/IntentFragment.java | 3 +- .../iitc_mobile/share/IntentListView.java | 6 ++- .../iitc_mobile/share/ShareActivity.java | 15 ++++-- 12 files changed, 120 insertions(+), 66 deletions(-) diff --git a/build.py b/build.py index 96212c5c..250e502f 100755 --- a/build.py +++ b/build.py @@ -263,7 +263,7 @@ if buildMobile: if buildMobile != 'copyonly': # now launch 'ant' to build the mobile project - retcode = os.system("ant %s -buildfile mobile/build.xml %s" % (antOptions, buildMobile)) + retcode = os.system("ant clean %s -buildfile mobile/build.xml %s" % (antOptions, buildMobile)) if retcode != 0: print ("Error: mobile app failed to build. ant returned %d" % retcode) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_DeviceAccountLogin.java b/mobile/src/com/cradle/iitc_mobile/IITC_DeviceAccountLogin.java index 11cf1518..fb8e1890 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_DeviceAccountLogin.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_DeviceAccountLogin.java @@ -128,10 +128,12 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback { */ public void onActivityResult(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) - // authentication activity succeeded, request token again + // authentication activity succeeded, request token again + { startAuthentication(); - else + } else { onLoginFailed(); + } } /** diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java b/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java index 245aefd2..c683dce9 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java @@ -47,12 +47,13 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList @Override public int compare(String lhs, String rhs) { // Move "No Highlights" on top. Sort the rest alphabetically - if (lhs.equals("No Highlights")) + if (lhs.equals("No Highlights")) { return -1000; - else if (rhs.equals("No Highlights")) + } else if (rhs.equals("No Highlights")) { return 1000; - else + } else { return lhs.compareTo(rhs); + } } } @@ -77,8 +78,9 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList Layer item = getItem(position); View view = (TextView) super.getView(position, convertView, parent); - if (view instanceof CheckedTextView) + if (view instanceof CheckedTextView) { ((CheckedTextView) view).setChecked(item.active); + } return view; } } @@ -128,9 +130,10 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList } private void setLayer(Layer layer) { - if (!mLoading) + if (!mLoading) { mIitc.getWebView().loadUrl( "javascript: window.layerChooser.showLayer(" + layer.id + "," + layer.active + ");"); + } } public void addPortalHighlighter(String name) { @@ -208,8 +211,9 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList mActiveHighlighter = name; int position = mHighlighters.getPosition(mActiveHighlighter); - if (position >= 0 && position < mHighlighters.getCount()) + if (position >= 0 && position < mHighlighters.getCount()) { mSpinnerHighlighter.setSelection(position); + } mIitc.getNavigationHelper().setHighlighter(name); } @@ -245,8 +249,10 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList layer.active = layerObj.getBoolean("active"); if (layer.active) - // getCount() will be the index of the layer we are about to add + // getCount() will be the index of the layer we are about to add + { mActiveLayer = mBaseLayers.getCount(); + } mBaseLayers.add(layer); } catch (JSONException e) { @@ -276,7 +282,8 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList } public void updateLayers() { - if (!mLoading) + if (!mLoading) { mIitc.getWebView().loadUrl("javascript: window.layerChooser.getLayers()"); + } } } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 06122fbd..043be0ec 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -133,8 +133,10 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis || key.equals("pref_share_selected_tab") || key.equals("pref_messages") || key.equals("pref_external_storage")) - // no reload needed + // no reload needed + { return; + } mReloadNeeded = true; } @@ -233,8 +235,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis // parts[0] may contain an 'uncertainty' parameter, delimited by a semicolon String[] pos = parts[0].split(";", 2)[0].split(",", 2); - if (pos.length != 2) + if (pos.length != 2) { throw new URISyntaxException(uri.toString(), "URI does not contain a valid position"); + } try { lat = Double.valueOf(pos[0]); @@ -262,8 +265,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis } String url = "http://www.ingress.com/intel?ll=" + lat + "," + lon; - if (z != null) + if (z != null) { url += "&z=" + z; + } this.loadUrl(url); } @@ -298,8 +302,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis Log.d("iitcm", "stopping iitcm"); mIitcWebView.loadUrl("javascript: window.idleSet();"); - if (mIsLocEnabled) + if (mIsLocEnabled) { mLocMngr.removeUpdates(this); + } super.onStop(); } @@ -383,10 +388,11 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis // ensure no double adds if (pane == mCurrentPane) return; - if (mBackStackPush) + if (mBackStackPush) { mBackStack.push(mCurrentPane); - else + } else { mBackStackPush = true; + } mCurrentPane = pane; mNavigationHelper.switchTo(pane); @@ -433,8 +439,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis @Override public boolean onOptionsItemSelected(MenuItem item) { - if (mNavigationHelper.onOptionsItemSelected(item)) + if (mNavigationHelper.onOptionsItemSelected(item)) { return true; + } // Handle item selection final int itemId = item.getItemId(); @@ -462,10 +469,11 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis "window.map.locate({setView : true, maxZoom: 15});"); // if gps location is displayed we can use a better location without any costs } else { - if (mLastLocation != null) + if (mLastLocation != null) { mIitcWebView.loadUrl("javascript: window.map.setView(new L.LatLng(" + mLastLocation.getLatitude() + "," + mLastLocation.getLongitude() + "), 15);"); + } } return true; case R.id.action_settings: // start settings activity @@ -511,10 +519,11 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis // vp=f enables mDesktopMode mode...vp=m is the defaul mobile view private String addUrlParam(String url) { - if (mDesktopMode) + if (mDesktopMode) { return (url + "?vp=f"); - else + } else { return (url + "?vp=m"); + } } // inject the iitc-script and load the intel url diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java b/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java index 1c0af426..6e78db67 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java @@ -46,18 +46,20 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt add(Pane.PUBLIC); add(Pane.FACTION); - if (mPrefs.getBoolean("pref_advanced_menu", false)) + if (mPrefs.getBoolean("pref_advanced_menu", false)) { add(Pane.DEBUG); + } } @Override public View getView(int position, View convertView, ViewGroup parent) { TextView view = (TextView) super.getView(position, convertView, parent); Pane item = getItem(position); - if (item == Pane.MAP) + if (item == Pane.MAP) { view.setText("Map"); - else + } else { view.setText(getPaneTitle(item)); + } int icon = 0; switch (item) { @@ -84,8 +86,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt break; } - if (icon != 0) + if (icon != 0) { view.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0); + } return view; } @@ -140,8 +143,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt } private void showNotice(final int which) { - if ((mPrefs.getInt("pref_messages", 0) & which) != 0) + if ((mPrefs.getInt("pref_messages", 0) & which) != 0) { return; + } String text; switch (which) { @@ -186,8 +190,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt private void updateActionBar() { int position = mNavigationAdapter.getPosition(mPane); - if (position >= 0 && position < mNavigationAdapter.getCount()) + if (position >= 0 && position < mNavigationAdapter.getCount()) { mDrawerLeft.setItemChecked(position, true); + } if (mDesktopMode) { mActionBar.setDisplayHomeAsUpEnabled(false); // Hide "up" indicator @@ -207,28 +212,32 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt mActionBar.setHomeButtonEnabled(true);// Make icon clickable mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); - if (mPane == Pane.MAP || mDrawerLayout.isDrawerOpen(mDrawerLeft)) + if (mPane == Pane.MAP || mDrawerLayout.isDrawerOpen(mDrawerLeft)) { setDrawerIndicatorEnabled(true); - else + } else { setDrawerIndicatorEnabled(false); + } } - if (mDrawerLayout.isDrawerOpen(mDrawerLeft)) + if (mDrawerLayout.isDrawerOpen(mDrawerLeft)) { mActionBar.setTitle(mIitc.getString(R.string.app_name)); - else + } else { mActionBar.setTitle(getPaneTitle(mPane)); + } } boolean mapVisible = mDesktopMode || mPane == Pane.MAP; - if ("No Highlights".equals(mHighlighter) || isDrawerOpened() || mIsLoading || !mapVisible) + if ("No Highlights".equals(mHighlighter) || isDrawerOpened() || mIsLoading || !mapVisible) { mActionBar.setSubtitle(null); - else + } else { mActionBar.setSubtitle(mHighlighter); + } - if (mFullscreen && mHideInFullscreen) + if (mFullscreen && mHideInFullscreen) { mActionBar.hide(); - else + } else { mActionBar.show(); + } } public void closeDrawers() { @@ -289,16 +298,18 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt Pane item = mNavigationAdapter.getItem(position); mIitc.switchToPane(item); - if (item == Pane.INFO) + if (item == Pane.INFO) { showNotice(NOTICE_INFO); + } mDrawerLayout.closeDrawer(mDrawerLeft); } @Override public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) + if (item.getItemId() == android.R.id.home) { mDrawerLayout.closeDrawer(mDrawerRight); + } return super.onOptionsItemSelected(item); } @@ -315,8 +326,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt } public void openRightDrawer() { - if (mDrawerLayout.getDrawerLockMode(mDrawerRight) == DrawerLayout.LOCK_MODE_UNLOCKED) + if (mDrawerLayout.getDrawerLockMode(mDrawerRight) == DrawerLayout.LOCK_MODE_UNLOCKED) { mDrawerLayout.openDrawer(mDrawerRight); + } } public void reset() { @@ -326,8 +338,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt public void setDebugMode(boolean enabled) { mNavigationAdapter.remove(Pane.DEBUG); // avoid duplicates - if (enabled) + if (enabled) { mNavigationAdapter.add(Pane.DEBUG); + } } public void setFullscreen(boolean fullscreen) { diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java index b8909fca..02ac8ddd 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java @@ -62,8 +62,10 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { - if (onIsMultiPane()) getIntent() - .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, PluginsFragment.class.getName()); + if (onIsMultiPane()) { + getIntent() + .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, PluginsFragment.class.getName()); + } super.onCreate(savedInstanceState); } @@ -162,8 +164,9 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { // TODO Auto-generated catch block e2.printStackTrace(); } - if (s != null) + if (s != null) { src = s.hasNext() ? s.next() : ""; + } // now we have all stuff together and can build the pref screen addPluginPreference(src, anAsset_array, false); } @@ -179,8 +182,9 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { e.printStackTrace(); Log.d("iitcm", "failed to parse file " + file); } - if (s != null) + if (s != null) { src = s.hasNext() ? s.next() : ""; + } // now we have all stuff together and can build the pref screen addPluginPreference(src, file.toString(), true); @@ -202,12 +206,15 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { String plugin_cat = "Misc"; for (int j = 0; j < attributes.length; j++) { // search for name and use the value - if (attributes[j].equals("@name")) + if (attributes[j].equals("@name")) { plugin_name = attributes[j + 1]; - if (attributes[j].equals("@description")) + } + if (attributes[j].equals("@description")) { plugin_desc = attributes[j + 1]; - if (attributes[j].equals("@category")) + } + if (attributes[j].equals("@category")) { plugin_cat = attributes[j + 1]; + } } // remove IITC plugin prefix from plugin_name diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index 3a9f29d9..f57069c7 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -33,7 +33,6 @@ public class IITC_WebView extends WebView { " Gecko/20130810 Firefox/17.0 Iceweasel/17.0.8"; - // init web view private void iitc_init(Context c) { if (isInEditMode()) return; @@ -136,10 +135,11 @@ public class IITC_WebView extends WebView { // force https if enabled in settings SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(getContext()); - if (sharedPref.getBoolean("pref_force_https", true)) + if (sharedPref.getBoolean("pref_force_https", true)) { url = url.replace("http://", "https://"); - else + } else { url = url.replace("https://", "http://"); + } // disable splash screen if a http error code is responded new CheckHttpResponse(mJsInterface, mContext).execute(url); @@ -157,7 +157,7 @@ public class IITC_WebView extends WebView { } public void updateCaching(boolean login) { - switch(Integer.parseInt(mSharedPrefs.getString("pref_caching", "1"))) { + switch (Integer.parseInt(mSharedPrefs.getString("pref_caching", "1"))) { case 0: mSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); break; @@ -173,8 +173,11 @@ public class IITC_WebView extends WebView { Log.d("iitcm", "not connected to wifi...load tiles from cache"); mSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); } else { - if (login) Log.d("iitcm", "login...load tiles from network"); - else Log.d("iitcm", "connected to wifi...load tiles from network"); + if (login) { + Log.d("iitcm", "login...load tiles from network"); + } else { + Log.d("iitcm", "connected to wifi...load tiles from network"); + } mSettings.setCacheMode(WebSettings.LOAD_DEFAULT); } break; diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index a41835ae..cd307a35 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -50,9 +50,10 @@ public class IITC_WebViewClient extends WebViewClient { public String getIITCVersion() { String header = ""; - if (mIitcScript != null) + if (mIitcScript != null) { header = mIitcScript.substring(mIitcScript.indexOf("==UserScript=="), mIitcScript.indexOf("==/UserScript==")); + } // remove new line comments header = header.replace("\n//", ""); // get a list of key-value @@ -60,8 +61,9 @@ public class IITC_WebViewClient extends WebViewClient { String iitc_version = "not found"; for (int i = 0; i < attributes.length; i++) { // search for version and use the value - if (attributes[i].equals("@version")) + if (attributes[i].equals("@version")) { iitc_version = attributes[i + 1]; + } } return iitc_version; } @@ -201,10 +203,11 @@ public class IITC_WebViewClient extends WebViewClient { // load it as javascript public boolean loadJS(String file, boolean asset, WebView view) { String js = fileToString(file, asset); - if (js.equals("false")) + if (js.equals("false")) { return false; - else + } else { view.loadUrl("javascript:" + js); + } return true; } @@ -235,8 +238,9 @@ public class IITC_WebViewClient extends WebViewClient { } } - if (s != null) + if (s != null) { src = s.hasNext() ? s.next() : ""; + } return src; } diff --git a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java index 49af96ea..c904385a 100644 --- a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java +++ b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java @@ -75,8 +75,9 @@ public class MainSettings extends PreferenceFragment { // thx to http://stackoverflow.com/a/16800527/2638486 !! @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { - if (preference.getTitle().toString().equals(getString(R.string.pref_advanced_options))) + if (preference.getTitle().toString().equals(getString(R.string.pref_advanced_options))) { initializeActionBar((PreferenceScreen) preference); + } return super.onPreferenceTreeClick(preferenceScreen, preference); } diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java b/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java index b1b15682..5a181099 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java @@ -33,8 +33,9 @@ public class IntentFragment extends Fragment implements OnScrollListener, OnItem mIntents = args.getParcelableArrayList("intents"); mListView = new IntentListView(getActivity()); mListView.setIntents(mIntents); - if (mScrollIndex != -1 && mScrollTop != -1) + if (mScrollIndex != -1 && mScrollTop != -1) { mListView.setSelectionFromTop(mScrollIndex, mScrollTop); + } mListView.setOnScrollListener(this); mListView.setOnItemClickListener(this); diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java index 9c6b16c1..621f023c 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java @@ -60,8 +60,9 @@ public class IntentListView extends ListView { private static final HashSet KNOWN_COPY_HANDLERS = new HashSet(); private static void setupKnownCopyHandlers() { - if (!KNOWN_COPY_HANDLERS.isEmpty()) + if (!KNOWN_COPY_HANDLERS.isEmpty()) { return; + } KNOWN_COPY_HANDLERS.add(new CopyHandler( "com.google.android.apps.docs", @@ -141,8 +142,9 @@ public class IntentListView extends ListView { for (ResolveInfo resolveInfo : activityList) { // search for "Copy to clipboard" handler CopyHandler handler = new CopyHandler(resolveInfo); - if (KNOWN_COPY_HANDLERS.contains(handler)) + if (KNOWN_COPY_HANDLERS.contains(handler)) { hasCopyIntent = true; + } } // use traditional loop since list may change during iteration diff --git a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java index 9e23bb50..fdb1d49f 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java @@ -45,15 +45,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList private String getUrl() { String url = "http://www.ingress.com/intel?ll=" + mLl + "&z=" + mZoom; - if (mIsPortal) + if (mIsPortal) { url += "&pll=" + mLl; + } return url; } private void setSelected(int position) { // Activity not fully loaded yet (may occur during tab creation) - if (mSharedPrefs == null) + if (mSharedPrefs == null) { return; + } mSharedPrefs .edit() @@ -125,8 +127,9 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { - if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD) + if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD) { actionBar.setSelectedNavigationItem(position); + } setSelected(position); } }); @@ -141,15 +144,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList .setTabListener(this)); } - if (mFragmentAdapter.getCount() > 1) + if (mFragmentAdapter.getCount() > 1) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); + } mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); int selected = mSharedPrefs.getInt("pref_share_selected_tab", 0); if (selected < mFragmentAdapter.getCount()) { mViewPager.setCurrentItem(selected); - if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD) + if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD) { actionBar.setSelectedNavigationItem(selected); + } } }