forked from GitHub-Mirror/riotX-android
Plug screens together
This commit is contained in:
parent
02a81dd9e1
commit
dde94c0d0f
@ -296,8 +296,8 @@ abstract class VectorBaseActivity : BaseMvRxActivity() {
|
||||
* Temporary method
|
||||
* ========================================================================================== */
|
||||
|
||||
fun notImplemented() {
|
||||
toast(getString(R.string.not_implemented))
|
||||
fun notImplemented(message: String = "") {
|
||||
toast(getString(R.string.not_implemented) + message.takeIf { message.isNotBlank() }.run { ": $message" })
|
||||
}
|
||||
|
||||
}
|
@ -123,12 +123,6 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
|
||||
SignOutUiWorker(this).perform(Matrix.getInstance().currentSession!!)
|
||||
return true
|
||||
}
|
||||
// TODO Temporary code here to create a room
|
||||
R.id.tmp_menu_create_room -> {
|
||||
// Start Activity for now
|
||||
startActivity(Intent(this, RoomDirectoryActivity::class.java))
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
|
@ -24,6 +24,7 @@ import com.airbnb.mvrx.ViewModelContext
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.group.model.GroupSummary
|
||||
import im.vector.matrix.rx.rx
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.platform.VectorViewModel
|
||||
import im.vector.riotredesign.core.resources.StringProvider
|
||||
import im.vector.riotredesign.core.utils.LiveEvent
|
||||
@ -88,8 +89,7 @@ class GroupListViewModel(initialState: GroupListViewState,
|
||||
val myUser = session.getUser(session.sessionParams.credentials.userId)
|
||||
val allCommunityGroup = GroupSummary(
|
||||
groupId = ALL_COMMUNITIES_GROUP_ID,
|
||||
// TODO i18n
|
||||
displayName = "All Communities",
|
||||
displayName = stringProvider.getString(R.string.group_all_communities),
|
||||
avatarUrl = myUser?.avatarUrl ?: "")
|
||||
listOf(allCommunityGroup) + it
|
||||
}
|
||||
|
@ -16,15 +16,12 @@
|
||||
|
||||
package im.vector.riotredesign.features.home.room.list
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.airbnb.mvrx.Fail
|
||||
import com.airbnb.mvrx.Incomplete
|
||||
import com.airbnb.mvrx.Success
|
||||
import com.airbnb.mvrx.args
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.*
|
||||
import im.vector.matrix.android.api.failure.Failure
|
||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||
import im.vector.riotredesign.R
|
||||
@ -32,13 +29,11 @@ import im.vector.riotredesign.core.epoxy.LayoutManagerStateRestorer
|
||||
import im.vector.riotredesign.core.extensions.observeEvent
|
||||
import im.vector.riotredesign.core.platform.StateView
|
||||
import im.vector.riotredesign.core.platform.VectorBaseFragment
|
||||
import im.vector.riotredesign.features.home.HomeModule
|
||||
import im.vector.riotredesign.features.home.HomeNavigator
|
||||
import im.vector.riotredesign.features.roomdirectory.RoomDirectoryActivity
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import kotlinx.android.synthetic.main.fragment_room_list.*
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.koin.android.scope.ext.android.bindScope
|
||||
import org.koin.android.scope.ext.android.getOrCreateScope
|
||||
|
||||
@Parcelize
|
||||
data class RoomListParams(
|
||||
@ -82,7 +77,8 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback {
|
||||
private fun setupCreateRoomButton() {
|
||||
createRoomButton.setImageResource(R.drawable.ic_add_white)
|
||||
createRoomButton.setOnClickListener {
|
||||
vectorBaseActivity.notImplemented()
|
||||
// Start Activity for now
|
||||
startActivity(Intent(requireActivity(), RoomDirectoryActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,23 +83,27 @@ class PublicRoomsController(private val stringProvider: StringProvider,
|
||||
avatarUrl(publicRoom.avatarUrl)
|
||||
roomName(publicRoom.name)
|
||||
nbOfMembers(publicRoom.numJoinedMembers)
|
||||
when {
|
||||
viewState.joinedRoomsIds.contains(publicRoom.roomId) -> joinState(PublicRoomItem.JoinState.JOINED)
|
||||
viewState.joiningRoomsIds.contains(publicRoom.roomId) -> joinState(PublicRoomItem.JoinState.JOINING)
|
||||
viewState.joiningErrorRoomsIds.contains(publicRoom.roomId) -> joinState(PublicRoomItem.JoinState.JOINING_ERROR)
|
||||
else -> joinState(PublicRoomItem.JoinState.NOT_JOINED)
|
||||
|
||||
val joinState = when {
|
||||
viewState.joinedRoomsIds.contains(publicRoom.roomId) -> PublicRoomItem.JoinState.JOINED
|
||||
viewState.joiningRoomsIds.contains(publicRoom.roomId) -> PublicRoomItem.JoinState.JOINING
|
||||
viewState.joiningErrorRoomsIds.contains(publicRoom.roomId) -> PublicRoomItem.JoinState.JOINING_ERROR
|
||||
else -> PublicRoomItem.JoinState.NOT_JOINED
|
||||
}
|
||||
|
||||
joinState(joinState)
|
||||
|
||||
joinListener {
|
||||
callback?.onPublicRoomJoin(publicRoom)
|
||||
}
|
||||
globalListener {
|
||||
callback?.onPublicRoomClicked(publicRoom)
|
||||
callback?.onPublicRoomClicked(publicRoom, joinState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Callback {
|
||||
fun onPublicRoomClicked(publicRoom: PublicRoom)
|
||||
fun onPublicRoomClicked(publicRoom: PublicRoom, joinState: PublicRoomItem.JoinState)
|
||||
fun onPublicRoomJoin(publicRoom: PublicRoom)
|
||||
fun loadMore()
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ import im.vector.riotredesign.R
|
||||
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.home.room.detail.RoomDetailActivity
|
||||
import im.vector.riotredesign.features.home.room.detail.RoomDetailArgs
|
||||
import im.vector.riotredesign.features.roomdirectory.picker.RoomDirectoryPickerFragment
|
||||
import io.reactivex.rxkotlin.subscribeBy
|
||||
import kotlinx.android.synthetic.main.fragment_public_rooms.*
|
||||
@ -114,9 +116,25 @@ class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback
|
||||
publicRoomsList.setController(publicRoomsController)
|
||||
}
|
||||
|
||||
override fun onPublicRoomClicked(publicRoom: PublicRoom) {
|
||||
override fun onPublicRoomClicked(publicRoom: PublicRoom, joinState: PublicRoomItem.JoinState) {
|
||||
Timber.v("PublicRoomClicked: $publicRoom")
|
||||
vectorBaseActivity.notImplemented()
|
||||
|
||||
when (joinState) {
|
||||
PublicRoomItem.JoinState.JOINED -> {
|
||||
val args = RoomDetailArgs(publicRoom.roomId)
|
||||
val roomDetailIntent = RoomDetailActivity.newIntent(requireActivity(), args)
|
||||
requireActivity().startActivity(roomDetailIntent)
|
||||
}
|
||||
PublicRoomItem.JoinState.NOT_JOINED,
|
||||
PublicRoomItem.JoinState.JOINING_ERROR -> {
|
||||
// ROOM PREVIEW
|
||||
vectorBaseActivity.notImplemented("Opening room preview")
|
||||
}
|
||||
else -> {
|
||||
Snackbar.make(publicRoomsCoordinator, getString(R.string.please_wait), Snackbar.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPublicRoomJoin(publicRoom: PublicRoom) {
|
||||
|
@ -88,7 +88,7 @@ class RoomDirectoryPickerController(private val stringProvider: StringProvider,
|
||||
}
|
||||
|
||||
interface Callback {
|
||||
fun onRoomDirectoryClicked(roomDirectory: RoomDirectoryData)
|
||||
fun onRoomDirectoryClicked(roomDirectoryData: RoomDirectoryData)
|
||||
fun retry()
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:labelVisibilityMode="unlabeled"
|
||||
app:itemIconTint="@android:color/white"
|
||||
app:itemTextColor="@color/home_bottom_nav_view_tint"
|
||||
app:labelVisibilityMode="unlabeled"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -149,7 +149,6 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/roomToolbar"
|
||||
app:layout_constraintVertical_bias="1.0"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -40,7 +40,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/inviteNameView"
|
||||
tools:text="\@matthew:matrix.org" />
|
||||
tools:text=" @matthew:matrix.org" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/inviteLabelView"
|
||||
@ -55,11 +55,13 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/inviteRejectView"
|
||||
style="@style/VectorButtonStyleFlat"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:minWidth="120dp"
|
||||
android:text="@string/reject"
|
||||
app:layout_constraintEnd_toStartOf="@+id/inviteAcceptView"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
@ -68,10 +70,12 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/inviteAcceptView"
|
||||
style="@style/VectorButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:minWidth="120dp"
|
||||
android:text="@string/accept"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
|
@ -6,9 +6,4 @@
|
||||
android:icon="@drawable/ic_material_exit_to_app"
|
||||
android:title="@string/action_sign_out" />
|
||||
|
||||
<!-- TODO Temporary code -->
|
||||
<item
|
||||
android:id="@+id/tmp_menu_create_room"
|
||||
android:title="@string/room_recents_create_room" />
|
||||
|
||||
</menu>
|
@ -27,5 +27,7 @@
|
||||
<string name="error_no_network">No network. Please check your Internet connection.</string>
|
||||
|
||||
<string name="action_change">"Change"</string>
|
||||
<string name="please_wait">"Please wait…"</string>
|
||||
<string name="group_all_communities">"All Communities"</string>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user