Эх сурвалжийг харах

Merge pull request #1249 from nextcloud/bugfix/noid/fix-participant-list-call-state

🎙️ Fix participant list call state icon
Joas Schilling 4 жил өмнө
parent
commit
c35ba8fe75

+ 21 - 55
app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java

@@ -37,6 +37,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.models.database.UserEntity;
 import com.nextcloud.talk.models.database.UserEntity;
 import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
 import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
 import com.nextcloud.talk.models.json.participants.Participant;
 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.ApiUtils;
 import com.nextcloud.talk.utils.DisplayUtils;
 import com.nextcloud.talk.utils.DisplayUtils;
 
 
@@ -186,56 +187,24 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
         Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
         Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
 
 
         if (header == null) {
         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) {
             if (holder.contactMentionId != null) {
@@ -302,11 +271,8 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
         @BindView(R.id.secondary_text)
         @BindView(R.id.secondary_text)
         public EmojiTextView contactMentionId;
         public EmojiTextView contactMentionId;
         @Nullable
         @Nullable
-        @BindView(R.id.voiceOrSimpleCallImageView)
-        ImageView voiceOrSimpleCallImageView;
-        @Nullable
-        @BindView(R.id.videoCallImageView)
-        ImageView videoCallImageView;
+        @BindView(R.id.videoCallIcon)
+        ImageView videoCallIconView;
         @Nullable
         @Nullable
         @BindView(R.id.checkedImageView)
         @BindView(R.id.checkedImageView)
         ImageView checkedImageView;
         ImageView checkedImageView;

+ 2 - 1
app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

@@ -56,6 +56,7 @@ import android.widget.RelativeLayout
 import android.widget.Space
 import android.widget.Space
 import android.widget.TextView
 import android.widget.TextView
 import android.widget.Toast
 import android.widget.Toast
+import androidx.appcompat.view.ContextThemeWrapper
 import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
 import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
 import androidx.emoji.text.EmojiCompat
 import androidx.emoji.text.EmojiCompat
 import androidx.emoji.widget.EmojiEditText
 import androidx.emoji.widget.EmojiEditText
@@ -1554,7 +1555,7 @@ class ChatController(args: Bundle) :
 
 
     override fun onMessageViewLongClick(view: View?, message: IMessage?) {
     override fun onMessageViewLongClick(view: View?, message: IMessage?) {
         PopupMenu(
         PopupMenu(
-            this.context,
+            ContextThemeWrapper(view?.context, R.style.appActionBarPopupMenu),
             view,
             view,
             if (message?.user?.id == conversationUser?.userId) Gravity.END else Gravity.START
             if (message?.user?.id == conversationUser?.userId) Gravity.END else Gravity.START
         ).apply {
         ).apply {

+ 22 - 2
app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java

@@ -146,8 +146,19 @@ public class Participant {
         return sessionIds;
         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() {
     public String getSource() {
@@ -327,6 +338,15 @@ public class Participant {
         GUEST_MODERATOR
         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 {
     public enum ParticipantFlags {
         NOT_IN_CALL(0),
         NOT_IN_CALL(0),
         IN_CALL(1),
         IN_CALL(1),

+ 0 - 30
app/src/main/res/drawable/shape_call_bubble.xml

@@ -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>

+ 0 - 30
app/src/main/res/drawable/shape_favorite_bubble.xml

@@ -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>

+ 0 - 30
app/src/main/res/drawable/shape_lock_bubble.xml

@@ -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>

+ 0 - 30
app/src/main/res/drawable/shape_video_bubble.xml

@@ -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>

+ 0 - 30
app/src/main/res/drawable/shape_voice_bubble.xml

@@ -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>

+ 21 - 33
app/src/main/res/layout/rv_item_conversation_info_participant.xml

@@ -25,40 +25,27 @@
     android:layout_height="@dimen/item_height"
     android:layout_height="@dimen/item_height"
     android:orientation="vertical">
     android:orientation="vertical">
 
 
-    <FrameLayout
-        android:id="@+id/frame_layout"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_centerVertical="true"
-        android:layout_marginStart="@dimen/activity_horizontal_margin">
-
-        <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" />
+    <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"
+        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
     <LinearLayout
         android:id="@+id/linear_layout"
         android:id="@+id/linear_layout"
@@ -67,7 +54,8 @@
         android:layout_centerInParent="true"
         android:layout_centerInParent="true"
         android:layout_marginStart="@dimen/margin_between_elements"
         android:layout_marginStart="@dimen/margin_between_elements"
         android:layout_marginEnd="@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">
         android:orientation="vertical">
 
 
         <androidx.emoji.widget.EmojiTextView
         <androidx.emoji.widget.EmojiTextView

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -215,7 +215,7 @@
     <string name="nc_offline">Currently offline, please check your connectivity</string>
     <string name="nc_offline">Currently offline, please check your connectivity</string>
     <string name="nc_leaving_call">Leaving call…</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">%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>
     <string name="nc_call_state_with_video">%1$s with video</string>
 
 
     <!-- Notification channels -->
     <!-- Notification channels -->

+ 1 - 1
scripts/analysis/findbugs-results.txt

@@ -1 +1 @@
-473
+465

+ 1 - 1
scripts/analysis/lint-results.txt

@@ -1,2 +1,2 @@
 DO NOT TOUCH; GENERATED BY DRONE
 DO NOT TOUCH; GENERATED BY DRONE
-      <span class="mdl-layout-title">Lint Report: 3 errors and 348 warnings</span>
+      <span class="mdl-layout-title">Lint Report: 3 errors and 347 warnings</span>