diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt
index dbc8468b7..e04174104 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt
+++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt
@@ -89,13 +89,11 @@ import io.reactivex.schedulers.Schedulers
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
-import retrofit2.adapter.rxjava2.HttpException
import java.util.Calendar
import java.util.Collections
import java.util.Comparator
import java.util.Locale
import javax.inject.Inject
-import kotlin.reflect.typeOf
@AutoInjector(NextcloudTalkApplication::class)
class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleAdapter.OnItemClickListener {
@@ -922,9 +920,30 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
- if (participant.getUserId() == conversationUser!!.userId
- || participant.type == Participant.ParticipantType.OWNER) {
- // FIXME Show pin?
+ if (participant.getUserId() == conversationUser!!.userId) {
+ if (participant.attendeePin.isNotEmpty()) {
+ val items = mutableListOf(
+ BasicListItemWithImage(
+ R.drawable.ic_lock_grey600_24px,
+ context.getString(R.string.nc_attendee_pin, participant.attendeePin)
+ )
+ )
+ MaterialDialog(activity!!, BottomSheet(WRAP_CONTENT)).show {
+ cornerRadius(res = R.dimen.corner_radius)
+
+ title(text = participant.displayName)
+ listItemsWithImage(items = items) { dialog, index, _ ->
+ if (index == 0) {
+ removeAttendeeFromConversation(apiVersion, participant)
+ }
+ }
+ }
+ }
+ return true
+ }
+
+ if (participant.type == Participant.ParticipantType.OWNER) {
+ // Can not moderate owner
return true
}
@@ -949,6 +968,10 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
}
var items = mutableListOf(
+ BasicListItemWithImage(
+ R.drawable.ic_lock_grey600_24px,
+ context.getString(R.string.nc_attendee_pin, participant.attendeePin)
+ ),
BasicListItemWithImage(R.drawable.ic_pencil_grey600_24dp, context.getString(R.string.nc_promote)),
BasicListItemWithImage(R.drawable.ic_pencil_grey600_24dp, context.getString(R.string.nc_demote)),
BasicListItemWithImage(
@@ -959,13 +982,17 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
if (participant.type == Participant.ParticipantType.MODERATOR
|| participant.type == Participant.ParticipantType.GUEST_MODERATOR) {
- items.removeAt(0)
+ items.removeAt(1)
} else if (participant.type == Participant.ParticipantType.USER
|| participant.type == Participant.ParticipantType.GUEST) {
- items.removeAt(1)
+ items.removeAt(2)
} else {
// Self joined users can not be promoted nor demoted
- items.removeAt(0)
+ items.removeAt(2)
+ items.removeAt(1)
+ }
+
+ if (participant.attendeePin.isEmpty()) {
items.removeAt(0)
}
@@ -975,13 +1002,21 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
title(text = participant.displayName)
listItemsWithImage(items = items) { dialog, index, _ ->
- if (index == 0) {
- if (participant.type == Participant.ParticipantType.USER_FOLLOWING_LINK) {
- removeAttendeeFromConversation(apiVersion, participant)
- } else {
- toggleModeratorStatus(apiVersion, participant)
- }
- } else if (index == 1) {
+ var actionToTrigger = index
+ if (participant.attendeePin.isEmpty()) {
+ actionToTrigger++
+ }
+ if (participant.type == Participant.ParticipantType.USER_FOLLOWING_LINK) {
+ actionToTrigger++
+ }
+
+ if (actionToTrigger == 0) {
+ // Pin, nothing to do
+ } else if (actionToTrigger == 1) {
+ // Promote/demote
+ toggleModeratorStatus(apiVersion, participant)
+ } else if (actionToTrigger == 2) {
+ // Remove from conversation
removeAttendeeFromConversation(apiVersion, participant)
}
}
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 b6c81c1f2..56d2fafdd 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
@@ -44,6 +44,9 @@ public class Participant {
@JsonField(name = "actorId")
public String actorId;
+ @JsonField(name = "attendeePin")
+ public String attendeePin;
+
@Deprecated
@JsonField(name = "userId")
public String userId;
@@ -115,6 +118,9 @@ public class Participant {
return actorId;
}
+ public String getAttendeePin() {
+ return attendeePin;
+ }
@Deprecated
public String getUserId() {
@@ -184,6 +190,10 @@ public class Participant {
this.actorId = actorId;
}
+ public void setAttendeePin(String attendeePin) {
+ this.attendeePin = attendeePin;
+ }
+
public void setType(ParticipantType type) {
this.type = type;
}
@@ -256,6 +266,9 @@ public class Participant {
if (!actorId.equals(that.actorId)) {
return false;
}
+ if (!attendeePin.equals(that.attendeePin)) {
+ return false;
+ }
if (!userId.equals(that.userId)) {
return false;
}
@@ -288,8 +301,9 @@ public class Participant {
@Override
public int hashCode() {
int result = attendeeId.hashCode();
- result = 31 * result + actorType.hashCode();
- result = 31 * result + actorId.hashCode();
+ result = 31 * result + (actorType != null ? actorType.hashCode() : 0);
+ result = 31 * result + (actorId != null ? actorId.hashCode() : 0);
+ result = 31 * result + (attendeePin != null ? attendeePin.hashCode() : 0);
result = 31 * result + (userId != null ? userId.hashCode() : 0);
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
@@ -310,6 +324,7 @@ public class Participant {
"attendeeId=" + attendeeId +
", actorType='" + actorType + '\'' +
", actorId='" + actorId + '\'' +
+ ", attendeePin='" + attendeePin + '\'' +
", userId='" + userId + '\'' +
", type=" + type +
", name='" + name + '\'' +
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 28ce9c704..0d6942d3b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -256,6 +256,7 @@
Promote to moderator
Remove participant
Remove group and members
+ Pin: %1$s
Enter a messageā¦