diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index e0f2f7b288..43507e60ce 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3191,7 +3191,8 @@ <string name="open_poll_option_description">Voters see results as soon as they have voted</string> <string name="closed_poll_option_title">Closed poll</string> <string name="closed_poll_option_description">Results are only revealed when you end the poll</string> - <string name="active_polls">Active polls</string> + <string name="room_polls_active">Active polls</string> + <string name="room_polls_active_no_item">There are no active polls in this room</string> <!-- Location --> <string name="location_activity_title_static_sharing">Share location</string> diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsFragment.kt index 7617da71df..5c150f4391 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsFragment.kt @@ -66,7 +66,7 @@ class RoomPollsFragment : VectorBaseFragment<FragmentRoomPollsBinding>() { tabLayoutMediator = TabLayoutMediator(views.roomPollsTabs, views.roomPollsViewPager) { tab, position -> when (position) { - 0 -> tab.text = getString(R.string.active_polls) + 0 -> tab.text = getString(R.string.room_polls_active) } }.also { it.attach() } } diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/RoomActivePollsFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/RoomActivePollsFragment.kt index b4e812a49e..4cc318edf9 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/RoomActivePollsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/RoomActivePollsFragment.kt @@ -20,9 +20,11 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import com.airbnb.mvrx.parentFragmentViewModel import com.airbnb.mvrx.withState import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.R import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseFragment @@ -55,7 +57,8 @@ class RoomActivePollsFragment : private fun setupList() { roomActivePollsController.listener = this - views.activePollsList.configureWith(roomActivePollsController) + views.roomPollsList.configureWith(roomActivePollsController) + views.roomPollsEmptyTitle.text = getString(R.string.room_polls_active_no_item) } override fun onDestroyView() { @@ -64,7 +67,7 @@ class RoomActivePollsFragment : } private fun cleanUpList() { - views.activePollsList.cleanup() + views.roomPollsList.cleanup() roomActivePollsController.listener = null } @@ -79,6 +82,7 @@ class RoomActivePollsFragment : private fun renderList(polls: List<PollSummary.ActivePoll>) { roomActivePollsController.setData(polls) + views.roomPollsEmptyTitle.isVisible = polls.isEmpty() } override fun onPollClicked(pollId: String) { diff --git a/vector/src/main/res/layout/fragment_room_polls_list.xml b/vector/src/main/res/layout/fragment_room_polls_list.xml index 1aa6625ae5..6949bb0c67 100644 --- a/vector/src/main/res/layout/fragment_room_polls_list.xml +++ b/vector/src/main/res/layout/fragment_room_polls_list.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent"> <androidx.recyclerview.widget.RecyclerView - android:id="@+id/activePollsList" + android:id="@+id/roomPollsList" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginHorizontal="@dimen/layout_horizontal_margin" @@ -17,5 +17,26 @@ tools:itemCount="5" tools:listitem="@layout/item_poll_active" /> + <TextView + android:id="@+id/roomPollsEmptyTitle" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginHorizontal="@dimen/layout_horizontal_margin" + android:layout_marginBottom="@dimen/layout_vertical_margin" + android:gravity="center" + android:textAppearance="@style/TextAppearance.Vector.Body" + android:textColor="?vctr_content_secondary" + android:visibility="gone" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/roomPollsEmptyGuideline" + tools:text="@string/room_polls_active_no_item" /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/roomPollsEmptyGuideline" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + app:layout_constraintGuide_percent="0.33" /> </androidx.constraintlayout.widget.ConstraintLayout>