Fix participant flags

This commit is contained in:
Mario Danic 2018-11-28 13:47:00 +01:00
parent 9fadec5e10
commit e2a74f53dc
4 changed files with 107 additions and 57 deletions

View File

@ -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().equals(Participant.ParticipantFlags.NOT_IN_CALL))) { if (participant.getParticipantFlags() != Participant.ParticipantFlags.NOT_IN_CALL) {
hasParticipantsInCall = true; hasParticipantsInCall = true;
if (participant.getUserId().equals(userBeingCalled.getUserId())) { if (participant.getUserId().equals(userBeingCalled.getUserId())) {
@ -436,38 +436,38 @@ public class CallNotificationController extends BaseController {
(getActivity()).getBitmapPool(), resource, avatarSize, avatarSize)); (getActivity()).getBitmapPool(), resource, avatarSize, avatarSize));
} }
if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 200 && if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 200 &&
userBeingCalled.hasSpreedCapabilityWithName("no-ping")) { userBeingCalled.hasSpreedCapabilityWithName("no-ping")) {
final Allocation input = Allocation.createFromBitmap(renderScript, resource); final Allocation input = Allocation.createFromBitmap(renderScript, resource);
final Allocation output = Allocation.createTyped(renderScript, input.getType()); final Allocation output = Allocation.createTyped(renderScript, input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(renderScript, Element final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(renderScript, Element
.U8_4(renderScript)); .U8_4(renderScript));
script.setRadius(15f); script.setRadius(15f);
script.setInput(input); script.setInput(input);
script.forEach(output); script.forEach(output);
output.copyTo(resource); output.copyTo(resource);
if (getResources() != null) { if (getResources() != null) {
incomingTextRelativeLayout.setBackground(getResources().getDrawable(R.drawable incomingTextRelativeLayout.setBackground(getResources().getDrawable(R.drawable
.incoming_gradient)); .incoming_gradient));
constraintLayout.setBackground(new BitmapDrawable(resource)); 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)) { constraintLayout.setBackgroundColor(color);
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] *= 0.75f;
color = Color.HSVToColor(hsv);
}
constraintLayout.setBackgroundColor(color);
}
} }
} }
}
}); });

View File

@ -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());
}
}

View File

@ -20,19 +20,17 @@
package com.nextcloud.talk.models.json.converters; package com.nextcloud.talk.models.json.converters;
import com.bluelinelabs.logansquare.typeconverters.IntBasedTypeConverter; import com.bluelinelabs.logansquare.typeconverters.LongBasedTypeConverter;
import com.nextcloud.talk.models.json.participants.Participant;
import com.nextcloud.talk.models.json.participants.Participant.ParticipantFlags; 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 @Override
public ParticipantFlags getFromInt(int i) { public ParticipantFlags getFromLong(long l) {
return ParticipantFlags.fromValue(i); return ParticipantFlags.fromValue(l);
} };
@Override @Override
public int convertToInt(ParticipantFlags object) { public long convertToLong(ParticipantFlags object) {
return object.getValue(); return object.getValue();
} }
} }

View File

@ -23,9 +23,10 @@ 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 com.nextcloud.talk.models.json.converters.ObjectParcelConverter;
import org.parceler.Parcel; import org.parceler.Parcel;
import org.parceler.ParcelPropertyConverter;
import lombok.Data; import lombok.Data;
@ -54,12 +55,26 @@ public class Participant {
@JsonField(name = "roomId") @JsonField(name = "roomId")
long roomId; long roomId;
@ParcelPropertyConverter(ObjectParcelConverter.class)
@JsonField(name = "inCall") @JsonField(name = "inCall")
boolean inCall; Object inCall;
@JsonField(name = "participantFlags", typeConverter = ParticipantFlagsConverter.class) public ParticipantFlags getParticipantFlags() {
ParticipantFlags participantFlags; 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; String source;
public enum ParticipantType { public enum ParticipantType {
@ -78,30 +93,29 @@ public class Participant {
IN_CALL_WITH_VIDEO (5), IN_CALL_WITH_VIDEO (5),
IN_CALL_WITH_AUDIO_AND_VIDEO (7); IN_CALL_WITH_AUDIO_AND_VIDEO (7);
private int value; private long value;
ParticipantFlags(int value) { ParticipantFlags(long value) {
this.value = value; this.value = value;
} }
public int getValue() { public long getValue() {
return value; return value;
} }
public static ParticipantFlags fromValue(int value) { public static ParticipantFlags fromValue(long value) {
switch (value) { if (value == 0) {
case 0: return NOT_IN_CALL;
return NOT_IN_CALL; } else if (value == 1) {
case 1: return IN_CALL;
return IN_CALL; } else if (value == 3) {
case 3: return IN_CALL_WITH_AUDIO;
return IN_CALL_WITH_AUDIO; } else if (value == 5) {
case 5: return IN_CALL_WITH_VIDEO;
return IN_CALL_WITH_VIDEO; } else if (value == 7) {
case 7: return IN_CALL_WITH_AUDIO_AND_VIDEO;
return IN_CALL_WITH_AUDIO_AND_VIDEO; } else {
default: return NOT_IN_CALL;
return NOT_IN_CALL;
} }
} }