android: Show remediation instructions instead of log on failure
authorTobias Brunner <tobias@strongswan.org>
Thu, 30 May 2013 10:04:59 +0000 (12:04 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 8 Jul 2013 16:49:29 +0000 (18:49 +0200)
src/frontends/android/res/values-de/strings.xml
src/frontends/android/res/values-pl/strings.xml
src/frontends/android/res/values-ru/strings.xml
src/frontends/android/res/values-ua/strings.xml
src/frontends/android/res/values/strings.xml
src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java

index 6414f11..7682b3b 100644 (file)
@@ -90,6 +90,7 @@
     <string name="imc_state_label">Assessment:</string>
     <string name="imc_state_isolate">Eingeschr√§nkt</string>
     <string name="imc_state_block">Fehlgeschlagen</string>
+    <string name="show_remediation_instructions">Korrekturanweisungen anzeigen</string>
 
     <!-- Remediation instructions -->
     <string name="remediation_instructions_title">Korrekturanweisungen</string>
index 722bc10..18f886f 100644 (file)
@@ -90,6 +90,7 @@
     <string name="imc_state_label">Assessment:</string>
     <string name="imc_state_isolate">Restricted</string>
     <string name="imc_state_block">Failed</string>
+    <string name="show_remediation_instructions">View remediation instructions</string>
 
     <!-- Remediation instructions -->
     <string name="remediation_instructions_title">Remediation instructions</string>
index c82350b..fdb72b5 100644 (file)
@@ -87,6 +87,7 @@
     <string name="imc_state_label">Assessment:</string>
     <string name="imc_state_isolate">Restricted</string>
     <string name="imc_state_block">Failed</string>
+    <string name="show_remediation_instructions">View remediation instructions</string>
 
     <!-- Remediation instructions -->
     <string name="remediation_instructions_title">Remediation instructions</string>
index 3d82008..7c9e124 100644 (file)
@@ -88,6 +88,7 @@
     <string name="imc_state_label">Assessment:</string>
     <string name="imc_state_isolate">Restricted</string>
     <string name="imc_state_block">Failed</string>
+    <string name="show_remediation_instructions">View remediation instructions</string>
 
     <!-- Remediation instructions -->
     <string name="remediation_instructions_title">Remediation instructions</string>
index b275cd5..94d2464 100644 (file)
@@ -90,6 +90,7 @@
     <string name="imc_state_label">Assessment:</string>
     <string name="imc_state_isolate">Restricted</string>
     <string name="imc_state_block">Failed</string>
+    <string name="show_remediation_instructions">View remediation instructions</string>
 
     <!-- Remediation instructions -->
     <string name="remediation_instructions_title">Remediation instructions</string>
index d745d83..3219bba 100644 (file)
@@ -17,6 +17,9 @@
 
 package org.strongswan.android.ui;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.strongswan.android.R;
 import org.strongswan.android.data.VpnProfile;
 import org.strongswan.android.logic.VpnStateService;
@@ -24,6 +27,7 @@ import org.strongswan.android.logic.VpnStateService.ErrorState;
 import org.strongswan.android.logic.VpnStateService.State;
 import org.strongswan.android.logic.VpnStateService.VpnStateListener;
 import org.strongswan.android.logic.imc.ImcState;
+import org.strongswan.android.logic.imc.RemediationInstruction;
 
 import android.app.AlertDialog;
 import android.app.Fragment;
@@ -362,17 +366,31 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
 
        private void showErrorDialog(int textid)
        {
+               final List<RemediationInstruction> instructions = mService.getRemediationInstructions();
+               final boolean show_instructions = mImcState == ImcState.BLOCK && !instructions.isEmpty();
+               int text = show_instructions ? R.string.show_remediation_instructions : R.string.show_log;
+
                mErrorDialog = new AlertDialog.Builder(getActivity())
                        .setMessage(getString(R.string.error_introduction) + " " + getString(textid))
                        .setCancelable(false)
-                       .setNeutralButton(R.string.show_log, new DialogInterface.OnClickListener() {
+                       .setNeutralButton(text, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which)
                                {
                                        clearError();
                                        dialog.dismiss();
-                                       Intent logIntent = new Intent(getActivity(), LogActivity.class);
-                                       startActivity(logIntent);
+                                       Intent intent;
+                                       if (show_instructions)
+                                       {
+                                               intent = new Intent(getActivity(), RemediationInstructionsActivity.class);
+                                               intent.putParcelableArrayListExtra(RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS,
+                                                                                                                  new ArrayList<RemediationInstruction>(instructions));
+                                       }
+                                       else
+                                       {
+                                               intent = new Intent(getActivity(), LogActivity.class);
+                                       }
+                                       startActivity(intent);
                                }
                        })
                        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {