diff options
author | Parménides GV <parmegv@sdf.org> | 2013-10-07 16:15:50 +0200 |
---|---|---|
committer | cyBerta <richy@cyborgsociety.org> | 2013-11-15 23:53:51 +0100 |
commit | d9c8729bfdead18aa695ceddac3a12efe6c8b568 (patch) | |
tree | 2d498408730d65b8b943f2133459a709bfd177e7 /src/se | |
parent | 76d52773a237da8fcae3670a959bbe2bfe609796 (diff) |
Dashboard asks for real VPN state.
Right now, the answer is always "disconnected", I think it's a problem in EIP.isRunning().
I've also added some new strings, trying to minimize the number of them scattered through litterals around the code.
Diffstat (limited to 'src/se')
-rw-r--r-- | src/se/leap/bitmaskclient/Dashboard.java | 53 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/EipServiceFragment.java | 8 |
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); |