some code formatting

This commit is contained in:
Philipp Schaefer 2013-06-16 13:23:41 +02:00
parent b4ccf09437
commit e85a6a98ac
7 changed files with 40 additions and 42 deletions

View File

@ -12,7 +12,7 @@ import android.widget.TextView;
public class IITC_AboutDialogPreference extends DialogPreference {
private Context context;
private final Context context;
public IITC_AboutDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);

View File

@ -54,19 +54,19 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle> {
}
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)
*/
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) {

View File

@ -22,13 +22,13 @@ import android.widget.Toast;
public class IITC_JSInterface {
// context of main activity
Context context;
HashMap<String, String> 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<String, String> 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<String, String>();
@ -167,8 +167,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 +193,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];

View File

@ -37,7 +37,7 @@ public class IITC_Mobile extends Activity {
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<String> dialogStack = new ArrayList<String>();
private final ArrayList<String> dialogStack = new ArrayList<String>();
private SharedPreferences sharedPref;
// Used for custom back stack handling
private ArrayList<Integer> backStack = new ArrayList<Integer>();
private final ArrayList<Integer> backStack = new ArrayList<Integer>();
private boolean backStack_push = true;
private int currentPane = android.R.id.home;
private boolean back_button_pressed = false;
@ -144,7 +144,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 +206,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,
@ -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();
@ -375,8 +375,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) {

View File

@ -22,7 +22,7 @@ import java.util.Scanner;
public class IITC_SettingsFragment extends PreferenceFragment {
String iitc_version;
private String iitc_version;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -60,7 +60,7 @@ public class IITC_SettingsFragment extends PreferenceFragment {
public boolean onPreferenceChange(Preference preference,
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 +88,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 +102,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 <storage-path>/IITC_Mobile/plugins/
@ -113,18 +113,18 @@ 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);
}
}
}

View File

@ -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;
}

View File

@ -35,7 +35,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;
@ -126,14 +126,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) {
handler.proceed();
};
}
/**
* this method is called automatically when the Google login form is opened.
@ -162,7 +162,6 @@ public class IITC_WebViewClient extends WebViewClient {
// get the plugin preferences
SharedPreferences sharedPref = PreferenceManager
.getDefaultSharedPreferences(context);
Set<String> plugin_list = sharedPref.getStringSet("pref_plugins", null);
boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", false);
Map<String, ?> all_prefs = sharedPref.getAll();
@ -170,7 +169,7 @@ public class IITC_WebViewClient extends WebViewClient {
// iterate through all plugins
for(Map.Entry<String, ?> 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,7 +257,7 @@ 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() {";