diff options
Diffstat (limited to 'src')
4 files changed, 41 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index caea57fc8..90b2784a5 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -2354,6 +2354,11 @@ public class XmppConnectionService extends Service { }); } + public void deleteAccountFromServer(final Account account) { + account.getXmppConnection().sendDeleteRequest(); + deleteAccount(account); + } + public void deleteAccount(final Account account) { synchronized (this.conversations) { for (final Conversation conversation : conversations) { diff --git a/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java b/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java index fc5563df0..449e3871b 100644 --- a/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java @@ -355,7 +355,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.mgmt_account_are_you_sure)); builder.setIconAttribute(android.R.attr.alertDialogIcon); - builder.setMessage(getString(R.string.mgmt_account_delete_confirm_text)); + builder.setMessage(getString(R.string.mgmt_account_delete_confirm_message)); builder.setPositiveButton(getString(R.string.delete), (dialog, which) -> { xmppConnectionService.deleteAccount(account); @@ -364,7 +364,21 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda WelcomeActivity.launch(this); } }); - builder.setNegativeButton(getString(R.string.cancel), null); + + builder.setNegativeButton(getString(R.string.delete_from_server), + (dialog, which) -> { + if (account.isOnlineAndConnected()) { + xmppConnectionService.deleteAccountFromServer(account); + selectedAccount = null; + if (xmppConnectionService.getAccounts().size() == 0 && Config.MAGIC_CREATE_DOMAIN != null) { + WelcomeActivity.launch(this); + } + } else { + informUser(R.string.go_online_to_delete); + } + }); + + builder.setNeutralButton(getString(R.string.cancel), null); builder.create().show(); } diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index dd82ab7bb..8910ee418 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -1017,6 +1017,22 @@ public class XmppConnection implements Runnable { }, true); } + public void sendDeleteRequest() { + final IqPacket delete = new IqPacket(IqPacket.TYPE.SET); + delete.query("jabber:iq:register").addChild("remove"); + delete.setTo(Jid.of(account.getServer())); + delete.setFrom(account.getJid().asBareJid()); + Log.d(Config.LOGTAG, "Delete " + delete); + sendUnmodifiedIqPacket(delete, (account, packet) -> { + if (packet.getType() == IqPacket.TYPE.TIMEOUT) { + return; + } + if (packet.getType() == IqPacket.TYPE.ERROR) { + throw new StateChangingError(Account.State.DISABLED); + } + }, true); + } + private void setAccountCreationFailed(String url) { if (url != null) { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 8228c7c1b..1f463846e 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -156,7 +156,7 @@ <string name="unpublish_pgp_message">Are you sure you want to remove your OpenPGP public key from your presence announcement?\nYour contacts will no longer be able to send you OpenPGP encrypted messages.</string> <string name="openpgp_has_been_published">OpenPGP public key has been published.</string> <string name="mgmt_account_are_you_sure">Are you sure?</string> - <string name="mgmt_account_delete_confirm_text">If you delete your account, your entire conversation history will be lost</string> + <string name="mgmt_account_delete_confirm_message">If you delete your account, your entire local conversation history will be lost.\n\nIf you delete your account from server, your entire account will be deleted from server too, you will not be able to login anymore until you register a new account.</string> <string name="attach_record_voice">Record voice</string> <string name="account_settings_jabber_id">Jabber-ID</string> <string name="account_settings_example_jabber_id">username@pix-art.de</string> @@ -896,4 +896,7 @@ <string name="pref_use_internal_updater_summary">Let the messenger look for new app updates once a day</string> <string name="pref_use_internal_updater">look for updates</string> <string name="attach">Attach</string> + <string name="delete_locally">Delete locally</string> + <string name="delete_from_server">Delete from server</string> + <string name="go_online_to_delete">You have to activate and/or go online with the account you want to delete from server.</string> </resources> |