kopia lustrzana https://github.com/ryukoposting/Signal-Android
Keep muted chats archived option.
rodzic
c674d5b674
commit
5e25e8d0a2
|
@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.components.settings.configure
|
||||||
import org.thoughtcrime.securesms.exporter.flow.SmsExportActivity
|
import org.thoughtcrime.securesms.exporter.flow.SmsExportActivity
|
||||||
import org.thoughtcrime.securesms.exporter.flow.SmsExportDialogs
|
import org.thoughtcrime.securesms.exporter.flow.SmsExportDialogs
|
||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
||||||
import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
||||||
|
|
||||||
|
@ -103,6 +104,17 @@ class ChatsSettingsFragment : DSLSettingsFragment(R.string.preferences_chats__ch
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (FeatureFlags.keepMutedChatsArchived() || FeatureFlags.internalUser()) {
|
||||||
|
switchPref(
|
||||||
|
title = DSLSettingsText.from(R.string.preferences__pref_keep_muted_chats_archived),
|
||||||
|
summary = DSLSettingsText.from(R.string.preferences__muted_chats_that_are_archived_will_remain_archived),
|
||||||
|
isChecked = state.keepMutedChatsArchived,
|
||||||
|
onClick = {
|
||||||
|
viewModel.setKeepMutedChatsArchived(!state.keepMutedChatsArchived)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
dividerPref()
|
dividerPref()
|
||||||
|
|
||||||
sectionHeaderPref(R.string.ChatsSettingsFragment__keyboard)
|
sectionHeaderPref(R.string.ChatsSettingsFragment__keyboard)
|
||||||
|
|
|
@ -39,4 +39,11 @@ class ChatsSettingsRepository {
|
||||||
StorageSyncHelper.scheduleSyncForDataChange()
|
StorageSyncHelper.scheduleSyncForDataChange()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun syncKeepMutedChatsArchivedState() {
|
||||||
|
SignalExecutors.BOUNDED.execute {
|
||||||
|
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
|
||||||
|
StorageSyncHelper.scheduleSyncForDataChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.thoughtcrime.securesms.components.settings.app.chats.sms.SmsExportSta
|
||||||
data class ChatsSettingsState(
|
data class ChatsSettingsState(
|
||||||
val generateLinkPreviews: Boolean,
|
val generateLinkPreviews: Boolean,
|
||||||
val useAddressBook: Boolean,
|
val useAddressBook: Boolean,
|
||||||
|
val keepMutedChatsArchived: Boolean,
|
||||||
val useSystemEmoji: Boolean,
|
val useSystemEmoji: Boolean,
|
||||||
val enterKeySends: Boolean,
|
val enterKeySends: Boolean,
|
||||||
val chatBackupsEnabled: Boolean,
|
val chatBackupsEnabled: Boolean,
|
||||||
|
|
|
@ -25,6 +25,7 @@ class ChatsSettingsViewModel @JvmOverloads constructor(
|
||||||
ChatsSettingsState(
|
ChatsSettingsState(
|
||||||
generateLinkPreviews = SignalStore.settings().isLinkPreviewsEnabled,
|
generateLinkPreviews = SignalStore.settings().isLinkPreviewsEnabled,
|
||||||
useAddressBook = SignalStore.settings().isPreferSystemContactPhotos,
|
useAddressBook = SignalStore.settings().isPreferSystemContactPhotos,
|
||||||
|
keepMutedChatsArchived = SignalStore.settings().shouldKeepMutedChatsArchived(),
|
||||||
useSystemEmoji = SignalStore.settings().isPreferSystemEmoji,
|
useSystemEmoji = SignalStore.settings().isPreferSystemEmoji,
|
||||||
enterKeySends = SignalStore.settings().isEnterKeySends,
|
enterKeySends = SignalStore.settings().isEnterKeySends,
|
||||||
chatBackupsEnabled = SignalStore.settings().isBackupEnabled && BackupUtil.canUserAccessBackupDirectory(ApplicationDependencies.getApplication()),
|
chatBackupsEnabled = SignalStore.settings().isBackupEnabled && BackupUtil.canUserAccessBackupDirectory(ApplicationDependencies.getApplication()),
|
||||||
|
@ -57,6 +58,12 @@ class ChatsSettingsViewModel @JvmOverloads constructor(
|
||||||
repository.syncPreferSystemContactPhotos()
|
repository.syncPreferSystemContactPhotos()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setKeepMutedChatsArchived(enabled: Boolean) {
|
||||||
|
store.update { it.copy(keepMutedChatsArchived = enabled) }
|
||||||
|
SignalStore.settings().setKeepMutedChatsArchived(enabled)
|
||||||
|
repository.syncKeepMutedChatsArchivedState()
|
||||||
|
}
|
||||||
|
|
||||||
fun setUseSystemEmoji(enabled: Boolean) {
|
fun setUseSystemEmoji(enabled: Boolean) {
|
||||||
store.update { it.copy(useSystemEmoji = enabled) }
|
store.update { it.copy(useSystemEmoji = enabled) }
|
||||||
SignalStore.settings().isPreferSystemEmoji = enabled
|
SignalStore.settings().isPreferSystemEmoji = enabled
|
||||||
|
|
|
@ -1980,6 +1980,7 @@ public class MmsDatabase extends MessageDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean updateThread = retrieved.getStoryType() == StoryType.NONE;
|
boolean updateThread = retrieved.getStoryType() == StoryType.NONE;
|
||||||
|
boolean keepThreadArchived = SignalStore.settings().shouldKeepMutedChatsArchived() && Recipient.resolved(retrieved.getFrom()).isMuted();
|
||||||
long messageId = insertMediaMessage(threadId,
|
long messageId = insertMediaMessage(threadId,
|
||||||
retrieved.getBody(),
|
retrieved.getBody(),
|
||||||
retrieved.getAttachments(),
|
retrieved.getAttachments(),
|
||||||
|
@ -1990,13 +1991,14 @@ public class MmsDatabase extends MessageDatabase {
|
||||||
retrieved.getMessageRanges(),
|
retrieved.getMessageRanges(),
|
||||||
contentValues,
|
contentValues,
|
||||||
null,
|
null,
|
||||||
updateThread);
|
updateThread,
|
||||||
|
!keepThreadArchived);
|
||||||
|
|
||||||
boolean isNotStoryGroupReply = retrieved.getParentStoryId() == null || !retrieved.getParentStoryId().isGroupReply();
|
boolean isNotStoryGroupReply = retrieved.getParentStoryId() == null || !retrieved.getParentStoryId().isGroupReply();
|
||||||
if (!Types.isPaymentsActivated(mailbox) && !Types.isRequestToActivatePayments(mailbox) && !Types.isExpirationTimerUpdate(mailbox) && !retrieved.getStoryType().isStory() && isNotStoryGroupReply) {
|
if (!Types.isPaymentsActivated(mailbox) && !Types.isRequestToActivatePayments(mailbox) && !Types.isExpirationTimerUpdate(mailbox) && !retrieved.getStoryType().isStory() && isNotStoryGroupReply) {
|
||||||
boolean incrementUnreadMentions = !retrieved.getMentions().isEmpty() && retrieved.getMentions().stream().anyMatch(m -> m.getRecipientId().equals(Recipient.self().getId()));
|
boolean incrementUnreadMentions = !retrieved.getMentions().isEmpty() && retrieved.getMentions().stream().anyMatch(m -> m.getRecipientId().equals(Recipient.self().getId()));
|
||||||
SignalDatabase.threads().incrementUnread(threadId, 1, incrementUnreadMentions ? 1 : 0);
|
SignalDatabase.threads().incrementUnread(threadId, 1, incrementUnreadMentions ? 1 : 0);
|
||||||
SignalDatabase.threads().update(threadId, true);
|
SignalDatabase.threads().update(threadId, !keepThreadArchived);
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
|
@ -2297,7 +2299,7 @@ public class MmsDatabase extends MessageDatabase {
|
||||||
|
|
||||||
MentionUtil.UpdatedBodyAndMentions updatedBodyAndMentions = MentionUtil.updateBodyAndMentionsWithPlaceholders(message.getBody(), message.getMentions());
|
MentionUtil.UpdatedBodyAndMentions updatedBodyAndMentions = MentionUtil.updateBodyAndMentionsWithPlaceholders(message.getBody(), message.getMentions());
|
||||||
|
|
||||||
long messageId = insertMediaMessage(threadId, updatedBodyAndMentions.getBodyAsString(), message.getAttachments(), quoteAttachments, message.getSharedContacts(), message.getLinkPreviews(), updatedBodyAndMentions.getMentions(), null, contentValues, insertListener, false);
|
long messageId = insertMediaMessage(threadId, updatedBodyAndMentions.getBodyAsString(), message.getAttachments(), quoteAttachments, message.getSharedContacts(), message.getLinkPreviews(), updatedBodyAndMentions.getMentions(), null, contentValues, insertListener, false, false);
|
||||||
|
|
||||||
if (message.getRecipient().isGroup()) {
|
if (message.getRecipient().isGroup()) {
|
||||||
OutgoingGroupUpdateMessage outgoingGroupUpdateMessage = (message instanceof OutgoingGroupUpdateMessage) ? (OutgoingGroupUpdateMessage) message : null;
|
OutgoingGroupUpdateMessage outgoingGroupUpdateMessage = (message instanceof OutgoingGroupUpdateMessage) ? (OutgoingGroupUpdateMessage) message : null;
|
||||||
|
@ -2371,7 +2373,8 @@ public class MmsDatabase extends MessageDatabase {
|
||||||
@Nullable BodyRangeList messageRanges,
|
@Nullable BodyRangeList messageRanges,
|
||||||
@NonNull ContentValues contentValues,
|
@NonNull ContentValues contentValues,
|
||||||
@Nullable InsertListener insertListener,
|
@Nullable InsertListener insertListener,
|
||||||
boolean updateThread)
|
boolean updateThread,
|
||||||
|
boolean unarchive)
|
||||||
throws MmsException
|
throws MmsException
|
||||||
{
|
{
|
||||||
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
|
||||||
|
@ -2443,7 +2446,7 @@ public class MmsDatabase extends MessageDatabase {
|
||||||
|
|
||||||
if (updateThread) {
|
if (updateThread) {
|
||||||
SignalDatabase.threads().setLastScrolled(contentValuesThreadId, 0);
|
SignalDatabase.threads().setLastScrolled(contentValuesThreadId, 0);
|
||||||
SignalDatabase.threads().update(threadId, true);
|
SignalDatabase.threads().update(threadId, unarchive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,8 +742,8 @@ public class SmsDatabase extends MessageDatabase {
|
||||||
|
|
||||||
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
||||||
}
|
}
|
||||||
|
boolean keepThreadArchived = SignalStore.settings().shouldKeepMutedChatsArchived() && recipient.isMuted();
|
||||||
SignalDatabase.threads().update(threadId, true);
|
SignalDatabase.threads().update(threadId, !keepThreadArchived);
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -820,7 +820,8 @@ public class SmsDatabase extends MessageDatabase {
|
||||||
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalDatabase.threads().update(threadId, true);
|
final boolean keepThreadArchived = SignalStore.settings().shouldKeepMutedChatsArchived() && recipient.isMuted();
|
||||||
|
SignalDatabase.threads().update(threadId, !keepThreadArchived);
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -891,8 +892,8 @@ public class SmsDatabase extends MessageDatabase {
|
||||||
if (unread) {
|
if (unread) {
|
||||||
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
||||||
}
|
}
|
||||||
|
boolean keepThreadArchived = SignalStore.settings().shouldKeepMutedChatsArchived() && Recipient.resolved(recipientId).isMuted();
|
||||||
SignalDatabase.threads().update(threadId, true);
|
SignalDatabase.threads().update(threadId, !keepThreadArchived);
|
||||||
|
|
||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
TrimThreadJob.enqueueAsync(threadId);
|
TrimThreadJob.enqueueAsync(threadId);
|
||||||
|
@ -1281,7 +1282,8 @@ public class SmsDatabase extends MessageDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
SignalDatabase.threads().update(threadId, true);
|
final boolean keepThreadArchived = SignalStore.settings().shouldKeepMutedChatsArchived() && recipient.isMuted();
|
||||||
|
SignalDatabase.threads().update(threadId, !keepThreadArchived);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.getSubscriptionId() != -1) {
|
if (message.getSubscriptionId() != -1) {
|
||||||
|
@ -1324,7 +1326,8 @@ public class SmsDatabase extends MessageDatabase {
|
||||||
long messageId = db.insert(TABLE_NAME, null, values);
|
long messageId = db.insert(TABLE_NAME, null, values);
|
||||||
|
|
||||||
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
||||||
SignalDatabase.threads().update(threadId, true);
|
boolean keepThreadArchived = SignalStore.settings().shouldKeepMutedChatsArchived() && Recipient.resolved(recipientId).isMuted();
|
||||||
|
SignalDatabase.threads().update(threadId, !keepThreadArchived);
|
||||||
|
|
||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
|
|
||||||
|
@ -1348,7 +1351,8 @@ public class SmsDatabase extends MessageDatabase {
|
||||||
databaseHelper.getSignalWritableDatabase().insert(TABLE_NAME, null, values);
|
databaseHelper.getSignalWritableDatabase().insert(TABLE_NAME, null, values);
|
||||||
|
|
||||||
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
SignalDatabase.threads().incrementUnread(threadId, 1, 0);
|
||||||
SignalDatabase.threads().update(threadId, true);
|
boolean keepThreadArchived = SignalStore.settings().shouldKeepMutedChatsArchived() && Recipient.resolved(recipientId).isMuted();
|
||||||
|
SignalDatabase.threads().update(threadId, !keepThreadArchived);
|
||||||
|
|
||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ public final class FeatureFlags {
|
||||||
private static final String SMS_EXPORT_MEGAPHONE_DELAY_DAYS = "android.smsExport.megaphoneDelayDays.2";
|
private static final String SMS_EXPORT_MEGAPHONE_DELAY_DAYS = "android.smsExport.megaphoneDelayDays.2";
|
||||||
public static final String CREDIT_CARD_PAYMENTS = "android.credit.card.payments";
|
public static final String CREDIT_CARD_PAYMENTS = "android.credit.card.payments";
|
||||||
private static final String PAYMENTS_REQUEST_ACTIVATE_FLOW = "android.payments.requestActivateFlow";
|
private static final String PAYMENTS_REQUEST_ACTIVATE_FLOW = "android.payments.requestActivateFlow";
|
||||||
|
private static final String KEEP_MUTED_CHATS_ARCHIVED = "android.keepMutedChatsArchived";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||||
|
@ -161,7 +162,8 @@ public final class FeatureFlags {
|
||||||
HIDE_CONTACTS,
|
HIDE_CONTACTS,
|
||||||
SMS_EXPORT_MEGAPHONE_DELAY_DAYS,
|
SMS_EXPORT_MEGAPHONE_DELAY_DAYS,
|
||||||
CREDIT_CARD_PAYMENTS,
|
CREDIT_CARD_PAYMENTS,
|
||||||
PAYMENTS_REQUEST_ACTIVATE_FLOW
|
PAYMENTS_REQUEST_ACTIVATE_FLOW,
|
||||||
|
KEEP_MUTED_CHATS_ARCHIVED
|
||||||
);
|
);
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -225,7 +227,8 @@ public final class FeatureFlags {
|
||||||
STORIES,
|
STORIES,
|
||||||
SMS_EXPORT_MEGAPHONE_DELAY_DAYS,
|
SMS_EXPORT_MEGAPHONE_DELAY_DAYS,
|
||||||
CREDIT_CARD_PAYMENTS,
|
CREDIT_CARD_PAYMENTS,
|
||||||
PAYMENTS_REQUEST_ACTIVATE_FLOW
|
PAYMENTS_REQUEST_ACTIVATE_FLOW,
|
||||||
|
KEEP_MUTED_CHATS_ARCHIVED
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -578,6 +581,13 @@ public final class FeatureFlags {
|
||||||
return getBoolean(PAYMENTS_REQUEST_ACTIVATE_FLOW, false);
|
return getBoolean(PAYMENTS_REQUEST_ACTIVATE_FLOW, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether users can enable keeping conversations with incoming messages archived if the conversation is muted.
|
||||||
|
*/
|
||||||
|
public static boolean keepMutedChatsArchived() {
|
||||||
|
return getBoolean(KEEP_MUTED_CHATS_ARCHIVED, false);
|
||||||
|
}
|
||||||
|
|
||||||
/** Only for rendering debug info. */
|
/** Only for rendering debug info. */
|
||||||
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
||||||
return new TreeMap<>(REMOTE_VALUES);
|
return new TreeMap<>(REMOTE_VALUES);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.database.MessageDatabase.InsertResult;
|
||||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.IdentityRecord;
|
import org.thoughtcrime.securesms.database.model.IdentityRecord;
|
||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
import org.thoughtcrime.securesms.notifications.v2.ConversationId;
|
import org.thoughtcrime.securesms.notifications.v2.ConversationId;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
|
@ -112,7 +113,8 @@ public final class IdentityUtil {
|
||||||
|
|
||||||
Log.i(TAG, "Inserting verified outbox...");
|
Log.i(TAG, "Inserting verified outbox...");
|
||||||
SignalDatabase.sms().insertMessageOutbox(threadId, outgoing, false, time, null);
|
SignalDatabase.sms().insertMessageOutbox(threadId, outgoing, false, time, null);
|
||||||
SignalDatabase.threads().update(threadId, true);
|
boolean keepThreadArchived = SignalStore.settings().shouldKeepMutedChatsArchived() && recipient.isMuted();
|
||||||
|
SignalDatabase.threads().update(threadId, !keepThreadArchived);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2664,6 +2664,10 @@
|
||||||
<string name="preferences__pressing_the_enter_key_will_send_text_messages">Pressing the Enter key will send text messages</string>
|
<string name="preferences__pressing_the_enter_key_will_send_text_messages">Pressing the Enter key will send text messages</string>
|
||||||
<string name="preferences__pref_use_address_book_photos">Use address book photos</string>
|
<string name="preferences__pref_use_address_book_photos">Use address book photos</string>
|
||||||
<string name="preferences__display_contact_photos_from_your_address_book_if_available">Display contact photos from your address book if available</string>
|
<string name="preferences__display_contact_photos_from_your_address_book_if_available">Display contact photos from your address book if available</string>
|
||||||
|
<!-- Preference menu item title for a toggle switch for preserving the archived state of muted chats. -->
|
||||||
|
<string name="preferences__pref_keep_muted_chats_archived">Keep Muted Chats Archived</string>
|
||||||
|
<!-- Preference menu item description for a toggle switch for preserving the archived state of muted chats. -->
|
||||||
|
<string name="preferences__muted_chats_that_are_archived_will_remain_archived">Muted chats that are archived will remain archived when a new message arrives.</string>
|
||||||
<string name="preferences__generate_link_previews">Generate link previews</string>
|
<string name="preferences__generate_link_previews">Generate link previews</string>
|
||||||
<string name="preferences__retrieve_link_previews_from_websites_for_messages">Retrieve link previews directly from websites for messages you send.</string>
|
<string name="preferences__retrieve_link_previews_from_websites_for_messages">Retrieve link previews directly from websites for messages you send.</string>
|
||||||
<string name="preferences__choose_identity">Choose identity</string>
|
<string name="preferences__choose_identity">Choose identity</string>
|
||||||
|
|
Ładowanie…
Reference in New Issue