summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap/bitmaskclient')
-rw-r--r--src/se/leap/bitmaskclient/Dashboard.java53
-rw-r--r--src/se/leap/bitmaskclient/EipServiceFragment.java8
2 files changed, 52 insertions, 9 deletions
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java
index 68b7d248..5066f286 100644
--- a/src/se/leap/bitmaskclient/Dashboard.java
+++ b/src/se/leap/bitmaskclient/Dashboard.java
@@ -39,6 +39,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
+import android.os.ResultReceiver;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -370,7 +371,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
authed_eip = false;
ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip);
- eipStatus.setText("Connection secure using anonymous certificate.");
+ changeStatusMessage(resultCode);
mProgressBar.setVisibility(ProgressBar.GONE);
mProgressBar.setProgress(0);
invalidateOptionsMenu();
@@ -383,19 +384,47 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
Toast.makeText(getApplicationContext(), R.string.log_out_failed_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) {
setResult(RESULT_OK);
- eipStatus.setText("Connection secure using authed certificate.");
mProgressBar.setVisibility(ProgressBar.GONE);
+ changeStatusMessage(resultCode);
//mProgressBar.setProgress(0);
Toast.makeText(getApplicationContext(), R.string.successful_authed_cert_downloaded_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
setResult(RESULT_CANCELED);
mProgressBar.setVisibility(ProgressBar.GONE);
//mProgressBar.setProgress(0);
- eipStatus.setText("Connection secure using anonymous certificate.");
+ changeStatusMessage(resultCode);
Toast.makeText(getApplicationContext(), R.string.authed_cert_download_failed_message, Toast.LENGTH_LONG).show();
}
}
+ private void changeStatusMessage(final int previous_result_code) {
+ // TODO Auto-generated method stub
+ ResultReceiver eip_status_receiver = new ResultReceiver(new Handler()){
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ super.onReceiveResult(resultCode, resultData);
+ String request = resultData.getString(EIP.REQUEST_TAG);
+ if(resultCode == RESULT_OK) {
+ if(request.equalsIgnoreCase(EIP.ACTION_IS_EIP_RUNNING)) {
+ switch (previous_result_code) {
+ case ProviderAPI.LOGOUT_SUCCESSFUL: eipStatus.setText(R.string.anonymous_secured_status); break;
+ case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: eipStatus.setText(R.string.authed_secured_status); break;
+ }
+ }
+ } else {
+ if(request.equalsIgnoreCase(EIP.ACTION_IS_EIP_RUNNING)) {
+ switch (previous_result_code) {
+ case ProviderAPI.LOGOUT_SUCCESSFUL: eipStatus.setText(R.string.future_anonymous_secured_status); break;
+ case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: eipStatus.setText(R.string.future_authed_secured_status); break;
+ }
+ }
+ }
+ }
+ };
+ eipIsRunning(eip_status_receiver);
+
+ }
+
/**
* For retrieving the base application Context in classes that don't extend
* Android's Activity class
@@ -406,11 +435,19 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
return app;
}
- @Override
- public void startActivityForResult(Intent intent, int requestCode) {
- intent.putExtra(Dashboard.REQUEST_CODE, requestCode);
- super.startActivityForResult(intent, requestCode);
- }
+ /**
+ * Send a command to EIP
+ *
+ * @param action A valid String constant from EIP class representing an Intent
+ * filter for the EIP class
+ */
+ private void eipIsRunning(ResultReceiver eip_receiver){
+ // TODO validate "action"...how do we get the list of intent-filters for a class via Android API?
+ Intent eip_intent = new Intent(this, EIP.class);
+ eip_intent.setAction(EIP.ACTION_IS_EIP_RUNNING);
+ eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver);
+ startService(eip_intent);
+ }
public class ProviderAPIBroadcastReceiver_Update extends BroadcastReceiver {
diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java
index 1b2cfb20..0d73f544 100644
--- a/src/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/src/se/leap/bitmaskclient/EipServiceFragment.java
@@ -178,11 +178,17 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli
String statusMessage = "";
String prefix = getString(localizedResId);
if (state.equals("CONNECTED")){
+<<<<<<< HEAD
statusMessage = getString(R.string.eip_state_connected);
+=======
+ statusMessage = getResources().getString(R.string.connection_secure);
+>>>>>>> Dashboard asks for real VPN state.
getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
mEipStartPending = false;
} else if (state.equals("BYTECOUNT")) {
- statusMessage = logmessage;
+ statusMessage = getString(R.string.eip_state_connected); getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
+ mEipStartPending = false;
+
} else if ( (state.equals("NOPROCESS") && !mEipStartPending ) || state.equals("EXITING")) {
statusMessage = getString(R.string.eip_state_not_connected);
getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);