OC-3212: Show appropiate error messages for SslError in SSL error dialog shown by...
authormasensio <masensio@solidgear.es>
Mon, 10 Mar 2014 09:53:11 +0000 (10:53 +0100)
committermasensio <masensio@solidgear.es>
Mon, 10 Mar 2014 09:53:11 +0000 (10:53 +0100)
res/layout/ssl_untrusted_cert_layout.xml
res/values/strings.xml
src/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java
src/com/owncloud/android/ui/dialog/SslUntrustedCertDialogForEmptySslError.java

index ef57de6..6a30c2e 100644 (file)
                android:textAppearance="?android:attr/textAppearanceSmall"
                 />
        
+       <TextView
+               android:id="@+id/reason_no_info_about_error"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"
+               android:layout_gravity="left"
+               android:paddingLeft="20dp"
+               android:text="@string/ssl_validator_no_info_about_error"
+               android:textAppearance="?android:attr/textAppearanceSmall"
+                />
+       
     <ScrollView 
         android:id="@+id/details_scroll"
         android:visibility="gone" 
index 3fe79de..37a97fe 100644 (file)
        <string name="ssl_validator_label_signature">Signature:</string>
        <string name="ssl_validator_label_signature_algorithm">Algorithm:</string>
        <string name="ssl_validator_null_cert">The certificate could not be shown.</string>
+       <string name="ssl_validator_no_info_about_error">- No information about the error</string>
                        
     <string name="placeholder_sentence">This is a placeholder</string>
     <string name="placeholder_filename">placeholder.txt</string>
index ec33ddf..5a67e97 100644 (file)
@@ -141,7 +141,7 @@ public class SslUntrustedCertDialog extends SslUntrustedCertDialogABSTRACT {
         // Create a view by inflating desired layout
         mView = inflater.inflate(R.layout.ssl_untrusted_cert_layout, container,  false);
         
-        updateException(mException);
+        updateMessageException(mException, mError);
         
         Button ok = (Button) mView.findViewById(R.id.ok);
         ok.setOnClickListener(new OnClickListener() {
@@ -224,35 +224,50 @@ public class SslUntrustedCertDialog extends SslUntrustedCertDialogABSTRACT {
     }
     
     
-    private void updateException(CertificateCombinedException exception) {
+    private void updateMessageException(CertificateCombinedException exception, SslError error) {
         
         /// clean
         mView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.GONE);
         mView.findViewById(R.id.reason_cert_expired).setVisibility(View.GONE);
         mView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.GONE);
         mView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.GONE);
+        mView.findViewById(R.id.reason_no_info_about_error).setVisibility(View.GONE);
         mView.findViewById(R.id.details_scroll).setVisibility(View.GONE);
         
-        
-        if (mException != null) {
+       
+        if (exception != null) {
             
             /// refresh
-            if (mException.getCertPathValidatorException() != null) {
+            if (exception.getCertPathValidatorException() != null) {
                 ((TextView)mView.findViewById(R.id.reason_cert_not_trusted)).setVisibility(View.VISIBLE);
             }
             
-            if (mException.getCertificateExpiredException() != null) {
+            if (exception.getCertificateExpiredException() != null) {
                 ((TextView)mView.findViewById(R.id.reason_cert_expired)).setVisibility(View.VISIBLE);
             }
             
-            if (mException.getCertificateNotYetValidException() != null) {
+            if (exception.getCertificateNotYetValidException() != null) {
                 ((TextView)mView.findViewById(R.id.reason_cert_not_yet_valid)).setVisibility(View.VISIBLE);
             } 
 
-            if (mException.getSslPeerUnverifiedException() != null ) {
+            if (exception.getSslPeerUnverifiedException() != null) {
                 ((TextView)mView.findViewById(R.id.reason_hostname_not_verified)).setVisibility(View.VISIBLE);
             }
             
+        } else if ( error != null) {
+            /// refresh
+            if (error.getPrimaryError() == SslError.SSL_UNTRUSTED) {
+                ((TextView)mView.findViewById(R.id.reason_cert_not_trusted)).setVisibility(View.VISIBLE);
+                
+            } else if (error.getPrimaryError() == SslError.SSL_EXPIRED) {
+                ((TextView)mView.findViewById(R.id.reason_cert_expired)).setVisibility(View.VISIBLE);
+                
+            } else if (error.getPrimaryError() == SslError.SSL_NOTYETVALID) {
+                ((TextView)mView.findViewById(R.id.reason_cert_not_yet_valid)).setVisibility(View.VISIBLE);
+                
+            } else if (error.getPrimaryError() == SslError.SSL_IDMISMATCH) {
+                ((TextView)mView.findViewById(R.id.reason_hostname_not_verified)).setVisibility(View.VISIBLE);
+            }
         }
         
     }
index 7495ba5..d9173bb 100644 (file)
@@ -114,6 +114,8 @@ public class SslUntrustedCertDialogForEmptySslError extends SslUntrustedCertDial
             ((ViewGroup)mView.getParent()).removeView(mView);
         }
         
+        showNoMessageError();
+        
         Button ok = (Button) mView.findViewById(R.id.ok);
         ok.setOnClickListener(new OnClickListener() {
             
@@ -247,4 +249,15 @@ public class SslUntrustedCertDialogForEmptySslError extends SslUntrustedCertDial
         ((TextView)mView.findViewById(R.id.value_signature)).setVisibility(View.GONE);
     }
 
+    private void showNoMessageError() {
+        /// clean
+        mView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.GONE);
+        mView.findViewById(R.id.reason_cert_expired).setVisibility(View.GONE);
+        mView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.GONE);
+        mView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.GONE);
+        mView.findViewById(R.id.details_scroll).setVisibility(View.GONE);
+        
+        mView.findViewById(R.id.reason_no_info_about_error).setVisibility(View.VISIBLE);
+        
+    }
 }