+ /**
+ * Create dialog for request authentication to the user
+ * @param webView
+ * @param handler
+ */
+ private void createAuthenticationDialog(WebView webView, HttpAuthHandler handler) {
+ final WebView mWebView = webView;
+ final HttpAuthHandler mHandler = handler;
+
+ // Create field for username
+ final EditText usernameET = new EditText(mContext);
+ usernameET.setHint(mContext.getText(R.string.auth_username));
+
+ // Create field for password
+ final EditText passwordET = new EditText(mContext);
+ passwordET.setHint(mContext.getText(R.string.auth_password));
+ passwordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
+
+ // Prepare LinearLayout for dialog
+ LinearLayout ll = new LinearLayout(mContext);
+ ll.setOrientation(LinearLayout.VERTICAL);
+ ll.addView(usernameET);
+ ll.addView(passwordET);
+
+ Builder authDialog = new AlertDialog
+ .Builder(mContext)
+ .setTitle(mContext.getText(R.string.saml_authentication_required_text))
+ .setView(ll)
+ .setCancelable(false)
+ .setPositiveButton(mContext.getText(R.string.common_ok),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+
+ String username = usernameET.getText().toString().trim();
+ String password = passwordET.getText().toString().trim();
+
+ // Proceed with the authentication
+ mHandler.proceed(username, password);
+ dialog.dismiss();
+ }
+ })
+ .setNegativeButton(mContext.getText(R.string.common_cancel),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ dialog.dismiss();
+ mWebView.stopLoading();
+ }
+ });
+
+ if (mWebView!=null) {
+ authDialog.show();
+ }
+
+ }