summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-10-14 22:14:08 +0200
committerParménides GV <parmegv@sdf.org>2014-10-14 22:14:08 +0200
commit6bc3d7da8fdf32cdbd934831f2385f5098c7f979 (patch)
tree286bd9d2088eb414e7c8fb0dfd4e3c32f7145791 /app/src/main/java/se/leap
parent11528c3f7124090ef44675cf613a949ed07ad9bb (diff)
Big refactor, ProviderAPI looks better.
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java366
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EIP.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/LogInDialog.java15
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java39
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java11
7 files changed, 212 insertions, 224 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 16e4cf03..286d88c3 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -75,8 +75,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
protected static SharedPreferences preferences;
private static Provider provider;
- private TextView providerNameTV;
-
private boolean authed_eip = false;
public ProviderAPIResultReceiver providerAPI_result_receiver;
@@ -143,7 +141,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
startService(updateEIP);
buildDashboard(false);
invalidateOptionsMenu();
- if(data != null && data.hasExtra(LogInDialog.VERB)) {
+ if(data != null && data.hasExtra(LogInDialog.TAG)) {
View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
logInDialog(Bundle.EMPTY);
}
@@ -190,7 +188,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
setContentView(R.layout.client_dashboard);
- providerNameTV = (TextView) findViewById(R.id.providerName);
+ TextView providerNameTV = (TextView) findViewById(R.id.providerName);
providerNameTV.setText(provider.getDomain());
providerNameTV.setTextSize(28);
@@ -269,14 +267,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER);
return true;
case R.id.login_button:
- View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
logInDialog(Bundle.EMPTY);
return true;
case R.id.logout_button:
logOut();
return true;
case R.id.signup_button:
- signUpDialog(((ViewGroup)findViewById(android.R.id.content)).getChildAt(0), Bundle.EMPTY);
+ signUpDialog(Bundle.EMPTY);
return true;
default:
return super.onOptionsItemSelected(item);
@@ -284,38 +281,59 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
- @Override
- public void authenticate(String username, String password) {
- mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
- eipStatus = (TextView) findViewById(R.id.eipStatus);
+ private Intent prepareProviderAPICommand() {
+ mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
+ eipStatus = (TextView) findViewById(R.id.eipStatus);
- providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
- providerAPI_result_receiver.setReceiver(this);
+ providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
+ providerAPI_result_receiver.setReceiver(this);
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
-
- Bundle parameters = new Bundle();
- parameters.putString(LogInDialog.USERNAME, username);
- parameters.putString(LogInDialog.PASSWORD, password);
+ Intent command = new Intent(this, ProviderAPI.class);
- JSONObject provider_json;
- try {
- provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
- parameters.putString(Provider.API_URL, provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION));
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ return command;
+ }
- provider_API_command.setAction(ProviderAPI.SRP_AUTH);
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
-
- mProgressBar.setVisibility(ProgressBar.VISIBLE);
- eipStatus.setText(R.string.authenticating_message);
- //mProgressBar.setMax(4);
- startService(provider_API_command);
+ private FragmentTransaction removePreviousFragment(String tag) {
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ Fragment previous_fragment = getFragmentManager().findFragmentByTag(tag);
+ if (previous_fragment != null) {
+ transaction.remove(previous_fragment);
}
+ transaction.addToBackStack(null);
+
+ return transaction;
+ }
+
+ /**
+ * Shows the log in dialog.
+ */
+ public void logInDialog(Bundle resultData) {
+ FragmentTransaction transaction = removePreviousFragment(LogInDialog.TAG);
+
+ DialogFragment newFragment = LogInDialog.newInstance();
+ if(resultData != null && !resultData.isEmpty())
+ newFragment.setArguments(resultData);
+ newFragment.show(transaction, LogInDialog.TAG);
+ }
+
+ @Override
+ public void logIn(String username, String password) {
+ Intent provider_API_command = prepareProviderAPICommand();
+ Bundle parameters = provider_API_command.getExtras().getBundle(ProviderAPI.PARAMETERS);
+ if(parameters == null)
+ parameters = new Bundle();
+
+ parameters.putString(SessionDialogInterface.USERNAME, username);
+ parameters.putString(SessionDialogInterface.PASSWORD, password);
+
+ mProgressBar.setVisibility(ProgressBar.VISIBLE);
+ eipStatus.setText(R.string.authenticating_message);
+
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
+ provider_API_command.setAction(ProviderAPI.SRP_AUTH);
+ startService(provider_API_command);
+ }
public void cancelAuthedEipOn() {
EipServiceFragment eipFragment = (EipServiceFragment) getFragmentManager().findFragmentByTag(EipServiceFragment.TAG);
@@ -323,125 +341,59 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
public void cancelLoginOrSignup() {
- if(mProgressBar == null) mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
- if(mProgressBar != null) {
- mProgressBar.setVisibility(ProgressBar.GONE);
- if(eipStatus == null) eipStatus = (TextView) findViewById(R.id.eipStatus);
- if(eipStatus != null) eipStatus.setText("");
- }
- cancelAuthedEipOn();
+ hideProgressBar();
}
- /**
- * Asks ProviderAPI to log out.
- */
- public void logOut() {
- providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
- providerAPI_result_receiver.setReceiver(this);
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
-
- Bundle parameters = new Bundle();
-
- JSONObject provider_json;
- try {
- provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
- parameters.putString(Provider.API_URL, provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION));
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- provider_API_command.setAction(ProviderAPI.LOG_OUT);
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
-
- if(mProgressBar == null) mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
- mProgressBar.setVisibility(ProgressBar.VISIBLE);
- if(eipStatus == null) eipStatus = (TextView) findViewById(R.id.eipStatus);
- eipStatus.setText(R.string.logout_message);
- // eipStatus.setText("Starting to logout");
-
- startService(provider_API_command);
- //mProgressBar.setMax(1);
-
- }
-
- /**
- * Shows the log in dialog.
- */
- public void logInDialog(Bundle resultData) {
- Log.d("Dashboard", "Log In Dialog");
- FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction();
- Fragment previous_log_in_dialog = getFragmentManager().findFragmentByTag(LogInDialog.TAG);
- if (previous_log_in_dialog != null) {
- fragment_transaction.remove(previous_log_in_dialog);
- }
- fragment_transaction.addToBackStack(null);
-
- DialogFragment newFragment = LogInDialog.newInstance();
- if(resultData != null && !resultData.isEmpty()) {
- newFragment.setArguments(resultData);
- }
- newFragment.show(fragment_transaction, LogInDialog.TAG);
- }
-
- @Override
- public void signUp(String username, String password) {
- mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
- eipStatus = (TextView) findViewById(R.id.eipStatus);
-
- providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
- providerAPI_result_receiver.setReceiver(this);
-
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
-
- Bundle parameters = new Bundle();
- parameters.putString(SignUpDialog.USERNAME, username);
- parameters.putString(SignUpDialog.PASSWORD, password);
-
- JSONObject provider_json;
- try {
- provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
- parameters.putString(Provider.API_URL, provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION));
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- provider_API_command.setAction(ProviderAPI.SRP_REGISTER);
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ /**
+ * Asks ProviderAPI to log out.
+ */
+ public void logOut() {
+ Intent provider_API_command = prepareProviderAPICommand();
+
+ if(mProgressBar == null) mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
+ mProgressBar.setVisibility(ProgressBar.VISIBLE);
+ if(eipStatus == null) eipStatus = (TextView) findViewById(R.id.eipStatus);
+ eipStatus.setText(R.string.logout_message);
- mProgressBar.setVisibility(ProgressBar.VISIBLE);
- eipStatus.setText(R.string.signingup_message);
- //mProgressBar.setMax(4);
- startService(provider_API_command);
- }
+ provider_API_command.setAction(ProviderAPI.LOG_OUT);
+ startService(provider_API_command);
+ }
- /**
- * Shows the sign up dialog.
- * @param view from which the dialog is created.
- */
- public void signUpDialog(View view, Bundle resultData) {
- FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction();
- Fragment previous_sign_up_dialog = getFragmentManager().findFragmentByTag(SignUpDialog.TAG);
- if (previous_sign_up_dialog != null) {
- fragment_transaction.remove(previous_sign_up_dialog);
- }
- fragment_transaction.addToBackStack(null);
-
- DialogFragment newFragment = SignUpDialog.newInstance();
- if(resultData != null && !resultData.isEmpty()) {
- newFragment.setArguments(resultData);
- }
- newFragment.show(fragment_transaction, SignUpDialog.TAG);
+ /**
+ * Shows the sign up dialog.
+ */
+ public void signUpDialog(Bundle resultData) {
+ FragmentTransaction transaction = removePreviousFragment(SignUpDialog.TAG);
+
+ DialogFragment newFragment = SignUpDialog.newInstance();
+ if(resultData != null && !resultData.isEmpty()) {
+ newFragment.setArguments(resultData);
}
+ newFragment.show(transaction, SignUpDialog.TAG);
+ }
+
+ @Override
+ public void signUp(String username, String password) {
+ Intent provider_API_command = prepareProviderAPICommand();
+ Bundle parameters = provider_API_command.getExtras().getBundle(ProviderAPI.PARAMETERS);
+ if(parameters == null)
+ parameters = new Bundle();
+
+ parameters.putString(SessionDialogInterface.USERNAME, username);
+ parameters.putString(SessionDialogInterface.PASSWORD, password);
+
+ mProgressBar.setVisibility(ProgressBar.VISIBLE);
+ eipStatus.setText(R.string.signingup_message);
+
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
+ provider_API_command.setAction(ProviderAPI.SRP_REGISTER);
+ startService(provider_API_command);
+ }
/**
* Asks ProviderAPI to download an authenticated OpenVPN certificate.
- * @param session_id cookie for the server to allow us to download the certificate.
*/
- private void downloadAuthedUserCertificate(/*Cookie session_id*/) {
+ private void downloadAuthedUserCertificate() {
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
providerAPI_result_receiver.setReceiver(this);
@@ -449,8 +401,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
Bundle parameters = new Bundle();
parameters.putString(ConfigurationWizard.TYPE_OF_CERTIFICATE, ConfigurationWizard.AUTHED_CERTIFICATE);
- /*parameters.putString(ConfigHelper.SESSION_ID_COOKIE_KEY, session_id.getName());
- parameters.putString(ConfigHelper.SESSION_ID_KEY, session_id.getValue());*/
provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE);
provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
@@ -461,50 +411,55 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
- if(resultCode == ProviderAPI.SRP_REGISTRATION_SUCCESSFUL){
- authenticate(resultData.getString(LogInDialog.USERNAME), resultData.getString(LogInDialog.PASSWORD));
- } else if(resultCode == ProviderAPI.SRP_REGISTRATION_FAILED){
- signUpDialog(((ViewGroup)findViewById(android.R.id.content)).getChildAt(0), resultData);
- } else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL){
- String session_id_cookie_key = resultData.getString(ProviderAPI.SESSION_ID_COOKIE_KEY);
- String session_id_string = resultData.getString(ProviderAPI.SESSION_ID_KEY);
- setResult(RESULT_OK);
-
- authed_eip = true;
- preferences.edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit();
-
- invalidateOptionsMenu();
- mProgressBar.setVisibility(ProgressBar.GONE);
- changeStatusMessage(resultCode);
+ if(resultCode == ProviderAPI.SRP_REGISTRATION_SUCCESSFUL) {
+ String username = resultData.getString(SessionDialogInterface.USERNAME);
+ String password = resultData.getString(SessionDialogInterface.PASSWORD);
+ logIn(username, password);
+ } else if(resultCode == ProviderAPI.SRP_REGISTRATION_FAILED) {
+ changeStatusMessage(resultCode);
+ hideProgressBar();
+
+ signUpDialog(resultData);
+ } else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL) {
+ changeStatusMessage(resultCode);
+ hideProgressBar();
+
+ invalidateOptionsMenu();
+
+ authed_eip = true;
+ preferences.edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit();
- //Cookie session_id = new BasicClientCookie(session_id_cookie_key, session_id_string);
- downloadAuthedUserCertificate(/*session_id*/);
- } else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_FAILED) {
- logInDialog(resultData);
- } else if(resultCode == ProviderAPI.LOGOUT_SUCCESSFUL) {
- authed_eip = false;
- preferences.edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit();
- mProgressBar.setVisibility(ProgressBar.GONE);
- mProgressBar.setProgress(0);
- invalidateOptionsMenu();
- setResult(RESULT_OK);
- changeStatusMessage(resultCode);
-
- } else if(resultCode == ProviderAPI.LOGOUT_FAILED) {
- setResult(RESULT_CANCELED);
- changeStatusMessage(resultCode);
- mProgressBar.setVisibility(ProgressBar.GONE);
- } else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) {
- setResult(RESULT_OK);
+ downloadAuthedUserCertificate();
+ } else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_FAILED) {
+ changeStatusMessage(resultCode);
+ hideProgressBar();
+
+ logInDialog(resultData);
+ } else if(resultCode == ProviderAPI.LOGOUT_SUCCESSFUL) {
+ changeStatusMessage(resultCode);
+ hideProgressBar();
+
+ invalidateOptionsMenu();
+
+ authed_eip = false;
+ preferences.edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit();
+
+ } else if(resultCode == ProviderAPI.LOGOUT_FAILED) {
+ changeStatusMessage(resultCode);
+ hideProgressBar();
+
+ setResult(RESULT_CANCELED);
+ } else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) {
changeStatusMessage(resultCode);
- if(mProgressBar != null)
- mProgressBar.setVisibility(ProgressBar.GONE);
+ hideProgressBar();
+
+ setResult(RESULT_OK);
eipStart();
- } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
- setResult(RESULT_CANCELED);
+ } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
changeStatusMessage(resultCode);
- mProgressBar.setVisibility(ProgressBar.GONE);
- }
+ hideProgressBar();
+ setResult(RESULT_CANCELED);
+ }
}
private void changeStatusMessage(final int previous_result_code) {
@@ -513,6 +468,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
protected void onReceiveResult(int resultCode, Bundle resultData){
super.onReceiveResult(resultCode, resultData);
String request = resultData.getString(EIP.REQUEST_TAG);
+ if(eipStatus == null) eipStatus = (TextView) findViewById(R.id.eipStatus);
if (request.equalsIgnoreCase(EIP.ACTION_IS_EIP_RUNNING)){
if (resultCode == Activity.RESULT_OK){
@@ -532,6 +488,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: eipStatus.setText(R.string.succesful_authentication_message); break;
case ProviderAPI.SRP_AUTHENTICATION_FAILED: eipStatus.setText(R.string.authentication_failed_message); break;
+ case ProviderAPI.SRP_REGISTRATION_FAILED: eipStatus.setText(R.string.registration_failed_message); break;
case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: break;
case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eipStatus.setText(R.string.incorrectly_downloaded_certificate_message); break;
case ProviderAPI.LOGOUT_SUCCESSFUL: eipStatus.setText(R.string.logged_out_message); break;
@@ -545,6 +502,14 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
eipIsRunning(eip_status_receiver);
}
+ private void hideProgressBar() {
+ if(mProgressBar == null)
+ mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
+
+ mProgressBar.setProgress(0);
+ mProgressBar.setVisibility(ProgressBar.GONE);
+ }
+
/**
* For retrieving the base application Context in classes that don't extend
* Android's Activity class
@@ -556,11 +521,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
- @Override
+ @Override
public void startActivityForResult(Intent intent, int requestCode) {
intent.putExtra(Dashboard.REQUEST_CODE, requestCode);
super.startActivityForResult(intent, requestCode);
}
+
/**
* Send a command to EIP
*
@@ -575,30 +541,22 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
startService(eip_intent);
}
- /**
- * Send a command to EIP
- *
- */
- private void eipStop(){
- // 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_STOP_EIP);
- // eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver);fi
- startService(eip_intent);
-
- }
+ private void eipStop(){
+ // 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_STOP_EIP);
+ startService(eip_intent);
+ }
- private void eipStart(){
+ private void eipStart() {
Intent eip_intent = new Intent(this, EIP.class);
eip_intent.setAction(EIP.ACTION_START_EIP);
- eip_intent.putExtra(EIP.RECEIVER_TAG, EipServiceFragment.getReceiver());
- startService(eip_intent);
-
+ startService(eip_intent);
}
- protected void setProgressBarVisibility(int visibility) {
+ protected void showProgressBar() {
if(mProgressBar == null)
mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
- mProgressBar.setVisibility(visibility);
+ mProgressBar.setVisibility(ProgressBar.VISIBLE);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java
index 4a8bae46..1b34ac21 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java
@@ -155,6 +155,7 @@ public final class EIP extends IntentService {
activeGateway = selectGateway();
if(activeGateway != null && activeGateway.mVpnProfile != null) {
+ mReceiver = EipServiceFragment.getReceiver();
launchActiveGateway();
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
index 18ee0262..57e009dc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
@@ -380,7 +380,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
case Activity.RESULT_CANCELED:
Dashboard dashboard = (Dashboard) getActivity();
- dashboard.setProgressBarVisibility(ProgressBar.VISIBLE);
+ dashboard.showProgressBar();
String status = getResources().getString(R.string.updating_certificate_message);
setEipStatus(status);
diff --git a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java b/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java
index 45d3a373..5a0c9a6d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java
@@ -42,15 +42,10 @@ import android.widget.TextView;
* @author parmegv
*
*/
-public class LogInDialog extends DialogFragment {
+public class LogInDialog extends SessionDialogInterface {
- final public static String TAG = "logInDialog";
- final public static String VERB = "log in";
- final public static String USERNAME = "username";
- final public static String PASSWORD = "password";
- final public static String USERNAME_MISSING = "username missing";
- final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length";
+ final public static String TAG = LogInDialog.class.getSimpleName();
private static boolean is_eip_pending = false;
@@ -93,7 +88,7 @@ public class LogInDialog extends DialogFragment {
String username = username_field.getText().toString();
String password = password_field.getText().toString();
dialog.dismiss();
- interface_with_Dashboard.authenticate(username, password);
+ interface_with_Dashboard.logIn(username, password);
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@@ -120,7 +115,7 @@ public class LogInDialog extends DialogFragment {
*
*/
public interface LogInDialogInterface {
- public void authenticate(String username, String password);
+ public void logIn(String username, String password);
public void cancelAuthedEipOn();
public void signUp(String username, String password);
public void cancelLoginOrSignup();
@@ -149,8 +144,8 @@ public class LogInDialog extends DialogFragment {
@Override
public void onCancel(DialogInterface dialog) {
+ super.onCancel(dialog);
if(is_eip_pending)
interface_with_Dashboard.cancelAuthedEipOn();
- super.onCancel(dialog);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java b/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java
index 7b256124..7e4e95d3 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
- package se.leap.bitmaskclient;
+package se.leap.bitmaskclient;
import android.os.Bundle;
import android.os.Handler;
diff --git a/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java
new file mode 100644
index 00000000..7b08a4d1
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2013 LEAP Encryption Access Project and contributers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package se.leap.bitmaskclient;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.os.Bundle;
+
+/**
+ * @author parmegv
+ */
+public abstract class SessionDialogInterface extends DialogFragment {
+ final public static String USERNAME = "username";
+ final public static String PASSWORD = "password";
+ final public static String USERNAME_MISSING = "username missing";
+ final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length";
+
+ @Override
+ public void onAttach(Activity activity) { super.onAttach(activity); }
+
+ @Override
+ public void onCancel(DialogInterface dialog) { super.onCancel(dialog); }
+}
diff --git a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java
index 120d4eec..3cb41f4f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java
@@ -42,14 +42,9 @@ import android.widget.TextView;
* @author parmegv
*
*/
-public class SignUpDialog extends DialogFragment {
-
- final public static String TAG = "signUpDialog";
- final public static String VERB = "log in";
- final public static String USERNAME = "username";
- final public static String PASSWORD = "password";
- final public static String USERNAME_MISSING = "username missing";
- final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length";
+public class SignUpDialog extends SessionDialogInterface {
+
+ final public static String TAG = SignUpDialog.class.getSimpleName();
private static boolean is_eip_pending = false;