Fix participant list call state

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-05-14 09:50:55 +02:00 committed by Andy Scherzinger
parent 8d15a4b671
commit 39a848afa4
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
9 changed files with 65 additions and 241 deletions

View File

@ -37,6 +37,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.models.database.UserEntity;
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
import com.nextcloud.talk.models.json.participants.Participant;
import com.nextcloud.talk.models.json.participants.Participant.InCallFlags;
import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.DisplayUtils;
@ -186,56 +187,24 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
if (header == null) {
Participant.ParticipantFlags participantFlags = participant.getParticipantFlags();
switch (participantFlags) {
case NOT_IN_CALL:
holder.voiceOrSimpleCallImageView.setVisibility(View.GONE);
holder.videoCallImageView.setVisibility(View.GONE);
break;
case IN_CALL:
holder.voiceOrSimpleCallImageView.setBackground(
ResourcesCompat.getDrawable(resources, R.drawable.shape_call_bubble, null));
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
holder.voiceOrSimpleCallImageView.setContentDescription(
resources.getString(R.string.nc_call_state_in_call, participant.displayName));
holder.videoCallImageView.setVisibility(View.GONE);
break;
case IN_CALL_WITH_AUDIO:
holder.voiceOrSimpleCallImageView.setBackground(
ResourcesCompat.getDrawable(resources, R.drawable.shape_voice_bubble, null));
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
holder.voiceOrSimpleCallImageView.setContentDescription(
resources.getString(R.string.nc_call_state_in_call_with_audio, participant.displayName));
holder.videoCallImageView.setVisibility(View.GONE);
break;
case IN_CALL_WITH_VIDEO:
holder.voiceOrSimpleCallImageView.setBackground(
ResourcesCompat.getDrawable(resources, R.drawable.shape_call_bubble, null));
holder.videoCallImageView.setBackground(
ResourcesCompat.getDrawable(resources, R.drawable.shape_video_bubble, null));
holder.voiceOrSimpleCallImageView.setContentDescription(
resources.getString(R.string.nc_call_state_in_call, participant.displayName));
holder.videoCallImageView.setContentDescription(
resources.getString(R.string.nc_call_state_with_video, participant.displayName));
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
holder.videoCallImageView.setVisibility(View.VISIBLE);
break;
case IN_CALL_WITH_AUDIO_AND_VIDEO:
holder.voiceOrSimpleCallImageView.setBackground(
ResourcesCompat.getDrawable(resources, R.drawable.shape_voice_bubble, null));
holder.videoCallImageView.setBackground(
ResourcesCompat.getDrawable(resources, R.drawable.shape_video_bubble, null));
holder.voiceOrSimpleCallImageView.setContentDescription(
resources.getString(R.string.nc_call_state_in_call_with_audio));
holder.videoCallImageView.setContentDescription(
resources.getString(R.string.nc_call_state_with_video));
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
holder.videoCallImageView.setVisibility(View.VISIBLE);
break;
default:
holder.voiceOrSimpleCallImageView.setVisibility(View.GONE);
holder.videoCallImageView.setVisibility(View.GONE);
break;
Long inCallFlag = participant.getInCall();
if ((inCallFlag & InCallFlags.WITH_PHONE) > 0) {
holder.videoCallIconView.setImageResource(R.drawable.ic_call_grey_600_24dp);
holder.videoCallIconView.setVisibility(View.VISIBLE);
holder.videoCallIconView.setContentDescription(
resources.getString(R.string.nc_call_state_with_phone, participant.displayName));
} else if ((inCallFlag & InCallFlags.WITH_VIDEO) > 0) {
holder.videoCallIconView.setImageResource(R.drawable.ic_videocam_grey_600_24dp);
holder.videoCallIconView.setVisibility(View.VISIBLE);
holder.videoCallIconView.setContentDescription(
resources.getString(R.string.nc_call_state_with_video, participant.displayName));
} else if (inCallFlag > InCallFlags.DISCONNECTED) {
holder.videoCallIconView.setImageResource(R.drawable.ic_mic_grey_600_24dp);
holder.videoCallIconView.setVisibility(View.VISIBLE);
holder.videoCallIconView.setContentDescription(
resources.getString(R.string.nc_call_state_in_call, participant.displayName));
} else {
holder.videoCallIconView.setVisibility(View.GONE);
}
if (holder.contactMentionId != null) {
@ -302,11 +271,8 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
@BindView(R.id.secondary_text)
public EmojiTextView contactMentionId;
@Nullable
@BindView(R.id.voiceOrSimpleCallImageView)
ImageView voiceOrSimpleCallImageView;
@Nullable
@BindView(R.id.videoCallImageView)
ImageView videoCallImageView;
@BindView(R.id.videoCallIcon)
ImageView videoCallIconView;
@Nullable
@BindView(R.id.checkedImageView)
ImageView checkedImageView;

View File

@ -146,8 +146,19 @@ public class Participant {
return sessionIds;
}
public Object getInCall() {
return this.inCall;
public Long getInCall() {
if (inCall instanceof Long) {
return (Long) this.inCall;
}
if (this.inCall instanceof Boolean) {
if ((boolean) inCall) {
return 1L;
} else {
return 0L;
}
}
return 0L;
}
public String getSource() {
@ -327,6 +338,15 @@ public class Participant {
GUEST_MODERATOR
}
public static class InCallFlags {
public static final int DISCONNECTED = 0;
public static final int IN_CALL = 1;
public static final int WITH_AUDIO = 2;
public static final int WITH_VIDEO = 4;
public static final int WITH_PHONE = 8;
}
@Deprecated
public enum ParticipantFlags {
NOT_IN_CALL(0),
IN_CALL(1),

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Nextcloud Talk application
~
~ @author Mario Danic
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="oval">
<solid android:color="@color/white"/>
</shape>
</item>
<item android:drawable="@drawable/ic_call_grey_600_24dp"/>
</layer-list>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Nextcloud Talk application
~
~ @author Mario Danic
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="oval">
<solid android:color="@color/white"/>
</shape>
</item>
<item android:drawable="@drawable/ic_star_black_24dp" android:tint="@color/grey_600"/>
</layer-list>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Nextcloud Talk application
~
~ @author Mario Danic
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="oval">
<solid android:color="@color/bg_default"/>
</shape>
</item>
<item android:drawable="@drawable/ic_lock_grey600_24px"/>
</layer-list>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Nextcloud Talk application
~
~ @author Mario Danic
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="oval">
<solid android:color="@color/bg_default"/>
</shape>
</item>
<item android:drawable="@drawable/ic_videocam_grey_600_24dp"/>
</layer-list>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Nextcloud Talk application
~
~ @author Mario Danic
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="oval">
<solid android:color="@color/bg_default"/>
</shape>
</item>
<item android:drawable="@drawable/ic_mic_grey_600_24dp"/>
</layer-list>

View File

@ -25,40 +25,27 @@
android:layout_height="@dimen/item_height"
android:orientation="vertical">
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/simple_drawee_view"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/activity_horizontal_margin">
android:layout_marginStart="@dimen/activity_horizontal_margin"
app:roundAsCircle="true" />
<ImageView
android:id="@+id/voiceOrSimpleCallImageView"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_gravity="bottom|end"
android:background="@drawable/shape_lock_bubble"
android:contentDescription="@null"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/videoCallImageView"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_gravity="top|end"
android:background="@drawable/shape_favorite_bubble"
android:contentDescription="@null"
android:visibility="gone"
tools:visibility="visible" />
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/simple_drawee_view"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
app:roundAsCircle="true" />
</FrameLayout>
<ImageView
android:id="@+id/videoCallIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:src="@drawable/ic_videocam_grey_600_24dp"
android:contentDescription="@null"
android:visibility="gone"
tools:visibility="visible" />
<LinearLayout
android:id="@+id/linear_layout"
@ -67,7 +54,8 @@
android:layout_centerInParent="true"
android:layout_marginStart="@dimen/margin_between_elements"
android:layout_marginEnd="@dimen/margin_between_elements"
android:layout_toEndOf="@id/frame_layout"
android:layout_toEndOf="@id/simple_drawee_view"
android:layout_toStartOf="@id/videoCallIcon"
android:orientation="vertical">
<androidx.emoji.widget.EmojiTextView

View File

@ -215,7 +215,7 @@
<string name="nc_offline">Currently offline, please check your connectivity</string>
<string name="nc_leaving_call">Leaving call…</string>
<string name="nc_call_state_in_call">%1$s in call</string>
<string name="nc_call_state_in_call_with_audio">%1$s in call with audio</string>
<string name="nc_call_state_with_phone">%1$s with phone</string>
<string name="nc_call_state_with_video">%1$s with video</string>
<!-- Notification channels -->