mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
further cleaning on V1 multi device
This commit is contained in:
parent
8e5e2fdc49
commit
0d2f5e0cde
@ -555,12 +555,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
if (publicChatAPI == null) { return; }
|
if (publicChatAPI == null) { return; }
|
||||||
byte[] profileKey = ProfileKeyUtil.getProfileKey(this);
|
byte[] profileKey = ProfileKeyUtil.getProfileKey(this);
|
||||||
String url = TextSecurePreferences.getProfilePictureURL(this);
|
String url = TextSecurePreferences.getProfilePictureURL(this);
|
||||||
String userMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(this);
|
|
||||||
if (userMasterDevice != null) {
|
|
||||||
Recipient userMasterDeviceAsRecipient = Recipient.from(this, Address.fromSerialized(userMasterDevice), false).resolve();
|
|
||||||
profileKey = userMasterDeviceAsRecipient.getProfileKey();
|
|
||||||
url = userMasterDeviceAsRecipient.getProfileAvatar();
|
|
||||||
}
|
|
||||||
Set<String> servers = DatabaseFactory.getLokiThreadDatabase(this).getAllPublicChatServers();
|
Set<String> servers = DatabaseFactory.getLokiThreadDatabase(this).getAllPublicChatServers();
|
||||||
for (String server : servers) {
|
for (String server : servers) {
|
||||||
if (profileKey != null) {
|
if (profileKey != null) {
|
||||||
|
@ -92,7 +92,6 @@ public class SignalCommunicationModule {
|
|||||||
new DynamicCredentialsProvider(context),
|
new DynamicCredentialsProvider(context),
|
||||||
new SignalProtocolStoreImpl(context),
|
new SignalProtocolStoreImpl(context),
|
||||||
BuildConfig.USER_AGENT,
|
BuildConfig.USER_AGENT,
|
||||||
TextSecurePreferences.isMultiDevice(context),
|
|
||||||
Optional.fromNullable(IncomingMessageObserver.getPipe()),
|
Optional.fromNullable(IncomingMessageObserver.getPipe()),
|
||||||
Optional.fromNullable(IncomingMessageObserver.getUnidentifiedPipe()),
|
Optional.fromNullable(IncomingMessageObserver.getUnidentifiedPipe()),
|
||||||
Optional.of(new MessageSenderEventListener(context)),
|
Optional.of(new MessageSenderEventListener(context)),
|
||||||
@ -108,7 +107,6 @@ public class SignalCommunicationModule {
|
|||||||
((ApplicationContext)context.getApplicationContext()).broadcaster);
|
((ApplicationContext)context.getApplicationContext()).broadcaster);
|
||||||
} else {
|
} else {
|
||||||
this.messageSender.setMessagePipe(IncomingMessageObserver.getPipe(), IncomingMessageObserver.getUnidentifiedPipe());
|
this.messageSender.setMessagePipe(IncomingMessageObserver.getPipe(), IncomingMessageObserver.getUnidentifiedPipe());
|
||||||
this.messageSender.setIsMultiDevice(TextSecurePreferences.isMultiDevice(context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.messageSender;
|
return this.messageSender;
|
||||||
|
@ -73,10 +73,9 @@ 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 masterPublicKeyOrNull = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||||
String masterPublicKey = masterPublicKeyOrNull != null ? masterPublicKeyOrNull : TextSecurePreferences.getLocalNumber(context);
|
|
||||||
|
|
||||||
memberAddresses.add(Address.fromSerialized(masterPublicKey));
|
memberAddresses.add(Address.fromSerialized(userPublicKey));
|
||||||
groupDatabase.create(groupId, name, new LinkedList<>(memberAddresses), null, null, new LinkedList<>(adminAddresses), System.currentTimeMillis());
|
groupDatabase.create(groupId, name, new LinkedList<>(memberAddresses), null, null, new LinkedList<>(adminAddresses), System.currentTimeMillis());
|
||||||
|
|
||||||
groupDatabase.updateProfilePicture(groupId, avatarBytes);
|
groupDatabase.updateProfilePicture(groupId, avatarBytes);
|
||||||
|
@ -125,10 +125,9 @@ public class GroupMessageProcessor {
|
|||||||
Address address = Address.fromExternal(context, GroupUtil.getEncodedId(group));
|
Address address = Address.fromExternal(context, GroupUtil.getEncodedId(group));
|
||||||
Recipient recipient = Recipient.from(context, address, false);
|
Recipient recipient = Recipient.from(context, address, false);
|
||||||
|
|
||||||
String userMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||||
if (userMasterDevice == null) { userMasterDevice = TextSecurePreferences.getLocalNumber(context); }
|
|
||||||
|
|
||||||
if (content.getSender().equals(userMasterDevice)) {
|
if (content.getSender().equals(userPublicKey)) {
|
||||||
long threadId = threadDatabase.getThreadIdIfExistsFor(recipient);
|
long threadId = threadDatabase.getThreadIdIfExistsFor(recipient);
|
||||||
return threadId == -1 ? null : threadId;
|
return threadId == -1 ? null : threadId;
|
||||||
}
|
}
|
||||||
@ -141,9 +140,9 @@ public class GroupMessageProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loki - Only process update messages if we're part of the group
|
// Loki - Only process update messages if we're part of the group
|
||||||
Address userMasterDeviceAddress = Address.fromSerialized(userMasterDevice);
|
Address userMasterDeviceAddress = Address.fromSerialized(userPublicKey);
|
||||||
if (!groupRecord.getMembers().contains(userMasterDeviceAddress) &&
|
if (!groupRecord.getMembers().contains(userMasterDeviceAddress) &&
|
||||||
!group.getMembers().or(Collections.emptyList()).contains(userMasterDevice)) {
|
!group.getMembers().or(Collections.emptyList()).contains(userPublicKey)) {
|
||||||
Log.d("Loki", "Received a group update message from a group we're not a member of: " + id + "; ignoring.");
|
Log.d("Loki", "Received a group update message from a group we're not a member of: " + id + "; ignoring.");
|
||||||
database.setActive(id, false);
|
database.setActive(id, false);
|
||||||
return null;
|
return null;
|
||||||
@ -193,7 +192,7 @@ public class GroupMessageProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we were removed then we need to disable the chat
|
// If we were removed then we need to disable the chat
|
||||||
if (removedMembers.contains(Address.fromSerialized(userMasterDevice))) {
|
if (removedMembers.contains(Address.fromSerialized(userPublicKey))) {
|
||||||
database.setActive(id, false);
|
database.setActive(id, false);
|
||||||
} else {
|
} else {
|
||||||
if (!groupRecord.isActive()) database.setActive(id, true);
|
if (!groupRecord.isActive()) database.setActive(id, true);
|
||||||
|
@ -276,17 +276,5 @@ public abstract class PushSendJob extends SendJob {
|
|||||||
// Loki - We don't need verification on sender certificates
|
// Loki - We don't need verification on sender certificates
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SignalServiceSyncMessage buildSelfSendSyncMessage(@NonNull Context context, @NonNull SignalServiceDataMessage message, Optional<UnidentifiedAccessPair> syncAccess) {
|
|
||||||
String masterPublicKeyOrNull = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
|
||||||
String masterPublicKey = masterPublicKeyOrNull != null ? masterPublicKeyOrNull : TextSecurePreferences.getLocalNumber(context);
|
|
||||||
SentTranscriptMessage transcript = new SentTranscriptMessage(masterPublicKey,
|
|
||||||
message.getTimestamp(),
|
|
||||||
message,
|
|
||||||
message.getExpiresInSeconds(),
|
|
||||||
Collections.singletonMap(masterPublicKey, syncAccess.isPresent()));
|
|
||||||
return SignalServiceSyncMessage.forSentTranscript(transcript);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected abstract void onPushSend() throws Exception;
|
protected abstract void onPushSend() throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,7 @@ class CreatePrivateChatActivity : PassphraseRequiredActionBarActivity(), ScanQRC
|
|||||||
|
|
||||||
fun createPrivateChatIfPossible(hexEncodedPublicKey: String) {
|
fun createPrivateChatIfPossible(hexEncodedPublicKey: String) {
|
||||||
if (!PublicKeyValidation.isValid(hexEncodedPublicKey)) { return Toast.makeText(this, R.string.invalid_session_id, Toast.LENGTH_SHORT).show() }
|
if (!PublicKeyValidation.isValid(hexEncodedPublicKey)) { return Toast.makeText(this, R.string.invalid_session_id, Toast.LENGTH_SHORT).show() }
|
||||||
val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(this)
|
val recipient = Recipient.from(this, Address.fromSerialized(hexEncodedPublicKey), false)
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this)!!
|
|
||||||
val targetHexEncodedPublicKey = if (hexEncodedPublicKey == masterHexEncodedPublicKey) userHexEncodedPublicKey else hexEncodedPublicKey
|
|
||||||
val recipient = Recipient.from(this, Address.fromSerialized(targetHexEncodedPublicKey), false)
|
|
||||||
val intent = Intent(this, ConversationActivity::class.java)
|
val intent = Intent(this, ConversationActivity::class.java)
|
||||||
intent.putExtra(ConversationActivity.ADDRESS_EXTRA, recipient.address)
|
intent.putExtra(ConversationActivity.ADDRESS_EXTRA, recipient.address)
|
||||||
intent.putExtra(ConversationActivity.TEXT_EXTRA, getIntent().getStringExtra(ConversationActivity.TEXT_EXTRA))
|
intent.putExtra(ConversationActivity.TEXT_EXTRA, getIntent().getStringExtra(ConversationActivity.TEXT_EXTRA))
|
||||||
@ -115,9 +112,7 @@ class EnterPublicKeyFragment : Fragment() {
|
|||||||
|
|
||||||
private val hexEncodedPublicKey: String
|
private val hexEncodedPublicKey: String
|
||||||
get() {
|
get() {
|
||||||
val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(requireContext())
|
return TextSecurePreferences.getLocalNumber(requireContext())!!
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(requireContext())!!
|
|
||||||
return masterHexEncodedPublicKey ?: userHexEncodedPublicKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
@ -84,9 +84,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
|
|
||||||
private val publicKey: String
|
private val publicKey: String
|
||||||
get() {
|
get() {
|
||||||
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(this)
|
return TextSecurePreferences.getLocalNumber(this)!!
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(this)!!
|
|
||||||
return masterPublicKey ?: userPublicKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// region Lifecycle
|
// region Lifecycle
|
||||||
@ -111,9 +109,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
pathStatusViewContainer.disableClipping()
|
pathStatusViewContainer.disableClipping()
|
||||||
pathStatusViewContainer.setOnClickListener { showPath() }
|
pathStatusViewContainer.setOnClickListener { showPath() }
|
||||||
// Set up seed reminder view
|
// Set up seed reminder view
|
||||||
val isMasterDevice = (TextSecurePreferences.getMasterHexEncodedPublicKey(this) == null)
|
|
||||||
val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this)
|
val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this)
|
||||||
if (!hasViewedSeed && isMasterDevice) {
|
if (!hasViewedSeed) {
|
||||||
val seedReminderViewTitle = SpannableString("You're almost finished! 80%") // Intentionally not yet translated
|
val seedReminderViewTitle = SpannableString("You're almost finished! 80%") // Intentionally not yet translated
|
||||||
seedReminderViewTitle.setSpan(ForegroundColorSpan(resources.getColorWithID(R.color.accent, theme)), 24, 27, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
seedReminderViewTitle.setSpan(ForegroundColorSpan(resources.getColorWithID(R.color.accent, theme)), 24, 27, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
seedReminderView.title = seedReminderViewTitle
|
seedReminderView.title = seedReminderViewTitle
|
||||||
@ -191,9 +188,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
if (TextSecurePreferences.getLocalNumber(this) == null) { return; } // This can be the case after a secondary device is auto-cleared
|
if (TextSecurePreferences.getLocalNumber(this) == null) { return; } // This can be the case after a secondary device is auto-cleared
|
||||||
profileButton.update()
|
profileButton.update()
|
||||||
val isMasterDevice = (TextSecurePreferences.getMasterHexEncodedPublicKey(this) == null)
|
|
||||||
val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this)
|
val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this)
|
||||||
if (hasViewedSeed || !isMasterDevice) {
|
if (hasViewedSeed) {
|
||||||
seedReminderView.visibility = View.GONE
|
seedReminderView.visibility = View.GONE
|
||||||
}
|
}
|
||||||
showKeyPairMigrationSheetIfNeeded()
|
showKeyPairMigrationSheetIfNeeded()
|
||||||
|
@ -28,10 +28,6 @@ class LandingActivity : BaseActionBarActivity() {
|
|||||||
findViewById<View>(R.id.restoreButton).setOnClickListener { restoreFromRecoveryPhrase() }
|
findViewById<View>(R.id.restoreButton).setOnClickListener { restoreFromRecoveryPhrase() }
|
||||||
findViewById<View>(R.id.restoreBackupButton).setOnClickListener { restoreFromBackup() }
|
findViewById<View>(R.id.restoreBackupButton).setOnClickListener { restoreFromBackup() }
|
||||||
|
|
||||||
if (TextSecurePreferences.getWasUnlinked(this)) {
|
|
||||||
Toast.makeText(this, R.string.activity_landing_device_unlinked_dialog_title, Toast.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup essentials for a new user.
|
// Setup essentials for a new user.
|
||||||
IdentityKeyUtil.generateIdentityKeyPair(this)
|
IdentityKeyUtil.generateIdentityKeyPair(this)
|
||||||
|
|
||||||
|
@ -53,10 +53,7 @@ class QRCodeActivity : PassphraseRequiredActionBarActivity(), ScanQRCodeWrapperF
|
|||||||
|
|
||||||
fun createPrivateChatIfPossible(hexEncodedPublicKey: String) {
|
fun createPrivateChatIfPossible(hexEncodedPublicKey: String) {
|
||||||
if (!PublicKeyValidation.isValid(hexEncodedPublicKey)) { return Toast.makeText(this, R.string.invalid_session_id, Toast.LENGTH_SHORT).show() }
|
if (!PublicKeyValidation.isValid(hexEncodedPublicKey)) { return Toast.makeText(this, R.string.invalid_session_id, Toast.LENGTH_SHORT).show() }
|
||||||
val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(this)
|
val recipient = Recipient.from(this, Address.fromSerialized(hexEncodedPublicKey), false)
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this)
|
|
||||||
val targetHexEncodedPublicKey = if (hexEncodedPublicKey == masterHexEncodedPublicKey) userHexEncodedPublicKey else hexEncodedPublicKey
|
|
||||||
val recipient = Recipient.from(this, Address.fromSerialized(targetHexEncodedPublicKey!!), false)
|
|
||||||
val intent = Intent(this, ConversationActivity::class.java)
|
val intent = Intent(this, ConversationActivity::class.java)
|
||||||
intent.putExtra(ConversationActivity.ADDRESS_EXTRA, recipient.address)
|
intent.putExtra(ConversationActivity.ADDRESS_EXTRA, recipient.address)
|
||||||
intent.putExtra(ConversationActivity.TEXT_EXTRA, getIntent().getStringExtra(ConversationActivity.TEXT_EXTRA))
|
intent.putExtra(ConversationActivity.TEXT_EXTRA, getIntent().getStringExtra(ConversationActivity.TEXT_EXTRA))
|
||||||
@ -105,9 +102,7 @@ class ViewMyQRCodeFragment : Fragment() {
|
|||||||
|
|
||||||
private val hexEncodedPublicKey: String
|
private val hexEncodedPublicKey: String
|
||||||
get() {
|
get() {
|
||||||
val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(requireContext())
|
return TextSecurePreferences.getLocalNumber(requireContext())!!
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(requireContext())!!
|
|
||||||
return masterHexEncodedPublicKey ?: userHexEncodedPublicKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
@ -63,9 +63,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
|
|
||||||
private val hexEncodedPublicKey: String
|
private val hexEncodedPublicKey: String
|
||||||
get() {
|
get() {
|
||||||
val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(this)
|
return TextSecurePreferences.getLocalNumber(this)!!
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this)!!
|
|
||||||
return masterHexEncodedPublicKey ?: userHexEncodedPublicKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// region Lifecycle
|
// region Lifecycle
|
||||||
@ -85,17 +83,11 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
publicKeyTextView.text = hexEncodedPublicKey
|
publicKeyTextView.text = hexEncodedPublicKey
|
||||||
copyButton.setOnClickListener { copyPublicKey() }
|
copyButton.setOnClickListener { copyPublicKey() }
|
||||||
shareButton.setOnClickListener { sharePublicKey() }
|
shareButton.setOnClickListener { sharePublicKey() }
|
||||||
val isMasterDevice = (TextSecurePreferences.getMasterHexEncodedPublicKey(this) == null)
|
|
||||||
linkedDevicesButtonTopSeparator.visibility = View.GONE
|
linkedDevicesButtonTopSeparator.visibility = View.GONE
|
||||||
linkedDevicesButton.visibility = View.GONE
|
linkedDevicesButton.visibility = View.GONE
|
||||||
if (!isMasterDevice) {
|
|
||||||
seedButtonTopSeparator.visibility = View.GONE
|
|
||||||
seedButton.visibility = View.GONE
|
|
||||||
}
|
|
||||||
privacyButton.setOnClickListener { showPrivacySettings() }
|
privacyButton.setOnClickListener { showPrivacySettings() }
|
||||||
notificationsButton.setOnClickListener { showNotificationSettings() }
|
notificationsButton.setOnClickListener { showNotificationSettings() }
|
||||||
chatsButton.setOnClickListener { showChatSettings() }
|
chatsButton.setOnClickListener { showChatSettings() }
|
||||||
// linkedDevicesButton.setOnClickListener { showLinkedDevices() }
|
|
||||||
sendInvitationButton.setOnClickListener { sendInvitation() }
|
sendInvitationButton.setOnClickListener { sendInvitation() }
|
||||||
seedButton.setOnClickListener { showSeed() }
|
seedButton.setOnClickListener { showSeed() }
|
||||||
clearAllDataButton.setOnClickListener { clearAllData() }
|
clearAllDataButton.setOnClickListener { clearAllData() }
|
||||||
|
@ -204,7 +204,7 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh
|
|||||||
}
|
}
|
||||||
// If we got a message from our master device then make sure our mapping stays in sync
|
// If we got a message from our master device then make sure our mapping stays in sync
|
||||||
val recipient = Recipient.from(context, Address.fromSerialized(message.senderPublicKey), false)
|
val recipient = Recipient.from(context, Address.fromSerialized(message.senderPublicKey), false)
|
||||||
if (recipient.isUserMasterDevice && message.profilePicture != null) {
|
if (message.profilePicture != null) {
|
||||||
val profileKey = message.profilePicture!!.profileKey
|
val profileKey = message.profilePicture!!.profileKey
|
||||||
val url = message.profilePicture!!.url
|
val url = message.profilePicture!!.url
|
||||||
if (recipient.profileKey == null || !MessageDigest.isEqual(recipient.profileKey, profileKey)) {
|
if (recipient.profileKey == null || !MessageDigest.isEqual(recipient.profileKey, profileKey)) {
|
||||||
|
@ -37,12 +37,8 @@ class MultiDeviceRemovalBottomSheet : BottomSheetDialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val explanation by lazy {
|
private val explanation by lazy {
|
||||||
if (TextSecurePreferences.getMasterHexEncodedPublicKey(requireContext()) != null) {
|
|
||||||
"You’re seeing this because this is a secondary device in a multi-device setup. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on $removalDateDescription.\n\nTo read more about this change, visit the Session FAQ at getsession.org/faq."
|
|
||||||
} else {
|
|
||||||
"You’re seeing this because you have a secondary device linked to your Session ID. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on $removalDateDescription.\n\nTo read more about this change, visit the Session FAQ at getsession.org/faq"
|
"You’re seeing this because you have a secondary device linked to your Session ID. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on $removalDateDescription.\n\nTo read more about this change, visit the Session FAQ at getsession.org/faq"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private val decoratedExplanation by lazy {
|
private val decoratedExplanation by lazy {
|
||||||
val result = SpannableStringBuilder(explanation)
|
val result = SpannableStringBuilder(explanation)
|
||||||
|
@ -47,9 +47,8 @@ object SessionMetaProtocol {
|
|||||||
val displayName = content.senderDisplayName.orNull() ?: return
|
val displayName = content.senderDisplayName.orNull() ?: return
|
||||||
if (displayName.isBlank()) { return }
|
if (displayName.isBlank()) { return }
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
val userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
|
||||||
val sender = content.sender.toLowerCase()
|
val sender = content.sender.toLowerCase()
|
||||||
if (userMasterPublicKey == sender) {
|
if (userPublicKey == sender) {
|
||||||
// Update the user's local name if the message came from their master device
|
// Update the user's local name if the message came from their master device
|
||||||
TextSecurePreferences.setProfileName(context, displayName)
|
TextSecurePreferences.setProfileName(context, displayName)
|
||||||
}
|
}
|
||||||
@ -67,8 +66,8 @@ object SessionMetaProtocol {
|
|||||||
database.setUnidentifiedAccessMode(recipient, Recipient.UnidentifiedAccessMode.UNKNOWN)
|
database.setUnidentifiedAccessMode(recipient, Recipient.UnidentifiedAccessMode.UNKNOWN)
|
||||||
val url = content.senderProfilePictureURL.or("")
|
val url = content.senderProfilePictureURL.or("")
|
||||||
ApplicationContext.getInstance(context).jobManager.add(RetrieveProfileAvatarJob(recipient, url))
|
ApplicationContext.getInstance(context).jobManager.add(RetrieveProfileAvatarJob(recipient, url))
|
||||||
val userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
if (userMasterPublicKey == content.sender) {
|
if (userPublicKey == content.sender) {
|
||||||
ApplicationContext.getInstance(context).updateOpenGroupProfilePicturesIfNeeded()
|
ApplicationContext.getInstance(context).updateOpenGroupProfilePicturesIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class GroupDescription(context: Context, groupContext: SignalServiceProtos.Group
|
|||||||
private val groupContext: SignalServiceProtos.GroupContext?
|
private val groupContext: SignalServiceProtos.GroupContext?
|
||||||
private val newMembers: MutableList<Recipient>
|
private val newMembers: MutableList<Recipient>
|
||||||
private val removedMembers: MutableList<Recipient>
|
private val removedMembers: MutableList<Recipient>
|
||||||
private var wasCurrentUserRemoved: Boolean
|
private var wasCurrentUserRemoved: Boolean = false
|
||||||
private fun toRecipient(hexEncodedPublicKey: String): Recipient {
|
private fun toRecipient(hexEncodedPublicKey: String): Recipient {
|
||||||
val address = Address.fromSerialized(hexEncodedPublicKey)
|
val address = Address.fromSerialized(hexEncodedPublicKey)
|
||||||
return Recipient.from(context, address, false)
|
return Recipient.from(context, address, false)
|
||||||
@ -74,7 +74,6 @@ class GroupDescription(context: Context, groupContext: SignalServiceProtos.Group
|
|||||||
this.groupContext = groupContext
|
this.groupContext = groupContext
|
||||||
newMembers = LinkedList()
|
newMembers = LinkedList()
|
||||||
removedMembers = LinkedList()
|
removedMembers = LinkedList()
|
||||||
wasCurrentUserRemoved = false
|
|
||||||
if (groupContext != null) {
|
if (groupContext != null) {
|
||||||
val newMembers = groupContext.newMembersList
|
val newMembers = groupContext.newMembersList
|
||||||
for (member in newMembers) {
|
for (member in newMembers) {
|
||||||
@ -84,15 +83,7 @@ class GroupDescription(context: Context, groupContext: SignalServiceProtos.Group
|
|||||||
for (member in removedMembers) {
|
for (member in removedMembers) {
|
||||||
this.removedMembers.add(toRecipient(member))
|
this.removedMembers.add(toRecipient(member))
|
||||||
}
|
}
|
||||||
|
wasCurrentUserRemoved = removedMembers.contains(TextSecurePreferences.getLocalNumber(context))
|
||||||
// If we were the one that quit then we need to leave the group (only relevant for slave
|
|
||||||
// devices in a multi device context)
|
|
||||||
if (!removedMembers.isEmpty()) {
|
|
||||||
val masterPublicKeyOrNull = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
|
||||||
val masterPublicKey = masterPublicKeyOrNull
|
|
||||||
?: TextSecurePreferences.getLocalNumber(context)
|
|
||||||
wasCurrentUserRemoved = removedMembers.contains(masterPublicKey)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,10 +75,6 @@ class ProfilePictureView : RelativeLayout {
|
|||||||
if (recipient.isGroupRecipient && !isOpenGroupWithProfilePicture(recipient)) {
|
if (recipient.isGroupRecipient && !isOpenGroupWithProfilePicture(recipient)) {
|
||||||
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf()
|
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf()
|
||||||
users.remove(TextSecurePreferences.getLocalNumber(context))
|
users.remove(TextSecurePreferences.getLocalNumber(context))
|
||||||
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
|
||||||
if (masterPublicKey != null) {
|
|
||||||
users.remove(masterPublicKey)
|
|
||||||
}
|
|
||||||
val randomUsers = users.sorted().toMutableList() // Sort to provide a level of stability
|
val randomUsers = users.sorted().toMutableList() // Sort to provide a level of stability
|
||||||
if (users.count() == 1) {
|
if (users.count() == 1) {
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
||||||
@ -159,13 +155,11 @@ class ProfilePictureView : RelativeLayout {
|
|||||||
imagesCached.add(publicKey)
|
imagesCached.add(publicKey)
|
||||||
} else {
|
} else {
|
||||||
val sizeInPX = resources.getDimensionPixelSize(sizeResId)
|
val sizeInPX = resources.getDimensionPixelSize(sizeResId)
|
||||||
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
|
||||||
val hepk = if (recipient.isLocalNumber && masterPublicKey != null) masterPublicKey else publicKey
|
|
||||||
glide.clear(imageView)
|
glide.clear(imageView)
|
||||||
glide.load(AvatarPlaceholderGenerator.generate(
|
glide.load(AvatarPlaceholderGenerator.generate(
|
||||||
context,
|
context,
|
||||||
sizeInPX,
|
sizeInPX,
|
||||||
hepk,
|
publicKey,
|
||||||
displayName
|
displayName
|
||||||
)).diskCacheStrategy(DiskCacheStrategy.ALL).circleCrop().into(imageView)
|
)).diskCacheStrategy(DiskCacheStrategy.ALL).circleCrop().into(imageView)
|
||||||
imagesCached.add(publicKey)
|
imagesCached.add(publicKey)
|
||||||
|
@ -326,10 +326,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
|
|
||||||
private static Drawable getPlaceholderDrawable(Context context, Recipient recipient) {
|
private static Drawable getPlaceholderDrawable(Context context, Recipient recipient) {
|
||||||
String publicKey = recipient.getAddress().serialize();
|
String publicKey = recipient.getAddress().serialize();
|
||||||
String hepk = (recipient.isLocalNumber() && publicKey == null)
|
|
||||||
? TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
|
||||||
: publicKey;
|
|
||||||
String displayName = recipient.getName();
|
String displayName = recipient.getName();
|
||||||
return AvatarPlaceholderGenerator.generate(context, 128, hepk, displayName);
|
return AvatarPlaceholderGenerator.generate(context, 128, publicKey, displayName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,8 +211,7 @@ public class MessageSender {
|
|||||||
private static boolean isLocalSelfSend(@NonNull Context context, @NonNull Recipient recipient, boolean forceSms) {
|
private static boolean isLocalSelfSend(@NonNull Context context, @NonNull Recipient recipient, boolean forceSms) {
|
||||||
return recipient.isLocalNumber() &&
|
return recipient.isLocalNumber() &&
|
||||||
!forceSms &&
|
!forceSms &&
|
||||||
TextSecurePreferences.isPushRegistered(context) &&
|
TextSecurePreferences.isPushRegistered(context);
|
||||||
!TextSecurePreferences.isMultiDevice(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendLocalMediaSelf(Context context, long messageId) {
|
private static void sendLocalMediaSelf(Context context, long messageId) {
|
||||||
|
@ -268,11 +268,6 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
return isLocalNumber;
|
return isLocalNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUserMasterDevice() {
|
|
||||||
String userMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
|
||||||
return userMasterDevice != null && userMasterDevice.equals(getAddress().serialize());
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable Uri getContactUri() {
|
public synchronized @Nullable Uri getContactUri() {
|
||||||
return this.contactUri;
|
return this.contactUri;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,6 @@ object TextSecurePreferences {
|
|||||||
const val MEDIA_DOWNLOAD_ROAMING_PREF = "pref_media_download_roaming"
|
const val MEDIA_DOWNLOAD_ROAMING_PREF = "pref_media_download_roaming"
|
||||||
|
|
||||||
const val SYSTEM_EMOJI_PREF = "pref_system_emoji"
|
const val SYSTEM_EMOJI_PREF = "pref_system_emoji"
|
||||||
private const val MULTI_DEVICE_PROVISIONED_PREF = "pref_multi_device"
|
|
||||||
const val DIRECT_CAPTURE_CAMERA_ID = "pref_direct_capture_camera_id"
|
const val DIRECT_CAPTURE_CAMERA_ID = "pref_direct_capture_camera_id"
|
||||||
const val PROFILE_KEY_PREF = "pref_profile_key"
|
const val PROFILE_KEY_PREF = "pref_profile_key"
|
||||||
const val PROFILE_NAME_PREF = "pref_profile_name"
|
const val PROFILE_NAME_PREF = "pref_profile_name"
|
||||||
@ -129,20 +128,9 @@ object TextSecurePreferences {
|
|||||||
private const val LAST_FCM_TOKEN_UPLOAD_TIME = "pref_last_fcm_token_upload_time_2"
|
private const val LAST_FCM_TOKEN_UPLOAD_TIME = "pref_last_fcm_token_upload_time_2"
|
||||||
|
|
||||||
// region Multi Device
|
// region Multi Device
|
||||||
private const val IS_USING_MULTI_DEVICE = "pref_is_using_multi_device"
|
|
||||||
private const val LAST_CONFIGURATION_SYNC_TIME = "pref_last_configuration_sync_time"
|
private const val LAST_CONFIGURATION_SYNC_TIME = "pref_last_configuration_sync_time"
|
||||||
private const val CONFIGURATION_SYNCED = "pref_configuration_synced"
|
private const val CONFIGURATION_SYNCED = "pref_configuration_synced"
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun isUsingMultiDevice(context: Context): Boolean {
|
|
||||||
return getBooleanPreference(context, IS_USING_MULTI_DEVICE, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun setIsUsingMultiDevice(context: Context, value: Boolean) {
|
|
||||||
setBooleanPreference(context, IS_USING_MULTI_DEVICE, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getLastConfigurationSyncTime(context: Context): Long {
|
fun getLastConfigurationSyncTime(context: Context): Long {
|
||||||
return getLongPreference(context, LAST_CONFIGURATION_SYNC_TIME, 0)
|
return getLongPreference(context, LAST_CONFIGURATION_SYNC_TIME, 0)
|
||||||
@ -417,11 +405,6 @@ object TextSecurePreferences {
|
|||||||
return getIntegerPreference(context, DIRECT_CAPTURE_CAMERA_ID, Camera.CameraInfo.CAMERA_FACING_FRONT)
|
return getIntegerPreference(context, DIRECT_CAPTURE_CAMERA_ID, Camera.CameraInfo.CAMERA_FACING_FRONT)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun isMultiDevice(context: Context): Boolean {
|
|
||||||
return getBooleanPreference(context, MULTI_DEVICE_PROVISIONED_PREF, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getNotificationPrivacy(context: Context): NotificationPrivacyPreference {
|
fun getNotificationPrivacy(context: Context): NotificationPrivacyPreference {
|
||||||
return NotificationPrivacyPreference(getStringPreference(context, NOTIFICATION_PRIVACY_PREF, "all"))
|
return NotificationPrivacyPreference(getStringPreference(context, NOTIFICATION_PRIVACY_PREF, "all"))
|
||||||
@ -876,13 +859,6 @@ object TextSecurePreferences {
|
|||||||
|
|
||||||
// region Loki
|
// region Loki
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getMasterHexEncodedPublicKey(context: Context): String? {
|
|
||||||
return getStringPreference(context, "master_hex_encoded_public_key", null)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setMasterHexEncodedPublicKey(context: Context, masterHexEncodedPublicKey: String) {
|
|
||||||
setStringPreference(context, "master_hex_encoded_public_key", masterHexEncodedPublicKey.toLowerCase())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getHasViewedSeed(context: Context): Boolean {
|
fun getHasViewedSeed(context: Context): Boolean {
|
||||||
return getBooleanPreference(context, "has_viewed_seed", false)
|
return getBooleanPreference(context, "has_viewed_seed", false)
|
||||||
@ -892,23 +868,6 @@ object TextSecurePreferences {
|
|||||||
setBooleanPreference(context, "has_viewed_seed", hasViewedSeed)
|
setBooleanPreference(context, "has_viewed_seed", hasViewedSeed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setWasUnlinked(context: Context, value: Boolean) {
|
|
||||||
// We do it this way so that it gets persisted in storage straight away
|
|
||||||
getDefaultSharedPreferences(context).edit().putBoolean("database_reset_unpair", value).commit()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getWasUnlinked(context: Context): Boolean {
|
|
||||||
return getBooleanPreference(context, "database_reset_unpair", false)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setNeedsIsRevokedSlaveDeviceCheck(context: Context, value: Boolean) {
|
|
||||||
setBooleanPreference(context, "needs_revocation", value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getNeedsIsRevokedSlaveDeviceCheck(context: Context): Boolean {
|
|
||||||
return getBooleanPreference(context, "needs_revocation", false)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setRestorationTime(context: Context, time: Long) {
|
fun setRestorationTime(context: Context, time: Long) {
|
||||||
setLongPreference(context, "restoration_time", time)
|
setLongPreference(context, "restoration_time", time)
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@ public class SignalServiceMessageSender {
|
|||||||
|
|
||||||
private final AtomicReference<Optional<SignalServiceMessagePipe>> pipe;
|
private final AtomicReference<Optional<SignalServiceMessagePipe>> pipe;
|
||||||
private final AtomicReference<Optional<SignalServiceMessagePipe>> unidentifiedPipe;
|
private final AtomicReference<Optional<SignalServiceMessagePipe>> unidentifiedPipe;
|
||||||
private final AtomicBoolean isMultiDevice;
|
|
||||||
|
|
||||||
// Loki
|
// Loki
|
||||||
private final String userPublicKey;
|
private final String userPublicKey;
|
||||||
@ -143,7 +142,6 @@ public class SignalServiceMessageSender {
|
|||||||
String user, String password,
|
String user, String password,
|
||||||
SignalProtocolStore store,
|
SignalProtocolStore store,
|
||||||
String userAgent,
|
String userAgent,
|
||||||
boolean isMultiDevice,
|
|
||||||
Optional<SignalServiceMessagePipe> pipe,
|
Optional<SignalServiceMessagePipe> pipe,
|
||||||
Optional<SignalServiceMessagePipe> unidentifiedPipe,
|
Optional<SignalServiceMessagePipe> unidentifiedPipe,
|
||||||
Optional<EventListener> eventListener,
|
Optional<EventListener> eventListener,
|
||||||
@ -158,14 +156,13 @@ public class SignalServiceMessageSender {
|
|||||||
LokiOpenGroupDatabaseProtocol openGroupDatabase,
|
LokiOpenGroupDatabaseProtocol openGroupDatabase,
|
||||||
Broadcaster broadcaster)
|
Broadcaster broadcaster)
|
||||||
{
|
{
|
||||||
this(urls, new StaticCredentialsProvider(user, password, null), store, userAgent, isMultiDevice, pipe, unidentifiedPipe, eventListener, userPublicKey, apiDatabase, threadDatabase, messageDatabase, preKeyBundleDatabase, sessionProtocolImpl, sessionResetImpl, userDatabase, openGroupDatabase, broadcaster);
|
this(urls, new StaticCredentialsProvider(user, password, null), store, userAgent, pipe, unidentifiedPipe, eventListener, userPublicKey, apiDatabase, threadDatabase, messageDatabase, preKeyBundleDatabase, sessionProtocolImpl, sessionResetImpl, userDatabase, openGroupDatabase, broadcaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceMessageSender(SignalServiceConfiguration urls,
|
public SignalServiceMessageSender(SignalServiceConfiguration urls,
|
||||||
CredentialsProvider credentialsProvider,
|
CredentialsProvider credentialsProvider,
|
||||||
SignalProtocolStore store,
|
SignalProtocolStore store,
|
||||||
String userAgent,
|
String userAgent,
|
||||||
boolean isMultiDevice,
|
|
||||||
Optional<SignalServiceMessagePipe> pipe,
|
Optional<SignalServiceMessagePipe> pipe,
|
||||||
Optional<SignalServiceMessagePipe> unidentifiedPipe,
|
Optional<SignalServiceMessagePipe> unidentifiedPipe,
|
||||||
Optional<EventListener> eventListener,
|
Optional<EventListener> eventListener,
|
||||||
@ -185,7 +182,6 @@ public class SignalServiceMessageSender {
|
|||||||
this.localAddress = new SignalServiceAddress(credentialsProvider.getUser());
|
this.localAddress = new SignalServiceAddress(credentialsProvider.getUser());
|
||||||
this.pipe = new AtomicReference<>(pipe);
|
this.pipe = new AtomicReference<>(pipe);
|
||||||
this.unidentifiedPipe = new AtomicReference<>(unidentifiedPipe);
|
this.unidentifiedPipe = new AtomicReference<>(unidentifiedPipe);
|
||||||
this.isMultiDevice = new AtomicBoolean(isMultiDevice);
|
|
||||||
this.eventListener = eventListener;
|
this.eventListener = eventListener;
|
||||||
this.userPublicKey = userPublicKey;
|
this.userPublicKey = userPublicKey;
|
||||||
this.apiDatabase = apiDatabase;
|
this.apiDatabase = apiDatabase;
|
||||||
@ -328,10 +324,6 @@ public class SignalServiceMessageSender {
|
|||||||
this.unidentifiedPipe.set(Optional.fromNullable(unidentifiedPipe));
|
this.unidentifiedPipe.set(Optional.fromNullable(unidentifiedPipe));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsMultiDevice(boolean isMultiDevice) {
|
|
||||||
this.isMultiDevice.set(isMultiDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SignalServiceAttachmentPointer uploadAttachment(SignalServiceAttachmentStream attachment, boolean usePadding, @Nullable SignalServiceAddress recipient)
|
public SignalServiceAttachmentPointer uploadAttachment(SignalServiceAttachmentStream attachment, boolean usePadding, @Nullable SignalServiceAddress recipient)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user