Cleanup during PR review

This commit is contained in:
Benoit Marty 2020-01-09 09:42:34 +01:00
parent e14b9b3b20
commit 0f7d59a8c7
11 changed files with 20 additions and 38 deletions

View file

@ -39,7 +39,7 @@ interface GroupService {
fun getGroupSummary(groupId: String): GroupSummary?
/**
* Get a list of group summaries.This list is a snapshot of the data.
* Get a list of group summaries. This list is a snapshot of the data.
* @return the list of [GroupSummary]
*/
fun getGroupSummaries(groupSummaryQueryParams: GroupSummaryQueryParams): List<GroupSummary>

View file

@ -116,7 +116,7 @@ interface RelationService {
fun getEventAnnotationsSummary(eventId: String): EventAnnotationsSummary?
/**
* Get the a LiveData EventAnnotationsSummary
* Get a LiveData of EventAnnotationsSummary for the specified eventId
* @param eventId the eventId to look for EventAnnotationsSummary
* @return the LiveData of EventAnnotationsSummary
*/

View file

@ -21,13 +21,13 @@ import io.realm.RealmQuery
fun <T : RealmObject, E : Enum<E>> RealmQuery<T>.process(field: String, enums: List<Enum<E>>): RealmQuery<T> {
val lastEnumValue = enums.lastOrNull()
this.beginGroup()
beginGroup()
for (enumValue in enums) {
this.equalTo(field, enumValue.name)
equalTo(field, enumValue.name)
if (enumValue != lastEnumValue) {
this.or()
or()
}
}
this.endGroup()
endGroup()
return this
}

View file

@ -25,16 +25,12 @@ import timber.log.Timber
fun <T : RealmObject> RealmQuery<T>.process(field: String, queryStringValue: QueryStringValue): RealmQuery<T> {
when (queryStringValue) {
is QueryStringValue.NoCondition -> Timber.v("No condition to process")
is QueryStringValue.IsNotNull -> this.isNotNull(field)
is QueryStringValue.IsNull -> this.isNull(field)
is QueryStringValue.IsEmpty -> this.isEmpty(field)
is QueryStringValue.IsNotEmpty -> this.isNotEmpty(field)
is QueryStringValue.Equals -> {
this.equalTo(field, queryStringValue.string, queryStringValue.case.toRealmCase())
}
is QueryStringValue.Contains -> {
this.contains(field, queryStringValue.string, queryStringValue.case.toRealmCase())
}
is QueryStringValue.IsNotNull -> isNotNull(field)
is QueryStringValue.IsNull -> isNull(field)
is QueryStringValue.IsEmpty -> isEmpty(field)
is QueryStringValue.IsNotEmpty -> isNotEmpty(field)
is QueryStringValue.Equals -> equalTo(field, queryStringValue.string, queryStringValue.case.toRealmCase())
is QueryStringValue.Contains -> contains(field, queryStringValue.string, queryStringValue.case.toRealmCase())
}
return this
}
@ -42,6 +38,6 @@ fun <T : RealmObject> RealmQuery<T>.process(field: String, queryStringValue: Que
private fun QueryStringValue.Case.toRealmCase(): Case {
return when (this) {
QueryStringValue.Case.INSENSITIVE -> Case.INSENSITIVE
QueryStringValue.Case.SENSITIVE -> Case.SENSITIVE
QueryStringValue.Case.SENSITIVE -> Case.SENSITIVE
}
}

View file

@ -35,7 +35,7 @@ internal class RoomMemberEventHandler @Inject constructor() {
val userId = event.stateKey ?: return false
val roomMemberEntity = RoomMemberEntityFactory.create(roomId, userId, roomMember)
realm.insertOrUpdate(roomMemberEntity)
if (roomMember.membership == Membership.JOIN || roomMember.membership == Membership.INVITE) {
if (roomMember.membership in Membership.activeMemberships()) {
val userEntity = UserEntityFactory.create(userId, roomMember)
realm.insertOrUpdate(userEntity)
}

View file

@ -18,7 +18,6 @@ package im.vector.riotx.features.autocomplete.group
import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.mvrx.Async
import com.otaliastudios.autocomplete.RecyclerViewPresenter
import im.vector.matrix.android.api.query.QueryStringValue
import im.vector.matrix.android.api.session.Session
@ -59,8 +58,4 @@ class AutocompleteGroupPresenter @Inject constructor(context: Context,
.sortedBy { it.displayName }
controller.setData(groups.toList())
}
fun render(groups: Async<List<GroupSummary>>) {
controller.setData(groups())
}
}

View file

@ -18,8 +18,6 @@ package im.vector.riotx.features.autocomplete.member
import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Success
import com.otaliastudios.autocomplete.RecyclerViewPresenter
import com.squareup.inject.assisted.Assisted
import com.squareup.inject.assisted.AssistedInject
@ -71,10 +69,4 @@ class AutocompleteMemberPresenter @AssistedInject constructor(context: Context,
.sortedBy { it.displayName }
controller.setData(members.toList())
}
fun render(members: Async<List<RoomMember>>) {
if (members is Success) {
controller.setData(members())
}
}
}

View file

@ -50,7 +50,7 @@ class AutoCompleter @AssistedInject constructor(
private val avatarRenderer: AvatarRenderer,
private val commandAutocompletePolicy: CommandAutocompletePolicy,
private val autocompleteCommandPresenter: AutocompleteCommandPresenter,
private val autocompleteMemberPresenter: AutocompleteMemberPresenter.Factory,
private val autocompleteMemberPresenterFactory: AutocompleteMemberPresenter.Factory,
private val autocompleteRoomPresenter: AutocompleteRoomPresenter,
private val autocompleteGroupPresenter: AutocompleteGroupPresenter,
private val autocompleteEmojiPresenter: AutocompleteEmojiPresenter
@ -107,10 +107,10 @@ class AutoCompleter @AssistedInject constructor(
}
private fun setupMembers(backgroundDrawable: ColorDrawable, editText: EditText) {
val membersPresenter = autocompleteMemberPresenter.create(roomId)
val autocompleteMemberPresenter = autocompleteMemberPresenterFactory.create(roomId)
Autocomplete.on<RoomMember>(editText)
.with(CharPolicy('@', true))
.with(membersPresenter)
.with(autocompleteMemberPresenter)
.with(ELEVATION)
.with(backgroundDrawable)
.with(object : AutocompleteCallback<RoomMember> {

View file

@ -27,7 +27,6 @@ import im.vector.riotx.core.epoxy.VectorEpoxyModel
import im.vector.riotx.core.platform.CheckableView
import im.vector.riotx.core.ui.views.ReadReceiptsView
import im.vector.riotx.core.utils.DimensionConverter
import kotlinx.coroutines.*
/**
* Children must override getViewType()

View file

@ -398,7 +398,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
fun getNotificationRingTone(): Uri? {
val url = defaultPrefs.getString(SETTINGS_NOTIFICATION_RINGTONE_PREFERENCE_KEY, null)
// the user selects "NoCondition"
// the user selects "None"
if (url == "") {
return null
}
@ -425,7 +425,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
/**
* Provide the notification ringtone filename
*
* @return the filename or null if "NoCondition" is selected
* @return the filename or null if "None" is selected
*/
fun getNotificationRingToneName(): String? {
val toneUri = getNotificationRingTone() ?: return null

View file

@ -47,12 +47,12 @@
android:maxLines="2"
android:textColor="?riotx_text_secondary"
android:textSize="17sp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/actionSelected"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@id/actionStartSpace"
app:layout_constraintTop_toTopOf="parent"
app:layout_constrainedWidth="true"
tools:text="zbla azjazjaz s sdkqdskdsqk kqsdkdqsk kdqsksqdk" />