mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-20 23:08:27 +00:00
Clean
This commit is contained in:
parent
373dfc264f
commit
06883cc3ef
@ -3209,6 +3209,5 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
FriendRequestProtocol.rejectFriendRequest(this, recipient);
|
FriendRequestProtocol.rejectFriendRequest(this, recipient);
|
||||||
updateInputPanel();
|
updateInputPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
||||||
|
@ -9,22 +9,15 @@ import android.support.annotation.WorkerThread;
|
|||||||
import org.signal.libsignal.metadata.SignalProtos;
|
import org.signal.libsignal.metadata.SignalProtos;
|
||||||
import org.signal.libsignal.metadata.certificate.CertificateValidator;
|
import org.signal.libsignal.metadata.certificate.CertificateValidator;
|
||||||
import org.signal.libsignal.metadata.certificate.InvalidCertificateException;
|
import org.signal.libsignal.metadata.certificate.InvalidCertificateException;
|
||||||
import network.loki.messenger.BuildConfig;
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.Base64;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.libsignal.InvalidKeyException;
|
|
||||||
import org.whispersystems.libsignal.ecc.Curve;
|
|
||||||
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
||||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
|
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class UnidentifiedAccessUtil {
|
public class UnidentifiedAccessUtil {
|
||||||
|
|
||||||
private static final String TAG = UnidentifiedAccessUtil.class.getSimpleName();
|
private static final String TAG = UnidentifiedAccessUtil.class.getSimpleName();
|
||||||
|
@ -293,8 +293,7 @@ public class GroupDatabase extends Database {
|
|||||||
contents.put(ADMINS, Address.toSerializedList(admins, ','));
|
contents.put(ADMINS, Address.toSerializedList(admins, ','));
|
||||||
contents.put(ACTIVE, 1);
|
contents.put(ACTIVE, 1);
|
||||||
|
|
||||||
databaseHelper.getWritableDatabase().update(TABLE_NAME, contents, GROUP_ID + " = ?",
|
databaseHelper.getWritableDatabase().update(TABLE_NAME, contents, GROUP_ID + " = ?", new String[] {groupId});
|
||||||
new String[] {groupId});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String groupId, Address source) {
|
public void remove(String groupId, Address source) {
|
||||||
|
@ -544,7 +544,7 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||||||
if (publicChat != null) {
|
if (publicChat != null) {
|
||||||
byte[] groupId = publicChat.getId().getBytes();
|
byte[] groupId = publicChat.getId().getBytes();
|
||||||
String oldId = GroupUtil.getEncodedId(groupId, false);
|
String oldId = GroupUtil.getEncodedId(groupId, false);
|
||||||
String newId = GroupUtil.getEncodedPublicChatId(groupId);
|
String newId = GroupUtil.getEncodedOpenGroupId(groupId);
|
||||||
ContentValues threadUpdate = new ContentValues();
|
ContentValues threadUpdate = new ContentValues();
|
||||||
threadUpdate.put("recipient_ids", newId);
|
threadUpdate.put("recipient_ids", newId);
|
||||||
db.update("thread", threadUpdate, "recipient_ids = ?", new String[]{ oldId });
|
db.update("thread", threadUpdate, "recipient_ids = ?", new String[]{ oldId });
|
||||||
|
@ -21,7 +21,6 @@ import android.content.Context;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
import org.thoughtcrime.securesms.database.MmsSmsColumns;
|
import org.thoughtcrime.securesms.database.MmsSmsColumns;
|
||||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||||
@ -30,6 +29,8 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message record model which represents standard SMS messages.
|
* The message record model which represents standard SMS messages.
|
||||||
*
|
*
|
||||||
|
@ -37,7 +37,7 @@ import java.util.Set;
|
|||||||
public class GroupManager {
|
public class GroupManager {
|
||||||
|
|
||||||
public static long getOpenGroupThreadID(String id, @NonNull Context context) {
|
public static long getOpenGroupThreadID(String id, @NonNull Context context) {
|
||||||
final String groupID = GroupUtil.getEncodedPublicChatId(id.getBytes());
|
final String groupID = GroupUtil.getEncodedOpenGroupId(id.getBytes());
|
||||||
return getThreadIDFromGroupID(groupID, context);
|
return getThreadIDFromGroupID(groupID, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,10 +78,10 @@ public class GroupManager {
|
|||||||
final Set<Address> memberAddresses = getMemberAddresses(members);
|
final Set<Address> memberAddresses = getMemberAddresses(members);
|
||||||
final Set<Address> adminAddresses = getMemberAddresses(admins);
|
final Set<Address> adminAddresses = getMemberAddresses(admins);
|
||||||
|
|
||||||
String masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
String masterPublicKeyOrNull = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||||
String publicKeyToUse = masterPublicKey != null ? masterPublicKey : TextSecurePreferences.getLocalNumber(context);
|
String masterPublicKey = masterPublicKeyOrNull != null ? masterPublicKeyOrNull : TextSecurePreferences.getLocalNumber(context);
|
||||||
|
|
||||||
memberAddresses.add(Address.fromSerialized(publicKeyToUse));
|
memberAddresses.add(Address.fromSerialized(masterPublicKey));
|
||||||
groupDatabase.create(groupId, name, new LinkedList<>(memberAddresses), null, null, new LinkedList<>(adminAddresses));
|
groupDatabase.create(groupId, name, new LinkedList<>(memberAddresses), null, null, new LinkedList<>(adminAddresses));
|
||||||
|
|
||||||
if (!mms) {
|
if (!mms) {
|
||||||
@ -99,7 +99,7 @@ public class GroupManager {
|
|||||||
@Nullable Bitmap avatar,
|
@Nullable Bitmap avatar,
|
||||||
@Nullable String name)
|
@Nullable String name)
|
||||||
{
|
{
|
||||||
final String groupID = GroupUtil.getEncodedPublicChatId(id.getBytes());
|
final String groupID = GroupUtil.getEncodedOpenGroupId(id.getBytes());
|
||||||
return createLokiGroup(groupID, context, avatar, name);
|
return createLokiGroup(groupID, context, avatar, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,9 @@ public class AttachmentDownloadJob extends BaseJob implements InjectableType {
|
|||||||
try {
|
try {
|
||||||
long id = Long.parseLong(attachment.getLocation());
|
long id = Long.parseLong(attachment.getLocation());
|
||||||
if (isPublicAttachment) {
|
if (isPublicAttachment) {
|
||||||
return new SignalServiceAttachmentPointer(id, null, new byte[0],
|
return new SignalServiceAttachmentPointer(id,
|
||||||
|
null,
|
||||||
|
new byte[0],
|
||||||
Optional.of(Util.toIntExact(attachment.getSize())),
|
Optional.of(Util.toIntExact(attachment.getSize())),
|
||||||
Optional.absent(),
|
Optional.absent(),
|
||||||
0,
|
0,
|
||||||
|
@ -148,9 +148,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob implements InjectableTy
|
|||||||
verifiedMessage,
|
verifiedMessage,
|
||||||
Optional.fromNullable(recipient.getProfileKey()),
|
Optional.fromNullable(recipient.getProfileKey()),
|
||||||
recipient.isBlocked(),
|
recipient.isBlocked(),
|
||||||
recipient.getExpireMessages() > 0 ?
|
recipient.getExpireMessages() > 0 ? Optional.of(recipient.getExpireMessages()) : Optional.absent()));
|
||||||
Optional.of(recipient.getExpireMessages()) :
|
|
||||||
Optional.absent()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -124,7 +124,7 @@ public class MultiDeviceGroupUpdateJob extends BaseJob implements InjectableType
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onShouldRetry(@NonNull Exception exception) {
|
public boolean onShouldRetry(@NonNull Exception exception) {
|
||||||
// Loki - Disabled because we have our own retrying
|
// Loki - Disabled since we have our own retrying
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI;
|
|||||||
import org.whispersystems.signalservice.loki.crypto.LokiServiceCipher;
|
import org.whispersystems.signalservice.loki.crypto.LokiServiceCipher;
|
||||||
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager;
|
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager;
|
||||||
import org.whispersystems.signalservice.loki.protocol.meta.LokiServiceMessage;
|
import org.whispersystems.signalservice.loki.protocol.meta.LokiServiceMessage;
|
||||||
|
import org.whispersystems.signalservice.loki.utilities.PublicKeyValidation;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
@ -824,7 +825,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
private long handleSynchronizeSentExpirationUpdate(@NonNull SentTranscriptMessage message) throws MmsException {
|
private long handleSynchronizeSentExpirationUpdate(@NonNull SentTranscriptMessage message) throws MmsException {
|
||||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||||
Recipient recipient = getSyncMessageMasterDestination(message.getDestination().get());
|
Recipient recipient = getSyncMessageMasterDestination(message);
|
||||||
|
|
||||||
OutgoingExpirationUpdateMessage expirationUpdateMessage = new OutgoingExpirationUpdateMessage(recipient,
|
OutgoingExpirationUpdateMessage expirationUpdateMessage = new OutgoingExpirationUpdateMessage(recipient,
|
||||||
message.getTimestamp(),
|
message.getTimestamp(),
|
||||||
@ -844,7 +845,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
throws MmsException
|
throws MmsException
|
||||||
{
|
{
|
||||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||||
Recipient recipients = getSyncMessageMasterDestination(message.getDestination().get());
|
Recipient recipients = getSyncMessageMasterDestination(message);
|
||||||
Optional<QuoteModel> quote = getValidatedQuote(message.getMessage().getQuote());
|
Optional<QuoteModel> quote = getValidatedQuote(message.getMessage().getQuote());
|
||||||
Optional<Attachment> sticker = getStickerAttachment(message.getMessage().getSticker());
|
Optional<Attachment> sticker = getStickerAttachment(message.getMessage().getSticker());
|
||||||
Optional<List<Contact>> sharedContacts = getContacts(message.getMessage().getSharedContacts());
|
Optional<List<Contact>> sharedContacts = getContacts(message.getMessage().getSharedContacts());
|
||||||
@ -1007,7 +1008,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
throws MmsException
|
throws MmsException
|
||||||
{
|
{
|
||||||
|
|
||||||
Recipient recipient = getSyncMessageMasterDestination(message.getDestination().get());
|
Recipient recipient = getSyncMessageMasterDestination(message);
|
||||||
String body = message.getMessage().getBody().or("");
|
String body = message.getMessage().getBody().or("");
|
||||||
long expiresInMillis = message.getMessage().getExpiresInSeconds() * 1000L;
|
long expiresInMillis = message.getMessage().getExpiresInSeconds() * 1000L;
|
||||||
|
|
||||||
@ -1394,10 +1395,42 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Recipient getSyncMessageMasterDestination(String publicKey) {
|
private Recipient getSyncMessageMasterDestination(SentTranscriptMessage message) {
|
||||||
Recipient recipient = Recipient.from(context, Address.fromSerialized(publicKey), false);
|
if (message.getMessage().isGroupMessage()) {
|
||||||
if (recipient.isGroupRecipient()) {
|
return Recipient.from(context, Address.fromSerialized(GroupUtil.getEncodedId(message.getMessage().getGroupInfo().get())), false);
|
||||||
return recipient;
|
} else {
|
||||||
|
String publicKey = message.getDestination().get();
|
||||||
|
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||||
|
Set<String> allUserDevices = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey);
|
||||||
|
if (allUserDevices.contains(publicKey)) {
|
||||||
|
return Recipient.from(context, Address.fromSerialized(userPublicKey), false);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
// TODO: Burn this with fire when we can
|
||||||
|
PromiseUtilities.timeout(LokiFileServerAPI.shared.getDeviceLinks(publicKey, false), 4000).get();
|
||||||
|
String masterPublicKey = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey);
|
||||||
|
if (masterPublicKey == null) {
|
||||||
|
masterPublicKey = publicKey;
|
||||||
|
}
|
||||||
|
return Recipient.from(context, Address.fromSerialized(masterPublicKey), false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Recipient.from(context, Address.fromSerialized(publicKey), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Recipient getMessageDestination(SignalServiceContent content, SignalServiceDataMessage message) {
|
||||||
|
if (message.getGroupInfo().isPresent()) {
|
||||||
|
return Recipient.from(context, Address.fromExternal(context, GroupUtil.getEncodedId(message.getGroupInfo().get().getGroupId(), false)), false);
|
||||||
|
} else {
|
||||||
|
return Recipient.from(context, Address.fromExternal(context, content.getSender()), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Recipient getMessageMasterDestination(String publicKey) {
|
||||||
|
if (!PublicKeyValidation.isValid(publicKey)) {
|
||||||
|
return Recipient.from(context, Address.fromSerialized(publicKey), false);
|
||||||
} else {
|
} else {
|
||||||
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||||
Set<String> allUserDevices = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey);
|
Set<String> allUserDevices = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey);
|
||||||
@ -1413,39 +1446,12 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
return Recipient.from(context, Address.fromSerialized(masterPublicKey), false);
|
return Recipient.from(context, Address.fromSerialized(masterPublicKey), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return recipient;
|
return Recipient.from(context, Address.fromSerialized(publicKey), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Recipient getMessageDestination(SignalServiceContent content, SignalServiceDataMessage message) {
|
|
||||||
if (message.getGroupInfo().isPresent()) {
|
|
||||||
return Recipient.from(context, Address.fromExternal(context, GroupUtil.getEncodedId(message.getGroupInfo().get().getGroupId(), false)), false);
|
|
||||||
} else {
|
|
||||||
return Recipient.from(context, Address.fromExternal(context, content.getSender()), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Recipient getMessageMasterDestination(String publicKey) {
|
|
||||||
Recipient recipient = Recipient.from(context, Address.fromSerialized(publicKey), false);
|
|
||||||
if (recipient.isGroupRecipient()) {
|
|
||||||
return recipient;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
// TODO: Burn this with fire when we can
|
|
||||||
PromiseUtilities.timeout(LokiFileServerAPI.shared.getDeviceLinks(publicKey, false), 4000).get();
|
|
||||||
String masterPublicKey = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey);
|
|
||||||
if (masterPublicKey == null) {
|
|
||||||
masterPublicKey = publicKey;
|
|
||||||
}
|
|
||||||
return Recipient.from(context, Address.fromSerialized(masterPublicKey), false);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return recipient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyTypingStoppedFromIncomingMessage(@NonNull Recipient conversationRecipient, @NonNull String sender, int device) {
|
private void notifyTypingStoppedFromIncomingMessage(@NonNull Recipient conversationRecipient, @NonNull String sender, int device) {
|
||||||
Recipient author = Recipient.from(context, Address.fromSerialized(sender), false);
|
Recipient author = Recipient.from(context, Address.fromSerialized(sender), false);
|
||||||
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(conversationRecipient);
|
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(conversationRecipient);
|
||||||
|
@ -247,10 +247,8 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Bitmap getCircularBitmap(Bitmap bitmap) {
|
private Bitmap getCircularBitmap(Bitmap bitmap) {
|
||||||
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
|
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
|
||||||
final Canvas canvas = new Canvas(output);
|
final Canvas canvas = new Canvas(output);
|
||||||
|
|
||||||
final int color = Color.RED;
|
final int color = Color.RED;
|
||||||
final Paint paint = new Paint();
|
final Paint paint = new Paint();
|
||||||
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||||
@ -260,7 +258,6 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
canvas.drawARGB(0, 0, 0, 0);
|
canvas.drawARGB(0, 0, 0, 0);
|
||||||
paint.setColor(color);
|
paint.setColor(color);
|
||||||
canvas.drawOval(rectF, paint);
|
canvas.drawOval(rectF, paint);
|
||||||
|
|
||||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||||
canvas.drawBitmap(bitmap, rect, rect, paint);
|
canvas.drawBitmap(bitmap, rect, rect, paint);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class ProfilePreference extends Preference {
|
|||||||
private TextView profileNameView;
|
private TextView profileNameView;
|
||||||
private TextView profileNumberView;
|
private TextView profileNumberView;
|
||||||
private TextView profileTagView;
|
private TextView profileTagView;
|
||||||
private String ourDeviceWords;
|
private String shortDeviceMnemonic;
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
public ProfilePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public ProfilePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
@ -81,8 +81,8 @@ public class ProfilePreference extends Preference {
|
|||||||
|
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||||
String masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
String userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||||
String publicKeyToUse = masterPublicKey != null ? masterPublicKey : userPublicKey;
|
String publicKeyToUse = userMasterPublicKey != null ? userMasterPublicKey : userPublicKey;
|
||||||
final Address address = Address.fromSerialized(publicKeyToUse);
|
final Address address = Address.fromSerialized(publicKeyToUse);
|
||||||
final Recipient recipient = Recipient.from(context, address, false);
|
final Recipient recipient = Recipient.from(context, address, false);
|
||||||
final String displayName = TextSecurePreferences.getProfileName(context);
|
final String displayName = TextSecurePreferences.getProfileName(context);
|
||||||
@ -121,13 +121,14 @@ public class ProfilePreference extends Preference {
|
|||||||
profileNameView.setVisibility(TextUtils.isEmpty(displayName) ? View.GONE : View.VISIBLE);
|
profileNameView.setVisibility(TextUtils.isEmpty(displayName) ? View.GONE : View.VISIBLE);
|
||||||
profileNumberView.setText(address.toPhoneString());
|
profileNumberView.setText(address.toPhoneString());
|
||||||
|
|
||||||
profileTagView.setVisibility(masterPublicKey == null ? View.GONE : View.VISIBLE);
|
profileTagView.setVisibility(userMasterPublicKey == null ? View.GONE : View.VISIBLE);
|
||||||
if (masterPublicKey != null && ourDeviceWords == null) {
|
|
||||||
|
if (userMasterPublicKey != null && shortDeviceMnemonic == null) {
|
||||||
MnemonicCodec codec = new MnemonicCodec(MnemonicUtilities.getLanguageFileDirectory(context));
|
MnemonicCodec codec = new MnemonicCodec(MnemonicUtilities.getLanguageFileDirectory(context));
|
||||||
ourDeviceWords = MnemonicUtilities.getFirst3Words(codec, userPublicKey);
|
shortDeviceMnemonic = MnemonicUtilities.getFirst3Words(codec, userPublicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
String tag = context.getResources().getString(R.string.activity_settings_linked_device_tag);
|
String tag = context.getResources().getString(R.string.activity_settings_linked_device_tag);
|
||||||
profileTagView.setText(String.format(tag, ourDeviceWords != null ? ourDeviceWords : "-"));
|
profileTagView.setText(String.format(tag, shortDeviceMnemonic != null ? shortDeviceMnemonic : "-"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,6 @@ import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
|||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
|
||||||
public class MessageSenderEventListener implements SignalServiceMessageSender.EventListener {
|
public class MessageSenderEventListener implements SignalServiceMessageSender.EventListener {
|
||||||
|
|
||||||
private static final String TAG = MessageSenderEventListener.class.getSimpleName();
|
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
public MessageSenderEventListener(Context context) {
|
public MessageSenderEventListener(Context context) {
|
||||||
@ -22,15 +19,18 @@ public class MessageSenderEventListener implements SignalServiceMessageSender.Ev
|
|||||||
SecurityEvent.broadcastSecurityUpdateEvent(context);
|
SecurityEvent.broadcastSecurityUpdateEvent(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFriendRequestSending(long messageID, long threadID) {
|
@Override
|
||||||
|
public void onFriendRequestSending(long messageID, long threadID) {
|
||||||
FriendRequestProtocol.setFriendRequestStatusToSendingIfNeeded(context, messageID, threadID);
|
FriendRequestProtocol.setFriendRequestStatusToSendingIfNeeded(context, messageID, threadID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFriendRequestSent(long messageID, long threadID) {
|
@Override
|
||||||
|
public void onFriendRequestSent(long messageID, long threadID) {
|
||||||
FriendRequestProtocol.setFriendRequestStatusToSentIfNeeded(context, messageID, threadID);
|
FriendRequestProtocol.setFriendRequestStatusToSentIfNeeded(context, messageID, threadID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFriendRequestSendingFailed(long messageID, long threadID) {
|
@Override
|
||||||
|
public void onFriendRequestSendingFailed(long messageID, long threadID) {
|
||||||
FriendRequestProtocol.setFriendRequestStatusToFailedIfNeeded(context, messageID, threadID);
|
FriendRequestProtocol.setFriendRequestStatusToFailedIfNeeded(context, messageID, threadID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
|
|
||||||
public synchronized String toShortString() {
|
public synchronized String toShortString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
return (name == null ? address.serialize() : name);
|
return (name != null ? name : address.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized @NonNull Drawable getFallbackContactPhotoDrawable(Context context, boolean inverted) {
|
public synchronized @NonNull Drawable getFallbackContactPhotoDrawable(Context context, boolean inverted) {
|
||||||
@ -469,8 +469,8 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
else {
|
else {
|
||||||
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||||
String publicKey = address.serialize();
|
String publicKey = address.serialize();
|
||||||
String masterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
String userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||||
String publicKeyToUse = (publicKey.equalsIgnoreCase(userPublicKey) && masterDevice != null) ? masterDevice : publicKey;
|
String publicKeyToUse = (publicKey.equalsIgnoreCase(userPublicKey) && userMasterPublicKey != null) ? userMasterPublicKey : publicKey;
|
||||||
return new JazzIdenticonContactPhoto(publicKeyToUse);
|
return new JazzIdenticonContactPhoto(publicKeyToUse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package org.thoughtcrime.securesms.search;
|
package org.thoughtcrime.securesms.search;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.DatabaseUtils;
|
import android.database.DatabaseUtils;
|
||||||
import android.database.MergeCursor;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
||||||
import org.thoughtcrime.securesms.contacts.ContactsDatabase;
|
import org.thoughtcrime.securesms.contacts.ContactsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.Address;
|
import org.thoughtcrime.securesms.database.Address;
|
||||||
@ -20,13 +17,11 @@ import org.thoughtcrime.securesms.database.SearchDatabase;
|
|||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.search.model.MessageResult;
|
import org.thoughtcrime.securesms.search.model.MessageResult;
|
||||||
import org.thoughtcrime.securesms.search.model.SearchResult;
|
import org.thoughtcrime.securesms.search.model.SearchResult;
|
||||||
import org.thoughtcrime.securesms.util.Stopwatch;
|
import org.thoughtcrime.securesms.util.Stopwatch;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -122,7 +117,7 @@ public class SearchRepository {
|
|||||||
|
|
||||||
private CursorList<Recipient> queryContacts(String query) {
|
private CursorList<Recipient> queryContacts(String query) {
|
||||||
return CursorList.emptyList();
|
return CursorList.emptyList();
|
||||||
/* Loki - Don't need contact permissions
|
/* Loki - We don't need contacts permission
|
||||||
if (!Permissions.hasAny(context, Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)) {
|
if (!Permissions.hasAny(context, Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)) {
|
||||||
return CursorList.emptyList();
|
return CursorList.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -28,16 +28,16 @@ import static org.whispersystems.signalservice.internal.push.SignalServiceProtos
|
|||||||
|
|
||||||
public class GroupUtil {
|
public class GroupUtil {
|
||||||
|
|
||||||
private static final String ENCODED_SIGNAL_GROUP_PREFIX = "__textsecure_group__!";
|
private static final String ENCODED_CLOSED_GROUP_PREFIX = "__textsecure_group__!";
|
||||||
private static final String ENCODED_MMS_GROUP_PREFIX = "__signal_mms_group__!";
|
private static final String ENCODED_MMS_GROUP_PREFIX = "__signal_mms_group__!";
|
||||||
private static final String ENCODED_PUBLIC_CHAT_GROUP_PREFIX = "__loki_public_chat_group__!";
|
private static final String ENCODED_OPEN_GROUP_PREFIX = "__loki_public_chat_group__!";
|
||||||
private static final String ENCODED_RSS_FEED_GROUP_PREFIX = "__loki_rss_feed_group__!";
|
private static final String ENCODED_RSS_FEED_GROUP_PREFIX = "__loki_rss_feed_group__!";
|
||||||
private static final String TAG = GroupUtil.class.getSimpleName();
|
private static final String TAG = GroupUtil.class.getSimpleName();
|
||||||
|
|
||||||
public static String getEncodedId(SignalServiceGroup group) {
|
public static String getEncodedId(SignalServiceGroup group) {
|
||||||
byte[] groupId = group.getGroupId();
|
byte[] groupId = group.getGroupId();
|
||||||
if (group.getGroupType() == SignalServiceGroup.GroupType.PUBLIC_CHAT) {
|
if (group.getGroupType() == SignalServiceGroup.GroupType.PUBLIC_CHAT) {
|
||||||
return getEncodedPublicChatId(groupId);
|
return getEncodedOpenGroupId(groupId);
|
||||||
} else if (group.getGroupType() == SignalServiceGroup.GroupType.RSS_FEED) {
|
} else if (group.getGroupType() == SignalServiceGroup.GroupType.RSS_FEED) {
|
||||||
return getEncodedRSSFeedId(groupId);
|
return getEncodedRSSFeedId(groupId);
|
||||||
}
|
}
|
||||||
@ -45,11 +45,11 @@ public class GroupUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getEncodedId(byte[] groupId, boolean mms) {
|
public static String getEncodedId(byte[] groupId, boolean mms) {
|
||||||
return (mms ? ENCODED_MMS_GROUP_PREFIX : ENCODED_SIGNAL_GROUP_PREFIX) + Hex.toStringCondensed(groupId);
|
return (mms ? ENCODED_MMS_GROUP_PREFIX : ENCODED_CLOSED_GROUP_PREFIX) + Hex.toStringCondensed(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getEncodedPublicChatId(byte[] groupId) {
|
public static String getEncodedOpenGroupId(byte[] groupId) {
|
||||||
return ENCODED_PUBLIC_CHAT_GROUP_PREFIX + Hex.toStringCondensed(groupId);
|
return ENCODED_OPEN_GROUP_PREFIX + Hex.toStringCondensed(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getEncodedRSSFeedId(byte[] groupId) {
|
public static String getEncodedRSSFeedId(byte[] groupId) {
|
||||||
@ -70,7 +70,7 @@ public class GroupUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEncodedGroup(@NonNull String groupId) {
|
public static boolean isEncodedGroup(@NonNull String groupId) {
|
||||||
return groupId.startsWith(ENCODED_SIGNAL_GROUP_PREFIX) || groupId.startsWith(ENCODED_MMS_GROUP_PREFIX) || groupId.startsWith(ENCODED_PUBLIC_CHAT_GROUP_PREFIX) || groupId.startsWith(ENCODED_RSS_FEED_GROUP_PREFIX);
|
return groupId.startsWith(ENCODED_CLOSED_GROUP_PREFIX) || groupId.startsWith(ENCODED_MMS_GROUP_PREFIX) || groupId.startsWith(ENCODED_OPEN_GROUP_PREFIX) || groupId.startsWith(ENCODED_RSS_FEED_GROUP_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMmsGroup(@NonNull String groupId) {
|
public static boolean isMmsGroup(@NonNull String groupId) {
|
||||||
@ -78,7 +78,7 @@ public class GroupUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOpenGroup(@NonNull String groupId) {
|
public static boolean isOpenGroup(@NonNull String groupId) {
|
||||||
return groupId.startsWith(ENCODED_PUBLIC_CHAT_GROUP_PREFIX);
|
return groupId.startsWith(ENCODED_OPEN_GROUP_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRSSFeed(@NonNull String groupId) {
|
public static boolean isRSSFeed(@NonNull String groupId) {
|
||||||
@ -86,7 +86,7 @@ public class GroupUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClosedGroup(@NonNull String groupId) {
|
public static boolean isClosedGroup(@NonNull String groupId) {
|
||||||
return groupId.startsWith(ENCODED_SIGNAL_GROUP_PREFIX);
|
return groupId.startsWith(ENCODED_CLOSED_GROUP_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
@ -159,9 +159,9 @@ public class GroupUtil {
|
|||||||
// If we were the one that quit then we need to leave the group (only relevant for slave
|
// If we were the one that quit then we need to leave the group (only relevant for slave
|
||||||
// devices in a multi device context)
|
// devices in a multi device context)
|
||||||
if (!removedMembers.isEmpty()) {
|
if (!removedMembers.isEmpty()) {
|
||||||
String masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
String masterPublicKeyOrNull = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||||
String userPublicKey = masterPublicKey != null ? masterPublicKey : TextSecurePreferences.getLocalNumber(context);
|
String masterPublicKey = masterPublicKeyOrNull != null ? masterPublicKeyOrNull : TextSecurePreferences.getLocalNumber(context);
|
||||||
wasCurrentUserRemoved = removedMembers.contains(userPublicKey);
|
wasCurrentUserRemoved = removedMembers.contains(masterPublicKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user