From 5d5d6ae8aeafbba407b9a4cf5985a1cdc1cf2904 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Thu, 11 Jan 2018 19:41:28 +0100 Subject: rename variables to CamelCase --- .../main/java/se/leap/bitmaskclient/eip/EIP.java | 58 ++++++++++---------- .../leap/bitmaskclient/eip/VpnConfigGenerator.java | 64 +++++++++++----------- 2 files changed, 61 insertions(+), 61 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/eip') diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 998d2c87..a2ac9d66 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -63,8 +63,8 @@ public final class EIP extends IntentService { private static ResultReceiver mReceiver; private static SharedPreferences preferences; - private static JSONObject eip_definition; - private static GatewaysManager gateways_manager = new GatewaysManager(); + private static JSONObject eipDefinition; + private static GatewaysManager gatewaysManager = new GatewaysManager(); private static Gateway gateway; public EIP() { @@ -76,8 +76,8 @@ public final class EIP extends IntentService { super.onCreate(); context = getApplicationContext(); preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); - eip_definition = eipDefinitionFromPreferences(); - if (gateways_manager.isEmpty()) + eipDefinition = eipDefinitionFromPreferences(); + if (gatewaysManager.isEmpty()) gatewaysFromPreferences(); } @@ -106,13 +106,13 @@ public final class EIP extends IntentService { * It also sets up early routes. */ private void startEIP() { - if (gateways_manager.isEmpty()) + if (gatewaysManager.isEmpty()) updateEIPService(); if (!EipStatus.getInstance().isBlockingVpnEstablished()) { earlyRoutes(); } - gateway = gateways_manager.select(); + gateway = gatewaysManager.select(); if (gateway != null && gateway.getProfile() != null) { mReceiver = VpnFragment.getReceiver(); launchActiveGateway(); @@ -128,10 +128,10 @@ public final class EIP extends IntentService { private void startAlwaysOnEIP() { Log.d(TAG, "startAlwaysOnEIP vpn"); - if (gateways_manager.isEmpty()) + if (gatewaysManager.isEmpty()) updateEIPService(); - gateway = gateways_manager.select(); + gateway = gatewaysManager.select(); if (gateway != null && gateway.getProfile() != null) { //mReceiver = VpnFragment.getReceiver(); @@ -147,9 +147,9 @@ public final class EIP extends IntentService { * VpnService is started properly. */ private void earlyRoutes() { - Intent void_vpn_launcher = new Intent(context, VoidVpnLauncher.class); - void_vpn_launcher.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(void_vpn_launcher); + Intent voidVpnLauncher = new Intent(context, VoidVpnLauncher.class); + voidVpnLauncher.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(voidVpnLauncher); } private void launchActiveGateway() { @@ -162,12 +162,12 @@ public final class EIP extends IntentService { } private void stopEIP() { - EipStatus eip_status = EipStatus.getInstance(); - int result_code = Activity.RESULT_CANCELED; - if (eip_status.isConnected() || eip_status.isConnecting()) - result_code = Activity.RESULT_OK; + EipStatus eipStatus = EipStatus.getInstance(); + int resultCode = Activity.RESULT_CANCELED; + if (eipStatus.isConnected() || eipStatus.isConnecting()) + resultCode = Activity.RESULT_OK; - tellToReceiver(EIP_ACTION_STOP, result_code); + tellToReceiver(EIP_ACTION_STOP, resultCode); } /** @@ -176,8 +176,8 @@ public final class EIP extends IntentService { * request if it's not connected, Activity.RESULT_OK otherwise. */ private void isRunning() { - EipStatus eip_status = EipStatus.getInstance(); - int resultCode = (eip_status.isConnected()) ? + EipStatus eipStatus = EipStatus.getInstance(); + int resultCode = (eipStatus.isConnected()) ? Activity.RESULT_OK : Activity.RESULT_CANCELED; tellToReceiver(EIP_ACTION_IS_RUNNING, resultCode); @@ -188,8 +188,8 @@ public final class EIP extends IntentService { * TODO Implement API call to refresh eip-service.json from the provider */ private void updateEIPService() { - eip_definition = eipDefinitionFromPreferences(); - if (eip_definition.length() > 0) + eipDefinition = eipDefinitionFromPreferences(); + if (eipDefinition.length() > 0) updateGateways(); tellToReceiver(EIP_ACTION_UPDATE, Activity.RESULT_OK); } @@ -197,9 +197,9 @@ public final class EIP extends IntentService { private JSONObject eipDefinitionFromPreferences() { JSONObject result = new JSONObject(); try { - String eip_definition_string = preferences.getString(PROVIDER_KEY, ""); - if (!eip_definition_string.isEmpty()) { - result = new JSONObject(eip_definition_string); + String eipDefinitionString = preferences.getString(PROVIDER_KEY, ""); + if (!eipDefinitionString.isEmpty()) { + result = new JSONObject(eipDefinitionString); } } catch (JSONException e) { // TODO Auto-generated catch block @@ -209,20 +209,20 @@ public final class EIP extends IntentService { } private void updateGateways() { - gateways_manager.clearGatewaysAndProfiles(); - gateways_manager.fromEipServiceJson(eip_definition); + gatewaysManager.clearGatewaysAndProfiles(); + gatewaysManager.fromEipServiceJson(eipDefinition); gatewaysToPreferences(); } private void gatewaysFromPreferences() { - String gateways_string = preferences.getString(Gateway.TAG, ""); - gateways_manager = new GatewaysManager(context, preferences); - gateways_manager.addFromString(gateways_string); + String gatewaysString = preferences.getString(Gateway.TAG, ""); + gatewaysManager = new GatewaysManager(context, preferences); + gatewaysManager.addFromString(gatewaysString); preferences.edit().remove(Gateway.TAG).apply(); } private void gatewaysToPreferences() { - String gateways_string = gateways_manager.toString(); + String gateways_string = gatewaysManager.toString(); preferences.edit().putString(Gateway.TAG, gateways_string).commit(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java index b1318def..e9c16dda 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java @@ -32,7 +32,7 @@ public class VpnConfigGenerator { private JSONObject secrets; public final static String TAG = VpnConfigGenerator.class.getSimpleName(); - private final String new_line = System.getProperty("line.separator"); // Platform new line + private final String newLine = System.getProperty("line.separator"); // Platform new line public VpnConfigGenerator(JSONObject general_configuration, JSONObject secrets, JSONObject gateway) { this.general_configuration = general_configuration; @@ -43,25 +43,25 @@ public class VpnConfigGenerator { public String generate() { return generalConfiguration() - + new_line + + newLine + gatewayConfiguration() - + new_line + + newLine + secretsConfiguration() - + new_line + + newLine + androidCustomizations(); } private String generalConfiguration() { - String common_options = ""; + String commonOptions = ""; try { Iterator keys = general_configuration.keys(); while (keys.hasNext()) { String key = keys.next().toString(); - common_options += key + " "; + commonOptions += key + " "; for (String word : String.valueOf(general_configuration.get(key)).split(" ")) - common_options += word + " "; - common_options += new_line; + commonOptions += word + " "; + commonOptions += newLine; } } catch (JSONException e) { @@ -69,31 +69,31 @@ public class VpnConfigGenerator { e.printStackTrace(); } - common_options += "client"; + commonOptions += "client"; - return common_options; + return commonOptions; } private String gatewayConfiguration() { String remotes = ""; - String ip_address_keyword = "ip_address"; - String remote_keyword = "remote"; - String ports_keyword = "ports"; - String protocol_keyword = "protocols"; - String capabilities_keyword = "capabilities"; + String ipAddressKeyword = "ip_address"; + String remoteKeyword = "remote"; + String portsKeyword = "ports"; + String protocolKeyword = "protocols"; + String capabilitiesKeyword = "capabilities"; try { - String ip_address = gateway.getString(ip_address_keyword); - JSONObject capabilities = gateway.getJSONObject(capabilities_keyword); - JSONArray ports = capabilities.getJSONArray(ports_keyword); + String ip_address = gateway.getString(ipAddressKeyword); + JSONObject capabilities = gateway.getJSONObject(capabilitiesKeyword); + JSONArray ports = capabilities.getJSONArray(portsKeyword); for (int i = 0; i < ports.length(); i++) { String port_specific_remotes = ""; int port = ports.getInt(i); - JSONArray protocols = capabilities.getJSONArray(protocol_keyword); + JSONArray protocols = capabilities.getJSONArray(protocolKeyword); for (int j = 0; j < protocols.length(); j++) { String protocol = protocols.optString(j); - String new_remote = remote_keyword + " " + ip_address + " " + port + " " + protocol + new_line; + String new_remote = remoteKeyword + " " + ip_address + " " + port + " " + protocol + newLine; port_specific_remotes += new_remote; } @@ -103,8 +103,8 @@ public class VpnConfigGenerator { // TODO Auto-generated catch block e.printStackTrace(); } - if (remotes.endsWith(new_line)) { - remotes = remotes.substring(0, remotes.lastIndexOf(new_line)); + if (remotes.endsWith(newLine)) { + remotes = remotes.substring(0, remotes.lastIndexOf(newLine)); } return remotes; } @@ -113,26 +113,26 @@ public class VpnConfigGenerator { try { String ca = "" - + new_line + + newLine + secrets.getString(Provider.CA_CERT) - + new_line + + newLine + ""; String key = "" - + new_line + + newLine + secrets.getString(Constants.PROVIDER_PRIVATE_KEY) - + new_line + + newLine + ""; - String openvpn_cert = + String openvpnCert = "" - + new_line + + newLine + secrets.getString(Constants.PROVIDER_VPN_CERTIFICATE) - + new_line + + newLine + ""; - return ca + new_line + key + new_line + openvpn_cert; + return ca + newLine + key + newLine + openvpnCert; } catch (JSONException e) { e.printStackTrace(); return ""; @@ -142,9 +142,9 @@ public class VpnConfigGenerator { private String androidCustomizations() { return "remote-cert-tls server" - + new_line + + newLine + "persist-tun" - + new_line + + newLine + "auth-retry nointeract"; } } -- cgit v1.2.3