summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Leonard <meanderingcode@aetherislands.net>2013-06-08 22:27:25 -0600
committerSean Leonard <meanderingcode@aetherislands.net>2013-06-08 22:27:25 -0600
commit769344327d5cb16adbdc04db224ff6902b4a4771 (patch)
treedf878d7b93ee8c6ef2ad6b62990e375293c46a33
parent626b32fba7b6b45bead3b79fb7e7aa6cddc5c535 (diff)
Better config/partial config handling in Dashboard
-rwxr-xr-xres/values/strings.xml4
-rw-r--r--src/se/leap/leapclient/Dashboard.java30
2 files changed, 29 insertions, 5 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0efa9414..4501ac1d 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -271,6 +271,10 @@
<string name="login_button">Log In</string>
<string name="logout_button">Log Out</string>
<string name="danger_checkbox">Trust completely</string>
+ <string name="setup_error_title">Configuration Error</string>
+ <string name="setup_error_configure_button">Configure</string>
+ <string name="setup_error_close_button">Exit</string>
+ <string name="setup_error_text">There was an error configuring LEAP with your chosen provider.\n\nYou may choose to reconfigure, or exit and configure a provider upon next launch.</string>
<string name="config_wait_title">Configuring LEAP provider</string>
<string name="config_connecting_provider">Downloading provider configuration</string>
<string name="config_downloading_services">Downloading service definitions</string>
diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java
index de7946e9..6bdd74d2 100644
--- a/src/se/leap/leapclient/Dashboard.java
+++ b/src/se/leap/leapclient/Dashboard.java
@@ -13,10 +13,12 @@ import se.leap.leapclient.R.menu;
import se.leap.openvpn.AboutFragment;
import se.leap.openvpn.MainActivity;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -58,10 +60,10 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
// Check if we have preferences, run configuration wizard if not
// TODO We should do a better check for config that this!
- if (!preferences.contains("provider") )
- startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
- else
+ if (preferences.contains("provider") && preferences.getString(ConfigHelper.PROVIDER_KEY, null) != null)
buildDashboard();
+ else
+ startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
}
@Override
@@ -73,8 +75,26 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
buildDashboard();
} else {
- // Something went wrong... TODO figure out what
- // TODO Error dialog
+ // Something went wrong in configuration
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getAppContext());
+ alertBuilder.setTitle(getResources().getString(R.string.setup_error_title));
+ alertBuilder
+ .setMessage(getResources().getString(R.string.setup_error_text))
+ .setCancelable(false)
+ .setPositiveButton(getResources().getString(R.string.setup_error_configure_button), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ startActivityForResult(new Intent(getAppContext(),ConfigurationWizard.class),CONFIGURE_LEAP);
+ }
+ })
+ .setNegativeButton(getResources().getString(R.string.setup_error_close_button), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences.Editor prefsEdit = getSharedPreferences(ConfigHelper.PREFERENCES_KEY, MODE_PRIVATE).edit();
+ prefsEdit.remove(ConfigHelper.PROVIDER_KEY).commit();
+ finish();
+ }
+ });
}
}
}