some code formatting
This commit is contained in:
parent
b4ccf09437
commit
e85a6a98ac
@ -12,7 +12,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
public class IITC_AboutDialogPreference extends DialogPreference {
|
public class IITC_AboutDialogPreference extends DialogPreference {
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
|
|
||||||
public IITC_AboutDialogPreference(Context context, AttributeSet attrs) {
|
public IITC_AboutDialogPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
@ -54,19 +54,19 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
private AccountAdapter mAccountAdapter;
|
private final AccountAdapter mAccountAdapter;
|
||||||
private AccountManager mAccountManager;
|
private final AccountManager mAccountManager;
|
||||||
private Account[] mAccounts;
|
private Account[] mAccounts;
|
||||||
private IITC_Mobile mActivity;
|
private final IITC_Mobile mActivity;
|
||||||
private String mAuthToken;
|
private String mAuthToken;
|
||||||
private AlertDialog mProgressbar;
|
private final AlertDialog mProgressbar;
|
||||||
private WebView mWebView;
|
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
|
* 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)
|
* is clicked, (in which case `index` is <0)
|
||||||
*/
|
*/
|
||||||
private DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
|
private final DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int index) {
|
public void onClick(DialogInterface dialog, int index) {
|
||||||
if (index >= 0 && index < mAccounts.length) {
|
if (index >= 0 && index < mAccounts.length) {
|
||||||
|
@ -22,13 +22,13 @@ import android.widget.Toast;
|
|||||||
public class IITC_JSInterface {
|
public class IITC_JSInterface {
|
||||||
|
|
||||||
// context of main activity
|
// context of main activity
|
||||||
Context context;
|
private final Context context;
|
||||||
HashMap<String, String> layer_ids;
|
private final HashMap<String, String> layer_ids;
|
||||||
boolean[] overlay_is_active;
|
private boolean[] overlay_is_active;
|
||||||
int active_base_layer;
|
private int active_base_layer;
|
||||||
String[] overlay_layers, base_layers;
|
private String[] overlay_layers, base_layers;
|
||||||
int num_base_layers;
|
private int num_base_layers;
|
||||||
int num_overlay_layers;
|
private int num_overlay_layers;
|
||||||
|
|
||||||
IITC_JSInterface(Context c) {
|
IITC_JSInterface(Context c) {
|
||||||
layer_ids = new HashMap<String, String>();
|
layer_ids = new HashMap<String, String>();
|
||||||
@ -167,8 +167,8 @@ public class IITC_JSInterface {
|
|||||||
String id = "";
|
String id = "";
|
||||||
String name = "";
|
String name = "";
|
||||||
boolean isActive = false;
|
boolean isActive = false;
|
||||||
for (int j = 0; j < layers.length; ++j) {
|
for (String b_layer : layers) {
|
||||||
String[] values = layers[j].split(":");
|
String[] values = b_layer.split(":");
|
||||||
if (values[0].contains("active")) isActive = values[1].equals("true");
|
if (values[0].contains("active")) isActive = values[1].equals("true");
|
||||||
if (values[0].contains("layerId")) id = values[1];
|
if (values[0].contains("layerId")) id = values[1];
|
||||||
if (values[0].contains("name")) name = values[1];
|
if (values[0].contains("name")) name = values[1];
|
||||||
@ -193,8 +193,8 @@ public class IITC_JSInterface {
|
|||||||
String id = "";
|
String id = "";
|
||||||
String name = "";
|
String name = "";
|
||||||
boolean isActive = false;
|
boolean isActive = false;
|
||||||
for (int j = 0; j < layers.length; ++j) {
|
for (String o_layer : layers) {
|
||||||
String[] values = layers[j].split(":");
|
String[] values = o_layer.split(":");
|
||||||
if (values[0].contains("active")) isActive = values[1].equals("true");
|
if (values[0].contains("active")) isActive = values[1].equals("true");
|
||||||
if (values[0].contains("layerId")) id = values[1];
|
if (values[0].contains("layerId")) id = values[1];
|
||||||
if (values[0].contains("name")) name = values[1];
|
if (values[0].contains("name")) name = values[1];
|
||||||
|
@ -37,7 +37,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
|
|
||||||
private IITC_WebView iitc_view;
|
private IITC_WebView iitc_view;
|
||||||
private OnSharedPreferenceChangeListener listener;
|
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 boolean is_loc_enabled = false;
|
||||||
private Location last_location = null;
|
private Location last_location = null;
|
||||||
private LocationManager loc_mngr = null;
|
private LocationManager loc_mngr = null;
|
||||||
@ -49,11 +49,11 @@ public class IITC_Mobile extends Activity {
|
|||||||
private MenuItem searchMenuItem;
|
private MenuItem searchMenuItem;
|
||||||
private boolean desktop = false;
|
private boolean desktop = false;
|
||||||
private boolean reload_needed = false;
|
private boolean reload_needed = false;
|
||||||
private ArrayList<String> dialogStack = new ArrayList<String>();
|
private final ArrayList<String> dialogStack = new ArrayList<String>();
|
||||||
private SharedPreferences sharedPref;
|
private SharedPreferences sharedPref;
|
||||||
|
|
||||||
// Used for custom back stack handling
|
// 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 boolean backStack_push = true;
|
||||||
private int currentPane = android.R.id.home;
|
private int currentPane = android.R.id.home;
|
||||||
private boolean back_button_pressed = false;
|
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);
|
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
|
// Register the listener with the Location Manager to receive
|
||||||
// location updates
|
// location updates
|
||||||
loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||||
@ -206,7 +206,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
iitc_view.loadUrl("javascript: window.renderUpdateStatus()");
|
iitc_view.loadUrl("javascript: window.renderUpdateStatus()");
|
||||||
iitc_view.updateCaching();
|
iitc_view.updateCaching();
|
||||||
|
|
||||||
if (is_loc_enabled == true) {
|
if (is_loc_enabled) {
|
||||||
// Register the listener with the Location Manager to receive
|
// Register the listener with the Location Manager to receive
|
||||||
// location updates
|
// location updates
|
||||||
loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||||
@ -257,7 +257,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
}
|
}
|
||||||
Log.d("iitcm", "stopping iitcm");
|
Log.d("iitcm", "stopping iitcm");
|
||||||
|
|
||||||
if (is_loc_enabled == true)
|
if (is_loc_enabled)
|
||||||
loc_mngr.removeUpdates(loc_listener);
|
loc_mngr.removeUpdates(loc_listener);
|
||||||
|
|
||||||
super.onStop();
|
super.onStop();
|
||||||
@ -375,8 +375,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
// Handle item selection
|
// Handle item selection
|
||||||
final int itemId = item.getItemId();
|
final int itemId = item.getItemId();
|
||||||
boolean result = handleMenuItemSelected(itemId);
|
boolean result = handleMenuItemSelected(itemId);
|
||||||
if (!result) return super.onOptionsItemSelected(item);
|
return result || super.onOptionsItemSelected(item);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleMenuItemSelected(int itemId) {
|
public boolean handleMenuItemSelected(int itemId) {
|
||||||
|
@ -22,7 +22,7 @@ import java.util.Scanner;
|
|||||||
|
|
||||||
public class IITC_SettingsFragment extends PreferenceFragment {
|
public class IITC_SettingsFragment extends PreferenceFragment {
|
||||||
|
|
||||||
String iitc_version;
|
private String iitc_version;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -60,7 +60,7 @@ public class IITC_SettingsFragment extends PreferenceFragment {
|
|||||||
public boolean onPreferenceChange(Preference preference,
|
public boolean onPreferenceChange(Preference preference,
|
||||||
Object newValue) {
|
Object newValue) {
|
||||||
preference.setSummary(getString(R.string.pref_select_iitc_sum) +
|
preference.setSummary(getString(R.string.pref_select_iitc_sum) +
|
||||||
" " + (CharSequence) newValue);
|
" " + newValue);
|
||||||
// TODO: update iitc_version when iitc source has
|
// TODO: update iitc_version when iitc source has
|
||||||
// changed
|
// changed
|
||||||
return true;
|
return true;
|
||||||
@ -88,12 +88,12 @@ public class IITC_SettingsFragment extends PreferenceFragment {
|
|||||||
e.printStackTrace();
|
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
|
// find user plugin name for user readable entries
|
||||||
Scanner s = null;
|
Scanner s = null;
|
||||||
String src = "";
|
String src = "";
|
||||||
try {
|
try {
|
||||||
s = new Scanner(am.open("plugins/" + asset_array[i]))
|
s = new Scanner(am.open("plugins/" + anAsset_array))
|
||||||
.useDelimiter("\\A");
|
.useDelimiter("\\A");
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
@ -102,7 +102,7 @@ public class IITC_SettingsFragment extends PreferenceFragment {
|
|||||||
if (s != null)
|
if (s != null)
|
||||||
src = s.hasNext() ? s.next() : "";
|
src = s.hasNext() ? s.next() : "";
|
||||||
// now we have all stuff together and can build the pref screen
|
// 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/
|
// load additional plugins from <storage-path>/IITC_Mobile/plugins/
|
||||||
@ -113,18 +113,18 @@ public class IITC_SettingsFragment extends PreferenceFragment {
|
|||||||
if (files != null) {
|
if (files != null) {
|
||||||
Scanner s = null;
|
Scanner s = null;
|
||||||
String src = "";
|
String src = "";
|
||||||
for (int i = 0; i < files.length; ++i) {
|
for (File file : files) {
|
||||||
try {
|
try {
|
||||||
s = new Scanner(files[i]).useDelimiter("\\A");
|
s = new Scanner(file).useDelimiter("\\A");
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log.d("iitcm", "failed to parse file " + files[i]);
|
Log.d("iitcm", "failed to parse file " + file);
|
||||||
}
|
}
|
||||||
if (s != null)
|
if (s != null)
|
||||||
src = s.hasNext() ? s.next() : "";
|
src = s.hasNext() ? s.next() : "";
|
||||||
|
|
||||||
// now we have all stuff together and can build the pref screen
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class IITC_WebView extends WebView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do nothing if script is enabled;
|
// do nothing if script is enabled;
|
||||||
if (this.disableJS == true) {
|
if (this.disableJS) {
|
||||||
Log.d("iitcm", "javascript injection disabled...return");
|
Log.d("iitcm", "javascript injection disabled...return");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
private WebResourceResponse iitcjs;
|
private WebResourceResponse iitcjs;
|
||||||
private String js = null;
|
private String js = null;
|
||||||
private String iitc_path = null;
|
private String iitc_path = null;
|
||||||
Context context;
|
private final Context context;
|
||||||
|
|
||||||
public IITC_WebViewClient(Context c) {
|
public IITC_WebViewClient(Context c) {
|
||||||
this.context = c;
|
this.context = c;
|
||||||
@ -126,14 +126,14 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
|
|
||||||
iitcjs = new WebResourceResponse("text/javascript", "UTF-8",
|
iitcjs = new WebResourceResponse("text/javascript", "UTF-8",
|
||||||
new ByteArrayInputStream(js.getBytes()));
|
new ByteArrayInputStream(js.getBytes()));
|
||||||
};
|
}
|
||||||
|
|
||||||
// enable https
|
// enable https
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedSslError(WebView view, SslErrorHandler handler,
|
public void onReceivedSslError(WebView view, SslErrorHandler handler,
|
||||||
SslError error) {
|
SslError error) {
|
||||||
handler.proceed();
|
handler.proceed();
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method is called automatically when the Google login form is opened.
|
* 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
|
// get the plugin preferences
|
||||||
SharedPreferences sharedPref = PreferenceManager
|
SharedPreferences sharedPref = PreferenceManager
|
||||||
.getDefaultSharedPreferences(context);
|
.getDefaultSharedPreferences(context);
|
||||||
Set<String> plugin_list = sharedPref.getStringSet("pref_plugins", null);
|
|
||||||
boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", false);
|
boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", false);
|
||||||
|
|
||||||
Map<String, ?> all_prefs = sharedPref.getAll();
|
Map<String, ?> all_prefs = sharedPref.getAll();
|
||||||
@ -170,7 +169,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
// iterate through all plugins
|
// iterate through all plugins
|
||||||
for(Map.Entry<String, ?> entry : all_prefs.entrySet()){
|
for(Map.Entry<String, ?> entry : all_prefs.entrySet()){
|
||||||
String plugin = entry.getKey();
|
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
|
// load default iitc plugins
|
||||||
if (!plugin.startsWith(iitc_path)) {
|
if (!plugin.startsWith(iitc_path)) {
|
||||||
Log.d("iitcm", "adding plugin " + plugin);
|
Log.d("iitcm", "adding plugin " + plugin);
|
||||||
@ -258,7 +257,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
public String removePluginWrapper(String file, boolean asset) {
|
public String removePluginWrapper(String file, boolean asset) {
|
||||||
if (!file.endsWith("user.js")) return "";
|
if (!file.endsWith("user.js")) return "";
|
||||||
String js = fileToString(file, asset);
|
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", "\n"); //convert CR-LF pairs to LF - windows format text files
|
||||||
js = js.replaceAll("\r", "\n"); //convert remaining CR to LF - Mac format files(?)
|
js = js.replaceAll("\r", "\n"); //convert remaining CR to LF - Mac format files(?)
|
||||||
String wrapper_start = "function wrapper() {";
|
String wrapper_start = "function wrapper() {";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user