Skip to content

Commit

Permalink
add contact status indicators, fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Apr 4, 2019
1 parent 46f937a commit 2fbf438
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 27 deletions.
21 changes: 16 additions & 5 deletions app/src/main/java/co/tinode/tindroid/ChatsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.HashMap;
Expand Down Expand Up @@ -205,8 +206,11 @@ static class ViewHolder extends RecyclerView.ViewHolder {
TextView name;
TextView unreadCount;
TextView contactPriv;
AppCompatImageView icon;
AppCompatImageView online;
AppCompatImageView avatar;
ImageView online;
ImageView muted;
ImageView blocked;
ImageView archived;

ContactDetails details;
ClickListener clickListener;
Expand All @@ -219,8 +223,11 @@ static class ViewHolder extends RecyclerView.ViewHolder {
name = item.findViewById(R.id.contactName);
unreadCount = item.findViewById(R.id.unreadCount);
contactPriv = item.findViewById(R.id.contactPriv);
icon = item.findViewById(R.id.avatar);
avatar = item.findViewById(R.id.avatar);
online = item.findViewById(R.id.online);
muted = item.findViewById(R.id.icon_muted);
blocked = item.findViewById(R.id.icon_blocked);
archived = item.findViewById(R.id.icon_archived);

details = new ContactDetails();
clickListener = cl;
Expand Down Expand Up @@ -255,16 +262,20 @@ void bind(int position, final ComTopic<VxCard> topic, boolean selected) {
unreadCount.setText(unread > 9 ? "9+" : String.valueOf(unread));
unreadCount.setVisibility(View.VISIBLE);
} else {
unreadCount.setVisibility(View.INVISIBLE);
unreadCount.setVisibility(View.GONE);
}

icon.setImageDrawable(UiUtils.avatarDrawable(context,
avatar.setImageDrawable(UiUtils.avatarDrawable(context,
pub != null ? pub.getBitmap() : null,
pub != null ? pub.fn : null,
topicName));

online.setColorFilter(topic.getOnline() ? sColorOnline : sColorOffline);

muted.setVisibility(topic.isMuted() ? View.VISIBLE : View.GONE);
archived.setVisibility(topic.isArchived() ? View.VISIBLE : View.GONE);
blocked.setVisibility(!topic.isJoiner() ? View.VISIBLE : View.GONE);

if (selected) {
itemView.setBackgroundResource(R.drawable.contact_background);
itemView.setOnClickListener(null);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF757575"
android:fillColor="#dd000000"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-4.42 3.58,-8 8,-8 1.85,0 3.55,0.63 4.9,1.69L5.69,16.9C4.63,15.55 4,13.85 4,12zM12,20c-1.85,0 -3.55,-0.63 -4.9,-1.69L18.31,7.1C19.37,8.45 20,10.15 20,12c0,4.42 -3.58,8 -8,8z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_block_gray.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF757575"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-4.42 3.58,-8 8,-8 1.85,0 3.55,0.63 4.9,1.69L5.69,16.9C4.63,15.55 4,13.85 4,12zM12,20c-1.85,0 -3.55,-0.63 -4.9,-1.69L18.31,7.1C19.37,8.45 20,10.15 20,12c0,4.42 -3.58,8 -8,8z"/>
</vector>
24 changes: 8 additions & 16 deletions app/src/main/res/drawable/ic_filecab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m7.2455,2.7352 l9.509,0.0296"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="1.4700408"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:fillType="evenOdd"
android:pathData="m7.25,2.74 l9.5,0.03"
android:strokeWidth="1.47"
android:strokeColor="#dd000000"
android:strokeLineCap="round"/>
<path
android:pathData="m5.9985,5.4383 l12.003,0.0236"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="1.47599149"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:fillType="evenOdd"
android:pathData="m6,5.44 l12,0.02"
android:strokeWidth="1.47"
android:strokeColor="#dd000000"
android:strokeLineCap="round"/>
<path
android:pathData="M6.5479,7.2993C5.0358,7.2993 3.8188,8.4359 3.8188,9.8467L3.8188,19.4531C3.8188,20.8639 5.0358,22.0005 6.5479,22.0005L17.5884,22.0005C19.1004,22.0005 20.3188,20.8639 20.3188,19.4531L20.3188,9.8467C20.3188,8.4359 19.1004,7.2993 17.5884,7.2993L6.5479,7.2993zM9.3003,10.6011A0.7381,0.7381 0,0 1,10.0503 11.3496L10.0503,12.4116C11.337,12.4066 12.6398,12.3964 13.9497,12.4116C13.9498,12.1347 13.9499,12.0992 13.9497,11.3496A0.7383,0.7383 0,1 1,15.4263 11.3496C15.4267,12.6205 15.4263,13.1499 15.4263,13.1499A0.7381,0.7381 0,0 1,14.6704 13.8882C12.9071,13.8456 11.1077,13.8922 9.3105,13.8882A0.7381,0.7381 0,0 1,8.5737 13.1499L8.5737,11.3496A0.7381,0.7381 0,0 1,9.3003 10.6011z"
android:fillColor="#000000"/>
android:pathData="M6.55,7.3C5,7.3 3.8,8.4 3.8,9.8L3.8,19.45C3.8,20.86 5,22 6.5,22L17.6,22C19.1,22 20.3188,20.8639 20.3188,19.4531L20.3188,9.8467C20.3188,8.4359 19.1004,7.2993 17.5884,7.2993L6.5479,7.2993zM9.3003,10.6011A0.7381,0.7381 0,0 1,10.0503 11.3496L10.0503,12.4116C11.337,12.4066 12.6398,12.3964 13.9497,12.4116C13.9498,12.1347 13.9499,12.0992 13.9497,11.3496A0.7383,0.7383 0,1 1,15.4263 11.3496C15.4267,12.6205 15.4263,13.1499 15.4263,13.1499A0.7381,0.74 0,0 1,14.7 13.92C12.9,13.8 11.1,13.9 9.3,13.92A0.74,0.74 0,0 1,8.6 13.15L8.6,11.35A0.74,0.7 0,0 1,9.3 10.6z"
android:fillColor="#dd000000"/>
</vector>
31 changes: 29 additions & 2 deletions app/src/main/res/layout/contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@

<TextView
android:id="@+id/unreadCount"
android:layout_width="20sp"
android:layout_height="20sp"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="end|center_vertical"
android:background="@drawable/pill_counter"
android:padding="3dp"
Expand All @@ -70,6 +70,33 @@
tools:text="9+"
/>

<ImageView
android:id="@+id/icon_muted"
android:layout_width="20dp"
android:layout_height="20dp"
android:alpha="0.2"
android:contentDescription="@string/topic_muted"
android:visibility="gone"
app:srcCompat="@drawable/ic_notifications_off"/>

<ImageView
android:id="@+id/icon_blocked"
android:layout_width="20dp"
android:layout_height="20dp"
android:alpha="0.2"
android:contentDescription="@string/topic_blocked"
android:visibility="gone"
app:srcCompat="@drawable/ic_block"/>

<ImageView
android:id="@+id/icon_archived"
android:layout_width="20dp"
android:layout_height="20dp"
android:alpha="0.2"
android:contentDescription="@string/topic_archived"
android:visibility="gone"
app:srcCompat="@drawable/ic_filecab"/>

</LinearLayout>

<TextView android:id="@+id/contactPriv"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dialog_accept_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawablePadding="4sp"
app:drawableStartCompat="@drawable/ic_block"
app:drawableStartCompat="@drawable/ic_block_gray"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/new_chat_block"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dialog_member_actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawablePadding="4sp"
app:drawableStartCompat="@drawable/ic_block"
app:drawableStartCompat="@drawable/ic_block_gray"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/block"/>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,7 @@
<string name="content_type_label">Content type:</string>
<string name="image_size_label">Size:</string>
<string name="must_subscribe_first">Must subscribe first</string>
<string name="topic_blocked">Blocked</string>
<string name="topic_archived">Archived</string>

</resources>
6 changes: 5 additions & 1 deletion tinodesdk/src/main/java/co/tinode/tinodesdk/Topic.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ protected void update(Map<String,Object> params, MetaSetSub sub) {


// This is an update to someone else's subscription to topic (given)
Subscription<SP,SR> s = mSubs.get(user);
Subscription<SP,SR> s = getSubscription(user);
if (s == null) {
s = new Subscription<>();
s.user = user;
Expand Down Expand Up @@ -551,6 +551,10 @@ public boolean isWriter() {
return mDesc.acs != null && mDesc.acs.isWriter();
}

public boolean isJoiner() {
return mDesc.acs != null && mDesc.acs.isJoiner();
}

public Defacs getDefacs() {
return mDesc.defacs;
}
Expand Down

0 comments on commit 2fbf438

Please sign in to comment.