forked from GitHub-Mirror/riotX-android
Public rooms little rework
This commit is contained in:
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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" />
|
||||
|
||||
|
10
vector/src/main/res/menu/menu_room_directory.xml
Normal file
10
vector/src/main/res/menu/menu_room_directory.xml
Normal 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>
|
@ -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>
|
||||
|
||||
|
Reference in New Issue
Block a user