summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/build.gradle1
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java140
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Provider.java66
-rw-r--r--app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java90
5 files changed, 122 insertions, 180 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 9c1d5b4e..6cf06281 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -47,6 +47,7 @@ android {
dependencies {
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
+ compile 'com.jakewharton:butterknife:6.0.0+'
compile 'com.intellij:annotations:12.0'
}
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
index 7c79c7c7..65cab91e 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2013 LEAP Encryption Access Project and contributers
+ * Copyright (c) 2013 LEAP Encryption Access Project and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,9 +23,13 @@ import android.view.*;
import android.widget.*;
import java.io.*;
import java.net.*;
-import java.util.*;
+
+import butterknife.ButterKnife;
+import butterknife.InjectView;
+import org.jetbrains.annotations.NotNull;
import org.json.*;
+import butterknife.OnItemSelected;
import se.leap.bitmaskclient.DownloadFailedDialog.DownloadFailedDialogInterface;
import se.leap.bitmaskclient.NewProviderDialog.NewProviderDialogInterface;
import se.leap.bitmaskclient.ProviderAPIResultReceiver.Receiver;
@@ -41,11 +45,14 @@ import se.leap.bitmaskclient.eip.Constants;
* @author parmegv
*
*/
-public class ConfigurationWizard extends Activity
+public class ConfigurationWizard extends ListActivity
implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderDetailFragmentInterface, DownloadFailedDialogInterface, Receiver {
- private ProgressBar mProgressBar;
- private TextView progressbar_description;
+ @InjectView(R.id.progressbar_configuration_wizard)
+ ProgressBar mProgressBar;
+ @InjectView(R.id.progressbar_description)
+ TextView progressbar_description;
+
private ProviderListFragment provider_list_fragment;
private Intent mConfigState = new Intent();
private ProviderItem selected_provider;
@@ -73,7 +80,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private int progress = -1;
@Override
- protected void onSaveInstanceState(Bundle outState) {
+ protected void onSaveInstanceState(@NotNull Bundle outState) {
if(mProgressBar != null)
outState.putInt(PROGRESSBAR_NUMBER, mProgressBar.getProgress());
if(progressbar_description != null)
@@ -89,6 +96,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
super.onCreate(savedInstanceState);
preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
+ ButterKnife.inject(this);
setUpInitialUI();
@@ -99,15 +107,19 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
setUpProviderList();
if(savedInstanceState != null) {
- progressbar_text = savedInstanceState.getString(PROGRESSBAR_TEXT, "");
- provider_name = savedInstanceState.getString(Provider.NAME, "");
- selected_provider = getProvider(provider_name);
- progress = savedInstanceState.getInt(PROGRESSBAR_NUMBER, -1);
- providerAPI_result_receiver = savedInstanceState.getParcelable(ProviderAPI.RECEIVER_KEY);
- providerAPI_result_receiver.setReceiver(this);
+ restoreState(savedInstanceState);
}
}
+ private void restoreState(Bundle savedInstanceState) {
+ progressbar_text = savedInstanceState.getString(PROGRESSBAR_TEXT, "");
+ provider_name = savedInstanceState.getString(Provider.NAME, "");
+ selected_provider = getProvider(provider_name);
+ progress = savedInstanceState.getInt(PROGRESSBAR_NUMBER, -1);
+ providerAPI_result_receiver = savedInstanceState.getParcelable(ProviderAPI.RECEIVER_KEY);
+ providerAPI_result_receiver.setReceiver(this);
+ }
+
@Override
protected void onPostResume() {
super.onPostResume();
@@ -128,10 +140,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
private void hideProgressBar() {
- mProgressBar = (ProgressBar) findViewById(R.id.progressbar_configuration_wizard);
mProgressBar.setVisibility(ProgressBar.INVISIBLE);
-
- progressbar_description = (TextView) findViewById(R.id.progressbar_description);
progressbar_description.setVisibility(TextView.INVISIBLE);
}
@@ -145,11 +154,6 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
provider_list_fragment.setArguments(arguments);
- putProviderListFragment(provider_list_fragment);
- }
-
- private void putProviderListFragment(ProviderListFragment fragment) {
- fragment_manager.replace(R.id.configuration_wizard_layout, provider_list_fragment, ProviderListFragment.TAG);
}
@Override
@@ -194,7 +198,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
setResult(RESULT_CANCELED, mConfigState);
String reason_to_fail = resultData.getString(ProviderAPI.ERRORS);
- showDownloadFailedDialog(getCurrentFocus(), reason_to_fail);
+ showDownloadFailedDialog(reason_to_fail);
}
else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) {
mProgressBar.incrementProgressBy(1);
@@ -256,21 +260,14 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
private void usualBackButton() {
- try {
- boolean is_provider_set_up = new JSONObject(preferences.getString(Provider.KEY, "no provider")) != null ? true : false;
- boolean is_provider_set_up_truly = new JSONObject(preferences.getString(Provider.KEY, "no provider")).length() != 0 ? true : false;
- if(!is_provider_set_up || !is_provider_set_up_truly) {
- askDashboardToQuitApp();
- } else {
- setResult(RESULT_OK);
- }
- } catch (JSONException e) {
- askDashboardToQuitApp();
- super.onBackPressed();
- e.printStackTrace();
- }
- super.onBackPressed();
+ if(preferences.getString(Provider.KEY, "").isEmpty()) {
+ askDashboardToQuitApp();
+ } else {
+ setResult(RESULT_OK);
+ }
+ super.onBackPressed();
}
+
private void askDashboardToQuitApp() {
Intent ask_quit = new Intent();
ask_quit.putExtra(Dashboard.ACTION_QUIT, Dashboard.ACTION_QUIT);
@@ -278,13 +275,11 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
private ProviderItem getProvider(String name) {
- Iterator<ProviderItem> providers_iterator = ProviderListContent.ITEMS.iterator();
- while(providers_iterator.hasNext()) {
- ProviderItem provider = providers_iterator.next();
- if(provider.name().equalsIgnoreCase(name)) {
- return provider;
- }
- }
+ for (ProviderItem provider : ProviderListContent.ITEMS) {
+ if (provider.name().equalsIgnoreCase(name)) {
+ return provider;
+ }
+ }
return null;
}
@@ -301,13 +296,11 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private int getProviderIndex(String id) {
int index = 0;
- Iterator<ProviderItem> providers_iterator = ProviderListContent.ITEMS.iterator();
- while(providers_iterator.hasNext()) {
- ProviderItem provider = providers_iterator.next();
- if(provider.name().equalsIgnoreCase(id)) {
- break;
- } else index++;
- }
+ for (ProviderItem provider : ProviderListContent.ITEMS) {
+ if (provider.name().equalsIgnoreCase(id)) {
+ break;
+ } else index++;
+ }
return index;
}
@@ -358,15 +351,16 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
}
- private String extractProviderMainUrlFromAssetsFile(String filepath) {
+ private String extractProviderMainUrlFromAssetsFile(String file_path) {
String provider_main_url = "";
try {
- InputStream input_stream_file_contents = getAssets().open(filepath);
+ InputStream input_stream_file_contents = getAssets().open(file_path);
byte[] urls_file_bytes = new byte[input_stream_file_contents.available()];
- input_stream_file_contents.read(urls_file_bytes);
- String urls_file_content = new String(urls_file_bytes);
- JSONObject file_contents = new JSONObject(urls_file_content);
- provider_main_url = file_contents.getString(Provider.MAIN_URL);
+ if(input_stream_file_contents.read(urls_file_bytes) > 0) {
+ String urls_file_content = new String(urls_file_bytes);
+ JSONObject file_contents = new JSONObject(urls_file_content);
+ provider_main_url = file_contents.getString(Provider.MAIN_URL);
+ }
} catch (JSONException e) {
} catch (IOException e) {
}
@@ -376,14 +370,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private String getId(String provider_main_url) {
try {
URL provider_url = new URL(provider_main_url);
- Iterator<ProviderItem> providers_iterator = ProviderListContent.ITEMS.iterator();
- while(providers_iterator.hasNext()) {
- ProviderItem provider = providers_iterator.next();
- URL aux_provider_url = new URL(provider.providerMainUrl());
- if(isSameURL(provider_url, aux_provider_url)) {
- return provider.name();
- }
- }
+ for (ProviderItem provider : ProviderListContent.ITEMS) {
+ URL aux_provider_url = new URL(provider.providerMainUrl());
+ if (isSameURL(provider_url, aux_provider_url)) {
+ return provider.name();
+ }
+ }
} catch (MalformedURLException e) {
e.printStackTrace();
}
@@ -399,16 +391,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
* same protocol, false otherwise.
*/
private boolean isSameURL(final URL url, final URL baseUrl) {
- if (!url.getProtocol().equals(baseUrl.getProtocol())) {
- return false;
- }
- if (!url.getHost().equals(baseUrl.getHost())) {
- return false;
- }
- if (url.getPort() != baseUrl.getPort()) {
- return false;
- }
- return true;
+ return url.getProtocol().equals(baseUrl.getProtocol()) &&
+ url.getHost().equals(baseUrl.getHost()) &&
+ url.getPort() == baseUrl.getPort();
}
/**
@@ -455,10 +440,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
* Once selected a provider, this fragment offers the user to log in,
* use it anonymously (if possible)
* or cancel his/her election pressing the back button.
- * @param view
- * @param reason_to_fail
+ * @param reason_to_fail
*/
- public void showDownloadFailedDialog(View view, String reason_to_fail) {
+ public void showDownloadFailedDialog(String reason_to_fail) {
FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(DownloadFailedDialog.TAG);
DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail);
@@ -492,7 +476,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
private void autoSelectProvider(String provider_main_url, boolean danger_on) {
- preferences.edit().putBoolean(ProviderItem.DANGER_ON, danger_on).commit();
+ preferences.edit().putBoolean(ProviderItem.DANGER_ON, danger_on).apply();
onItemSelected(getId(provider_main_url));
}
@@ -559,7 +543,7 @@ n * @param provider_main_url
if(provider_list_fragment != null && preferences.contains(ProviderItem.DANGER_ON)) {
provider_list_fragment.removeLastItem();
}
- preferences.edit().remove(Provider.KEY).remove(ProviderItem.DANGER_ON).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit();
+ preferences.edit().remove(Provider.KEY).remove(ProviderItem.DANGER_ON).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).apply();
}
@Override
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 94de2fe8..c4f845b8 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -86,8 +86,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
handleVersion();
- boolean provider_configured = preferences.getString(Constants.KEY, "").isEmpty();
- if (provider_configured)
+ boolean no_provider_configured = preferences.getString(Constants.KEY, "").isEmpty();
+ if (no_provider_configured)
startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
else
buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false));
@@ -135,6 +135,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
preferences.edit().putInt(Constants.PARSED_SERIAL, 0).apply();
preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply();
updateEipService();
+ buildDashboard(false);
invalidateOptionsMenu();
if(data != null && data.hasExtra(LogInDialog.TAG)) {
logInDialog(Bundle.EMPTY);
diff --git a/app/src/main/java/se/leap/bitmaskclient/Provider.java b/app/src/main/java/se/leap/bitmaskclient/Provider.java
index fa1a4fb5..bb30905c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Provider.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Provider.java
@@ -110,11 +110,10 @@ public final class Provider implements Serializable {
}
protected String getDomain(){
- String domain = "Null";
+ String domain = "";
try {
domain = definition.getString(API_TERM_DOMAIN);
} catch (JSONException e) {
- domain = "Null";
e.printStackTrace();
}
return domain;
@@ -157,58 +156,25 @@ public final class Provider implements Serializable {
}
protected boolean hasEIP() {
- JSONArray services = null;
try {
- services = definition.getJSONArray(API_TERM_SERVICES); // returns ["openvpn"]
+ JSONArray services = definition.getJSONArray(API_TERM_SERVICES); // returns ["openvpn"]
+ for (int i=0;i<API_EIP_TYPES.length+1;i++){
+ try {
+ // Walk the EIP types array looking for matches in provider's service definitions
+ if ( Arrays.asList(API_EIP_TYPES).contains( services.getString(i) ) )
+ return true;
+ } catch (NullPointerException e){
+ e.printStackTrace();
+ return false;
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ }
+ }
} catch (Exception e) {
// TODO: handle exception
}
- for (int i=0;i<API_EIP_TYPES.length+1;i++){
- try {
- // Walk the EIP types array looking for matches in provider's service definitions
- if ( Arrays.asList(API_EIP_TYPES).contains( services.getString(i) ) )
- return true;
- } catch (NullPointerException e){
- e.printStackTrace();
- return false;
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return false;
- }
- }
return false;
}
-
- protected String getEIPType() {
- // FIXME!!!!! We won't always be providing /only/ OpenVPN, will we?
- // This will have to hook into some saved choice of EIP transport
- if ( instance.hasEIP() )
- return "OpenVPN";
- else
- return null;
- }
-
- protected JSONObject getEIP() {
- // FIXME!!!!! We won't always be providing /only/ OpenVPN, will we?
- // This will have to hook into some saved choice of EIP transport, cluster, gateway
- // with possible "choose at random" preference
- if ( instance.hasEIP() ){
- // TODO Might need an EIP class, but we've only got OpenVPN type right now,
- // and only one gateway for our only provider...
- // TODO We'll try to load from preferences, have to call ProviderAPI if we've got nothin...
- JSONObject eipObject = null;
- try {
- eipObject = new JSONObject( preferences.getString(PREFS_EIP_NAME, "") );
- } catch (JSONException e) {
- // TODO ConfigHelper.rescueJSON()
- // Still nothing?
- // TODO ProviderAPI.getEIP()
- e.printStackTrace();
- }
-
- return eipObject;
- } else
- return null;
- }
}
diff --git a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java
index 9afcf8a1..cb9f42fb 100644
--- a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -23,7 +23,6 @@ import android.view.*;
import android.widget.*;
import java.io.*;
import java.net.*;
-import java.util.*;
import org.json.*;
import se.leap.bitmaskclient.DownloadFailedDialog.DownloadFailedDialogInterface;
@@ -46,8 +45,12 @@ import se.leap.bitmaskclient.R;
public class ConfigurationWizard extends Activity
implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderDetailFragmentInterface, DownloadFailedDialogInterface, Receiver {
- private ProgressBar mProgressBar;
- private TextView progressbar_description;
+
+ @InjectView(R.id.progressbar_configuration_wizard)
+ private ProgressBar mProgressBar;
+ @InjectView(R.id.progressbar_description)
+ private TextView progressbar_description;
+
private ProviderListFragment provider_list_fragment;
private Intent mConfigState = new Intent();
private ProviderItem selected_provider;
@@ -148,10 +151,10 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
provider_list_fragment.setArguments(arguments);
- putProviderListFragment(provider_list_fragment);
+ putProviderListFragment();
}
- private void putProviderListFragment(ProviderListFragment fragment) {
+ private void putProviderListFragment() {
fragment_manager.replace(R.id.configuration_wizard_layout, provider_list_fragment, ProviderListFragment.TAG);
}
@@ -190,13 +193,13 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
} else if(resultCode == ProviderAPI.PROVIDER_NOK) {
hideProgressBar();
- preferences.edit().remove(Provider.KEY).commit();
+ preferences.edit().remove(Provider.KEY).apply();
setting_up_provider = false;
setResult(RESULT_CANCELED, mConfigState);
String reason_to_fail = resultData.getString(ProviderAPI.ERRORS);
- showDownloadFailedDialog(getCurrentFocus(), reason_to_fail);
+ showDownloadFailedDialog(reason_to_fail);
}
else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) {
mProgressBar.incrementProgressBy(1);
@@ -248,7 +251,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
mProgressBar.setProgress(0);
progressbar_description.setVisibility(TextView.GONE);
- preferences.edit().remove(Provider.KEY).commit();
+ preferences.edit().remove(Provider.KEY).apply();
setting_up_provider = false;
showAllProviders();
}
@@ -276,14 +279,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
private ProviderItem getProvider(String name) {
- Iterator<ProviderItem> providers_iterator = ProviderListContent.ITEMS.iterator();
- while(providers_iterator.hasNext()) {
- ProviderItem provider = providers_iterator.next();
- if(provider.name().equalsIgnoreCase(name)) {
- return provider;
- }
+ for (ProviderItem provider : ProviderListContent.ITEMS) {
+ if(provider.name().equalsIgnoreCase(name)) {
+ return provider;
}
- return null;
+ }
+ return null;
}
private void startProgressBar() {
@@ -299,14 +300,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private int getProviderIndex(String id) {
int index = 0;
- Iterator<ProviderItem> providers_iterator = ProviderListContent.ITEMS.iterator();
- while(providers_iterator.hasNext()) {
- ProviderItem provider = providers_iterator.next();
- if(provider.name().equalsIgnoreCase(id)) {
- break;
- } else index++;
- }
- return index;
+ for (ProviderItem provider : ProviderListContent.ITEMS) {
+ if(provider.name().equalsIgnoreCase(id)) {
+ break;
+ } else index++;
+ }
+ return index;
}
private int listItemHeight() {
@@ -314,8 +313,8 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
ListAdapter provider_list_adapter = provider_list_view.getAdapter();
View listItem = provider_list_adapter.getView(0, null, provider_list_view);
listItem.setLayoutParams(new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT));
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT));
WindowManager wm = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
@@ -361,10 +360,11 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
try {
InputStream input_stream_file_contents = getAssets().open(filepath);
byte[] urls_file_bytes = new byte[input_stream_file_contents.available()];
- input_stream_file_contents.read(urls_file_bytes);
- String urls_file_content = new String(urls_file_bytes);
- JSONObject file_contents = new JSONObject(urls_file_content);
- provider_main_url = file_contents.getString(Provider.MAIN_URL);
+ if(input_stream_file_contents.read(urls_file_bytes) > 0) {
+ String urls_file_content = new String(urls_file_bytes);
+ JSONObject file_contents = new JSONObject(urls_file_content);
+ provider_main_url = file_contents.getString(Provider.MAIN_URL);
+ }
} catch (JSONException e) {
} catch (IOException e) {
}
@@ -373,15 +373,13 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private String getId(String provider_main_url) {
try {
- URL provider_url = new URL(provider_main_url);
- Iterator<ProviderItem> providers_iterator = ProviderListContent.ITEMS.iterator();
- while(providers_iterator.hasNext()) {
- ProviderItem provider = providers_iterator.next();
- URL aux_provider_url = new URL(provider.providerMainUrl());
- if(isSameURL(provider_url, aux_provider_url)) {
- return provider.name();
+ URL provider_url = new URL(provider_main_url);
+ for (ProviderItem provider : ProviderListContent.ITEMS) {
+ URL aux_provider_url = new URL(provider.providerMainUrl());
+ if(isSameURL(provider_url, aux_provider_url)) {
+ return provider.name();
+ }
}
- }
} catch (MalformedURLException e) {
e.printStackTrace();
}
@@ -397,16 +395,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
* same protocol, false otherwise.
*/
private boolean isSameURL(final URL url, final URL baseUrl) {
- if (!url.getProtocol().equals(baseUrl.getProtocol())) {
- return false;
- }
- if (!url.getHost().equals(baseUrl.getHost())) {
- return false;
- }
- if (url.getPort() != baseUrl.getPort()) {
- return false;
- }
- return true;
+ return url.getProtocol().equals(baseUrl.getProtocol()) &&
+ url.getHost().equals(baseUrl.getHost()) &&
+ url.getPort() == baseUrl.getPort();
}
/**
@@ -452,10 +443,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
* Once selected a provider, this fragment offers the user to log in,
* use it anonymously (if possible)
* or cancel his/her election pressing the back button.
- * @param view
* @param reason_to_fail
*/
- public void showDownloadFailedDialog(View view, String reason_to_fail) {
+ public void showDownloadFailedDialog(String reason_to_fail) {
FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(DownloadFailedDialog.TAG);
DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail);
@@ -555,7 +545,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
if(provider_list_fragment != null) {
provider_list_fragment.removeLastItem();
}
- preferences.edit().remove(Provider.KEY).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit();
+ preferences.edit().remove(Provider.KEY).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).apply();
}
@Override