summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java25
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java115
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java20
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java16
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderManager.java76
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/VpnFragment.java91
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java58
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java64
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java32
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java8
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java46
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/NewProviderDialog.java22
13 files changed, 286 insertions, 289 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
index 6d69b71a..c180e43a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
@@ -42,20 +42,20 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity
preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE);
try {
- JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
- domain.setText(provider_json.getString(Provider.DOMAIN));
- name.setText(provider_json.getJSONObject(Provider.NAME).getString("en"));
- description.setText(provider_json.getJSONObject(Provider.DESCRIPTION).getString("en"));
+ JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, ""));
+ domain.setText(providerJson.getString(Provider.DOMAIN));
+ name.setText(providerJson.getJSONObject(Provider.NAME).getString("en"));
+ description.setText(providerJson.getJSONObject(Provider.DESCRIPTION).getString("en"));
setTitle(R.string.provider_details_title);
// Show only the options allowed by the provider
ArrayList<String> optionsList = new ArrayList<>();
- if (registration_allowed(provider_json)) {
+ if (registrationAllowed(providerJson)) {
optionsList.add(getString(R.string.login_button));
optionsList.add(getString(R.string.signup_button));
}
- if (anon_allowed(provider_json)) {
+ if (anonAllowed(providerJson)) {
optionsList.add(getString(R.string.use_anonymously_button));
}
@@ -77,6 +77,7 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity
Log.d(TAG, "signup selected");
intent = new Intent(getApplicationContext(), SignupActivity.class);
} else {
+ Log.d(TAG, "use anonymously selected");
intent = new Intent(getApplicationContext(), MainActivity.class);
}
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
@@ -88,19 +89,19 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity
}
}
- private boolean anon_allowed(JSONObject provider_json) {
+ private boolean anonAllowed(JSONObject providerJson) {
try {
- JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- return service_description.has(Constants.PROVIDER_ALLOW_ANONYMOUS) && service_description.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS);
+ JSONObject serviceDescription = providerJson.getJSONObject(Provider.SERVICE);
+ return serviceDescription.has(Constants.PROVIDER_ALLOW_ANONYMOUS) && serviceDescription.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS);
} catch (JSONException e) {
return false;
}
}
- private boolean registration_allowed(JSONObject provider_json) {
+ private boolean registrationAllowed(JSONObject providerJson) {
try {
- JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- return service_description.has(Provider.ALLOW_REGISTRATION) && service_description.getBoolean(Provider.ALLOW_REGISTRATION);
+ JSONObject serviceDescription = providerJson.getJSONObject(Provider.SERVICE);
+ return serviceDescription.has(Provider.ALLOW_REGISTRATION) && serviceDescription.getBoolean(Provider.ALLOW_REGISTRATION);
} catch (JSONException e) {
return false;
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
index 0b51af27..915e948a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
@@ -26,7 +26,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentTransaction;
-import android.support.v7.app.AppCompatActivity;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
@@ -48,11 +47,9 @@ import java.util.List;
import javax.inject.Inject;
-import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnItemClick;
import se.leap.bitmaskclient.fragments.AboutFragment;
-import se.leap.bitmaskclient.userstatus.SessionDialog;
import static android.view.View.GONE;
import static android.view.View.INVISIBLE;
@@ -75,16 +72,16 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
@InjectView(R.id.progressbar_configuration_wizard)
protected ProgressBar mProgressBar;
@InjectView(R.id.progressbar_description)
- protected TextView progressbar_description;
+ protected TextView progressbarDescription;
@InjectView(R.id.provider_list)
- protected ListView provider_list_view;
+ protected ListView providerListView;
@Inject
protected ProviderListAdapter adapter;
- private ProviderManager provider_manager;
+ private ProviderManager providerManager;
protected Intent mConfigState = new Intent(PROVIDER_NOT_SET);
- protected Provider selected_provider;
+ protected Provider selectedProvider;
final public static String TAG = ConfigurationWizard.class.getSimpleName();
@@ -99,13 +96,13 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
final private static String PROGRESSBAR_TEXT = TAG + "PROGRESSBAR_TEXT";
final private static String PROGRESSBAR_NUMBER = TAG + "PROGRESSBAR_NUMBER";
- public ProviderAPIResultReceiver providerAPI_result_receiver;
- private ProviderAPIBroadcastReceiver_Update providerAPI_broadcast_receiver_update;
+ public ProviderAPIResultReceiver providerAPIResultReceiver;
+ private BaseConfigurationWizard.providerAPIBroadcastReceiverUpdate providerAPIBroadcastReceiverUpdate;
protected static SharedPreferences preferences;
- FragmentManagerEnhanced fragment_manager;
- //TODO: add some states (values for progressbar_text) about ongoing setup or remove that field
- private String progressbar_text = "";
+ FragmentManagerEnhanced fragmentManager;
+ //TODO: add some states (values for progressbarText) about ongoing setup or remove that field
+ private String progressbarText = "";
@@ -118,17 +115,17 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
List<Renderer<Provider>> prototypes = new ArrayList<>();
prototypes.add(new ProviderRenderer(this));
ProviderRendererBuilder providerRendererBuilder = new ProviderRendererBuilder(prototypes);
- adapter = new ProviderListAdapter(getLayoutInflater(), providerRendererBuilder, provider_manager);
- provider_list_view.setAdapter(adapter);
+ adapter = new ProviderListAdapter(getLayoutInflater(), providerRendererBuilder, providerManager);
+ providerListView.setAdapter(adapter);
}
@Override
protected void onSaveInstanceState(@NotNull Bundle outState) {
if (mProgressBar != null)
outState.putInt(PROGRESSBAR_NUMBER, mProgressBar.getProgress());
- if (progressbar_description != null)
- outState.putString(PROGRESSBAR_TEXT, progressbar_description.getText().toString());
- outState.putParcelable(Provider.KEY, selected_provider);
+ if (progressbarDescription != null)
+ outState.putString(PROGRESSBAR_TEXT, progressbarDescription.getText().toString());
+ outState.putParcelable(Provider.KEY, selectedProvider);
super.onSaveInstanceState(outState);
}
@@ -136,8 +133,8 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE);
- fragment_manager = new FragmentManagerEnhanced(getSupportFragmentManager());
- provider_manager = ProviderManager.getInstance(getAssets(), getExternalFilesDir(null));
+ fragmentManager = new FragmentManagerEnhanced(getSupportFragmentManager());
+ providerManager = ProviderManager.getInstance(getAssets(), getExternalFilesDir(null));
setUpInitialUI();
@@ -149,8 +146,8 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
}
private void restoreState(Bundle savedInstanceState) {
- progressbar_text = savedInstanceState.getString(PROGRESSBAR_TEXT, "");
- selected_provider = savedInstanceState.getParcelable(Provider.KEY);
+ progressbarText = savedInstanceState.getString(PROGRESSBAR_TEXT, "");
+ selectedProvider = savedInstanceState.getParcelable(Provider.KEY);
}
@Override
@@ -172,43 +169,43 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
}
private void hideProgressBar() {
- //needs to be "INVISIBLE" instead of GONE b/c the progressbar_description gets translated
+ //needs to be "INVISIBLE" instead of GONE b/c the progressbarDescription gets translated
// by the height of mProgressbar (and the height of the first list item)
mProgressBar.setVisibility(INVISIBLE);
- progressbar_description.setVisibility(INVISIBLE);
+ progressbarDescription.setVisibility(INVISIBLE);
mProgressBar.setProgress(0);
}
protected void showProgressBar() {
mProgressBar.setVisibility(VISIBLE);
- progressbar_description.setVisibility(VISIBLE);
+ progressbarDescription.setVisibility(VISIBLE);
}
@Override
protected void onDestroy() {
super.onDestroy();
- if (providerAPI_broadcast_receiver_update != null)
- unregisterReceiver(providerAPI_broadcast_receiver_update);
+ if (providerAPIBroadcastReceiverUpdate != null)
+ unregisterReceiver(providerAPIBroadcastReceiverUpdate);
}
private void setUpProviderAPIResultReceiver() {
- providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this);
- providerAPI_broadcast_receiver_update = new ProviderAPIBroadcastReceiver_Update();
+ providerAPIResultReceiver = new ProviderAPIResultReceiver(new Handler(), this);
+ providerAPIBroadcastReceiverUpdate = new providerAPIBroadcastReceiverUpdate();
IntentFilter update_intent_filter = new IntentFilter(ProviderAPI.UPDATE_PROGRESSBAR);
update_intent_filter.addCategory(Intent.CATEGORY_DEFAULT);
- registerReceiver(providerAPI_broadcast_receiver_update, update_intent_filter);
+ registerReceiver(providerAPIBroadcastReceiverUpdate, update_intent_filter);
}
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
if (resultCode == ProviderAPI.PROVIDER_OK) {
try {
- String provider_json_string = preferences.getString(Provider.KEY, "");
- if (!provider_json_string.isEmpty())
- selected_provider.define(new JSONObject(provider_json_string));
+ String providerJsonString = preferences.getString(Provider.KEY, "");
+ if (!providerJsonString.isEmpty())
+ selectedProvider.define(new JSONObject(providerJsonString));
String caCert = preferences.getString(Provider.CA_CERT, "");
- selected_provider.setCACert(caCert);
+ selectedProvider.setCACert(caCert);
} catch (JSONException e) {
e.printStackTrace();
}
@@ -255,13 +252,13 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
//TODO Code 2 pane view
mConfigState.setAction(SETTING_UP_PROVIDER);
- selected_provider = adapter.getItem(position);
+ selectedProvider = adapter.getItem(position);
onItemSelectedUi();
onItemSelectedLogic();
}
protected void onItemSelectedUi() {
- adapter.hideAllBut(adapter.indexOf(selected_provider));
+ adapter.hideAllBut(adapter.indexOf(selectedProvider));
startProgressBar();
}
@@ -281,7 +278,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
ProviderAPI.stop();
mProgressBar.setVisibility(GONE);
mProgressBar.setProgress(0);
- progressbar_description.setVisibility(GONE);
+ progressbarDescription.setVisibility(GONE);
cancelSettingUpProvider();
}
@@ -297,21 +294,21 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
@Override
public void updateProviderDetails() {
mConfigState.setAction(SETTING_UP_PROVIDER);
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
+ Intent providerAPICommand = new Intent(this, ProviderAPI.class);
- provider_API_command.setAction(ProviderAPI.UPDATE_PROVIDER_DETAILS);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ providerAPICommand.setAction(ProviderAPI.UPDATE_PROVIDER_DETAILS);
+ providerAPICommand.putExtra(ProviderAPI.RECEIVER_KEY, providerAPIResultReceiver);
Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, selected_provider.getMainUrl().toString());
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
+ parameters.putString(Provider.MAIN_URL, selectedProvider.getMainUrl().toString());
+ providerAPICommand.putExtra(ProviderAPI.PARAMETERS, parameters);
- startService(provider_API_command);
+ startService(providerAPICommand);
}
private void askDashboardToQuitApp() {
- Intent ask_quit = new Intent();
- ask_quit.putExtra(Constants.APP_ACTION_QUIT, Constants.APP_ACTION_QUIT);
- setResult(RESULT_CANCELED, ask_quit);
+ Intent askQuit = new Intent();
+ askQuit.putExtra(Constants.APP_ACTION_QUIT, Constants.APP_ACTION_QUIT);
+ setResult(RESULT_CANCELED, askQuit);
}
private void startProgressBar() {
@@ -321,11 +318,11 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
int measured_height = listItemHeight();
mProgressBar.setTranslationY(measured_height);
- progressbar_description.setTranslationY(measured_height + mProgressBar.getHeight());
+ progressbarDescription.setTranslationY(measured_height + mProgressBar.getHeight());
}
private int listItemHeight() {
- View listItem = adapter.getView(0, null, provider_list_view);
+ View listItem = adapter.getView(0, null, providerListView);
listItem.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT));
@@ -346,33 +343,33 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
* Asks ProviderApiService to download an anonymous (anon) VPN certificate.
*/
private void downloadVpnCertificate() {
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
+ Intent providerAPICommand = new Intent(this, ProviderAPI.class);
- provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ providerAPICommand.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE);
+ providerAPICommand.putExtra(ProviderAPI.RECEIVER_KEY, providerAPIResultReceiver);
- startService(provider_API_command);
+ startService(providerAPICommand);
}
/**
* Open the new provider dialog
*/
public void addAndSelectNewProvider() {
- FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(NewProviderDialog.TAG);
- new NewProviderDialog().show(fragment_transaction, NewProviderDialog.TAG);
+ FragmentTransaction fragmentTransaction = fragmentManager.removePreviousFragment(NewProviderDialog.TAG);
+ new NewProviderDialog().show(fragmentTransaction, NewProviderDialog.TAG);
}
/**
* Open the new provider dialog with data
*/
public void addAndSelectNewProvider(String main_url) {
- FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(NewProviderDialog.TAG);
+ FragmentTransaction fragmentTransaction = fragmentManager.removePreviousFragment(NewProviderDialog.TAG);
DialogFragment newFragment = new NewProviderDialog();
Bundle data = new Bundle();
data.putString(Provider.MAIN_URL, main_url);
newFragment.setArguments(data);
- newFragment.show(fragment_transaction, NewProviderDialog.TAG);
+ newFragment.show(fragmentTransaction, NewProviderDialog.TAG);
}
/**
@@ -382,7 +379,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
*/
public void showDownloadFailedDialog(String reasonToFail) {
try {
- FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(DownloadFailedDialog.TAG);
+ FragmentTransaction fragmentTransaction = fragmentManager.removePreviousFragment(DownloadFailedDialog.TAG);
DialogFragment newFragment;
try {
JSONObject errorJson = new JSONObject(reasonToFail);
@@ -391,7 +388,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
e.printStackTrace();
newFragment = DownloadFailedDialog.newInstance(reasonToFail);
}
- newFragment.show(fragment_transaction, DownloadFailedDialog.TAG);
+ newFragment.show(fragmentTransaction, DownloadFailedDialog.TAG);
} catch (IllegalStateException e) {
e.printStackTrace();
mConfigState.setAction(PENDING_SHOW_FAILED_DIALOG);
@@ -435,11 +432,11 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
public void cancelAndShowAllProviders() {
mConfigState.setAction(PROVIDER_NOT_SET);
- selected_provider = null;
+ selectedProvider = null;
adapter.showAllProviders();
}
- public class ProviderAPIBroadcastReceiver_Update extends BroadcastReceiver {
+ public class providerAPIBroadcastReceiverUpdate extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int update = intent.getIntExtra(ProviderAPI.CURRENT_PROGRESS, 0);
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index dc58b865..3e8668de 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -283,7 +283,7 @@ public class Dashboard extends ButterKnifeActivity {
* service dependent UI elements to include.
*/
//TODO: REFACTOR ME! Consider implementing a manager that handles most of VpnFragment's logic about handling EIP commands.
- //This way, we could avoid to create UI elements (like fragment_manager.replace(R.id.servicesCollection, eip_fragment, VpnFragment.TAG); )
+ //This way, we could avoid to create UI elements (like fragmentManager.replace(R.id.servicesCollection, eip_fragment, VpnFragment.TAG); )
// just to start services and destroy them afterwards
private void buildDashboard(boolean hideAndTurnOnEipOnBoot) {
setContentView(R.layout.dashboard);
diff --git a/app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java b/app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java
index 9594cea0..9fe4fd23 100644
--- a/app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java
+++ b/app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java
@@ -22,17 +22,17 @@ import android.support.v4.app.FragmentTransaction;
public class FragmentManagerEnhanced {
- private FragmentManager generic_fragment_manager;
+ private FragmentManager genericFragmentManager;
- public FragmentManagerEnhanced(FragmentManager generic_fragment_manager) {
- this.generic_fragment_manager = generic_fragment_manager;
+ public FragmentManagerEnhanced(FragmentManager genericFragmentManager) {
+ this.genericFragmentManager = genericFragmentManager;
}
public FragmentTransaction removePreviousFragment(String tag) {
- FragmentTransaction transaction = generic_fragment_manager.beginTransaction();
- Fragment previous_fragment = generic_fragment_manager.findFragmentByTag(tag);
- if (previous_fragment != null) {
- transaction.remove(previous_fragment);
+ FragmentTransaction transaction = genericFragmentManager.beginTransaction();
+ Fragment previousFragment = genericFragmentManager.findFragmentByTag(tag);
+ if (previousFragment != null) {
+ transaction.remove(previousFragment);
}
transaction.addToBackStack(null);
@@ -40,16 +40,16 @@ public class FragmentManagerEnhanced {
}
public void replace(int containerViewId, Fragment fragment, String tag) {
- FragmentTransaction transaction = generic_fragment_manager.beginTransaction();
+ FragmentTransaction transaction = genericFragmentManager.beginTransaction();
transaction.replace(containerViewId, fragment, tag).commit();
}
public FragmentTransaction beginTransaction() {
- return generic_fragment_manager.beginTransaction();
+ return genericFragmentManager.beginTransaction();
}
public Fragment findFragmentByTag(String tag) {
- return generic_fragment_manager.findFragmentByTag(tag);
+ return genericFragmentManager.findFragmentByTag(tag);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
index a87e0460..aa661723 100644
--- a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
@@ -33,17 +33,17 @@ public class OnBootReceiver extends BroadcastReceiver {
return;
}
if (startOnBoot) {
- Intent dashboard_intent = new Intent(context, Dashboard.class);
- dashboard_intent.putExtra(EIP_RESTART_ON_BOOT, true);
- dashboard_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(dashboard_intent);
+ Intent dashboardIntent = new Intent(context, Dashboard.class);
+ dashboardIntent.putExtra(EIP_RESTART_ON_BOOT, true);
+ dashboardIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(dashboardIntent);
}
} else {
if (isAlwaysOnConfigured) {
- Intent dashboard_intent = new Intent(context, Dashboard.class);
- dashboard_intent.putExtra(Constants.APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE, true);
- dashboard_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(dashboard_intent);
+ Intent dashboardIntent = new Intent(context, Dashboard.class);
+ dashboardIntent.putExtra(Constants.APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE, true);
+ dashboardIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(dashboardIntent);
}
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
index 92d5da9f..62c04c1a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
@@ -27,39 +27,39 @@ public class ProviderManager implements AdapteeCollection<Provider> {
private static final String TAG = ProviderManager.class.getName();
private AssetManager assets_manager;
- private File external_files_dir;
- private Set<Provider> default_providers;
- private Set<Provider> custom_providers;
+ private File externalFilesDir;
+ private Set<Provider> defaultProviders;
+ private Set<Provider> customProviders;
private static ProviderManager instance;
final protected static String URLS = "urls";
- public static ProviderManager getInstance(AssetManager assets_manager, File external_files_dir) {
+ public static ProviderManager getInstance(AssetManager assetsManager, File externalFilesDir) {
if (instance == null)
- instance = new ProviderManager(assets_manager, external_files_dir);
+ instance = new ProviderManager(assetsManager, externalFilesDir);
return instance;
}
- public ProviderManager(AssetManager assets_manager, File external_files_dir) {
- this.assets_manager = assets_manager;
- addDefaultProviders(assets_manager);
- addCustomProviders(external_files_dir);
+ public ProviderManager(AssetManager assetManager, File externalFilesDir) {
+ this.assets_manager = assetManager;
+ addDefaultProviders(assetManager);
+ addCustomProviders(externalFilesDir);
}
private void addDefaultProviders(AssetManager assets_manager) {
try {
- default_providers = providersFromAssets(URLS, assets_manager.list(URLS));
+ defaultProviders = providersFromAssets(URLS, assets_manager.list(URLS));
} catch (IOException e) {
e.printStackTrace();
}
}
- private Set<Provider> providersFromAssets(String directory, String[] relative_file_paths) {
+ private Set<Provider> providersFromAssets(String directory, String[] relativeFilePaths) {
Set<Provider> providers = new HashSet<Provider>();
- for (String file : relative_file_paths) {
+ for (String file : relativeFilePaths) {
String mainUrl = null;
String certificate = null;
String providerDefinition = null;
@@ -83,10 +83,10 @@ public class ProviderManager implements AdapteeCollection<Provider> {
}
- private void addCustomProviders(File external_files_dir) {
- this.external_files_dir = external_files_dir;
- custom_providers = external_files_dir != null && external_files_dir.isDirectory() ?
- providersFromFiles(external_files_dir.list()) :
+ private void addCustomProviders(File externalFilesDir) {
+ this.externalFilesDir = externalFilesDir;
+ customProviders = externalFilesDir != null && externalFilesDir.isDirectory() ?
+ providersFromFiles(externalFilesDir.list()) :
new HashSet<Provider>();
}
@@ -94,7 +94,7 @@ public class ProviderManager implements AdapteeCollection<Provider> {
Set<Provider> providers = new HashSet<Provider>();
try {
for (String file : files) {
- String main_url = extractMainUrlFromInputStream(new FileInputStream(external_files_dir.getAbsolutePath() + "/" + file));
+ String main_url = extractMainUrlFromInputStream(new FileInputStream(externalFilesDir.getAbsolutePath() + "/" + file));
providers.add(new Provider(new URL(main_url)));
}
} catch (MalformedURLException | FileNotFoundException e) {
@@ -105,21 +105,21 @@ public class ProviderManager implements AdapteeCollection<Provider> {
}
private String extractMainUrlFromInputStream(InputStream input_stream) {
- String main_url = "";
+ String mainUrl = "";
JSONObject file_contents = inputStreamToJson(input_stream);
if (file_contents != null)
- main_url = file_contents.optString(Provider.MAIN_URL);
- return main_url;
+ mainUrl = file_contents.optString(Provider.MAIN_URL);
+ return mainUrl;
}
- private JSONObject inputStreamToJson(InputStream input_stream) {
+ private JSONObject inputStreamToJson(InputStream inputStream) {
JSONObject json = null;
try {
- byte[] bytes = new byte[input_stream.available()];
- if (input_stream.read(bytes) > 0)
+ byte[] bytes = new byte[inputStream.available()];
+ if (inputStream.read(bytes) > 0)
json = new JSONObject(new String(bytes));
- input_stream.reset();
+ inputStream.reset();
} catch (IOException | JSONException e) {
e.printStackTrace();
}
@@ -128,9 +128,9 @@ public class ProviderManager implements AdapteeCollection<Provider> {
public Set<Provider> providers() {
Set<Provider> all_providers = new HashSet<Provider>();
- all_providers.addAll(default_providers);
- if(custom_providers != null)
- all_providers.addAll(custom_providers);
+ all_providers.addAll(defaultProviders);
+ if(customProviders != null)
+ all_providers.addAll(customProviders);
return all_providers;
}
@@ -151,40 +151,40 @@ public class ProviderManager implements AdapteeCollection<Provider> {
@Override
public boolean add(Provider element) {
- if (!default_providers.contains(element))
- return custom_providers.add(element);
+ if (!defaultProviders.contains(element))
+ return customProviders.add(element);
else return true;
}
@Override
public boolean remove(Object element) {
- return custom_providers.remove(element);
+ return customProviders.remove(element);
}
@Override
public boolean addAll(Collection<? extends Provider> elements) {
- return custom_providers.addAll(elements);
+ return customProviders.addAll(elements);
}
@Override
public boolean removeAll(Collection<?> elements) {
if(!elements.getClass().equals(Provider.class))
return false;
- return default_providers.removeAll(elements) || custom_providers.removeAll(elements);
+ return defaultProviders.removeAll(elements) || customProviders.removeAll(elements);
}
@Override
public void clear() {
- default_providers.clear();
- custom_providers.clear();
+ defaultProviders.clear();
+ customProviders.clear();
}
protected void saveCustomProvidersToFile() {
try {
- for (Provider provider : custom_providers) {
- File provider_file = new File(external_files_dir, provider.getName() + ".json");
- if (!provider_file.exists()) {
- FileWriter writer = new FileWriter(provider_file);
+ for (Provider provider : customProviders) {
+ File providerFile = new File(externalFilesDir, provider.getName() + ".json");
+ if (!providerFile.exists()) {
+ FileWriter writer = new FileWriter(providerFile);
writer.write(provider.toJson().toString());
writer.close();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
index e16ab75c..0af23917 100644
--- a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
@@ -76,13 +76,13 @@ public class VpnFragment extends Fragment implements Observer {
private SharedPreferences preferences;
@InjectView(R.id.vpn_status_image)
- FabButton vpn_status_image;
+ FabButton vpnStatusImage;
@InjectView(R.id.vpn_main_button)
- Button main_button;
+ Button mainButton;
- private static EIPReceiver eip_receiver;
- private static EipStatus eip_status;
- private boolean wants_to_connect;
+ private static EIPReceiver eipReceiver;
+ private static EipStatus eipStatus;
+ private boolean wantsToConnect;
private IOpenVPNServiceInternal mService;
private ServiceConnection openVpnConnection = new ServiceConnection() {
@@ -103,18 +103,17 @@ public class VpnFragment extends Fragment implements Observer {
};
- //FIXME: replace with onAttach(Context context)
- public void onAttach(Activity activity) {
- super.onAttach(activity);
+ public void onAttach(Context context) {
+ super.onAttach(context);
downloadEIPServiceConfig();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- eip_status = EipStatus.getInstance();
- eip_status.addObserver(this);
- eip_receiver = new EIPReceiver(new Handler());
+ eipStatus = EipStatus.getInstance();
+ eipStatus.addObserver(this);
+ eipReceiver = new EIPReceiver(new Handler());
preferences = getActivity().getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE);
}
@@ -147,7 +146,7 @@ public class VpnFragment extends Fragment implements Observer {
@Override
public void onSaveInstanceState(Bundle outState) {
- outState.putBoolean(IS_CONNECTED, eip_status.isConnected());
+ outState.putBoolean(IS_CONNECTED, eipStatus.isConnected());
super.onSaveInstanceState(outState);
}
@@ -157,7 +156,7 @@ public class VpnFragment extends Fragment implements Observer {
@OnClick(R.id.vpn_main_button)
void handleIcon() {
- if (eip_status.isConnected() || eip_status.isConnecting())
+ if (eipStatus.isConnected() || eipStatus.isConnecting())
handleSwitchOff();
else
handleSwitchOn();
@@ -167,7 +166,7 @@ public class VpnFragment extends Fragment implements Observer {
if (canStartEIP())
startEipFromScratch();
else if (canLogInToStartEIP()) {
- wants_to_connect = true;
+ wantsToConnect = true;
Bundle bundle = new Bundle();
MainActivity.sessionDialog(bundle);
} else {
@@ -180,19 +179,19 @@ public class VpnFragment extends Fragment implements Observer {
private boolean canStartEIP() {
boolean certificateExists = !preferences.getString(PROVIDER_VPN_CERTIFICATE, "").isEmpty();
boolean isAllowedAnon = preferences.getBoolean(PROVIDER_ALLOW_ANONYMOUS, false);
- return (isAllowedAnon || certificateExists) && !eip_status.isConnected() && !eip_status.isConnecting();
+ return (isAllowedAnon || certificateExists) && !eipStatus.isConnected() && !eipStatus.isConnecting();
}
private boolean canLogInToStartEIP() {
boolean isAllowedRegistered = preferences.getBoolean(PROVIDER_ALLOWED_REGISTERED, false);
boolean isLoggedIn = !LeapSRPSession.getToken().isEmpty();
- return isAllowedRegistered && !isLoggedIn && !eip_status.isConnecting() && !eip_status.isConnected();
+ return isAllowedRegistered && !isLoggedIn && !eipStatus.isConnecting() && !eipStatus.isConnected();
}
private void handleSwitchOff() {
- if (eip_status.isConnecting()) {
+ if (eipStatus.isConnecting()) {
askPendingStartCancellation();
- } else if (eip_status.isConnected()) {
+ } else if (eipStatus.isConnected()) {
askToStopEIP();
} else {
updateIcon();
@@ -219,14 +218,14 @@ public class VpnFragment extends Fragment implements Observer {
}
public void startEipFromScratch() {
- wants_to_connect = false;
+ wantsToConnect = false;
saveStatus(true);
eipCommand(EIP_ACTION_START);
}
private void stop() {
saveStatus(false);
- if (eip_status.isBlockingVpnEstablished()) {
+ if (eipStatus.isBlockingVpnEstablished()) {
stopBlockingVpn();
}
disconnect();
@@ -258,7 +257,7 @@ public class VpnFragment extends Fragment implements Observer {
private void downloadEIPServiceConfig() {
ProviderAPIResultReceiver provider_api_receiver = new ProviderAPIResultReceiver(new Handler(), Dashboard.dashboardReceiver);
- if(eip_receiver != null)
+ if(eipReceiver != null)
ProviderAPICommand.execute(Bundle.EMPTY, ProviderAPI.DOWNLOAD_EIP_SERVICE, provider_api_receiver);
}
@@ -296,14 +295,14 @@ public class VpnFragment extends Fragment implements Observer {
// TODO validate "action"...how do we get the list of intent-filters for a class via Android API?
Intent vpn_intent = new Intent(activity.getApplicationContext(), EIP.class);
vpn_intent.setAction(action);
- vpn_intent.putExtra(EIP_RECEIVER, eip_receiver);
+ vpn_intent.putExtra(EIP_RECEIVER, eipReceiver);
activity.startService(vpn_intent);
}
@Override
public void update(Observable observable, Object data) {
if (observable instanceof EipStatus) {
- eip_status = (EipStatus) observable;
+ eipStatus = (EipStatus) observable;
Activity activity = getActivity();
if (activity != null) {
getActivity().runOnUiThread(new Runnable() {
@@ -324,40 +323,40 @@ public class VpnFragment extends Fragment implements Observer {
}
private void updateIcon() {
- if (eip_status.isBlocking()) {
- vpn_status_image.showProgress(false);
- vpn_status_image.setIcon(R.drawable.ic_stat_vpn_blocking, R.drawable.ic_stat_vpn_blocking);
- vpn_status_image.setTag(R.drawable.ic_stat_vpn_blocking);
- } else if (eip_status.isConnecting()) {
- vpn_status_image.showProgress(true);
- vpn_status_image.setIcon(R.drawable.ic_stat_vpn_empty_halo, R.drawable.ic_stat_vpn_empty_halo);
- vpn_status_image.setTag(R.drawable.ic_stat_vpn_empty_halo);
- } else if (eip_status.isConnected()){
- vpn_status_image.showProgress(false);
- vpn_status_image.setIcon(R.drawable.ic_stat_vpn, R.drawable.ic_stat_vpn);
- vpn_status_image.setTag(R.drawable.ic_stat_vpn);
+ if (eipStatus.isBlocking()) {
+ vpnStatusImage.showProgress(false);
+ vpnStatusImage.setIcon(R.drawable.ic_stat_vpn_blocking, R.drawable.ic_stat_vpn_blocking);
+ vpnStatusImage.setTag(R.drawable.ic_stat_vpn_blocking);
+ } else if (eipStatus.isConnecting()) {
+ vpnStatusImage.showProgress(true);
+ vpnStatusImage.setIcon(R.drawable.ic_stat_vpn_empty_halo, R.drawable.ic_stat_vpn_empty_halo);
+ vpnStatusImage.setTag(R.drawable.ic_stat_vpn_empty_halo);
+ } else if (eipStatus.isConnected()){
+ vpnStatusImage.showProgress(false);
+ vpnStatusImage.setIcon(R.drawable.ic_stat_vpn, R.drawable.ic_stat_vpn);
+ vpnStatusImage.setTag(R.drawable.ic_stat_vpn);
} else {
- vpn_status_image.setIcon(R.drawable.ic_stat_vpn_offline, R.drawable.ic_stat_vpn_offline);
- vpn_status_image.setTag(R.drawable.ic_stat_vpn_offline);
- vpn_status_image.showProgress(false);
+ vpnStatusImage.setIcon(R.drawable.ic_stat_vpn_offline, R.drawable.ic_stat_vpn_offline);
+ vpnStatusImage.setTag(R.drawable.ic_stat_vpn_offline);
+ vpnStatusImage.showProgress(false);
}
}
private void updateButton() {
Activity activity = getActivity();
- if (eip_status.isConnecting()) {
- main_button.setText(activity.getString(android.R.string.cancel));
- } else if (eip_status.isConnected() || isOpenVpnRunningWithoutNetwork()) {
- main_button.setText(activity.getString(R.string.vpn_button_turn_off));
+ if (eipStatus.isConnecting()) {
+ mainButton.setText(activity.getString(android.R.string.cancel));
+ } else if (eipStatus.isConnected() || isOpenVpnRunningWithoutNetwork()) {
+ mainButton.setText(activity.getString(R.string.vpn_button_turn_off));
} else {
- main_button.setText(activity.getString(R.string.vpn_button_turn_on));
+ mainButton.setText(activity.getString(R.string.vpn_button_turn_on));
}
}
private boolean isOpenVpnRunningWithoutNetwork() {
boolean isRunning = false;
try {
- isRunning = eip_status.getLevel() == LEVEL_NONETWORK &&
+ isRunning = eipStatus.getLevel() == LEVEL_NONETWORK &&
mService.isVpnRunning();
} catch (Exception e) {
//eat me
@@ -428,7 +427,7 @@ public class VpnFragment extends Fragment implements Observer {
case EIP_ACTION_UPDATE:
switch (resultCode) {
case Activity.RESULT_OK:
- if (wants_to_connect)
+ if (wantsToConnect)
startEipFromScratch();
break;
case Activity.RESULT_CANCELED:
@@ -441,6 +440,6 @@ public class VpnFragment extends Fragment implements Observer {
public static EIPReceiver getReceiver() {
- return eip_receiver;
+ return eipReceiver;
}
}
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, <code>Activity.RESULT_OK</code> 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 =
"<ca>"
- + new_line
+ + newLine
+ secrets.getString(Provider.CA_CERT)
- + new_line
+ + newLine
+ "</ca>";
String key =
"<key>"
- + new_line
+ + newLine
+ secrets.getString(Constants.PROVIDER_PRIVATE_KEY)
- + new_line
+ + newLine
+ "</key>";
- String openvpn_cert =
+ String openvpnCert =
"<cert>"
- + new_line
+ + newLine
+ secrets.getString(Constants.PROVIDER_VPN_CERTIFICATE)
- + new_line
+ + newLine
+ "</cert>";
- 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";
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java
index d86da957..5c6355f5 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java
@@ -58,11 +58,11 @@ public class SessionDialog extends DialogFragment {
}
@InjectView(R.id.user_message)
- TextView user_message;
+ TextView userMessage;
@InjectView(R.id.username_entered)
- EditText username_field;
+ EditText usernameField;
@InjectView(R.id.password_entered)
- EditText password_field;
+ EditText passwordField;
public static SessionDialog getInstance(Provider provider, Bundle arguments) {
SessionDialog dialog = new SessionDialog();
@@ -118,35 +118,35 @@ public class SessionDialog extends DialogFragment {
private void setUp(Bundle arguments) {
if (arguments.containsKey(ERRORS.PASSWORD_INVALID_LENGTH.toString()))
- password_field.setError(getString(R.string.error_not_valid_password_user_message));
+ passwordField.setError(getString(R.string.error_not_valid_password_user_message));
else if (arguments.containsKey(ERRORS.RISEUP_WARNING.toString())) {
- user_message.setVisibility(VISIBLE);
- user_message.setText(R.string.login_riseup_warning);
+ userMessage.setVisibility(VISIBLE);
+ userMessage.setText(R.string.login_riseup_warning);
}
if (arguments.containsKey(USERNAME)) {
String username = arguments.getString(USERNAME);
- username_field.setText(username);
+ usernameField.setText(username);
}
if (arguments.containsKey(ERRORS.USERNAME_MISSING.toString())) {
- username_field.setError(getString(R.string.username_ask));
+ usernameField.setError(getString(R.string.username_ask));
}
if (arguments.containsKey(getString(R.string.user_message))) {
- user_message.setText(arguments.getString(getString(R.string.user_message)));
- user_message.setVisibility(VISIBLE);
- } else if (user_message.getVisibility() != VISIBLE)
- user_message.setVisibility(View.GONE);
+ userMessage.setText(arguments.getString(getString(R.string.user_message)));
+ userMessage.setVisibility(VISIBLE);
+ } else if (userMessage.getVisibility() != VISIBLE)
+ userMessage.setVisibility(View.GONE);
- if (!username_field.getText().toString().isEmpty() && password_field.isFocusable())
- password_field.requestFocus();
+ if (!usernameField.getText().toString().isEmpty() && passwordField.isFocusable())
+ passwordField.requestFocus();
}
private String getEnteredUsername() {
- return username_field.getText().toString();
+ return usernameField.getText().toString();
}
private String getEnteredPassword() {
- return password_field.getText().toString();
+ return passwordField.getText().toString();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
index 07c102e4..30a34de8 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
@@ -37,7 +37,7 @@ public class UserStatusFragment extends Fragment implements Observer, SessionDia
Button button;
private UserStatus status;
- private boolean allows_registration = false;
+ private boolean allowsRegistration = false;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -63,7 +63,7 @@ public class UserStatusFragment extends Fragment implements Observer, SessionDia
ButterKnife.inject(this, view);
Bundle arguments = getArguments();
- allows_registration = arguments.getBoolean(Provider.ALLOW_REGISTRATION);
+ allowsRegistration = arguments.getBoolean(Provider.ALLOW_REGISTRATION);
handleNewStatus(status);
return view;
@@ -108,7 +108,7 @@ public class UserStatusFragment extends Fragment implements Observer, SessionDia
private void handleNewStatus(UserStatus status) {
this.status = status;
- if (allows_registration) {
+ if (allowsRegistration) {
if (this.status.inProgress())
showUserSessionProgressBar();
else
@@ -134,7 +134,7 @@ public class UserStatusFragment extends Fragment implements Observer, SessionDia
private void updateButton() {
if(status.isLoggedIn() || status.didntLogOut())
button.setText(getActivity().getString(R.string.logout_button));
- else if(allows_registration) {
+ else if(allowsRegistration) {
if (status.isLoggedOut() || status.notLoggedIn())
button.setText(getActivity().getString(R.string.login_button));
else if (status.inProgress())
diff --git a/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java
index 3f05b0a2..e8182796 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -40,17 +40,17 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
public void showAndSelectProvider(String provider_main_url) {
try {
- selected_provider = new Provider(new URL((provider_main_url)));
- adapter.add(selected_provider);
+ selectedProvider = new Provider(new URL((provider_main_url)));
+ adapter.add(selectedProvider);
adapter.saveProviders();
- autoSelectProvider(selected_provider);
+ autoSelectProvider(selectedProvider);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
private void autoSelectProvider(Provider provider) {
- selected_provider = provider;
+ selectedProvider = provider;
onItemSelectedUi();
onItemSelectedLogic();
}
@@ -61,24 +61,24 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
*/
public void setUpProvider() {
mConfigState.setAction(SETTING_UP_PROVIDER);
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
+ Intent providerApiCommand = new Intent(this, ProviderAPI.class);
Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, selected_provider.getMainUrl().toString());
- if (selected_provider.hasCertificatePin()){
- parameters.putString(Provider.CA_CERT_FINGERPRINT, selected_provider.certificatePin());
+ parameters.putString(Provider.MAIN_URL, selectedProvider.getMainUrl().toString());
+ if (selectedProvider.hasCertificatePin()){
+ parameters.putString(Provider.CA_CERT_FINGERPRINT, selectedProvider.certificatePin());
}
- if (selected_provider.hasCaCert()) {
- parameters.putString(Provider.CA_CERT, selected_provider.getCaCert());
+ if (selectedProvider.hasCaCert()) {
+ parameters.putString(Provider.CA_CERT, selectedProvider.getCaCert());
}
- if (selected_provider.hasDefinition()) {
- parameters.putString(Provider.KEY, selected_provider.getDefinition().toString());
+ if (selectedProvider.hasDefinition()) {
+ parameters.putString(Provider.KEY, selectedProvider.getDefinition().toString());
}
- provider_API_command.setAction(ProviderAPI.SET_UP_PROVIDER);
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ providerApiCommand.setAction(ProviderAPI.SET_UP_PROVIDER);
+ providerApiCommand.putExtra(ProviderAPI.PARAMETERS, parameters);
+ providerApiCommand.putExtra(ProviderAPI.RECEIVER_KEY, providerAPIResultReceiver);
- startService(provider_API_command);
+ startService(providerApiCommand);
}
@Override
@@ -88,17 +88,17 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
addAndSelectNewProvider(ProviderAPI.lastProviderMainUrl());
} else {
showProgressBar();
- adapter.hideAllBut(adapter.indexOf(selected_provider));
+ adapter.hideAllBut(adapter.indexOf(selectedProvider));
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
- provider_API_command.setAction(ProviderAPI.SET_UP_PROVIDER);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ Intent providerApiCommand = new Intent(this, ProviderAPI.class);
+ providerApiCommand.setAction(ProviderAPI.SET_UP_PROVIDER);
+ providerApiCommand.putExtra(ProviderAPI.RECEIVER_KEY, providerAPIResultReceiver);
Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, selected_provider.getMainUrl().toString());
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
+ parameters.putString(Provider.MAIN_URL, selectedProvider.getMainUrl().toString());
+ providerApiCommand.putExtra(ProviderAPI.PARAMETERS, parameters);
- startService(provider_API_command);
+ startService(providerApiCommand);
}
}
diff --git a/app/src/production/java/se/leap/bitmaskclient/NewProviderDialog.java b/app/src/production/java/se/leap/bitmaskclient/NewProviderDialog.java
index fc7c9ede..025d5263 100644
--- a/app/src/production/java/se/leap/bitmaskclient/NewProviderDialog.java
+++ b/app/src/production/java/se/leap/bitmaskclient/NewProviderDialog.java
@@ -41,19 +41,19 @@ public class NewProviderDialog extends DialogFragment {
final public static String TAG = "newProviderDialog";
@InjectView(R.id.new_provider_url)
- EditText url_input_field;
+ EditText urlInputField;
public interface NewProviderDialogInterface {
void showAndSelectProvider(String url_provider);
}
- NewProviderDialogInterface interface_with_ConfigurationWizard;
+ NewProviderDialogInterface interfaceWithConfigurationWizard;
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
- interface_with_ConfigurationWizard = (NewProviderDialogInterface) context;
+ interfaceWithConfigurationWizard = (NewProviderDialogInterface) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement NoticeDialogListener");
@@ -69,7 +69,7 @@ public class NewProviderDialog extends DialogFragment {
ButterKnife.inject(this, view);
Bundle arguments = getArguments();
if (arguments != null) {
- url_input_field.setText(arguments.getString(Provider.MAIN_URL, ""));
+ urlInputField.setText(arguments.getString(Provider.MAIN_URL, ""));
}
builder.setView(view)
@@ -89,7 +89,7 @@ public class NewProviderDialog extends DialogFragment {
}
private void saveProvider() {
- String entered_url = url_input_field.getText().toString().trim();
+ String entered_url = urlInputField.getText().toString().trim();
if (!entered_url.startsWith("https://")) {
if (entered_url.startsWith("http://")) {
entered_url = entered_url.substring("http://".length());
@@ -98,10 +98,10 @@ public class NewProviderDialog extends DialogFragment {
}
if (validURL(entered_url)) {
- interface_with_ConfigurationWizard.showAndSelectProvider(entered_url);
+ interfaceWithConfigurationWizard.showAndSelectProvider(entered_url);
Toast.makeText(getActivity().getApplicationContext(), R.string.valid_url_entered, Toast.LENGTH_LONG).show();
} else {
- url_input_field.setText("");
+ urlInputField.setText("");
Toast.makeText(getActivity().getApplicationContext(), R.string.not_valid_url_entered, Toast.LENGTH_LONG).show();
}
}
@@ -109,11 +109,11 @@ public class NewProviderDialog extends DialogFragment {
/**
* Checks if the entered url is valid or not.
*
- * @param entered_url
+ * @param enteredUrl
* @return true if it's not empty nor contains only the protocol.
*/
- boolean validURL(String entered_url) {
- //return !entered_url.isEmpty() && entered_url.matches("http[s]?://.+") && !entered_url.replaceFirst("http[s]?://", "").isEmpty();
- return android.util.Patterns.WEB_URL.matcher(entered_url).matches();
+ boolean validURL(String enteredUrl) {
+ //return !enteredUrl.isEmpty() && enteredUrl.matches("http[s]?://.+") && !enteredUrl.replaceFirst("http[s]?://", "").isEmpty();
+ return android.util.Patterns.WEB_URL.matcher(enteredUrl).matches();
}
}