mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #2144 from deltachat/display-last-seen
Display last-seen info in profile
This commit is contained in:
@@ -1722,6 +1722,12 @@ JNIEXPORT jstring Java_com_b44t_messenger_DcContact_getStatus(JNIEnv *env, jobje
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jlong Java_com_b44t_messenger_DcContact_getLastSeen(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return JTIMESTAMP(dc_contact_get_last_seen(get_dc_contact(env, obj)));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcContact_isBlocked(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return (jboolean)(dc_contact_is_blocked(get_dc_contact(env, obj))!=0);
|
||||
|
||||
@@ -85,6 +85,8 @@
|
||||
<string name="this_month">This month</string>
|
||||
<string name="last_week">Last week</string>
|
||||
<string name="last_month">Last month</string>
|
||||
<string name="last_seen_at">Last seen at %1$s</string>
|
||||
<string name="last_seen_never">Last seen: Never</string>
|
||||
<!-- Translators: show beside messages that are "N minutes old". prefer a short string, prefer abbreviations if they're well-known -->
|
||||
<plurals name="n_minutes">
|
||||
<item quantity="one">%d min</item>
|
||||
|
||||
@@ -54,6 +54,7 @@ public class DcContact {
|
||||
public native String getProfileImage();
|
||||
public native int getColor ();
|
||||
public native String getStatus ();
|
||||
public native long getLastSeen ();
|
||||
public native boolean isBlocked ();
|
||||
public native boolean isVerified ();
|
||||
|
||||
|
||||
@@ -69,6 +69,17 @@ public class ConversationTitleView extends RelativeLayout {
|
||||
title.setText(dcChat.getName());
|
||||
String subtitleStr = "ErrSubtitle";
|
||||
|
||||
// set icons etc.
|
||||
int imgLeft = 0;
|
||||
int imgRight = 0;
|
||||
|
||||
if (dcChat.isMuted()) {
|
||||
imgLeft = R.drawable.ic_volume_off_white_18dp;
|
||||
}
|
||||
if (dcChat.isProtected()) {
|
||||
imgRight = R.drawable.ic_verified;
|
||||
}
|
||||
|
||||
int[] chatContacts = dcContext.getChatContacts(chatId);
|
||||
if (dcChat.isMailingList()) {
|
||||
subtitleStr = context.getString(R.string.mailing_list);
|
||||
@@ -84,23 +95,16 @@ public class ConversationTitleView extends RelativeLayout {
|
||||
subtitleStr = context.getString(R.string.device_talk_subtitle);
|
||||
}
|
||||
else {
|
||||
subtitleStr = dcContext.getContact(chatContacts[0]).getAddr();
|
||||
DcContact dcContact = dcContext.getContact(chatContacts[0]);
|
||||
subtitleStr = dcContact.getAddr();
|
||||
if (dcContact.isVerified()) {
|
||||
imgRight = R.drawable.ic_verified;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subtitle.setText(subtitleStr);
|
||||
|
||||
// set icons etc.
|
||||
int imgLeft = 0;
|
||||
int imgRight = 0;
|
||||
|
||||
if (dcChat.isMuted()) {
|
||||
imgLeft = R.drawable.ic_volume_off_white_18dp;
|
||||
}
|
||||
if (dcChat.isProtected()) {
|
||||
imgRight = R.drawable.ic_verified;
|
||||
}
|
||||
|
||||
avatar.setAvatar(glideRequests, new Recipient(getContext(), dcChat), false);
|
||||
title.setCompoundDrawablesWithIntrinsicBounds(imgLeft, 0, imgRight, 0);
|
||||
subtitle.setVisibility(showAddInfo? View.VISIBLE : View.GONE);
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.b44t.messenger.DcLot;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.contacts.ContactSelectionListItem;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.util.DateUtils;
|
||||
import org.thoughtcrime.securesms.util.StickyHeaderDecoration.StickyHeaderAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -235,11 +236,12 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
txt = context.getString(R.string.profile_shared_chats);
|
||||
break;
|
||||
case ItemData.TYPE_PRIMARY_SETTING:
|
||||
if(itemDataContact!=null && itemDataContact.isVerified()) {
|
||||
txt = context.getString(R.string.verified_contact);
|
||||
long lastSeen = (itemDataContact!=null? itemDataContact.getLastSeen() : 0);
|
||||
if (lastSeen == 0) {
|
||||
txt = context.getString(R.string.last_seen_never);
|
||||
}
|
||||
else {
|
||||
txt = context.getString(R.string.contact);
|
||||
txt = context.getString(R.string.last_seen_at, DateUtils.getExtendedTimeSpanString(context, locale, lastSeen));
|
||||
}
|
||||
break;
|
||||
case ItemData.TYPE_STATUS:
|
||||
|
||||
@@ -77,6 +77,19 @@ public class DateUtils extends android.text.format.DateUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getExtendedTimeSpanString(final Context c, final Locale locale, final long timestamp) {
|
||||
StringBuilder format = new StringBuilder();
|
||||
if (DateUtils.isToday(timestamp)) {}
|
||||
else if (isWithin(timestamp, 6, TimeUnit.DAYS)) format.append("EEE ");
|
||||
else if (isWithin(timestamp, 365, TimeUnit.DAYS)) format.append("MMM d, ");
|
||||
else format.append("MMM d, yyyy, ");
|
||||
|
||||
if (DateFormat.is24HourFormat(c)) format.append("HH:mm");
|
||||
else format.append("hh:mm a");
|
||||
|
||||
return getFormattedDateTime(timestamp, format.toString(), locale);
|
||||
}
|
||||
|
||||
public static String getExtendedRelativeTimeSpanString(final Context c, final Locale locale, final long timestamp) {
|
||||
if (isWithin(timestamp, 1, TimeUnit.MINUTES)) {
|
||||
return c.getString(R.string.now);
|
||||
@@ -84,16 +97,7 @@ public class DateUtils extends android.text.format.DateUtils {
|
||||
int mins = (int)TimeUnit.MINUTES.convert(System.currentTimeMillis() - timestamp, TimeUnit.MILLISECONDS);
|
||||
return c.getResources().getQuantityString(R.plurals.n_minutes, mins, mins);
|
||||
} else {
|
||||
StringBuilder format = new StringBuilder();
|
||||
if (DateUtils.isToday(timestamp)) {}
|
||||
else if (isWithin(timestamp, 6, TimeUnit.DAYS)) format.append("EEE ");
|
||||
else if (isWithin(timestamp, 365, TimeUnit.DAYS)) format.append("MMM d, ");
|
||||
else format.append("MMM d, yyyy, ");
|
||||
|
||||
if (DateFormat.is24HourFormat(c)) format.append("HH:mm");
|
||||
else format.append("hh:mm a");
|
||||
|
||||
return getFormattedDateTime(timestamp, format.toString(), locale);
|
||||
return getExtendedTimeSpanString(c, locale, timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user