From 0ddef67cc95c5615dde476f2f3805dfee9d31abb Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 16 Jul 2019 15:01:14 +0200 Subject: [PATCH] Migrate to rxbinding 3 and fix bad layout for room directory filter (Fixes #349) --- CHANGES.md | 3 ++- vector/build.gradle | 5 +++-- .../riotx/features/login/LoginActivity.kt | 8 +++---- .../roomdirectory/PublicRoomsFragment.kt | 7 ++---- vector/src/main/res/drawable/ic_search.xml | 22 +++++++++++++++++++ .../main/res/layout/fragment_public_rooms.xml | 22 ++++--------------- vector/src/main/res/values/strings_riotX.xml | 2 ++ vector/src/main/res/values/styles_riot.xml | 1 + 8 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 vector/src/main/res/drawable/ic_search.xml diff --git a/CHANGES.md b/CHANGES.md index 2b666e88..d1e84259 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,12 +10,13 @@ Improvements: - Improve edit of replies Other changes: - - + - migrate from rxbinding 2 to rxbinding 3 Bugfix: - Fix regression on permalink click - Fix crash reported by the PlayStore (#341) - Fix Chat composer separator color in dark/black theme + - Fix bad layout for room directory filter (#349) Translations: - diff --git a/vector/build.gradle b/vector/build.gradle index d7332c47..5fdb240a 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -187,8 +187,9 @@ dependencies { implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0' implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0' - // TODO RxBindings3 exists - implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0' + // RXBinding + implementation 'com.jakewharton.rxbinding3:rxbinding:3.0.0-alpha2' + implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.0.0-alpha2' implementation("com.airbnb.android:epoxy:$epoxy_version") kapt "com.airbnb.android:epoxy-processor:$epoxy_version" diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginActivity.kt index 5c91b4bc..53519fc4 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginActivity.kt @@ -22,7 +22,7 @@ import android.os.Bundle import android.widget.Toast import androidx.core.view.isVisible import arrow.core.Try -import com.jakewharton.rxbinding2.widget.RxTextView +import com.jakewharton.rxbinding3.widget.textChanges import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.auth.Authenticator import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig @@ -127,9 +127,9 @@ class LoginActivity : VectorBaseActivity() { private fun setupAuthButton() { Observable .combineLatest( - RxTextView.textChanges(loginField).map { it.trim().isNotEmpty() }, - RxTextView.textChanges(passwordField).map { it.trim().isNotEmpty() }, - RxTextView.textChanges(homeServerField).map { it.trim().isNotEmpty() }, + loginField.textChanges().map { it.trim().isNotEmpty() }, + passwordField.textChanges().map { it.trim().isNotEmpty() }, + homeServerField.textChanges().map { it.trim().isNotEmpty() }, Function3 { isLoginNotEmpty, isPasswordNotEmpty, isHomeServerNotEmpty -> isLoginNotEmpty && isPasswordNotEmpty && isHomeServerNotEmpty } diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt index 873f8b8b..9888463e 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt @@ -25,14 +25,13 @@ import com.airbnb.epoxy.EpoxyVisibilityTracker import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.withState import com.google.android.material.snackbar.Snackbar -import com.jakewharton.rxbinding2.widget.RxTextView +import com.jakewharton.rxbinding3.appcompat.queryTextChanges import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent import im.vector.riotx.core.error.ErrorFormatter import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.platform.VectorBaseFragment -import im.vector.riotx.features.themes.ThemeUtils import io.reactivex.rxkotlin.subscribeBy import kotlinx.android.synthetic.main.fragment_public_rooms.* import timber.log.Timber @@ -70,9 +69,7 @@ class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback it.setDisplayHomeAsUpEnabled(true) } - publicRoomsFilter.setBackgroundResource(ThemeUtils.getResourceId(requireContext(), R.drawable.bg_search_edit_text_light)) - - RxTextView.textChanges(publicRoomsFilter) + publicRoomsFilter.queryTextChanges() .debounce(500, TimeUnit.MILLISECONDS) .subscribeBy { viewModel.filterWith(it.toString()) diff --git a/vector/src/main/res/drawable/ic_search.xml b/vector/src/main/res/drawable/ic_search.xml new file mode 100644 index 00000000..e2a66c77 --- /dev/null +++ b/vector/src/main/res/drawable/ic_search.xml @@ -0,0 +1,22 @@ + + + + diff --git a/vector/src/main/res/layout/fragment_public_rooms.xml b/vector/src/main/res/layout/fragment_public_rooms.xml index de6fa436..2ba74a75 100644 --- a/vector/src/main/res/layout/fragment_public_rooms.xml +++ b/vector/src/main/res/layout/fragment_public_rooms.xml @@ -33,26 +33,12 @@ app:layout_constraintTop_toTopOf="parent" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap|enterAlways"> - - + android:layout_height="wrap_content" + app:queryHint="@string/room_directory_search_hint" /> diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 06f495a8..aa24261e 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -32,5 +32,7 @@ Send a new direct message View the room directory + Name or ID (#example:matrix.org) + \ No newline at end of file diff --git a/vector/src/main/res/values/styles_riot.xml b/vector/src/main/res/values/styles_riot.xml index d31ab201..59d87ec7 100644 --- a/vector/src/main/res/values/styles_riot.xml +++ b/vector/src/main/res/values/styles_riot.xml @@ -161,6 +161,7 @@