From 26754ac8c02b3d2faacfdede7c7d04be837fe919 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Fri, 4 Oct 2013 16:03:58 +0200 Subject: [PATCH 1/2] moved some listeners from field attribute to class --- mobile/AndroidManifest.xml | 4 +- .../com/cradle/iitc_mobile/IITC_Mobile.java | 125 +++++++++--------- 2 files changed, 66 insertions(+), 63 deletions(-) diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index 29831632..d8fa1712 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="52" + android:versionName="0.7.2"> Date: Fri, 4 Oct 2013 16:15:58 +0200 Subject: [PATCH 2/2] some code formatting --- .../cradle/iitc_mobile/IITC_JSInterface.java | 4 ++-- .../cradle/iitc_mobile/IITC_MapSettings.java | 24 ++++++++----------- .../com/cradle/iitc_mobile/IITC_Mobile.java | 8 +++---- .../iitc_mobile/IITC_NavigationHelper.java | 20 +++++++--------- .../IITC_PluginPreferenceActivity.java | 8 +++---- .../com/cradle/iitc_mobile/IITC_WebView.java | 2 +- .../iitc_mobile/IITC_WebViewClient.java | 2 +- .../iitc_mobile/async/CheckHttpResponse.java | 6 ++--- .../share/IntentFragmentAdapter.java | 2 +- .../iitc_mobile/share/IntentListView.java | 6 ++--- .../iitc_mobile/share/ShareActivity.java | 2 +- 11 files changed, 37 insertions(+), 47 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java index c26c8e21..93873162 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java @@ -18,7 +18,7 @@ import java.util.Locale; // provide communication between IITC script and android app public class IITC_JSInterface { // context of main activity - private IITC_Mobile mIitc; + private final IITC_Mobile mIitc; IITC_JSInterface(IITC_Mobile iitc) { mIitc = iitc; @@ -111,7 +111,7 @@ public class IITC_JSInterface { @Override public void run() { mIitc.setLoadingState(false); - + mIitc.getMapSettings().onBootFinished(); } }); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java b/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java index c97c65a6..245aefd2 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java @@ -22,7 +22,7 @@ import java.util.Comparator; public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickListener, OnItemLongClickListener { private class HighlighterAdapter extends ArrayAdapter { - private HighlighterComparator mComparator = new HighlighterComparator(); + private final HighlighterComparator mComparator = new HighlighterComparator(); private HighlighterAdapter(int resource) { super(mIitc, resource); @@ -67,8 +67,7 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList } } - private class LayerAdapter extends ArrayAdapter - { + private class LayerAdapter extends ArrayAdapter { public LayerAdapter(int resource) { super(mIitc, resource); } @@ -84,15 +83,15 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList } } - private IITC_Mobile mIitc; + private final IITC_Mobile mIitc; - private ArrayAdapter mHighlighters; - private ArrayAdapter mBaseLayers; - private ArrayAdapter mOverlayLayers; + private final ArrayAdapter mHighlighters; + private final ArrayAdapter mBaseLayers; + private final ArrayAdapter mOverlayLayers; - private Spinner mSpinnerBaseMap; - private Spinner mSpinnerHighlighter; - private ListView mListViewOverlayLayers; + private final Spinner mSpinnerBaseMap; + private final Spinner mSpinnerHighlighter; + private final ListView mListViewOverlayLayers; private String mActiveHighlighter; private int mActiveLayer; @@ -181,8 +180,7 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList if (parent.equals(mSpinnerHighlighter)) { String name = mHighlighters.getItem(position); mIitc.getWebView().loadUrl("javascript: window.changePortalHighlights('" + name + "')"); - } - else if (parent.equals(mSpinnerBaseMap)) { + } else if (parent.equals(mSpinnerBaseMap)) { mBaseLayers.getItem(mActiveLayer).active = false; // set old layer to hidden, but no need to really hide Layer layer = mBaseLayers.getItem(position); @@ -253,7 +251,6 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList mBaseLayers.add(layer); } catch (JSONException e) { e.printStackTrace(); - continue; } } mBaseLayers.notifyDataSetChanged(); @@ -273,7 +270,6 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList mOverlayLayers.add(layer); } catch (JSONException e) { e.printStackTrace(); - continue; } } mOverlayLayers.notifyDataSetChanged(); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 5ebbf450..25c4cb9c 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -283,8 +283,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis if (mReloadNeeded) { Log.d("iitcm", "preference had changed...reload needed"); reloadIITC(); - } - else { + } else { // iitc is not fully booted...timer will be reset by the script itself if (findViewById(R.id.imageLoading).getVisibility() == View.GONE) { mIitcWebView.loadUrl("javascript: window.idleReset();"); @@ -353,7 +352,6 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis if (mBackButtonPressed || !mSharedPrefs.getBoolean("pref_press_twice_to_exit", false)) { super.onBackPressed(); - return; } else { mBackButtonPressed = true; Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show(); @@ -574,7 +572,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis * called by IITC_WebViewClient when the Google login form is opened. */ public void onReceivedLoginRequest(IITC_WebViewClient client, WebView view, - String realm, String account, String args) { + String realm, String account, String args) { mLogin = new IITC_DeviceAccountLogin(this, view, client); mLogin.startLogin(realm, account, args); } @@ -621,8 +619,8 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis } /** - * @deprecated ActionBar related stuff should be handled by IITC_NavigationHelper * @see getNavigationHelper() + * @deprecated ActionBar related stuff should be handled by IITC_NavigationHelper */ @Deprecated @Override diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java b/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java index b7b7f629..1c0af426 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java @@ -60,8 +60,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt view.setText(getPaneTitle(item)); int icon = 0; - switch (item) - { + switch (item) { case MAP: icon = R.drawable.location_map; break; @@ -100,13 +99,13 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt public static final int NOTICE_INFO = 1 << 1; // next one would be 1<<2; (this results in 1,2,4,8,...) - private IITC_Mobile mIitc; - private ActionBar mActionBar; - private SharedPreferences mPrefs; - private NavigationAdapter mNavigationAdapter; - private DrawerLayout mDrawerLayout; - private ListView mDrawerLeft; - private View mDrawerRight; + private final IITC_Mobile mIitc; + private final ActionBar mActionBar; + private final SharedPreferences mPrefs; + private final NavigationAdapter mNavigationAdapter; + private final DrawerLayout mDrawerLayout; + private final ListView mDrawerLeft; + private final View mDrawerRight; private boolean mDesktopMode = false; private boolean mFullscreen = false; @@ -236,8 +235,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt mDrawerLayout.closeDrawers(); } - public String getPaneTitle(Pane pane) - { + public String getPaneTitle(Pane pane) { switch (pane) { case INFO: return "Info"; diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java index 209db065..b8909fca 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java @@ -62,7 +62,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { - if(onIsMultiPane()) getIntent() + if (onIsMultiPane()) getIntent() .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, PluginsFragment.class.getName()); super.onCreate(savedInstanceState); } @@ -76,7 +76,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { // Select the displayed fragment in the headers (when using a tablet) : // This should be done by Android, it is a bug fix // thx to http://stackoverflow.com/a/16793839 - if(mHeaders != null) { + if (mHeaders != null) { final String displayedFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); if (displayedFragment != null) { @@ -227,7 +227,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { // now we have all stuff together and can build the preference // first check if we need a new category - if (sPlugins.containsKey(plugin_cat) == false) { + if (!sPlugins.containsKey(plugin_cat)) { sPlugins.put(plugin_cat, new ArrayList()); Log.d("iitcm", "create " + plugin_cat + " and add " + plugin_name); } @@ -288,7 +288,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { TextView summary; } - private LayoutInflater mInflater; + private final LayoutInflater mInflater; static int getHeaderType(Header header) { if (header.fragment == null && header.intent == null) { diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index c0966c28..affa80c1 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -53,7 +53,7 @@ public class IITC_WebView extends WebView { */ @Override public void onGeolocationPermissionsShowPrompt(String origin, - GeolocationPermissions.Callback callback) { + GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index ca67e9f5..3297447c 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -148,7 +148,7 @@ public class IITC_WebViewClient extends WebViewClient { @Override public void onPageFinished(WebView view, String url) { if (url.startsWith("http://www.ingress.com/intel") - || url.startsWith("https://www.ingress.com/intel")) { + || url.startsWith("https://www.ingress.com/intel")) { Log.d("iitcm", "injecting iitc.."); view.loadUrl("javascript: " + this.mIitcScript); } diff --git a/mobile/src/com/cradle/iitc_mobile/async/CheckHttpResponse.java b/mobile/src/com/cradle/iitc_mobile/async/CheckHttpResponse.java index 057b0c74..dde6e89c 100644 --- a/mobile/src/com/cradle/iitc_mobile/async/CheckHttpResponse.java +++ b/mobile/src/com/cradle/iitc_mobile/async/CheckHttpResponse.java @@ -24,13 +24,13 @@ import java.io.IOException; */ public class CheckHttpResponse extends AsyncTask { - private IITC_JSInterface mJsInterface; - private Context mContext; + private final IITC_JSInterface mJsInterface; + private final Context mContext; public CheckHttpResponse(IITC_JSInterface jsInterface, Context c) { mContext = c; mJsInterface = jsInterface; - }; + } @Override protected Boolean doInBackground(String... urls) { diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentFragmentAdapter.java b/mobile/src/com/cradle/iitc_mobile/share/IntentFragmentAdapter.java index 68743a08..fd803345 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentFragmentAdapter.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentFragmentAdapter.java @@ -8,7 +8,7 @@ import java.util.ArrayList; import java.util.List; public class IntentFragmentAdapter extends FragmentPagerAdapter { - private List mTabs; + private final List mTabs; public IntentFragmentAdapter(FragmentManager fm) { super(fm); diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java index d0a72cc6..9c6b16c1 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java @@ -74,7 +74,7 @@ public class IntentListView extends ListView { private IntentAdapter mAdapter; private PackageManager mPackageManager; - HashMap mActivities = new HashMap(); + private final HashMap mActivities = new HashMap(); public IntentListView(Context context) { super(context); @@ -155,7 +155,6 @@ public class IntentListView extends ListView { if (hasCopyIntent || !activity.name.equals(SendToClipboard.class.getCanonicalName())) { activityList.remove(i); i--; - continue; } } } @@ -172,8 +171,7 @@ public class IntentListView extends ListView { if (resolveInfo.activityInfo.packageName.equals(defaultTarget.activityInfo.packageName) && resolveInfo.activityInfo.name.equals(defaultTarget.activityInfo.name)) { allActivities.add(0, resolveInfo); - } - else { + } else { allActivities.add(resolveInfo); } } diff --git a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java index 71200af3..aeec04cc 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java @@ -108,7 +108,7 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList Intent intent = getIntent(); // from portallinks/permalinks we build 3 intents (share / geo / vanilla-intel-link) - if (intent.getBooleanExtra("onlyShare", false) == false) { + if (!intent.getBooleanExtra("onlyShare", false)) { mTitle = intent.getStringExtra("title"); mLl = intent.getDoubleExtra("lat", 0) + "," + intent.getDoubleExtra("lng", 0); mZoom = intent.getIntExtra("zoom", 0);