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.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
import retrofit2.adapter.rxjava2.HttpException
|
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.Comparator
|
import java.util.Comparator
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.reflect.typeOf
|
|
||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication::class)
|
@AutoInjector(NextcloudTalkApplication::class)
|
||||||
class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleAdapter.OnItemClickListener {
|
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))
|
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||||
|
|
||||||
if (participant.getUserId() == conversationUser!!.userId
|
if (participant.getUserId() == conversationUser!!.userId) {
|
||||||
|| participant.type == Participant.ParticipantType.OWNER) {
|
if (participant.attendeePin.isNotEmpty()) {
|
||||||
// FIXME Show pin?
|
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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,6 +968,10 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
}
|
}
|
||||||
|
|
||||||
var items = mutableListOf(
|
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_promote)),
|
||||||
BasicListItemWithImage(R.drawable.ic_pencil_grey600_24dp, context.getString(R.string.nc_demote)),
|
BasicListItemWithImage(R.drawable.ic_pencil_grey600_24dp, context.getString(R.string.nc_demote)),
|
||||||
BasicListItemWithImage(
|
BasicListItemWithImage(
|
||||||
@ -959,13 +982,17 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
|
|
||||||
if (participant.type == Participant.ParticipantType.MODERATOR
|
if (participant.type == Participant.ParticipantType.MODERATOR
|
||||||
|| participant.type == Participant.ParticipantType.GUEST_MODERATOR) {
|
|| participant.type == Participant.ParticipantType.GUEST_MODERATOR) {
|
||||||
items.removeAt(0)
|
items.removeAt(1)
|
||||||
} else if (participant.type == Participant.ParticipantType.USER
|
} else if (participant.type == Participant.ParticipantType.USER
|
||||||
|| participant.type == Participant.ParticipantType.GUEST) {
|
|| participant.type == Participant.ParticipantType.GUEST) {
|
||||||
items.removeAt(1)
|
items.removeAt(2)
|
||||||
} else {
|
} else {
|
||||||
// Self joined users can not be promoted nor demoted
|
// 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)
|
items.removeAt(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -975,13 +1002,21 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
|
|
||||||
title(text = participant.displayName)
|
title(text = participant.displayName)
|
||||||
listItemsWithImage(items = items) { dialog, index, _ ->
|
listItemsWithImage(items = items) { dialog, index, _ ->
|
||||||
if (index == 0) {
|
var actionToTrigger = index
|
||||||
if (participant.type == Participant.ParticipantType.USER_FOLLOWING_LINK) {
|
if (participant.attendeePin.isEmpty()) {
|
||||||
removeAttendeeFromConversation(apiVersion, participant)
|
actionToTrigger++
|
||||||
} else {
|
}
|
||||||
toggleModeratorStatus(apiVersion, participant)
|
if (participant.type == Participant.ParticipantType.USER_FOLLOWING_LINK) {
|
||||||
}
|
actionToTrigger++
|
||||||
} else if (index == 1) {
|
}
|
||||||
|
|
||||||
|
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)
|
removeAttendeeFromConversation(apiVersion, participant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,9 @@ public class Participant {
|
|||||||
@JsonField(name = "actorId")
|
@JsonField(name = "actorId")
|
||||||
public String actorId;
|
public String actorId;
|
||||||
|
|
||||||
|
@JsonField(name = "attendeePin")
|
||||||
|
public String attendeePin;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@JsonField(name = "userId")
|
@JsonField(name = "userId")
|
||||||
public String userId;
|
public String userId;
|
||||||
@ -115,6 +118,9 @@ public class Participant {
|
|||||||
return actorId;
|
return actorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAttendeePin() {
|
||||||
|
return attendeePin;
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getUserId() {
|
public String getUserId() {
|
||||||
@ -184,6 +190,10 @@ public class Participant {
|
|||||||
this.actorId = actorId;
|
this.actorId = actorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAttendeePin(String attendeePin) {
|
||||||
|
this.attendeePin = attendeePin;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(ParticipantType type) {
|
public void setType(ParticipantType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
@ -256,6 +266,9 @@ public class Participant {
|
|||||||
if (!actorId.equals(that.actorId)) {
|
if (!actorId.equals(that.actorId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!attendeePin.equals(that.attendeePin)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!userId.equals(that.userId)) {
|
if (!userId.equals(that.userId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -288,8 +301,9 @@ public class Participant {
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = attendeeId.hashCode();
|
int result = attendeeId.hashCode();
|
||||||
result = 31 * result + actorType.hashCode();
|
result = 31 * result + (actorType != null ? actorType.hashCode() : 0);
|
||||||
result = 31 * result + actorId.hashCode();
|
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 + (userId != null ? userId.hashCode() : 0);
|
||||||
result = 31 * result + (type != null ? type.hashCode() : 0);
|
result = 31 * result + (type != null ? type.hashCode() : 0);
|
||||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||||
@ -310,6 +324,7 @@ public class Participant {
|
|||||||
"attendeeId=" + attendeeId +
|
"attendeeId=" + attendeeId +
|
||||||
", actorType='" + actorType + '\'' +
|
", actorType='" + actorType + '\'' +
|
||||||
", actorId='" + actorId + '\'' +
|
", actorId='" + actorId + '\'' +
|
||||||
|
", attendeePin='" + attendeePin + '\'' +
|
||||||
", userId='" + userId + '\'' +
|
", userId='" + userId + '\'' +
|
||||||
", type=" + type +
|
", type=" + type +
|
||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
|
@ -256,6 +256,7 @@
|
|||||||
<string name="nc_promote">Promote to moderator</string>
|
<string name="nc_promote">Promote to moderator</string>
|
||||||
<string name="nc_remove_participant">Remove participant</string>
|
<string name="nc_remove_participant">Remove participant</string>
|
||||||
<string name="nc_remove_group_and_members">Remove group and members</string>
|
<string name="nc_remove_group_and_members">Remove group and members</string>
|
||||||
|
<string name="nc_attendee_pin">Pin: %1$s</string>
|
||||||
|
|
||||||
<!-- Chat -->
|
<!-- Chat -->
|
||||||
<string name="nc_hint_enter_a_message">Enter a message…</string>
|
<string name="nc_hint_enter_a_message">Enter a message…</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user