Public rooms little rework

This commit is contained in:
Benoit Marty 2019-06-03 16:04:22 +02:00
parent 3b12f5eec7
commit c1fa728c24
10 changed files with 155 additions and 107 deletions

View File

@ -45,10 +45,10 @@ android {

debug {
// Set to true to log privacy or sensible data, such as token
buildConfigField "boolean", "LOG_PRIVATE_DATA", "false"
buildConfigField "boolean", "LOG_PRIVATE_DATA", "true"

// Set to BODY instead of NONE to enable logging
buildConfigField "okhttp3.logging.HttpLoggingInterceptor.Level", "OKHTTP_LOGGING_LEVEL", "okhttp3.logging.HttpLoggingInterceptor.Level.NONE"
buildConfigField "okhttp3.logging.HttpLoggingInterceptor.Level", "OKHTTP_LOGGING_LEVEL", "okhttp3.logging.HttpLoggingInterceptor.Level.BODY"
}

release {

View File

@ -5,6 +5,7 @@
"mxid": "@longmatrixidbecausesometimesuserschooselongmxid:matrix.org",
"message": "William Shakespeare (bapt. 26 April 1564 23 April 1616) was an English poet, playwright and actor, widely regarded as the greatest writer in the English language and the world's greatest dramatist. He is often called England's national poet and the \"Bard of Avon\". His extant works, including collaborations, consist of approximately 39 plays, 154 sonnets, two long narrative poems, and a few other verses, some of uncertain authorship. His plays have been translated into every major living language and are performed more often than those of any other playwright.\n\nShakespeare was born and raised in Stratford-upon-Avon, Warwickshire. At the age of 18, he married Anne Hathaway, with whom he had three children: Susanna and twins Hamnet and Judith. Sometime between 1585 and 1592, he began a successful career in London as an actor, writer, and part-owner of a playing company called the Lord Chamberlain's Men, later known as the King's Men. At age 49 (around 1613), he appears to have retired to Stratford, where he died three years later. Few records of Shakespeare's private life survive; this has stimulated considerable speculation about such matters as his physical appearance, his sexuality, his religious beliefs, and whether the works attributed to him were written by others. Such theories are often criticised for failing to adequately note that few records survive of most commoners of the period.\n\nShakespeare produced most of his known works between 1589 and 1613. His early plays were primarily comedies and histories and are regarded as some of the best work produced in these genres. Until about 1608, he wrote mainly tragedies, among them Hamlet, Othello, King Lear, and Macbeth, all considered to be among the finest works in the English language. In the last phase of his life, he wrote tragicomedies (also known as romances) and collaborated with other playwrights.\n\nMany of Shakespeare's plays were published in editions of varying quality and accuracy in his lifetime. However, in 1623, two fellow actors and friends of Shakespeare's, John Heminges and Henry Condell, published a more definitive text known as the First Folio, a posthumous collected edition of Shakespeare's dramatic works that included all but two of his plays. The volume was prefaced with a poem by Ben Jonson, in which Jonson presciently hails Shakespeare in a now-famous quote as \"not of an age, but for all time\".\n\nThroughout the 20th and 21st centuries, Shakespeare's works have been continually adapted and rediscovered by new movements in scholarship and performance. His plays remain popular and are studied, performed, and reinterpreted through various cultural and political contexts around the world.",
"roomName": "Matrix HQ",
"roomAlias": "#matrix:matrix.org",
"roomTopic": "Welcome to Matrix HQ! Here is the rest of the room topic…"
},
{
@ -12,6 +13,7 @@
"mxid": "@benoit:matrix.org",
"message": "Hello!",
"roomName": "Room name very loooooooong with some details",
"roomAlias": "#matrix:matrix.org",
"roomTopic": "Room topic very loooooooong with some details"
},
{
@ -19,6 +21,7 @@
"mxid": "@ganfra:matrix.org",
"message": "How are you?",
"roomName": "Room name very loooooooong with some details",
"roomAlias": "#matrix:matrix.org",
"roomTopic": "Room topic very loooooooong with some details"
},
{
@ -26,6 +29,7 @@
"mxid": "@manu:matrix.org",
"message": "Great weather today!",
"roomName": "Room name very loooooooong with some details",
"roomAlias": "#matrix:matrix.org",
"roomTopic": "Room topic very loooooooong with some details"
},
{
@ -33,6 +37,7 @@
"mxid": "@giom:matrix.org",
"message": "Let's do a picnic",
"roomName": "Room name very loooooooong with some details",
"roomAlias": "#matrix:matrix.org",
"roomTopic": "Room topic very loooooooong with some details"
},
{
@ -40,6 +45,7 @@
"mxid": "@nadonomy:matrix.org",
"message": "Yes, great idea",
"roomName": "Room name very loooooooong with some details",
"roomAlias": "#matrix:matrix.org",
"roomTopic": "Room topic very loooooooong with some details"
}
]

