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;
import com.xabber.android.ui.dialog.DialogBuilder;
import com.xabber.android.ui.dialog.GroupDeleteDialogFragment;
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.helper.ManagedListActivity;
import com.xabber.androiddev.R;
......@@ -485,11 +486,9 @@ public class ContactList extends ManagedListActivity implements
@Override
public boolean onMenuItemClick(MenuItem item) {
ContactDeleteDialogFragment.newInstance(
account == GroupManager.NO_ACCOUNT ? null
: account, user).show(
getSupportFragmentManager(),
"CONTACT_DELETE");
MUCDeleteDialogFragment.newInstance(account, user)
.show(getSupportFragmentManager(),
"MUC_DELETE");
return true;
}
......@@ -534,10 +533,8 @@ public class ContactList extends ManagedListActivity implements
@Override
public boolean onMenuItemClick(MenuItem item) {
ContactDeleteDialogFragment.newInstance(
account == GroupManager.NO_ACCOUNT ? null
: account, user).show(
getSupportFragmentManager(),
ContactDeleteDialogFragment.newInstance(account,
user).show(getSupportFragmentManager(),
"CONTACT_DELETE");
return true;
}
......
......@@ -6,9 +6,6 @@ import android.support.v4.app.DialogFragment;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
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;
......@@ -19,7 +16,6 @@ public class ContactDeleteDialogFragment extends ConfirmDialogFragment {
/**
* @param account
* can be <code>null</code> to be used for all accounts.
* @param user
* @return
*/
......@@ -30,33 +26,23 @@ public class ContactDeleteDialogFragment extends ConfirmDialogFragment {
private String user;
private String account;
private boolean isRoom;
@Override
protected Builder getBuilder() {
user = getArguments().getString(USER);
account = getArguments().getString(ACCOUNT);
isRoom = MUCManager.getInstance().hasRoom(account, user);
return new Builder(getActivity()).setMessage(getString(
isRoom ? R.string.muc_delete_confirm
: R.string.contact_delete_confirm, RosterManager
.getInstance().getName(account, user), AccountManager
.getInstance().getVerboseName(account)));
R.string.contact_delete_confirm, RosterManager.getInstance()
.getName(account, user), AccountManager.getInstance()
.getVerboseName(account)));
}
@Override
protected boolean onPositiveClick() {
if (isRoom) {
MUCManager.getInstance().removeRoom(account, user);
MessageManager.getInstance().closeChat(account, user);
NotificationManager.getInstance().removeMessageNotification(
account, user);
} else {
try {
RosterManager.getInstance().removeContact(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
try {
RosterManager.getInstance().removeContact(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
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