Commit 6cc4cc51 authored by Grigory Fedorov's avatar Grigory Fedorov

ContactEditor: name editing removed.

parent 33074dd2
......@@ -326,30 +326,20 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
ConnectionManager.getInstance().sendPacket(account, packet);
}
/**
* Requests to change contact's name and groups.
*
* @param account
* @param bareAddress
* @param name
* @param groups
* @throws NetworkException
*/
public void setNameAndGroup(String account, String bareAddress,
String name, Collection<String> groups) throws NetworkException {
public void setGroups(String account, String bareAddress, Collection<String> groups) throws NetworkException {
RosterContact contact = getRosterContact(account, bareAddress);
if (contact == null)
if (contact == null) {
throw new NetworkException(R.string.ENTRY_IS_NOT_FOUND);
if (contact.getRealName().equals(name)) {
HashSet<String> check = new HashSet<String>(contact.getGroupNames());
if (check.size() == groups.size()) {
check.removeAll(groups);
if (check.isEmpty())
return;
}
}
updateRosterContact(account, bareAddress, name, groups);
HashSet<String> check = new HashSet<>(contact.getGroupNames());
if (check.size() == groups.size()) {
check.removeAll(groups);
if (check.isEmpty())
return;
}
updateRosterContact(account, bareAddress, contact.getRealName(), groups);
}
public void setName(String account, String bareAddress, String name) throws NetworkException {
......
......@@ -76,7 +76,6 @@ public class ContactEditor extends GroupListActivity implements
@Override
protected void onResume() {
super.onResume();
((EditText) findViewById(R.id.contact_name)).setText(RosterManager.getInstance().getName(account, user));
Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
Application.getInstance().addUIListener(OnContactChangedListener.class, this);
update();
......@@ -88,8 +87,7 @@ public class ContactEditor extends GroupListActivity implements
Application.getInstance().removeUIListener(OnAccountChangedListener.class, this);
Application.getInstance().removeUIListener(OnContactChangedListener.class, this);
try {
String name = ((EditText) findViewById(R.id.contact_name)).getText().toString();
RosterManager.getInstance().setNameAndGroup(account, user, name, getSelected());
RosterManager.getInstance().setGroups(account, user, getSelected());
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
......
......@@ -21,22 +21,6 @@
<include layout="@layout/toolbar_default"/>
<TextView
android:text="@string/contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="8dip"
android:paddingBottom="4dip"
android:paddingLeft="2dip"
android:paddingRight="2dip"
/>
<EditText
android:id="@+id/contact_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:text="@string/contact_group"
android:layout_width="wrap_content"
......
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