mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Remove mirrored timer texts
as we can't detect reliably if a timer setting was mirrored or manually changed. Also remove item update optimization from adapter as this can cause issues when items already exist.
This commit is contained in:
@@ -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<ConversationItem> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ abstract class ConversationItem {
|
||||
private final long time, autoDeleteTimer;
|
||||
private final boolean isIncoming;
|
||||
private final LiveData<String> contactName;
|
||||
private boolean read, sent, seen, showTimerNotice, timerMirrored;
|
||||
private boolean read, sent, seen, showTimerNotice;
|
||||
|
||||
ConversationItem(@LayoutRes int layoutRes, ConversationMessageHeader h,
|
||||
LiveData<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -166,14 +166,10 @@
|
||||
<string name="set_contact_alias">Change contact name</string>
|
||||
<string name="set_contact_alias_hint">Contact name</string>
|
||||
<string name="menu_item_auto_delete">Disappearing messages</string>
|
||||
<string name="auto_delete_msg_you_enabled">You turned on disappearing messages. Your messages will disappear after 7 days.</string>
|
||||
<string name="auto_delete_msg_you_disabled">You turned off disappearing messages. Your messages will not disappear.</string>
|
||||
<string name="auto_delete_msg_you_enabled_mirrored">Your messages will disappear after 7 days.</string>
|
||||
<string name="auto_delete_msg_you_disabled_mirrored">Your messages will not disappear.</string>
|
||||
<string name="auto_delete_msg_contact_enabled">%1$s turned on disappearing messages. %2$s\'s messages will disappear after 7 days.</string>
|
||||
<string name="auto_delete_msg_contact_disabled">%1$s turned off disappearing messages. %2$s\'s messages will not disappear.</string>
|
||||
<string name="auto_delete_msg_contact_enabled_mirrored">%1$s\'s messages will disappear after 7 days.</string>
|
||||
<string name="auto_delete_msg_contact_disabled_mirrored">%1$s\'s messages will not disappear.</string>
|
||||
<string name="auto_delete_msg_you_enabled">Your messages will disappear after 7 days.</string>
|
||||
<string name="auto_delete_msg_you_disabled">Your messages will not disappear.</string>
|
||||
<string name="auto_delete_msg_contact_enabled">%1$s\'s messages will disappear after 7 days.</string>
|
||||
<string name="auto_delete_msg_contact_disabled">%1$s\'s messages will not disappear.</string>
|
||||
<string name="delete_all_messages">Delete all messages</string>
|
||||
<string name="dialog_title_delete_all_messages">Confirm Message Deletion</string>
|
||||
<string name="dialog_message_delete_all_messages">Are you sure that you want to delete all messages?</string>
|
||||
|
||||
Reference in New Issue
Block a user