mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
call "markseen" on messages scrolled into view #100
This commit is contained in:
@@ -19,6 +19,7 @@ public class DcMsg {
|
||||
public final static int DC_STATE_UNDEFINED = 0;
|
||||
public final static int DC_STATE_IN_FRESH = 10;
|
||||
public final static int DC_STATE_IN_NOTICED = 13;
|
||||
public final static int DC_STATE_IN_SEEN = 16;
|
||||
public final static int DC_STATE_OUT_PENDING = 20;
|
||||
public final static int DC_STATE_OUT_ERROR = 24;
|
||||
public final static int DC_STATE_OUT_DELIVERED = 26;
|
||||
@@ -143,6 +144,9 @@ public class DcMsg {
|
||||
public boolean isRemoteRead() {
|
||||
return getState() == DC_STATE_OUT_MDN_RCVD;
|
||||
}
|
||||
public boolean isSeen() {
|
||||
return getState() == DC_STATE_IN_SEEN;
|
||||
}
|
||||
public int getSubscriptionId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
|
||||
return dcMsgList[dcMsgList.length-1-position];
|
||||
}
|
||||
|
||||
private @NonNull DcMsg getMsg(int position) {
|
||||
public @NonNull DcMsg getMsg(int position) {
|
||||
if(position<0 || position>=dcMsgList.length) {
|
||||
return new DcMsg(0);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.b44t.messenger.DcContact.DC_CONTACT_ID_SELF;
|
||||
import static org.thoughtcrime.securesms.ShareActivity.EXTRA_FORWARD;
|
||||
import static org.thoughtcrime.securesms.ShareActivity.EXTRA_MSG_IDS;
|
||||
|
||||
@@ -590,6 +591,7 @@ public class ConversationFragment extends Fragment
|
||||
boolean currentlyAtBottom = isAtBottom();
|
||||
boolean currentlyAtZoomScrollHeight = isAtZoomScrollHeight();
|
||||
int positionId = getHeaderPositionId();
|
||||
int firstItemPosition = getFirstItemPosition();
|
||||
|
||||
if (currentlyAtBottom && !wasAtBottom) {
|
||||
ViewUtil.animateOut(scrollToBottomButton, scrollButtonOutAnimation, View.INVISIBLE);
|
||||
@@ -606,6 +608,7 @@ public class ConversationFragment extends Fragment
|
||||
wasAtBottom = currentlyAtBottom;
|
||||
wasAtZoomScrollHeight = currentlyAtZoomScrollHeight;
|
||||
lastPositionId = positionId;
|
||||
manageMessageSeenState(firstItemPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -635,6 +638,10 @@ public class ConversationFragment extends Fragment
|
||||
return ((LinearLayoutManager)list.getLayoutManager()).findLastVisibleItemPosition();
|
||||
}
|
||||
|
||||
private int getFirstItemPosition() {
|
||||
return ((LinearLayoutManager)list.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
|
||||
}
|
||||
|
||||
private void bindScrollHeader(HeaderViewHolder headerViewHolder, int positionId) {
|
||||
if (((ConversationAdapter)list.getAdapter()).getHeaderId(positionId) != -1) {
|
||||
((ConversationAdapter) list.getAdapter()).onBindHeaderViewHolder(headerViewHolder, positionId);
|
||||
@@ -642,6 +649,13 @@ public class ConversationFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
private void manageMessageSeenState(int firstItemPosition) {
|
||||
DcMsg message = ((ConversationAdapter) list.getAdapter()).getMsg(firstItemPosition);
|
||||
if (message.getFromId() != DC_CONTACT_ID_SELF && !message.isSeen()) {
|
||||
dcContext.markseenMsgs(new int[]{message.getId()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void querySetupCode(final DcMsg dcMsg, String[] preload)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user