mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
Remove static preferences methods
This commit is contained in:
parent
5855bcd17f
commit
f23a0fb5d8
@ -100,7 +100,7 @@ class HomeActivityTests {
|
|||||||
// PN select
|
// PN select
|
||||||
if (hasViewedSeed) {
|
if (hasViewedSeed) {
|
||||||
// has viewed seed is set to false after register activity
|
// has viewed seed is set to false after register activity
|
||||||
TextSecurePreferences.setHasViewedSeed(InstrumentationRegistry.getInstrumentation().targetContext, true)
|
context.prefs.setHasViewedSeed(InstrumentationRegistry.getInstrumentation().targetContext, true)
|
||||||
}
|
}
|
||||||
// allow notification permission
|
// allow notification permission
|
||||||
PermissionGranter.allowPermissionsIfNeeded(Manifest.permission.POST_NOTIFICATIONS)
|
PermissionGranter.allowPermissionsIfNeeded(Manifest.permission.POST_NOTIFICATIONS)
|
||||||
@ -149,7 +149,7 @@ class HomeActivityTests {
|
|||||||
fun testChat_withSelf() {
|
fun testChat_withSelf() {
|
||||||
setupLoggedInState()
|
setupLoggedInState()
|
||||||
goToMyChat()
|
goToMyChat()
|
||||||
TextSecurePreferences.setLinkPreviewsEnabled(context, true)
|
context.prefs.setLinkPreviewsEnabled(context, true)
|
||||||
sendMessage("howdy")
|
sendMessage("howdy")
|
||||||
sendMessage("test")
|
sendMessage("test")
|
||||||
// tests url rewriter doesn't crash
|
// tests url rewriter doesn't crash
|
||||||
@ -161,7 +161,7 @@ class HomeActivityTests {
|
|||||||
fun testChat_displaysCorrectUrl() {
|
fun testChat_displaysCorrectUrl() {
|
||||||
setupLoggedInState()
|
setupLoggedInState()
|
||||||
goToMyChat()
|
goToMyChat()
|
||||||
TextSecurePreferences.setLinkPreviewsEnabled(InstrumentationRegistry.getInstrumentation().targetContext, true)
|
context.prefs.setLinkPreviewsEnabled(InstrumentationRegistry.getInstrumentation().targetContext, true)
|
||||||
// given the link url text
|
// given the link url text
|
||||||
val url = "https://www.ámazon.com"
|
val url = "https://www.ámazon.com"
|
||||||
sendMessage(url, LinkPreview(url, "amazon", Optional.absent()))
|
sendMessage(url, LinkPreview(url, "amazon", Optional.absent()))
|
||||||
|
@ -90,10 +90,10 @@ class LibSessionTests {
|
|||||||
val kp = KeyPairUtilities.generate(newBytes)
|
val kp = KeyPairUtilities.generate(newBytes)
|
||||||
KeyPairUtilities.store(context, kp.seed, kp.ed25519KeyPair, kp.x25519KeyPair)
|
KeyPairUtilities.store(context, kp.seed, kp.ed25519KeyPair, kp.x25519KeyPair)
|
||||||
val registrationID = KeyHelper.generateRegistrationId(false)
|
val registrationID = KeyHelper.generateRegistrationId(false)
|
||||||
TextSecurePreferences.setLocalRegistrationId(context, registrationID)
|
context.prefs.setLocalRegistrationId(context, registrationID)
|
||||||
TextSecurePreferences.setLocalNumber(context, kp.x25519KeyPair.hexEncodedPublicKey)
|
context.prefs.setLocalNumber(context, kp.x25519KeyPair.hexEncodedPublicKey)
|
||||||
TextSecurePreferences.setRestorationTime(context, 0)
|
context.prefs.setRestorationTime(context, 0)
|
||||||
TextSecurePreferences.setHasViewedSeed(context, false)
|
context.prefs.setHasViewedSeed(context, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -110,7 +110,6 @@ import javax.inject.Inject;
|
|||||||
import dagger.hilt.EntryPoints;
|
import dagger.hilt.EntryPoints;
|
||||||
import dagger.hilt.android.HiltAndroidApp;
|
import dagger.hilt.android.HiltAndroidApp;
|
||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
import kotlinx.coroutines.Job;
|
|
||||||
import network.loki.messenger.BuildConfig;
|
import network.loki.messenger.BuildConfig;
|
||||||
import network.loki.messenger.libsession_util.ConfigBase;
|
import network.loki.messenger.libsession_util.ConfigBase;
|
||||||
import network.loki.messenger.libsession_util.UserProfile;
|
import network.loki.messenger.libsession_util.UserProfile;
|
||||||
@ -152,20 +151,11 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
|||||||
@Inject ConfigFactory configFactory;
|
@Inject ConfigFactory configFactory;
|
||||||
@Inject LastSentTimestampCache lastSentTimestampCache;
|
@Inject LastSentTimestampCache lastSentTimestampCache;
|
||||||
CallMessageProcessor callMessageProcessor;
|
CallMessageProcessor callMessageProcessor;
|
||||||
MessagingModuleConfiguration messagingModuleConfiguration;
|
|
||||||
|
|
||||||
private volatile boolean isAppVisible;
|
private volatile boolean isAppVisible;
|
||||||
|
|
||||||
public boolean newAccount = false;
|
public boolean newAccount = false;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getSystemService(String name) {
|
|
||||||
if (MessagingModuleConfiguration.MESSAGING_MODULE_SERVICE.equals(name)) {
|
|
||||||
return messagingModuleConfiguration;
|
|
||||||
}
|
|
||||||
return super.getSystemService(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ApplicationContext getInstance(Context context) {
|
public static ApplicationContext getInstance(Context context) {
|
||||||
return (ApplicationContext) context.getApplicationContext();
|
return (ApplicationContext) context.getApplicationContext();
|
||||||
}
|
}
|
||||||
@ -214,9 +204,8 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
|||||||
TextSecurePreferences.setPushSuffix(BuildConfig.PUSH_KEY_SUFFIX);
|
TextSecurePreferences.setPushSuffix(BuildConfig.PUSH_KEY_SUFFIX);
|
||||||
|
|
||||||
DatabaseModule.init(this);
|
DatabaseModule.init(this);
|
||||||
MessagingModuleConfiguration.configure(this);
|
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
messagingModuleConfiguration = new MessagingModuleConfiguration(
|
MessagingModuleConfiguration.shared = new MessagingModuleConfiguration(
|
||||||
this,
|
this,
|
||||||
storage,
|
storage,
|
||||||
device,
|
device,
|
||||||
@ -431,12 +420,12 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
|||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context base) {
|
protected void attachBaseContext(Context base) {
|
||||||
initializeLocaleParser();
|
initializeLocaleParser();
|
||||||
super.attachBaseContext(DynamicLanguageContextWrapper.updateContext(base, TextSecurePreferences.getLanguage(base)));
|
super.attachBaseContext(DynamicLanguageContextWrapper.updateContext(base, new TextSecurePreferences(base).getLanguage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ProviderInitializationException extends RuntimeException { }
|
private static class ProviderInitializationException extends RuntimeException { }
|
||||||
private void setUpPollingIfNeeded() {
|
private void setUpPollingIfNeeded() {
|
||||||
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
|
String userPublicKey = textSecurePreferences.getLocalNumber();
|
||||||
if (userPublicKey == null) return;
|
if (userPublicKey == null) return;
|
||||||
if (poller != null) {
|
if (poller != null) {
|
||||||
poller.setUserPublicKey(userPublicKey);
|
poller.setUserPublicKey(userPublicKey);
|
||||||
@ -463,15 +452,15 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
|||||||
private void resubmitProfilePictureIfNeeded() {
|
private void resubmitProfilePictureIfNeeded() {
|
||||||
// Files expire on the file server after a while, so we simply re-upload the user's profile picture
|
// Files expire on the file server after a while, so we simply re-upload the user's profile picture
|
||||||
// at a certain interval to ensure it's always available.
|
// at a certain interval to ensure it's always available.
|
||||||
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
|
String userPublicKey = textSecurePreferences.getLocalNumber();
|
||||||
if (userPublicKey == null) return;
|
if (userPublicKey == null) return;
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
long lastProfilePictureUpload = TextSecurePreferences.getLastProfilePictureUpload(this);
|
long lastProfilePictureUpload = textSecurePreferences.getLastProfilePictureUpload();
|
||||||
if (now - lastProfilePictureUpload <= 14 * 24 * 60 * 60 * 1000) return;
|
if (now - lastProfilePictureUpload <= 14 * 24 * 60 * 60 * 1000) return;
|
||||||
ThreadUtils.queue(() -> {
|
ThreadUtils.queue(() -> {
|
||||||
// Don't generate a new profile key here; we do that when the user changes their profile picture
|
// Don't generate a new profile key here; we do that when the user changes their profile picture
|
||||||
Log.d("Loki-Avatar", "Uploading Avatar Started");
|
Log.d("Loki-Avatar", "Uploading Avatar Started");
|
||||||
String encodedProfileKey = TextSecurePreferences.getProfileKey(ApplicationContext.this);
|
String encodedProfileKey = textSecurePreferences.getProfileKey();
|
||||||
try {
|
try {
|
||||||
// Read the file into a byte array
|
// Read the file into a byte array
|
||||||
InputStream inputStream = AvatarHelper.getInputStreamFor(ApplicationContext.this, Address.fromSerialized(userPublicKey));
|
InputStream inputStream = AvatarHelper.getInputStreamFor(ApplicationContext.this, Address.fromSerialized(userPublicKey));
|
||||||
@ -486,7 +475,7 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
|||||||
// Re-upload it
|
// Re-upload it
|
||||||
ProfilePictureUtilities.INSTANCE.upload(profilePicture, encodedProfileKey, ApplicationContext.this).success(unit -> {
|
ProfilePictureUtilities.INSTANCE.upload(profilePicture, encodedProfileKey, ApplicationContext.this).success(unit -> {
|
||||||
// Update the last profile picture upload date
|
// Update the last profile picture upload date
|
||||||
TextSecurePreferences.setLastProfilePictureUpload(ApplicationContext.this, new Date().getTime());
|
textSecurePreferences.setLastProfilePictureUpload(new Date().getTime());
|
||||||
Log.d("Loki-Avatar", "Uploading Avatar Finished");
|
Log.d("Loki-Avatar", "Uploading Avatar Finished");
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
});
|
});
|
||||||
@ -518,7 +507,7 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
|||||||
*/
|
*/
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
public boolean clearAllData() {
|
public boolean clearAllData() {
|
||||||
TextSecurePreferences.clearAll(this);
|
getPrefs().clearAll();
|
||||||
getSharedPreferences(PREFERENCES_NAME, 0).edit().clear().commit();
|
getSharedPreferences(PREFERENCES_NAME, 0).edit().clear().commit();
|
||||||
if (!deleteDatabase(SQLCipherOpenHelper.DATABASE_NAME)) {
|
if (!deleteDatabase(SQLCipherOpenHelper.DATABASE_NAME)) {
|
||||||
Log.d("Loki", "Failed to delete database.");
|
Log.d("Loki", "Failed to delete database.");
|
||||||
|
@ -16,6 +16,7 @@ import androidx.annotation.StyleRes;
|
|||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageActivityHelper;
|
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageActivityHelper;
|
||||||
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper;
|
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper;
|
||||||
@ -97,7 +98,7 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
initializeScreenshotSecurity(true);
|
initializeScreenshotSecurity(true);
|
||||||
DynamicLanguageActivityHelper.recreateIfNotInCorrectLanguage(this, TextSecurePreferences.getLanguage(this));
|
DynamicLanguageActivityHelper.recreateIfNotInCorrectLanguage(this, MessagingModuleConfiguration.getShared().getPrefs().getLanguage());
|
||||||
String name = getResources().getString(R.string.app_name);
|
String name = getResources().getString(R.string.app_name);
|
||||||
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_foreground);
|
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_foreground);
|
||||||
int color = getResources().getColor(R.color.app_icon_background);
|
int color = getResources().getColor(R.color.app_icon_background);
|
||||||
@ -130,7 +131,7 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
|
|||||||
if (!isResume) {
|
if (!isResume) {
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
} else {
|
} else {
|
||||||
if (TextSecurePreferences.isScreenSecurityEnabled(this)) {
|
if (MessagingModuleConfiguration.getShared().getPrefs().isScreenSecurityEnabled()) {
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
} else {
|
} else {
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
@ -140,6 +141,6 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context newBase) {
|
protected void attachBaseContext(Context newBase) {
|
||||||
super.attachBaseContext(DynamicLanguageContextWrapper.updateContext(newBase, TextSecurePreferences.getLanguage(newBase)));
|
super.attachBaseContext(DynamicLanguageContextWrapper.updateContext(newBase, MessagingModuleConfiguration.getShared().getPrefs().getLanguage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,10 @@ import android.app.ActivityManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Build.VERSION;
|
|
||||||
import android.os.Build.VERSION_CODES;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageActivityHelper;
|
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageActivityHelper;
|
||||||
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper;
|
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper;
|
||||||
@ -21,7 +18,7 @@ public abstract class BaseActivity extends FragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
DynamicLanguageActivityHelper.recreateIfNotInCorrectLanguage(this, TextSecurePreferences.getLanguage(this));
|
DynamicLanguageActivityHelper.recreateIfNotInCorrectLanguage(this, MessagingModuleConfiguration.getShared().getPrefs().getLanguage());
|
||||||
String name = getResources().getString(R.string.app_name);
|
String name = getResources().getString(R.string.app_name);
|
||||||
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_foreground);
|
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_foreground);
|
||||||
int color = getResources().getColor(R.color.app_icon_background);
|
int color = getResources().getColor(R.color.app_icon_background);
|
||||||
@ -30,6 +27,6 @@ public abstract class BaseActivity extends FragmentActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context newBase) {
|
protected void attachBaseContext(Context newBase) {
|
||||||
super.attachBaseContext(DynamicLanguageContextWrapper.updateContext(newBase, TextSecurePreferences.getLanguage(newBase)));
|
super.attachBaseContext(DynamicLanguageContextWrapper.updateContext(newBase, MessagingModuleConfiguration.getShared().getPrefs().getLanguage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,13 @@ import android.widget.ImageView;
|
|||||||
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
|
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
|
||||||
import androidx.core.os.CancellationSignal;
|
import androidx.core.os.CancellationSignal;
|
||||||
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import org.thoughtcrime.securesms.components.AnimatingToggle;
|
import org.thoughtcrime.securesms.components.AnimatingToggle;
|
||||||
import org.thoughtcrime.securesms.crypto.BiometricSecretProvider;
|
import org.thoughtcrime.securesms.crypto.BiometricSecretProvider;
|
||||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||||
import org.thoughtcrime.securesms.util.AnimationCompleteListener;
|
import org.thoughtcrime.securesms.util.AnimationCompleteListener;
|
||||||
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
import java.security.Signature;
|
import java.security.Signature;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
@ -103,7 +102,7 @@ public class PassphrasePromptActivity extends BaseActionBarActivity {
|
|||||||
|
|
||||||
setLockTypeVisibility();
|
setLockTypeVisibility();
|
||||||
|
|
||||||
if (TextSecurePreferences.isScreenLockEnabled(this) && !authenticated && !failure) {
|
if (MessagingModuleConfiguration.getShared().getPrefs().isScreenLockEnabled() && !authenticated && !failure) {
|
||||||
resumeScreenLock();
|
resumeScreenLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +113,7 @@ public class PassphrasePromptActivity extends BaseActionBarActivity {
|
|||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (TextSecurePreferences.isScreenLockEnabled(this)) {
|
if (MessagingModuleConfiguration.getShared().getPrefs().isScreenLockEnabled()) {
|
||||||
pauseScreenLock();
|
pauseScreenLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,7 +175,7 @@ public class PassphrasePromptActivity extends BaseActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setLockTypeVisibility() {
|
private void setLockTypeVisibility() {
|
||||||
if (TextSecurePreferences.isScreenLockEnabled(this)) {
|
if (MessagingModuleConfiguration.getShared().getPrefs().isScreenLockEnabled()) {
|
||||||
if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
|
if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
|
||||||
fingerprintPrompt.setVisibility(View.VISIBLE);
|
fingerprintPrompt.setVisibility(View.VISIBLE);
|
||||||
lockScreenButton.setVisibility(View.GONE);
|
lockScreenButton.setVisibility(View.GONE);
|
||||||
@ -197,8 +196,8 @@ public class PassphrasePromptActivity extends BaseActionBarActivity {
|
|||||||
|
|
||||||
if (!keyguardManager.isKeyguardSecure()) {
|
if (!keyguardManager.isKeyguardSecure()) {
|
||||||
Log.w(TAG ,"Keyguard not secure...");
|
Log.w(TAG ,"Keyguard not secure...");
|
||||||
TextSecurePreferences.setScreenLockEnabled(getApplicationContext(), false);
|
MessagingModuleConfiguration.getShared().getPrefs().setScreenLockEnabled(false);
|
||||||
TextSecurePreferences.setScreenLockTimeout(getApplicationContext(), 0);
|
MessagingModuleConfiguration.getShared().getPrefs().setScreenLockTimeout(0);
|
||||||
handleAuthenticated();
|
handleAuthenticated();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import org.thoughtcrime.securesms.home.HomeActivity;
|
import org.thoughtcrime.securesms.home.HomeActivity;
|
||||||
import org.thoughtcrime.securesms.onboarding.landing.LandingActivity;
|
import org.thoughtcrime.securesms.onboarding.landing.LandingActivity;
|
||||||
@ -39,8 +39,8 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
|||||||
onPreCreate();
|
onPreCreate();
|
||||||
|
|
||||||
final boolean locked = KeyCachingService.isLocked(this) &&
|
final boolean locked = KeyCachingService.isLocked(this) &&
|
||||||
TextSecurePreferences.isScreenLockEnabled(this) &&
|
MessagingModuleConfiguration.getShared().getPrefs().isScreenLockEnabled() &&
|
||||||
TextSecurePreferences.getLocalNumber(this) != null;
|
MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber() != null;
|
||||||
routeApplicationState(locked);
|
routeApplicationState(locked);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -125,7 +125,7 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getApplicationState(boolean locked) {
|
private int getApplicationState(boolean locked) {
|
||||||
if (TextSecurePreferences.getLocalNumber(this) == null) {
|
if (MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber() == null) {
|
||||||
return STATE_WELCOME_SCREEN;
|
return STATE_WELCOME_SCREEN;
|
||||||
} else if (locked) {
|
} else if (locked) {
|
||||||
return STATE_PROMPT_PASSPHRASE;
|
return STATE_PROMPT_PASSPHRASE;
|
||||||
|
@ -22,6 +22,7 @@ import androidx.core.view.inputmethod.EditorInfoCompat;
|
|||||||
import androidx.core.view.inputmethod.InputConnectionCompat;
|
import androidx.core.view.inputmethod.InputConnectionCompat;
|
||||||
import androidx.core.view.inputmethod.InputContentInfoCompat;
|
import androidx.core.view.inputmethod.InputContentInfoCompat;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
@ -108,8 +109,8 @@ public class ComposeText extends EmojiEditText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setTransport() {
|
public void setTransport() {
|
||||||
final boolean useSystemEmoji = TextSecurePreferences.isSystemEmojiPreferred(getContext());
|
final boolean useSystemEmoji = MessagingModuleConfiguration.getShared().getPrefs().isSystemEmojiPreferred();
|
||||||
final boolean isIncognito = TextSecurePreferences.isIncognitoKeyboardEnabled(getContext());
|
final boolean isIncognito = MessagingModuleConfiguration.getShared().getPrefs().isIncognitoKeyboardEnabled();
|
||||||
|
|
||||||
int imeOptions = (getImeOptions() & ~EditorInfo.IME_MASK_ACTION) | EditorInfo.IME_ACTION_SEND;
|
int imeOptions = (getImeOptions() & ~EditorInfo.IME_MASK_ACTION) | EditorInfo.IME_ACTION_SEND;
|
||||||
int inputType = getInputType();
|
int inputType = getInputType();
|
||||||
@ -132,7 +133,7 @@ public class ComposeText extends EmojiEditText {
|
|||||||
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
|
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
|
||||||
InputConnection inputConnection = super.onCreateInputConnection(editorInfo);
|
InputConnection inputConnection = super.onCreateInputConnection(editorInfo);
|
||||||
|
|
||||||
if(TextSecurePreferences.isEnterSendsEnabled(getContext())) {
|
if(MessagingModuleConfiguration.getShared().getPrefs().isEnterSendsEnabled()) {
|
||||||
editorInfo.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
|
editorInfo.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +150,7 @@ public class ComposeText extends EmojiEditText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
if (TextSecurePreferences.isIncognitoKeyboardEnabled(getContext())) {
|
if (MessagingModuleConfiguration.getShared().getPrefs().isIncognitoKeyboardEnabled()) {
|
||||||
setImeOptions(getImeOptions() | 16777216);
|
setImeOptions(getImeOptions() | 16777216);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import android.text.Editable;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@ -84,19 +86,19 @@ public class CustomDefaultPreference extends DialogPreference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCustom() {
|
private boolean isCustom() {
|
||||||
return TextSecurePreferences.getBooleanPreference(getContext(), customToggle, false);
|
return MessagingModuleConfiguration.getShared().getPrefs().getBooleanPreference(customToggle, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCustom(boolean custom) {
|
private void setCustom(boolean custom) {
|
||||||
TextSecurePreferences.setBooleanPreference(getContext(), customToggle, custom);
|
MessagingModuleConfiguration.getShared().getPrefs().setBooleanPreference(customToggle, custom);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCustomValue() {
|
private String getCustomValue() {
|
||||||
return TextSecurePreferences.getStringPreference(getContext(), customPreference, "");
|
return MessagingModuleConfiguration.getShared().getPrefs().getStringPreference(customPreference, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCustomValue(String value) {
|
private void setCustomValue(String value) {
|
||||||
TextSecurePreferences.setStringPreference(getContext(), customPreference, value);
|
MessagingModuleConfiguration.getShared().getPrefs().setStringPreference(customPreference, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDefaultValue() {
|
private String getDefaultValue() {
|
||||||
|
@ -32,6 +32,8 @@ import android.os.Build.VERSION;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import android.view.OrientationEventListener;
|
import android.view.OrientationEventListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -81,7 +83,7 @@ public class CameraView extends ViewGroup {
|
|||||||
int camera = typedArray.getInt(R.styleable.CameraView_camera, -1);
|
int camera = typedArray.getInt(R.styleable.CameraView_camera, -1);
|
||||||
|
|
||||||
if (camera != -1) cameraId = camera;
|
if (camera != -1) cameraId = camera;
|
||||||
else if (isMultiCamera()) cameraId = TextSecurePreferences.getDirectCaptureCameraId(context);
|
else if (isMultiCamera()) cameraId = MessagingModuleConfiguration.getShared().getPrefs().getDirectCaptureCameraId();
|
||||||
|
|
||||||
typedArray.recycle();
|
typedArray.recycle();
|
||||||
}
|
}
|
||||||
@ -266,7 +268,7 @@ public class CameraView extends ViewGroup {
|
|||||||
: CameraInfo.CAMERA_FACING_BACK;
|
: CameraInfo.CAMERA_FACING_BACK;
|
||||||
onPause();
|
onPause();
|
||||||
onResume();
|
onResume();
|
||||||
TextSecurePreferences.setDirectCaptureCameraId(getContext(), cameraId);
|
MessagingModuleConfiguration.getShared().getPrefs().setDirectCaptureCameraId(cameraId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.components.emoji;
|
package org.thoughtcrime.securesms.components.emoji;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -12,9 +11,10 @@ import android.text.TextUtils;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiProvider.EmojiDrawable;
|
import org.thoughtcrime.securesms.components.emoji.EmojiProvider.EmojiDrawable;
|
||||||
import org.thoughtcrime.securesms.components.emoji.parsing.EmojiParser;
|
import org.thoughtcrime.securesms.components.emoji.parsing.EmojiParser;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
|
||||||
import org.session.libsession.utilities.Util;
|
import org.session.libsession.utilities.Util;
|
||||||
import org.session.libsignal.utilities.guava.Optional;
|
import org.session.libsignal.utilities.guava.Optional;
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public class EmojiTextView extends AppCompatTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean useSystemEmoji() {
|
private boolean useSystemEmoji() {
|
||||||
return TextSecurePreferences.isSystemEmojiPreferred(getContext());
|
return MessagingModuleConfiguration.getShared().getPrefs().isSystemEmojiPreferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,9 +74,9 @@ public class ContactAccessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if (context.getString(R.string.note_to_self).toLowerCase().contains(constraint.toLowerCase()) &&
|
// if (context.getString(R.string.note_to_self).toLowerCase().contains(constraint.toLowerCase()) &&
|
||||||
// !numberList.contains(TextSecurePreferences.getLocalNumber(context)))
|
// !numberList.contains(MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber(context)))
|
||||||
// {
|
// {
|
||||||
// numberList.add(TextSecurePreferences.getLocalNumber(context));
|
// numberList.add(MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber(context));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return numberList;
|
return numberList;
|
||||||
|
@ -8,7 +8,9 @@ import androidx.compose.runtime.collectAsState
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.conversation.start.StartConversationDelegate
|
import org.thoughtcrime.securesms.conversation.start.StartConversationDelegate
|
||||||
import org.thoughtcrime.securesms.conversation.start.NullStartConversationDelegate
|
import org.thoughtcrime.securesms.conversation.start.NullStartConversationDelegate
|
||||||
import org.thoughtcrime.securesms.ui.createThemedComposeView
|
import org.thoughtcrime.securesms.ui.createThemedComposeView
|
||||||
@ -28,7 +30,7 @@ class StartConversationHomeFragment : Fragment() {
|
|||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View = createThemedComposeView {
|
): View = createThemedComposeView {
|
||||||
StartConversationScreen(
|
StartConversationScreen(
|
||||||
accountId = TextSecurePreferences.getLocalNumber(requireContext())!!,
|
accountId = requireContext().prefs.getLocalNumber()!!,
|
||||||
delegate = delegate.collectAsState().value
|
delegate = delegate.collectAsState().value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ import android.view.ViewGroup
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.conversation.start.StartConversationDelegate
|
import org.thoughtcrime.securesms.conversation.start.StartConversationDelegate
|
||||||
import org.thoughtcrime.securesms.preferences.copyPublicKey
|
import org.thoughtcrime.securesms.preferences.copyPublicKey
|
||||||
import org.thoughtcrime.securesms.preferences.sendInvitationToUseSession
|
import org.thoughtcrime.securesms.preferences.sendInvitationToUseSession
|
||||||
@ -22,7 +24,7 @@ class InviteFriendFragment : Fragment() {
|
|||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View = createThemedComposeView {
|
): View = createThemedComposeView {
|
||||||
InviteFriend(
|
InviteFriend(
|
||||||
TextSecurePreferences.getLocalNumber(LocalContext.current)!!,
|
requireContext().prefs.getLocalNumber()!!,
|
||||||
onBack = { delegate.onDialogBackPressed() },
|
onBack = { delegate.onDialogBackPressed() },
|
||||||
onClose = { delegate.onDialogClosePressed() },
|
onClose = { delegate.onDialogClosePressed() },
|
||||||
copyPublicKey = requireContext()::copyPublicKey,
|
copyPublicKey = requireContext()::copyPublicKey,
|
||||||
|
@ -30,9 +30,10 @@ import kotlinx.coroutines.flow.filter
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.snode.SnodeAPI
|
import org.session.libsession.snode.SnodeAPI
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.getLocalNumber
|
|
||||||
import org.session.libsession.utilities.ThemeUtil
|
import org.session.libsession.utilities.ThemeUtil
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiImageView
|
import org.thoughtcrime.securesms.components.emoji.EmojiImageView
|
||||||
import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel
|
import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel
|
||||||
import org.thoughtcrime.securesms.components.menu.ActionItem
|
import org.thoughtcrime.securesms.components.menu.ActionItem
|
||||||
@ -514,7 +515,7 @@ class ConversationReactionOverlay : FrameLayout {
|
|||||||
|
|
||||||
private fun getOldEmoji(messageRecord: MessageRecord): String? =
|
private fun getOldEmoji(messageRecord: MessageRecord): String? =
|
||||||
messageRecord.reactions
|
messageRecord.reactions
|
||||||
.filter { it.author == getLocalNumber(context) }
|
.filter { it.author == context.prefs.getLocalNumber() }
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
?.let(ReactionRecord::emoji)
|
?.let(ReactionRecord::emoji)
|
||||||
|
|
||||||
@ -527,7 +528,7 @@ class ConversationReactionOverlay : FrameLayout {
|
|||||||
val openGroup = get(context).lokiThreadDatabase().getOpenGroupChat(message.threadId)
|
val openGroup = get(context).lokiThreadDatabase().getOpenGroupChat(message.threadId)
|
||||||
val recipient = get(context).threadDatabase().getRecipientForThreadId(message.threadId)
|
val recipient = get(context).threadDatabase().getRecipientForThreadId(message.threadId)
|
||||||
?: return emptyList()
|
?: return emptyList()
|
||||||
val userPublicKey = getLocalNumber(context)!!
|
val userPublicKey = context.prefs.getLocalNumber()!!
|
||||||
// Select message
|
// Select message
|
||||||
items += ActionItem(R.attr.menu_select_icon, R.string.conversation_context__menu_select, { handleActionItemClicked(Action.SELECT) }, R.string.AccessibilityId_select)
|
items += ActionItem(R.attr.menu_select_icon, R.string.conversation_context__menu_select, { handleActionItemClicked(Action.SELECT) }, R.string.AccessibilityId_select)
|
||||||
// Reply
|
// Reply
|
||||||
|
@ -4,7 +4,9 @@ import android.app.Dialog
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.createSessionDialog
|
import org.thoughtcrime.securesms.createSessionDialog
|
||||||
|
|
||||||
/** Shown the first time the user inputs a URL that could generate a link preview, to
|
/** Shown the first time the user inputs a URL that could generate a link preview, to
|
||||||
@ -19,7 +21,7 @@ class LinkPreviewDialog(private val onEnabled: () -> Unit) : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun enable() {
|
private fun enable() {
|
||||||
TextSecurePreferences.setLinkPreviewsEnabled(requireContext(), true)
|
requireContext().prefs.setLinkPreviewsEnabled(true)
|
||||||
dismiss()
|
dismiss()
|
||||||
onEnabled()
|
onEnabled()
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,10 @@ import androidx.core.view.isGone
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import network.loki.messenger.databinding.ViewInputBarBinding
|
import network.loki.messenger.databinding.ViewInputBarBinding
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.sending_receiving.link_preview.LinkPreview
|
import org.session.libsession.messaging.sending_receiving.link_preview.LinkPreview
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.conversation.v2.components.LinkPreviewDraftView
|
import org.thoughtcrime.securesms.conversation.v2.components.LinkPreviewDraftView
|
||||||
import org.thoughtcrime.securesms.conversation.v2.components.LinkPreviewDraftViewDelegate
|
import org.thoughtcrime.securesms.conversation.v2.components.LinkPreviewDraftViewDelegate
|
||||||
@ -158,7 +160,7 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li
|
|||||||
|
|
||||||
// Edit text
|
// Edit text
|
||||||
binding.inputBarEditText.setOnEditorActionListener(this)
|
binding.inputBarEditText.setOnEditorActionListener(this)
|
||||||
if (TextSecurePreferences.isEnterSendsEnabled(context)) {
|
if (context.prefs.isEnterSendsEnabled()) {
|
||||||
binding.inputBarEditText.imeOptions = EditorInfo.IME_ACTION_SEND
|
binding.inputBarEditText.imeOptions = EditorInfo.IME_ACTION_SEND
|
||||||
binding.inputBarEditText.inputType =
|
binding.inputBarEditText.inputType =
|
||||||
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
||||||
@ -168,7 +170,7 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li
|
|||||||
binding.inputBarEditText.inputType or
|
binding.inputBarEditText.inputType or
|
||||||
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
||||||
}
|
}
|
||||||
val incognitoFlag = if (TextSecurePreferences.isIncognitoKeyboardEnabled(context)) 16777216 else 0
|
val incognitoFlag = if (context.prefs.isIncognitoKeyboardEnabled()) 16777216 else 0
|
||||||
binding.inputBarEditText.imeOptions = binding.inputBarEditText.imeOptions or incognitoFlag // Always use incognito keyboard if setting enabled
|
binding.inputBarEditText.imeOptions = binding.inputBarEditText.imeOptions or incognitoFlag // Always use incognito keyboard if setting enabled
|
||||||
binding.inputBarEditText.delegate = this
|
binding.inputBarEditText.delegate = this
|
||||||
}
|
}
|
||||||
@ -216,7 +218,7 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li
|
|||||||
it.delegate = this
|
it.delegate = this
|
||||||
binding.inputBarAdditionalContentContainer.addView(layout)
|
binding.inputBarAdditionalContentContainer.addView(layout)
|
||||||
val attachments = (message as? MmsMessageRecord)?.slideDeck
|
val attachments = (message as? MmsMessageRecord)?.slideDeck
|
||||||
val sender = if (message.isOutgoing) TextSecurePreferences.getLocalNumber(context)!! else message.individualRecipient.address.serialize()
|
val sender = if (message.isOutgoing) context.prefs.getLocalNumber()!! else message.individualRecipient.address.serialize()
|
||||||
it.bind(sender, message.body, attachments, thread, true, message.isOpenGroupInvitation, message.threadId, false, glide)
|
it.bind(sender, message.body, attachments, thread, true, message.isOpenGroupInvitation, message.threadId, false, glide)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import org.session.libsession.messaging.MessagingModuleConfiguration
|
|||||||
import org.session.libsession.messaging.utilities.AccountId
|
import org.session.libsession.messaging.utilities.AccountId
|
||||||
import org.session.libsession.messaging.utilities.SodiumUtilities
|
import org.session.libsession.messaging.utilities.SodiumUtilities
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.utilities.IdPrefix
|
import org.session.libsignal.utilities.IdPrefix
|
||||||
import org.thoughtcrime.securesms.conversation.v2.ConversationAdapter
|
import org.thoughtcrime.securesms.conversation.v2.ConversationAdapter
|
||||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord
|
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord
|
||||||
@ -36,7 +37,7 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p
|
|||||||
val firstMessage = selectedItems.iterator().next()
|
val firstMessage = selectedItems.iterator().next()
|
||||||
val openGroup = DatabaseComponent.get(context).lokiThreadDatabase().getOpenGroupChat(threadID)
|
val openGroup = DatabaseComponent.get(context).lokiThreadDatabase().getOpenGroupChat(threadID)
|
||||||
val thread = DatabaseComponent.get(context).threadDatabase().getRecipientForThreadId(threadID)!!
|
val thread = DatabaseComponent.get(context).threadDatabase().getRecipientForThreadId(threadID)!!
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
val userPublicKey = context.prefs.getLocalNumber()!!
|
||||||
val edKeyPair = MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!
|
val edKeyPair = MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!
|
||||||
val blindedPublicKey = openGroup?.publicKey?.let { SodiumUtilities.blindedKeyPair(it, edKeyPair)?.publicKey?.asBytes }
|
val blindedPublicKey = openGroup?.publicKey?.let { SodiumUtilities.blindedKeyPair(it, edKeyPair)?.publicKey?.asBytes }
|
||||||
?.let { AccountId(IdPrefix.BLINDED, it) }?.hexString
|
?.let { AccountId(IdPrefix.BLINDED, it) }?.hexString
|
||||||
|
@ -20,7 +20,7 @@ import network.loki.messenger.R
|
|||||||
import org.session.libsession.messaging.sending_receiving.MessageSender
|
import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||||
import org.session.libsession.messaging.sending_receiving.leave
|
import org.session.libsession.messaging.sending_receiving.leave
|
||||||
import org.session.libsession.utilities.GroupUtil.doubleDecodeGroupID
|
import org.session.libsession.utilities.GroupUtil.doubleDecodeGroupID
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.guava.Optional
|
import org.session.libsignal.utilities.guava.Optional
|
||||||
import org.session.libsignal.utilities.toHexString
|
import org.session.libsignal.utilities.toHexString
|
||||||
@ -162,7 +162,7 @@ object ConversationMenuHelper {
|
|||||||
|
|
||||||
private fun call(context: Context, thread: Recipient) {
|
private fun call(context: Context, thread: Recipient) {
|
||||||
|
|
||||||
if (!TextSecurePreferences.isCallNotificationsEnabled(context)) {
|
if (!context.prefs.isCallNotificationsEnabled()) {
|
||||||
context.showSessionDialog {
|
context.showSessionDialog {
|
||||||
title(R.string.ConversationActivity_call_title)
|
title(R.string.ConversationActivity_call_title)
|
||||||
text(R.string.ConversationActivity_call_prompt)
|
text(R.string.ConversationActivity_call_prompt)
|
||||||
@ -271,7 +271,7 @@ object ConversationMenuHelper {
|
|||||||
|
|
||||||
val group = DatabaseComponent.get(context).groupDatabase().getGroup(thread.address.toGroupString()).orNull()
|
val group = DatabaseComponent.get(context).groupDatabase().getGroup(thread.address.toGroupString()).orNull()
|
||||||
val admins = group.admins
|
val admins = group.admins
|
||||||
val accountID = TextSecurePreferences.getLocalNumber(context)
|
val accountID = context.prefs.getLocalNumber()
|
||||||
val isCurrentUserAdmin = admins.any { it.toString() == accountID }
|
val isCurrentUserAdmin = admins.any { it.toString() == accountID }
|
||||||
val message = if (isCurrentUserAdmin) {
|
val message = if (isCurrentUserAdmin) {
|
||||||
"Because you are the creator of this group it will be deleted for everyone. This cannot be undone."
|
"Because you are the creator of this group it will be deleted for everyone. This cannot be undone."
|
||||||
|
@ -13,8 +13,9 @@ import androidx.core.content.ContextCompat
|
|||||||
import com.google.android.flexbox.JustifyContent
|
import com.google.android.flexbox.JustifyContent
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import network.loki.messenger.databinding.ViewEmojiReactionsBinding
|
import network.loki.messenger.databinding.ViewEmojiReactionsBinding
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.getLocalNumber
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.ThemeUtil
|
import org.session.libsession.utilities.ThemeUtil
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiImageView
|
import org.thoughtcrime.securesms.components.emoji.EmojiImageView
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiUtil
|
import org.thoughtcrime.securesms.components.emoji.EmojiUtil
|
||||||
import org.thoughtcrime.securesms.conversation.v2.ViewUtil
|
import org.thoughtcrime.securesms.conversation.v2.ViewUtil
|
||||||
@ -86,7 +87,7 @@ class EmojiReactionsView : ConstraintLayout, OnTouchListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun displayReactions(threshold: Int) {
|
private fun displayReactions(threshold: Int) {
|
||||||
val userPublicKey = getLocalNumber(context)
|
val userPublicKey = context.prefs.getLocalNumber()
|
||||||
val reactions = buildSortedReactionsList(records!!, userPublicKey, threshold)
|
val reactions = buildSortedReactionsList(records!!, userPublicKey, threshold)
|
||||||
binding.layoutEmojiContainer.removeAllViews()
|
binding.layoutEmojiContainer.removeAllViews()
|
||||||
val overflowContainer = LinearLayout(context)
|
val overflowContainer = LinearLayout(context)
|
||||||
|
@ -12,9 +12,11 @@ import androidx.core.view.isVisible
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import network.loki.messenger.databinding.ViewQuoteBinding
|
import network.loki.messenger.databinding.ViewQuoteBinding
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.contacts.Contact
|
import org.session.libsession.messaging.contacts.Contact
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.getColorFromAttr
|
import org.session.libsession.utilities.getColorFromAttr
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.conversation.v2.utilities.MentionUtilities
|
import org.thoughtcrime.securesms.conversation.v2.utilities.MentionUtilities
|
||||||
import org.thoughtcrime.securesms.database.SessionContactDatabase
|
import org.thoughtcrime.securesms.database.SessionContactDatabase
|
||||||
@ -71,7 +73,7 @@ class QuoteView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
|||||||
isOriginalMissing: Boolean, glide: GlideRequests) {
|
isOriginalMissing: Boolean, glide: GlideRequests) {
|
||||||
// Author
|
// Author
|
||||||
val author = contactDb.getContactWithAccountID(authorPublicKey)
|
val author = contactDb.getContactWithAccountID(authorPublicKey)
|
||||||
val localNumber = TextSecurePreferences.getLocalNumber(context)
|
val localNumber = context.prefs.getLocalNumber()
|
||||||
val quoteIsLocalUser = localNumber != null && authorPublicKey == localNumber
|
val quoteIsLocalUser = localNumber != null && authorPublicKey == localNumber
|
||||||
|
|
||||||
val authorDisplayName =
|
val authorDisplayName =
|
||||||
|
@ -12,12 +12,14 @@ import android.util.Range
|
|||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import nl.komponents.kovenant.combine.Tuple2
|
import nl.komponents.kovenant.combine.Tuple2
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.contacts.Contact
|
import org.session.libsession.messaging.contacts.Contact
|
||||||
import org.session.libsession.messaging.open_groups.OpenGroup
|
import org.session.libsession.messaging.open_groups.OpenGroup
|
||||||
import org.session.libsession.messaging.utilities.SodiumUtilities
|
import org.session.libsession.messaging.utilities.SodiumUtilities
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.ThemeUtil
|
import org.session.libsession.utilities.ThemeUtil
|
||||||
import org.session.libsession.utilities.getColorFromAttr
|
import org.session.libsession.utilities.getColorFromAttr
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
import org.thoughtcrime.securesms.util.RoundedBackgroundSpan
|
import org.thoughtcrime.securesms.util.RoundedBackgroundSpan
|
||||||
import org.thoughtcrime.securesms.util.getAccentColor
|
import org.thoughtcrime.securesms.util.getAccentColor
|
||||||
@ -54,7 +56,7 @@ object MentionUtilities {
|
|||||||
var matcher = pattern.matcher(text)
|
var matcher = pattern.matcher(text)
|
||||||
val mentions = mutableListOf<Tuple2<Range<Int>, String>>()
|
val mentions = mutableListOf<Tuple2<Range<Int>, String>>()
|
||||||
var startIndex = 0
|
var startIndex = 0
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
val userPublicKey = context.prefs.getLocalNumber()!!
|
||||||
val openGroup by lazy { DatabaseComponent.get(context).storage().getOpenGroup(threadID) }
|
val openGroup by lazy { DatabaseComponent.get(context).storage().getOpenGroup(threadID) }
|
||||||
|
|
||||||
// format the mention text
|
// format the mention text
|
||||||
|
@ -10,6 +10,7 @@ import org.session.libsession.messaging.messages.visible.VisibleMessage
|
|||||||
import org.session.libsession.messaging.sending_receiving.MessageSender
|
import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||||
import org.session.libsession.messaging.utilities.UpdateMessageData
|
import org.session.libsession.messaging.utilities.UpdateMessageData
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||||
@ -44,7 +45,7 @@ object ResendMessageUtilities {
|
|||||||
messageRecord.linkPreviews.firstOrNull()?.let { message.linkPreview = LinkPreview.from(it) }
|
messageRecord.linkPreviews.firstOrNull()?.let { message.linkPreview = LinkPreview.from(it) }
|
||||||
messageRecord.quote?.quoteModel?.let {
|
messageRecord.quote?.quoteModel?.let {
|
||||||
message.quote = Quote.from(it)?.apply {
|
message.quote = Quote.from(it)?.apply {
|
||||||
if (userBlindedKey != null && publicKey == TextSecurePreferences.getLocalNumber(context)) {
|
if (userBlindedKey != null && publicKey == context.prefs.getLocalNumber()) {
|
||||||
publicKey = userBlindedKey
|
publicKey = userBlindedKey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package org.thoughtcrime.securesms.crypto;
|
package org.thoughtcrime.securesms.crypto;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
@ -19,85 +17,55 @@ public class AttachmentSecretProvider {
|
|||||||
|
|
||||||
private static AttachmentSecretProvider provider;
|
private static AttachmentSecretProvider provider;
|
||||||
|
|
||||||
public static synchronized AttachmentSecretProvider getInstance(@NonNull Context context) {
|
public static synchronized AttachmentSecretProvider getInstance() {
|
||||||
if (provider == null) provider = new AttachmentSecretProvider(context.getApplicationContext());
|
if (provider == null) provider = new AttachmentSecretProvider();
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Context context;
|
|
||||||
|
|
||||||
private AttachmentSecret attachmentSecret;
|
private AttachmentSecret attachmentSecret;
|
||||||
|
|
||||||
private AttachmentSecretProvider(@NonNull Context context) {
|
|
||||||
this.context = context.getApplicationContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized AttachmentSecret getOrCreateAttachmentSecret() {
|
public synchronized AttachmentSecret getOrCreateAttachmentSecret() {
|
||||||
if (attachmentSecret != null) return attachmentSecret;
|
if (attachmentSecret != null) return attachmentSecret;
|
||||||
|
|
||||||
String unencryptedSecret = TextSecurePreferences.getAttachmentUnencryptedSecret(context);
|
String unencryptedSecret = MessagingModuleConfiguration.getShared().getPrefs().getAttachmentUnencryptedSecret();
|
||||||
String encryptedSecret = TextSecurePreferences.getAttachmentEncryptedSecret(context);
|
String encryptedSecret = MessagingModuleConfiguration.getShared().getPrefs().getAttachmentEncryptedSecret();
|
||||||
|
|
||||||
if (unencryptedSecret != null) attachmentSecret = getUnencryptedAttachmentSecret(context, unencryptedSecret);
|
if (unencryptedSecret != null) attachmentSecret = getUnencryptedAttachmentSecret(unencryptedSecret);
|
||||||
else if (encryptedSecret != null) attachmentSecret = getEncryptedAttachmentSecret(encryptedSecret);
|
else if (encryptedSecret != null) attachmentSecret = getEncryptedAttachmentSecret(encryptedSecret);
|
||||||
else attachmentSecret = createAndStoreAttachmentSecret(context);
|
else attachmentSecret = createAndStoreAttachmentSecret();
|
||||||
|
|
||||||
return attachmentSecret;
|
return attachmentSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized AttachmentSecret setClassicKey(@NonNull Context context, @NonNull byte[] classicCipherKey, @NonNull byte[] classicMacKey) {
|
private AttachmentSecret getUnencryptedAttachmentSecret(@NonNull String unencryptedSecret) {
|
||||||
AttachmentSecret currentSecret = getOrCreateAttachmentSecret();
|
|
||||||
currentSecret.setClassicCipherKey(classicCipherKey);
|
|
||||||
currentSecret.setClassicMacKey(classicMacKey);
|
|
||||||
|
|
||||||
storeAttachmentSecret(context, attachmentSecret);
|
|
||||||
|
|
||||||
return attachmentSecret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AttachmentSecret getUnencryptedAttachmentSecret(@NonNull Context context, @NonNull String unencryptedSecret)
|
|
||||||
{
|
|
||||||
AttachmentSecret attachmentSecret = AttachmentSecret.fromString(unencryptedSecret);
|
AttachmentSecret attachmentSecret = AttachmentSecret.fromString(unencryptedSecret);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
||||||
return attachmentSecret;
|
|
||||||
} else {
|
|
||||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(attachmentSecret.serialize().getBytes());
|
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(attachmentSecret.serialize().getBytes());
|
||||||
|
|
||||||
TextSecurePreferences.setAttachmentEncryptedSecret(context, encryptedSecret.serialize());
|
MessagingModuleConfiguration.getShared().getPrefs().setAttachmentEncryptedSecret(encryptedSecret.serialize());
|
||||||
TextSecurePreferences.setAttachmentUnencryptedSecret(context, null);
|
MessagingModuleConfiguration.getShared().getPrefs().setAttachmentUnencryptedSecret(null);
|
||||||
|
|
||||||
return attachmentSecret;
|
return attachmentSecret;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AttachmentSecret getEncryptedAttachmentSecret(@NonNull String serializedEncryptedSecret) {
|
private AttachmentSecret getEncryptedAttachmentSecret(@NonNull String serializedEncryptedSecret) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.SealedData.fromString(serializedEncryptedSecret);
|
||||||
throw new AssertionError("OS downgrade not supported. KeyStore sealed data exists on platform < M!");
|
return AttachmentSecret.fromString(new String(KeyStoreHelper.unseal(encryptedSecret)));
|
||||||
} else {
|
|
||||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.SealedData.fromString(serializedEncryptedSecret);
|
|
||||||
return AttachmentSecret.fromString(new String(KeyStoreHelper.unseal(encryptedSecret)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AttachmentSecret createAndStoreAttachmentSecret(@NonNull Context context) {
|
private AttachmentSecret createAndStoreAttachmentSecret() {
|
||||||
SecureRandom random = new SecureRandom();
|
SecureRandom random = new SecureRandom();
|
||||||
byte[] secret = new byte[32];
|
byte[] secret = new byte[32];
|
||||||
random.nextBytes(secret);
|
random.nextBytes(secret);
|
||||||
|
|
||||||
AttachmentSecret attachmentSecret = new AttachmentSecret(null, null, secret);
|
AttachmentSecret attachmentSecret = new AttachmentSecret(null, null, secret);
|
||||||
storeAttachmentSecret(context, attachmentSecret);
|
storeAttachmentSecret(attachmentSecret);
|
||||||
|
|
||||||
return attachmentSecret;
|
return attachmentSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeAttachmentSecret(@NonNull Context context, @NonNull AttachmentSecret attachmentSecret) {
|
private void storeAttachmentSecret(@NonNull AttachmentSecret attachmentSecret) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(attachmentSecret.serialize().getBytes());
|
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(attachmentSecret.serialize().getBytes());
|
||||||
TextSecurePreferences.setAttachmentEncryptedSecret(context, encryptedSecret.serialize());
|
MessagingModuleConfiguration.getShared().getPrefs().setAttachmentEncryptedSecret(encryptedSecret.serialize());
|
||||||
} else {
|
|
||||||
TextSecurePreferences.setAttachmentUnencryptedSecret(context, attachmentSecret.serialize());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@ import android.content.Context
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.security.keystore.KeyGenParameterSpec
|
import android.security.keystore.KeyGenParameterSpec
|
||||||
import android.security.keystore.KeyProperties
|
import android.security.keystore.KeyProperties
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.Util
|
import org.session.libsession.utilities.Util
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import java.security.InvalidKeyException
|
import java.security.InvalidKeyException
|
||||||
import java.security.KeyPairGenerator
|
import java.security.KeyPairGenerator
|
||||||
import java.security.KeyStore
|
import java.security.KeyStore
|
||||||
@ -54,10 +56,10 @@ class BiometricSecretProvider {
|
|||||||
ks.load(null)
|
ks.load(null)
|
||||||
if (!ks.containsAlias(BIOMETRIC_ASYM_KEY_ALIAS)
|
if (!ks.containsAlias(BIOMETRIC_ASYM_KEY_ALIAS)
|
||||||
|| !ks.entryInstanceOf(BIOMETRIC_ASYM_KEY_ALIAS, KeyStore.PrivateKeyEntry::class.java)
|
|| !ks.entryInstanceOf(BIOMETRIC_ASYM_KEY_ALIAS, KeyStore.PrivateKeyEntry::class.java)
|
||||||
|| !TextSecurePreferences.getFingerprintKeyGenerated(context)
|
|| !context.prefs.getFingerprintKeyGenerated()
|
||||||
) {
|
) {
|
||||||
createAsymmetricKey(context)
|
createAsymmetricKey(context)
|
||||||
TextSecurePreferences.setFingerprintKeyGenerated(context)
|
context.prefs.setFingerprintKeyGenerated()
|
||||||
}
|
}
|
||||||
val signature = try {
|
val signature = try {
|
||||||
val key = ks.getKey(BIOMETRIC_ASYM_KEY_ALIAS, null) as PrivateKey
|
val key = ks.getKey(BIOMETRIC_ASYM_KEY_ALIAS, null) as PrivateKey
|
||||||
@ -67,7 +69,7 @@ class BiometricSecretProvider {
|
|||||||
} catch (e: InvalidKeyException) {
|
} catch (e: InvalidKeyException) {
|
||||||
ks.deleteEntry(BIOMETRIC_ASYM_KEY_ALIAS)
|
ks.deleteEntry(BIOMETRIC_ASYM_KEY_ALIAS)
|
||||||
createAsymmetricKey(context)
|
createAsymmetricKey(context)
|
||||||
TextSecurePreferences.setFingerprintKeyGenerated(context)
|
context.prefs.setFingerprintKeyGenerated()
|
||||||
val key = ks.getKey(BIOMETRIC_ASYM_KEY_ALIAS, null) as PrivateKey
|
val key = ks.getKey(BIOMETRIC_ASYM_KEY_ALIAS, null) as PrivateKey
|
||||||
val signature = Signature.getInstance(SIGNATURE_ALGORITHM)
|
val signature = Signature.getInstance(SIGNATURE_ALGORITHM)
|
||||||
signature.initSign(key)
|
signature.initSign(key)
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.thoughtcrime.securesms.crypto;
|
package org.thoughtcrime.securesms.crypto;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -15,63 +13,51 @@ public class DatabaseSecretProvider {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final String TAG = DatabaseSecretProvider.class.getSimpleName();
|
private static final String TAG = DatabaseSecretProvider.class.getSimpleName();
|
||||||
|
|
||||||
private final Context context;
|
private final TextSecurePreferences prefs;
|
||||||
|
|
||||||
public DatabaseSecretProvider(@NonNull Context context) {
|
public DatabaseSecretProvider(@NonNull TextSecurePreferences prefs) {
|
||||||
this.context = context.getApplicationContext();
|
this.prefs = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatabaseSecret getOrCreateDatabaseSecret() {
|
public DatabaseSecret getOrCreateDatabaseSecret() {
|
||||||
String unencryptedSecret = TextSecurePreferences.getDatabaseUnencryptedSecret(context);
|
String unencryptedSecret = prefs.getDatabaseUnencryptedSecret();
|
||||||
String encryptedSecret = TextSecurePreferences.getDatabaseEncryptedSecret(context);
|
String encryptedSecret = prefs.getDatabaseEncryptedSecret();
|
||||||
|
|
||||||
if (unencryptedSecret != null) return getUnencryptedDatabaseSecret(context, unencryptedSecret);
|
if (unencryptedSecret != null) return getUnencryptedDatabaseSecret(unencryptedSecret);
|
||||||
else if (encryptedSecret != null) return getEncryptedDatabaseSecret(encryptedSecret);
|
else if (encryptedSecret != null) return getEncryptedDatabaseSecret(encryptedSecret);
|
||||||
else return createAndStoreDatabaseSecret(context);
|
else return createAndStoreDatabaseSecret();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DatabaseSecret getUnencryptedDatabaseSecret(@NonNull Context context, @NonNull String unencryptedSecret)
|
private DatabaseSecret getUnencryptedDatabaseSecret(@NonNull String unencryptedSecret)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DatabaseSecret databaseSecret = new DatabaseSecret(unencryptedSecret);
|
DatabaseSecret databaseSecret = new DatabaseSecret(unencryptedSecret);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(databaseSecret.asBytes());
|
||||||
return databaseSecret;
|
|
||||||
} else {
|
|
||||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(databaseSecret.asBytes());
|
|
||||||
|
|
||||||
TextSecurePreferences.setDatabaseEncryptedSecret(context, encryptedSecret.serialize());
|
prefs.setDatabaseEncryptedSecret(encryptedSecret.serialize());
|
||||||
TextSecurePreferences.setDatabaseUnencryptedSecret(context, null);
|
prefs.setDatabaseUnencryptedSecret(null);
|
||||||
|
|
||||||
return databaseSecret;
|
return databaseSecret;
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DatabaseSecret getEncryptedDatabaseSecret(@NonNull String serializedEncryptedSecret) {
|
private DatabaseSecret getEncryptedDatabaseSecret(@NonNull String serializedEncryptedSecret) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.SealedData.fromString(serializedEncryptedSecret);
|
||||||
throw new AssertionError("OS downgrade not supported. KeyStore sealed data exists on platform < M!");
|
return new DatabaseSecret(KeyStoreHelper.unseal(encryptedSecret));
|
||||||
} else {
|
|
||||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.SealedData.fromString(serializedEncryptedSecret);
|
|
||||||
return new DatabaseSecret(KeyStoreHelper.unseal(encryptedSecret));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DatabaseSecret createAndStoreDatabaseSecret(@NonNull Context context) {
|
private DatabaseSecret createAndStoreDatabaseSecret() {
|
||||||
SecureRandom random = new SecureRandom();
|
SecureRandom random = new SecureRandom();
|
||||||
byte[] secret = new byte[32];
|
byte[] secret = new byte[32];
|
||||||
random.nextBytes(secret);
|
random.nextBytes(secret);
|
||||||
|
|
||||||
DatabaseSecret databaseSecret = new DatabaseSecret(secret);
|
DatabaseSecret databaseSecret = new DatabaseSecret(secret);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(databaseSecret.asBytes());
|
||||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(databaseSecret.asBytes());
|
prefs.setDatabaseEncryptedSecret(encryptedSecret.serialize());
|
||||||
TextSecurePreferences.setDatabaseEncryptedSecret(context, encryptedSecret.serialize());
|
|
||||||
} else {
|
|
||||||
TextSecurePreferences.setDatabaseUnencryptedSecret(context, databaseSecret.asString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return databaseSecret;
|
return databaseSecret;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import com.annimon.stream.Stream;
|
|||||||
import net.zetetic.database.sqlcipher.SQLiteDatabase;
|
import net.zetetic.database.sqlcipher.SQLiteDatabase;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.Address;
|
import org.session.libsession.utilities.Address;
|
||||||
import org.session.libsession.utilities.GroupRecord;
|
import org.session.libsession.utilities.GroupRecord;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
@ -172,7 +173,7 @@ public class GroupDatabase extends Database implements LokiOpenGroupDatabaseProt
|
|||||||
List<Recipient> recipients = new LinkedList<>();
|
List<Recipient> recipients = new LinkedList<>();
|
||||||
|
|
||||||
for (Address member : members) {
|
for (Address member : members) {
|
||||||
if (!includeSelf && Util.isOwnNumber(context, member.serialize()))
|
if (!includeSelf && Util.isOwnNumber(member.serialize()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (member.isContact()) {
|
if (member.isContact()) {
|
||||||
@ -186,7 +187,7 @@ public class GroupDatabase extends Database implements LokiOpenGroupDatabaseProt
|
|||||||
public @NonNull List<Address> getGroupMemberAddresses(String groupId, boolean includeSelf) {
|
public @NonNull List<Address> getGroupMemberAddresses(String groupId, boolean includeSelf) {
|
||||||
List<Address> members = getCurrentMembers(groupId, false);
|
List<Address> members = getCurrentMembers(groupId, false);
|
||||||
if (!includeSelf) {
|
if (!includeSelf) {
|
||||||
String ownNumber = TextSecurePreferences.getLocalNumber(context);
|
String ownNumber = MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber();
|
||||||
if (ownNumber == null) return members;
|
if (ownNumber == null) return members;
|
||||||
Address ownAddress = Address.fromSerialized(ownNumber);
|
Address ownAddress = Address.fromSerialized(ownNumber);
|
||||||
int indexOfSelf = members.indexOf(ownAddress);
|
int indexOfSelf = members.indexOf(ownAddress);
|
||||||
|
@ -2,7 +2,9 @@ package org.thoughtcrime.securesms.database
|
|||||||
|
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.crypto.ecc.DjbECPrivateKey
|
import org.session.libsignal.crypto.ecc.DjbECPrivateKey
|
||||||
import org.session.libsignal.crypto.ecc.DjbECPublicKey
|
import org.session.libsignal.crypto.ecc.DjbECPublicKey
|
||||||
import org.session.libsignal.crypto.ecc.ECKeyPair
|
import org.session.libsignal.crypto.ecc.ECKeyPair
|
||||||
@ -479,13 +481,13 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getLastSnodePoolRefreshDate(): Date? {
|
override fun getLastSnodePoolRefreshDate(): Date? {
|
||||||
val time = TextSecurePreferences.getLastSnodePoolRefreshDate(context)
|
val time = context.prefs.getLastSnodePoolRefreshDate()
|
||||||
if (time <= 0) { return null }
|
if (time <= 0) { return null }
|
||||||
return Date(time)
|
return Date(time)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setLastSnodePoolRefreshDate(date: Date) {
|
override fun setLastSnodePoolRefreshDate(date: Date) {
|
||||||
TextSecurePreferences.setLastSnodePoolRefreshDate(context, date)
|
context.prefs.setLastSnodePoolRefreshDate(date)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUserX25519KeyPair(): ECKeyPair {
|
override fun getUserX25519KeyPair(): ECKeyPair {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package org.thoughtcrime.securesms.database
|
package org.thoughtcrime.securesms.database
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
|
|
||||||
class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
|
class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
|
||||||
|
|
||||||
@ -20,8 +22,8 @@ class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getDisplayName(publicKey: String): String? {
|
fun getDisplayName(publicKey: String): String? {
|
||||||
if (publicKey == TextSecurePreferences.getLocalNumber(context)) {
|
if (publicKey == context.prefs.getLocalNumber()) {
|
||||||
return TextSecurePreferences.getProfileName(context)
|
return context.prefs.getProfileName()
|
||||||
} else {
|
} else {
|
||||||
val database = databaseHelper.readableDatabase
|
val database = databaseHelper.readableDatabase
|
||||||
val result = database.get(displayNameTable, "${Companion.publicKey} = ?", arrayOf( publicKey )) { cursor ->
|
val result = database.get(displayNameTable, "${Companion.publicKey} = ?", arrayOf( publicKey )) { cursor ->
|
||||||
|
@ -14,7 +14,6 @@ import org.session.libsession.utilities.IdentityKeyMismatchList;
|
|||||||
import org.session.libsignal.crypto.IdentityKey;
|
import org.session.libsignal.crypto.IdentityKey;
|
||||||
import org.session.libsignal.utilities.JsonUtil;
|
import org.session.libsignal.utilities.JsonUtil;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.ExpiryType;
|
|
||||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||||
import org.thoughtcrime.securesms.util.SqlUtil;
|
import org.thoughtcrime.securesms.util.SqlUtil;
|
||||||
|
@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils
|
|||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.messages.ExpirationConfiguration
|
import org.session.libsession.messaging.messages.ExpirationConfiguration
|
||||||
import org.session.libsession.messaging.messages.signal.IncomingMediaMessage
|
import org.session.libsession.messaging.messages.signal.IncomingMediaMessage
|
||||||
import org.session.libsession.messaging.messages.signal.OutgoingGroupMediaMessage
|
import org.session.libsession.messaging.messages.signal.OutgoingGroupMediaMessage
|
||||||
@ -45,8 +46,8 @@ import org.session.libsession.utilities.IdentityKeyMismatch
|
|||||||
import org.session.libsession.utilities.IdentityKeyMismatchList
|
import org.session.libsession.utilities.IdentityKeyMismatchList
|
||||||
import org.session.libsession.utilities.NetworkFailure
|
import org.session.libsession.utilities.NetworkFailure
|
||||||
import org.session.libsession.utilities.NetworkFailureList
|
import org.session.libsession.utilities.NetworkFailureList
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.isReadReceiptsEnabled
|
|
||||||
import org.session.libsession.utilities.Util.toIsoBytes
|
import org.session.libsession.utilities.Util.toIsoBytes
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.JsonUtil
|
import org.session.libsignal.utilities.JsonUtil
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
@ -1264,7 +1265,7 @@ class MmsDatabase(context: Context, databaseHelper: SQLCipherOpenHelper) : Messa
|
|||||||
DELIVERY_RECEIPT_COUNT
|
DELIVERY_RECEIPT_COUNT
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val readReceiptCount = if (isReadReceiptsEnabled(context)) cursor.getInt(cursor.getColumnIndexOrThrow(READ_RECEIPT_COUNT)) else 0
|
val readReceiptCount = if (context.prefs.isReadReceiptsEnabled()) cursor.getInt(cursor.getColumnIndexOrThrow(READ_RECEIPT_COUNT)) else 0
|
||||||
val hasMention = (cursor.getInt(cursor.getColumnIndexOrThrow(HAS_MENTION)) == 1)
|
val hasMention = (cursor.getInt(cursor.getColumnIndexOrThrow(HAS_MENTION)) == 1)
|
||||||
val contentLocationBytes: ByteArray? = contentLocation?.takeUnless { it.isEmpty() }?.let(::toIsoBytes)
|
val contentLocationBytes: ByteArray? = contentLocation?.takeUnless { it.isEmpty() }?.let(::toIsoBytes)
|
||||||
val transactionIdBytes: ByteArray? = transactionId?.takeUnless { it.isEmpty() }?.let(::toIsoBytes)
|
val transactionIdBytes: ByteArray? = transactionId?.takeUnless { it.isEmpty() }?.let(::toIsoBytes)
|
||||||
@ -1309,7 +1310,7 @@ class MmsDatabase(context: Context, databaseHelper: SQLCipherOpenHelper) : Messa
|
|||||||
val expireStarted = cursor.getLong(cursor.getColumnIndexOrThrow(EXPIRE_STARTED))
|
val expireStarted = cursor.getLong(cursor.getColumnIndexOrThrow(EXPIRE_STARTED))
|
||||||
val unidentified = cursor.getInt(cursor.getColumnIndexOrThrow(UNIDENTIFIED)) == 1
|
val unidentified = cursor.getInt(cursor.getColumnIndexOrThrow(UNIDENTIFIED)) == 1
|
||||||
val hasMention = cursor.getInt(cursor.getColumnIndexOrThrow(HAS_MENTION)) == 1
|
val hasMention = cursor.getInt(cursor.getColumnIndexOrThrow(HAS_MENTION)) == 1
|
||||||
if (!isReadReceiptsEnabled(context)) {
|
if (!context.prefs.isReadReceiptsEnabled()) {
|
||||||
readReceiptCount = 0
|
readReceiptCount = 0
|
||||||
}
|
}
|
||||||
val recipient = getRecipientFor(address)
|
val recipient = getRecipientFor(address)
|
||||||
|
@ -106,7 +106,7 @@ public class MmsSmsDatabase extends Database {
|
|||||||
MmsSmsDatabase.Reader reader = readerFor(cursor, getQuote);
|
MmsSmsDatabase.Reader reader = readerFor(cursor, getQuote);
|
||||||
|
|
||||||
MessageRecord messageRecord;
|
MessageRecord messageRecord;
|
||||||
boolean isOwnNumber = Util.isOwnNumber(context, serializedAuthor);
|
boolean isOwnNumber = Util.isOwnNumber(serializedAuthor);
|
||||||
|
|
||||||
while ((messageRecord = reader.getNext()) != null) {
|
while ((messageRecord = reader.getNext()) != null) {
|
||||||
if ((isOwnNumber && messageRecord.isOutgoing()) ||
|
if ((isOwnNumber && messageRecord.isOutgoing()) ||
|
||||||
@ -122,7 +122,7 @@ public class MmsSmsDatabase extends Database {
|
|||||||
|
|
||||||
public @Nullable MessageRecord getSentMessageFor(long timestamp, String serializedAuthor) {
|
public @Nullable MessageRecord getSentMessageFor(long timestamp, String serializedAuthor) {
|
||||||
// Early exit if the author is not us
|
// Early exit if the author is not us
|
||||||
boolean isOwnNumber = Util.isOwnNumber(context, serializedAuthor);
|
boolean isOwnNumber = Util.isOwnNumber(serializedAuthor);
|
||||||
if (!isOwnNumber) {
|
if (!isOwnNumber) {
|
||||||
Log.i(TAG, "Asked to find sent messages but provided author is not us - returning null.");
|
Log.i(TAG, "Asked to find sent messages but provided author is not us - returning null.");
|
||||||
return null;
|
return null;
|
||||||
@ -145,7 +145,7 @@ public class MmsSmsDatabase extends Database {
|
|||||||
|
|
||||||
public MessageRecord getLastSentMessageRecordFromSender(long threadId, String serializedAuthor) {
|
public MessageRecord getLastSentMessageRecordFromSender(long threadId, String serializedAuthor) {
|
||||||
// Early exit if the author is not us
|
// Early exit if the author is not us
|
||||||
boolean isOwnNumber = Util.isOwnNumber(context, serializedAuthor);
|
boolean isOwnNumber = Util.isOwnNumber(serializedAuthor);
|
||||||
if (!isOwnNumber) {
|
if (!isOwnNumber) {
|
||||||
Log.i(TAG, "Asked to find last sent message but provided author is not us - returning null.");
|
Log.i(TAG, "Asked to find last sent message but provided author is not us - returning null.");
|
||||||
return null;
|
return null;
|
||||||
@ -375,7 +375,7 @@ public class MmsSmsDatabase extends Database {
|
|||||||
|
|
||||||
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_SENT, MmsSmsColumns.ADDRESS }, selection, order, null)) {
|
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_SENT, MmsSmsColumns.ADDRESS }, selection, order, null)) {
|
||||||
String serializedAddress = address.serialize();
|
String serializedAddress = address.serialize();
|
||||||
boolean isOwnNumber = Util.isOwnNumber(context, address.serialize());
|
boolean isOwnNumber = Util.isOwnNumber(address.serialize());
|
||||||
|
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
boolean quoteIdMatches = cursor.getLong(0) == quoteId;
|
boolean quoteIdMatches = cursor.getLong(0) == quoteId;
|
||||||
@ -395,7 +395,7 @@ public class MmsSmsDatabase extends Database {
|
|||||||
|
|
||||||
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_SENT, MmsSmsColumns.ADDRESS }, selection, order, null)) {
|
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_SENT, MmsSmsColumns.ADDRESS }, selection, order, null)) {
|
||||||
String serializedAddress = address.serialize();
|
String serializedAddress = address.serialize();
|
||||||
boolean isOwnNumber = Util.isOwnNumber(context, address.serialize());
|
boolean isOwnNumber = Util.isOwnNumber(address.serialize());
|
||||||
|
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
boolean timestampMatches = cursor.getLong(0) == sentTimestamp;
|
boolean timestampMatches = cursor.getLong(0) == sentTimestamp;
|
||||||
|
@ -28,6 +28,7 @@ import com.annimon.stream.Stream;
|
|||||||
import net.zetetic.database.sqlcipher.SQLiteDatabase;
|
import net.zetetic.database.sqlcipher.SQLiteDatabase;
|
||||||
import net.zetetic.database.sqlcipher.SQLiteStatement;
|
import net.zetetic.database.sqlcipher.SQLiteStatement;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.messaging.calls.CallMessageType;
|
import org.session.libsession.messaging.calls.CallMessageType;
|
||||||
import org.session.libsession.messaging.messages.signal.IncomingGroupMessage;
|
import org.session.libsession.messaging.messages.signal.IncomingGroupMessage;
|
||||||
import org.session.libsession.messaging.messages.signal.IncomingTextMessage;
|
import org.session.libsession.messaging.messages.signal.IncomingTextMessage;
|
||||||
@ -837,7 +838,7 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
boolean unidentified = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.UNIDENTIFIED)) == 1;
|
boolean unidentified = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.UNIDENTIFIED)) == 1;
|
||||||
boolean hasMention = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.HAS_MENTION)) == 1;
|
boolean hasMention = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.HAS_MENTION)) == 1;
|
||||||
|
|
||||||
if (!TextSecurePreferences.isReadReceiptsEnabled(context)) {
|
if (!MessagingModuleConfiguration.getShared().getPrefs().isReadReceiptsEnabled()) {
|
||||||
readReceiptCount = 0;
|
readReceiptCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import network.loki.messenger.libsession_util.util.afterSend
|
|||||||
import org.session.libsession.avatars.AvatarHelper
|
import org.session.libsession.avatars.AvatarHelper
|
||||||
import org.session.libsession.database.StorageProtocol
|
import org.session.libsession.database.StorageProtocol
|
||||||
import org.session.libsession.messaging.BlindedIdMapping
|
import org.session.libsession.messaging.BlindedIdMapping
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.calls.CallMessageType
|
import org.session.libsession.messaging.calls.CallMessageType
|
||||||
import org.session.libsession.messaging.contacts.Contact
|
import org.session.libsession.messaging.contacts.Contact
|
||||||
import org.session.libsession.messaging.jobs.AttachmentUploadJob
|
import org.session.libsession.messaging.jobs.AttachmentUploadJob
|
||||||
@ -68,6 +69,7 @@ import org.session.libsession.utilities.ProfileKeyUtil
|
|||||||
import org.session.libsession.utilities.SSKEnvironment
|
import org.session.libsession.utilities.SSKEnvironment
|
||||||
import org.session.libsession.utilities.SSKEnvironment.ProfileManagerProtocol.Companion.NAME_PADDED_LENGTH
|
import org.session.libsession.utilities.SSKEnvironment.ProfileManagerProtocol.Companion.NAME_PADDED_LENGTH
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsession.utilities.recipients.Recipient.DisappearingState
|
import org.session.libsession.utilities.recipients.Recipient.DisappearingState
|
||||||
import org.session.libsignal.crypto.ecc.DjbECPrivateKey
|
import org.session.libsignal.crypto.ecc.DjbECPrivateKey
|
||||||
@ -174,7 +176,7 @@ open class Storage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getUserPublicKey(): String? {
|
override fun getUserPublicKey(): String? {
|
||||||
return TextSecurePreferences.getLocalNumber(context)
|
return context.prefs.getLocalNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUserX25519KeyPair(): ECKeyPair {
|
override fun getUserX25519KeyPair(): ECKeyPair {
|
||||||
@ -182,9 +184,9 @@ open class Storage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getUserProfile(): Profile {
|
override fun getUserProfile(): Profile {
|
||||||
val displayName = TextSecurePreferences.getProfileName(context)
|
val displayName = context.prefs.getProfileName()
|
||||||
val profileKey = ProfileKeyUtil.getProfileKey(context)
|
val profileKey = ProfileKeyUtil.getProfileKey(context)
|
||||||
val profilePictureUrl = TextSecurePreferences.getProfilePictureURL(context)
|
val profilePictureUrl = context.prefs.getProfilePictureURL()
|
||||||
return Profile(displayName, profileKey, profilePictureUrl)
|
return Profile(displayName, profileKey, profilePictureUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,8 +211,8 @@ open class Storage(
|
|||||||
Recipient.from(context, it, false)
|
Recipient.from(context, it, false)
|
||||||
}
|
}
|
||||||
ourRecipient.resolve().profileKey = newProfileKey
|
ourRecipient.resolve().profileKey = newProfileKey
|
||||||
TextSecurePreferences.setProfileKey(context, newProfileKey?.let { Base64.encodeBytes(it) })
|
context.prefs.setProfileKey(newProfileKey?.let { Base64.encodeBytes(it) })
|
||||||
TextSecurePreferences.setProfilePictureURL(context, newProfilePicture)
|
context.prefs.setProfilePictureURL(newProfilePicture)
|
||||||
|
|
||||||
if (newProfileKey != null) {
|
if (newProfileKey != null) {
|
||||||
JobQueue.shared.add(RetrieveProfileAvatarJob(newProfilePicture, ourRecipient.address))
|
JobQueue.shared.add(RetrieveProfileAvatarJob(newProfilePicture, ourRecipient.address))
|
||||||
@ -218,10 +220,10 @@ open class Storage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getOrGenerateRegistrationID(): Int {
|
override fun getOrGenerateRegistrationID(): Int {
|
||||||
var registrationID = TextSecurePreferences.getLocalRegistrationId(context)
|
var registrationID = context.prefs.getLocalRegistrationId()
|
||||||
if (registrationID == 0) {
|
if (registrationID == 0) {
|
||||||
registrationID = KeyHelper.generateRegistrationId(false)
|
registrationID = KeyHelper.generateRegistrationId(false)
|
||||||
TextSecurePreferences.setLocalRegistrationId(context, registrationID)
|
context.prefs.setLocalRegistrationId(registrationID)
|
||||||
}
|
}
|
||||||
return registrationID
|
return registrationID
|
||||||
}
|
}
|
||||||
@ -478,7 +480,7 @@ open class Storage(
|
|||||||
val profileManager = SSKEnvironment.shared.profileManager
|
val profileManager = SSKEnvironment.shared.profileManager
|
||||||
|
|
||||||
name.takeUnless { it.isEmpty() }?.truncate(NAME_PADDED_LENGTH)?.let {
|
name.takeUnless { it.isEmpty() }?.truncate(NAME_PADDED_LENGTH)?.let {
|
||||||
TextSecurePreferences.setProfileName(context, it)
|
context.prefs.setProfileName(it)
|
||||||
profileManager.setName(context, recipient, it)
|
profileManager.setName(context, recipient, it)
|
||||||
if (it != name) userProfile.setName(it)
|
if (it != name) userProfile.setName(it)
|
||||||
}
|
}
|
||||||
@ -487,7 +489,7 @@ open class Storage(
|
|||||||
if (userPic == UserPic.DEFAULT) {
|
if (userPic == UserPic.DEFAULT) {
|
||||||
clearUserPic()
|
clearUserPic()
|
||||||
} else if (userPic.key.isNotEmpty() && userPic.url.isNotEmpty()
|
} else if (userPic.key.isNotEmpty() && userPic.url.isNotEmpty()
|
||||||
&& TextSecurePreferences.getProfilePictureURL(context) != userPic.url) {
|
&& context.prefs.getProfilePictureURL() != userPic.url) {
|
||||||
setUserProfilePicture(userPic.url, userPic.key)
|
setUserProfilePicture(userPic.url, userPic.key)
|
||||||
}
|
}
|
||||||
if (userProfile.getNtsPriority() == PRIORITY_HIDDEN) {
|
if (userProfile.getNtsPriority() == PRIORITY_HIDDEN) {
|
||||||
@ -523,11 +525,11 @@ open class Storage(
|
|||||||
// would love to get rid of recipient and context from this
|
// would love to get rid of recipient and context from this
|
||||||
val recipient = Recipient.from(context, fromSerialized(userPublicKey), false)
|
val recipient = Recipient.from(context, fromSerialized(userPublicKey), false)
|
||||||
// clear picture if userPic is null
|
// clear picture if userPic is null
|
||||||
TextSecurePreferences.setProfileKey(context, null)
|
context.prefs.setProfileKey(null)
|
||||||
ProfileKeyUtil.setEncodedProfileKey(context, null)
|
ProfileKeyUtil.setEncodedProfileKey(context, null)
|
||||||
recipientDatabase.setProfileAvatar(recipient, null)
|
recipientDatabase.setProfileAvatar(recipient, null)
|
||||||
TextSecurePreferences.setProfileAvatarId(context, 0)
|
context.prefs.setProfileAvatarId(0)
|
||||||
TextSecurePreferences.setProfilePictureURL(context, null)
|
context.prefs.setProfilePictureURL(null)
|
||||||
|
|
||||||
Recipient.removeCached(fromSerialized(userPublicKey))
|
Recipient.removeCached(fromSerialized(userPublicKey))
|
||||||
configFactory.user?.setPic(UserPic.DEFAULT)
|
configFactory.user?.setPic(UserPic.DEFAULT)
|
||||||
@ -786,7 +788,7 @@ open class Storage(
|
|||||||
// message timestamp and as such we cannot use that to identify the local message.
|
// message timestamp and as such we cannot use that to identify the local message.
|
||||||
override fun markAsSentToCommunity(threadId: Long, messageID: Long) {
|
override fun markAsSentToCommunity(threadId: Long, messageID: Long) {
|
||||||
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
||||||
val message = database.getLastSentMessageRecordFromSender(threadId, TextSecurePreferences.getLocalNumber(context))
|
val message = database.getLastSentMessageRecordFromSender(threadId, context.prefs.getLocalNumber())
|
||||||
|
|
||||||
// Ensure we can find the local message..
|
// Ensure we can find the local message..
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
@ -851,7 +853,7 @@ open class Storage(
|
|||||||
// modifies the message timestamp and as such we cannot use that to identify the local message.
|
// modifies the message timestamp and as such we cannot use that to identify the local message.
|
||||||
override fun markUnidentifiedInCommunity(threadId: Long, messageId: Long) {
|
override fun markUnidentifiedInCommunity(threadId: Long, messageId: Long) {
|
||||||
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
||||||
val message = database.getLastSentMessageRecordFromSender(threadId, TextSecurePreferences.getLocalNumber(context))
|
val message = database.getLastSentMessageRecordFromSender(threadId, context.prefs.getLocalNumber())
|
||||||
|
|
||||||
// Check to ensure the message exists
|
// Check to ensure the message exists
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
|
@ -31,6 +31,7 @@ import androidx.annotation.Nullable;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import net.zetetic.database.sqlcipher.SQLiteDatabase;
|
import net.zetetic.database.sqlcipher.SQLiteDatabase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.snode.SnodeAPI;
|
import org.session.libsession.snode.SnodeAPI;
|
||||||
import org.session.libsession.utilities.Address;
|
import org.session.libsession.utilities.Address;
|
||||||
import org.session.libsession.utilities.Contact;
|
import org.session.libsession.utilities.Contact;
|
||||||
@ -924,7 +925,7 @@ public class ThreadDatabase extends Database {
|
|||||||
Uri snippetUri = getSnippetUri(cursor);
|
Uri snippetUri = getSnippetUri(cursor);
|
||||||
boolean pinned = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.IS_PINNED)) != 0;
|
boolean pinned = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.IS_PINNED)) != 0;
|
||||||
|
|
||||||
if (!TextSecurePreferences.isReadReceiptsEnabled(context)) {
|
if (!MessagingModuleConfiguration.getShared().getPrefs().isReadReceiptsEnabled()) {
|
||||||
readReceiptCount = 0;
|
readReceiptCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import net.zetetic.database.sqlcipher.SQLiteDatabase;
|
|||||||
import net.zetetic.database.sqlcipher.SQLiteDatabaseHook;
|
import net.zetetic.database.sqlcipher.SQLiteDatabaseHook;
|
||||||
import net.zetetic.database.sqlcipher.SQLiteOpenHelper;
|
import net.zetetic.database.sqlcipher.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
|
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
|
||||||
@ -125,9 +126,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||||||
// if not vacuumed in a while, perform that operation
|
// if not vacuumed in a while, perform that operation
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
// 7 days
|
// 7 days
|
||||||
if (currentTime - TextSecurePreferences.getLastVacuumTime(context) > 604_800_000) {
|
if (currentTime - MessagingModuleConfiguration.getShared().getPrefs().getLastVacuumTime() > 604_800_000) {
|
||||||
connection.execute("VACUUM;", null, null);
|
connection.execute("VACUUM;", null, null);
|
||||||
TextSecurePreferences.setLastVacuumNow(context);
|
MessagingModuleConfiguration.getShared().getPrefs().setLastVacuumNow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.repository.DefaultConversationRepository
|
|||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
abstract class AppModule {
|
abstract class AppModule {
|
||||||
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
abstract fun bindConversationRepository(repository: DefaultConversationRepository): ConversationRepository
|
abstract fun bindConversationRepository(repository: DefaultConversationRepository): ConversationRepository
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,11 @@ import network.loki.messenger.libsession_util.Contacts
|
|||||||
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
||||||
import network.loki.messenger.libsession_util.UserGroupsConfig
|
import network.loki.messenger.libsession_util.UserGroupsConfig
|
||||||
import network.loki.messenger.libsession_util.UserProfile
|
import network.loki.messenger.libsession_util.UserProfile
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.ConfigFactoryProtocol
|
import org.session.libsession.utilities.ConfigFactoryProtocol
|
||||||
import org.session.libsession.utilities.ConfigFactoryUpdateListener
|
import org.session.libsession.utilities.ConfigFactoryUpdateListener
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.protos.SignalServiceProtos.SharedConfigMessage
|
import org.session.libsignal.protos.SignalServiceProtos.SharedConfigMessage
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.thoughtcrime.securesms.database.ConfigDatabase
|
import org.thoughtcrime.securesms.database.ConfigDatabase
|
||||||
@ -49,7 +51,7 @@ class ConfigFactory(
|
|||||||
private val userGroupsLock = Object()
|
private val userGroupsLock = Object()
|
||||||
private var _userGroups: UserGroupsConfig? = null
|
private var _userGroups: UserGroupsConfig? = null
|
||||||
|
|
||||||
private val isConfigForcedOn by lazy { TextSecurePreferences.hasForcedNewConfig(context) }
|
private val isConfigForcedOn by lazy { context.prefs.hasForcedNewConfig() }
|
||||||
|
|
||||||
private val listeners: MutableList<ConfigFactoryUpdateListener> = mutableListOf()
|
private val listeners: MutableList<ConfigFactoryUpdateListener> = mutableListOf()
|
||||||
fun registerListener(listener: ConfigFactoryUpdateListener) {
|
fun registerListener(listener: ConfigFactoryUpdateListener) {
|
||||||
|
@ -8,6 +8,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
|||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import org.session.libsession.database.MessageDataProvider
|
import org.session.libsession.database.MessageDataProvider
|
||||||
import org.session.libsession.utilities.SSKEnvironment
|
import org.session.libsession.utilities.SSKEnvironment
|
||||||
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachmentProvider
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachmentProvider
|
||||||
import org.thoughtcrime.securesms.crypto.AttachmentSecret
|
import org.thoughtcrime.securesms.crypto.AttachmentSecret
|
||||||
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider
|
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider
|
||||||
@ -32,12 +33,12 @@ object DatabaseModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideAttachmentSecret(@ApplicationContext context: Context) = AttachmentSecretProvider.getInstance(context).orCreateAttachmentSecret
|
fun provideAttachmentSecret(@ApplicationContext context: Context) = AttachmentSecretProvider.getInstance().orCreateAttachmentSecret
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideOpenHelper(@ApplicationContext context: Context): SQLCipherOpenHelper {
|
fun provideOpenHelper(@ApplicationContext context: Context, prefs: TextSecurePreferences): SQLCipherOpenHelper {
|
||||||
val dbSecret = DatabaseSecretProvider(context).orCreateDatabaseSecret
|
val dbSecret = DatabaseSecretProvider(prefs).orCreateDatabaseSecret
|
||||||
SQLCipherOpenHelper.migrateSqlCipher3To4IfNeeded(context, dbSecret)
|
SQLCipherOpenHelper.migrateSqlCipher3To4IfNeeded(context, dbSecret)
|
||||||
return SQLCipherOpenHelper(context, dbSecret)
|
return SQLCipherOpenHelper(context, dbSecret)
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,10 @@ import dagger.Provides
|
|||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.ConfigFactoryUpdateListener
|
import org.session.libsession.utilities.ConfigFactoryUpdateListener
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.crypto.KeyPairUtilities
|
import org.thoughtcrime.securesms.crypto.KeyPairUtilities
|
||||||
import org.thoughtcrime.securesms.database.ConfigDatabase
|
import org.thoughtcrime.securesms.database.ConfigDatabase
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@ -25,7 +27,7 @@ object SessionUtilModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
fun provideConfigFactory(@ApplicationContext context: Context, configDatabase: ConfigDatabase): ConfigFactory =
|
fun provideConfigFactory(@ApplicationContext context: Context, configDatabase: ConfigDatabase): ConfigFactory =
|
||||||
ConfigFactory(context, configDatabase) {
|
ConfigFactory(context, configDatabase) {
|
||||||
val localUserPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val localUserPublicKey = context.prefs.getLocalNumber()
|
||||||
val secretKey = maybeUserEdSecretKey(context)
|
val secretKey = maybeUserEdSecretKey(context)
|
||||||
if (localUserPublicKey == null || secretKey == null) null
|
if (localUserPublicKey == null || secretKey == null) null
|
||||||
else secretKey to localUserPublicKey
|
else secretKey to localUserPublicKey
|
||||||
|
@ -18,6 +18,7 @@ import androidx.viewpager.widget.ViewPager;
|
|||||||
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.MediaTypes;
|
import org.session.libsession.utilities.MediaTypes;
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
@ -59,7 +60,7 @@ public class GiphyActivity extends PassphraseRequiredActionBarActivity
|
|||||||
GiphyActivityToolbar toolbar = ViewUtil.findById(this, R.id.giphy_toolbar);
|
GiphyActivityToolbar toolbar = ViewUtil.findById(this, R.id.giphy_toolbar);
|
||||||
toolbar.setOnFilterChangedListener(this);
|
toolbar.setOnFilterChangedListener(this);
|
||||||
toolbar.setOnLayoutChangedListener(this);
|
toolbar.setOnLayoutChangedListener(this);
|
||||||
toolbar.setPersistence(GiphyActivityToolbarTextSecurePreferencesPersistence.fromContext(this));
|
toolbar.setPersistence(new GiphyActivityToolbarTextSecurePreferencesPersistence());
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.giph.ui;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
|
||||||
|
|
||||||
class GiphyActivityToolbarTextSecurePreferencesPersistence implements GiphyActivityToolbar.Persistence {
|
|
||||||
|
|
||||||
static GiphyActivityToolbar.Persistence fromContext(Context context) {
|
|
||||||
return new GiphyActivityToolbarTextSecurePreferencesPersistence(context.getApplicationContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Context context;
|
|
||||||
|
|
||||||
private GiphyActivityToolbarTextSecurePreferencesPersistence(Context context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getGridSelected() {
|
|
||||||
return TextSecurePreferences.isGifSearchInGridLayout(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGridSelected(boolean isGridSelected) {
|
|
||||||
TextSecurePreferences.setIsGifSearchInGridLayout(context, isGridSelected);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package org.thoughtcrime.securesms.giph.ui
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration.Companion.shared
|
||||||
|
import org.thoughtcrime.securesms.giph.ui.GiphyActivityToolbar.Persistence
|
||||||
|
|
||||||
|
class GiphyActivityToolbarTextSecurePreferencesPersistence: Persistence {
|
||||||
|
override fun getGridSelected(): Boolean = shared.prefs.isGifSearchInGridLayout()
|
||||||
|
override fun setGridSelected(isGridSelected: Boolean) = shared.prefs.setIsGifSearchInGridLayout(isGridSelected)
|
||||||
|
}
|
@ -16,11 +16,11 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.thoughtcrime.securesms.giph.model.GiphyImage;
|
import org.thoughtcrime.securesms.giph.model.GiphyImage;
|
||||||
import org.thoughtcrime.securesms.giph.net.GiphyLoader;
|
import org.thoughtcrime.securesms.giph.net.GiphyLoader;
|
||||||
import org.thoughtcrime.securesms.giph.util.InfiniteScrollListener;
|
import org.thoughtcrime.securesms.giph.util.InfiniteScrollListener;
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
|
||||||
import org.session.libsession.utilities.ViewUtil;
|
import org.session.libsession.utilities.ViewUtil;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -57,7 +57,7 @@ public abstract class GiphyFragment extends Fragment implements LoaderManager.Lo
|
|||||||
this.giphyAdapter = new GiphyAdapter(getActivity(), GlideApp.with(this), new LinkedList<>());
|
this.giphyAdapter = new GiphyAdapter(getActivity(), GlideApp.with(this), new LinkedList<>());
|
||||||
this.giphyAdapter.setListener(this);
|
this.giphyAdapter.setListener(this);
|
||||||
|
|
||||||
setLayoutManager(TextSecurePreferences.isGifSearchInGridLayout(getContext()));
|
setLayoutManager(MessagingModuleConfiguration.getShared().getPrefs().isGifSearchInGridLayout());
|
||||||
this.recyclerView.setItemAnimator(new DefaultItemAnimator());
|
this.recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||||
this.recyclerView.setAdapter(giphyAdapter);
|
this.recyclerView.setAdapter(giphyAdapter);
|
||||||
this.recyclerView.addOnScrollListener(new GiphyScrollListener());
|
this.recyclerView.addOnScrollListener(new GiphyScrollListener());
|
||||||
|
@ -18,11 +18,13 @@ import network.loki.messenger.R
|
|||||||
import network.loki.messenger.databinding.FragmentCreateGroupBinding
|
import network.loki.messenger.databinding.FragmentCreateGroupBinding
|
||||||
import nl.komponents.kovenant.ui.failUi
|
import nl.komponents.kovenant.ui.failUi
|
||||||
import nl.komponents.kovenant.ui.successUi
|
import nl.komponents.kovenant.ui.successUi
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.sending_receiving.MessageSender
|
import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||||
import org.session.libsession.messaging.sending_receiving.groupSizeLimit
|
import org.session.libsession.messaging.sending_receiving.groupSizeLimit
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.Device
|
import org.session.libsession.utilities.Device
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.contacts.SelectContactsAdapter
|
import org.thoughtcrime.securesms.contacts.SelectContactsAdapter
|
||||||
import org.thoughtcrime.securesms.conversation.start.StartConversationDelegate
|
import org.thoughtcrime.securesms.conversation.start.StartConversationDelegate
|
||||||
@ -88,7 +90,7 @@ class CreateGroupFragment : Fragment() {
|
|||||||
if (selectedMembers.count() >= groupSizeLimit) { // Minus one because we're going to include self later
|
if (selectedMembers.count() >= groupSizeLimit) { // Minus one because we're going to include self later
|
||||||
return@setOnClickListener Toast.makeText(context, R.string.activity_create_closed_group_too_many_group_members_error, Toast.LENGTH_LONG).show()
|
return@setOnClickListener Toast.makeText(context, R.string.activity_create_closed_group_too_many_group_members_error, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(requireContext())!!
|
val userPublicKey = requireContext().prefs.getLocalNumber()!!
|
||||||
isLoading = true
|
isLoading = true
|
||||||
binding.loaderContainer.fadeIn()
|
binding.loaderContainer.fadeIn()
|
||||||
MessageSender.createClosedGroup(device, name.toString(), selectedMembers + setOf( userPublicKey )).successUi { groupID ->
|
MessageSender.createClosedGroup(device, name.toString(), selectedMembers + setOf( userPublicKey )).successUi { groupID ->
|
||||||
|
@ -22,12 +22,14 @@ import nl.komponents.kovenant.Promise
|
|||||||
import nl.komponents.kovenant.task
|
import nl.komponents.kovenant.task
|
||||||
import nl.komponents.kovenant.ui.failUi
|
import nl.komponents.kovenant.ui.failUi
|
||||||
import nl.komponents.kovenant.ui.successUi
|
import nl.komponents.kovenant.ui.successUi
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.sending_receiving.MessageSender
|
import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||||
import org.session.libsession.messaging.sending_receiving.groupSizeLimit
|
import org.session.libsession.messaging.sending_receiving.groupSizeLimit
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.GroupUtil
|
import org.session.libsession.utilities.GroupUtil
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.ThemeUtil
|
import org.session.libsession.utilities.ThemeUtil
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.session.libsignal.utilities.toHexString
|
import org.session.libsignal.utilities.toHexString
|
||||||
@ -107,7 +109,7 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
groupID = intent.getStringExtra(groupIDKey)!!
|
groupID = intent.getStringExtra(groupIDKey)!!
|
||||||
val groupInfo = DatabaseComponent.get(this).groupDatabase().getGroup(groupID).get()
|
val groupInfo = DatabaseComponent.get(this).groupDatabase().getGroup(groupID).get()
|
||||||
originalName = groupInfo.title
|
originalName = groupInfo.title
|
||||||
isSelfAdmin = groupInfo.admins.any{ it.serialize() == TextSecurePreferences.getLocalNumber(this) }
|
isSelfAdmin = groupInfo.admins.any{ it.serialize() == prefs.getLocalNumber() }
|
||||||
|
|
||||||
name = originalName
|
name = originalName
|
||||||
|
|
||||||
@ -291,7 +293,7 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
return Toast.makeText(this, R.string.activity_create_closed_group_too_many_group_members_error, Toast.LENGTH_LONG).show()
|
return Toast.makeText(this, R.string.activity_create_closed_group_too_many_group_members_error, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(this)!!
|
val userPublicKey = prefs.getLocalNumber()!!
|
||||||
val userAsRecipient = Recipient.from(this, Address.fromSerialized(userPublicKey), false)
|
val userAsRecipient = Recipient.from(this, Address.fromSerialized(userPublicKey), false)
|
||||||
|
|
||||||
if (!members.contains(userAsRecipient) && !members.map { it.address.toString() }.containsAll(originalMembers.minus(userPublicKey))) {
|
if (!members.contains(userAsRecipient) && !members.map { it.address.toString() }.containsAll(originalMembers.minus(userPublicKey))) {
|
||||||
|
@ -3,11 +3,13 @@ package org.thoughtcrime.securesms.groups
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.thoughtcrime.securesms.contacts.UserView
|
import org.thoughtcrime.securesms.contacts.UserView
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
|
|
||||||
class EditClosedGroupMembersAdapter(
|
class EditClosedGroupMembersAdapter(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
@ -41,7 +43,7 @@ class EditClosedGroupMembersAdapter(
|
|||||||
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
|
||||||
val member = members[position]
|
val member = members[position]
|
||||||
|
|
||||||
val unlocked = admin && member != TextSecurePreferences.getLocalNumber(context)
|
val unlocked = admin && member != context.prefs.getLocalNumber()
|
||||||
|
|
||||||
viewHolder.view.bind(Recipient.from(
|
viewHolder.view.bind(Recipient.from(
|
||||||
context,
|
context,
|
||||||
|
@ -56,7 +56,7 @@ public class GroupManager {
|
|||||||
final Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(groupId), false);
|
final Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(groupId), false);
|
||||||
final Set<Address> memberAddresses = new HashSet<>();
|
final Set<Address> memberAddresses = new HashSet<>();
|
||||||
|
|
||||||
memberAddresses.add(Address.fromSerialized(Objects.requireNonNull(TextSecurePreferences.getLocalNumber(context))));
|
memberAddresses.add(Address.fromSerialized(Objects.requireNonNull(MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber())));
|
||||||
groupDatabase.create(groupId, name, new LinkedList<>(memberAddresses), null, null, new LinkedList<>(), System.currentTimeMillis());
|
groupDatabase.create(groupId, name, new LinkedList<>(memberAddresses), null, null, new LinkedList<>(), System.currentTimeMillis());
|
||||||
|
|
||||||
groupDatabase.updateProfilePicture(groupId, avatarBytes);
|
groupDatabase.updateProfilePicture(groupId, avatarBytes);
|
||||||
|
@ -38,6 +38,7 @@ import org.session.libsession.utilities.Address
|
|||||||
import org.session.libsession.utilities.GroupUtil
|
import org.session.libsession.utilities.GroupUtil
|
||||||
import org.session.libsession.utilities.ProfilePictureModifiedEvent
|
import org.session.libsession.utilities.ProfilePictureModifiedEvent
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.session.libsignal.utilities.ThreadUtils
|
import org.session.libsignal.utilities.ThreadUtils
|
||||||
@ -324,7 +325,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
binding.sessionToolbar.isVisible = !isShown
|
binding.sessionToolbar.isVisible = !isShown
|
||||||
binding.recyclerView.isVisible = !isShown
|
binding.recyclerView.isVisible = !isShown
|
||||||
binding.emptyStateContainer.isVisible = (binding.recyclerView.adapter as HomeAdapter).itemCount == 0 && binding.recyclerView.isVisible
|
binding.emptyStateContainer.isVisible = (binding.recyclerView.adapter as HomeAdapter).itemCount == 0 && binding.recyclerView.isVisible
|
||||||
binding.seedReminderView.isVisible = !TextSecurePreferences.getHasViewedSeed(this) && !isShown
|
binding.seedReminderView.isVisible = !prefs.getHasViewedSeed() && !isShown
|
||||||
binding.globalSearchRecycler.isInvisible = !isShown
|
binding.globalSearchRecycler.isInvisible = !isShown
|
||||||
binding.newConversationButton.isVisible = !isShown
|
binding.newConversationButton.isVisible = !isShown
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.thoughtcrime.securesms.crypto.KeyStoreHelper;
|
import org.thoughtcrime.securesms.crypto.KeyStoreHelper;
|
||||||
import org.session.libsignal.utilities.Base64;
|
import org.session.libsignal.utilities.Base64;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
@ -14,8 +15,8 @@ import java.security.SecureRandom;
|
|||||||
class LogSecretProvider {
|
class LogSecretProvider {
|
||||||
|
|
||||||
static byte[] getOrCreateAttachmentSecret(@NonNull Context context) {
|
static byte[] getOrCreateAttachmentSecret(@NonNull Context context) {
|
||||||
String unencryptedSecret = TextSecurePreferences.getLogUnencryptedSecret(context);
|
String unencryptedSecret = MessagingModuleConfiguration.getShared().getPrefs().getLogUnencryptedSecret();
|
||||||
String encryptedSecret = TextSecurePreferences.getLogEncryptedSecret(context);
|
String encryptedSecret = MessagingModuleConfiguration.getShared().getPrefs().getLogEncryptedSecret();
|
||||||
|
|
||||||
if (unencryptedSecret != null) return parseUnencryptedSecret(unencryptedSecret);
|
if (unencryptedSecret != null) return parseUnencryptedSecret(unencryptedSecret);
|
||||||
else if (encryptedSecret != null) return parseEncryptedSecret(encryptedSecret);
|
else if (encryptedSecret != null) return parseEncryptedSecret(encryptedSecret);
|
||||||
@ -44,12 +45,8 @@ class LogSecretProvider {
|
|||||||
byte[] secret = new byte[32];
|
byte[] secret = new byte[32];
|
||||||
random.nextBytes(secret);
|
random.nextBytes(secret);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(secret);
|
||||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(secret);
|
MessagingModuleConfiguration.getShared().getPrefs().setLogEncryptedSecret(encryptedSecret.serialize());
|
||||||
TextSecurePreferences.setLogEncryptedSecret(context, encryptedSecret.serialize());
|
|
||||||
} else {
|
|
||||||
TextSecurePreferences.setLogUnencryptedSecret(context, Base64.encodeBytes(secret));
|
|
||||||
}
|
|
||||||
|
|
||||||
return secret;
|
return secret;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@ import com.bumptech.glide.request.target.SimpleTarget;
|
|||||||
import com.bumptech.glide.request.transition.Transition;
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||||
import org.session.libsession.utilities.ServiceUtil;
|
import org.session.libsession.utilities.ServiceUtil;
|
||||||
@ -78,7 +80,7 @@ public class Camera1Fragment extends Fragment implements TextureView.SurfaceText
|
|||||||
display.getSize(displaySize);
|
display.getSize(displaySize);
|
||||||
|
|
||||||
controller = (Controller) getActivity();
|
controller = (Controller) getActivity();
|
||||||
camera = new Camera1Controller(TextSecurePreferences.getDirectCaptureCameraId(getContext()), displaySize.x, displaySize.y, this);
|
camera = new Camera1Controller(MessagingModuleConfiguration.getShared().getPrefs().getDirectCaptureCameraId(), displaySize.x, displaySize.y, this);
|
||||||
orderEnforcer = new OrderEnforcer<>(Stage.SURFACE_AVAILABLE, Stage.CAMERA_PROPERTIES_AVAILABLE);
|
orderEnforcer = new OrderEnforcer<>(Stage.SURFACE_AVAILABLE, Stage.CAMERA_PROPERTIES_AVAILABLE);
|
||||||
viewModel = new ViewModelProvider(requireActivity(), new MediaSendViewModel.Factory(requireActivity().getApplication(), new MediaRepository())).get(MediaSendViewModel.class);
|
viewModel = new ViewModelProvider(requireActivity(), new MediaSendViewModel.Factory(requireActivity().getApplication(), new MediaRepository())).get(MediaSendViewModel.class);
|
||||||
}
|
}
|
||||||
@ -212,7 +214,7 @@ public class Camera1Fragment extends Fragment implements TextureView.SurfaceText
|
|||||||
flipButton.setVisibility(properties.getCameraCount() > 1 ? View.VISIBLE : View.GONE);
|
flipButton.setVisibility(properties.getCameraCount() > 1 ? View.VISIBLE : View.GONE);
|
||||||
flipButton.setOnClickListener(v -> {
|
flipButton.setOnClickListener(v -> {
|
||||||
int newCameraId = camera.flip();
|
int newCameraId = camera.flip();
|
||||||
TextSecurePreferences.setDirectCaptureCameraId(getContext(), newCameraId);
|
MessagingModuleConfiguration.getShared().getPrefs().setDirectCaptureCameraId(newCameraId);
|
||||||
|
|
||||||
Animation animation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
|
Animation animation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
|
||||||
animation.setDuration(200);
|
animation.setDuration(200);
|
||||||
|
@ -28,6 +28,7 @@ import android.view.inputmethod.EditorInfo;
|
|||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.MediaTypes;
|
import org.session.libsession.utilities.MediaTypes;
|
||||||
import org.thoughtcrime.securesms.components.ComposeText;
|
import org.thoughtcrime.securesms.components.ComposeText;
|
||||||
import org.thoughtcrime.securesms.components.ControllableViewPager;
|
import org.thoughtcrime.securesms.components.ControllableViewPager;
|
||||||
@ -50,7 +51,6 @@ import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
|||||||
import org.thoughtcrime.securesms.util.Stopwatch;
|
import org.thoughtcrime.securesms.util.Stopwatch;
|
||||||
import org.session.libsignal.utilities.guava.Optional;
|
import org.session.libsignal.utilities.guava.Optional;
|
||||||
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
|
||||||
import org.session.libsession.utilities.Util;
|
import org.session.libsession.utilities.Util;
|
||||||
import org.session.libsession.utilities.Stub;
|
import org.session.libsession.utilities.Stub;
|
||||||
import org.session.libsignal.utilities.ListenableFuture;
|
import org.session.libsignal.utilities.ListenableFuture;
|
||||||
@ -215,7 +215,7 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
return isSend;
|
return isSend;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (TextSecurePreferences.isSystemEmojiPreferred(getContext())) {
|
if (MessagingModuleConfiguration.getShared().getPrefs().isSystemEmojiPreferred()) {
|
||||||
emojiToggle.setVisibility(View.GONE);
|
emojiToggle.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
emojiToggle.setOnClickListener(this::onEmojiToggleClicked);
|
emojiToggle.setOnClickListener(this::onEmojiToggleClicked);
|
||||||
@ -511,7 +511,7 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||||
if (TextSecurePreferences.isEnterSendsEnabled(requireContext())) {
|
if (MessagingModuleConfiguration.getShared().getPrefs().isEnterSendsEnabled()) {
|
||||||
sendButton.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
|
sendButton.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
|
||||||
sendButton.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER));
|
sendButton.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER));
|
||||||
return true;
|
return true;
|
||||||
|
@ -58,7 +58,7 @@ public class SignalGlideModule extends AppGlideModule {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
|
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
|
||||||
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
|
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance().getOrCreateAttachmentSecret();
|
||||||
byte[] secret = attachmentSecret.getModernKey();
|
byte[] secret = attachmentSecret.getModernKey();
|
||||||
|
|
||||||
registry.prepend(File.class, File.class, UnitModelLoader.Factory.getInstance());
|
registry.prepend(File.class, File.class, UnitModelLoader.Factory.getInstance());
|
||||||
|
@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.NotificationPrivacyPreference;
|
import org.session.libsession.utilities.NotificationPrivacyPreference;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
import org.session.libsession.utilities.Util;
|
import org.session.libsession.utilities.Util;
|
||||||
@ -50,8 +51,8 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAlarms(@Nullable Uri ringtone, VibrateState vibrate) {
|
public void setAlarms(@Nullable Uri ringtone, VibrateState vibrate) {
|
||||||
Uri defaultRingtone = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context) : TextSecurePreferences.getNotificationRingtone(context);
|
Uri defaultRingtone = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context) : MessagingModuleConfiguration.getShared().getPrefs().getNotificationRingtone();
|
||||||
boolean defaultVibrate = NotificationChannels.supported() ? NotificationChannels.getMessageVibrate(context) : TextSecurePreferences.isNotificationVibrateEnabled(context);
|
boolean defaultVibrate = NotificationChannels.supported() ? NotificationChannels.getMessageVibrate(context) : MessagingModuleConfiguration.getShared().getPrefs().isNotificationVibrateEnabled();
|
||||||
|
|
||||||
if (ringtone == null && !TextUtils.isEmpty(defaultRingtone.toString())) setSound(defaultRingtone);
|
if (ringtone == null && !TextUtils.isEmpty(defaultRingtone.toString())) setSound(defaultRingtone);
|
||||||
else if (ringtone != null && !ringtone.toString().isEmpty()) setSound(ringtone);
|
else if (ringtone != null && !ringtone.toString().isEmpty()) setSound(ringtone);
|
||||||
@ -64,7 +65,7 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setLed() {
|
private void setLed() {
|
||||||
int ledColor = TextSecurePreferences.getNotificationLedColor(context);
|
int ledColor = MessagingModuleConfiguration.getShared().getPrefs().getNotificationLedColor();
|
||||||
setLights(ledColor, 500,2000);
|
setLights(ledColor, 500,2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import org.session.libsession.messaging.sending_receiving.pollers.ClosedGroupPol
|
|||||||
import org.session.libsession.messaging.sending_receiving.pollers.OpenGroupPoller
|
import org.session.libsession.messaging.sending_receiving.pollers.OpenGroupPoller
|
||||||
import org.session.libsession.snode.SnodeAPI
|
import org.session.libsession.snode.SnodeAPI
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.session.libsignal.utilities.recover
|
import org.session.libsignal.utilities.recover
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
@ -76,7 +77,7 @@ class BackgroundPollWorker(val context: Context, params: WorkerParameters) : Wor
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
if (TextSecurePreferences.getLocalNumber(context) == null) {
|
if (MessagingModuleConfiguration.shared.prefs.getLocalNumber() == null) {
|
||||||
Log.v(TAG, "User not registered yet.")
|
Log.v(TAG, "User not registered yet.")
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
}
|
}
|
||||||
@ -108,7 +109,7 @@ class BackgroundPollWorker(val context: Context, params: WorkerParameters) : Wor
|
|||||||
var dmsPromise: Promise<Unit, Exception> = Promise.ofSuccess(Unit)
|
var dmsPromise: Promise<Unit, Exception> = Promise.ofSuccess(Unit)
|
||||||
|
|
||||||
if (requestTargets.contains(Targets.DMS)) {
|
if (requestTargets.contains(Targets.DMS)) {
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
val userPublicKey = context.prefs.getLocalNumber()!!
|
||||||
dmsPromise = SnodeAPI.getMessages(userPublicKey).bind { envelopes ->
|
dmsPromise = SnodeAPI.getMessages(userPublicKey).bind { envelopes ->
|
||||||
val params = envelopes.map { (envelope, serverHash) ->
|
val params = envelopes.map { (envelope, serverHash) ->
|
||||||
// FIXME: Using a job here seems like a bad idea...
|
// FIXME: Using a job here seems like a bad idea...
|
||||||
|
@ -40,6 +40,7 @@ import com.annimon.stream.Optional;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import com.goterl.lazysodium.utils.KeyPair;
|
import com.goterl.lazysodium.utils.KeyPair;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.messaging.open_groups.OpenGroup;
|
import org.session.libsession.messaging.open_groups.OpenGroup;
|
||||||
import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier;
|
import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier;
|
||||||
import org.session.libsession.messaging.utilities.AccountId;
|
import org.session.libsession.messaging.utilities.AccountId;
|
||||||
@ -138,18 +139,18 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
intent.putExtra(ConversationActivityV2.THREAD_ID, threadId);
|
intent.putExtra(ConversationActivityV2.THREAD_ID, threadId);
|
||||||
intent.setData((Uri.parse("custom://" + SnodeAPI.getNowWithOffset())));
|
intent.setData((Uri.parse("custom://" + SnodeAPI.getNowWithOffset())));
|
||||||
|
|
||||||
FailedNotificationBuilder builder = new FailedNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context), intent);
|
FailedNotificationBuilder builder = new FailedNotificationBuilder(context, MessagingModuleConfiguration.getShared().getPrefs().getNotificationPrivacy(), intent);
|
||||||
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
||||||
.notify((int)threadId, builder.build());
|
.notify((int)threadId, builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyMessagesPending(Context context) {
|
public void notifyMessagesPending(Context context) {
|
||||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
if (!MessagingModuleConfiguration.getShared().getPrefs().isNotificationsEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingMessageNotificationBuilder builder = new PendingMessageNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context));
|
PendingMessageNotificationBuilder builder = new PendingMessageNotificationBuilder(context, MessagingModuleConfiguration.getShared().getPrefs().getNotificationPrivacy());
|
||||||
ServiceUtil.getNotificationManager(context).notify(PENDING_MESSAGES_ID, builder.build());
|
ServiceUtil.getNotificationManager(context).notify(PENDING_MESSAGES_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +211,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNotification(@NonNull Context context) {
|
public void updateNotification(@NonNull Context context) {
|
||||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
if (!MessagingModuleConfiguration.getShared().getPrefs().isNotificationsEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,10 +239,10 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
|
|
||||||
if (recipient != null && !recipient.isGroupRecipient() && threads.getMessageCount(threadId) == 1 &&
|
if (recipient != null && !recipient.isGroupRecipient() && threads.getMessageCount(threadId) == 1 &&
|
||||||
!(recipient.isApproved() || threads.getLastSeenAndHasSent(threadId).second())) {
|
!(recipient.isApproved() || threads.getLastSeenAndHasSent(threadId).second())) {
|
||||||
TextSecurePreferences.removeHasHiddenMessageRequests(context);
|
MessagingModuleConfiguration.getShared().getPrefs().removeHasHiddenMessageRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextSecurePreferences.isNotificationsEnabled(context) ||
|
if (!MessagingModuleConfiguration.getShared().getPrefs().isNotificationsEnabled() ||
|
||||||
(recipient != null && recipient.isMuted()))
|
(recipient != null && recipient.isMuted()))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -271,7 +272,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
try {
|
try {
|
||||||
telcoCursor = DatabaseComponent.get(context).mmsSmsDatabase().getUnread(); // TODO: add a notification specific lighter query here
|
telcoCursor = DatabaseComponent.get(context).mmsSmsDatabase().getUnread(); // TODO: add a notification specific lighter query here
|
||||||
|
|
||||||
if ((telcoCursor == null || telcoCursor.isAfterLast()) || TextSecurePreferences.getLocalNumber(context) == null)
|
if ((telcoCursor == null || telcoCursor.isAfterLast()) || MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber() == null)
|
||||||
{
|
{
|
||||||
updateBadge(context, 0);
|
updateBadge(context, 0);
|
||||||
cancelActiveNotifications(context);
|
cancelActiveNotifications(context);
|
||||||
@ -324,7 +325,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context));
|
SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, MessagingModuleConfiguration.getShared().getPrefs().getNotificationPrivacy());
|
||||||
List<NotificationItem> notifications = notificationState.getNotifications();
|
List<NotificationItem> notifications = notificationState.getNotifications();
|
||||||
Recipient recipient = notifications.get(0).getRecipient();
|
Recipient recipient = notifications.get(0).getRecipient();
|
||||||
int notificationId = (int) (SUMMARY_NOTIFICATION_ID + (bundled ? notifications.get(0).getThreadId() : 0));
|
int notificationId = (int) (SUMMARY_NOTIFICATION_ID + (bundled ? notifications.get(0).getThreadId() : 0));
|
||||||
@ -411,7 +412,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
{
|
{
|
||||||
Log.i(TAG, "sendMultiThreadNotification() signal: " + signal);
|
Log.i(TAG, "sendMultiThreadNotification() signal: " + signal);
|
||||||
|
|
||||||
MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context));
|
MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, MessagingModuleConfiguration.getShared().getPrefs().getNotificationPrivacy());
|
||||||
List<NotificationItem> notifications = notificationState.getNotifications();
|
List<NotificationItem> notifications = notificationState.getNotifications();
|
||||||
|
|
||||||
builder.setMessageCount(notificationState.getMessageCount(), notificationState.getThreadCount());
|
builder.setMessageCount(notificationState.getMessageCount(), notificationState.getThreadCount());
|
||||||
@ -501,7 +502,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
threadRecipients = threadDatabase.getRecipientForThreadId(threadId);
|
threadRecipients = threadDatabase.getRecipientForThreadId(threadId);
|
||||||
messageRequest = threadRecipients != null && !threadRecipients.isGroupRecipient() &&
|
messageRequest = threadRecipients != null && !threadRecipients.isGroupRecipient() &&
|
||||||
!threadRecipients.isApproved() && !threadDatabase.getLastSeenAndHasSent(threadId).second();
|
!threadRecipients.isApproved() && !threadDatabase.getLastSeenAndHasSent(threadId).second();
|
||||||
if (messageRequest && (threadDatabase.getMessageCount(threadId) > 1 || !TextSecurePreferences.hasHiddenMessageRequests(context))) {
|
if (messageRequest && (threadDatabase.getMessageCount(threadId) > 1 || !MessagingModuleConfiguration.getShared().getPrefs().hasHiddenMessageRequests())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,7 +524,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
} else if (record.isOpenGroupInvitation()) {
|
} else if (record.isOpenGroupInvitation()) {
|
||||||
body = SpanUtil.italic(context.getString(R.string.ThreadRecord_open_group_invitation));
|
body = SpanUtil.italic(context.getString(R.string.ThreadRecord_open_group_invitation));
|
||||||
}
|
}
|
||||||
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
String userPublicKey = MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber();
|
||||||
String blindedPublicKey = cache.get(threadId);
|
String blindedPublicKey = cache.get(threadId);
|
||||||
if (blindedPublicKey == null) {
|
if (blindedPublicKey == null) {
|
||||||
blindedPublicKey = generateBlindedId(threadId, context);
|
blindedPublicKey = generateBlindedId(threadId, context);
|
||||||
@ -594,7 +595,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleReminder(Context context, int count) {
|
private void scheduleReminder(Context context, int count) {
|
||||||
if (count >= TextSecurePreferences.getRepeatAlertsCount(context)) {
|
if (count >= MessagingModuleConfiguration.getShared().getPrefs().getRepeatAlertsCount()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,15 +6,14 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.AsyncTask
|
import android.os.AsyncTask
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import org.session.libsession.messaging.MessagingModuleConfiguration.Companion.shared
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.messages.control.ReadReceipt
|
import org.session.libsession.messaging.messages.control.ReadReceipt
|
||||||
import org.session.libsession.messaging.sending_receiving.MessageSender.send
|
import org.session.libsession.messaging.sending_receiving.MessageSender.send
|
||||||
import org.session.libsession.snode.SnodeAPI
|
import org.session.libsession.snode.SnodeAPI
|
||||||
import org.session.libsession.snode.SnodeAPI.nowWithOffset
|
import org.session.libsession.snode.SnodeAPI.nowWithOffset
|
||||||
import org.session.libsession.utilities.SSKEnvironment
|
import org.session.libsession.utilities.SSKEnvironment
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.isReadReceiptsEnabled
|
|
||||||
import org.session.libsession.utilities.associateByNotNull
|
import org.session.libsession.utilities.associateByNotNull
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
@ -35,7 +34,7 @@ class MarkReadReceiver : BroadcastReceiver() {
|
|||||||
val currentTime = nowWithOffset
|
val currentTime = nowWithOffset
|
||||||
threadIds.forEach {
|
threadIds.forEach {
|
||||||
Log.i(TAG, "Marking as read: $it")
|
Log.i(TAG, "Marking as read: $it")
|
||||||
shared.storage.markConversationAsRead(it, currentTime, true)
|
MessagingModuleConfiguration.shared.storage.markConversationAsRead(it, currentTime, true)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -102,7 +101,7 @@ class MarkReadReceiver : BroadcastReceiver() {
|
|||||||
SnodeAPI.alterTtl(
|
SnodeAPI.alterTtl(
|
||||||
messageHashes = hashes,
|
messageHashes = hashes,
|
||||||
newExpiry = nowWithOffset + expiresIn,
|
newExpiry = nowWithOffset + expiresIn,
|
||||||
publicKey = TextSecurePreferences.getLocalNumber(context)!!,
|
publicKey = context.prefs.getLocalNumber()!!,
|
||||||
shorten = true
|
shorten = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -112,7 +111,7 @@ class MarkReadReceiver : BroadcastReceiver() {
|
|||||||
context: Context,
|
context: Context,
|
||||||
markedReadMessages: List<MarkedMessageInfo>
|
markedReadMessages: List<MarkedMessageInfo>
|
||||||
) {
|
) {
|
||||||
if (!isReadReceiptsEnabled(context)) return
|
if (!context.prefs.isReadReceiptsEnabled()) return
|
||||||
|
|
||||||
markedReadMessages.map { it.syncMessageId }
|
markedReadMessages.map { it.syncMessageId }
|
||||||
.filter { shouldSendReadReceipt(Recipient.from(context, it.address, false)) }
|
.filter { shouldSendReadReceipt(Recipient.from(context, it.address, false)) }
|
||||||
@ -130,7 +129,7 @@ class MarkReadReceiver : BroadcastReceiver() {
|
|||||||
hashToMessage: Map<String, MarkedMessageInfo>
|
hashToMessage: Map<String, MarkedMessageInfo>
|
||||||
) {
|
) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val expiries = SnodeAPI.getExpiries(hashToMessage.keys.toList(), TextSecurePreferences.getLocalNumber(context)!!).get()["expiries"] as Map<String, Long>
|
val expiries = SnodeAPI.getExpiries(hashToMessage.keys.toList(), context.prefs.getLocalNumber()!!).get()["expiries"] as Map<String, Long>
|
||||||
hashToMessage.forEach { (hash, info) -> expiries[hash]?.let { scheduleDeletion(context, info.expirationInfo, it - info.expirationInfo.expireStarted) } }
|
hashToMessage.forEach { (hash, info) -> expiries[hash]?.let { scheduleDeletion(context, info.expirationInfo, it - info.expirationInfo.expireStarted) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.messaging.contacts.Contact;
|
import org.session.libsession.messaging.contacts.Contact;
|
||||||
import org.session.libsession.utilities.NotificationPrivacyPreference;
|
import org.session.libsession.utilities.NotificationPrivacyPreference;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
@ -39,7 +40,7 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
|||||||
setGroupSummary(true);
|
setGroupSummary(true);
|
||||||
|
|
||||||
if (!NotificationChannels.supported()) {
|
if (!NotificationChannels.supported()) {
|
||||||
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
setPriority(MessagingModuleConfiguration.getShared().getPrefs().getNotificationPriority());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import androidx.annotation.WorkerThread;
|
|||||||
import com.annimon.stream.Collectors;
|
import com.annimon.stream.Collectors;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.Address;
|
import org.session.libsession.utilities.Address;
|
||||||
import org.session.libsession.utilities.ServiceUtil;
|
import org.session.libsession.utilities.ServiceUtil;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
@ -69,10 +70,10 @@ public class NotificationChannels {
|
|||||||
|
|
||||||
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
|
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
|
||||||
|
|
||||||
int oldVersion = TextSecurePreferences.getNotificationChannelVersion(context);
|
int oldVersion = MessagingModuleConfiguration.getShared().getPrefs().getNotificationChannelVersion();
|
||||||
if (oldVersion != VERSION) {
|
if (oldVersion != VERSION) {
|
||||||
onUpgrade(notificationManager, oldVersion, VERSION);
|
onUpgrade(notificationManager, oldVersion, VERSION);
|
||||||
TextSecurePreferences.setNotificationChannelVersion(context, VERSION);
|
MessagingModuleConfiguration.getShared().getPrefs().setNotificationChannelVersion(VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCreate(context, notificationManager);
|
onCreate(context, notificationManager);
|
||||||
@ -112,7 +113,7 @@ public class NotificationChannels {
|
|||||||
* @return The channel ID for the default messages channel.
|
* @return The channel ID for the default messages channel.
|
||||||
*/
|
*/
|
||||||
public static synchronized @NonNull String getMessagesChannel(@NonNull Context context) {
|
public static synchronized @NonNull String getMessagesChannel(@NonNull Context context) {
|
||||||
return getMessagesChannelId(TextSecurePreferences.getNotificationMessagesChannelVersion(context));
|
return getMessagesChannelId(MessagingModuleConfiguration.getShared().getPrefs().getNotificationMessagesChannelVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,7 +144,7 @@ public class NotificationChannels {
|
|||||||
*/
|
*/
|
||||||
public static synchronized String createChannelFor(@NonNull Context context, @NonNull Recipient recipient) {
|
public static synchronized String createChannelFor(@NonNull Context context, @NonNull Recipient recipient) {
|
||||||
VibrateState vibrateState = recipient.getMessageVibrate();
|
VibrateState vibrateState = recipient.getMessageVibrate();
|
||||||
boolean vibrationEnabled = vibrateState == VibrateState.DEFAULT ? TextSecurePreferences.isNotificationVibrateEnabled(context) : vibrateState == VibrateState.ENABLED;
|
boolean vibrationEnabled = vibrateState == VibrateState.DEFAULT ? MessagingModuleConfiguration.getShared().getPrefs().isNotificationVibrateEnabled() : vibrateState == VibrateState.ENABLED;
|
||||||
Uri messageRingtone = recipient.getMessageRingtone() != null ? recipient.getMessageRingtone() : getMessageRingtone(context);
|
Uri messageRingtone = recipient.getMessageRingtone() != null ? recipient.getMessageRingtone() : getMessageRingtone(context);
|
||||||
String displayName = getChannelDisplayNameFor(context, recipient.getName(), recipient.getProfileName(), recipient.getAddress());
|
String displayName = getChannelDisplayNameFor(context, recipient.getName(), recipient.getProfileName(), recipient.getAddress());
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ public class NotificationChannels {
|
|||||||
String channelId = generateChannelIdFor(address);
|
String channelId = generateChannelIdFor(address);
|
||||||
NotificationChannel channel = new NotificationChannel(channelId, displayName, NotificationManager.IMPORTANCE_HIGH);
|
NotificationChannel channel = new NotificationChannel(channelId, displayName, NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
|
||||||
setLedPreference(channel, TextSecurePreferences.getNotificationLedColor(context));
|
setLedPreference(channel, MessagingModuleConfiguration.getShared().getPrefs().getNotificationLedColor());
|
||||||
channel.setGroup(CATEGORY_MESSAGES);
|
channel.setGroup(CATEGORY_MESSAGES);
|
||||||
channel.enableVibration(vibrationEnabled);
|
channel.enableVibration(vibrationEnabled);
|
||||||
|
|
||||||
@ -434,9 +435,9 @@ public class NotificationChannels {
|
|||||||
NotificationChannel other = new NotificationChannel(OTHER, context.getString(R.string.NotificationChannel_other), NotificationManager.IMPORTANCE_LOW);
|
NotificationChannel other = new NotificationChannel(OTHER, context.getString(R.string.NotificationChannel_other), NotificationManager.IMPORTANCE_LOW);
|
||||||
|
|
||||||
messages.setGroup(CATEGORY_MESSAGES);
|
messages.setGroup(CATEGORY_MESSAGES);
|
||||||
messages.enableVibration(TextSecurePreferences.isNotificationVibrateEnabled(context));
|
messages.enableVibration(MessagingModuleConfiguration.getShared().getPrefs().isNotificationVibrateEnabled());
|
||||||
messages.setSound(TextSecurePreferences.getNotificationRingtone(context), getRingtoneAudioAttributes());
|
messages.setSound(MessagingModuleConfiguration.getShared().getPrefs().getNotificationRingtone(), getRingtoneAudioAttributes());
|
||||||
setLedPreference(messages, TextSecurePreferences.getNotificationLedColor(context));
|
setLedPreference(messages, MessagingModuleConfiguration.getShared().getPrefs().getNotificationLedColor());
|
||||||
|
|
||||||
calls.setShowBadge(false);
|
calls.setShowBadge(false);
|
||||||
calls.setSound(null, null);
|
calls.setSound(null, null);
|
||||||
@ -528,12 +529,12 @@ public class NotificationChannels {
|
|||||||
@TargetApi(26)
|
@TargetApi(26)
|
||||||
private static void updateMessageChannel(@NonNull Context context, @NonNull ChannelUpdater updater) {
|
private static void updateMessageChannel(@NonNull Context context, @NonNull ChannelUpdater updater) {
|
||||||
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
|
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
|
||||||
int existingVersion = TextSecurePreferences.getNotificationMessagesChannelVersion(context);
|
int existingVersion = MessagingModuleConfiguration.getShared().getPrefs().getNotificationMessagesChannelVersion();
|
||||||
int newVersion = existingVersion + 1;
|
int newVersion = existingVersion + 1;
|
||||||
|
|
||||||
Log.i(TAG, "Updating message channel from version " + existingVersion + " to " + newVersion);
|
Log.i(TAG, "Updating message channel from version " + existingVersion + " to " + newVersion);
|
||||||
if (updateExistingChannel(notificationManager, getMessagesChannelId(existingVersion), getMessagesChannelId(newVersion), updater)) {
|
if (updateExistingChannel(notificationManager, getMessagesChannelId(existingVersion), getMessagesChannelId(newVersion), updater)) {
|
||||||
TextSecurePreferences.setNotificationMessagesChannelVersion(context, newVersion);
|
MessagingModuleConfiguration.getShared().getPrefs().setNotificationMessagesChannelVersion(newVersion);
|
||||||
} else {
|
} else {
|
||||||
onCreate(context, notificationManager);
|
onCreate(context, notificationManager);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
|||||||
|
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.NotificationPrivacyPreference;
|
import org.session.libsession.utilities.NotificationPrivacyPreference;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
import org.session.libsession.utilities.recipients.Recipient;
|
import org.session.libsession.utilities.recipients.Recipient;
|
||||||
@ -34,7 +35,7 @@ public class PendingMessageNotificationBuilder extends AbstractNotificationBuild
|
|||||||
setAlarms(null, Recipient.VibrateState.DEFAULT);
|
setAlarms(null, Recipient.VibrateState.DEFAULT);
|
||||||
|
|
||||||
if (!NotificationChannels.supported()) {
|
if (!NotificationChannels.supported()) {
|
||||||
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
setPriority(MessagingModuleConfiguration.getShared().getPrefs().getNotificationPriority());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|||||||
import org.session.libsession.avatars.ContactColors;
|
import org.session.libsession.avatars.ContactColors;
|
||||||
import org.session.libsession.avatars.ContactPhoto;
|
import org.session.libsession.avatars.ContactPhoto;
|
||||||
import org.session.libsession.avatars.GeneratedContactPhoto;
|
import org.session.libsession.avatars.GeneratedContactPhoto;
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.messaging.contacts.Contact;
|
import org.session.libsession.messaging.contacts.Contact;
|
||||||
import org.session.libsession.utilities.NotificationPrivacyPreference;
|
import org.session.libsession.utilities.NotificationPrivacyPreference;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
@ -69,7 +70,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
||||||
|
|
||||||
if (!NotificationChannels.supported()) {
|
if (!NotificationChannels.supported()) {
|
||||||
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
setPriority(MessagingModuleConfiguration.getShared().getPrefs().getNotificationPriority());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.thoughtcrime.securesms.notifications
|
package org.thoughtcrime.securesms.notifications
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@ -10,7 +8,7 @@ private const val INTERVAL: Int = 12 * 60 * 60 * 1000
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class TokenManager @Inject constructor(
|
class TokenManager @Inject constructor(
|
||||||
@ApplicationContext private val context: Context,
|
private val prefs: TextSecurePreferences
|
||||||
) {
|
) {
|
||||||
val hasValidRegistration get() = isRegistered && !isExpired
|
val hasValidRegistration get() = isRegistered && !isExpired
|
||||||
val isRegistered get() = time > 0
|
val isRegistered get() = time > 0
|
||||||
@ -25,8 +23,8 @@ class TokenManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var time
|
private var time
|
||||||
get() = TextSecurePreferences.getPushRegisterTime(context)
|
get() = prefs.getPushRegisterTime()
|
||||||
set(value) = TextSecurePreferences.setPushRegisterTime(context, value)
|
set(value) = prefs.setPushRegisterTime(value)
|
||||||
|
|
||||||
private fun currentTime() = System.currentTimeMillis()
|
private fun currentTime() = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class LandingActivity: BaseActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IdentityKeyUtil.generateIdentityKeyPair(this)
|
IdentityKeyUtil.generateIdentityKeyPair(this)
|
||||||
TextSecurePreferences.setPasswordDisabled(this, true)
|
prefs.setPasswordDisabled(true)
|
||||||
// AC: This is a temporary workaround to trick the old code that the screen is unlocked.
|
// AC: This is a temporary workaround to trick the old code that the screen is unlocked.
|
||||||
KeyCachingService.setMasterSecret(applicationContext, Object())
|
KeyCachingService.setMasterSecret(applicationContext, Object())
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@ import android.Manifest
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.setBooleanPreference
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions
|
import org.thoughtcrime.securesms.permissions.Permissions
|
||||||
import org.thoughtcrime.securesms.showSessionDialog
|
import org.thoughtcrime.securesms.showSessionDialog
|
||||||
|
|
||||||
internal class CallToggleListener(
|
internal class CallToggleListener(
|
||||||
private val context: Fragment,
|
private val fragment: Fragment,
|
||||||
private val setCallback: (Boolean) -> Unit
|
private val setCallback: (Boolean) -> Unit
|
||||||
) : Preference.OnPreferenceChangeListener {
|
) : Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ internal class CallToggleListener(
|
|||||||
if (newValue == false) return true
|
if (newValue == false) return true
|
||||||
|
|
||||||
// check if we've shown the info dialog and check for microphone permissions
|
// check if we've shown the info dialog and check for microphone permissions
|
||||||
context.showSessionDialog {
|
fragment.showSessionDialog {
|
||||||
title(R.string.dialog_voice_video_title)
|
title(R.string.dialog_voice_video_title)
|
||||||
text(R.string.dialog_voice_video_message)
|
text(R.string.dialog_voice_video_message)
|
||||||
button(R.string.dialog_link_preview_enable_button_title, R.string.AccessibilityId_enable) { requestMicrophonePermission() }
|
button(R.string.dialog_link_preview_enable_button_title, R.string.AccessibilityId_enable) { requestMicrophonePermission() }
|
||||||
@ -29,14 +29,10 @@ internal class CallToggleListener(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun requestMicrophonePermission() {
|
private fun requestMicrophonePermission() {
|
||||||
Permissions.with(context)
|
Permissions.with(fragment)
|
||||||
.request(Manifest.permission.RECORD_AUDIO)
|
.request(Manifest.permission.RECORD_AUDIO)
|
||||||
.onAllGranted {
|
.onAllGranted {
|
||||||
setBooleanPreference(
|
fragment.requireContext().prefs.setCallNotificationsEnabled(true)
|
||||||
context.requireContext(),
|
|
||||||
TextSecurePreferences.CALL_NOTIFICATIONS_ENABLED,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
setCallback(true)
|
setCallback(true)
|
||||||
}
|
}
|
||||||
.onAnyDenied { setCallback(false) }
|
.onAnyDenied { setCallback(false) }
|
||||||
|
@ -18,8 +18,9 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.isNotificationsEnabled
|
import org.session.libsession.utilities.prefs
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
||||||
import org.thoughtcrime.securesms.notifications.NotificationChannels
|
import org.thoughtcrime.securesms.notifications.NotificationChannels
|
||||||
@ -175,7 +176,7 @@ class NotificationsPreferenceFragment : ListSummaryPreferenceFragment() {
|
|||||||
companion object {
|
companion object {
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
private val TAG = NotificationsPreferenceFragment::class.java.simpleName
|
private val TAG = NotificationsPreferenceFragment::class.java.simpleName
|
||||||
fun getSummary(context: Context): CharSequence = when (isNotificationsEnabled(context)) {
|
fun getSummary(context: Context): CharSequence = when (context.prefs.isNotificationsEnabled()) {
|
||||||
true -> R.string.ApplicationPreferencesActivity_On
|
true -> R.string.ApplicationPreferencesActivity_On
|
||||||
false -> R.string.ApplicationPreferencesActivity_Off
|
false -> R.string.ApplicationPreferencesActivity_Off
|
||||||
}.let(context::getString)
|
}.let(context::getString)
|
||||||
|
@ -13,9 +13,9 @@ import androidx.preference.PreferenceDataStore
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import network.loki.messenger.BuildConfig
|
import network.loki.messenger.BuildConfig
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.isPasswordDisabled
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.setScreenLockEnabled
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
||||||
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
||||||
@ -30,6 +30,7 @@ import javax.inject.Inject
|
|||||||
class PrivacySettingsPreferenceFragment : ListSummaryPreferenceFragment() {
|
class PrivacySettingsPreferenceFragment : ListSummaryPreferenceFragment() {
|
||||||
|
|
||||||
@Inject lateinit var configFactory: ConfigFactory
|
@Inject lateinit var configFactory: ConfigFactory
|
||||||
|
@Inject lateinit var prefs: TextSecurePreferences
|
||||||
|
|
||||||
override fun onCreate(paramBundle: Bundle?) {
|
override fun onCreate(paramBundle: Bundle?) {
|
||||||
super.onCreate(paramBundle)
|
super.onCreate(paramBundle)
|
||||||
@ -109,12 +110,8 @@ class PrivacySettingsPreferenceFragment : ListSummaryPreferenceFragment() {
|
|||||||
addPreferencesFromResource(R.xml.preferences_app_protection)
|
addPreferencesFromResource(R.xml.preferences_app_protection)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initializeVisibility() {
|
private fun initializeVisibility() {
|
||||||
if (isPasswordDisabled(requireContext())) {
|
if (prefs.isPasswordDisabled()) {
|
||||||
val keyguardManager =
|
val keyguardManager =
|
||||||
requireContext().getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
requireContext().getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||||
if (!keyguardManager.isKeyguardSecure) {
|
if (!keyguardManager.isKeyguardSecure) {
|
||||||
@ -130,10 +127,10 @@ class PrivacySettingsPreferenceFragment : ListSummaryPreferenceFragment() {
|
|||||||
private inner class ScreenLockListener : Preference.OnPreferenceChangeListener {
|
private inner class ScreenLockListener : Preference.OnPreferenceChangeListener {
|
||||||
override fun onPreferenceChange(preference: Preference, newValue: Any): Boolean {
|
override fun onPreferenceChange(preference: Preference, newValue: Any): Boolean {
|
||||||
val enabled = newValue as Boolean
|
val enabled = newValue as Boolean
|
||||||
setScreenLockEnabled(context!!, enabled)
|
requireContext().prefs.setScreenLockEnabled(enabled)
|
||||||
val intent = Intent(context, KeyCachingService::class.java)
|
val intent = Intent(context, KeyCachingService::class.java)
|
||||||
intent.action = KeyCachingService.LOCK_TOGGLED_EVENT
|
intent.action = KeyCachingService.LOCK_TOGGLED_EVENT
|
||||||
context!!.startService(intent)
|
requireContext().startService(intent)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,10 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.asSharedFlow
|
import kotlinx.coroutines.flow.asSharedFlow
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.PublicKeyValidation
|
import org.session.libsignal.utilities.PublicKeyValidation
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
@ -47,7 +49,7 @@ class QRCodeActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
|
|
||||||
setComposeContent {
|
setComposeContent {
|
||||||
Tabs(
|
Tabs(
|
||||||
TextSecurePreferences.getLocalNumber(this)!!,
|
prefs.getLocalNumber()!!,
|
||||||
errors.asSharedFlow(),
|
errors.asSharedFlow(),
|
||||||
onScan = ::onScan
|
onScan = ::onScan
|
||||||
)
|
)
|
||||||
|
@ -108,7 +108,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
set(value) { field = value; handleDisplayNameEditActionModeChanged() }
|
set(value) { field = value; handleDisplayNameEditActionModeChanged() }
|
||||||
private var tempFile: File? = null
|
private var tempFile: File? = null
|
||||||
|
|
||||||
private val hexEncodedPublicKey: String get() = TextSecurePreferences.getLocalNumber(this)!!
|
private val hexEncodedPublicKey: String get() = prefs.getLocalNumber()!!
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val SCROLL_STATE = "SCROLL_STATE"
|
private const val SCROLL_STATE = "SCROLL_STATE"
|
||||||
@ -140,7 +140,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDisplayName(): String =
|
private fun getDisplayName(): String =
|
||||||
TextSecurePreferences.getProfileName(this) ?: truncateIdForDisplay(hexEncodedPublicKey)
|
prefs.getProfileName() ?: truncateIdForDisplay(hexEncodedPublicKey)
|
||||||
|
|
||||||
private fun setupProfilePictureView(view: ProfilePictureView) {
|
private fun setupProfilePictureView(view: ProfilePictureView) {
|
||||||
view.apply {
|
view.apply {
|
||||||
@ -255,7 +255,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
binding.loader.isVisible = true
|
binding.loader.isVisible = true
|
||||||
val promises = mutableListOf<Promise<*, Exception>>()
|
val promises = mutableListOf<Promise<*, Exception>>()
|
||||||
if (displayName != null) {
|
if (displayName != null) {
|
||||||
TextSecurePreferences.setProfileName(this, displayName)
|
prefs.setProfileName(displayName)
|
||||||
configFactory.user?.setName(displayName)
|
configFactory.user?.setName(displayName)
|
||||||
}
|
}
|
||||||
val encodedProfileKey = ProfileKeyUtil.generateEncodedProfileKey(this)
|
val encodedProfileKey = ProfileKeyUtil.generateEncodedProfileKey(this)
|
||||||
@ -269,11 +269,11 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
all(promises) successUi { // Do this on the UI thread so that it happens before the alwaysUi clause below
|
all(promises) successUi { // Do this on the UI thread so that it happens before the alwaysUi clause below
|
||||||
val userConfig = configFactory.user
|
val userConfig = configFactory.user
|
||||||
if (isUpdatingProfilePicture) {
|
if (isUpdatingProfilePicture) {
|
||||||
AvatarHelper.setAvatar(this, Address.fromSerialized(TextSecurePreferences.getLocalNumber(this)!!), profilePicture)
|
AvatarHelper.setAvatar(this, Address.fromSerialized(prefs.getLocalNumber()!!), profilePicture)
|
||||||
prefs.setProfileAvatarId(profilePicture?.let { SecureRandom().nextInt() } ?: 0 )
|
prefs.setProfileAvatarId(profilePicture?.let { SecureRandom().nextInt() } ?: 0 )
|
||||||
ProfileKeyUtil.setEncodedProfileKey(this, encodedProfileKey)
|
ProfileKeyUtil.setEncodedProfileKey(this, encodedProfileKey)
|
||||||
// new config
|
// new config
|
||||||
val url = TextSecurePreferences.getProfilePictureURL(this)
|
val url = prefs.getProfilePictureURL()
|
||||||
val profileKey = ProfileKeyUtil.getProfileKey(this)
|
val profileKey = ProfileKeyUtil.getProfileKey(this)
|
||||||
if (profilePicture == null) {
|
if (profilePicture == null) {
|
||||||
userConfig?.setPic(UserPic.DEFAULT)
|
userConfig?.setPic(UserPic.DEFAULT)
|
||||||
|
@ -6,7 +6,9 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
|
|
||||||
fun Context.sendInvitationToUseSession() {
|
fun Context.sendInvitationToUseSession() {
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
@ -15,7 +17,7 @@ fun Context.sendInvitationToUseSession() {
|
|||||||
Intent.EXTRA_TEXT,
|
Intent.EXTRA_TEXT,
|
||||||
getString(
|
getString(
|
||||||
R.string.accountIdShare,
|
R.string.accountIdShare,
|
||||||
TextSecurePreferences.getLocalNumber(this@sendInvitationToUseSession)
|
prefs.getLocalNumber()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
type = "text/plain"
|
type = "text/plain"
|
||||||
@ -25,7 +27,7 @@ fun Context.sendInvitationToUseSession() {
|
|||||||
|
|
||||||
fun Context.copyPublicKey() {
|
fun Context.copyPublicKey() {
|
||||||
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
val clip = ClipData.newPlainText("Account ID", TextSecurePreferences.getLocalNumber(this))
|
val clip = ClipData.newPlainText("Account ID", prefs.getLocalNumber())
|
||||||
clipboard.setPrimaryClip(clip)
|
clipboard.setPrimaryClip(clip)
|
||||||
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class BlobProvider {
|
|||||||
String directory = getDirectory(storageType);
|
String directory = getDirectory(storageType);
|
||||||
File file = new File(getOrCreateCacheDirectory(context, directory), buildFileName(id));
|
File file = new File(getOrCreateCacheDirectory(context, directory), buildFileName(id));
|
||||||
|
|
||||||
return ModernDecryptingPartInputStream.createFor(AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret(), file, 0);
|
return ModernDecryptingPartInputStream.createFor(AttachmentSecretProvider.getInstance().getOrCreateAttachmentSecret(), file, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Provided URI does not match this spec. Uri: " + uri);
|
throw new IOException("Provided URI does not match this spec. Uri: " + uri);
|
||||||
@ -174,7 +174,7 @@ public class BlobProvider {
|
|||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private synchronized @NonNull Uri writeBlobSpecToDisk(@NonNull Context context, @NonNull BlobSpec blobSpec, @Nullable ErrorListener errorListener) throws IOException {
|
private synchronized @NonNull Uri writeBlobSpecToDisk(@NonNull Context context, @NonNull BlobSpec blobSpec, @Nullable ErrorListener errorListener) throws IOException {
|
||||||
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
|
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance().getOrCreateAttachmentSecret();
|
||||||
String directory = getDirectory(blobSpec.getStorageType());
|
String directory = getDirectory(blobSpec.getStorageType());
|
||||||
File outputFile = new File(getOrCreateCacheDirectory(context, directory), buildFileName(blobSpec.id));
|
File outputFile = new File(getOrCreateCacheDirectory(context, directory), buildFileName(blobSpec.id));
|
||||||
OutputStream outputStream = ModernEncryptingPartOutputStream.createFor(attachmentSecret, outputFile, true).second;
|
OutputStream outputStream = ModernEncryptingPartOutputStream.createFor(attachmentSecret, outputFile, true).second;
|
||||||
|
@ -12,6 +12,8 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.thoughtcrime.securesms.imageeditor.ColorableRenderer;
|
import org.thoughtcrime.securesms.imageeditor.ColorableRenderer;
|
||||||
import org.thoughtcrime.securesms.imageeditor.ImageEditorView;
|
import org.thoughtcrime.securesms.imageeditor.ImageEditorView;
|
||||||
import org.thoughtcrime.securesms.imageeditor.Renderer;
|
import org.thoughtcrime.securesms.imageeditor.Renderer;
|
||||||
@ -209,7 +211,7 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startTextEntityEditing(@NonNull EditorElement textElement, boolean selectAll) {
|
private void startTextEntityEditing(@NonNull EditorElement textElement, boolean selectAll) {
|
||||||
imageEditorView.startTextEditing(textElement, TextSecurePreferences.isIncognitoKeyboardEnabled(requireContext()), selectAll);
|
imageEditorView.startTextEditing(textElement, MessagingModuleConfiguration.getShared().getPrefs().isIncognitoKeyboardEnabled(), selectAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addText() {
|
protected void addText() {
|
||||||
|
@ -6,6 +6,8 @@ import android.database.DatabaseUtils;
|
|||||||
import android.database.MergeCursor;
|
import android.database.MergeCursor;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.messaging.contacts.Contact;
|
import org.session.libsession.messaging.contacts.Contact;
|
||||||
import org.session.libsession.utilities.Address;
|
import org.session.libsession.utilities.Address;
|
||||||
import org.session.libsession.utilities.GroupRecord;
|
import org.session.libsession.utilities.GroupRecord;
|
||||||
@ -137,7 +139,7 @@ public class SearchRepository {
|
|||||||
|
|
||||||
private CursorList<GroupRecord> queryConversations(@NonNull String query, List<String> matchingAddresses) {
|
private CursorList<GroupRecord> queryConversations(@NonNull String query, List<String> matchingAddresses) {
|
||||||
List<String> numbers = contactAccessor.getNumbersForThreadSearchFilter(context, query);
|
List<String> numbers = contactAccessor.getNumbersForThreadSearchFilter(context, query);
|
||||||
String localUserNumber = TextSecurePreferences.getLocalNumber(context);
|
String localUserNumber = MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber();
|
||||||
if (localUserNumber != null) {
|
if (localUserNumber != null) {
|
||||||
matchingAddresses.remove(localUserNumber);
|
matchingAddresses.remove(localUserNumber);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.service
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import network.loki.messenger.libsession_util.util.ExpiryMode
|
import network.loki.messenger.libsession_util.util.ExpiryMode
|
||||||
import network.loki.messenger.libsession_util.util.ExpiryMode.AfterSend
|
import network.loki.messenger.libsession_util.util.ExpiryMode.AfterSend
|
||||||
import org.session.libsession.messaging.MessagingModuleConfiguration.Companion.shared
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||||
import org.session.libsession.messaging.messages.signal.IncomingMediaMessage
|
import org.session.libsession.messaging.messages.signal.IncomingMediaMessage
|
||||||
import org.session.libsession.messaging.messages.signal.OutgoingExpirationUpdateMessage
|
import org.session.libsession.messaging.messages.signal.OutgoingExpirationUpdateMessage
|
||||||
@ -12,7 +12,7 @@ import org.session.libsession.utilities.Address.Companion.fromSerialized
|
|||||||
import org.session.libsession.utilities.GroupUtil.doubleEncodeGroupID
|
import org.session.libsession.utilities.GroupUtil.doubleEncodeGroupID
|
||||||
import org.session.libsession.utilities.GroupUtil.getDecodedGroupIDAsData
|
import org.session.libsession.utilities.GroupUtil.getDecodedGroupIDAsData
|
||||||
import org.session.libsession.utilities.SSKEnvironment.MessageExpirationManagerProtocol
|
import org.session.libsession.utilities.SSKEnvironment.MessageExpirationManagerProtocol
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.getLocalNumber
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.messages.SignalServiceGroup
|
import org.session.libsignal.messages.SignalServiceGroup
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
@ -87,7 +87,7 @@ class ExpiringMessageManager(context: Context) : MessageExpirationManagerProtoco
|
|||||||
val groupAddress = fromSerialized(groupID)
|
val groupAddress = fromSerialized(groupID)
|
||||||
recipient = Recipient.from(context, groupAddress, false)
|
recipient = Recipient.from(context, groupAddress, false)
|
||||||
}
|
}
|
||||||
val threadId = shared.storage.getThreadId(recipient) ?: return
|
val threadId = MessagingModuleConfiguration.shared.storage.getThreadId(recipient) ?: return
|
||||||
val mediaMessage = IncomingMediaMessage(
|
val mediaMessage = IncomingMediaMessage(
|
||||||
address, sentTimestamp!!, -1,
|
address, sentTimestamp!!, -1,
|
||||||
expiresInMillis, expireStartedAt, true,
|
expiresInMillis, expireStartedAt, true,
|
||||||
@ -125,7 +125,7 @@ class ExpiringMessageManager(context: Context) : MessageExpirationManagerProtoco
|
|||||||
val address = fromSerialized(serializedAddress)
|
val address = fromSerialized(serializedAddress)
|
||||||
val recipient = Recipient.from(context, address, false)
|
val recipient = Recipient.from(context, address, false)
|
||||||
|
|
||||||
message.threadID = shared.storage.getOrCreateThreadIdFor(address)
|
message.threadID = MessagingModuleConfiguration.shared.storage.getOrCreateThreadIdFor(address)
|
||||||
val timerUpdateMessage = OutgoingExpirationUpdateMessage(
|
val timerUpdateMessage = OutgoingExpirationUpdateMessage(
|
||||||
recipient,
|
recipient,
|
||||||
sentTimestamp!!,
|
sentTimestamp!!,
|
||||||
@ -149,7 +149,7 @@ class ExpiringMessageManager(context: Context) : MessageExpirationManagerProtoco
|
|||||||
override fun insertExpirationTimerMessage(message: ExpirationTimerUpdate) {
|
override fun insertExpirationTimerMessage(message: ExpirationTimerUpdate) {
|
||||||
val expiryMode: ExpiryMode = message.expiryMode
|
val expiryMode: ExpiryMode = message.expiryMode
|
||||||
|
|
||||||
val userPublicKey = getLocalNumber(context)
|
val userPublicKey = context.prefs.getLocalNumber()
|
||||||
val senderPublicKey = message.sender
|
val senderPublicKey = message.sender
|
||||||
val sentTimestamp = message.sentTimestamp ?: 0
|
val sentTimestamp = message.sentTimestamp ?: 0
|
||||||
val expireStartedAt = if ((expiryMode is AfterSend || message.isSenderSelf) && !message.isGroup) sentTimestamp else 0
|
val expireStartedAt = if ((expiryMode is AfterSend || message.isSenderSelf) && !message.isGroup) sentTimestamp else 0
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.service;
|
package org.thoughtcrime.securesms.service;
|
||||||
|
|
||||||
|
import static org.session.libsession.utilities.TextSecurePreferencesKt.getPrefs;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
@ -38,6 +40,7 @@ import androidx.core.app.NotificationCompat;
|
|||||||
|
|
||||||
import org.session.libsession.utilities.ServiceUtil;
|
import org.session.libsession.utilities.ServiceUtil;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
|
import org.session.libsession.utilities.TextSecurePreferencesKt;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.DatabaseUpgradeActivity;
|
import org.thoughtcrime.securesms.DatabaseUpgradeActivity;
|
||||||
@ -68,12 +71,13 @@ public class KeyCachingService extends Service {
|
|||||||
private static final String PASSPHRASE_EXPIRED_EVENT = "org.thoughtcrime.securesms.service.action.PASSPHRASE_EXPIRED_EVENT";
|
private static final String PASSPHRASE_EXPIRED_EVENT = "org.thoughtcrime.securesms.service.action.PASSPHRASE_EXPIRED_EVENT";
|
||||||
public static final String CLEAR_KEY_ACTION = "org.thoughtcrime.securesms.service.action.CLEAR_KEY";
|
public static final String CLEAR_KEY_ACTION = "org.thoughtcrime.securesms.service.action.CLEAR_KEY";
|
||||||
|
|
||||||
private final IBinder binder = new KeySetBinder();
|
|
||||||
|
|
||||||
// AC: This is a temporal drop off replacement for the refactoring time being.
|
// AC: This is a temporal drop off replacement for the refactoring time being.
|
||||||
// This field only indicates if the app was unlocked or not (null means locked).
|
// This field only indicates if the app was unlocked or not (null means locked).
|
||||||
private static Object masterSecret = null;
|
private static Object masterSecret = null;
|
||||||
|
|
||||||
|
private final IBinder binder = new KeySetBinder();
|
||||||
|
private final TextSecurePreferences prefs = getPrefs(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A temporal utility method to quickly call {@link KeyCachingService#setMasterSecret(Object)}
|
* A temporal utility method to quickly call {@link KeyCachingService#setMasterSecret(Object)}
|
||||||
* without explicitly binding to the service.
|
* without explicitly binding to the service.
|
||||||
@ -100,7 +104,9 @@ public class KeyCachingService extends Service {
|
|||||||
public KeyCachingService() {}
|
public KeyCachingService() {}
|
||||||
|
|
||||||
public static synchronized boolean isLocked(Context context) {
|
public static synchronized boolean isLocked(Context context) {
|
||||||
boolean enabled = !TextSecurePreferences.isPasswordDisabled(context) || TextSecurePreferences.isScreenLockEnabled(context);
|
TextSecurePreferences prefs = ApplicationContext.getInstance(context).getPrefs();
|
||||||
|
|
||||||
|
boolean enabled = !prefs.isPasswordDisabled() || prefs.isScreenLockEnabled();
|
||||||
return getMasterSecret(context) == null && enabled;
|
return getMasterSecret(context) == null && enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +162,7 @@ public class KeyCachingService extends Service {
|
|||||||
Log.i(TAG, "onCreate()");
|
Log.i(TAG, "onCreate()");
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
if (TextSecurePreferences.isPasswordDisabled(this) && !TextSecurePreferences.isScreenLockEnabled(this)) {
|
if (prefs.isPasswordDisabled() && !prefs.isScreenLockEnabled()) {
|
||||||
setMasterSecret(new Object());
|
setMasterSecret(new Object());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,22 +211,24 @@ public class KeyCachingService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void startTimeoutIfAppropriate(@NonNull Context context) {
|
private static void startTimeoutIfAppropriate(@NonNull Context context) {
|
||||||
|
TextSecurePreferences prefs = ApplicationContext.getInstance(context).getPrefs();
|
||||||
|
|
||||||
boolean appVisible = ApplicationContext.getInstance(context).isAppVisible();
|
boolean appVisible = ApplicationContext.getInstance(context).isAppVisible();
|
||||||
boolean secretSet = KeyCachingService.masterSecret != null;
|
boolean secretSet = KeyCachingService.masterSecret != null;
|
||||||
|
|
||||||
boolean timeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(context);
|
boolean timeoutEnabled = prefs.isPassphraseTimeoutEnabled();
|
||||||
boolean passLockActive = timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(context);
|
boolean passLockActive = timeoutEnabled && !prefs.isPasswordDisabled();
|
||||||
|
|
||||||
long screenTimeout = TextSecurePreferences.getScreenLockTimeout(context);
|
long screenTimeout = prefs.getScreenLockTimeout();
|
||||||
boolean screenLockActive = screenTimeout >= 0 && TextSecurePreferences.isScreenLockEnabled(context);
|
boolean screenLockActive = screenTimeout >= 0 && prefs.isScreenLockEnabled();
|
||||||
|
|
||||||
if (!appVisible && secretSet && (passLockActive || screenLockActive)) {
|
if (!appVisible && secretSet && (passLockActive || screenLockActive)) {
|
||||||
long passphraseTimeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(context);
|
long passphraseTimeoutMinutes = prefs.getPassphraseTimeoutInterval();
|
||||||
long screenLockTimeoutSeconds = TextSecurePreferences.getScreenLockTimeout(context);
|
long screenLockTimeoutSeconds = prefs.getScreenLockTimeout();
|
||||||
|
|
||||||
long timeoutMillis;
|
long timeoutMillis;
|
||||||
|
|
||||||
if (!TextSecurePreferences.isPasswordDisabled(context)) timeoutMillis = TimeUnit.MINUTES.toMillis(passphraseTimeoutMinutes);
|
if (!prefs.isPasswordDisabled()) timeoutMillis = TimeUnit.MINUTES.toMillis(passphraseTimeoutMinutes);
|
||||||
else timeoutMillis = TimeUnit.SECONDS.toMillis(screenLockTimeoutSeconds);
|
else timeoutMillis = TimeUnit.SECONDS.toMillis(screenLockTimeoutSeconds);
|
||||||
|
|
||||||
Log.i(TAG, "Starting timeout: " + timeoutMillis);
|
Log.i(TAG, "Starting timeout: " + timeoutMillis);
|
||||||
@ -234,7 +242,7 @@ public class KeyCachingService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void foregroundService() {
|
private void foregroundService() {
|
||||||
if (TextSecurePreferences.isPasswordDisabled(this) && !TextSecurePreferences.isScreenLockEnabled(this)) {
|
if (prefs.isPasswordDisabled() && !prefs.isScreenLockEnabled()) {
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import android.content.Intent;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
|
import org.session.libsession.utilities.TextSecurePreferencesKt;
|
||||||
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Respond to a PanicKit trigger Intent by locking the app. PanicKit provides a
|
* Respond to a PanicKit trigger Intent by locking the app. PanicKit provides a
|
||||||
@ -18,7 +20,8 @@ public class PanicResponderListener extends BroadcastReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent != null && !TextSecurePreferences.isPasswordDisabled(context) &&
|
TextSecurePreferences prefs = ApplicationContext.getInstance(context).getPrefs();
|
||||||
|
if (intent != null && !prefs.isPasswordDisabled() &&
|
||||||
"info.guardianproject.panic.action.TRIGGER".equals(intent.getAction()))
|
"info.guardianproject.panic.action.TRIGGER".equals(intent.getAction()))
|
||||||
{
|
{
|
||||||
Intent lockIntent = new Intent(context, KeyCachingService.class);
|
Intent lockIntent = new Intent(context, KeyCachingService.class);
|
||||||
|
@ -13,6 +13,7 @@ import android.net.Uri;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.FileUtils;
|
import org.session.libsession.utilities.FileUtils;
|
||||||
import org.session.libsession.utilities.ServiceUtil;
|
import org.session.libsession.utilities.ServiceUtil;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
@ -39,9 +40,9 @@ public class UpdateApkReadyListener extends BroadcastReceiver {
|
|||||||
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
|
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
|
||||||
long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -2);
|
long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -2);
|
||||||
|
|
||||||
if (downloadId == TextSecurePreferences.getUpdateApkDownloadId(context)) {
|
if (downloadId == MessagingModuleConfiguration.getShared().getPrefs().getUpdateApkDownloadId()) {
|
||||||
Uri uri = getLocalUriForDownloadId(context, downloadId);
|
Uri uri = getLocalUriForDownloadId(context, downloadId);
|
||||||
String encodedDigest = TextSecurePreferences.getUpdateApkDigest(context);
|
String encodedDigest = MessagingModuleConfiguration.getShared().getPrefs().getUpdateApkDigest();
|
||||||
|
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
Log.w(TAG, "Downloaded local URI is null?");
|
Log.w(TAG, "Downloaded local URI is null?");
|
||||||
|
@ -2,12 +2,14 @@ package org.thoughtcrime.securesms.sskenvironment
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import network.loki.messenger.libsession_util.util.UserPic
|
import network.loki.messenger.libsession_util.util.UserPic
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.contacts.Contact
|
import org.session.libsession.messaging.contacts.Contact
|
||||||
import org.session.libsession.messaging.jobs.JobQueue
|
import org.session.libsession.messaging.jobs.JobQueue
|
||||||
import org.session.libsession.messaging.jobs.RetrieveProfileAvatarJob
|
import org.session.libsession.messaging.jobs.RetrieveProfileAvatarJob
|
||||||
import org.session.libsession.messaging.utilities.AccountId
|
import org.session.libsession.messaging.utilities.AccountId
|
||||||
import org.session.libsession.utilities.SSKEnvironment
|
import org.session.libsession.utilities.SSKEnvironment
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.IdPrefix
|
import org.session.libsignal.utilities.IdPrefix
|
||||||
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
||||||
@ -91,7 +93,7 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
|||||||
|
|
||||||
override fun contactUpdatedInternal(contact: Contact): String? {
|
override fun contactUpdatedInternal(contact: Contact): String? {
|
||||||
val contactConfig = configFactory.contacts ?: return null
|
val contactConfig = configFactory.contacts ?: return null
|
||||||
if (contact.accountID == TextSecurePreferences.getLocalNumber(context)) return null
|
if (contact.accountID == context.prefs.getLocalNumber()) return null
|
||||||
val sessionId = AccountId(contact.accountID)
|
val sessionId = AccountId(contact.accountID)
|
||||||
if (sessionId.prefix != IdPrefix.STANDARD) return null // only internally store standard session IDs
|
if (sessionId.prefix != IdPrefix.STANDARD) return null // only internally store standard session IDs
|
||||||
contactConfig.upsertContact(contact.accountID) {
|
contactConfig.upsertContact(contact.accountID) {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package org.thoughtcrime.securesms.sskenvironment
|
package org.thoughtcrime.securesms.sskenvironment
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.SSKEnvironment
|
import org.session.libsession.utilities.SSKEnvironment
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId
|
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
@ -11,7 +13,7 @@ import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
|||||||
class ReadReceiptManager: SSKEnvironment.ReadReceiptManagerProtocol {
|
class ReadReceiptManager: SSKEnvironment.ReadReceiptManagerProtocol {
|
||||||
|
|
||||||
override fun processReadReceipts(context: Context, fromRecipientId: String, sentTimestamps: List<Long>, readTimestamp: Long) {
|
override fun processReadReceipts(context: Context, fromRecipientId: String, sentTimestamps: List<Long>, readTimestamp: Long) {
|
||||||
if (TextSecurePreferences.isReadReceiptsEnabled(context)) {
|
if (context.prefs.isReadReceiptsEnabled()) {
|
||||||
|
|
||||||
// Redirect message to master device conversation
|
// Redirect message to master device conversation
|
||||||
var address = Address.fromSerialized(fromRecipientId)
|
var address = Address.fromSerialized(fromRecipientId)
|
||||||
|
@ -11,6 +11,7 @@ import com.annimon.stream.Collectors;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.utilities.Address;
|
import org.session.libsession.utilities.Address;
|
||||||
import org.session.libsession.utilities.SSKEnvironment;
|
import org.session.libsession.utilities.SSKEnvironment;
|
||||||
import org.session.libsession.utilities.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
@ -48,7 +49,7 @@ public class TypingStatusRepository implements SSKEnvironment.TypingIndicatorsPr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void didReceiveTypingStartedMessage(@NotNull Context context, long threadId, @NotNull Address author, int device) {
|
public synchronized void didReceiveTypingStartedMessage(@NotNull Context context, long threadId, @NotNull Address author, int device) {
|
||||||
if (author.serialize().equals(TextSecurePreferences.getLocalNumber(context))) {
|
if (author.serialize().equals(MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ public class TypingStatusRepository implements SSKEnvironment.TypingIndicatorsPr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void didReceiveTypingStoppedMessage(@NotNull Context context, long threadId, @NotNull Address author, int device, boolean isReplacedByIncomingMessage) {
|
public synchronized void didReceiveTypingStoppedMessage(@NotNull Context context, long threadId, @NotNull Address author, int device, boolean isReplacedByIncomingMessage) {
|
||||||
if (author.serialize().equals(TextSecurePreferences.getLocalNumber(context))) {
|
if (author.serialize().equals(MessagingModuleConfiguration.getShared().getPrefs().getLocalNumber())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.ui.color
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.BLUE_ACCENT
|
import org.session.libsession.utilities.TextSecurePreferences.Companion.BLUE_ACCENT
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.CLASSIC_DARK
|
import org.session.libsession.utilities.TextSecurePreferences.Companion.CLASSIC_DARK
|
||||||
|
@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
||||||
import org.session.libsession.utilities.ServiceUtil;
|
import org.session.libsession.utilities.ServiceUtil;
|
||||||
@ -79,9 +80,9 @@ public class AttachmentUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static @NonNull Set<String> getAllowedAutoDownloadTypes(@NonNull Context context) {
|
private static @NonNull Set<String> getAllowedAutoDownloadTypes(@NonNull Context context) {
|
||||||
if (isConnectedWifi(context)) return TextSecurePreferences.getWifiMediaDownloadAllowed(context);
|
if (isConnectedWifi(context)) return MessagingModuleConfiguration.getShared().getPrefs().getWifiMediaDownloadAllowed();
|
||||||
else if (isConnectedRoaming(context)) return TextSecurePreferences.getRoamingMediaDownloadAllowed(context);
|
else if (isConnectedRoaming(context)) return MessagingModuleConfiguration.getShared().getPrefs().getRoamingMediaDownloadAllowed();
|
||||||
else if (isConnectedMobile(context)) return TextSecurePreferences.getMobileMediaDownloadAllowed(context);
|
else if (isConnectedMobile(context)) return MessagingModuleConfiguration.getShared().getPrefs().getMobileMediaDownloadAllowed();
|
||||||
else return Collections.emptySet();
|
else return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ import org.session.libsession.messaging.messages.Destination
|
|||||||
import org.session.libsession.messaging.messages.control.ConfigurationMessage
|
import org.session.libsession.messaging.messages.control.ConfigurationMessage
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.GroupUtil
|
import org.session.libsession.utilities.GroupUtil
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
|
||||||
import org.session.libsession.utilities.WindowDebouncer
|
import org.session.libsession.utilities.WindowDebouncer
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.crypto.ecc.DjbECPublicKey
|
import org.session.libsignal.crypto.ecc.DjbECPublicKey
|
||||||
import org.session.libsignal.utilities.Hex
|
import org.session.libsignal.utilities.Hex
|
||||||
import org.session.libsignal.utilities.IdPrefix
|
import org.session.libsignal.utilities.IdPrefix
|
||||||
@ -52,13 +52,13 @@ object ConfigurationMessageUtilities {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun syncConfigurationIfNeeded(context: Context) {
|
fun syncConfigurationIfNeeded(context: Context) {
|
||||||
// add if check here to schedule new config job process and return early
|
// add if check here to schedule new config job process and return early
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context) ?: return
|
val userPublicKey = context.prefs.getLocalNumber() ?: return
|
||||||
scheduleConfigSync(userPublicKey)
|
scheduleConfigSync(userPublicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun forceSyncConfigurationNowIfNeeded(context: Context): Promise<Unit, Exception> {
|
fun forceSyncConfigurationNowIfNeeded(context: Context): Promise<Unit, Exception> {
|
||||||
// add if check here to schedule new config job process and return early
|
// add if check here to schedule new config job process and return early
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context) ?: return Promise.ofFail(NullPointerException("User Public Key is null"))
|
val userPublicKey = context.prefs.getLocalNumber() ?: return Promise.ofFail(NullPointerException("User Public Key is null"))
|
||||||
// schedule job if none exist
|
// schedule job if none exist
|
||||||
// don't schedule job if we already have one
|
// don't schedule job if we already have one
|
||||||
scheduleConfigSync(userPublicKey)
|
scheduleConfigSync(userPublicKey)
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package org.thoughtcrime.securesms.util
|
package org.thoughtcrime.securesms.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.lang.RuntimeException
|
import java.lang.RuntimeException
|
||||||
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
|
||||||
|
|
||||||
object VersionTracker {
|
object VersionTracker {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getLastSeenVersion(context: Context): Int {
|
fun getLastSeenVersion(context: Context): Int {
|
||||||
var version = TextSecurePreferences.getLastVersionCode(context)
|
var version = context.prefs.getLastVersionCode()
|
||||||
// Zero means the app is freshly installed = user is actually on the current version.
|
// Zero means the app is freshly installed = user is actually on the current version.
|
||||||
if (version == 0) {
|
if (version == 0) {
|
||||||
version = updateLastSeenVersion(context)
|
version = updateLastSeenVersion(context)
|
||||||
@ -22,7 +22,7 @@ object VersionTracker {
|
|||||||
fun updateLastSeenVersion(context: Context): Int {
|
fun updateLastSeenVersion(context: Context): Int {
|
||||||
return try {
|
return try {
|
||||||
val currentVersionCode = Util.getCanonicalVersionCode()
|
val currentVersionCode = Util.getCanonicalVersionCode()
|
||||||
TextSecurePreferences.setLastVersionCode(context, currentVersionCode)
|
context.prefs.setLastVersionCode(currentVersionCode)
|
||||||
currentVersionCode
|
currentVersionCode
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
throw RuntimeException("Failed to update the last seen app version.", e)
|
throw RuntimeException("Failed to update the last seen app version.", e)
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package org.session.libsession.messaging
|
package org.session.libsession.messaging
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.goterl.lazysodium.utils.KeyPair
|
import com.goterl.lazysodium.utils.KeyPair
|
||||||
import org.session.libsession.database.MessageDataProvider
|
import org.session.libsession.database.MessageDataProvider
|
||||||
import org.session.libsession.database.StorageProtocol
|
import org.session.libsession.database.StorageProtocol
|
||||||
import org.session.libsession.utilities.ConfigFactoryProtocol
|
import org.session.libsession.utilities.ConfigFactoryProtocol
|
||||||
import org.session.libsession.utilities.Device
|
import org.session.libsession.utilities.Device
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
|
|
||||||
class MessagingModuleConfiguration(
|
class MessagingModuleConfiguration(
|
||||||
val context: Context,
|
val context: Context,
|
||||||
@ -16,19 +18,11 @@ class MessagingModuleConfiguration(
|
|||||||
val configFactory: ConfigFactoryProtocol,
|
val configFactory: ConfigFactoryProtocol,
|
||||||
val lastSentTimestampCache: LastSentTimestampCache
|
val lastSentTimestampCache: LastSentTimestampCache
|
||||||
) {
|
) {
|
||||||
|
val prefs get() = context.prefs
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@SuppressLint("StaticFieldLeak")
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val shared: MessagingModuleConfiguration
|
lateinit var shared: MessagingModuleConfiguration
|
||||||
get() = context.getSystemService(MESSAGING_MODULE_SERVICE) as MessagingModuleConfiguration
|
|
||||||
|
|
||||||
const val MESSAGING_MODULE_SERVICE: String = "MessagingModuleConfiguration_MESSAGING_MODULE_SERVICE"
|
|
||||||
|
|
||||||
private lateinit var context: Context
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun configure(context: Context) {
|
|
||||||
this.context = context
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,10 +5,9 @@ import org.session.libsession.messaging.MessagingModuleConfiguration
|
|||||||
import org.session.libsession.messaging.utilities.Data
|
import org.session.libsession.messaging.utilities.Data
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.DownloadUtilities.downloadFile
|
import org.session.libsession.utilities.DownloadUtilities.downloadFile
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.setProfileAvatarId
|
|
||||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.setProfilePictureURL
|
|
||||||
import org.session.libsession.utilities.Util.copy
|
import org.session.libsession.utilities.Util.copy
|
||||||
import org.session.libsession.utilities.Util.equals
|
import org.session.libsession.utilities.Util.equals
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.streams.ProfileCipherInputStream
|
import org.session.libsignal.streams.ProfileCipherInputStream
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
@ -64,8 +63,8 @@ class RetrieveProfileAvatarJob(private val profileAvatar: String?, val recipient
|
|||||||
Log.w(TAG, "Removing profile avatar for: " + recipient.address.serialize())
|
Log.w(TAG, "Removing profile avatar for: " + recipient.address.serialize())
|
||||||
|
|
||||||
if (recipient.isLocalNumber) {
|
if (recipient.isLocalNumber) {
|
||||||
setProfileAvatarId(context, SecureRandom().nextInt())
|
context.prefs.setProfileAvatarId(SecureRandom().nextInt())
|
||||||
setProfilePictureURL(context, null)
|
context.prefs.setProfilePictureURL(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarHelper.delete(context, recipient.address)
|
AvatarHelper.delete(context, recipient.address)
|
||||||
@ -83,8 +82,8 @@ class RetrieveProfileAvatarJob(private val profileAvatar: String?, val recipient
|
|||||||
decryptDestination.renameTo(AvatarHelper.getAvatarFile(context, recipient.address))
|
decryptDestination.renameTo(AvatarHelper.getAvatarFile(context, recipient.address))
|
||||||
|
|
||||||
if (recipient.isLocalNumber) {
|
if (recipient.isLocalNumber) {
|
||||||
setProfileAvatarId(context, SecureRandom().nextInt())
|
context.prefs.setProfileAvatarId(SecureRandom().nextInt())
|
||||||
setProfilePictureURL(context, profileAvatar)
|
context.prefs.setProfilePictureURL(profileAvatar)
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.setProfileAvatar(recipient, profileAvatar)
|
storage.setProfileAvatar(recipient, profileAvatar)
|
||||||
|
@ -2,7 +2,7 @@ package org.session.libsession.messaging.jobs
|
|||||||
|
|
||||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.utilities.Data
|
import org.session.libsession.messaging.utilities.Data
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.prefs
|
||||||
|
|
||||||
class TrimThreadJob(val threadId: Long, val openGroupId: String?) : Job {
|
class TrimThreadJob(val threadId: Long, val openGroupId: String?) : Job {
|
||||||
override var delegate: JobDelegate? = null
|
override var delegate: JobDelegate? = null
|
||||||
@ -22,7 +22,7 @@ class TrimThreadJob(val threadId: Long, val openGroupId: String?) : Job {
|
|||||||
|
|
||||||
override suspend fun execute(dispatcherName: String) {
|
override suspend fun execute(dispatcherName: String) {
|
||||||
val context = MessagingModuleConfiguration.shared.context
|
val context = MessagingModuleConfiguration.shared.context
|
||||||
val trimmingEnabled = TextSecurePreferences.isThreadLengthTrimmingEnabled(context)
|
val trimmingEnabled = context.prefs.isThreadLengthTrimmingEnabled()
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val messageCount = storage.getMessageCount(threadId)
|
val messageCount = storage.getMessageCount(threadId)
|
||||||
if (trimmingEnabled && !openGroupId.isNullOrEmpty() && messageCount >= THREAD_LENGTH_TRIGGER_SIZE) {
|
if (trimmingEnabled && !openGroupId.isNullOrEmpty() && messageCount >= THREAD_LENGTH_TRIGGER_SIZE) {
|
||||||
|
@ -7,6 +7,7 @@ import org.session.libsession.utilities.Address
|
|||||||
import org.session.libsession.utilities.GroupUtil
|
import org.session.libsession.utilities.GroupUtil
|
||||||
import org.session.libsession.utilities.ProfileKeyUtil
|
import org.session.libsession.utilities.ProfileKeyUtil
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.crypto.ecc.DjbECPrivateKey
|
import org.session.libsignal.crypto.ecc.DjbECPrivateKey
|
||||||
import org.session.libsignal.crypto.ecc.DjbECPublicKey
|
import org.session.libsignal.crypto.ecc.DjbECPublicKey
|
||||||
import org.session.libsignal.crypto.ecc.ECKeyPair
|
import org.session.libsignal.crypto.ecc.ECKeyPair
|
||||||
@ -117,8 +118,9 @@ class ConfigurationMessage(var closedGroups: List<ClosedGroup>, var openGroups:
|
|||||||
val sharedConfig = MessagingModuleConfiguration.shared
|
val sharedConfig = MessagingModuleConfiguration.shared
|
||||||
val storage = sharedConfig.storage
|
val storage = sharedConfig.storage
|
||||||
val context = sharedConfig.context
|
val context = sharedConfig.context
|
||||||
val displayName = TextSecurePreferences.getProfileName(context) ?: return null
|
val prefs = context.prefs
|
||||||
val profilePicture = TextSecurePreferences.getProfilePictureURL(context)
|
val displayName = prefs.getProfileName() ?: return null
|
||||||
|
val profilePicture = prefs.getProfilePictureURL()
|
||||||
val profileKey = ProfileKeyUtil.getProfileKey(context)
|
val profileKey = ProfileKeyUtil.getProfileKey(context)
|
||||||
val groups = storage.getAllGroups(includeInactive = false)
|
val groups = storage.getAllGroups(includeInactive = false)
|
||||||
for (group in groups) {
|
for (group in groups) {
|
||||||
|
@ -26,6 +26,7 @@ import org.session.libsession.snode.OnionRequestAPI
|
|||||||
import org.session.libsession.snode.OnionResponse
|
import org.session.libsession.snode.OnionResponse
|
||||||
import org.session.libsession.snode.SnodeAPI
|
import org.session.libsession.snode.SnodeAPI
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.utilities.Base64.decode
|
import org.session.libsignal.utilities.Base64.decode
|
||||||
import org.session.libsignal.utilities.Base64.encodeBytes
|
import org.session.libsignal.utilities.Base64.encodeBytes
|
||||||
import org.session.libsignal.utilities.HTTP
|
import org.session.libsignal.utilities.HTTP
|
||||||
@ -50,8 +51,7 @@ object OpenGroupApi {
|
|||||||
private val hasPerformedInitialPoll = mutableMapOf<String, Boolean>()
|
private val hasPerformedInitialPoll = mutableMapOf<String, Boolean>()
|
||||||
private var hasUpdatedLastOpenDate = false
|
private var hasUpdatedLastOpenDate = false
|
||||||
private val timeSinceLastOpen by lazy {
|
private val timeSinceLastOpen by lazy {
|
||||||
val context = MessagingModuleConfiguration.shared.context
|
val lastOpenDate = MessagingModuleConfiguration.shared.context.prefs.getLastOpenTimeDate()
|
||||||
val lastOpenDate = TextSecurePreferences.getLastOpenTimeDate(context)
|
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
now - lastOpenDate
|
now - lastOpenDate
|
||||||
}
|
}
|
||||||
@ -703,7 +703,7 @@ object OpenGroupApi {
|
|||||||
hasPerformedInitialPoll[server] = true
|
hasPerformedInitialPoll[server] = true
|
||||||
if (!hasUpdatedLastOpenDate) {
|
if (!hasUpdatedLastOpenDate) {
|
||||||
hasUpdatedLastOpenDate = true
|
hasUpdatedLastOpenDate = true
|
||||||
TextSecurePreferences.setLastOpenDate(context)
|
context.prefs.setLastOpenDate()
|
||||||
}
|
}
|
||||||
val lastInboxMessageId = storage.getLastInboxMessageId(server)
|
val lastInboxMessageId = storage.getLastInboxMessageId(server)
|
||||||
val lastOutboxMessageId = storage.getLastOutboxMessageId(server)
|
val lastOutboxMessageId = storage.getLastOutboxMessageId(server)
|
||||||
|
@ -16,6 +16,7 @@ import org.session.libsession.utilities.Address.Companion.fromSerialized
|
|||||||
import org.session.libsession.utilities.Device
|
import org.session.libsession.utilities.Device
|
||||||
import org.session.libsession.utilities.GroupUtil
|
import org.session.libsession.utilities.GroupUtil
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.crypto.ecc.Curve
|
import org.session.libsignal.crypto.ecc.Curve
|
||||||
import org.session.libsignal.crypto.ecc.ECKeyPair
|
import org.session.libsignal.crypto.ecc.ECKeyPair
|
||||||
import org.session.libsignal.messages.SignalServiceGroup
|
import org.session.libsignal.messages.SignalServiceGroup
|
||||||
@ -240,7 +241,7 @@ fun MessageSender.leave(groupPublicKey: String, notifyUser: Boolean = true): Pro
|
|||||||
ThreadUtils.queue {
|
ThreadUtils.queue {
|
||||||
val context = MessagingModuleConfiguration.shared.context
|
val context = MessagingModuleConfiguration.shared.context
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
val userPublicKey = context.prefs.getLocalNumber()!!
|
||||||
val groupID = GroupUtil.doubleEncodeGroupID(groupPublicKey)
|
val groupID = GroupUtil.doubleEncodeGroupID(groupPublicKey)
|
||||||
val group = storage.getGroup(groupID) ?: return@queue deferred.reject(Error.NoThread)
|
val group = storage.getGroup(groupID) ?: return@queue deferred.reject(Error.NoThread)
|
||||||
val updatedMembers = group.members.map { it.serialize() }.toSet() - userPublicKey
|
val updatedMembers = group.members.map { it.serialize() }.toSet() - userPublicKey
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.session.libsession.messaging.sending_receiving
|
package org.session.libsession.messaging.sending_receiving
|
||||||
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import network.loki.messenger.libsession_util.ConfigBase
|
|
||||||
import network.loki.messenger.libsession_util.util.ExpiryMode
|
import network.loki.messenger.libsession_util.util.ExpiryMode
|
||||||
import org.session.libsession.avatars.AvatarHelper
|
import org.session.libsession.avatars.AvatarHelper
|
||||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
@ -41,6 +40,7 @@ import org.session.libsession.utilities.GroupUtil.doubleEncodeGroupID
|
|||||||
import org.session.libsession.utilities.ProfileKeyUtil
|
import org.session.libsession.utilities.ProfileKeyUtil
|
||||||
import org.session.libsession.utilities.SSKEnvironment
|
import org.session.libsession.utilities.SSKEnvironment
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.crypto.ecc.DjbECPrivateKey
|
import org.session.libsignal.crypto.ecc.DjbECPrivateKey
|
||||||
import org.session.libsignal.crypto.ecc.DjbECPublicKey
|
import org.session.libsignal.crypto.ecc.DjbECPublicKey
|
||||||
@ -194,17 +194,18 @@ private fun MessageReceiver.handleDataExtractionNotification(message: DataExtrac
|
|||||||
private fun handleConfigurationMessage(message: ConfigurationMessage) {
|
private fun handleConfigurationMessage(message: ConfigurationMessage) {
|
||||||
val context = MessagingModuleConfiguration.shared.context
|
val context = MessagingModuleConfiguration.shared.context
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
if (TextSecurePreferences.getConfigurationMessageSynced(context)
|
val prefs = context.prefs
|
||||||
&& !TextSecurePreferences.shouldUpdateProfile(context, message.sentTimestamp!!)) return
|
if (prefs.getConfigurationMessageSynced()
|
||||||
|
&& !prefs.shouldUpdateProfile(message.sentTimestamp!!)) return
|
||||||
val userPublicKey = storage.getUserPublicKey()
|
val userPublicKey = storage.getUserPublicKey()
|
||||||
if (userPublicKey == null || message.sender != storage.getUserPublicKey()) return
|
if (userPublicKey == null || message.sender != storage.getUserPublicKey()) return
|
||||||
|
|
||||||
val firstTimeSync = !TextSecurePreferences.getConfigurationMessageSynced(context)
|
val firstTimeSync = !prefs.getConfigurationMessageSynced()
|
||||||
|
|
||||||
TextSecurePreferences.setConfigurationMessageSynced(context, true)
|
prefs.setConfigurationMessageSynced(true)
|
||||||
TextSecurePreferences.setLastProfileUpdateTime(context, message.sentTimestamp!!)
|
prefs.setLastProfileUpdateTime(message.sentTimestamp!!)
|
||||||
|
|
||||||
TextSecurePreferences.setHasLegacyConfig(context, true)
|
prefs.setHasLegacyConfig(true)
|
||||||
if (!firstTimeSync) return
|
if (!firstTimeSync) return
|
||||||
|
|
||||||
val allClosedGroupPublicKeys = storage.getAllClosedGroupPublicKeys()
|
val allClosedGroupPublicKeys = storage.getAllClosedGroupPublicKeys()
|
||||||
@ -233,11 +234,11 @@ private fun handleConfigurationMessage(message: ConfigurationMessage) {
|
|||||||
val profileManager = SSKEnvironment.shared.profileManager
|
val profileManager = SSKEnvironment.shared.profileManager
|
||||||
val recipient = Recipient.from(context, Address.fromSerialized(userPublicKey), false)
|
val recipient = Recipient.from(context, Address.fromSerialized(userPublicKey), false)
|
||||||
if (message.displayName.isNotEmpty()) {
|
if (message.displayName.isNotEmpty()) {
|
||||||
TextSecurePreferences.setProfileName(context, message.displayName)
|
prefs.setProfileName(message.displayName)
|
||||||
profileManager.setName(context, recipient, message.displayName)
|
profileManager.setName(context, recipient, message.displayName)
|
||||||
}
|
}
|
||||||
if (message.profileKey.isNotEmpty() && !message.profilePicture.isNullOrEmpty()
|
if (message.profileKey.isNotEmpty() && !message.profilePicture.isNullOrEmpty()
|
||||||
&& TextSecurePreferences.getProfilePictureURL(context) != message.profilePicture) {
|
&& prefs.getProfilePictureURL() != message.profilePicture) {
|
||||||
val profileKey = Base64.encodeBytes(message.profileKey)
|
val profileKey = Base64.encodeBytes(message.profileKey)
|
||||||
ProfileKeyUtil.setEncodedProfileKey(context, profileKey)
|
ProfileKeyUtil.setEncodedProfileKey(context, profileKey)
|
||||||
profileManager.setProfilePicture(context, recipient, message.profilePicture, message.profileKey)
|
profileManager.setProfilePicture(context, recipient, message.profilePicture, message.profileKey)
|
||||||
@ -641,7 +642,7 @@ private fun MessageReceiver.handleClosedGroupEncryptionKeyPair(message: ClosedGr
|
|||||||
private fun MessageReceiver.handleClosedGroupNameChanged(message: ClosedGroupControlMessage) {
|
private fun MessageReceiver.handleClosedGroupNameChanged(message: ClosedGroupControlMessage) {
|
||||||
val context = MessagingModuleConfiguration.shared.context
|
val context = MessagingModuleConfiguration.shared.context
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val userPublicKey = context.prefs.getLocalNumber()
|
||||||
val senderPublicKey = message.sender ?: return
|
val senderPublicKey = message.sender ?: return
|
||||||
val kind = message.kind!! as? ClosedGroupControlMessage.Kind.NameChange ?: return
|
val kind = message.kind!! as? ClosedGroupControlMessage.Kind.NameChange ?: return
|
||||||
val groupPublicKey = message.groupPublicKey ?: return
|
val groupPublicKey = message.groupPublicKey ?: return
|
||||||
|
@ -11,6 +11,7 @@ import org.session.libsession.snode.OnionResponse
|
|||||||
import org.session.libsession.snode.Version
|
import org.session.libsession.snode.Version
|
||||||
import org.session.libsession.utilities.Device
|
import org.session.libsession.utilities.Device
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsession.utilities.prefs
|
||||||
import org.session.libsignal.utilities.JsonUtil
|
import org.session.libsignal.utilities.JsonUtil
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.session.libsignal.utilities.emptyPromise
|
import org.session.libsignal.utilities.emptyPromise
|
||||||
@ -28,9 +29,9 @@ object PushRegistryV1 {
|
|||||||
|
|
||||||
fun register(
|
fun register(
|
||||||
device: Device,
|
device: Device,
|
||||||
isPushEnabled: Boolean = TextSecurePreferences.isPushEnabled(context),
|
isPushEnabled: Boolean = context.prefs.isPushEnabled(),
|
||||||
token: String? = TextSecurePreferences.getPushToken(context),
|
token: String? = context.prefs.getPushToken(),
|
||||||
publicKey: String? = TextSecurePreferences.getLocalNumber(context),
|
publicKey: String? = context.prefs.getLocalNumber(),
|
||||||
legacyGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
|
legacyGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
|
||||||
): Promise<*, Exception> = when {
|
): Promise<*, Exception> = when {
|
||||||
isPushEnabled -> retryIfNeeded(maxRetryCount) {
|
isPushEnabled -> retryIfNeeded(maxRetryCount) {
|
||||||
@ -78,7 +79,7 @@ object PushRegistryV1 {
|
|||||||
fun unregister(): Promise<*, Exception> {
|
fun unregister(): Promise<*, Exception> {
|
||||||
Log.d(TAG, "unregisterV1 requested")
|
Log.d(TAG, "unregisterV1 requested")
|
||||||
|
|
||||||
val token = TextSecurePreferences.getPushToken(context) ?: emptyPromise()
|
val token = context.prefs.getPushToken() ?: emptyPromise()
|
||||||
|
|
||||||
return retryIfNeeded(maxRetryCount) {
|
return retryIfNeeded(maxRetryCount) {
|
||||||
val parameters = mapOf("token" to token)
|
val parameters = mapOf("token" to token)
|
||||||
@ -99,7 +100,7 @@ object PushRegistryV1 {
|
|||||||
|
|
||||||
fun subscribeGroup(
|
fun subscribeGroup(
|
||||||
closedGroupPublicKey: String,
|
closedGroupPublicKey: String,
|
||||||
isPushEnabled: Boolean = TextSecurePreferences.isPushEnabled(context),
|
isPushEnabled: Boolean = context.prefs.isPushEnabled(),
|
||||||
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||||
) = if (isPushEnabled) {
|
) = if (isPushEnabled) {
|
||||||
performGroupOperation("subscribe_closed_group", closedGroupPublicKey, publicKey)
|
performGroupOperation("subscribe_closed_group", closedGroupPublicKey, publicKey)
|
||||||
@ -107,7 +108,7 @@ object PushRegistryV1 {
|
|||||||
|
|
||||||
fun unsubscribeGroup(
|
fun unsubscribeGroup(
|
||||||
closedGroupPublicKey: String,
|
closedGroupPublicKey: String,
|
||||||
isPushEnabled: Boolean = TextSecurePreferences.isPushEnabled(context),
|
isPushEnabled: Boolean = context.prefs.isPushEnabled(),
|
||||||
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||||
) = if (isPushEnabled) {
|
) = if (isPushEnabled) {
|
||||||
performGroupOperation("unsubscribe_closed_group", closedGroupPublicKey, publicKey)
|
performGroupOperation("unsubscribe_closed_group", closedGroupPublicKey, publicKey)
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package org.session.libsession.utilities;
|
package org.session.libsession.utilities;
|
||||||
|
|
||||||
|
import static org.session.libsession.utilities.TextSecurePreferencesKt.getPrefs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration;
|
||||||
import org.session.libsignal.utilities.Base64;
|
import org.session.libsignal.utilities.Base64;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -15,11 +18,11 @@ public class ProfileKeyUtil {
|
|||||||
|
|
||||||
public static synchronized @NonNull byte[] getProfileKey(@NonNull Context context) {
|
public static synchronized @NonNull byte[] getProfileKey(@NonNull Context context) {
|
||||||
try {
|
try {
|
||||||
String encodedProfileKey = TextSecurePreferences.getProfileKey(context);
|
String encodedProfileKey = MessagingModuleConfiguration.getShared().getPrefs().getProfileKey();
|
||||||
|
|
||||||
if (encodedProfileKey == null) {
|
if (encodedProfileKey == null) {
|
||||||
encodedProfileKey = Util.getSecret(PROFILE_KEY_BYTES);
|
encodedProfileKey = Util.getSecret(PROFILE_KEY_BYTES);
|
||||||
TextSecurePreferences.setProfileKey(context, encodedProfileKey);
|
MessagingModuleConfiguration.getShared().getPrefs().setProfileKey(encodedProfileKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Base64.decode(encodedProfileKey);
|
return Base64.decode(encodedProfileKey);
|
||||||
@ -41,6 +44,6 @@ public class ProfileKeyUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void setEncodedProfileKey(@NonNull Context context, @Nullable String key) {
|
public static synchronized void setEncodedProfileKey(@NonNull Context context, @Nullable String key) {
|
||||||
TextSecurePreferences.setProfileKey(context, key);
|
MessagingModuleConfiguration.getShared().getPrefs().setProfileKey(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import nl.komponents.kovenant.Promise
|
import nl.komponents.kovenant.Promise
|
||||||
import nl.komponents.kovenant.deferred
|
import nl.komponents.kovenant.deferred
|
||||||
import okio.Buffer
|
import okio.Buffer
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.file_server.FileServerApi
|
import org.session.libsession.messaging.file_server.FileServerApi
|
||||||
import org.session.libsignal.streams.ProfileCipherOutputStream
|
import org.session.libsignal.streams.ProfileCipherOutputStream
|
||||||
import org.session.libsignal.utilities.ProfileAvatarData
|
import org.session.libsignal.utilities.ProfileAvatarData
|
||||||
@ -35,9 +36,9 @@ object ProfilePictureUtilities {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
deferred.reject(e)
|
deferred.reject(e)
|
||||||
}
|
}
|
||||||
TextSecurePreferences.setLastProfilePictureUpload(context, Date().time)
|
context.prefs.setLastProfilePictureUpload(Date().time)
|
||||||
val url = "${FileServerApi.server}/file/$id"
|
val url = "${FileServerApi.server}/file/$id"
|
||||||
TextSecurePreferences.setProfilePictureURL(context, url)
|
context.prefs.setProfilePictureURL(url)
|
||||||
deferred.resolve(Unit)
|
deferred.resolve(Unit)
|
||||||
}
|
}
|
||||||
return deferred.promise
|
return deferred.promise
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@ import android.text.Spannable
|
|||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.text.style.StyleSpan
|
import android.text.style.StyleSpan
|
||||||
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.session.libsignal.utilities.Base64
|
import org.session.libsignal.utilities.Base64
|
||||||
import java.io.*
|
import java.io.*
|
||||||
@ -209,8 +210,8 @@ object Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun isOwnNumber(context: Context, number: String): Boolean {
|
fun isOwnNumber(number: String): Boolean {
|
||||||
return TextSecurePreferences.getLocalNumber(context).equals(number)
|
return MessagingModuleConfiguration.shared.context.prefs.getLocalNumber().equals(number)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.session.libsession.utilities.recipients;
|
package org.session.libsession.utilities.recipients;
|
||||||
|
|
||||||
|
import static org.session.libsession.utilities.TextSecurePreferencesKt.getPrefs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -524,7 +526,7 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized @Nullable ContactPhoto getContactPhoto() {
|
public synchronized @Nullable ContactPhoto getContactPhoto() {
|
||||||
if (isLocalNumber) return new ProfileContactPhoto(address, String.valueOf(TextSecurePreferences.getProfileAvatarId(context)));
|
if (isLocalNumber) return new ProfileContactPhoto(address, String.valueOf(getPrefs(MessagingModuleConfiguration.getShared().getContext()).getProfileAvatarId()));
|
||||||
else if (isGroupRecipient() && groupAvatarId != null) return new GroupRecordContactPhoto(address, groupAvatarId);
|
else if (isGroupRecipient() && groupAvatarId != null) return new GroupRecordContactPhoto(address, groupAvatarId);
|
||||||
else if (systemContactPhoto != null) return new SystemContactPhoto(address, systemContactPhoto, 0);
|
else if (systemContactPhoto != null) return new SystemContactPhoto(address, systemContactPhoto, 0);
|
||||||
else if (profileAvatar != null) return new ProfileContactPhoto(address, profileAvatar);
|
else if (profileAvatar != null) return new ProfileContactPhoto(address, profileAvatar);
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.session.libsession.utilities.recipients;
|
package org.session.libsession.utilities.recipients;
|
||||||
|
|
||||||
|
import static org.session.libsession.utilities.TextSecurePreferencesKt.getPrefs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -80,14 +82,16 @@ class RecipientProvider {
|
|||||||
return recipientCache.remove(address);
|
return recipientCache.remove(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NonNull Optional<RecipientDetails> createPrefetchedRecipientDetails(@NonNull Context context, @NonNull Address address,
|
private @NonNull Optional<RecipientDetails> createPrefetchedRecipientDetails(@NonNull Context context,
|
||||||
|
@NonNull Address address,
|
||||||
@NonNull Optional<RecipientSettings> settings,
|
@NonNull Optional<RecipientSettings> settings,
|
||||||
@NonNull Optional<GroupRecord> groupRecord)
|
@NonNull Optional<GroupRecord> groupRecord)
|
||||||
{
|
{
|
||||||
if (address.isGroup() && settings.isPresent() && groupRecord.isPresent()) {
|
if (address.isGroup() && settings.isPresent() && groupRecord.isPresent()) {
|
||||||
return Optional.of(getGroupRecipientDetails(context, address, groupRecord, settings, true));
|
return Optional.of(getGroupRecipientDetails(context, address, groupRecord, settings, true));
|
||||||
} else if (!address.isGroup() && settings.isPresent()) {
|
} else if (!address.isGroup() && settings.isPresent()) {
|
||||||
boolean isLocalNumber = address.serialize().equals(TextSecurePreferences.getLocalNumber(context));
|
TextSecurePreferences prefs = getPrefs(context);
|
||||||
|
boolean isLocalNumber = address.serialize().equals(prefs.getLocalNumber());
|
||||||
return Optional.of(new RecipientDetails(null, null, !TextUtils.isEmpty(settings.get().getSystemDisplayName()), isLocalNumber, settings.get(), null));
|
return Optional.of(new RecipientDetails(null, null, !TextUtils.isEmpty(settings.get().getSystemDisplayName()), isLocalNumber, settings.get(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +118,8 @@ class RecipientProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean systemContact = settings.isPresent() && !TextUtils.isEmpty(settings.get().getSystemDisplayName());
|
boolean systemContact = settings.isPresent() && !TextUtils.isEmpty(settings.get().getSystemDisplayName());
|
||||||
boolean isLocalNumber = address.serialize().equals(TextSecurePreferences.getLocalNumber(context));
|
TextSecurePreferences prefs = getPrefs(context);
|
||||||
|
boolean isLocalNumber = address.serialize().equals(prefs.getLocalNumber());
|
||||||
return new RecipientDetails(null, null, systemContact, isLocalNumber, settings.orNull(), null);
|
return new RecipientDetails(null, null, systemContact, isLocalNumber, settings.orNull(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user