Merge pull request #2450 from vector-im/feature/bca/home_empty_screens

Home empty screen design update
This commit is contained in:
Benoit Marty 2020-11-27 13:51:04 +01:00 committed by GitHub
commit 942f050579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 99 additions and 37 deletions

View file

@ -14,6 +14,7 @@ Improvements 🙌:
- Handle events of type "m.room.server_acl" (#890) - Handle events of type "m.room.server_acl" (#890)
- Room creation form: add advanced section to disable federation (#1314) - Room creation form: add advanced section to disable federation (#1314)
- Move "Enable Encryption" from room setting screen to room profile screen (#2394) - Move "Enable Encryption" from room setting screen to room profile screen (#2394)
- Home empty screens quick design update (#2347)
- Improve Invite user screen (seamless search for matrix ID) - Improve Invite user screen (seamless search for matrix ID)
Bugfix 🐛: Bugfix 🐛:

View file

@ -0,0 +1,28 @@
/*
* Copyright (c) 2020 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.extensions
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
fun ConstraintLayout.updateConstraintSet(block: (ConstraintSet) -> Unit) {
ConstraintSet().let {
it.clone(this)
block.invoke(it)
it.applyTo(this)
}
}

View file

@ -21,8 +21,10 @@ import android.graphics.drawable.Drawable
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.isVisible import androidx.core.view.isVisible
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.extensions.updateConstraintSet
import kotlinx.android.synthetic.main.view_state.view.* import kotlinx.android.synthetic.main.view_state.view.*
class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
@ -31,7 +33,12 @@ class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
sealed class State { sealed class State {
object Content : State() object Content : State()
object Loading : State() object Loading : State()
data class Empty(val title: CharSequence? = null, val image: Drawable? = null, val message: CharSequence? = null) : State() data class Empty(
val title: CharSequence? = null,
val image: Drawable? = null,
val isBigImage: Boolean = false,
val message: CharSequence? = null
) : State()
data class Error(val message: CharSequence? = null) : State() data class Error(val message: CharSequence? = null) : State()
} }
@ -71,6 +78,9 @@ class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
is State.Loading -> Unit is State.Loading -> Unit
is State.Empty -> { is State.Empty -> {
emptyImageView.setImageDrawable(newState.image) emptyImageView.setImageDrawable(newState.image)
emptyView.updateConstraintSet {
it.constrainPercentHeight(R.id.emptyImageView, if (newState.isBigImage) 0.5f else 0.1f)
}
emptyMessageView.text = newState.message emptyMessageView.text = newState.message
emptyTitleView.text = newState.title emptyTitleView.text = newState.title
} }

View file

@ -294,28 +294,30 @@ class RoomListFragment @Inject constructor(
RoomListDisplayMode.NOTIFICATIONS -> { RoomListDisplayMode.NOTIFICATIONS -> {
if (hasNoRoom) { if (hasNoRoom) {
StateView.State.Empty( StateView.State.Empty(
getString(R.string.room_list_catchup_welcome_title), title = getString(R.string.room_list_catchup_welcome_title),
ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_catchup), image = ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_catchup),
getString(R.string.room_list_catchup_welcome_body) message = getString(R.string.room_list_catchup_welcome_body)
) )
} else { } else {
StateView.State.Empty( StateView.State.Empty(
getString(R.string.room_list_catchup_empty_title), title = getString(R.string.room_list_catchup_empty_title),
ContextCompat.getDrawable(requireContext(), R.drawable.ic_noun_party_popper), image = ContextCompat.getDrawable(requireContext(), R.drawable.ic_noun_party_popper),
getString(R.string.room_list_catchup_empty_body)) message = getString(R.string.room_list_catchup_empty_body))
} }
} }
RoomListDisplayMode.PEOPLE -> RoomListDisplayMode.PEOPLE ->
StateView.State.Empty( StateView.State.Empty(
getString(R.string.room_list_people_empty_title), title = getString(R.string.room_list_people_empty_title),
ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_chat), image = ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_dm),
getString(R.string.room_list_people_empty_body) isBigImage = true,
message = getString(R.string.room_list_people_empty_body)
) )
RoomListDisplayMode.ROOMS -> RoomListDisplayMode.ROOMS ->
StateView.State.Empty( StateView.State.Empty(
getString(R.string.room_list_rooms_empty_title), title = getString(R.string.room_list_rooms_empty_title),
ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_group), image = ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_room),
getString(R.string.room_list_rooms_empty_body) isBigImage = true,
message = getString(R.string.room_list_rooms_empty_body)
) )
else -> else ->
// Always display the content in this mode, because if the footer // Always display the content in this mode, because if the footer

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

View file

@ -20,7 +20,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/layout_horizontal_margin"> android:padding="@dimen/layout_horizontal_margin"
android:visibility="gone"
tools:visibility="visible">
<TextView <TextView
android:id="@+id/errorMessageView" android:id="@+id/errorMessageView"
@ -32,7 +34,6 @@
android:textSize="16sp" android:textSize="16sp"
tools:text="Une erreur est survenue" /> tools:text="Une erreur est survenue" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/errorRetryView" android:id="@+id/errorRetryView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -44,7 +45,6 @@
</LinearLayout> </LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/emptyView" android:id="@+id/emptyView"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -53,47 +53,56 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/layout_horizontal_margin"> android:padding="@dimen/layout_horizontal_margin">
<ImageView
android:id="@+id/emptyImageView"
style="@style/VectorEmptyImageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="30dp"
android:maxHeight="350dp"
app:layout_constraintBottom_toTopOf="@id/emptyTitleView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:ignore="MissingPrefix"
tools:layout_constraintHeight_percent="0.5"
tools:src="@drawable/ic_search_no_results" />
<TextView <TextView
android:id="@+id/emptyTitleView" android:id="@+id/emptyTitleView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginBottom="49dp"
android:gravity="center" android:gravity="center"
android:textColor="?riotx_text_primary" android:textColor="?riotx_text_primary"
android:textSize="15sp" android:textSize="15sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/emptyImageView" app:layout_constraintBottom_toTopOf="@id/emptyMessageView"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:text="@string/room_list_catchup_empty_title" /> app:layout_constraintTop_toBottomOf="@id/emptyImageView"
app:layout_constraintVertical_chainStyle="packed"
<ImageView tools:text="@string/room_list_people_empty_title" />
android:id="@+id/emptyImageView"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center_horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_noun_party_popper"
app:tint="?riotx_text_primary"
tools:ignore="MissingPrefix" />
<TextView <TextView
android:id="@+id/emptyMessageView" android:id="@+id/emptyMessageView"
android:layout_width="220dp" android:layout_width="220dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="49dp" android:layout_marginTop="20dp"
android:gravity="center" android:gravity="center"
android:textColor="?riotx_text_secondary" android:textColor="?riotx_text_secondary"
android:textSize="14sp" android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emptyImageView" app:layout_constraintTop_toBottomOf="@+id/emptyTitleView"
tools:text="@string/room_list_catchup_empty_body" /> app:layout_constraintVertical_chainStyle="packed"
tools:text="@string/room_list_people_empty_body" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="VectorEmptyImageView">
<item name="android:visibility">gone</item>
</style>
</resources>

View file

@ -1644,9 +1644,9 @@
<string name="room_list_catchup_welcome_title">Welcome home!</string> <string name="room_list_catchup_welcome_title">Welcome home!</string>
<string name="room_list_catchup_welcome_body">Catch up on unread messages here</string> <string name="room_list_catchup_welcome_body">Catch up on unread messages here</string>
<string name="room_list_people_empty_title">Conversations</string> <string name="room_list_people_empty_title">Conversations</string>
<string name="room_list_people_empty_body">Your direct message conversations will be displayed here</string> <string name="room_list_people_empty_body">Your direct message conversations will be displayed here. Tap the + bottom right to start some.</string>
<string name="room_list_rooms_empty_title">Rooms</string> <string name="room_list_rooms_empty_title">Rooms</string>
<string name="room_list_rooms_empty_body">Your rooms will be displayed here</string> <string name="room_list_rooms_empty_body">Your rooms will be displayed here. Tap the + bottom right to find existing ones or start some of your own.</string>
<string name="title_activity_emoji_reaction_picker">Reactions</string> <string name="title_activity_emoji_reaction_picker">Reactions</string>
<string name="reactions_agree">Agree</string> <string name="reactions_agree">Agree</string>

View file

@ -3,4 +3,8 @@
<style name="Vector.PopupMenu" parent="Vector.PopupMenuBase" /> <style name="Vector.PopupMenu" parent="Vector.PopupMenuBase" />
<style name="VectorEmptyImageView">
<item name="android:visibility">visible</item>
</style>
</resources> </resources>