diff --git a/library/ui-styles/src/main/res/values/styles_jump_to_unread.xml b/library/ui-styles/src/main/res/values/styles_jump_to_unread.xml new file mode 100644 index 0000000000..d0561425ff --- /dev/null +++ b/library/ui-styles/src/main/res/values/styles_jump_to_unread.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/library/ui-styles/src/main/res/values/theme_dark.xml b/library/ui-styles/src/main/res/values/theme_dark.xml index b9965439ff..69f1b4d5cc 100644 --- a/library/ui-styles/src/main/res/values/theme_dark.xml +++ b/library/ui-styles/src/main/res/values/theme_dark.xml @@ -86,6 +86,7 @@ @style/Widget.Vector.SnackBar.Button @style/Widget.Vector.SnackBar.TextView @style/Widget.Vector.ActionMode + @style/Widget.Vector.JumpToUnread.Dark @style/Theme.Vector.BottomSheetDialog.Dark diff --git a/library/ui-styles/src/main/res/values/theme_light.xml b/library/ui-styles/src/main/res/values/theme_light.xml index 531f590b6c..db379028f3 100644 --- a/library/ui-styles/src/main/res/values/theme_light.xml +++ b/library/ui-styles/src/main/res/values/theme_light.xml @@ -86,6 +86,7 @@ @style/Widget.Vector.SnackBar.Button @style/Widget.Vector.SnackBar.TextView @style/Widget.Vector.ActionMode + @style/Widget.Vector.JumpToUnread.Light @style/Theme.Vector.BottomSheetDialog.Light diff --git a/vector/src/main/java/im/vector/app/core/ui/views/JumpToReadMarkerView.kt b/vector/src/main/java/im/vector/app/core/ui/views/JumpToReadMarkerView.kt deleted file mode 100644 index 28e23c0e50..0000000000 --- a/vector/src/main/java/im/vector/app/core/ui/views/JumpToReadMarkerView.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2019 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package im.vector.app.core.ui.views - -import android.content.Context -import android.util.AttributeSet -import android.view.View -import android.widget.RelativeLayout -import androidx.core.content.ContextCompat -import im.vector.app.R -import im.vector.app.databinding.ViewJumpToReadMarkerBinding - -class JumpToReadMarkerView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : RelativeLayout(context, attrs, defStyleAttr) { - - interface Callback { - fun onJumpToReadMarkerClicked() - fun onClearReadMarkerClicked() - } - - var callback: Callback? = null - - init { - setupView() - } - - private fun setupView() { - inflate(context, R.layout.view_jump_to_read_marker, this) - val views = ViewJumpToReadMarkerBinding.bind(this) - setBackgroundColor(ContextCompat.getColor(context, R.color.notification_accent_color)) - views.jumpToReadMarkerLabelView.setOnClickListener { - callback?.onJumpToReadMarkerClicked() - } - views.closeJumpToReadMarkerView.setOnClickListener { - visibility = View.INVISIBLE - callback?.onClearReadMarkerClicked() - } - } -} diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index 8307e93576..46a47f9be6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -1,3 +1,4 @@ + /* * Copyright 2019 New Vector Ltd * @@ -94,7 +95,6 @@ import im.vector.app.core.resources.ColorProvider import im.vector.app.core.ui.views.ActiveConferenceView import im.vector.app.core.ui.views.CurrentCallsView import im.vector.app.core.ui.views.FailedMessagesWarningView -import im.vector.app.core.ui.views.JumpToReadMarkerView import im.vector.app.core.ui.views.KnownCallsViewHolder import im.vector.app.core.ui.views.NotificationAreaView import im.vector.app.core.utils.Debouncer @@ -239,7 +239,6 @@ class RoomDetailFragment @Inject constructor( VectorBaseFragment(), TimelineEventController.Callback, VectorInviteView.Callback, - JumpToReadMarkerView.Callback, AttachmentTypeSelectorView.Callback, AttachmentsHelper.Callback, GalleryOrCameraDialogHelper.Listener, @@ -725,7 +724,13 @@ class RoomDetailFragment @Inject constructor( } private fun setupJumpToReadMarkerView() { - views.jumpToReadMarkerView.callback = this + views.jumpToReadMarkerView.setOnClickListener { + onJumpToReadMarkerClicked() + } + views.jumpToReadMarkerView.setOnCloseIconClickListener { + views.jumpToReadMarkerView.isVisible = false + onClearReadMarkerClicked() + } } private fun setupActiveCallView() { @@ -1959,9 +1964,7 @@ class RoomDetailFragment @Inject constructor( roomDetailViewModel.handle(RoomDetailAction.RejectInvite) } -// JumpToReadMarkerView.Callback - - override fun onJumpToReadMarkerClicked() = withState(roomDetailViewModel) { + private fun onJumpToReadMarkerClicked() = withState(roomDetailViewModel) { views.jumpToReadMarkerView.isVisible = false if (it.unreadState is UnreadState.HasUnread) { roomDetailViewModel.handle(RoomDetailAction.NavigateToEvent(it.unreadState.firstUnreadEventId, false)) @@ -1971,7 +1974,7 @@ class RoomDetailFragment @Inject constructor( } } - override fun onClearReadMarkerClicked() { + private fun onClearReadMarkerClicked() { roomDetailViewModel.handle(RoomDetailAction.MarkAllAsRead) } diff --git a/vector/src/main/res/drawable/ic_jump_to_unread.xml b/vector/src/main/res/drawable/ic_jump_to_unread.xml new file mode 100644 index 0000000000..2c5b8b90c1 --- /dev/null +++ b/vector/src/main/res/drawable/ic_jump_to_unread.xml @@ -0,0 +1,10 @@ + + + diff --git a/vector/src/main/res/layout/fragment_room_detail.xml b/vector/src/main/res/layout/fragment_room_detail.xml index 19d85d5393..de0f95f583 100644 --- a/vector/src/main/res/layout/fragment_room_detail.xml +++ b/vector/src/main/res/layout/fragment_room_detail.xml @@ -127,32 +127,22 @@ app:layout_constraintTop_toBottomOf="@id/activeConferenceView" tools:listitem="@layout/item_timeline_event_base" /> - + app:layout_constraintTop_toBottomOf="@id/activeConferenceView" + tools:visibility="visible" /> - - - - - - - - - - - - - + app:layout_constraintTop_toBottomOf="@id/jumpToReadMarkerView"> - - - - - - - diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 54356db664..5a95a96e5c 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -783,7 +783,7 @@ List members Open header Syncing… - Jump to first unread message. + Jump to unread You have been invited to join this room by %s