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
|
||||
suspend fun getOutOfOfficeStatusForUser(
|
||||
@Header("Authorization") authorization:String,
|
||||
@Url url:String
|
||||
@Header("Authorization") authorization: String,
|
||||
@Url url: String
|
||||
): UserAbsenceOverall
|
||||
|
||||
|
||||
}
|
||||
|
@ -617,10 +617,15 @@ class ChatActivity :
|
||||
urlForChatting
|
||||
)
|
||||
|
||||
if(currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL &&
|
||||
currentConversation?.status == "dnd"){
|
||||
conversationUser?.let{ user ->
|
||||
chatViewModel.outOfOfficeStatusOfUser(credentials, user.baseUrl!!, currentConversation!!.name)
|
||||
if (currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL &&
|
||||
currentConversation?.status == "dnd"
|
||||
) {
|
||||
conversationUser?.let { user ->
|
||||
chatViewModel.outOfOfficeStatusOfUser(
|
||||
credentials,
|
||||
user.baseUrl!!,
|
||||
currentConversation!!.name
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -695,11 +700,14 @@ class ChatActivity :
|
||||
|
||||
checkShowCallButtons()
|
||||
checkLobbyState()
|
||||
if(currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL){
|
||||
conversationUser?.let{ user ->
|
||||
if (currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
|
||||
conversationUser?.let { user ->
|
||||
val credentials = ApiUtils.getCredentials(user.username, user.token)
|
||||
chatViewModel.outOfOfficeStatusOfUser(credentials!!, user.baseUrl!!,
|
||||
currentConversation!!.displayName)
|
||||
chatViewModel.outOfOfficeStatusOfUser(
|
||||
credentials!!,
|
||||
user.baseUrl!!,
|
||||
currentConversation!!.displayName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1070,63 +1078,58 @@ class ChatActivity :
|
||||
binding.voiceRecordingLock.y -= y
|
||||
}
|
||||
|
||||
chatViewModel.outOfOfficeViewState.observe(this){uiState ->
|
||||
when(uiState){
|
||||
chatViewModel.outOfOfficeViewState.observe(this) { uiState ->
|
||||
when (uiState) {
|
||||
is ChatViewModel.OutOfOfficeUIState.Error -> {
|
||||
Log.e(TAG, "Error in outOfOfficeState",uiState.exception)
|
||||
|
||||
Log.e(TAG, "Error in outOfOfficeState", uiState.exception)
|
||||
}
|
||||
ChatViewModel.OutOfOfficeUIState.None -> {
|
||||
|
||||
}
|
||||
is ChatViewModel.OutOfOfficeUIState.Success -> {
|
||||
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 endDateTimestamp:Long = uiState.userAbsence.endDate.toLong()
|
||||
val startDate = Date(startDateTimestamp * 1000)
|
||||
val endDate = Date(endDateTimestamp * 1000)
|
||||
|
||||
val startDate = Date(startDateTimestamp * 1000)
|
||||
val endDate = Date(endDateTimestamp * 1000)
|
||||
val date1 = Calendar.getInstance().apply { time = startDate }
|
||||
val date2 = Calendar.getInstance().apply { time = endDate }
|
||||
|
||||
val date1 = Calendar.getInstance().apply{time = startDate}
|
||||
val date2 = Calendar.getInstance().apply{time = endDate}
|
||||
val isSameDay = date1.get(Calendar.YEAR) == date2.get(Calendar.YEAR) &&
|
||||
date1.get(Calendar.DAY_OF_YEAR) == date2.get(Calendar.DAY_OF_YEAR)
|
||||
|
||||
val isSameDay = date1.get(Calendar.YEAR) == date2.get(Calendar.YEAR) &&
|
||||
date1.get(Calendar.DAY_OF_YEAR) == date2.get(Calendar.DAY_OF_YEAR)
|
||||
if (isSameDay) {
|
||||
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.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"
|
||||
}
|
||||
|
||||
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(
|
||||
context.resources.getString(R.string.user_absence_replacement),
|
||||
uiState.userAbsence.replacementUserDisplayName
|
||||
)
|
||||
}else{
|
||||
} else {
|
||||
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).visibility = View.GONE
|
||||
}
|
||||
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 =
|
||||
currentMessage.value.parentMessageId != null &&
|
||||
currentMessage.value.systemMessageType == ChatMessage
|
||||
.SystemMessageType.MESSAGE_DELETED
|
||||
.SystemMessageType.MESSAGE_DELETED
|
||||
|
||||
private fun isReactionsMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION ||
|
||||
@ -3193,7 +3196,7 @@ class ChatActivity :
|
||||
private fun isEditMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||
currentMessage.value.parentMessageId != null &&
|
||||
currentMessage.value.systemMessageType == ChatMessage
|
||||
.SystemMessageType.MESSAGE_EDITED
|
||||
.SystemMessageType.MESSAGE_EDITED
|
||||
|
||||
private fun isPollVotedMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.POLL_VOTED
|
||||
@ -3488,7 +3491,7 @@ class ChatActivity :
|
||||
val lon = data["longitude"]!!
|
||||
metaData =
|
||||
"{\"type\":\"geo-location\",\"id\":\"geo:$lat,$lon\",\"latitude\":\"$lat\"," +
|
||||
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
|
||||
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
|
||||
}
|
||||
|
||||
shareToNotes(shareUri, roomToken, message, objectId, metaData)
|
||||
@ -3950,4 +3953,3 @@ class ChatActivity :
|
||||
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 setChatReadMarker(credentials: String, url: String, previousMessageId: Int): Observable<GenericOverall>
|
||||
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 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> {
|
||||
val credentials: String = ApiUtils.getCredentials(user.username, user.token)!!
|
||||
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 }
|
||||
}
|
||||
|
||||
override suspend fun getOutOfOfficeStatusForUser(credentials: String, baseUrl: String, userId:String):
|
||||
UserAbsenceOverall {
|
||||
return ncApiCoroutines.getOutOfOfficeStatusForUser(credentials,
|
||||
ApiUtils.getUrlForOutOfOffice(baseUrl,userId))
|
||||
override suspend fun getOutOfOfficeStatusForUser(
|
||||
credentials: String,
|
||||
baseUrl: String,
|
||||
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 {
|
||||
try {
|
||||
val response = chatNetworkDataSource.getOutOfOfficeStatusForUser(credentials, baseUrl, userId)
|
||||
@ -787,7 +787,6 @@ class ChatViewModel @Inject constructor(
|
||||
const val JOIN_ROOM_RETRY_COUNT: Long = 3
|
||||
}
|
||||
|
||||
|
||||
sealed class OutOfOfficeUIState {
|
||||
data object None : OutOfOfficeUIState()
|
||||
data class Success(val userAbsence: UserAbsenceData) : OutOfOfficeUIState()
|
||||
|
@ -148,7 +148,7 @@ class RepositoryModule {
|
||||
|
||||
@Provides
|
||||
fun provideChatNetworkDataSource(ncApi: NcApi, ncApiCoroutines: NcApiCoroutines): ChatNetworkDataSource {
|
||||
return RetrofitChatNetwork(ncApi,ncApiCoroutines)
|
||||
return RetrofitChatNetwork(ncApi, ncApiCoroutines)
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -30,7 +30,7 @@ data class UserAbsenceData(
|
||||
@JsonField(name = ["replacementUserId"])
|
||||
var replacementUserId: String?,
|
||||
@JsonField(name = ["replacementUserDisplayName"])
|
||||
var replacementUserDisplayName: String?,
|
||||
var replacementUserDisplayName: String?
|
||||
) : Parcelable {
|
||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||
constructor() :
|
||||
|
@ -24,4 +24,3 @@ data class UserAbsenceOCS(
|
||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||
constructor() : this(null, null)
|
||||
}
|
||||
|
||||
|
@ -21,4 +21,3 @@ data class UserAbsenceOverall(
|
||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||
constructor() : this(null)
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ object ApiUtils {
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user