]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Show a retry button in the error banner
authorTobias Brunner <tobias@strongswan.org>
Fri, 15 Jun 2018 09:00:08 +0000 (11:00 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:38 +0000 (11:31 +0200)
The button to view the log is now below the status info.  And since the
IMC results are just below that we don't need a special handling for
that anymore.

src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnStateFragment.java
src/frontends/android/app/src/main/res/layout/vpn_state_fragment.xml
src/frontends/android/app/src/main/res/values-de/strings.xml
src/frontends/android/app/src/main/res/values-pl/strings.xml
src/frontends/android/app/src/main/res/values-ru/strings.xml
src/frontends/android/app/src/main/res/values-ua/strings.xml
src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
src/frontends/android/app/src/main/res/values/strings.xml

index 0e4a583294d10f4eefdf0caa66f19ad854a85432..38549cb92cb61dd6418fe9257965a7afc8273f28 100644 (file)
@@ -61,7 +61,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
        private ProgressBar mProgress;
        private LinearLayout mErrorView;
        private TextView mErrorText;
-       private Button mErrorDetails;
+       private Button mErrorRetry;
        private Button mDismissError;
        private long mErrorConnectionID;
        private VpnStateService mService;
@@ -81,6 +81,17 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                        updateView();
                }
        };
+       private OnClickListener mDisconnectListener = new OnClickListener()
+       {
+               @Override
+               public void onClick(View v)
+               {
+                       if (mService != null)
+                       {
+                               mService.disconnect();
+                       }
+               }
+       };
 
        @Override
        public void onCreate(Bundle savedInstanceState)
@@ -117,22 +128,11 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                View view = inflater.inflate(R.layout.vpn_state_fragment, null);
 
                mActionButton = (Button)view.findViewById(R.id.action);
-               mActionButton.setOnClickListener(new OnClickListener()
-               {
-                       @Override
-                       public void onClick(View v)
-                       {
-                               if (mService != null)
-                               {
-                                       mService.disconnect();
-                               }
-                       }
-               });
                enableActionButton(null);
 
                mErrorView = view.findViewById(R.id.vpn_error);
                mErrorText = view.findViewById(R.id.vpn_error_text);
-               mErrorDetails = view.findViewById(R.id.error_details);
+               mErrorRetry = view.findViewById(R.id.retry);
                mDismissError = view.findViewById(R.id.dismiss_error);
                mProgress = (ProgressBar)view.findViewById(R.id.progress);
                mStateView = (TextView)view.findViewById(R.id.vpn_state);
@@ -140,14 +140,13 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                mProfileView = (TextView)view.findViewById(R.id.vpn_profile_label);
                mProfileNameView = (TextView)view.findViewById(R.id.vpn_profile_name);
 
-               mDismissError.setOnClickListener(new OnClickListener()
-               {
-                       @Override
-                       public void onClick(View v)
+               mErrorRetry.setOnClickListener(v -> {
+                       if (mService != null)
                        {
-                               clearError();
+                               mService.reconnect();
                        }
                });
+               mDismissError.setOnClickListener(v -> clearError());
 
                return view;
        }
@@ -255,15 +254,19 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                        mErrorView.setVisibility(View.GONE);
                        return false;
                }
-
                mErrorConnectionID = connectionID;
                mProfileNameView.setText(name);
                showProfile(true);
                mProgress.setVisibility(View.GONE);
-               enableActionButton(null);
                mStateView.setText(R.string.state_error);
                mStateView.setTextColor(mColorStateError);
-               showError(mService.getErrorText());
+               enableActionButton(getString(R.string.show_log));
+               mActionButton.setOnClickListener(v -> {
+                       Intent intent = new Intent(getActivity(), LogActivity.class);
+                       startActivity(intent);
+               });
+               mErrorText.setText(getString(R.string.error_format, getString(mService.getErrorText())));
+               mErrorView.setVisibility(View.VISIBLE);
                return true;
        }
 
@@ -278,6 +281,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                mActionButton.setText(text);
                mActionButton.setEnabled(text != null);
                mActionButton.setVisibility(text != null ? View.VISIBLE : View.GONE);
+               mActionButton.setOnClickListener(mDisconnectListener);
        }
 
        private void clearError()
@@ -292,34 +296,4 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                }
                updateView();
        }
-
-       private void showError(int textid)
-       {
-               final List<RemediationInstruction> instructions = mService.getRemediationInstructions();
-               final boolean show_instructions = mService.getImcState() == ImcState.BLOCK && !instructions.isEmpty();
-               int text = show_instructions ? R.string.show_remediation_instructions : R.string.show_log;
-
-               mErrorText.setText(getString(R.string.error_format, getString(textid)));
-               mErrorDetails.setText(text);
-               mErrorDetails.setOnClickListener(new OnClickListener()
-               {
-                       @Override
-                       public void onClick(View v)
-                       {
-                               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);
-                       }
-               });
-               mErrorView.setVisibility(View.VISIBLE);
-       }
 }
index 6807ae39e1ba2c177e8b49f920cbe8564f120919..adc9c8665b09b6d8a578cca5eae444b23ff2cb43 100644 (file)
             </Button>
 
             <Button
-                android:id="@+id/error_details"
+                android:id="@+id/retry"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="@string/show_log"
+                android:text="@string/retry"
                 android:textColor="@color/primary"
                 android:textSize="14sp"
                 android:textStyle="bold"
index 3f9ff83f821c074883c798ca88d5881db9369c89..7bfaac5eb650d99303ff7f553ff985479784e487 100644 (file)
     <string name="disconnect_question">VPN Verbindung trennen?</string>
     <string name="disconnect_active_connection">Dies trennt die aktuelle VPN Verbindung!</string>
     <string name="connect">Verbinden</string>
+    <string name="retry">Wiederholen</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">VPN umschalten</string>
index fa34739c4a7ec91ae05617d7f1ee54f231c4d4d2..962fb6e7cf94769782e473da7a287e498883b2e1 100644 (file)
     <string name="disconnect_question">Disconnect VPN?</string>
     <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
     <string name="connect">Połącz</string>
+    <string name="retry">Retry</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index 9d3bb8eb2f3665ea9df16d06658e1b860cd0ef42..23f641634c15662c61023d04446553a7d4d2e0ed 100644 (file)
     <string name="disconnect_question">Disconnect VPN?</string>
     <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
     <string name="connect">Соединить</string>
+    <string name="retry">Retry</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index 7d87b4b94e3be613ae8c07267807ee08cb97d753..731ca46de303683f1d2ca319f2b70394d3ac2754 100644 (file)
     <string name="disconnect_question">Disconnect VPN?</string>
     <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
     <string name="connect">Підключити</string>
+    <string name="retry">Retry</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index 54487793e6ac49c35456a67b827644d7802840b3..65b12ad111b1797f93f44fad74f511b446daf09d 100644 (file)
     <string name="disconnect_question">Disconnect VPN?</string>
     <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
     <string name="connect">连接</string>
+    <string name="retry">Retry</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index d0e9065aa339264469f3471674109a8e807e6ec9..d142318aa7e8e25fc9e923ca130ee4a11085555a 100644 (file)
     <string name="disconnect_question">Disconnect VPN?</string>
     <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
     <string name="connect">連線</string>
+    <string name="retry">Retry</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index 475fcd91eaaf85dc2b6dbb46d9d652c0b4babf55..dd675c41883f8ce6e4210057e1da2fcf42bfecac 100644 (file)
     <string name="disconnect_question">Disconnect VPN?</string>
     <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
     <string name="connect">Connect</string>
+    <string name="retry">Retry</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>