mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
WIP clean & make things compile
This commit is contained in:
parent
31d4deb354
commit
883c71331b
@ -133,6 +133,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
|
||||
@SuppressLint("MissingSuperCall")
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
|
||||
|
@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.loki.utilities.recipient
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
import org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.libsignal.loki.SessionResetStatus
|
||||
import org.session.libsignal.service.api.messages.SignalServiceContent
|
||||
import org.session.libsignal.service.loki.protocol.shelved.multidevice.MultiDeviceProtocol
|
||||
|
@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.service.api.messages.SignalServiceContent
|
||||
import org.session.libsignal.service.api.messages.SignalServiceDataMessage
|
||||
import java.security.MessageDigest
|
||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.loki.utilities
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.service.loki.protocol.shelved.multidevice.MultiDeviceProtocol
|
||||
|
||||
data class Contact(
|
||||
@ -29,7 +29,7 @@ object ContactUtilities {
|
||||
@JvmStatic
|
||||
fun getAllContacts(context: Context): Set<Contact> {
|
||||
val threadDatabase = DatabaseFactory.getThreadDatabase(context)
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
||||
val lokiAPIDatabase = DatabaseFactory.getLokiAPIDatabase(context)
|
||||
val userDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey)
|
||||
val cursor = threadDatabase.conversationList
|
||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.loki.utilities
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.service.loki.protocol.mentions.MentionsManager
|
||||
|
||||
object MentionManagerUtilities {
|
||||
@ -28,7 +28,7 @@ object MentionManagerUtilities {
|
||||
}
|
||||
}
|
||||
reader.close()
|
||||
result.add(TextSecurePreferences.getLocalNumber(context))
|
||||
result.add(TextSecurePreferences.getLocalNumber(context)!!)
|
||||
}
|
||||
MentionsManager.shared.userPublicKeyCache[threadID] = result
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import android.util.Range
|
||||
import network.loki.messenger.R
|
||||
import nl.komponents.kovenant.combine.Tuple2
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import java.util.regex.Pattern
|
||||
|
||||
object MentionUtilities {
|
||||
@ -28,7 +28,7 @@ object MentionUtilities {
|
||||
val mentions = mutableListOf<Tuple2<Range<Int>, String>>()
|
||||
var startIndex = 0
|
||||
val publicChat = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID)
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
||||
if (matcher.find(startIndex)) {
|
||||
while (true) {
|
||||
val publicKey = text.subSequence(matcher.start() + 1, matcher.end()).toString() // +1 to get rid of the @
|
||||
|
@ -7,8 +7,8 @@ import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.groups.GroupManager
|
||||
import org.thoughtcrime.securesms.util.GroupUtil
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.session.libsession.utilities.GroupUtil
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.service.loki.api.opengroups.PublicChat
|
||||
import java.lang.Exception
|
||||
import java.lang.IllegalStateException
|
||||
@ -62,7 +62,7 @@ object OpenGroupUtilities {
|
||||
?: throw IllegalStateException("Public chat API is not initialized!")
|
||||
|
||||
// Check if open group has a related DB record.
|
||||
val groupId = GroupUtil.getEncodedOpenGroupId(PublicChat.getId(channel, url).toByteArray())
|
||||
val groupId = GroupUtil.getEncodedOpenGroupID(PublicChat.getId(channel, url))
|
||||
if (!DatabaseFactory.getGroupDatabase(context).hasGroup(groupId)) {
|
||||
throw IllegalStateException("Attempt to update open group info for non-existent DB record: $groupId")
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.loki.utilities.AvatarPlaceholderGenerator
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.service.loki.protocol.mentions.MentionsManager
|
||||
|
||||
// TODO: Look into a better way of handling different sizes. Maybe an enum (with associated values) encapsulating the different modes?
|
||||
@ -80,7 +80,7 @@ class ProfilePictureView : RelativeLayout {
|
||||
}
|
||||
val randomUsers = users.sorted().toMutableList() // Sort to provide a level of stability
|
||||
if (users.count() == 1) {
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
||||
randomUsers.add(0, userPublicKey) // Ensure the current user is at the back visually
|
||||
}
|
||||
val pk = randomUsers.getOrNull(0) ?: ""
|
||||
|
@ -14,8 +14,8 @@ import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.mms.TextSlide;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
|
||||
import org.session.libsession.utilities.Util;
|
||||
import org.session.libsession.utilities.concurrent.SignalExecutors;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -40,7 +40,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.Stopwatch;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
|
@ -27,10 +27,10 @@ import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
|
||||
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.utilities.concurrent.SimpleTask;
|
||||
import org.session.libsession.utilities.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -11,11 +11,11 @@ import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
import org.session.libsession.utilities.preferences.NotificationPrivacyPreference;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient.*;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.Util;
|
||||
|
||||
public abstract class AbstractNotificationBuilder extends NotificationCompat.Builder {
|
||||
|
||||
|
@ -62,7 +62,7 @@ import org.thoughtcrime.securesms.service.IncomingMessageObserver;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.SpanUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsignal.service.internal.util.Util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -7,7 +7,7 @@ import android.graphics.BitmapFactory;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
import org.session.libsession.utilities.preferences.NotificationPrivacyPreference;
|
||||
|
||||
public class FailedNotificationBuilder extends AbstractNotificationBuilder {
|
||||
|
||||
|
@ -11,10 +11,10 @@ import android.text.SpannableStringBuilder;
|
||||
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.utilities.NotificationUtilities;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
import org.session.libsession.utilities.preferences.NotificationPrivacyPreference;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.Util;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -28,7 +28,7 @@ import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient.*;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsignal.libsignal.logging.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -8,8 +8,8 @@ import androidx.core.app.NotificationCompat;
|
||||
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.preferences.NotificationPrivacyPreference;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
|
@ -35,11 +35,11 @@ import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
import org.session.libsession.utilities.preferences.NotificationPrivacyPreference;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.Util;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.ProgressPreference;
|
||||
import org.thoughtcrime.securesms.util.BackupDirSelector;
|
||||
import org.thoughtcrime.securesms.util.BackupUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Trimmer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -17,7 +17,7 @@ import android.text.TextUtils;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
|
@ -64,9 +64,9 @@ public class UnknownSenderView extends FrameLayout {
|
||||
private void handleProfileAccess() {
|
||||
final Context context = getContext();
|
||||
|
||||
new AlertDialog.Builder(getContext())
|
||||
new AlertDialog.Builder(context)
|
||||
.setIconAttribute(R.attr.dialog_info_icon)
|
||||
.setTitle(getContext().getString(R.string.UnknownSenderView_share_profile_with_s, recipient.toShortString()))
|
||||
.setTitle(context.getString(R.string.UnknownSenderView_share_profile_with_s, recipient.toShortString()))
|
||||
.setMessage(R.string.UnknownSenderView_the_easiest_way_to_share_your_profile_information_is_to_add_the_sender_to_your_contacts)
|
||||
.setPositiveButton(R.string.UnknownSenderView_share_profile, (dialog, which) -> {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
@ -4,7 +4,7 @@ package org.thoughtcrime.securesms.push;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsignal.service.api.push.TrustStore;
|
||||
import org.session.libsignal.service.internal.configuration.SignalCdnUrl;
|
||||
import org.session.libsignal.service.internal.configuration.SignalContactDiscoveryUrl;
|
||||
|
@ -24,7 +24,7 @@ import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.PushMediaConstraints;
|
||||
import org.thoughtcrime.securesms.scribbles.widget.VerticalSlideColorPicker;
|
||||
import org.thoughtcrime.securesms.util.ParcelUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
|
@ -21,7 +21,7 @@ import org.thoughtcrime.securesms.jobs.PushContentReceiveJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsignal.libsignal.InvalidVersionException;
|
||||
import org.session.libsignal.service.api.SignalServiceMessagePipe;
|
||||
import org.session.libsignal.service.api.SignalServiceMessageReceiver;
|
||||
|
@ -40,7 +40,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import android.content.Intent;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.jobs.LocalBackupJob;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
/**
|
||||
* Respond to a PanicKit trigger Intent by locking the app. PanicKit provides a
|
||||
|
@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.util.FileProviderUtil;
|
||||
import org.thoughtcrime.securesms.util.FileUtils;
|
||||
import org.thoughtcrime.securesms.util.Hex;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -8,7 +8,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import network.loki.messenger.BuildConfig;
|
||||
import org.thoughtcrime.securesms.jobs.UpdateApkJob;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -18,7 +18,7 @@ package org.thoughtcrime.securesms.service;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -8,7 +8,7 @@ import androidx.annotation.Nullable;
|
||||
import android.telephony.SmsMessage;
|
||||
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.session.libsession.utilities.GroupUtil;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceGroup;
|
||||
import org.session.libsignal.service.api.push.SignalServiceAddress;
|
||||
@ -46,7 +46,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
|
||||
public IncomingTextMessage(@NonNull Context context, @NonNull SmsMessage message, int subscriptionId) {
|
||||
this.message = message.getDisplayMessageBody();
|
||||
this.sender = Address.fromSerialized(message.getDisplayOriginatingAddress());
|
||||
this.sender = Address.Companion.fromSerialized(message.getDisplayOriginatingAddress());
|
||||
this.senderDeviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
||||
this.protocol = message.getProtocolIdentifier();
|
||||
this.serviceCenterAddress = message.getServiceCenterAddress();
|
||||
@ -78,7 +78,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
this.unidentified = unidentified;
|
||||
|
||||
if (group.isPresent()) {
|
||||
this.groupId = Address.fromSerialized(GroupUtil.getEncodedId(group.get()));
|
||||
this.groupId = Address.Companion.fromSerialized(GroupUtil.getEncodedId(group.get()));
|
||||
} else {
|
||||
this.groupId = null;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
import org.session.libsignal.service.api.push.ContactTokenDetails;
|
||||
|
||||
|
@ -14,6 +14,7 @@ import org.session.libsession.messaging.sending_receiving.attachments.Attachment
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.loki.database.BackupFileRecord
|
||||
import org.thoughtcrime.securesms.service.LocalBackupListener
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.libsignal.util.ByteUtil
|
||||
import java.io.IOException
|
||||
import java.security.MessageDigest
|
||||
|
@ -1,38 +1,8 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.hardware.Camera.CameraInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import androidx.annotation.ArrayRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.thoughtcrime.securesms.backup.BackupProtos;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
import org.session.libsignal.libsignal.util.Medium;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
import static org.thoughtcrime.securesms.backup.FullBackupImporter.PREF_PREFIX_TYPE_BOOLEAN;
|
||||
import static org.thoughtcrime.securesms.backup.FullBackupImporter.PREF_PREFIX_TYPE_INT;
|
||||
import org.session.libsession.utilities.preferences.NotificationPrivacyPreference;
|
||||
|
||||
public class TextSecurePreferences {
|
||||
// TODO: Remove this file
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.session.libsession.messaging.threads.recipients;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
@ -28,6 +29,7 @@ import com.annimon.stream.function.Consumer;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.session.libsession.messaging.MessagingConfiguration;
|
||||
import org.session.libsession.messaging.contacts.avatars.TransparentContactPhoto;
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.session.libsession.messaging.threads.GroupRecord;
|
||||
import org.session.libsession.messaging.threads.recipients.RecipientProvider.RecipientDetails;
|
||||
@ -455,6 +457,17 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return (name != null ? name : address.serialize());
|
||||
}
|
||||
|
||||
public synchronized @NonNull Drawable getFallbackContactPhotoDrawable(Context context, boolean inverted) {
|
||||
return (new TransparentContactPhoto()).asDrawable(context, getColor().toAvatarColor(context), inverted);
|
||||
}
|
||||
|
||||
// public synchronized @NonNull FallbackContactPhoto getFallbackContactPhoto() {
|
||||
// // TODO: I believe this is now completely unused
|
||||
// if (isResolving()) return new TransparentContactPhoto();
|
||||
// else if (isGroupRecipient()) return new GeneratedContactPhoto(name, R.drawable.ic_profile_default);
|
||||
// else { return new TransparentContactPhoto(); }
|
||||
// }
|
||||
|
||||
public synchronized @Nullable ContactPhoto getContactPhoto() {
|
||||
if (isLocalNumber) return new ProfileContactPhoto(address, String.valueOf(TextSecurePreferences.getProfileAvatarId(context)));
|
||||
else if (isGroupRecipient() && groupAvatarId != null) return new GroupRecordContactPhoto(address, groupAvatarId);
|
||||
|
@ -7,6 +7,8 @@ import android.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import android.provider.Settings
|
||||
import androidx.annotation.ArrayRes
|
||||
import androidx.core.app.NotificationCompat
|
||||
import org.session.libsession.R
|
||||
import org.session.libsession.utilities.preferences.NotificationPrivacyPreference
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.libsignal.util.Medium
|
||||
import org.session.libsignal.service.internal.util.Base64
|
||||
@ -200,14 +202,17 @@ object TextSecurePreferences {
|
||||
return getBooleanPreference(context, SCREEN_LOCK, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setScreenLockEnabled(context: Context, value: Boolean) {
|
||||
setBooleanPreference(context, SCREEN_LOCK, value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getScreenLockTimeout(context: Context): Long {
|
||||
return getLongPreference(context, SCREEN_LOCK_TIMEOUT, 0)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setScreenLockTimeout(context: Context, value: Long) {
|
||||
setLongPreference(context, SCREEN_LOCK_TIMEOUT, value)
|
||||
}
|
||||
@ -236,14 +241,17 @@ object TextSecurePreferences {
|
||||
setBooleanPreference(context, BACKUP_ENABLED, value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isBackupEnabled(context: Context): Boolean {
|
||||
return getBooleanPreference(context, BACKUP_ENABLED, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setNextBackupTime(context: Context, time: Long) {
|
||||
setLongPreference(context, BACKUP_TIME, time)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getNextBackupTime(context: Context): Long {
|
||||
return getLongPreference(context, BACKUP_TIME, -1)
|
||||
}
|
||||
@ -377,6 +385,7 @@ object TextSecurePreferences {
|
||||
return getBooleanPreference(context, LINK_PREVIEWS, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setLinkPreviewsEnabled(context: Context, enabled: Boolean) {
|
||||
setBooleanPreference(context, LINK_PREVIEWS, enabled)
|
||||
}
|
||||
@ -430,6 +439,7 @@ object TextSecurePreferences {
|
||||
return getStringPreference(context, PROFILE_AVATAR_URL_PREF, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getNotificationPriority(context: Context): Int {
|
||||
return getStringPreference(context, NOTIFICATION_PRIORITY_PREF, NotificationCompat.PRIORITY_HIGH.toString())!!.toInt()
|
||||
}
|
||||
@ -487,10 +497,10 @@ object TextSecurePreferences {
|
||||
return getIntegerPreference(context, SIGNED_PREKEY_FAILURE_COUNT_PREF, 0)
|
||||
}
|
||||
|
||||
// TODO
|
||||
// fun getNotificationPrivacy(context: Context): NotificationPrivacyPreference {
|
||||
// return NotificationPrivacyPreference(getStringPreference(context, NOTIFICATION_PRIVACY_PREF, "all"))
|
||||
// }
|
||||
@JvmStatic
|
||||
fun getNotificationPrivacy(context: Context): NotificationPrivacyPreference {
|
||||
return NotificationPrivacyPreference(getStringPreference(context, NOTIFICATION_PRIVACY_PREF, "all"))
|
||||
}
|
||||
|
||||
fun isNewContactsNotificationEnabled(context: Context): Boolean {
|
||||
return getBooleanPreference(context, NEW_CONTACTS_NOTIFICATIONS, true)
|
||||
@ -512,6 +522,7 @@ object TextSecurePreferences {
|
||||
setBooleanPreference(context, RATING_ENABLED_PREF, enabled)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isWebsocketRegistered(context: Context): Boolean {
|
||||
return getBooleanPreference(context, WEBSOCKET_REGISTERED_PREF, false)
|
||||
}
|
||||
@ -525,6 +536,7 @@ object TextSecurePreferences {
|
||||
return getBooleanPreference(context, WIFI_SMS_PREF, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getRepeatAlertsCount(context: Context): Int {
|
||||
return try {
|
||||
getStringPreference(context, REPEAT_ALERTS_PREF, "0")!!.toInt()
|
||||
@ -558,6 +570,7 @@ object TextSecurePreferences {
|
||||
removePreference(context, LOCAL_REGISTRATION_ID_PREF)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isInThreadNotifications(context: Context): Boolean {
|
||||
return getBooleanPreference(context, IN_THREAD_NOTIFICATION_PREF, true)
|
||||
}
|
||||
@ -622,10 +635,12 @@ object TextSecurePreferences {
|
||||
setLongPreference(context, DIRECTORY_FRESH_TIME_PREF, value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getUpdateApkRefreshTime(context: Context): Long {
|
||||
return getLongPreference(context, UPDATE_APK_REFRESH_TIME_PREF, 0L)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setUpdateApkRefreshTime(context: Context, value: Long) {
|
||||
setLongPreference(context, UPDATE_APK_REFRESH_TIME_PREF, value)
|
||||
}
|
||||
@ -686,6 +701,7 @@ object TextSecurePreferences {
|
||||
return getBooleanPreference(context, ENTER_SENDS_PREF, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isPasswordDisabled(context: Context): Boolean {
|
||||
return getBooleanPreference(context, DISABLE_PASSPHRASE_PREF, false)
|
||||
}
|
||||
@ -847,6 +863,7 @@ object TextSecurePreferences {
|
||||
return getStringPreference(context, THEME_PREF, "light")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isVerifying(context: Context): Boolean {
|
||||
return getBooleanPreference(context, VERIFYING_STATE_PREF, false)
|
||||
}
|
||||
@ -869,10 +886,12 @@ object TextSecurePreferences {
|
||||
return getBooleanPreference(context, SHOW_INVITE_REMINDER_PREF, true)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isPassphraseTimeoutEnabled(context: Context): Boolean {
|
||||
return getBooleanPreference(context, PASSPHRASE_TIMEOUT_PREF, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPassphraseTimeoutInterval(context: Context): Int {
|
||||
return getIntegerPreference(context, PASSPHRASE_TIMEOUT_INTERVAL_PREF, 5 * 60)
|
||||
}
|
||||
@ -944,10 +963,12 @@ object TextSecurePreferences {
|
||||
return getBooleanPreference(context, ALL_SMS_PREF, true)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isNotificationsEnabled(context: Context): Boolean {
|
||||
return getBooleanPreference(context, NOTIFICATION_PREF, true)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getNotificationRingtone(context: Context): Uri {
|
||||
var result = getStringPreference(context, RINGTONE_PREF, Settings.System.DEFAULT_NOTIFICATION_URI.toString())
|
||||
if (result != null && result.startsWith("file:")) {
|
||||
@ -956,30 +977,37 @@ object TextSecurePreferences {
|
||||
return Uri.parse(result)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun removeNotificationRingtone(context: Context) {
|
||||
removePreference(context, RINGTONE_PREF)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setNotificationRingtone(context: Context, ringtone: String?) {
|
||||
setStringPreference(context, RINGTONE_PREF, ringtone)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setNotificationVibrateEnabled(context: Context, enabled: Boolean) {
|
||||
setBooleanPreference(context, VIBRATE_PREF, enabled)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isNotificationVibrateEnabled(context: Context): Boolean {
|
||||
return getBooleanPreference(context, VIBRATE_PREF, true)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getNotificationLedColor(context: Context): String? {
|
||||
return getStringPreference(context, LED_COLOR_PREF, "blue")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getNotificationLedPattern(context: Context): String? {
|
||||
return getStringPreference(context, LED_BLINK_PREF, "500,2000")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getNotificationLedPatternCustom(context: Context): String? {
|
||||
return getStringPreference(context, LED_BLINK_PREF_CUSTOM, "500,2000")
|
||||
}
|
||||
@ -1003,18 +1031,20 @@ object TextSecurePreferences {
|
||||
return getBooleanPreference(context, SYSTEM_EMOJI_PREF, false)
|
||||
}
|
||||
|
||||
// TODO
|
||||
// fun getMobileMediaDownloadAllowed(context: Context): Set<String> {
|
||||
// return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_MOBILE_PREF, R.array.pref_media_download_mobile_data_default)
|
||||
// }
|
||||
//
|
||||
// fun getWifiMediaDownloadAllowed(context: Context): Set<String> {
|
||||
// return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_WIFI_PREF, R.array.pref_media_download_wifi_default)
|
||||
// }
|
||||
//
|
||||
// fun getRoamingMediaDownloadAllowed(context: Context): Set<String> {
|
||||
// return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_ROAMING_PREF, R.array.pref_media_download_roaming_default)
|
||||
// }
|
||||
@JvmStatic
|
||||
fun getMobileMediaDownloadAllowed(context: Context): Set<String>? {
|
||||
return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_MOBILE_PREF, R.array.pref_media_download_mobile_data_default)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getWifiMediaDownloadAllowed(context: Context): Set<String>? {
|
||||
return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_WIFI_PREF, R.array.pref_media_download_wifi_default)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getRoamingMediaDownloadAllowed(context: Context): Set<String>? {
|
||||
return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_ROAMING_PREF, R.array.pref_media_download_roaming_default)
|
||||
}
|
||||
|
||||
private fun getMediaDownloadAllowed(context: Context, key: String, @ArrayRes defaultValuesRes: Int): Set<String>? {
|
||||
return getStringSetPreference(context, key, HashSet(Arrays.asList(*context.resources.getStringArray(defaultValuesRes))))
|
||||
@ -1056,18 +1086,22 @@ object TextSecurePreferences {
|
||||
return getStringPreference(context, LOG_UNENCRYPTED_SECRET, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getNotificationChannelVersion(context: Context): Int {
|
||||
return getIntegerPreference(context, NOTIFICATION_CHANNEL_VERSION, 1)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setNotificationChannelVersion(context: Context, version: Int) {
|
||||
setIntegerPrefrence(context, NOTIFICATION_CHANNEL_VERSION, version)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getNotificationMessagesChannelVersion(context: Context): Int {
|
||||
return getIntegerPreference(context, NOTIFICATION_MESSAGES_CHANNEL_VERSION, 1)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setNotificationMessagesChannelVersion(context: Context, version: Int) {
|
||||
setIntegerPrefrence(context, NOTIFICATION_MESSAGES_CHANNEL_VERSION, version)
|
||||
}
|
||||
|
@ -4,13 +4,17 @@ import android.annotation.SuppressLint
|
||||
import android.annotation.TargetApi
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.net.Uri
|
||||
import android.os.Build.VERSION
|
||||
import android.os.Build.VERSION_CODES
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Telephony
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.TextUtils
|
||||
import android.text.style.StyleSpan
|
||||
import org.session.libsession.messaging.threads.Address
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import java.io.*
|
||||
@ -314,4 +318,13 @@ object Util {
|
||||
return elements[SecureRandom().nextInt(elements.size)]
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBoldedString(value: String?): CharSequence {
|
||||
val spanned = SpannableString(value)
|
||||
spanned.setSpan(StyleSpan(Typeface.BOLD), 0,
|
||||
spanned.length,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
return spanned
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.preferences.widgets;
|
||||
package org.session.libsession.utilities.preferences;
|
||||
|
||||
public class NotificationPrivacyPreference {
|
||||
|
Loading…
Reference in New Issue
Block a user