summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderManager.java26
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java30
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/FabButton.java34
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java32
4 files changed, 89 insertions, 33 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
index 220a71c8..13ef9b80 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
@@ -28,7 +28,8 @@ public class ProviderManager implements AdapteeCollection<Provider> {
if (instance == null)
instance = new ProviderManager(assets_manager);
- instance.addCustomProviders(external_files_dir);
+ if(external_files_dir != null)
+ instance.addCustomProviders(external_files_dir);
return instance;
}
@@ -120,7 +121,8 @@ public class ProviderManager implements AdapteeCollection<Provider> {
public Set<Provider> providers() {
Set<Provider> all_providers = new HashSet<Provider>();
all_providers.addAll(default_providers);
- all_providers.addAll(custom_providers);
+ if(custom_providers != null)
+ all_providers.addAll(custom_providers);
return all_providers;
}
@@ -140,25 +142,27 @@ public class ProviderManager implements AdapteeCollection<Provider> {
}
@Override
- public void add(Provider element) {
+ public boolean add(Provider element) {
if (!default_providers.contains(element))
- custom_providers.add(element);
+ return custom_providers.add(element);
+ else return true;
}
@Override
- public void remove(Provider element) {
- custom_providers.remove(element);
+ public boolean remove(Object element) {
+ return custom_providers.remove(element);
}
@Override
- public void addAll(Collection<Provider> elements) {
- custom_providers.addAll(elements);
+ public boolean addAll(Collection<? extends Provider> elements) {
+ return custom_providers.addAll(elements);
}
@Override
- public void removeAll(Collection<Provider> elements) {
- custom_providers.removeAll(elements);
- default_providers.removeAll(elements);
+ public boolean removeAll(Collection<?> elements) {
+ if(!elements.getClass().equals(Provider.class))
+ return false;
+ return default_providers.removeAll(elements) || custom_providers.removeAll(elements);
}
@Override
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
index 171035d1..f41049c5 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
@@ -16,20 +16,27 @@
*/
package se.leap.bitmaskclient.eip;
-import android.content.*;
+import android.content.Context;
+import android.content.SharedPreferences;
-import com.google.gson.*;
-import com.google.gson.reflect.*;
-import com.google.gson.stream.JsonWriter;
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
-import org.json.*;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
-import java.lang.reflect.*;
-import java.util.*;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
-import de.blinkt.openvpn.*;
-import de.blinkt.openvpn.core.*;
-import se.leap.bitmaskclient.*;
+import de.blinkt.openvpn.VpnProfile;
+import de.blinkt.openvpn.core.Connection;
+import de.blinkt.openvpn.core.ProfileManager;
+import se.leap.bitmaskclient.Provider;
/**
* @author parmegv
@@ -66,7 +73,7 @@ public class GatewaysManager {
}
public void addFromString(String gateways) {
- List<Gateway> gateways_list = new ArrayList<Gateway>();
+ List<Gateway> gateways_list = new ArrayList<>();
try {
gateways_list = new Gson().fromJson(gateways, list_type);
} catch (JsonSyntaxException e) {
@@ -76,7 +83,6 @@ public class GatewaysManager {
if (gateways_list != null) {
for (Gateway gateway : gateways_list)
addGateway(gateway);
- this.gateways.addAll(gateways_list);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/FabButton.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/FabButton.java
new file mode 100644
index 00000000..1bf1847c
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/FabButton.java
@@ -0,0 +1,34 @@
+package se.leap.bitmaskclient.userstatus;
+
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import mbanje.kurt.fabbutton.CircleImageView;
+import se.leap.bitmaskclient.R;
+
+public class FabButton extends mbanje.kurt.fabbutton.FabButton {
+
+
+ public FabButton(Context context) {
+ super(context);
+ }
+
+ public FabButton(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public FabButton(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void init(Context context, AttributeSet attrs, int defStyle) {
+ super.init(context, attrs, defStyle);
+ super.init(context, attrs, defStyle);
+ }
+
+ private CircleImageView getImage() {
+ return (CircleImageView) findViewById(R.id.fabbutton_circle);
+ }
+}
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 f0f4a8fa..f670553f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
@@ -1,17 +1,29 @@
package se.leap.bitmaskclient.userstatus;
-import android.app.*;
-import android.os.*;
-import android.view.*;
-import android.widget.*;
+import android.app.Activity;
+import android.app.Fragment;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
import org.jetbrains.annotations.NotNull;
-import java.util.*;
-
-import butterknife.*;
-import mbanje.kurt.fabbutton.FabButton;
-import se.leap.bitmaskclient.*;
+import java.util.Observable;
+import java.util.Observer;
+
+import butterknife.ButterKnife;
+import butterknife.InjectView;
+import butterknife.OnClick;
+import se.leap.bitmaskclient.Dashboard;
+import se.leap.bitmaskclient.Provider;
+import se.leap.bitmaskclient.ProviderAPI;
+import se.leap.bitmaskclient.ProviderAPICommand;
+import se.leap.bitmaskclient.ProviderAPIResultReceiver;
+import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.eip.EipStatus;
public class UserStatusFragment extends Fragment implements Observer, SessionDialog.SessionDialogInterface {
@@ -50,7 +62,7 @@ public class UserStatusFragment extends Fragment implements Observer, SessionDia
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_user_session, container, false);
+ View view = inflater.inflate(R.layout.user_session_fragment, container, false);
ButterKnife.inject(this, view);
Bundle arguments = getArguments();