hrukudah #15
|
@ -523,7 +523,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
AvatarWorkerTask.loadAvatar(contact, binding.detailsContactBadge, R.dimen.avatar_on_details_screen_size);
|
AvatarWorkerTask.loadAvatar(contact, binding.detailsContactBadge, R.dimen.avatar_on_details_screen_size);
|
||||||
binding.detailsContactBadge.setOnClickListener(this::onBadgeClick);
|
binding.detailsContactBadge.setOnClickListener(this::onBadgeClick);
|
||||||
|
|
||||||
binding.presenceIndicator.setStatus(contact.getShownStatus());
|
binding.presenceIndicator.setStatus(contact);
|
||||||
|
|
||||||
binding.detailsContactKeys.removeAllViews();
|
binding.detailsContactKeys.removeAllViews();
|
||||||
boolean hasKeys = false;
|
boolean hasKeys = false;
|
||||||
|
|
|
@ -393,7 +393,7 @@ public class ConversationAdapter
|
||||||
Contact contact = conversation.getContact();
|
Contact contact = conversation.getContact();
|
||||||
|
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
viewHolder.binding.presenceIndicator.setStatus(contact.getShownStatus());
|
viewHolder.binding.presenceIndicator.setStatus(contact);
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.presenceIndicator.setStatus(null);
|
viewHolder.binding.presenceIndicator.setStatus(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
||||||
AvatarWorkerTask.loadAvatar(item, viewHolder.avatar, R.dimen.avatar);
|
AvatarWorkerTask.loadAvatar(item, viewHolder.avatar, R.dimen.avatar);
|
||||||
|
|
||||||
if (item instanceof Contact) {
|
if (item instanceof Contact) {
|
||||||
viewHolder.presenceIndicator.setStatus(((Contact) item).getShownStatus());
|
viewHolder.presenceIndicator.setStatus(((Contact) item));
|
||||||
} else {
|
} else {
|
||||||
viewHolder.presenceIndicator.setStatus(null);
|
viewHolder.presenceIndicator.setStatus(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class UserAdapter extends ListAdapter<MucOptions.User, UserAdapter.ViewHo
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.contactJid.setText(ConferenceDetailsActivity.getStatus(viewHolder.binding.getRoot().getContext(), user, advancedMode));
|
viewHolder.binding.contactJid.setText(ConferenceDetailsActivity.getStatus(viewHolder.binding.getRoot().getContext(), user, advancedMode));
|
||||||
}
|
}
|
||||||
viewHolder.binding.presenceIndicator.setStatus(contact.getShownStatus());
|
viewHolder.binding.presenceIndicator.setStatus(contact);
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.contactDisplayName.setText(name == null ? "" : name);
|
viewHolder.binding.contactDisplayName.setText(name == null ? "" : name);
|
||||||
viewHolder.binding.contactJid.setText(ConferenceDetailsActivity.getStatus(viewHolder.binding.getRoot().getContext(), user, advancedMode));
|
viewHolder.binding.contactJid.setText(ConferenceDetailsActivity.getStatus(viewHolder.binding.getRoot().getContext(), user, advancedMode));
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class UserPreviewAdapter extends ListAdapter<MucOptions.User, UserPreview
|
||||||
AvatarWorkerTask.loadAvatar(user, viewHolder.binding.avatar, R.dimen.media_size);
|
AvatarWorkerTask.loadAvatar(user, viewHolder.binding.avatar, R.dimen.media_size);
|
||||||
Contact contact = user.getContact();
|
Contact contact = user.getContact();
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
viewHolder.binding.presenceIndicator.setStatus(user.getContact().getShownStatus());
|
viewHolder.binding.presenceIndicator.setStatus(user.getContact());
|
||||||
} else {
|
} else {
|
||||||
viewHolder.binding.presenceIndicator.setStatus(null);
|
viewHolder.binding.presenceIndicator.setStatus(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,11 @@ import android.graphics.Paint
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewOutlineProvider
|
import android.view.ViewOutlineProvider
|
||||||
|
import eu.siacs.conversations.entities.Contact
|
||||||
import eu.siacs.conversations.entities.Presence
|
import eu.siacs.conversations.entities.Presence
|
||||||
import eu.siacs.conversations.ui.util.StyledAttributes
|
import eu.siacs.conversations.ui.util.StyledAttributes
|
||||||
import eu.siacs.conversations.utils.UIHelper
|
import eu.siacs.conversations.utils.UIHelper
|
||||||
|
import eu.siacs.conversations.xml.Namespace
|
||||||
|
|
||||||
class PresenceIndicator : View {
|
class PresenceIndicator : View {
|
||||||
private var paint: Paint = Paint().also {
|
private var paint: Paint = Paint().also {
|
||||||
|
@ -19,13 +21,7 @@ class PresenceIndicator : View {
|
||||||
it.strokeWidth = 1 * Resources.getSystem().displayMetrics.density
|
it.strokeWidth = 1 * Resources.getSystem().displayMetrics.density
|
||||||
}
|
}
|
||||||
|
|
||||||
var status: Presence.Status? = null
|
private var status: Presence.Status? = null
|
||||||
set(value) {
|
|
||||||
if (field != value) {
|
|
||||||
field = value
|
|
||||||
invalidate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(context: Context?) : super(context)
|
constructor(context: Context?) : super(context)
|
||||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
||||||
|
@ -51,6 +47,18 @@ class PresenceIndicator : View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setStatus(contact: Contact?) {
|
||||||
|
val status = contact?.shownStatus
|
||||||
|
if ((status == Presence.Status.ONLINE || status == Presence.Status.CHAT) &&
|
||||||
|
(contact.lastseen <= 0 || !contact.presences.allOrNonSupport(Namespace.IDLE) || ((System.currentTimeMillis() - contact.lastseen) / 1000) > 60)) {
|
||||||
|
this.status = null
|
||||||
|
} else {
|
||||||
|
this.status = status
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue