mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
use dc_contact_was_seen_recently() (#2373)
* add DcContact.wasSeenRecently() * use DcContact.wasSeenRecently() and remove isSeenRecently() * remove now again unused imports
This commit is contained in:
@@ -1860,6 +1860,11 @@ JNIEXPORT jlong Java_com_b44t_messenger_DcContact_getLastSeen(JNIEnv *env, jobje
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcContact_wasSeenRecently(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return (jboolean)(dc_contact_was_seen_recently(get_dc_contact(env, obj))!=0);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcContact_isBlocked(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return (jboolean)(dc_contact_is_blocked(get_dc_contact(env, obj))!=0);
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.b44t.messenger;
|
||||
|
||||
import org.thoughtcrime.securesms.util.DateUtils;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class DcContact {
|
||||
|
||||
public final static int DC_CONTACT_ID_SELF = 1;
|
||||
@@ -50,10 +46,6 @@ public class DcContact {
|
||||
return getAddr();
|
||||
}
|
||||
|
||||
public boolean isSeenRecently() {
|
||||
return DateUtils.isWithin(getLastSeen(), 10, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public native int getId ();
|
||||
public native String getName ();
|
||||
public native String getDisplayName ();
|
||||
@@ -63,6 +55,7 @@ public class DcContact {
|
||||
public native int getColor ();
|
||||
public native String getStatus ();
|
||||
public native long getLastSeen ();
|
||||
public native boolean wasSeenRecently();
|
||||
public native boolean isBlocked ();
|
||||
public native boolean isVerified ();
|
||||
|
||||
|
||||
@@ -1580,7 +1580,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|| eventId == DcContext.DC_EVENT_MSG_DELIVERED)
|
||||
&& event.getData1Int() == chatId) {
|
||||
DcContact contact = recipient.getDcContact();
|
||||
titleView.setSeenRecently(contact!=null? contact.isSeenRecently() : false);
|
||||
titleView.setSeenRecently(contact!=null? contact.wasSeenRecently() : false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
this.avatar.setAvatar(glideRequests, recipient, false);
|
||||
|
||||
DcContact contact = recipient.getDcContact();
|
||||
avatar.setSeenRecently(contact!=null? contact.isSeenRecently() : false);
|
||||
avatar.setSeenRecently(contact!=null? contact.wasSeenRecently() : false);
|
||||
|
||||
fromView.setCompoundDrawablesWithIntrinsicBounds(
|
||||
thread.isMuted()? R.drawable.ic_volume_off_grey600_18dp : 0,
|
||||
@@ -198,7 +198,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
|
||||
setBatchState(false);
|
||||
avatar.setAvatar(glideRequests, recipient, false);
|
||||
avatar.setSeenRecently(contact.isSeenRecently());
|
||||
avatar.setSeenRecently(contact.wasSeenRecently());
|
||||
}
|
||||
|
||||
public void bind(@NonNull DcMsg messageResult,
|
||||
|
||||
@@ -110,7 +110,7 @@ public class ConversationTitleView extends RelativeLayout {
|
||||
if (dcContact.isVerified()) {
|
||||
imgRight = R.drawable.ic_verified;
|
||||
}
|
||||
isOnline = dcContact.isSeenRecently();
|
||||
isOnline = dcContact.wasSeenRecently();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ConversationTitleView extends RelativeLayout {
|
||||
// the verified state is _not_ shown in the title. this will be confusing as in the one-to-one-ChatViews, the verified
|
||||
// icon is also not shown as these chats are always opportunistic chats
|
||||
avatar.setAvatar(glideRequests, new Recipient(getContext(), contact), false);
|
||||
avatar.setSeenRecently(contact.isSeenRecently());
|
||||
avatar.setSeenRecently(contact.wasSeenRecently());
|
||||
title.setText(contact.getDisplayName());
|
||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||
subtitle.setText(contact.getAddr());
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
|
||||
}
|
||||
}
|
||||
this.avatar.setAvatar(glideRequests, recipient, false);
|
||||
this.avatar.setSeenRecently(contact!=null? contact.isSeenRecently() : false);
|
||||
this.avatar.setSeenRecently(contact!=null? contact.wasSeenRecently() : false);
|
||||
|
||||
setText(name, number, label, contact);
|
||||
setEnabled(enabled);
|
||||
@@ -144,7 +144,7 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
|
||||
Util.runOnMain(() -> {
|
||||
avatar.setAvatar(glideRequests, recipient, false);
|
||||
DcContact contact = recipient.getDcContact();
|
||||
avatar.setSeenRecently(contact!=null? contact.isSeenRecently() : false);
|
||||
avatar.setSeenRecently(contact!=null? contact.wasSeenRecently() : false);
|
||||
nameView.setText(recipient.toShortString());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DateUtils extends android.text.format.DateUtils {
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = DateUtils.class.getSimpleName();
|
||||
|
||||
public static boolean isWithin(final long millis, final long span, final TimeUnit unit) {
|
||||
private static boolean isWithin(final long millis, final long span, final TimeUnit unit) {
|
||||
return System.currentTimeMillis() - millis <= unit.toMillis(span);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user