diff --git a/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationAdapter.java b/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationAdapter.java index 662ea2729..84fddd084 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationAdapter.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationAdapter.java @@ -112,40 +112,36 @@ class ConversationAdapter public void add(ConversationItem item) { items.beginBatchedUpdates(); items.add(item); - updateTimersInBatch(true); + updateTimersInBatch(); items.endBatchedUpdates(); } @Override public void addAll(Collection itemsToAdd) { items.beginBatchedUpdates(); + // there can be items already in the adapter + // SortedList takes care of duplicates and detecting changed items items.addAll(itemsToAdd); - updateTimersInBatch(false); + updateTimersInBatch(); items.endBatchedUpdates(); } - private void updateTimersInBatch(boolean updateItems) { + private void updateTimersInBatch() { long lastTimerIncoming = NO_AUTO_DELETE_TIMER; long lastTimerOutgoing = NO_AUTO_DELETE_TIMER; for (int i = 0; i < items.size(); i++) { ConversationItem c = items.get(i); boolean itemChanged; boolean timerChanged; - boolean timerMirrored; if (c.isIncoming()) { timerChanged = lastTimerIncoming != c.getAutoDeleteTimer(); - timerMirrored = timerChanged && - lastTimerOutgoing == c.getAutoDeleteTimer(); lastTimerIncoming = c.getAutoDeleteTimer(); } else { timerChanged = lastTimerOutgoing != c.getAutoDeleteTimer(); - timerMirrored = timerChanged && - lastTimerIncoming == c.getAutoDeleteTimer(); lastTimerOutgoing = c.getAutoDeleteTimer(); } itemChanged = c.setTimerNoticeVisible(timerChanged); - itemChanged |= c.setTimerMirrored(timerMirrored); - if (itemChanged && updateItems) items.updateItemAt(i, c); + if (itemChanged) items.updateItemAt(i, c); } } diff --git a/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationItem.java b/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationItem.java index 2802892ce..c3d96e462 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationItem.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationItem.java @@ -26,7 +26,7 @@ abstract class ConversationItem { private final long time, autoDeleteTimer; private final boolean isIncoming; private final LiveData contactName; - private boolean read, sent, seen, showTimerNotice, timerMirrored; + private boolean read, sent, seen, showTimerNotice; ConversationItem(@LayoutRes int layoutRes, ConversationMessageHeader h, LiveData contactName) { @@ -42,7 +42,6 @@ abstract class ConversationItem { this.isIncoming = !h.isLocal(); this.contactName = contactName; this.showTimerNotice = false; - this.timerMirrored = false; } @LayoutRes @@ -143,23 +142,4 @@ abstract class ConversationItem { boolean isTimerNoticeVisible() { return showTimerNotice; } - - /** - * Set this to true when {@link #getAutoDeleteTimer()} has changed - * to the same timer of the last message - * from the other peer in this conversation. - * - * @return true if the value was set, false if it was already set. - */ - public boolean setTimerMirrored(boolean timerMirrored) { - if (this.timerMirrored != timerMirrored) { - this.timerMirrored = timerMirrored; - return true; - } - return false; - } - - public boolean wasTimerMirrored() { - return timerMirrored; - } } diff --git a/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationItemViewHolder.java b/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationItemViewHolder.java index c0d552e3f..8c3dc790d 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationItemViewHolder.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/conversation/ConversationItemViewHolder.java @@ -84,28 +84,14 @@ abstract class ConversationItemViewHolder extends ViewHolder { String text; if (item.isIncoming()) { String name = item.getContactName().getValue(); - if (item.wasTimerMirrored()) { - int strRes = enabled ? - R.string.auto_delete_msg_contact_enabled_mirrored : - R.string.auto_delete_msg_contact_disabled_mirrored; - text = ctx.getString(strRes, name); - } else { - int strRes = enabled ? - R.string.auto_delete_msg_contact_enabled : - R.string.auto_delete_msg_contact_disabled; - text = ctx.getString(strRes, name, name); - } + int strRes = enabled ? + R.string.auto_delete_msg_contact_enabled : + R.string.auto_delete_msg_contact_disabled; + text = ctx.getString(strRes, name); } else { - int strRes; - if (item.wasTimerMirrored()) { - strRes = enabled ? - R.string.auto_delete_msg_you_enabled_mirrored : - R.string.auto_delete_msg_you_disabled_mirrored; - } else { - strRes = enabled ? - R.string.auto_delete_msg_you_enabled : - R.string.auto_delete_msg_you_disabled; - } + int strRes = enabled ? + R.string.auto_delete_msg_you_enabled : + R.string.auto_delete_msg_you_disabled; text = ctx.getString(strRes); } topNotice.setText(text); diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index 424747dd9..cc553ef2d 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -166,14 +166,10 @@ Change contact name Contact name Disappearing messages - You turned on disappearing messages. Your messages will disappear after 7 days. - You turned off disappearing messages. Your messages will not disappear. - Your messages will disappear after 7 days. - Your messages will not disappear. - %1$s turned on disappearing messages. %2$s\'s messages will disappear after 7 days. - %1$s turned off disappearing messages. %2$s\'s messages will not disappear. - %1$s\'s messages will disappear after 7 days. - %1$s\'s messages will not disappear. + Your messages will disappear after 7 days. + Your messages will not disappear. + %1$s\'s messages will disappear after 7 days. + %1$s\'s messages will not disappear. Delete all messages Confirm Message Deletion Are you sure that you want to delete all messages?