Cleanup
This commit is contained in:
parent
1dacfa6744
commit
0a79b8b315
|
@ -15,22 +15,16 @@
|
||||||
*/
|
*/
|
||||||
package im.vector.riotx.features.home.room.detail.timeline.action
|
package im.vector.riotx.features.home.room.detail.timeline.action
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
import com.airbnb.mvrx.withState
|
import com.airbnb.mvrx.withState
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
|
||||||
import im.vector.riotx.EmojiCompatFontProvider
|
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.di.ScreenComponent
|
import im.vector.riotx.core.di.ScreenComponent
|
||||||
import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment
|
import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment
|
||||||
import im.vector.riotx.features.home.AvatarRenderer
|
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData
|
import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData
|
||||||
import kotlinx.android.synthetic.main.bottom_sheet_generic_recycler_epoxy.*
|
import kotlinx.android.synthetic.main.bottom_sheet_generic_recycler_epoxy.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -40,12 +34,10 @@ import javax.inject.Inject
|
||||||
*/
|
*/
|
||||||
class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), MessageActionsEpoxyController.MessageActionsEpoxyControllerListener {
|
class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), MessageActionsEpoxyController.MessageActionsEpoxyControllerListener {
|
||||||
@Inject lateinit var messageActionViewModelFactory: MessageActionsViewModel.Factory
|
@Inject lateinit var messageActionViewModelFactory: MessageActionsViewModel.Factory
|
||||||
@Inject lateinit var avatarRenderer: AvatarRenderer
|
@Inject lateinit var messageActionsEpoxyController: MessageActionsEpoxyController
|
||||||
@Inject lateinit var fontProvider: EmojiCompatFontProvider
|
|
||||||
|
|
||||||
private val viewModel: MessageActionsViewModel by fragmentViewModel(MessageActionsViewModel::class)
|
private val viewModel: MessageActionsViewModel by fragmentViewModel(MessageActionsViewModel::class)
|
||||||
|
|
||||||
private lateinit var messageActionsEpoxyController: MessageActionsEpoxyController
|
|
||||||
private lateinit var actionHandlerModel: ActionsHandler
|
private lateinit var actionHandlerModel: ActionsHandler
|
||||||
|
|
||||||
override fun injectWith(screenComponent: ScreenComponent) {
|
override fun injectWith(screenComponent: ScreenComponent) {
|
||||||
|
@ -60,7 +52,6 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
actionHandlerModel = ViewModelProviders.of(requireActivity()).get(ActionsHandler::class.java)
|
actionHandlerModel = ViewModelProviders.of(requireActivity()).get(ActionsHandler::class.java)
|
||||||
|
|
||||||
messageActionsEpoxyController = MessageActionsEpoxyController(requireContext(), avatarRenderer, fontProvider)
|
|
||||||
bottomSheetEpoxyRecyclerView.setController(messageActionsEpoxyController)
|
bottomSheetEpoxyRecyclerView.setController(messageActionsEpoxyController)
|
||||||
messageActionsEpoxyController.listener = this
|
messageActionsEpoxyController.listener = this
|
||||||
}
|
}
|
||||||
|
@ -70,20 +61,6 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
val dialog = super.onCreateDialog(savedInstanceState)
|
|
||||||
// We want to force the bottom sheet initial state to expanded
|
|
||||||
(dialog as? BottomSheetDialog)?.let { bottomSheetDialog ->
|
|
||||||
bottomSheetDialog.setOnShowListener { dialog ->
|
|
||||||
val d = dialog as BottomSheetDialog
|
|
||||||
(d.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet) as? FrameLayout)?.let {
|
|
||||||
BottomSheetBehavior.from(it).state = BottomSheetBehavior.STATE_COLLAPSED
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dialog
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun invalidate() = withState(viewModel) {
|
override fun invalidate() = withState(viewModel) {
|
||||||
messageActionsEpoxyController.setData(it)
|
messageActionsEpoxyController.setData(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,18 +15,19 @@
|
||||||
*/
|
*/
|
||||||
package im.vector.riotx.features.home.room.detail.timeline.action
|
package im.vector.riotx.features.home.room.detail.timeline.action
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.airbnb.epoxy.TypedEpoxyController
|
import com.airbnb.epoxy.TypedEpoxyController
|
||||||
import com.airbnb.mvrx.Success
|
import com.airbnb.mvrx.Success
|
||||||
import im.vector.riotx.EmojiCompatFontProvider
|
import im.vector.riotx.EmojiCompatFontProvider
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
|
import im.vector.riotx.core.resources.StringProvider
|
||||||
import im.vector.riotx.features.home.AvatarRenderer
|
import im.vector.riotx.features.home.AvatarRenderer
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Epoxy controller for message action list
|
* Epoxy controller for message action list
|
||||||
*/
|
*/
|
||||||
class MessageActionsEpoxyController(private val context: Context,
|
class MessageActionsEpoxyController @Inject constructor(private val stringProvider: StringProvider,
|
||||||
private val avatarRenderer: AvatarRenderer,
|
private val avatarRenderer: AvatarRenderer,
|
||||||
private val fontProvider: EmojiCompatFontProvider) : TypedEpoxyController<MessageActionState>() {
|
private val fontProvider: EmojiCompatFontProvider) : TypedEpoxyController<MessageActionState>() {
|
||||||
|
|
||||||
|
@ -51,13 +52,13 @@ class MessageActionsEpoxyController(private val context: Context,
|
||||||
bottomSheetItemSendState {
|
bottomSheetItemSendState {
|
||||||
id("send_state")
|
id("send_state")
|
||||||
showProgress(true)
|
showProgress(true)
|
||||||
text(context.getString(R.string.event_status_sending_message))
|
text(stringProvider.getString(R.string.event_status_sending_message))
|
||||||
}
|
}
|
||||||
} else if (state.informationData.sendState.hasFailed()) {
|
} else if (state.informationData.sendState.hasFailed()) {
|
||||||
bottomSheetItemSendState {
|
bottomSheetItemSendState {
|
||||||
id("send_state")
|
id("send_state")
|
||||||
showProgress(false)
|
showProgress(false)
|
||||||
text(context.getString(R.string.unable_to_send_message))
|
text(stringProvider.getString(R.string.unable_to_send_message))
|
||||||
drawableStart(R.drawable.ic_warning_small)
|
drawableStart(R.drawable.ic_warning_small)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +74,7 @@ class MessageActionsEpoxyController(private val context: Context,
|
||||||
id("quick_reaction")
|
id("quick_reaction")
|
||||||
fontProvider(fontProvider)
|
fontProvider(fontProvider)
|
||||||
texts(state.quickStates()?.map { it.reaction }.orEmpty())
|
texts(state.quickStates()?.map { it.reaction }.orEmpty())
|
||||||
selecteds(state.quickStates()?.map { it.isSelected }.orEmpty())
|
selecteds(state.quickStates.invoke().map { it.isSelected })
|
||||||
listener(object : BottomSheetItemQuickReactions.Listener {
|
listener(object : BottomSheetItemQuickReactions.Listener {
|
||||||
override fun didSelect(emoji: String, selected: Boolean) {
|
override fun didSelect(emoji: String, selected: Boolean) {
|
||||||
listener?.didSelectMenuAction(SimpleAction.QuickReact(state.eventId, emoji, selected))
|
listener?.didSelectMenuAction(SimpleAction.QuickReact(state.eventId, emoji, selected))
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:fadeScrollbars="false"
|
android:fadeScrollbars="false"
|
||||||
android:orientation="vertical"
|
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
tools:itemCount="15"
|
tools:itemCount="15"
|
||||||
tools:listitem="@layout/item_simple_reaction_info" />
|
tools:listitem="@layout/item_simple_reaction_info" />
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:fadeScrollbars="false"
|
android:fadeScrollbars="false"
|
||||||
android:orientation="vertical"
|
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
tools:itemCount="5"
|
tools:itemCount="5"
|
||||||
tools:listitem="@layout/item_bottom_sheet_action" />
|
tools:listitem="@layout/item_bottom_sheet_action" />
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
android:paddingLeft="@dimen/layout_horizontal_margin"
|
android:paddingLeft="@dimen/layout_horizontal_margin"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:paddingRight="@dimen/layout_horizontal_margin"
|
android:paddingRight="@dimen/layout_horizontal_margin"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp">
|
||||||
tools:layout_height="50dp">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/action_icon"
|
android:id="@+id/action_icon"
|
||||||
|
|
Loading…
Reference in New Issue