Show name+addr when asking to start a new chat.

This commit is contained in:
B. Petersen
2016-11-12 14:05:09 +01:00
parent 6f1d364d1d
commit d1d38b64e2
3 changed files with 20 additions and 9 deletions
+9 -7
View File
@@ -580,15 +580,17 @@ JNIEXPORT void Java_org_telegram_messenger_MrMailbox_MrContactUnref(JNIEnv *env,
}
JNIEXPORT jstring Java_org_telegram_messenger_MrMailbox_MrContactGetDisplayName(JNIEnv *env, jclass c, jlong hContact)
JNIEXPORT jstring Java_org_telegram_messenger_MrMailbox_MrContactGetName(JNIEnv *env, jclass c, jlong hContact)
{
mrcontact_t* ths = (mrcontact_t*)hContact; if( ths == NULL ) { return JSTRING_NEW(NULL); }
if( ths->m_name && ths->m_name[0] ) {
return JSTRING_NEW(ths->m_name);
}
else {
return JSTRING_NEW(ths->m_addr);
}
return JSTRING_NEW(ths->m_name);
}
JNIEXPORT jstring Java_org_telegram_messenger_MrMailbox_MrContactGetAddr(JNIEnv *env, jclass c, jlong hContact)
{
mrcontact_t* ths = (mrcontact_t*)hContact; if( ths == NULL ) { return JSTRING_NEW(NULL); }
return JSTRING_NEW(ths->m_addr);
}
@@ -273,7 +273,9 @@ public class MrMailbox {
// MrContact objects
public native static void MrContactUnref (long hContact);
public native static String MrContactGetDisplayName (long hContact);
public native static String MrContactGetName (long hContact);
public native static String MrContactGetAddr (long hContact);
public static String MrContactGetDisplayName (long hContact) { String s=MrContactGetName(hContact); if(s.isEmpty()) {s=MrContactGetAddr(hContact);} return s; }
// MrPoortext objects
public native static void MrPoortextUnref (long hPoortext);
@@ -3765,7 +3765,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
long hContact = MrMailbox.MrMailboxGetContactById(MrMailbox.hMailbox, fromId);
if( hContact==0 ) { MrMailbox.MrMsgUnref(hMsg); return; }
String name = MrMailbox.MrContactGetDisplayName(hContact);
String name = MrMailbox.MrContactGetName(hContact);
if( name.isEmpty() ) {
name = MrMailbox.MrContactGetAddr(hContact);
}
else {
name += " (" + MrMailbox.MrContactGetAddr(hContact) + ")";
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {