mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-06 12:29:47 +01:00
Switch to enum
This commit is contained in:
parent
54dce7c374
commit
7fe92e67ac
@ -180,34 +180,37 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ public class CallNotificationController extends BaseController {
|
||||
boolean inCallOnDifferentDevice = false;
|
||||
List<Participant> 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())) {
|
||||
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
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<ParticipantFlags> {
|
||||
@Override
|
||||
public ParticipantFlags getFromInt(int i) {
|
||||
return ParticipantFlags.fromValue(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int convertToInt(ParticipantFlags object) {
|
||||
return object.getValue();
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user