From af4926d614e9cab008fb401748e863500a204e34 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 22 Nov 2018 21:19:08 +0100 Subject: [PATCH 01/10] Fix #353 Signed-off-by: Mario Danic --- .../talk/adapters/items/UserItem.java | 55 ++++++++--- .../res/drawable/ic_call_grey_600_24dp.xml | 25 +++++ .../res/drawable/ic_mic_grey_600_24dp.xml | 25 +++++ .../drawable/ic_videocam_grey_600_24dp.xml | 25 +++++ .../main/res/drawable/shape_call_bubble.xml | 30 ++++++ .../main/res/drawable/shape_video_bubble.xml | 30 ++++++ .../main/res/drawable/shape_voice_bubble.xml | 30 ++++++ .../rv_item_conversation_info_participant.xml | 94 +++++++++++++++++++ 8 files changed, 302 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/drawable/ic_call_grey_600_24dp.xml create mode 100644 app/src/main/res/drawable/ic_mic_grey_600_24dp.xml create mode 100644 app/src/main/res/drawable/ic_videocam_grey_600_24dp.xml create mode 100644 app/src/main/res/drawable/shape_call_bubble.xml create mode 100644 app/src/main/res/drawable/shape_video_bubble.xml create mode 100644 app/src/main/res/drawable/shape_voice_bubble.xml create mode 100644 app/src/main/res/layout/rv_item_conversation_info_participant.xml diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java index d627e68e0..45c2ec79b 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java @@ -20,9 +20,13 @@ package com.nextcloud.talk.adapters.items; +import android.content.Context; +import android.content.res.Resources; +import android.media.Image; import android.text.TextUtils; import android.util.Log; import android.view.View; +import android.widget.ImageView; import android.widget.TextView; import com.amulyakhare.textdrawable.TextDrawable; @@ -106,7 +110,7 @@ public class UserItem extends AbstractFlexibleItem if (header != null) { return R.layout.rv_item_contact; } else { - return R.layout.rv_item_mention; + return R.layout.rv_item_conversation_info_participant; } } @@ -177,17 +181,38 @@ public class UserItem extends AbstractFlexibleItem holder.itemView.setAlpha(1.0f); } - // TODO: show what the user is doing currently - long participantFlags = participant.getParticipantFlags(); - if (participantFlags == 0) { - } else if (participantFlags == 1) { - // do nothing, just in call - } else if (participantFlags == 2) { - // with audio - } else if (participantFlags == 4) { - // with video - } else if (participantFlags == 7) { - // video and audio + Resources resources = NextcloudTalkApplication.getSharedApplication().getResources(); + + if (header == null) { + long participantFlags = participant.getParticipantFlags(); + if (participantFlags == 0) { + holder.voiceOrSimpleCallImageView.setVisibility(View.GONE); + holder.videoCallImageView.setVisibility(View.GONE); + } else if (participantFlags == 1) { + holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble)); + holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); + holder.videoCallImageView.setVisibility(View.GONE); + } else if (participantFlags == 3) { + // with audio + holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble)); + holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); + holder.videoCallImageView.setVisibility(View.GONE); + } else if (participantFlags == 5) { + // with video + holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble)); + holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble)); + holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); + holder.videoCallImageView.setVisibility(View.VISIBLE); + } else if (participantFlags == 7) { + // video and audio + holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble)); + holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble)); + holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); + holder.videoCallImageView.setVisibility(View.VISIBLE); + } else { + holder.voiceOrSimpleCallImageView.setVisibility(View.GONE); + holder.videoCallImageView.setVisibility(View.GONE); + } } String userType = ""; @@ -244,6 +269,12 @@ public class UserItem extends AbstractFlexibleItem @Nullable @BindView(R.id.secondary_text) public TextView contactMentionId; + @Nullable + @BindView(R.id.voiceOrSimpleCallImageView) + ImageView voiceOrSimpleCallImageView; + @Nullable + @BindView(R.id.videoCallImageView) + ImageView videoCallImageView; /** * Default constructor. diff --git a/app/src/main/res/drawable/ic_call_grey_600_24dp.xml b/app/src/main/res/drawable/ic_call_grey_600_24dp.xml new file mode 100644 index 000000000..7cf4380b5 --- /dev/null +++ b/app/src/main/res/drawable/ic_call_grey_600_24dp.xml @@ -0,0 +1,25 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_mic_grey_600_24dp.xml b/app/src/main/res/drawable/ic_mic_grey_600_24dp.xml new file mode 100644 index 000000000..5a4a52926 --- /dev/null +++ b/app/src/main/res/drawable/ic_mic_grey_600_24dp.xml @@ -0,0 +1,25 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_videocam_grey_600_24dp.xml b/app/src/main/res/drawable/ic_videocam_grey_600_24dp.xml new file mode 100644 index 000000000..24f2e644f --- /dev/null +++ b/app/src/main/res/drawable/ic_videocam_grey_600_24dp.xml @@ -0,0 +1,25 @@ + + + + + diff --git a/app/src/main/res/drawable/shape_call_bubble.xml b/app/src/main/res/drawable/shape_call_bubble.xml new file mode 100644 index 000000000..8a583962f --- /dev/null +++ b/app/src/main/res/drawable/shape_call_bubble.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_video_bubble.xml b/app/src/main/res/drawable/shape_video_bubble.xml new file mode 100644 index 000000000..9351e5f46 --- /dev/null +++ b/app/src/main/res/drawable/shape_video_bubble.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_voice_bubble.xml b/app/src/main/res/drawable/shape_voice_bubble.xml new file mode 100644 index 000000000..88469dfbf --- /dev/null +++ b/app/src/main/res/drawable/shape_voice_bubble.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/rv_item_conversation_info_participant.xml b/app/src/main/res/layout/rv_item_conversation_info_participant.xml new file mode 100644 index 000000000..da4e500e9 --- /dev/null +++ b/app/src/main/res/layout/rv_item_conversation_info_participant.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + From eeb87183a00aa4c25a311c0fe0757fdf77f2f348 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 22 Nov 2018 23:03:56 +0100 Subject: [PATCH 02/10] Clean up Signed-off-by: Mario Danic --- app/src/gplay/AndroidManifest.xml | 5 +- app/src/main/AndroidManifest.xml | 3 +- .../talk/adapters/items/UserItem.java | 6 +- .../layout/controller_conversation_info.xml | 131 +++++++++--------- 4 files changed, 74 insertions(+), 71 deletions(-) diff --git a/app/src/gplay/AndroidManifest.xml b/app/src/gplay/AndroidManifest.xml index 1474521d4..2f388c5f5 100644 --- a/app/src/gplay/AndroidManifest.xml +++ b/app/src/gplay/AndroidManifest.xml @@ -11,11 +11,12 @@ android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true" android:theme="@style/AppTheme" - tools:replace="label, icon, theme, name, allowBackup"> + tools:replace="label, icon, theme, name, allowBackup" + tools:ignore="UnusedAttribute, ExportedService"> - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 06906a3c3..196a9b162 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,7 +43,8 @@ android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true" android:theme="@style/AppTheme" - tools:replace="label, icon, theme, name, allowBackup"> + tools:replace="label, icon, theme, name, allowBackup" + tools:ignore="UnusedAttribute"> } holder.contactMentionId.setText(userType); - holder.contactMentionId.setTextColor(NextcloudTalkApplication.getSharedApplication().getColor(R.color.colorPrimary)); + holder.contactMentionId.setTextColor(NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color.colorPrimary)); } } diff --git a/app/src/main/res/layout/controller_conversation_info.xml b/app/src/main/res/layout/controller_conversation_info.xml index 69f6d5ab5..8b8218cd0 100644 --- a/app/src/main/res/layout/controller_conversation_info.xml +++ b/app/src/main/res/layout/controller_conversation_info.xml @@ -18,7 +18,7 @@ ~ along with this program. If not, see . --> - - + + - - - + android:layout_height="wrap_content"> - - - - - - - - - - - - - - + android:animateLayoutChanges="true" + android:visibility="gone"> - + - - + + + + + + + + + + + + + + + + + From 11c55b53f201cbd6ff67839cc80970cdadbeb5fd Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 22 Nov 2018 23:12:04 +0100 Subject: [PATCH 03/10] Further clean ups Signed-off-by: Mario Danic --- .../res/drawable/ic_group_grey600_24px.xml | 6 +++-- .../main/res/drawable/ic_link_black_24px.xml | 6 +++-- .../res/drawable/ic_link_grey600_24px.xml | 6 +++-- .../main/res/drawable/ic_link_white_24px.xml | 6 +++-- .../drawable/ic_people_group_black_24px.xml | 26 +++---------------- .../drawable/ic_people_group_white_24px.xml | 6 +++-- .../res/drawable/ic_settings_black_24dp.xml | 6 +++-- app/src/main/res/layout/rv_item_contact.xml | 1 - .../rv_item_conversation_info_participant.xml | 1 - app/src/main/res/layout/rv_item_mention.xml | 1 - .../main/res/layout/rv_item_participant.xml | 2 +- 11 files changed, 29 insertions(+), 38 deletions(-) diff --git a/app/src/main/res/drawable/ic_group_grey600_24px.xml b/app/src/main/res/drawable/ic_group_grey600_24px.xml index 69b45ba78..4acc0cfd2 100644 --- a/app/src/main/res/drawable/ic_group_grey600_24px.xml +++ b/app/src/main/res/drawable/ic_group_grey600_24px.xml @@ -1,7 +1,9 @@ - + android:strokeColor="#00000000" android:strokeWidth="1" + tools:ignore="VectorPath" /> diff --git a/app/src/main/res/drawable/ic_link_black_24px.xml b/app/src/main/res/drawable/ic_link_black_24px.xml index 9f52bcc60..d1e8a70fa 100644 --- a/app/src/main/res/drawable/ic_link_black_24px.xml +++ b/app/src/main/res/drawable/ic_link_black_24px.xml @@ -18,10 +18,12 @@ ~ along with this program. If not, see . --> - + android:strokeColor="#00000000" android:strokeWidth="1" + tools:ignore="VectorPath" /> diff --git a/app/src/main/res/drawable/ic_link_grey600_24px.xml b/app/src/main/res/drawable/ic_link_grey600_24px.xml index b5386a5de..fcd044183 100644 --- a/app/src/main/res/drawable/ic_link_grey600_24px.xml +++ b/app/src/main/res/drawable/ic_link_grey600_24px.xml @@ -1,7 +1,9 @@ - + android:strokeColor="#00000000" android:strokeWidth="1" + tools:ignore="VectorPath" /> diff --git a/app/src/main/res/drawable/ic_link_white_24px.xml b/app/src/main/res/drawable/ic_link_white_24px.xml index 68f853464..d59f2cf40 100644 --- a/app/src/main/res/drawable/ic_link_white_24px.xml +++ b/app/src/main/res/drawable/ic_link_white_24px.xml @@ -1,4 +1,5 @@ - + android:strokeColor="#00000000" android:strokeWidth="1" + tools:ignore="VectorPath" /> diff --git a/app/src/main/res/drawable/ic_people_group_black_24px.xml b/app/src/main/res/drawable/ic_people_group_black_24px.xml index f1fd901a0..da3d845e3 100644 --- a/app/src/main/res/drawable/ic_people_group_black_24px.xml +++ b/app/src/main/res/drawable/ic_people_group_black_24px.xml @@ -18,30 +18,12 @@ ~ along with this program. If not, see . --> - - - + android:strokeColor="#00000000" android:strokeWidth="1" + tools:ignore="VectorPath" /> diff --git a/app/src/main/res/drawable/ic_people_group_white_24px.xml b/app/src/main/res/drawable/ic_people_group_white_24px.xml index e0cbf81fe..0f39f7bfe 100644 --- a/app/src/main/res/drawable/ic_people_group_white_24px.xml +++ b/app/src/main/res/drawable/ic_people_group_white_24px.xml @@ -1,4 +1,5 @@ - + android:strokeColor="#00000000" android:strokeWidth="1" + tools:ignore="VectorPath" /> diff --git a/app/src/main/res/drawable/ic_settings_black_24dp.xml b/app/src/main/res/drawable/ic_settings_black_24dp.xml index b1ed64c70..4fbe2f6f5 100644 --- a/app/src/main/res/drawable/ic_settings_black_24dp.xml +++ b/app/src/main/res/drawable/ic_settings_black_24dp.xml @@ -18,8 +18,10 @@ ~ along with this program. If not, see . --> - - + diff --git a/app/src/main/res/layout/rv_item_contact.xml b/app/src/main/res/layout/rv_item_contact.xml index fefd40ce0..4d3becac2 100644 --- a/app/src/main/res/layout/rv_item_contact.xml +++ b/app/src/main/res/layout/rv_item_contact.xml @@ -29,7 +29,6 @@ android:orientation="vertical"> - Date: Thu, 22 Nov 2018 22:47:02 +0000 Subject: [PATCH 04/10] Drone: update Lint results to reflect reduced error/warning count [skip ci] --- scripts/analysis/lint-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt index b35117bc9..39e7882b0 100644 --- a/scripts/analysis/lint-results.txt +++ b/scripts/analysis/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 2 errors and 126 warnings + Lint Report: 2 errors and 122 warnings From 54dce7c374d633dc94f632f62b7fcec87177254c Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Tue, 27 Nov 2018 11:56:44 +0100 Subject: [PATCH 05/10] Add newline to vectors --- app/src/main/res/drawable/shape_call_bubble.xml | 2 +- app/src/main/res/drawable/shape_video_bubble.xml | 2 +- app/src/main/res/drawable/shape_voice_bubble.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/drawable/shape_call_bubble.xml b/app/src/main/res/drawable/shape_call_bubble.xml index 8a583962f..c41afbad1 100644 --- a/app/src/main/res/drawable/shape_call_bubble.xml +++ b/app/src/main/res/drawable/shape_call_bubble.xml @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/drawable/shape_video_bubble.xml b/app/src/main/res/drawable/shape_video_bubble.xml index 9351e5f46..d02c78df9 100644 --- a/app/src/main/res/drawable/shape_video_bubble.xml +++ b/app/src/main/res/drawable/shape_video_bubble.xml @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/drawable/shape_voice_bubble.xml b/app/src/main/res/drawable/shape_voice_bubble.xml index 88469dfbf..618be4047 100644 --- a/app/src/main/res/drawable/shape_voice_bubble.xml +++ b/app/src/main/res/drawable/shape_voice_bubble.xml @@ -27,4 +27,4 @@ - \ No newline at end of file + From 7fe92e67acbad623c130263ff663507eb5eb9394 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Tue, 27 Nov 2018 13:52:24 +0100 Subject: [PATCH 06/10] Switch to enum --- .../talk/adapters/items/UserItem.java | 59 ++++++++++--------- .../CallNotificationController.java | 2 +- .../converters/ParticipantFlagsConverter.java | 38 ++++++++++++ .../models/json/participants/Participant.java | 41 ++++++++++++- 4 files changed, 109 insertions(+), 31 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java index 703c4849b..ad0bb6b40 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java @@ -180,34 +180,37 @@ public class UserItem extends AbstractFlexibleItem Resources resources = NextcloudTalkApplication.getSharedApplication().getResources(); if (header == null) { - long participantFlags = participant.getParticipantFlags(); - if (participantFlags == 0) { - holder.voiceOrSimpleCallImageView.setVisibility(View.GONE); - holder.videoCallImageView.setVisibility(View.GONE); - } else if (participantFlags == 1) { - holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble)); - holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); - holder.videoCallImageView.setVisibility(View.GONE); - } else if (participantFlags == 3) { - // with audio - holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble)); - holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); - holder.videoCallImageView.setVisibility(View.GONE); - } else if (participantFlags == 5) { - // with video - holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble)); - holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble)); - holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); - holder.videoCallImageView.setVisibility(View.VISIBLE); - } else if (participantFlags == 7) { - // video and audio - holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble)); - holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble)); - holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); - holder.videoCallImageView.setVisibility(View.VISIBLE); - } else { - holder.voiceOrSimpleCallImageView.setVisibility(View.GONE); - holder.videoCallImageView.setVisibility(View.GONE); + 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(resources.getDrawable(R.drawable.shape_call_bubble)); + holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); + holder.videoCallImageView.setVisibility(View.GONE); + break; + case IN_CALL_WITH_AUDIO: + holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble)); + holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); + holder.videoCallImageView.setVisibility(View.GONE); + break; + case IN_CALL_WITH_VIDEO: + holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble)); + holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble)); + holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); + holder.videoCallImageView.setVisibility(View.VISIBLE); + break; + case IN_CALL_WITH_AUDIO_AND_VIDEO: + holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble)); + holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble)); + holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE); + holder.videoCallImageView.setVisibility(View.VISIBLE); + break; + default: + holder.voiceOrSimpleCallImageView.setVisibility(View.GONE); + holder.videoCallImageView.setVisibility(View.GONE); } } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java index 5abe89da7..f3c01da74 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java @@ -216,7 +216,7 @@ public class CallNotificationController extends BaseController { boolean inCallOnDifferentDevice = false; List participantList = participantsOverall.getOcs().getData(); for (Participant participant : participantList) { - if (participant.isInCall() || (userBeingCalled.hasSpreedCapabilityWithName("in-call-flags") && participant.getParticipantFlags() != 0)) { + if (participant.isInCall() || (userBeingCalled.hasSpreedCapabilityWithName("in-call-flags") && !participant.getParticipantFlags().equals(Participant.ParticipantFlags.NOT_IN_CALL))) { hasParticipantsInCall = true; if (participant.getUserId().equals(userBeingCalled.getUserId())) { diff --git a/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java b/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java new file mode 100644 index 000000000..a87d3ea99 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java @@ -0,0 +1,38 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2018 Mario Danic + * + * 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 . + */ + +package com.nextcloud.talk.models.json.converters; + +import com.bluelinelabs.logansquare.typeconverters.IntBasedTypeConverter; +import com.nextcloud.talk.models.json.participants.Participant; +import com.nextcloud.talk.models.json.participants.Participant.ParticipantFlags; +import com.nextcloud.talk.models.json.rooms.Conversation; + +public class ParticipantFlagsConverter extends IntBasedTypeConverter { + @Override + public ParticipantFlags getFromInt(int i) { + return ParticipantFlags.fromValue(i); + } + + @Override + public int convertToInt(ParticipantFlags object) { + return object.getValue(); + } +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java b/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java index 60eaa3950..a3dbb6cf4 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java @@ -23,6 +23,7 @@ package com.nextcloud.talk.models.json.participants; import com.bluelinelabs.logansquare.annotation.JsonField; import com.bluelinelabs.logansquare.annotation.JsonObject; import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter; +import com.nextcloud.talk.models.json.converters.ParticipantFlagsConverter; import org.parceler.Parcel; @@ -56,8 +57,8 @@ public class Participant { @JsonField(name = "inCall") boolean inCall; - @JsonField(name = "participantFlags") - long participantFlags; + @JsonField(name = "participantFlags", typeConverter = ParticipantFlagsConverter.class) + ParticipantFlags participantFlags; String source; @@ -69,4 +70,40 @@ public class Participant { GUEST, USER_FOLLOWING_LINK } + + public enum ParticipantFlags { + NOT_IN_CALL (0), + IN_CALL (1), + IN_CALL_WITH_AUDIO (3), + IN_CALL_WITH_VIDEO (5), + IN_CALL_WITH_AUDIO_AND_VIDEO (7); + + private int value; + + ParticipantFlags(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static ParticipantFlags fromValue(int value) { + switch (value) { + case 0: + return NOT_IN_CALL; + case 1: + return IN_CALL; + case 3: + return IN_CALL_WITH_AUDIO; + case 5: + return IN_CALL_WITH_VIDEO; + case 7: + return IN_CALL_WITH_AUDIO_AND_VIDEO; + default: + return NOT_IN_CALL; + } + } + + } } From 9fadec5e101cd69459b8315e38ca7ad5c3f49f09 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Wed, 28 Nov 2018 05:32:38 +0100 Subject: [PATCH 07/10] Optimize imports --- .../talk/application/NextcloudTalkApplication.java | 1 - .../talk/controllers/ConversationInfoController.java | 4 ---- .../talk/models/database/ArbitraryStorage.java | 1 - .../arbitrarystorage/ArbitraryStorageUtils.java | 10 ---------- 4 files changed, 16 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.java b/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.java index daab3ad7c..434f352af 100644 --- a/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.java +++ b/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.java @@ -50,7 +50,6 @@ import javax.inject.Singleton; import androidx.lifecycle.LifecycleObserver; import androidx.multidex.MultiDex; import androidx.multidex.MultiDexApplication; -import androidx.work.Configuration; import androidx.work.OneTimeWorkRequest; import androidx.work.PeriodicWorkRequest; import androidx.work.WorkManager; diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java index e8ccc3378..685b9089f 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java @@ -42,7 +42,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.controllers.base.BaseController; import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.json.converters.EnumNotificationLevelConverter; -import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter; import com.nextcloud.talk.models.json.participants.Participant; import com.nextcloud.talk.models.json.participants.ParticipantsOverall; import com.nextcloud.talk.models.json.rooms.Conversation; @@ -58,9 +57,6 @@ import com.yarolegovich.mp.MaterialPreferenceScreen; import org.parceler.Parcels; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; import java.util.List; import javax.inject.Inject; diff --git a/app/src/main/java/com/nextcloud/talk/models/database/ArbitraryStorage.java b/app/src/main/java/com/nextcloud/talk/models/database/ArbitraryStorage.java index 77ae21451..c095f0e53 100644 --- a/app/src/main/java/com/nextcloud/talk/models/database/ArbitraryStorage.java +++ b/app/src/main/java/com/nextcloud/talk/models/database/ArbitraryStorage.java @@ -26,7 +26,6 @@ import java.io.Serializable; import io.requery.Entity; import io.requery.Key; -import io.requery.Nullable; import io.requery.Persistable; @Entity diff --git a/app/src/main/java/com/nextcloud/talk/utils/database/arbitrarystorage/ArbitraryStorageUtils.java b/app/src/main/java/com/nextcloud/talk/utils/database/arbitrarystorage/ArbitraryStorageUtils.java index 930cdf4aa..94ead9dab 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/database/arbitrarystorage/ArbitraryStorageUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/database/arbitrarystorage/ArbitraryStorageUtils.java @@ -19,21 +19,11 @@ */ package com.nextcloud.talk.utils.database.arbitrarystorage; -import android.text.TextUtils; - import com.nextcloud.talk.models.database.ArbitraryStorage; import com.nextcloud.talk.models.database.ArbitraryStorageEntity; -import com.nextcloud.talk.models.database.User; -import com.nextcloud.talk.models.database.UserEntity; - -import java.util.List; import androidx.annotation.Nullable; -import io.reactivex.Completable; import io.reactivex.Observable; -import io.reactivex.Observer; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; import io.requery.Persistable; import io.requery.query.Result; From e2a74f53dc9c540519f1e4a54e61a8c22ca86dc0 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Wed, 28 Nov 2018 13:47:00 +0100 Subject: [PATCH 08/10] Fix participant flags --- .../CallNotificationController.java | 56 +++++++++---------- .../converters/ObjectParcelConverter.java | 38 +++++++++++++ .../converters/ParticipantFlagsConverter.java | 14 ++--- .../models/json/participants/Participant.java | 56 ++++++++++++------- 4 files changed, 107 insertions(+), 57 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/converters/ObjectParcelConverter.java diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java index f3c01da74..0bb90d974 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java @@ -216,7 +216,7 @@ public class CallNotificationController extends BaseController { boolean inCallOnDifferentDevice = false; List participantList = participantsOverall.getOcs().getData(); for (Participant participant : participantList) { - if (participant.isInCall() || (userBeingCalled.hasSpreedCapabilityWithName("in-call-flags") && !participant.getParticipantFlags().equals(Participant.ParticipantFlags.NOT_IN_CALL))) { + if (participant.getParticipantFlags() != Participant.ParticipantFlags.NOT_IN_CALL) { hasParticipantsInCall = true; if (participant.getUserId().equals(userBeingCalled.getUserId())) { @@ -436,38 +436,38 @@ public class CallNotificationController extends BaseController { (getActivity()).getBitmapPool(), resource, avatarSize, avatarSize)); } - if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 200 && - userBeingCalled.hasSpreedCapabilityWithName("no-ping")) { - final Allocation input = Allocation.createFromBitmap(renderScript, resource); - final Allocation output = Allocation.createTyped(renderScript, input.getType()); - final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(renderScript, Element - .U8_4(renderScript)); - script.setRadius(15f); - script.setInput(input); - script.forEach(output); - output.copyTo(resource); + if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 200 && + userBeingCalled.hasSpreedCapabilityWithName("no-ping")) { + final Allocation input = Allocation.createFromBitmap(renderScript, resource); + final Allocation output = Allocation.createTyped(renderScript, input.getType()); + final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(renderScript, Element + .U8_4(renderScript)); + script.setRadius(15f); + script.setInput(input); + script.forEach(output); + output.copyTo(resource); - if (getResources() != null) { - incomingTextRelativeLayout.setBackground(getResources().getDrawable(R.drawable - .incoming_gradient)); - constraintLayout.setBackground(new BitmapDrawable(resource)); + if (getResources() != null) { + incomingTextRelativeLayout.setBackground(getResources().getDrawable(R.drawable + .incoming_gradient)); + constraintLayout.setBackground(new BitmapDrawable(resource)); + } + } else if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 201) { + Palette palette = Palette.from(resource).generate(); + if (getResources() != null) { + int color = palette.getDominantColor(getResources().getColor(R.color.grey950)); + + if (color != getResources().getColor(R.color.grey950)) { + float[] hsv = new float[3]; + Color.colorToHSV(color, hsv); + hsv[2] *= 0.75f; + color = Color.HSVToColor(hsv); } - } else if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 201) { - Palette palette = Palette.from(resource).generate(); - if (getResources() != null) { - int color = palette.getDominantColor(getResources().getColor(R.color.grey950)); - if (color != getResources().getColor(R.color.grey950)) { - float[] hsv = new float[3]; - Color.colorToHSV(color, hsv); - hsv[2] *= 0.75f; - color = Color.HSVToColor(hsv); - } - - constraintLayout.setBackgroundColor(color); - } + constraintLayout.setBackgroundColor(color); } } + } }); diff --git a/app/src/main/java/com/nextcloud/talk/models/json/converters/ObjectParcelConverter.java b/app/src/main/java/com/nextcloud/talk/models/json/converters/ObjectParcelConverter.java new file mode 100644 index 000000000..d536d8816 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/converters/ObjectParcelConverter.java @@ -0,0 +1,38 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2018 Mario Danic + * + * 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 . + */ + +package com.nextcloud.talk.models.json.converters; + +import android.os.Parcel; + +import org.parceler.ParcelConverter; +import org.parceler.Parcels; + +public class ObjectParcelConverter implements ParcelConverter { + @Override + public void toParcel(Object input, Parcel parcel) { + parcel.writeParcelable(Parcels.wrap(input), 0); + } + + @Override + public Object fromParcel(Parcel parcel) { + return parcel.readParcelable(Object.class.getClassLoader()); + } +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java b/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java index a87d3ea99..9b4556745 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java @@ -20,19 +20,17 @@ package com.nextcloud.talk.models.json.converters; -import com.bluelinelabs.logansquare.typeconverters.IntBasedTypeConverter; -import com.nextcloud.talk.models.json.participants.Participant; +import com.bluelinelabs.logansquare.typeconverters.LongBasedTypeConverter; import com.nextcloud.talk.models.json.participants.Participant.ParticipantFlags; -import com.nextcloud.talk.models.json.rooms.Conversation; -public class ParticipantFlagsConverter extends IntBasedTypeConverter { +public class ParticipantFlagsConverter extends LongBasedTypeConverter { @Override - public ParticipantFlags getFromInt(int i) { - return ParticipantFlags.fromValue(i); - } + public ParticipantFlags getFromLong(long l) { + return ParticipantFlags.fromValue(l); + }; @Override - public int convertToInt(ParticipantFlags object) { + public long convertToLong(ParticipantFlags object) { return object.getValue(); } } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java b/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java index a3dbb6cf4..07bbec190 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.java @@ -23,9 +23,10 @@ package com.nextcloud.talk.models.json.participants; import com.bluelinelabs.logansquare.annotation.JsonField; import com.bluelinelabs.logansquare.annotation.JsonObject; import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter; -import com.nextcloud.talk.models.json.converters.ParticipantFlagsConverter; +import com.nextcloud.talk.models.json.converters.ObjectParcelConverter; import org.parceler.Parcel; +import org.parceler.ParcelPropertyConverter; import lombok.Data; @@ -54,12 +55,26 @@ public class Participant { @JsonField(name = "roomId") long roomId; + @ParcelPropertyConverter(ObjectParcelConverter.class) @JsonField(name = "inCall") - boolean inCall; + Object inCall; - @JsonField(name = "participantFlags", typeConverter = ParticipantFlagsConverter.class) - ParticipantFlags participantFlags; + public ParticipantFlags getParticipantFlags() { + ParticipantFlags participantFlags = ParticipantFlags.NOT_IN_CALL; + if (inCall != null) { + if (inCall instanceof Long) { + participantFlags = ParticipantFlags.fromValue((Long) inCall); + } else if (inCall instanceof Boolean) { + if ((boolean) inCall) { + participantFlags = ParticipantFlags.IN_CALL; + } else { + participantFlags = ParticipantFlags.NOT_IN_CALL; + } + } + } + return participantFlags; + } String source; public enum ParticipantType { @@ -78,30 +93,29 @@ public class Participant { IN_CALL_WITH_VIDEO (5), IN_CALL_WITH_AUDIO_AND_VIDEO (7); - private int value; + private long value; - ParticipantFlags(int value) { + ParticipantFlags(long value) { this.value = value; } - public int getValue() { + public long getValue() { return value; } - public static ParticipantFlags fromValue(int value) { - switch (value) { - case 0: - return NOT_IN_CALL; - case 1: - return IN_CALL; - case 3: - return IN_CALL_WITH_AUDIO; - case 5: - return IN_CALL_WITH_VIDEO; - case 7: - return IN_CALL_WITH_AUDIO_AND_VIDEO; - default: - return NOT_IN_CALL; + public static ParticipantFlags fromValue(long value) { + if (value == 0) { + return NOT_IN_CALL; + } else if (value == 1) { + return IN_CALL; + } else if (value == 3) { + return IN_CALL_WITH_AUDIO; + } else if (value == 5) { + return IN_CALL_WITH_VIDEO; + } else if (value == 7) { + return IN_CALL_WITH_AUDIO_AND_VIDEO; + } else { + return NOT_IN_CALL; } } From e13e964fd3a122e4fc8f7e41953b1af2c14ab124 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 29 Nov 2018 14:01:33 +0100 Subject: [PATCH 09/10] Clean up --- .../java/com/nextcloud/talk/adapters/items/UserItem.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java index ad0bb6b40..419ba365b 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java @@ -211,12 +211,11 @@ public class UserItem extends AbstractFlexibleItem default: holder.voiceOrSimpleCallImageView.setVisibility(View.GONE); holder.videoCallImageView.setVisibility(View.GONE); + break; } - } - String userType = ""; + String userType = ""; - if (header == null) { switch (new EnumParticipantTypeConverter().convertToInt(participant.getType())) { case 1: userType = NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_owner); @@ -234,7 +233,7 @@ public class UserItem extends AbstractFlexibleItem userType = NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_following_link); break; default: - // do nothing + break; } holder.contactMentionId.setText(userType); From 8aeb754f15f7ab96c1bfaadcbb28096d7cd5d148 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 29 Nov 2018 18:29:46 +0100 Subject: [PATCH 10/10] Remove useless class --- .../converters/ParticipantFlagsConverter.java | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java diff --git a/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java b/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java deleted file mode 100644 index 9b4556745..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/converters/ParticipantFlagsConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017-2018 Mario Danic - * - * 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 . - */ - -package com.nextcloud.talk.models.json.converters; - -import com.bluelinelabs.logansquare.typeconverters.LongBasedTypeConverter; -import com.nextcloud.talk.models.json.participants.Participant.ParticipantFlags; - -public class ParticipantFlagsConverter extends LongBasedTypeConverter { - @Override - public ParticipantFlags getFromLong(long l) { - return ParticipantFlags.fromValue(l); - }; - - @Override - public long convertToLong(ParticipantFlags object) { - return object.getValue(); - } -}