View File

@ -24,6 +24,7 @@ import com.airbnb.epoxy.EpoxyModelClass
import im.vector.riotredesign.R
import im.vector.riotredesign.core.epoxy.VectorEpoxyHolder
import im.vector.riotredesign.core.epoxy.VectorEpoxyModel
import im.vector.riotredesign.core.extensions.setTextOrHide
import im.vector.riotredesign.core.platform.ButtonStateView
import im.vector.riotredesign.features.home.AvatarRenderer

@ -39,6 +40,12 @@ abstract class PublicRoomItem : VectorEpoxyModel<PublicRoomItem.Holder>() {
@EpoxyAttribute
var roomName: String? = null

@EpoxyAttribute
var roomAlias: String? = null

@EpoxyAttribute
var roomTopic: String? = null

@EpoxyAttribute
var nbOfMembers: Int = 0

@ -56,6 +63,8 @@ abstract class PublicRoomItem : VectorEpoxyModel<PublicRoomItem.Holder>() {

AvatarRenderer.render(avatarUrl, roomId!!, roomName, holder.avatarView)
holder.nameView.text = roomName
holder.aliasView.setTextOrHide(roomAlias)
holder.topicView.setTextOrHide(roomTopic)
// TODO Use formatter for big numbers?
holder.counterView.text = nbOfMembers.toString()

@ -85,6 +94,8 @@ abstract class PublicRoomItem : VectorEpoxyModel<PublicRoomItem.Holder>() {

val avatarView by bind<ImageView>(R.id.itemPublicRoomAvatar)
val nameView by bind<TextView>(R.id.itemPublicRoomName)
val aliasView by bind<TextView>(R.id.itemPublicRoomAlias)
val topicView by bind<TextView>(R.id.itemPublicRoomTopic)
val counterView by bind<TextView>(R.id.itemPublicRoomMembersCount)

val buttonState by bind<ButtonStateView>(R.id.itemPublicRoomButtonState)

View File

@ -82,6 +82,8 @@ class PublicRoomsController(private val stringProvider: StringProvider,
roomId(publicRoom.roomId)
avatarUrl(publicRoom.avatarUrl)
roomName(publicRoom.name)
roomAlias(publicRoom.canonicalAlias)
roomTopic(publicRoom.topic)
nbOfMembers(publicRoom.numJoinedMembers)

val joinState = when {

View File

@ -17,6 +17,7 @@
package im.vector.riotredesign.features.roomdirectory

import android.os.Bundle
import android.view.MenuItem
import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
@ -31,7 +32,6 @@ import im.vector.riotredesign.core.error.ErrorFormatter
import im.vector.riotredesign.core.extensions.addFragmentToBackstack
import im.vector.riotredesign.core.platform.VectorBaseFragment
import im.vector.riotredesign.features.roomdirectory.picker.RoomDirectoryPickerFragment
import im.vector.riotredesign.features.roomdirectory.roompreview.RoomPreviewActivity
import io.reactivex.rxkotlin.subscribeBy
import kotlinx.android.synthetic.main.fragment_public_rooms.*
import org.koin.android.ext.android.inject
@ -46,12 +46,20 @@ import java.util.concurrent.TimeUnit
* - When filtering more (when entering new chars), we could filter on result we already have, during the new server request, to avoid empty screen effect
*
* TODO For Nad:
* Display number of rooms?
* Picto size are not correct
* Where I put the room directory picker?
* World Readable badge
* Guest can join badge
* Display number of rooms? -> Not displayed
* Picto size are not correct -> Fixed
* Where I put the room directory picker? -> Menu
* World Readable badge -> not displayed
* Guest can join badge -> not displayed
* Create Room -> Wait for screen
*
*
* Home
* -> FAB on first screen
* -> Counter -> Ok
*
*
* @Benoit: Provide list for event type in last message on home
*/
class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback {

@ -61,6 +69,8 @@ class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback

override fun getLayoutResId() = R.layout.fragment_public_rooms

override fun getMenuRes() = R.menu.menu_room_directory

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

@ -84,10 +94,6 @@ class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback
vectorBaseActivity.notImplemented()
}

publicRoomsChangeDirectory.setOnClickListener {
vectorBaseActivity.addFragmentToBackstack(RoomDirectoryPickerFragment(), R.id.simpleFragmentContainer)
}

viewModel.joinRoomErrorLiveData.observe(this, Observer {
it.getContentIfNotHandled()?.let { throwable ->
Snackbar.make(publicRoomsCoordinator, errorFormatter.toHumanReadable(throwable), Snackbar.LENGTH_SHORT)
@ -96,6 +102,17 @@ class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback
})
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.menu_room_directory_change_protocol -> {
vectorBaseActivity.addFragmentToBackstack(RoomDirectoryPickerFragment(), R.id.simpleFragmentContainer)
true
}
else ->
super.onOptionsItemSelected(item)
}
}

override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
bindScope(getOrCreateScope(RoomDirectoryModule.ROOM_DIRECTORY_SCOPE))
@ -146,8 +163,5 @@ class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback
override fun invalidate() = withState(viewModel) { state ->
// Populate list with Epoxy
publicRoomsController.setData(state)

// Directory name
publicRoomsDirectoryName.text = state.roomDirectoryDisplayName
}
}

View File

@ -61,7 +61,7 @@ class RoomDirectoryPickerFragment : VectorBaseFragment(), RoomDirectoryPickerCon
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.action_add_custom_hs) {
// TODO
vectorBaseActivity.notImplemented()
vectorBaseActivity.notImplemented("Entering custom homeserver")
return true
}


View File

@ -19,88 +19,52 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.google.android.material.appbar.CollapsingToolbarLayout
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
style="@style/VectorToolbarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:expandedTitleGravity="top"
app:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed|snap">
android:background="?attr/colorPrimary"
app:contentInsetStartWithNavigation="0dp"
app:layout_scrollFlags="noScroll"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<LinearLayout
<EditText
android:id="@+id/publicRoomsFilter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="32dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="@dimen/layout_horizontal_margin"
android:layout_marginRight="@dimen/layout_horizontal_margin"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_search_edit_text"
android:drawableStart="@drawable/ic_search_white"
android:drawableLeft="@drawable/ic_search_white"
android:drawablePadding="8dp"
android:drawableTint="#9fa9ba"
android:hint="@string/home_filter_placeholder_rooms"
android:lines="1"
android:paddingLeft="8dp"
android:paddingRight="8dp" />

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</androidx.appcompat.widget.Toolbar>

<EditText
android:id="@+id/publicRoomsFilter"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="@dimen/layout_horizontal_margin"
android:layout_marginRight="@dimen/layout_horizontal_margin"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_search_edit_text"
android:drawableStart="@drawable/ic_search_white"
android:drawableLeft="@drawable/ic_search_white"
android:drawablePadding="8dp"
android:drawableTint="#9fa9ba"
android:hint="@string/home_filter_placeholder_rooms"
android:lines="1"
android:paddingLeft="8dp"
android:paddingRight="8dp" />

</androidx.appcompat.widget.Toolbar>

<Button
android:id="@+id/publicRoomsCreateNewRoom"
style="@style/VectorButtonStyleFlat"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:drawableStart="@drawable/ic_plus_circle"
android:drawableLeft="@drawable/ic_plus_circle"
android:drawablePadding="13dp"
android:text="@string/create_new_room" />

<!-- TODO Layout with Nad -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/layout_horizontal_margin"
android:layout_marginRight="@dimen/layout_horizontal_margin"
android:layout_marginBottom="8dp">

<TextView
android:id="@+id/publicRoomsDirectoryName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textColor="#FFFFFF"
tools:text="RoomDirectoryName" />

<Button
android:id="@+id/publicRoomsChangeDirectory"
style="@style/VectorButtonStyleFlat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="@string/action_change" />


</RelativeLayout>

</LinearLayout>

</com.google.android.material.appbar.CollapsingToolbarLayout>
<Button
android:id="@+id/publicRoomsCreateNewRoom"
style="@style/VectorButtonStyleFlat"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="8dp"
android:drawableStart="@drawable/ic_plus_circle"
android:drawableLeft="@drawable/ic_plus_circle"
android:drawablePadding="13dp"
android:text="@string/create_new_room"
app:layout_scrollFlags="scroll|enterAlways|snap" />

</com.google.android.material.appbar.AppBarLayout>


View File

@ -8,16 +8,15 @@
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground">
android:foreground="?attr/selectableItemBackground"
android:minHeight="97dp">

<ImageView
android:id="@+id/itemPublicRoomAvatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toTopOf="@+id/itemPublicRoomBottomSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
@ -27,48 +26,89 @@
android:id="@+id/itemPublicRoomName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="17dp"
android:layout_marginLeft="17dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="16dp"
android:ellipsize="end"
android:maxLines="2"
android:textColor="#2E2F3E"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/itemPublicRoomBottomSeparator"
app:layout_constraintEnd_toStartOf="@id/itemPublicRoomMembersCount"
app:layout_constraintBottom_toTopOf="@+id/itemPublicRoomMembersCount"
app:layout_constraintEnd_toStartOf="@+id/itemPublicRoomButtonState"
app:layout_constraintStart_toEndOf="@id/itemPublicRoomAvatar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="@sample/matrix.json/data/roomName" />

<TextView
android:id="@+id/itemPublicRoomMembersCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:drawableStart="@drawable/ic_user"
android:drawableLeft="@drawable/ic_user"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:minWidth="40dp"
android:minWidth="56dp"
android:textColor="#7E899C"
android:textSize="15sp"
app:layout_constraintBottom_toTopOf="@+id/itemPublicRoomBottomSeparator"
app:layout_constraintEnd_toStartOf="@id/itemPublicRoomButtonState"
app:layout_constraintStart_toEndOf="@id/itemPublicRoomName"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/itemPublicRoomTopic"
app:layout_constraintStart_toStartOf="@+id/itemPublicRoomName"
app:layout_constraintTop_toBottomOf="@+id/itemPublicRoomName"
tools:text="148" />

<TextView
android:id="@+id/itemPublicRoomAlias"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:maxLines="1"
android:minWidth="40dp"
android:singleLine="true"
android:textColor="#7E899C"
android:textSize="15sp"
app:layout_constraintBaseline_toBaselineOf="@+id/itemPublicRoomMembersCount"
app:layout_constraintEnd_toStartOf="@+id/itemPublicRoomButtonState"
app:layout_constraintStart_toEndOf="@+id/itemPublicRoomMembersCount"
tools:text="@sample/matrix.json/data/roomAlias" />

<TextView
android:id="@+id/itemPublicRoomTopic"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:maxLines="1"
android:singleLine="true"
android:textColor="#2E2F3E"
android:textSize="15sp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/itemPublicRoomBottomSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/itemPublicRoomName"
app:layout_constraintTop_toBottomOf="@+id/itemPublicRoomMembersCount"
tools:text="@sample/matrix.json/data/roomTopic"
tools:visibility="visible" />

<im.vector.riotredesign.core.platform.ButtonStateView
android:id="@+id/itemPublicRoomButtonState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:bsv_button_text="@string/join"
app:bsv_loaded_image_src="@drawable/ic_tick"
app:bsv_use_flat_button="true"
app:layout_constraintBottom_toTopOf="@+id/itemPublicRoomBottomSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />


View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/menu_room_directory_change_protocol"
android:title="@string/change_room_directory_network"
app:showAsAction="never" />

</menu>

View File

@ -31,6 +31,7 @@
<string name="error_no_network">No network. Please check your Internet connection.</string>

<string name="action_change">"Change"</string>
<string name="change_room_directory_network">"Change network"</string>
<string name="please_wait">"Please wait…"</string>
<string name="group_all_communities">"All Communities"</string>