diff --git a/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java b/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java index 924fa3452d..27eee0fdc5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java @@ -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); diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/SessionManagementProtocol.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/SessionManagementProtocol.kt index b309014208..2cc64e5eae 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/SessionManagementProtocol.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/SessionManagementProtocol.kt @@ -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 diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt index 94a28e0af8..03eaf970c0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt @@ -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 diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/ContactUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/ContactUtilities.kt index 4aaa05cace..a63360fdaa 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/ContactUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/ContactUtilities.kt @@ -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 { 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 diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MentionManagerUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MentionManagerUtilities.kt index 9176734397..c565c953ad 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MentionManagerUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MentionManagerUtilities.kt @@ -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 } diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MentionUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MentionUtilities.kt index bf32a41183..50b69274da 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MentionUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MentionUtilities.kt @@ -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, 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 @ diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/OpenGroupUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/OpenGroupUtilities.kt index 3fa2f5d5d2..c6a27be6f8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/OpenGroupUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/OpenGroupUtilities.kt @@ -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") } diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt index 3410fbded4..7103c7cc2e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt @@ -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) ?: "" diff --git a/app/src/main/java/org/thoughtcrime/securesms/longmessage/LongMessageRepository.java b/app/src/main/java/org/thoughtcrime/securesms/longmessage/LongMessageRepository.java index 264d1d57c9..a910724c45 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/longmessage/LongMessageRepository.java +++ b/app/src/main/java/org/thoughtcrime/securesms/longmessage/LongMessageRepository.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/mediasend/Camera1Fragment.java b/app/src/main/java/org/thoughtcrime/securesms/mediasend/Camera1Fragment.java index 42285049df..aef0f4ee79 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mediasend/Camera1Fragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mediasend/Camera1Fragment.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java b/app/src/main/java/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java index ae2cc7dcba..ad0aadab24 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java index d5ea663c66..204c489136 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java @@ -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 { diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java index 9495328e31..16398fc258 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/FailedNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/FailedNotificationBuilder.java index fcaf671710..333d00e00a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/FailedNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/FailedNotificationBuilder.java @@ -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 { diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java index e51529c9ef..ef285d1bb7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java index 04bb925339..7c0d43e85e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java index 020d8a4bdf..10d1435c19 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java index 729f3fa851..112a79f10b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java b/app/src/main/java/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java index fbef184b4a..db9484f9b0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/ChatsPreferenceFragment.java b/app/src/main/java/org/thoughtcrime/securesms/preferences/ChatsPreferenceFragment.java index 2af518b460..7e458409ea 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/ChatsPreferenceFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/ChatsPreferenceFragment.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java b/app/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java index 7f1a862b21..c8ab0292b4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/profiles/UnknownSenderView.java b/app/src/main/java/org/thoughtcrime/securesms/profiles/UnknownSenderView.java index ac3c4e7cf1..e69fbd819e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/profiles/UnknownSenderView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/profiles/UnknownSenderView.java @@ -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() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/push/SignalServiceNetworkAccess.java b/app/src/main/java/org/thoughtcrime/securesms/push/SignalServiceNetworkAccess.java index 53fdccee42..126861f8ef 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/push/SignalServiceNetworkAccess.java +++ b/app/src/main/java/org/thoughtcrime/securesms/push/SignalServiceNetworkAccess.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/scribbles/ImageEditorFragment.java b/app/src/main/java/org/thoughtcrime/securesms/scribbles/ImageEditorFragment.java index ef369bbb13..4639540ee4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/scribbles/ImageEditorFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/scribbles/ImageEditorFragment.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/IncomingMessageObserver.java b/app/src/main/java/org/thoughtcrime/securesms/service/IncomingMessageObserver.java index a05faf78ee..4ef12c22f8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/IncomingMessageObserver.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/IncomingMessageObserver.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java b/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java index 0a77f0aa92..f87429ae16 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/LocalBackupListener.java b/app/src/main/java/org/thoughtcrime/securesms/service/LocalBackupListener.java index 57ae5de31e..e33d9481e3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/LocalBackupListener.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/LocalBackupListener.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/PanicResponderListener.java b/app/src/main/java/org/thoughtcrime/securesms/service/PanicResponderListener.java index c6cefc6591..a23544d570 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/PanicResponderListener.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/PanicResponderListener.java @@ -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 diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/UpdateApkReadyListener.java b/app/src/main/java/org/thoughtcrime/securesms/service/UpdateApkReadyListener.java index f7401802ad..0fdc198bef 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/UpdateApkReadyListener.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/UpdateApkReadyListener.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/UpdateApkRefreshListener.java b/app/src/main/java/org/thoughtcrime/securesms/service/UpdateApkRefreshListener.java index a9854adbe1..fd99cb637a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/UpdateApkRefreshListener.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/UpdateApkRefreshListener.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/VerificationCodeParser.java b/app/src/main/java/org/thoughtcrime/securesms/service/VerificationCodeParser.java index cbaaa57970..4a7d1038b2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/VerificationCodeParser.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/VerificationCodeParser.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/sms/IncomingTextMessage.java b/app/src/main/java/org/thoughtcrime/securesms/sms/IncomingTextMessage.java index af8c720030..36f01071d9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/sms/IncomingTextMessage.java +++ b/app/src/main/java/org/thoughtcrime/securesms/sms/IncomingTextMessage.java @@ -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; } diff --git a/app/src/main/java/org/thoughtcrime/securesms/sms/MessageSender.java b/app/src/main/java/org/thoughtcrime/securesms/sms/MessageSender.java index e57ddaf03a..e439c9e0c3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/sms/MessageSender.java +++ b/app/src/main/java/org/thoughtcrime/securesms/sms/MessageSender.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/AttachmentUtil.java b/app/src/main/java/org/thoughtcrime/securesms/util/AttachmentUtil.java index 0dd266343a..e85da48250 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/AttachmentUtil.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/AttachmentUtil.java @@ -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; diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/BackupUtil.kt b/app/src/main/java/org/thoughtcrime/securesms/util/BackupUtil.kt index 7eb204d8f3..ef61c59988 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/BackupUtil.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/BackupUtil.kt @@ -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 diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/TextSecurePreferences.java b/app/src/main/java/org/thoughtcrime/securesms/util/TextSecurePreferences.java index ce8c0541a5..f028c0f789 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/TextSecurePreferences.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/TextSecurePreferences.java @@ -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 diff --git a/libsession/src/main/java/org/session/libsession/messaging/threads/recipients/Recipient.java b/libsession/src/main/java/org/session/libsession/messaging/threads/recipients/Recipient.java index 332bfa09d6..ef3532ac18 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/threads/recipients/Recipient.java +++ b/libsession/src/main/java/org/session/libsession/messaging/threads/recipients/Recipient.java @@ -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); diff --git a/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt b/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt index 0656554fbb..1fa2a94168 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt @@ -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 { -// return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_MOBILE_PREF, R.array.pref_media_download_mobile_data_default) -// } -// -// fun getWifiMediaDownloadAllowed(context: Context): Set { -// return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_WIFI_PREF, R.array.pref_media_download_wifi_default) -// } -// -// fun getRoamingMediaDownloadAllowed(context: Context): Set { -// return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_ROAMING_PREF, R.array.pref_media_download_roaming_default) -// } + @JvmStatic + fun getMobileMediaDownloadAllowed(context: Context): Set? { + return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_MOBILE_PREF, R.array.pref_media_download_mobile_data_default) + } + + @JvmStatic + fun getWifiMediaDownloadAllowed(context: Context): Set? { + return getMediaDownloadAllowed(context, MEDIA_DOWNLOAD_WIFI_PREF, R.array.pref_media_download_wifi_default) + } + + @JvmStatic + fun getRoamingMediaDownloadAllowed(context: Context): Set? { + 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? { 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) } diff --git a/libsession/src/main/java/org/session/libsession/utilities/Util.kt b/libsession/src/main/java/org/session/libsession/utilities/Util.kt index 50feeb5319..1198be3822 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/Util.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/Util.kt @@ -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 + } + } \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/widgets/NotificationPrivacyPreference.java b/libsession/src/main/java/org/session/libsession/utilities/preferences/NotificationPrivacyPreference.java similarity index 87% rename from app/src/main/java/org/thoughtcrime/securesms/preferences/widgets/NotificationPrivacyPreference.java rename to libsession/src/main/java/org/session/libsession/utilities/preferences/NotificationPrivacyPreference.java index 251af9b93b..66352ae083 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/widgets/NotificationPrivacyPreference.java +++ b/libsession/src/main/java/org/session/libsession/utilities/preferences/NotificationPrivacyPreference.java @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.preferences.widgets; +package org.session.libsession.utilities.preferences; public class NotificationPrivacyPreference {