diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
index 7cb243db69780d9d17f1803fefd11f00e8d99b9d..b63412752f1244ed82f9cb79ade9fc68362d4975 100644
--- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -892,65 +892,55 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
}
@Override
- public void onCaptchaRequested(final Account account, final String id, final Data data,
- final Bitmap captcha) {
- final AlertDialog.Builder builder = new AlertDialog.Builder(this);
- final ImageView view = new ImageView(this);
- final LinearLayout layout = new LinearLayout(this);
- final EditText input = new EditText(this);
-
- view.setImageBitmap(captcha);
- view.setScaleType(ImageView.ScaleType.FIT_CENTER);
-
- input.setHint(getString(R.string.captcha_hint));
-
- layout.setOrientation(LinearLayout.VERTICAL);
- layout.addView(view);
- layout.addView(input);
+ public void onCaptchaRequested(final Account account, final String id, final Data data, final Bitmap captcha) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if ((mCaptchaDialog != null) && mCaptchaDialog.isShowing()) {
+ mCaptchaDialog.dismiss();
+ }
+ final AlertDialog.Builder builder = new AlertDialog.Builder(EditAccountActivity.this);
+ final View view = getLayoutInflater().inflate(R.layout.captcha, null);
+ final ImageView imageView = (ImageView) view.findViewById(R.id.captcha);
+ final EditText input = (EditText) view.findViewById(R.id.input);
+ imageView.setImageBitmap(captcha);
- builder.setTitle(getString(R.string.captcha_required));
- builder.setView(layout);
+ builder.setTitle(getString(R.string.captcha_required));
+ builder.setView(view);
- builder.setPositiveButton(getString(R.string.ok),
- new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(getString(R.string.ok),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String rc = input.getText().toString();
+ data.put("username", account.getUsername());
+ data.put("password", account.getPassword());
+ data.put("ocr", rc);
+ data.submit();
+
+ if (xmppConnectionServiceBound) {
+ xmppConnectionService.sendCreateAccountWithCaptchaPacket(
+ account, id, data);
+ }
+ }
+ });
+ builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- String rc = input.getText().toString();
- data.put("username", account.getUsername());
- data.put("password", account.getPassword());
- data.put("ocr", rc);
- data.submit();
-
- if (xmppConnectionServiceBound) {
- xmppConnectionService.sendCreateAccountWithCaptchaPacket(
- account, id, data);
+ if (xmppConnectionService != null) {
+ xmppConnectionService.sendCreateAccountWithCaptchaPacket(account, null, null);
}
}
});
- builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (xmppConnectionService != null) {
- xmppConnectionService.sendCreateAccountWithCaptchaPacket(account, null, null);
- }
- }
- });
-
- builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- if (xmppConnectionService != null) {
- xmppConnectionService.sendCreateAccountWithCaptchaPacket(account, null, null);
- }
- }
- });
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if ((mCaptchaDialog != null) && mCaptchaDialog.isShowing()) {
- mCaptchaDialog.dismiss();
- }
+ builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ if (xmppConnectionService != null) {
+ xmppConnectionService.sendCreateAccountWithCaptchaPacket(account, null, null);
+ }
+ }
+ });
mCaptchaDialog = builder.create();
mCaptchaDialog.show();
}
diff --git a/src/main/res/layout/captcha.xml b/src/main/res/layout/captcha.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ea77b83545b3735fe38f2c3d2058df8659abb273
--- /dev/null
+++ b/src/main/res/layout/captcha.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 234c732c4ae56478fe5c09d30e73f574b28e11a3..7c027b509de9f9b0fa1df006002db1c6d4ec4034 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -557,9 +557,8 @@
Server-side archiving preferences
Fetching archiving preferences. Please wait…
Unable to fetch archiving preferences
- Captcha text
Captcha required
- enter the text from the image
+ Enter the text from the image above
Certificate chain is not trusted
Jabber ID does not match certificate
Renew certificate