format code and remove unused colors

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-12-09 13:50:40 +01:00
parent cadb12cd0f
commit 3eab18472f
No known key found for this signature in database
GPG Key ID: F7AA2A8B65B50220
6 changed files with 32 additions and 47 deletions

View File

@ -209,12 +209,10 @@ import java.io.File
import java.io.IOException import java.io.IOException
import java.net.HttpURLConnection import java.net.HttpURLConnection
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date import java.util.Date
import java.util.Locale import java.util.Locale
import java.util.concurrent.ExecutionException import java.util.concurrent.ExecutionException
import javax.inject.Inject import javax.inject.Inject
import kotlin.String
import kotlin.collections.set import kotlin.collections.set
import kotlin.math.roundToInt import kotlin.math.roundToInt
@ -621,18 +619,6 @@ class ChatActivity :
urlForChatting 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
)
}
}
logConversationInfos("GetRoomSuccessState") logConversationInfos("GetRoomSuccessState")
if (adapter == null) { if (adapter == null) {
@ -701,16 +687,17 @@ class ChatActivity :
loadAvatarForStatusBar() loadAvatarForStatusBar()
setupSwipeToReply() setupSwipeToReply()
setActionBarTitle() setActionBarTitle()
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 &&
currentConversation?.status == "dnd"
) {
conversationUser?.let { user -> conversationUser?.let { user ->
val credentials = ApiUtils.getCredentials(user.username, user.token) val credentials = ApiUtils.getCredentials(user.username, user.token)
chatViewModel.outOfOfficeStatusOfUser( chatViewModel.outOfOfficeStatusOfUser(
credentials!!, credentials!!,
user.baseUrl!!, user.baseUrl!!,
currentConversation!!.displayName currentConversation!!.name
) )
} }
} }
@ -1101,14 +1088,9 @@ class ChatActivity :
val startDate = Date(startDateTimestamp * 1000) val startDate = Date(startDateTimestamp * 1000)
val endDate = Date(endDateTimestamp * 1000) val endDate = Date(endDateTimestamp * 1000)
val date1 = Calendar.getInstance().apply { time = startDate } if (dateUtils.isSameDate(startDate, endDate)) {
val date2 = Calendar.getInstance().apply { time = endDate } binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceShortMessage).text =
String.format(
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), context.resources.getString(R.string.user_absence_for_one_day),
uiState.userAbsence.userId uiState.userAbsence.userId
) )
@ -1118,12 +1100,14 @@ class ChatActivity :
val dateFormatter = SimpleDateFormat("MMM d, yyyy", Locale.getDefault()) val dateFormatter = SimpleDateFormat("MMM d, yyyy", Locale.getDefault())
val startDateString = dateFormatter.format(startDate) val startDateString = dateFormatter.format(startDate)
val endDateString = dateFormatter.format(endDate) val endDateString = dateFormatter.format(endDate)
binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceShortMessage).text = String.format( binding.outOfOfficeContainer.findViewById<TextView>(R.id.userAbsenceShortMessage).text =
String.format(
context.resources.getString(R.string.user_absence), context.resources.getString(R.string.user_absence),
uiState.userAbsence.userId 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) {
@ -1146,7 +1130,8 @@ class ChatActivity :
) )
) )
} }
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).text = context.resources.getString(R.string.user_absence_replacement) binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).text =
context.resources.getString(R.string.user_absence_replacement)
binding.outOfOfficeContainer.findViewById<ImageView>(R.id.replacement_user_avatar) binding.outOfOfficeContainer.findViewById<ImageView>(R.id.replacement_user_avatar)
.load(imageUri) { .load(imageUri) {
transformations(CircleCropTransformation()) transformations(CircleCropTransformation())
@ -1157,9 +1142,11 @@ class ChatActivity :
binding.outOfOfficeContainer.findViewById<TextView>(R.id.replacement_user_name).text = binding.outOfOfficeContainer.findViewById<TextView>(R.id.replacement_user_name).text =
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
binding.outOfOfficeContainer.findViewById<CardView>(R.id.avatar_chip).setOnClickListener { binding.outOfOfficeContainer.findViewById<CardView>(R.id.avatar_chip).setOnClickListener {
joinOneToOneConversation(uiState.userAbsence.replacementUserId!!) joinOneToOneConversation(uiState.userAbsence.replacementUserId!!)
} }

View File

@ -51,6 +51,14 @@ class DateUtils(val context: Context) {
return formatTime.format(Date(timestampSeconds * DateConstants.SECOND_DIVIDER)) return formatTime.format(Date(timestampSeconds * DateConstants.SECOND_DIVIDER))
} }
fun isSameDate(date1: Date, date2: Date): Boolean {
val startDateCalendar = Calendar.getInstance().apply { time = date1 }
val endDateCalendar = Calendar.getInstance().apply { time = date2 }
val isSameDay = startDateCalendar.get(Calendar.YEAR) == endDateCalendar.get(Calendar.YEAR) &&
startDateCalendar.get(Calendar.DAY_OF_YEAR) == endDateCalendar.get(Calendar.DAY_OF_YEAR)
return isSameDay
}
fun getTimeDifferenceInSeconds(time2: Long, time1: Long): Long { fun getTimeDifferenceInSeconds(time2: Long, time1: Long): Long {
val difference = (time2 - time1) val difference = (time2 - time1)
return abs(difference) return abs(difference)

View File

@ -61,7 +61,4 @@
<color name="icon_on_bg_default">#99FFFFFF</color> <color name="icon_on_bg_default">#99FFFFFF</color>
<color name="scrollview_out_of_office_background">#cee7fe</color>
<color name="scrollview_out_of_office_text">#5e95b4</color>
</resources> </resources>

View File

@ -93,7 +93,4 @@
<color name="badge_color">#EF3B02</color> <color name="badge_color">#EF3B02</color>
<color name="secondary_button_background">#DBE2E9</color> <color name="secondary_button_background">#DBE2E9</color>
<color name="scrollview_out_of_office_background">#cee5fd</color>
<color name="scrollview_out_of_office_text">#08486e</color>
</resources> </resources>

View File

@ -842,5 +842,5 @@ How to translate with transifex:
<string name="user_absence">%1$s is out of office and might not respond</string> <string name="user_absence">%1$s is out of office and might not respond</string>
<string name="user_absence_for_one_day">%1$s is out of office today</string> <string name="user_absence_for_one_day">%1$s is out of office today</string>
<string name="user_absence_replacement">Replacement</string> <string name="user_absence_replacement">Replacement: </string>
</resources> </resources>

View File

@ -288,8 +288,4 @@
<item name="cornerSize">50%</item> <item name="cornerSize">50%</item>
</style> </style>
<style name="ScrollViewStyle">
<item name="android:background">@color/scrollview_out_of_office_background</item>
</style>
</resources> </resources>