From 85a322dd61b1aabd494e2947d31cdbbc68af8ad9 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Mon, 2 Sep 2019 12:55:10 +0200 Subject: [PATCH] Fix date selection & time formatting for lobby Signed-off-by: Mario Danic --- .../controllers/ConversationInfoController.kt | 16 ++++++++-------- .../java/com/nextcloud/talk/utils/DateUtils.kt | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt index d0fd74503..52f5021db 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt @@ -205,13 +205,13 @@ class ConversationInfoController(args: Bundle) : BaseController(args) { reconfigureLobbyTimerView() - val currentTimeCalendar = Calendar.getInstance() - if (conversation!!.lobbyTimer != null && conversation!!.lobbyTimer != 0L) { - currentTimeCalendar.set(Calendar.MILLISECOND, (conversation!!.lobbyTimer * 1000).toInt()) - } - startTimeView.setOnClickListener { MaterialDialog(activity!!, BottomSheet(WRAP_CONTENT)).show { + val currentTimeCalendar = Calendar.getInstance() + if (conversation!!.lobbyTimer != null && conversation!!.lobbyTimer != 0L) { + currentTimeCalendar.timeInMillis = conversation!!.lobbyTimer * 1000 + } + dateTimePicker(minDateTime = Calendar.getInstance(), requireFutureDateTime = true, currentDateTime = currentTimeCalendar, dateTimeCallback = { _, dateTime -> @@ -234,7 +234,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args) { val isChecked = (conversationInfoLobby.findViewById(R.id.mp_checkable) as SwitchCompat).isChecked if (dateTime != null && isChecked) { - conversation!!.lobbyTimer = dateTime.timeInMillis / 1000 + conversation!!.lobbyTimer = (dateTime.timeInMillis - (dateTime.time.seconds * 1000)) / 1000 } else if (!isChecked) { conversation!!.lobbyTimer = 0 } @@ -534,8 +534,8 @@ class ConversationInfoController(args: Bundle) : BaseController(args) { R.drawable.ic_link_white_24px)) Conversation.ConversationType.ROOM_SYSTEM -> { val layers = arrayOfNulls(2) - layers[0] = context!!.getDrawable(R.drawable.ic_launcher_background) - layers[1] = context!!.getDrawable(R.drawable.ic_launcher_foreground) + layers[0] = context.getDrawable(R.drawable.ic_launcher_background) + layers[1] = context.getDrawable(R.drawable.ic_launcher_foreground) val layerDrawable = LayerDrawable(layers) conversationAvatarImageView.hierarchy.setPlaceholderImage(DisplayUtils.getRoundedDrawable(layerDrawable)) } diff --git a/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt index cb2e66979..20fceb297 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt @@ -30,7 +30,7 @@ object DateUtils { val tz = cal.timeZone /* date formatter in local timezone */ - val format = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.MEDIUM, Locale + val format = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT, Locale .getDefault()) format.timeZone = tz