Commit 3b9a219f authored by Alexander Ivanov's avatar Alexander Ivanov

Separate conference delete dialog.

parent 5d3e3182
...@@ -87,6 +87,7 @@ import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment; ...@@ -87,6 +87,7 @@ import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment;
import com.xabber.android.ui.dialog.DialogBuilder; import com.xabber.android.ui.dialog.DialogBuilder;
import com.xabber.android.ui.dialog.GroupDeleteDialogFragment; import com.xabber.android.ui.dialog.GroupDeleteDialogFragment;
import com.xabber.android.ui.dialog.GroupRenameDialogFragment; import com.xabber.android.ui.dialog.GroupRenameDialogFragment;
import com.xabber.android.ui.dialog.MUCDeleteDialogFragment;
import com.xabber.android.ui.dialog.StartAtBootDialogFragment; import com.xabber.android.ui.dialog.StartAtBootDialogFragment;
import com.xabber.android.ui.helper.ManagedListActivity; import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
...@@ -485,11 +486,9 @@ public class ContactList extends ManagedListActivity implements ...@@ -485,11 +486,9 @@ public class ContactList extends ManagedListActivity implements
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
ContactDeleteDialogFragment.newInstance( MUCDeleteDialogFragment.newInstance(account, user)
account == GroupManager.NO_ACCOUNT ? null .show(getSupportFragmentManager(),
: account, user).show( "MUC_DELETE");
getSupportFragmentManager(),
"CONTACT_DELETE");
return true; return true;
} }
...@@ -534,10 +533,8 @@ public class ContactList extends ManagedListActivity implements ...@@ -534,10 +533,8 @@ public class ContactList extends ManagedListActivity implements
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
ContactDeleteDialogFragment.newInstance( ContactDeleteDialogFragment.newInstance(account,
account == GroupManager.NO_ACCOUNT ? null user).show(getSupportFragmentManager(),
: account, user).show(
getSupportFragmentManager(),
"CONTACT_DELETE"); "CONTACT_DELETE");
return true; return true;
} }
......
...@@ -6,9 +6,6 @@ import android.support.v4.app.DialogFragment; ...@@ -6,9 +6,6 @@ import android.support.v4.app.DialogFragment;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
...@@ -19,7 +16,6 @@ public class ContactDeleteDialogFragment extends ConfirmDialogFragment { ...@@ -19,7 +16,6 @@ public class ContactDeleteDialogFragment extends ConfirmDialogFragment {
/** /**
* @param account * @param account
* can be <code>null</code> to be used for all accounts.
* @param user * @param user
* @return * @return
*/ */
...@@ -30,33 +26,23 @@ public class ContactDeleteDialogFragment extends ConfirmDialogFragment { ...@@ -30,33 +26,23 @@ public class ContactDeleteDialogFragment extends ConfirmDialogFragment {
private String user; private String user;
private String account; private String account;
private boolean isRoom;
@Override @Override
protected Builder getBuilder() { protected Builder getBuilder() {
user = getArguments().getString(USER); user = getArguments().getString(USER);
account = getArguments().getString(ACCOUNT); account = getArguments().getString(ACCOUNT);
isRoom = MUCManager.getInstance().hasRoom(account, user);
return new Builder(getActivity()).setMessage(getString( return new Builder(getActivity()).setMessage(getString(
isRoom ? R.string.muc_delete_confirm R.string.contact_delete_confirm, RosterManager.getInstance()
: R.string.contact_delete_confirm, RosterManager .getName(account, user), AccountManager.getInstance()
.getInstance().getName(account, user), AccountManager .getVerboseName(account)));
.getInstance().getVerboseName(account)));
} }
@Override @Override
protected boolean onPositiveClick() { protected boolean onPositiveClick() {
if (isRoom) { try {
MUCManager.getInstance().removeRoom(account, user); RosterManager.getInstance().removeContact(account, user);
MessageManager.getInstance().closeChat(account, user); } catch (NetworkException e) {
NotificationManager.getInstance().removeMessageNotification( Application.getInstance().onError(e);
account, user);
} else {
try {
RosterManager.getInstance().removeContact(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
} }
return true; return true;
} }
......
package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder;
import android.support.v4.app.DialogFragment;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
public class MUCDeleteDialogFragment extends ConfirmDialogFragment {
private static final String ACCOUNT = "ACCOUNT";
private static final String USER = "USER";
/**
* @param account
* @param user
* @return
*/
public static DialogFragment newInstance(String account, String user) {
return new MUCDeleteDialogFragment().putAgrument(ACCOUNT, account)
.putAgrument(USER, user);
}
private String user;
private String account;
@Override
protected Builder getBuilder() {
user = getArguments().getString(USER);
account = getArguments().getString(ACCOUNT);
return new Builder(getActivity()).setMessage(getString(
R.string.muc_delete_confirm, RosterManager.getInstance()
.getName(account, user), AccountManager.getInstance()
.getVerboseName(account)));
}
@Override
protected boolean onPositiveClick() {
MUCManager.getInstance().removeRoom(account, user);
MessageManager.getInstance().closeChat(account, user);
NotificationManager.getInstance().removeMessageNotification(account,
user);
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment