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/leap/bitmaskclient/Dashboard.java | |
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/leap/bitmaskclient/Dashboard.java')
-rw-r--r-- | src/se/leap/bitmaskclient/Dashboard.java | 53 |
1 files changed, 45 insertions, 8 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 { |