mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-06 20:39: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();
|
Resources resources = NextcloudTalkApplication.getSharedApplication().getResources();
|
||||||
|
|
||||||
if (header == null) {
|
if (header == null) {
|
||||||
long participantFlags = participant.getParticipantFlags();
|
Participant.ParticipantFlags participantFlags = participant.getParticipantFlags();
|
||||||
if (participantFlags == 0) {
|
switch (participantFlags) {
|
||||||
holder.voiceOrSimpleCallImageView.setVisibility(View.GONE);
|
case NOT_IN_CALL:
|
||||||
holder.videoCallImageView.setVisibility(View.GONE);
|
holder.voiceOrSimpleCallImageView.setVisibility(View.GONE);
|
||||||
} else if (participantFlags == 1) {
|
holder.videoCallImageView.setVisibility(View.GONE);
|
||||||
holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble));
|
break;
|
||||||
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
|
case IN_CALL:
|
||||||
holder.videoCallImageView.setVisibility(View.GONE);
|
holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble));
|
||||||
} else if (participantFlags == 3) {
|
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
|
||||||
// with audio
|
holder.videoCallImageView.setVisibility(View.GONE);
|
||||||
holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble));
|
break;
|
||||||
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
|
case IN_CALL_WITH_AUDIO:
|
||||||
holder.videoCallImageView.setVisibility(View.GONE);
|
holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble));
|
||||||
} else if (participantFlags == 5) {
|
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
|
||||||
// with video
|
holder.videoCallImageView.setVisibility(View.GONE);
|
||||||
holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble));
|
break;
|
||||||
holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble));
|
case IN_CALL_WITH_VIDEO:
|
||||||
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
|
holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_call_bubble));
|
||||||
holder.videoCallImageView.setVisibility(View.VISIBLE);
|
holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble));
|
||||||
} else if (participantFlags == 7) {
|
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
|
||||||
// video and audio
|
holder.videoCallImageView.setVisibility(View.VISIBLE);
|
||||||
holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble));
|
break;
|
||||||
holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble));
|
case IN_CALL_WITH_AUDIO_AND_VIDEO:
|
||||||
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
|
holder.voiceOrSimpleCallImageView.setBackground(resources.getDrawable(R.drawable.shape_voice_bubble));
|
||||||
holder.videoCallImageView.setVisibility(View.VISIBLE);
|
holder.videoCallImageView.setBackground(resources.getDrawable(R.drawable.shape_video_bubble));
|
||||||
} else {
|
holder.voiceOrSimpleCallImageView.setVisibility(View.VISIBLE);
|
||||||
holder.voiceOrSimpleCallImageView.setVisibility(View.GONE);
|
holder.videoCallImageView.setVisibility(View.VISIBLE);
|
||||||
holder.videoCallImageView.setVisibility(View.GONE);
|
break;
|
||||||
|
default:
|
||||||
|
holder.voiceOrSimpleCallImageView.setVisibility(View.GONE);
|
||||||
|
holder.videoCallImageView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ public class CallNotificationController extends BaseController {
|
|||||||
boolean inCallOnDifferentDevice = false;
|
boolean inCallOnDifferentDevice = false;
|
||||||
List<Participant> participantList = participantsOverall.getOcs().getData();
|
List<Participant> participantList = participantsOverall.getOcs().getData();
|
||||||
for (Participant participant : participantList) {
|
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;
|
hasParticipantsInCall = true;
|
||||||
|
|
||||||
if (participant.getUserId().equals(userBeingCalled.getUserId())) {
|
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.JsonField;
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||||
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
||||||
|
import com.nextcloud.talk.models.json.converters.ParticipantFlagsConverter;
|
||||||
|
|
||||||
import org.parceler.Parcel;
|
import org.parceler.Parcel;
|
||||||
|
|
||||||
@ -56,8 +57,8 @@ public class Participant {
|
|||||||
@JsonField(name = "inCall")
|
@JsonField(name = "inCall")
|
||||||
boolean inCall;
|
boolean inCall;
|
||||||
|
|
||||||
@JsonField(name = "participantFlags")
|
@JsonField(name = "participantFlags", typeConverter = ParticipantFlagsConverter.class)
|
||||||
long participantFlags;
|
ParticipantFlags participantFlags;
|
||||||
|
|
||||||
String source;
|
String source;
|
||||||
|
|
||||||
@ -69,4 +70,40 @@ public class Participant {
|
|||||||
GUEST,
|
GUEST,
|
||||||
USER_FOLLOWING_LINK
|
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