mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
creating addresses from dc chat information, primitively.
This commit is contained in:
@@ -111,7 +111,7 @@ public class ApplicationDcContext extends DcContext {
|
||||
|
||||
RecipientProvider.RecipientDetails recipientDetails = new RecipientProvider.RecipientDetails(chat.getName(), null, false, null, null);
|
||||
|
||||
Recipient recipient = new Recipient(Address.UNKNOWN, recipientDetails);
|
||||
Recipient recipient = new Recipient(Address.fromChat(chat), recipientDetails);
|
||||
long date = summary.getTimestamp()*1000;
|
||||
long count = 1;
|
||||
int unreadCount = getFreshMsgCount(chatId);
|
||||
|
||||
@@ -11,6 +11,8 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.google.i18n.phonenumbers.NumberParseException;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
@@ -50,6 +52,10 @@ public class Address implements Parcelable, Comparable<Address> {
|
||||
|
||||
private final String address;
|
||||
|
||||
public static Address fromChat(DcChat chat) {
|
||||
return new Address("dc:" + chat.getId());
|
||||
}
|
||||
|
||||
private Address(@NonNull String address) {
|
||||
if (address == null) throw new AssertionError(address);
|
||||
this.address = address;
|
||||
@@ -123,6 +129,8 @@ public class Address implements Parcelable, Comparable<Address> {
|
||||
return !isGroup() && !isEmail();
|
||||
}
|
||||
|
||||
public boolean isDcChat() { return address.startsWith("dc:"); };
|
||||
|
||||
public @NonNull String toGroupString() {
|
||||
if (!isGroup()) throw new AssertionError("Not group: " + address);
|
||||
return address;
|
||||
@@ -138,6 +146,11 @@ public class Address implements Parcelable, Comparable<Address> {
|
||||
return address;
|
||||
}
|
||||
|
||||
public int getDcChatId() {
|
||||
if(!isDcChat()) throw new AssertionError("Not dc chat: " + address);
|
||||
return Integer.valueOf(address.substring("dc:".length()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return address;
|
||||
|
||||
Reference in New Issue
Block a user