Loading presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsActivity.kt +9 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,9 @@ package com.moez.QKSMS.feature.contacts import android.app.Activity import android.content.Intent import android.os.Bundle import androidx.core.view.isVisible import androidx.lifecycle.ViewModelProviders import com.jakewharton.rxbinding2.view.clicks import com.jakewharton.rxbinding2.widget.editorActions import com.jakewharton.rxbinding2.widget.textChanges import com.moez.QKSMS.R Loading Loading @@ -53,7 +55,7 @@ class ContactsActivity : QkThemedActivity(), ContactsContract { @Inject lateinit var viewModelFactory: ViewModelFactory override val queryChangedIntent: Observable<CharSequence> by lazy { search.textChanges() } override val queryBackspaceIntent: Observable<*> by lazy { search.backspaces } override val queryClearedIntent: Observable<*> by lazy { cancel.clicks() } override val queryEditorActionIntent: Observable<Int> by lazy { search.editorActions() } override val composeItemPressedIntent: Subject<ComposeItem> by lazy { contactsAdapter.clicks } override val composeItemLongPressedIntent: Subject<ComposeItem> by lazy { contactsAdapter.longClicks } Loading Loading @@ -86,6 +88,8 @@ class ContactsActivity : QkThemedActivity(), ContactsContract { } override fun render(state: ContactsState) { cancel.isVisible = state.query.length > 1 contactsAdapter.data = state.composeItems if (state.selectedContact != null && !phoneNumberDialog.isShowing) { Loading @@ -97,6 +101,10 @@ class ContactsActivity : QkThemedActivity(), ContactsContract { } } override fun clearQuery() { search.text = null } override fun openKeyboard() { search.postDelayed({ search.showKeyboard() Loading presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsContract.kt +2 −1 Original line number Diff line number Diff line Loading @@ -28,13 +28,14 @@ import io.reactivex.subjects.Subject interface ContactsContract : QkView<ContactsState> { val queryChangedIntent: Observable<CharSequence> val queryBackspaceIntent: Observable<*> val queryClearedIntent: Observable<*> val queryEditorActionIntent: Observable<Int> val composeItemPressedIntent: Subject<ComposeItem> val composeItemLongPressedIntent: Subject<ComposeItem> val phoneNumberSelectedIntent: Subject<Optional<Long>> val phoneNumberActionIntent: Subject<PhoneNumberAction> fun clearQuery() fun openKeyboard() fun finish(result: HashMap<String, String?>) Loading presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsState.kt +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.moez.QKSMS.feature.compose.editing.ComposeItem import com.moez.QKSMS.model.Contact data class ContactsState( val query: String = "", val composeItems: List<ComposeItem> = ArrayList(), val selectedContact: Contact? = null // For phone number picker ) presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsViewModel.kt +10 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,16 @@ class ContactsViewModel @Inject constructor( shouldOpenKeyboard = false } // Update the state's query, so we know if we should show the cancel button view.queryChangedIntent .autoDisposable(view.scope()) .subscribe { query -> newState { copy(query = query.toString()) } } // Clear the query view.queryClearedIntent .autoDisposable(view.scope()) .subscribe { view.clearQuery() } // Update the list of contact suggestions based on the query input, while also filtering out any contacts // that have already been selected Observables Loading presentation/src/main/res/layout/contacts_activity.xml +36 −10 Original line number Diff line number Diff line Loading @@ -47,22 +47,48 @@ style="@style/Toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" app:contentInsetStartWithNavigation="0dp" app:layout_constrainedHeight="true" app:layout_constraintTop_toTopOf="parent"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:animateLayoutChanges="true"> <com.moez.QKSMS.common.widget.QkEditText android:id="@+id/search" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@null" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:background="@drawable/rounded_rectangle_24dp" android:backgroundTint="?attr/bubbleColor" android:hint="@string/title_compose" android:imeOptions="flagNoExtractUi" android:inputType="textFilter|textNoSuggestions" android:paddingStart="16dp" android:paddingEnd="16dp" android:privateImeOptions="nm" android:textColor="?android:attr/textColorPrimary" android:textColorHint="?android:attr/textColorTertiary" app:textSize="primary" /> <ImageView android:id="@+id/cancel" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="center_vertical|end" android:layout_marginEnd="8dp" android:background="?android:attr/selectableItemBackgroundBorderless" android:padding="8dp" android:src="@drawable/ic_cancel_black_24dp" android:tint="?android:attr/textColorSecondary" android:visibility="gone" /> </FrameLayout> </androidx.appcompat.widget.Toolbar> <View Loading Loading
presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsActivity.kt +9 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,9 @@ package com.moez.QKSMS.feature.contacts import android.app.Activity import android.content.Intent import android.os.Bundle import androidx.core.view.isVisible import androidx.lifecycle.ViewModelProviders import com.jakewharton.rxbinding2.view.clicks import com.jakewharton.rxbinding2.widget.editorActions import com.jakewharton.rxbinding2.widget.textChanges import com.moez.QKSMS.R Loading Loading @@ -53,7 +55,7 @@ class ContactsActivity : QkThemedActivity(), ContactsContract { @Inject lateinit var viewModelFactory: ViewModelFactory override val queryChangedIntent: Observable<CharSequence> by lazy { search.textChanges() } override val queryBackspaceIntent: Observable<*> by lazy { search.backspaces } override val queryClearedIntent: Observable<*> by lazy { cancel.clicks() } override val queryEditorActionIntent: Observable<Int> by lazy { search.editorActions() } override val composeItemPressedIntent: Subject<ComposeItem> by lazy { contactsAdapter.clicks } override val composeItemLongPressedIntent: Subject<ComposeItem> by lazy { contactsAdapter.longClicks } Loading Loading @@ -86,6 +88,8 @@ class ContactsActivity : QkThemedActivity(), ContactsContract { } override fun render(state: ContactsState) { cancel.isVisible = state.query.length > 1 contactsAdapter.data = state.composeItems if (state.selectedContact != null && !phoneNumberDialog.isShowing) { Loading @@ -97,6 +101,10 @@ class ContactsActivity : QkThemedActivity(), ContactsContract { } } override fun clearQuery() { search.text = null } override fun openKeyboard() { search.postDelayed({ search.showKeyboard() Loading
presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsContract.kt +2 −1 Original line number Diff line number Diff line Loading @@ -28,13 +28,14 @@ import io.reactivex.subjects.Subject interface ContactsContract : QkView<ContactsState> { val queryChangedIntent: Observable<CharSequence> val queryBackspaceIntent: Observable<*> val queryClearedIntent: Observable<*> val queryEditorActionIntent: Observable<Int> val composeItemPressedIntent: Subject<ComposeItem> val composeItemLongPressedIntent: Subject<ComposeItem> val phoneNumberSelectedIntent: Subject<Optional<Long>> val phoneNumberActionIntent: Subject<PhoneNumberAction> fun clearQuery() fun openKeyboard() fun finish(result: HashMap<String, String?>) Loading
presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsState.kt +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.moez.QKSMS.feature.compose.editing.ComposeItem import com.moez.QKSMS.model.Contact data class ContactsState( val query: String = "", val composeItems: List<ComposeItem> = ArrayList(), val selectedContact: Contact? = null // For phone number picker )
presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsViewModel.kt +10 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,16 @@ class ContactsViewModel @Inject constructor( shouldOpenKeyboard = false } // Update the state's query, so we know if we should show the cancel button view.queryChangedIntent .autoDisposable(view.scope()) .subscribe { query -> newState { copy(query = query.toString()) } } // Clear the query view.queryClearedIntent .autoDisposable(view.scope()) .subscribe { view.clearQuery() } // Update the list of contact suggestions based on the query input, while also filtering out any contacts // that have already been selected Observables Loading
presentation/src/main/res/layout/contacts_activity.xml +36 −10 Original line number Diff line number Diff line Loading @@ -47,22 +47,48 @@ style="@style/Toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" app:contentInsetStartWithNavigation="0dp" app:layout_constrainedHeight="true" app:layout_constraintTop_toTopOf="parent"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:animateLayoutChanges="true"> <com.moez.QKSMS.common.widget.QkEditText android:id="@+id/search" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@null" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:background="@drawable/rounded_rectangle_24dp" android:backgroundTint="?attr/bubbleColor" android:hint="@string/title_compose" android:imeOptions="flagNoExtractUi" android:inputType="textFilter|textNoSuggestions" android:paddingStart="16dp" android:paddingEnd="16dp" android:privateImeOptions="nm" android:textColor="?android:attr/textColorPrimary" android:textColorHint="?android:attr/textColorTertiary" app:textSize="primary" /> <ImageView android:id="@+id/cancel" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="center_vertical|end" android:layout_marginEnd="8dp" android:background="?android:attr/selectableItemBackgroundBorderless" android:padding="8dp" android:src="@drawable/ic_cancel_black_24dp" android:tint="?android:attr/textColorSecondary" android:visibility="gone" /> </FrameLayout> </androidx.appcompat.widget.Toolbar> <View Loading