mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Clean code and update CHANGES
This commit is contained in:
parent
d3415d345f
commit
9671a77e5d
42 changed files with 7 additions and 80 deletions
|
@ -3,6 +3,8 @@ Changes in RiotX 0.13.0 (2020-XX-XX)
|
|||
|
||||
Features ✨:
|
||||
- Send and render typing events (#564)
|
||||
- Create Room Profile screen (#54)
|
||||
- Create Room Member Profile screen (#59)
|
||||
|
||||
Improvements 🙌:
|
||||
- Render events m.room.encryption and m.room.guest_access in the timeline
|
||||
|
|
|
@ -98,7 +98,6 @@ class RxSession(private val session: Session) {
|
|||
fun getProfileInfo(userId: String): Single<JsonDict> = singleBuilder {
|
||||
session.getProfile(userId, it)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun Session.rx(): RxSession {
|
||||
|
|
|
@ -22,7 +22,6 @@ import im.vector.matrix.android.api.util.Cancelable
|
|||
import im.vector.matrix.android.api.util.JsonDict
|
||||
import im.vector.matrix.android.api.util.Optional
|
||||
|
||||
|
||||
interface ProfileService {
|
||||
|
||||
companion object Constants {
|
||||
|
@ -35,5 +34,4 @@ interface ProfileService {
|
|||
fun getAvatarUrl(userId: String, matrixCallback: MatrixCallback<Optional<String>>): Cancelable
|
||||
|
||||
fun getProfile(userId: String, matrixCallback: MatrixCallback<JsonDict>): Cancelable
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package im.vector.matrix.android.api.session.room.model
|
|||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
import im.vector.matrix.android.api.session.room.powerlevers.PowerLevelsConstants
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,5 +22,4 @@ object PowerLevelsConstants {
|
|||
const val DEFAULT_ROOM_ADMIN_LEVEL = 100
|
||||
const val DEFAULT_ROOM_MODERATOR_LEVEL = 50
|
||||
const val DEFAULT_ROOM_USER_LEVEL = 0
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ class PowerLevelsHelper(private val powerLevelsContent: PowerLevelsContent) {
|
|||
} else false
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the notification level for a dedicated key.
|
||||
*
|
||||
|
|
|
@ -73,5 +73,4 @@ internal class DefaultProfileService @Inject constructor(private val taskExecuto
|
|||
}
|
||||
.executeBy(taskExecutor)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,5 +38,3 @@ internal class DefaultGetProfileInfoTask @Inject constructor(private val profile
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,12 +26,11 @@ import retrofit2.http.Path
|
|||
interface ProfileAPI {
|
||||
|
||||
/**
|
||||
* Get the combined profile information for this user. This API may be used to fetch the user's own profile information or other users; either locally or on remote homeservers. This API may return keys which are not limited to displayname or avatar_url.
|
||||
*
|
||||
* Get the combined profile information for this user.
|
||||
* This API may be used to fetch the user's own profile information or other users; either locally or on remote homeservers.
|
||||
* This API may return keys which are not limited to displayname or avatar_url.
|
||||
* @param userId the user id to fetch profile info
|
||||
*/
|
||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}")
|
||||
fun getProfile(@Path("userId") roomId: String): Call<JsonDict>
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -95,7 +95,6 @@ internal class DefaultMembershipService @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
private fun roomMembersQuery(realm: Realm, queryParams: RoomMemberQueryParams): RealmQuery<RoomMemberSummaryEntity> {
|
||||
return RoomMemberHelper(realm, roomId).queryRoomMembersEvent()
|
||||
.process(RoomMemberSummaryEntityFields.USER_ID, queryParams.userId)
|
||||
|
|
|
@ -57,7 +57,7 @@ internal class DefaultStateService @AssistedInject constructor(@Assisted private
|
|||
|
||||
override fun getStateEventLive(eventType: String): LiveData<Optional<Event>> {
|
||||
val liveData = monarchy.findAllMappedWithChanges(
|
||||
{ realm -> EventEntity.where(realm, roomId, eventType).descending()},
|
||||
{ realm -> EventEntity.where(realm, roomId, eventType).descending() },
|
||||
{ it.asDomain() }
|
||||
)
|
||||
return Transformations.map(liveData) { results ->
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.google.android.material.appbar.AppBarLayout
|
|||
import com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
abstract class AppBarStateChangeListener : OnOffsetChangedListener {
|
||||
|
||||
enum class State {
|
||||
|
|
|
@ -218,6 +218,4 @@ class PercentViewBehavior<V : View>(context: Context, attrs: AttributeSet) : Coo
|
|||
|
||||
child.requestLayout()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -291,5 +291,4 @@ interface FragmentModule {
|
|||
@IntoMap
|
||||
@FragmentKey(SoftLogoutFragment::class)
|
||||
fun bindSoftLogoutFragment(fragment: SoftLogoutFragment): Fragment
|
||||
|
||||
}
|
||||
|
|
|
@ -16,13 +16,11 @@
|
|||
|
||||
package im.vector.riotx.core.epoxy.profiles
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.ImageViewCompat
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.riotx.R
|
||||
|
@ -67,12 +65,10 @@ abstract class ProfileItemAction : VectorEpoxyModel<ProfileItemAction.Holder>()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val icon by bind<ImageView>(R.id.actionIcon)
|
||||
val title by bind<TextView>(R.id.actionTitle)
|
||||
val subtitle by bind<TextView>(R.id.actionSubtitle)
|
||||
val editable by bind<ImageView>(R.id.actionEditable)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ fun EpoxyController.buildProfileAction(
|
|||
divider: Boolean = true,
|
||||
action: () -> Unit
|
||||
) {
|
||||
|
||||
profileItemAction {
|
||||
iconRes(icon)
|
||||
id("action_$id")
|
||||
|
|
|
@ -37,7 +37,4 @@ abstract class ProfileItemSection: VectorEpoxyModel<ProfileItemSection.Holder>()
|
|||
class Holder : VectorEpoxyHolder() {
|
||||
val sectionView by bind<TextView>(R.id.itemProfileSectionView)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ abstract class VectorBaseFragment : BaseMvRxFragment(), HasScreenInjector {
|
|||
|
||||
private var progress: ProgressDialog? = null
|
||||
|
||||
|
||||
/* ==========================================================================================
|
||||
* View model
|
||||
* ========================================================================================== */
|
||||
|
@ -192,7 +191,7 @@ abstract class VectorBaseFragment : BaseMvRxFragment(), HasScreenInjector {
|
|||
}
|
||||
}
|
||||
|
||||
protected fun dismissLoadingDialog(){
|
||||
protected fun dismissLoadingDialog() {
|
||||
progress?.dismiss()
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import com.jakewharton.rxrelay2.BehaviorRelay
|
|||
import com.jakewharton.rxrelay2.PublishRelay
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
interface DataSource<T> {
|
||||
fun observe(): Observable<T>
|
||||
|
|
|
@ -456,7 +456,6 @@ class RoomDetailFragment @Inject constructor(
|
|||
composerLayout.composerRelatedMessageActionIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), iconRes))
|
||||
composerLayout.sendButton.setContentDescription(getString(descriptionRes))
|
||||
|
||||
|
||||
avatarRenderer.render(
|
||||
MatrixItem.UserItem(event.root.senderId
|
||||
?: "", event.getDisambiguatedDisplayName(), event.senderAvatar),
|
||||
|
|
|
@ -20,7 +20,6 @@ import com.airbnb.mvrx.Async
|
|||
import com.airbnb.mvrx.MvRxState
|
||||
import com.airbnb.mvrx.Uninitialized
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.api.session.room.model.PowerLevelsContent
|
||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||
import im.vector.matrix.android.api.session.sync.SyncState
|
||||
|
|
|
@ -19,9 +19,6 @@ import android.view.View
|
|||
import com.airbnb.epoxy.TypedEpoxyController
|
||||
import im.vector.matrix.android.api.session.room.notification.RoomNotificationState
|
||||
import im.vector.matrix.android.api.util.toMatrixItem
|
||||
import im.vector.riotx.core.epoxy.DividerItem_
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.BottomSheetRoomPreviewItem
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.BottomSheetRoomPreviewItem_
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetActionItem
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetRoomPreviewItem
|
||||
import im.vector.riotx.core.epoxy.dividerItem
|
||||
|
|
|
@ -141,5 +141,4 @@ class DefaultNavigator @Inject constructor(
|
|||
override fun openRoomProfile(context: Context, roomId: String) {
|
||||
context.startActivity(RoomProfileActivity.newIntent(context, roomId))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,5 +53,4 @@ interface Navigator {
|
|||
fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean = false)
|
||||
|
||||
fun openRoomProfile(context: Context, roomId: String)
|
||||
|
||||
}
|
||||
|
|
|
@ -115,6 +115,4 @@ interface NavigationInterceptor {
|
|||
fun navToMemberProfile(userId: String): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,5 +23,4 @@ sealed class RoomMemberProfileAction : VectorViewModelAction {
|
|||
|
||||
object RetryFetchingInfo: RoomMemberProfileAction()
|
||||
object IgnoreUser: RoomMemberProfileAction()
|
||||
|
||||
}
|
||||
|
|
|
@ -51,5 +51,4 @@ class RoomMemberProfileActivity : VectorBaseActivity(), ToolbarConfigurable {
|
|||
override fun configure(toolbar: Toolbar) {
|
||||
configureToolbar(toolbar)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -112,6 +112,4 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider
|
|||
stringProvider.getString(R.string.ignore)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -85,7 +85,6 @@ class RoomMemberProfileFragment @Inject constructor(
|
|||
}
|
||||
}
|
||||
.disposeOnDestroyView()
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -95,7 +94,6 @@ class RoomMemberProfileFragment @Inject constructor(
|
|||
super.onDestroyView()
|
||||
}
|
||||
|
||||
|
||||
override fun invalidate() = withState(viewModel) { state ->
|
||||
when (val asyncUserMatrixItem = state.userMatrixItem) {
|
||||
is Incomplete -> {
|
||||
|
@ -141,6 +139,4 @@ class RoomMemberProfileFragment @Inject constructor(
|
|||
override fun onMentionClicked() {
|
||||
vectorBaseActivity.notImplemented("Mention")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,5 +23,4 @@ sealed class RoomMemberProfileViewEvents {
|
|||
data class Loading(val message: CharSequence) : RoomMemberProfileViewEvents()
|
||||
object OnIgnoreActionSuccess : RoomMemberProfileViewEvents()
|
||||
data class Failure(val throwable: Throwable) : RoomMemberProfileViewEvents()
|
||||
|
||||
}
|
||||
|
|
|
@ -195,5 +195,4 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v
|
|||
session.ignoreUserIds(listOf(initialState.userId), ignoreActionCallback)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,6 @@ package im.vector.riotx.features.roommemberprofile
|
|||
import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.MvRxState
|
||||
import com.airbnb.mvrx.Uninitialized
|
||||
import im.vector.matrix.android.api.session.room.model.PowerLevelsContent
|
||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||
import im.vector.matrix.android.api.util.JsonDict
|
||||
import im.vector.matrix.android.api.util.MatrixItem
|
||||
|
||||
data class RoomMemberProfileViewState(
|
||||
|
@ -37,6 +34,4 @@ data class RoomMemberProfileViewState(
|
|||
) : MvRxState {
|
||||
|
||||
constructor(args: RoomMemberProfileArgs) : this(roomId = args.roomId, userId = args.userId)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package im.vector.riotx.features.roomprofile
|
|||
|
||||
import im.vector.matrix.android.api.session.room.notification.RoomNotificationState
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
import im.vector.riotx.features.home.room.list.RoomListAction
|
||||
|
||||
sealed class RoomProfileAction: VectorViewModelAction {
|
||||
object LeaveRoom: RoomProfileAction()
|
||||
|
|
|
@ -79,5 +79,4 @@ class RoomProfileActivity : VectorBaseActivity(), ToolbarConfigurable {
|
|||
override fun configure(toolbar: Toolbar) {
|
||||
configureToolbar(toolbar)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,16 +17,10 @@
|
|||
|
||||
package im.vector.riotx.features.roomprofile
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import com.airbnb.epoxy.TypedEpoxyController
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.epoxy.DividerItem_
|
||||
import im.vector.riotx.core.epoxy.dividerItem
|
||||
import im.vector.riotx.core.epoxy.profiles.buildProfileAction
|
||||
import im.vector.riotx.core.epoxy.profiles.buildProfileSection
|
||||
import im.vector.riotx.core.epoxy.profiles.profileItemAction
|
||||
import im.vector.riotx.core.epoxy.profiles.profileItemSection
|
||||
import im.vector.riotx.core.resources.StringProvider
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -101,7 +95,4 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri
|
|||
action = { callback?.onLeaveRoomClicked() }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ class RoomProfileFragment @Inject constructor(
|
|||
|
||||
private lateinit var appBarStateChangeListener: AppBarStateChangeListener
|
||||
|
||||
|
||||
override fun getLayoutResId() = R.layout.fragment_matrix_profile
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
|
|
@ -22,5 +22,4 @@ sealed class RoomProfileViewEvents {
|
|||
data class Loading(val message: CharSequence): RoomProfileViewEvents()
|
||||
object OnLeaveRoomSuccess: RoomProfileViewEvents()
|
||||
data class Failure(val throwable: Throwable) : RoomProfileViewEvents()
|
||||
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@ import im.vector.riotx.core.platform.VectorViewModel
|
|||
import im.vector.riotx.core.resources.StringProvider
|
||||
import im.vector.riotx.core.utils.DataSource
|
||||
import im.vector.riotx.core.utils.PublishDataSource
|
||||
import im.vector.riotx.features.home.room.list.RoomListAction
|
||||
import im.vector.riotx.features.home.room.list.RoomListViewEvents
|
||||
|
||||
class RoomProfileViewModel @AssistedInject constructor(@Assisted initialState: RoomProfileViewState,
|
||||
private val stringProvider: StringProvider,
|
||||
|
@ -98,5 +96,4 @@ class RoomProfileViewModel @AssistedInject constructor(@Assisted initialState: R
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,4 @@ class RoomMemberListController @Inject constructor(private val avatarRenderer: A
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import im.vector.riotx.features.roomprofile.RoomProfileArgs
|
|||
import kotlinx.android.synthetic.main.fragment_room_member_list.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
class RoomMemberListFragment @Inject constructor(
|
||||
val viewModelFactory: RoomMemberListViewModel.Factory,
|
||||
private val roomMemberListController: RoomMemberListController,
|
||||
|
@ -42,7 +41,6 @@ class RoomMemberListFragment @Inject constructor(
|
|||
private val viewModel: RoomMemberListViewModel by fragmentViewModel()
|
||||
private val roomProfileArgs: RoomProfileArgs by args()
|
||||
|
||||
|
||||
override fun getLayoutResId() = R.layout.fragment_room_member_list
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -72,5 +70,4 @@ class RoomMemberListFragment @Inject constructor(
|
|||
avatarRenderer.render(it.toMatrixItem(), roomMemberListToolbarAvatarImageView)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState
|
|||
.execute { async ->
|
||||
copy(roomMemberSummaries = async)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun observeRoomSummary() {
|
||||
|
@ -93,7 +92,6 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private fun buildRoomMemberSummaries(powerLevelsContent: PowerLevelsContent, roomMembers: List<RoomMemberSummary>): RoomMemberSummaries {
|
||||
val admins = ArrayList<RoomMemberSummary>()
|
||||
val moderators = ArrayList<RoomMemberSummary>()
|
||||
|
@ -123,7 +121,5 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState
|
|||
}
|
||||
|
||||
override fun handle(action: RoomMemberListAction) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ data class RoomMemberListViewState(
|
|||
) : MvRxState {
|
||||
|
||||
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
||||
|
||||
}
|
||||
|
||||
typealias RoomMemberSummaries = Map<PowerLevelCategory, List<RoomMemberSummary>>
|
||||
|
|
Loading…
Reference in a new issue