mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 14:54:09 +01:00
Display the pin if the participant has one
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
4ad96cc347
commit
32bb98e43e
@ -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)
|
||||
var actionToTrigger = index
|
||||
if (participant.attendeePin.isEmpty()) {
|
||||
actionToTrigger++
|
||||
}
|
||||
} else if (index == 1) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -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 + '\'' +
|
||||
|
@ -256,6 +256,7 @@
|
||||
<string name="nc_promote">Promote to moderator</string>
|
||||
<string name="nc_remove_participant">Remove participant</string>
|
||||
<string name="nc_remove_group_and_members">Remove group and members</string>
|
||||
<string name="nc_attendee_pin">Pin: %1$s</string>
|
||||
|
||||
<!-- Chat -->
|
||||
<string name="nc_hint_enter_a_message">Enter a message…</string>
|
||||
|
Loading…
Reference in New Issue
Block a user