mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Fix participant flags
This commit is contained in:
parent
9fadec5e10
commit
e2a74f53dc
@ -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().equals(Participant.ParticipantFlags.NOT_IN_CALL))) {
|
||||
if (participant.getParticipantFlags() != 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 android.os.Parcel;
|
||||
|
||||
import org.parceler.ParcelConverter;
|
||||
import org.parceler.Parcels;
|
||||
|
||||
public class ObjectParcelConverter implements ParcelConverter<Object> {
|
||||
@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());
|
||||
}
|
||||
}
|
@ -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<ParticipantFlags> {
|
||||
public class ParticipantFlagsConverter extends LongBasedTypeConverter<ParticipantFlags> {
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
@ -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,29 +93,28 @@ 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:
|
||||
public static ParticipantFlags fromValue(long value) {
|
||||
if (value == 0) {
|
||||
return NOT_IN_CALL;
|
||||
case 1:
|
||||
} else if (value == 1) {
|
||||
return IN_CALL;
|
||||
case 3:
|
||||
} else if (value == 3) {
|
||||
return IN_CALL_WITH_AUDIO;
|
||||
case 5:
|
||||
} else if (value == 5) {
|
||||
return IN_CALL_WITH_VIDEO;
|
||||
case 7:
|
||||
} else if (value == 7) {
|
||||
return IN_CALL_WITH_AUDIO_AND_VIDEO;
|
||||
default:
|
||||
} else {
|
||||
return NOT_IN_CALL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user