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/Dashboard.java7
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java3
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionFragment.java35
4 files changed, 38 insertions, 19 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index a854ffd4..f87c9f94 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -82,8 +82,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
User.init();
ProviderAPICommand.initialize(this);
- providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
- providerAPI_result_receiver.setReceiver(this);
+ providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this);
restoreProvider(savedInstanceState);
if (!provider.isConfigured())
@@ -199,7 +198,11 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
ButterKnife.inject(this);
provider_name.setText(provider.getDomain());
+
user_session_fragment = new UserSessionFragment();
+ Bundle bundle = new Bundle();
+ bundle.putBoolean(Provider.ALLOW_REGISTRATION, provider.allowsRegistration());
+ user_session_fragment.setArguments(bundle);
fragment_manager.replace(R.id.user_session_fragment, user_session_fragment, UserSessionFragment.TAG);
if (provider.hasEIP()) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index 4d1eb4bf..5a7b2ced 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -45,7 +45,7 @@ public class EipFragment extends Fragment implements Observer {
Button main_button;
private static Dashboard dashboard;
- private static EIPReceiver provider_api_receiver;
+ private static EIPReceiver eip_receiver;
private static EipStatus eip_status;
private boolean wants_to_connect;
@@ -53,7 +53,9 @@ public class EipFragment extends Fragment implements Observer {
super.onAttach(activity);
dashboard = (Dashboard) activity;
- if(provider_api_receiver != null)
+ ProviderAPIResultReceiver provider_api_receiver = new ProviderAPIResultReceiver(new Handler(), dashboard);
+
+ if(eip_receiver != null)
ProviderAPICommand.execute(Bundle.EMPTY, ProviderAPI.DOWNLOAD_EIP_SERVICE, provider_api_receiver);
}
@@ -62,7 +64,7 @@ public class EipFragment extends Fragment implements Observer {
super.onCreate(savedInstanceState);
eip_status = EipStatus.getInstance();
eip_status.addObserver(this);
- provider_api_receiver = new EIPReceiver(new Handler());
+ eip_receiver = new EIPReceiver(new Handler());
}
@Override
@@ -220,7 +222,7 @@ public class EipFragment 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(dashboard.getApplicationContext(), EIP.class);
vpn_intent.setAction(action);
- vpn_intent.putExtra(Constants.RECEIVER_TAG, provider_api_receiver);
+ vpn_intent.putExtra(Constants.RECEIVER_TAG, eip_receiver);
dashboard.startService(vpn_intent);
}
@@ -336,6 +338,6 @@ public class EipFragment extends Fragment implements Observer {
public static EIPReceiver getReceiver() {
- return provider_api_receiver;
+ return eip_receiver;
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java b/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java
index 533e5caf..9b880f89 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java
@@ -26,8 +26,9 @@ import android.os.*;
public class ProviderAPIResultReceiver extends ResultReceiver {
private Receiver mReceiver;
- public ProviderAPIResultReceiver(Handler handler) {
+ public ProviderAPIResultReceiver(Handler handler, Receiver receiver) {
super(handler);
+ setReceiver(receiver);
// TODO Auto-generated constructor stub
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionFragment.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionFragment.java
index 02b9fbeb..dc334c3d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionFragment.java
@@ -15,8 +15,6 @@ import se.leap.bitmaskclient.eip.EipStatus;
public class UserSessionFragment extends Fragment implements Observer, SessionDialog.SessionDialogInterface {
- private static View view;
-
public static String TAG = UserSessionFragment.class.getSimpleName();
private static Dashboard dashboard;
private ProviderAPIResultReceiver providerAPI_result_receiver;
@@ -37,8 +35,6 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
user_session_status = UserSessionStatus.getInstance(getResources());
user_session_status.addObserver(this);
-
- handleNewUserSessionStatus(user_session_status);
}
@Override
@@ -52,7 +48,15 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_user_session, container, false);
+
+ View view = inflater.inflate(R.layout.fragment_user_session, container, false);
+ ButterKnife.inject(this, view);
+
+ Bundle arguments = getArguments();
+ allows_registration = arguments.getBoolean(Provider.ALLOW_REGISTRATION);
+ handleNewUserSessionStatus(user_session_status);
+
+ return view;
}
@Override
@@ -69,8 +73,7 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
super.onAttach(activity);
dashboard = (Dashboard) activity;
- providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
- providerAPI_result_receiver.setReceiver(dashboard);
+ providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), dashboard);
}
public void restoreSessionStatus(Bundle savedInstanceState) {
@@ -106,7 +109,7 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
showUserSessionProgressBar();
else
hideUserSessionProgressBar();
- changeSessionStatusMessage();
+ changeMessage();
updateButton();
}
}
@@ -129,7 +132,7 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
});
}
- private void changeSessionStatusMessage() {
+ private void changeMessage() {
final String message = user_session_status.toString();
dashboard.runOnUiThread(new Runnable() {
@Override
@@ -141,9 +144,19 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
private void updateButton() {
if(User.loggedIn())
- main_button.setText(getString(R.string.logout_button));
+ dashboard.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ main_button.setText(dashboard.getString(R.string.logout_button));
+ }
+ });
else if(allows_registration)
- main_button.setText(getString(R.string.login_button));
+ dashboard.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ main_button.setText(dashboard.getString(R.string.login_button));
+ }
+ });
}