mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
format code
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
27538a77ff
commit
a9168b3f9d
@ -201,9 +201,7 @@ interface NcApiCoroutines {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
suspend fun getOutOfOfficeStatusForUser(
|
suspend fun getOutOfOfficeStatusForUser(
|
||||||
@Header("Authorization") authorization:String,
|
@Header("Authorization") authorization: String,
|
||||||
@Url url:String
|
@Url url: String
|
||||||
): UserAbsenceOverall
|
): UserAbsenceOverall
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -617,10 +617,15 @@ class ChatActivity :
|
|||||||
urlForChatting
|
urlForChatting
|
||||||
)
|
)
|
||||||
|
|
||||||
if(currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL &&
|
if (currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL &&
|
||||||
currentConversation?.status == "dnd"){
|
currentConversation?.status == "dnd"
|
||||||
conversationUser?.let{ user ->
|
) {
|
||||||
chatViewModel.outOfOfficeStatusOfUser(credentials, user.baseUrl!!, currentConversation!!.name)
|
conversationUser?.let { user ->
|
||||||
|
chatViewModel.outOfOfficeStatusOfUser(
|
||||||
|
credentials,
|
||||||
|
user.baseUrl!!,
|
||||||
|
currentConversation!!.name
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,11 +700,14 @@ class ChatActivity :
|
|||||||
|
|
||||||
checkShowCallButtons()
|
checkShowCallButtons()
|
||||||
checkLobbyState()
|
checkLobbyState()
|
||||||
if(currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL){
|
if (currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
|
||||||
conversationUser?.let{ user ->
|
conversationUser?.let { user ->
|
||||||
val credentials = ApiUtils.getCredentials(user.username, user.token)
|
val credentials = ApiUtils.getCredentials(user.username, user.token)
|
||||||
chatViewModel.outOfOfficeStatusOfUser(credentials!!, user.baseUrl!!,
|
chatViewModel.outOfOfficeStatusOfUser(
|
||||||
currentConversation!!.displayName)
|
credentials!!,
|
||||||
|
user.baseUrl!!,
|
||||||
|
currentConversation!!.displayName
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1070,63 +1078,58 @@ class ChatActivity :
|
|||||||
binding.voiceRecordingLock.y -= y
|
binding.voiceRecordingLock.y -= y
|
||||||
}
|
}
|
||||||
|
|
||||||
chatViewModel.outOfOfficeViewState.observe(this){uiState ->
|
chatViewModel.outOfOfficeViewState.observe(this) { uiState ->
|
||||||
when(uiState){
|
when (uiState) {
|
||||||
is ChatViewModel.OutOfOfficeUIState.Error -> {
|
is ChatViewModel.OutOfOfficeUIState.Error -> {
|
||||||
Log.e(TAG, "Error in outOfOfficeState",uiState.exception)
|
Log.e(TAG, "Error in outOfOfficeState", uiState.exception)
|
||||||
|
|
||||||
}
|
}
|
||||||
ChatViewModel.OutOfOfficeUIState.None -> {
|
ChatViewModel.OutOfOfficeUIState.None -> {
|
||||||
|
|
||||||
}
|
}
|
||||||
is ChatViewModel.OutOfOfficeUIState.Success -> {
|
is ChatViewModel.OutOfOfficeUIState.Success -> {
|
||||||
binding.outOfOfficeContainer.visibility = View.VISIBLE
|
binding.outOfOfficeContainer.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
val startDateTimestamp: Long = uiState.userAbsence.startDate.toLong()
|
||||||
|
val endDateTimestamp: Long = uiState.userAbsence.endDate.toLong()
|
||||||
|
|
||||||
val startDateTimestamp:Long = uiState.userAbsence.startDate.toLong()
|
val startDate = Date(startDateTimestamp * 1000)
|
||||||
val endDateTimestamp:Long = uiState.userAbsence.endDate.toLong()
|
val endDate = Date(endDateTimestamp * 1000)
|
||||||
|
|
||||||
val startDate = Date(startDateTimestamp * 1000)
|
val date1 = Calendar.getInstance().apply { time = startDate }
|
||||||
val endDate = Date(endDateTimestamp * 1000)
|
val date2 = Calendar.getInstance().apply { time = endDate }
|
||||||
|
|
||||||
val date1 = Calendar.getInstance().apply{time = startDate}
|
val isSameDay = date1.get(Calendar.YEAR) == date2.get(Calendar.YEAR) &&
|
||||||
val date2 = Calendar.getInstance().apply{time = endDate}
|
date1.get(Calendar.DAY_OF_YEAR) == date2.get(Calendar.DAY_OF_YEAR)
|
||||||
|
|
||||||
val isSameDay = date1.get(Calendar.YEAR) == date2.get(Calendar.YEAR) &&
|
if (isSameDay) {
|
||||||
date1.get(Calendar.DAY_OF_YEAR) == date2.get(Calendar.DAY_OF_YEAR)
|
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceShortMessage).text = String.format(
|
||||||
|
context.resources.getString(R.string.user_absence_for_one_day),
|
||||||
|
uiState.userAbsence.userId
|
||||||
|
)
|
||||||
|
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsencePeriod).visibility =
|
||||||
|
View.GONE
|
||||||
|
} else {
|
||||||
|
val dateFormatter = SimpleDateFormat("MMM d, yyyy", Locale.getDefault())
|
||||||
|
val startDateString = dateFormatter.format(startDate)
|
||||||
|
val endDateString = dateFormatter.format(endDate)
|
||||||
|
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceShortMessage).text = String.format(
|
||||||
|
context.resources.getString(R.string.user_absence),
|
||||||
|
uiState.userAbsence.userId
|
||||||
|
)
|
||||||
|
|
||||||
if (isSameDay) {
|
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsencePeriod).text = "$startDateString - $endDateString"
|
||||||
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceShortMessage).text = String.format(
|
}
|
||||||
context.resources.getString(R.string.user_absence_for_one_day),
|
|
||||||
uiState.userAbsence.userId
|
|
||||||
)
|
|
||||||
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsencePeriod).visibility =
|
|
||||||
View.GONE
|
|
||||||
} else {
|
|
||||||
val dateFormatter = SimpleDateFormat("MMM d, yyyy", Locale.getDefault())
|
|
||||||
val startDateString = dateFormatter.format(startDate)
|
|
||||||
val endDateString = dateFormatter.format(endDate)
|
|
||||||
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceShortMessage).text = String.format(
|
|
||||||
context.resources.getString(R.string.user_absence),
|
|
||||||
uiState.userAbsence.userId
|
|
||||||
)
|
|
||||||
|
|
||||||
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsencePeriod).text = "$startDateString - $endDateString"
|
if (uiState.userAbsence.replacementUserDisplayName != null) {
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(uiState.userAbsence.replacementUserDisplayName != null){
|
|
||||||
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).text = String.format(
|
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).text = String.format(
|
||||||
context.resources.getString(R.string.user_absence_replacement),
|
context.resources.getString(R.string.user_absence_replacement),
|
||||||
uiState.userAbsence.replacementUserDisplayName
|
uiState.userAbsence.replacementUserDisplayName
|
||||||
)
|
)
|
||||||
}else{
|
} else {
|
||||||
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).visibility = View.GONE
|
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).visibility = View.GONE
|
||||||
}
|
}
|
||||||
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceLongMessage).text = uiState.userAbsence.message
|
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceLongMessage).text = uiState.userAbsence.message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3183,7 +3186,7 @@ class ChatActivity :
|
|||||||
private fun isInfoMessageAboutDeletion(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
private fun isInfoMessageAboutDeletion(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||||
currentMessage.value.parentMessageId != null &&
|
currentMessage.value.parentMessageId != null &&
|
||||||
currentMessage.value.systemMessageType == ChatMessage
|
currentMessage.value.systemMessageType == ChatMessage
|
||||||
.SystemMessageType.MESSAGE_DELETED
|
.SystemMessageType.MESSAGE_DELETED
|
||||||
|
|
||||||
private fun isReactionsMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
private fun isReactionsMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||||
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION ||
|
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION ||
|
||||||
@ -3193,7 +3196,7 @@ class ChatActivity :
|
|||||||
private fun isEditMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
private fun isEditMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||||
currentMessage.value.parentMessageId != null &&
|
currentMessage.value.parentMessageId != null &&
|
||||||
currentMessage.value.systemMessageType == ChatMessage
|
currentMessage.value.systemMessageType == ChatMessage
|
||||||
.SystemMessageType.MESSAGE_EDITED
|
.SystemMessageType.MESSAGE_EDITED
|
||||||
|
|
||||||
private fun isPollVotedMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
private fun isPollVotedMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||||
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.POLL_VOTED
|
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.POLL_VOTED
|
||||||
@ -3488,7 +3491,7 @@ class ChatActivity :
|
|||||||
val lon = data["longitude"]!!
|
val lon = data["longitude"]!!
|
||||||
metaData =
|
metaData =
|
||||||
"{\"type\":\"geo-location\",\"id\":\"geo:$lat,$lon\",\"latitude\":\"$lat\"," +
|
"{\"type\":\"geo-location\",\"id\":\"geo:$lat,$lon\",\"latitude\":\"$lat\"," +
|
||||||
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
|
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
shareToNotes(shareUri, roomToken, message, objectId, metaData)
|
shareToNotes(shareUri, roomToken, message, objectId, metaData)
|
||||||
@ -3950,4 +3953,3 @@ class ChatActivity :
|
|||||||
const val NO_OFFLINE_MESSAGES_FOUND = "NO_OFFLINE_MESSAGES_FOUND"
|
const val NO_OFFLINE_MESSAGES_FOUND = "NO_OFFLINE_MESSAGES_FOUND"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,5 @@ interface ChatNetworkDataSource {
|
|||||||
fun createRoom(credentials: String, url: String, map: Map<String, String>): Observable<RoomOverall>
|
fun createRoom(credentials: String, url: String, map: Map<String, String>): Observable<RoomOverall>
|
||||||
fun setChatReadMarker(credentials: String, url: String, previousMessageId: Int): Observable<GenericOverall>
|
fun setChatReadMarker(credentials: String, url: String, previousMessageId: Int): Observable<GenericOverall>
|
||||||
fun editChatMessage(credentials: String, url: String, text: String): Observable<ChatOverallSingleMessage>
|
fun editChatMessage(credentials: String, url: String, text: String): Observable<ChatOverallSingleMessage>
|
||||||
suspend fun getOutOfOfficeStatusForUser (credentials:String,baseUrl:String, userId:String): UserAbsenceOverall
|
suspend fun getOutOfOfficeStatusForUser(credentials: String, baseUrl: String, userId: String): UserAbsenceOverall
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import com.nextcloud.talk.utils.ApiUtils
|
|||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
|
|
||||||
class RetrofitChatNetwork(private val ncApi: NcApi, private val ncApiCoroutines:NcApiCoroutines) : ChatNetworkDataSource {
|
class RetrofitChatNetwork(private val ncApi: NcApi, private val ncApiCoroutines: NcApiCoroutines) : ChatNetworkDataSource {
|
||||||
override fun getRoom(user: User, roomToken: String): Observable<ConversationModel> {
|
override fun getRoom(user: User, roomToken: String): Observable<ConversationModel> {
|
||||||
val credentials: String = ApiUtils.getCredentials(user.username, user.token)!!
|
val credentials: String = ApiUtils.getCredentials(user.username, user.token)!!
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1))
|
val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1))
|
||||||
@ -181,9 +181,14 @@ class RetrofitChatNetwork(private val ncApi: NcApi, private val ncApiCoroutines:
|
|||||||
return ncApi.editChatMessage(credentials, url, text).map { it }
|
return ncApi.editChatMessage(credentials, url, text).map { it }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getOutOfOfficeStatusForUser(credentials: String, baseUrl: String, userId:String):
|
override suspend fun getOutOfOfficeStatusForUser(
|
||||||
UserAbsenceOverall {
|
credentials: String,
|
||||||
return ncApiCoroutines.getOutOfOfficeStatusForUser(credentials,
|
baseUrl: String,
|
||||||
ApiUtils.getUrlForOutOfOffice(baseUrl,userId))
|
userId: String
|
||||||
|
): UserAbsenceOverall {
|
||||||
|
return ncApiCoroutines.getOutOfOfficeStatusForUser(
|
||||||
|
credentials,
|
||||||
|
ApiUtils.getUrlForOutOfOffice(baseUrl, userId)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -771,7 +771,7 @@ class ChatViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun outOfOfficeStatusOfUser(credentials:String, baseUrl: String, userId: String) {
|
fun outOfOfficeStatusOfUser(credentials: String, baseUrl: String, userId: String) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
val response = chatNetworkDataSource.getOutOfOfficeStatusForUser(credentials, baseUrl, userId)
|
val response = chatNetworkDataSource.getOutOfOfficeStatusForUser(credentials, baseUrl, userId)
|
||||||
@ -787,7 +787,6 @@ class ChatViewModel @Inject constructor(
|
|||||||
const val JOIN_ROOM_RETRY_COUNT: Long = 3
|
const val JOIN_ROOM_RETRY_COUNT: Long = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sealed class OutOfOfficeUIState {
|
sealed class OutOfOfficeUIState {
|
||||||
data object None : OutOfOfficeUIState()
|
data object None : OutOfOfficeUIState()
|
||||||
data class Success(val userAbsence: UserAbsenceData) : OutOfOfficeUIState()
|
data class Success(val userAbsence: UserAbsenceData) : OutOfOfficeUIState()
|
||||||
|
@ -148,7 +148,7 @@ class RepositoryModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
fun provideChatNetworkDataSource(ncApi: NcApi, ncApiCoroutines: NcApiCoroutines): ChatNetworkDataSource {
|
fun provideChatNetworkDataSource(ncApi: NcApi, ncApiCoroutines: NcApiCoroutines): ChatNetworkDataSource {
|
||||||
return RetrofitChatNetwork(ncApi,ncApiCoroutines)
|
return RetrofitChatNetwork(ncApi, ncApiCoroutines)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -30,7 +30,7 @@ data class UserAbsenceData(
|
|||||||
@JsonField(name = ["replacementUserId"])
|
@JsonField(name = ["replacementUserId"])
|
||||||
var replacementUserId: String?,
|
var replacementUserId: String?,
|
||||||
@JsonField(name = ["replacementUserDisplayName"])
|
@JsonField(name = ["replacementUserDisplayName"])
|
||||||
var replacementUserDisplayName: String?,
|
var replacementUserDisplayName: String?
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
constructor() :
|
constructor() :
|
||||||
|
@ -24,4 +24,3 @@ data class UserAbsenceOCS(
|
|||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
constructor() : this(null, null)
|
constructor() : this(null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,4 +21,3 @@ data class UserAbsenceOverall(
|
|||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
constructor() : this(null)
|
constructor() : this(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ object ApiUtils {
|
|||||||
return "${getUrlForRoom(version, baseUrl, token)}/archive"
|
return "${getUrlForRoom(version, baseUrl, token)}/archive"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUrlForOutOfOffice(baseUrl:String, userId:String):String{
|
fun getUrlForOutOfOffice(baseUrl: String, userId: String): String {
|
||||||
return "$baseUrl$OCS_API_VERSION/apps/dav/api/v1/outOfOffice/$userId/now"
|
return "$baseUrl$OCS_API_VERSION/apps/dav/api/v1/outOfOffice/$userId/now"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user