mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
use Rpc.createContact() to set contact's name
This commit is contained in:
parent
fbca401488
commit
c1eff8362f
2 changed files with 14 additions and 1 deletions
|
@ -129,6 +129,10 @@ public class Rpc {
|
|||
return getResult("get_account_file_size", accountId).getAsInt();
|
||||
}
|
||||
|
||||
public int createContact(int accountId, String email, String name) throws RpcException {
|
||||
return getResult("create_contact", accountId, email, name).getAsInt();
|
||||
}
|
||||
|
||||
public int addAccount() throws RpcException {
|
||||
return getResult("add_account").getAsInt();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import com.b44t.messenger.DcChat;
|
|||
import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.b44t.messenger.DcEvent;
|
||||
import com.b44t.messenger.rpc.Rpc;
|
||||
import com.b44t.messenger.rpc.RpcException;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.DcEventCenter;
|
||||
|
@ -63,6 +65,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
private static final int REQUEST_CODE_PICK_RINGTONE = 1;
|
||||
|
||||
private DcContext dcContext;
|
||||
private Rpc rpc;
|
||||
private int chatId;
|
||||
private boolean chatIsMultiUser;
|
||||
private boolean chatIsDeviceTalk;
|
||||
|
@ -82,6 +85,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
dynamicTheme = new DynamicNoActionBarTheme();
|
||||
super.onPreCreate();
|
||||
dcContext = DcHelper.getContext(this);
|
||||
rpc = DcHelper.getRpc(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -536,6 +540,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
}
|
||||
else {
|
||||
int accountId = dcContext.getAccountId();
|
||||
DcContact dcContact = dcContext.getContact(contactId);
|
||||
|
||||
String authName = dcContact.getAuthName();
|
||||
|
@ -555,7 +560,11 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
.setView(gl)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, whichButton) -> {
|
||||
String newName = inputField.getText().toString();
|
||||
dcContext.createContact(newName, dcContact.getAddr());
|
||||
try {
|
||||
rpc.createContact(accountId, dcContact.getAddr(), newName);
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setCancelable(false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue