Clean code and update CHANGES

This commit is contained in:
ganfra 2020-01-14 18:48:13 +01:00
parent d3415d345f
commit 9671a77e5d
42 changed files with 7 additions and 80 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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
}

View file

@ -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
/**

View file

@ -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
}

View file

@ -57,7 +57,6 @@ class PowerLevelsHelper(private val powerLevelsContent: PowerLevelsContent) {
} else false
}
/**
* Get the notification level for a dedicated key.
*

View file

@ -73,5 +73,4 @@ internal class DefaultProfileService @Inject constructor(private val taskExecuto
}
.executeBy(taskExecutor)
}
}

View file

@ -38,5 +38,3 @@ internal class DefaultGetProfileInfoTask @Inject constructor(private val profile
}
}
}

View file

@ -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>
}

View file

@ -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)

View file

@ -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 ->

View file

@ -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 {

View file

@ -218,6 +218,4 @@ class PercentViewBehavior<V : View>(context: Context, attrs: AttributeSet) : Coo
child.requestLayout()
}
}

View file

@ -291,5 +291,4 @@ interface FragmentModule {
@IntoMap
@FragmentKey(SoftLogoutFragment::class)
fun bindSoftLogoutFragment(fragment: SoftLogoutFragment): Fragment
}

View file

@ -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)
}
}

View file

@ -38,7 +38,6 @@ fun EpoxyController.buildProfileAction(
divider: Boolean = true,
action: () -> Unit
) {
profileItemAction {
iconRes(icon)
id("action_$id")

View file

@ -37,7 +37,4 @@ abstract class ProfileItemSection: VectorEpoxyModel<ProfileItemSection.Holder>()
class Holder : VectorEpoxyHolder() {
val sectionView by bind<TextView>(R.id.itemProfileSectionView)
}
}

View file

@ -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()
}

View file

@ -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>

View file

@ -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),

View file

@ -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

View file

@ -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

View file

@ -141,5 +141,4 @@ class DefaultNavigator @Inject constructor(
override fun openRoomProfile(context: Context, roomId: String) {
context.startActivity(RoomProfileActivity.newIntent(context, roomId))
}
}

View file

@ -53,5 +53,4 @@ interface Navigator {
fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean = false)
fun openRoomProfile(context: Context, roomId: String)
}

View file

@ -115,6 +115,4 @@ interface NavigationInterceptor {
fun navToMemberProfile(userId: String): Boolean {
return false
}
}

View file

@ -23,5 +23,4 @@ sealed class RoomMemberProfileAction : VectorViewModelAction {
object RetryFetchingInfo: RoomMemberProfileAction()
object IgnoreUser: RoomMemberProfileAction()
}

View file

@ -51,5 +51,4 @@ class RoomMemberProfileActivity : VectorBaseActivity(), ToolbarConfigurable {
override fun configure(toolbar: Toolbar) {
configureToolbar(toolbar)
}
}

View file

@ -112,6 +112,4 @@ class RoomMemberProfileController @Inject constructor(private val stringProvider
stringProvider.getString(R.string.ignore)
}
}
}

View file

@ -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")
}
}

View file

@ -23,5 +23,4 @@ sealed class RoomMemberProfileViewEvents {
data class Loading(val message: CharSequence) : RoomMemberProfileViewEvents()
object OnIgnoreActionSuccess : RoomMemberProfileViewEvents()
data class Failure(val throwable: Throwable) : RoomMemberProfileViewEvents()
}

View file

@ -195,5 +195,4 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v
session.ignoreUserIds(listOf(initialState.userId), ignoreActionCallback)
}
}
}

View file

@ -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)
}

View file

@ -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()

View file

@ -79,5 +79,4 @@ class RoomProfileActivity : VectorBaseActivity(), ToolbarConfigurable {
override fun configure(toolbar: Toolbar) {
configureToolbar(toolbar)
}
}

View file

@ -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() }
)
}
}

View file

@ -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?) {

View file

@ -22,5 +22,4 @@ sealed class RoomProfileViewEvents {
data class Loading(val message: CharSequence): RoomProfileViewEvents()
object OnLeaveRoomSuccess: RoomProfileViewEvents()
data class Failure(val throwable: Throwable) : RoomProfileViewEvents()
}

View file

@ -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
}
})
}
}

View file

@ -64,6 +64,4 @@ class RoomMemberListController @Inject constructor(private val avatarRenderer: A
}
}
}
}

View file

@ -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)
}
}
}

View file

@ -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) {
}
}

View file

@ -32,7 +32,6 @@ data class RoomMemberListViewState(
) : MvRxState {
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
}
typealias RoomMemberSummaries = Map<PowerLevelCategory, List<RoomMemberSummary>>