Show keyboard when selecting contact and contact selected

This commit is contained in:
moezbhatti
2019-11-17 02:10:55 -05:00
committed by Moez Bhatti
parent 8d43d60e56
commit 30126523ae
8 changed files with 35 additions and 8 deletions
@@ -27,6 +27,8 @@ import com.jakewharton.rxbinding2.widget.textChanges
import com.moez.QKSMS.R
import com.moez.QKSMS.common.ViewModelFactory
import com.moez.QKSMS.common.base.QkThemedActivity
import com.moez.QKSMS.common.util.extensions.hideKeyboard
import com.moez.QKSMS.common.util.extensions.showKeyboard
import com.moez.QKSMS.common.widget.QkDialog
import com.moez.QKSMS.extensions.Optional
import com.moez.QKSMS.feature.compose.editing.ComposeItem
@@ -95,7 +97,14 @@ class ContactsActivity : QkThemedActivity(), ContactsContract {
}
}
override fun openKeyboard() {
search.postDelayed({
search.showKeyboard()
}, 200)
}
override fun finish(result: HashMap<String, String?>) {
search.hideKeyboard()
val intent = Intent().putExtra(ChipsKey, result)
setResult(Activity.RESULT_OK, intent)
finish()
@@ -35,6 +35,7 @@ interface ContactsContract : QkView<ContactsState> {
val phoneNumberSelectedIntent: Subject<Optional<Long>>
val phoneNumberActionIntent: Subject<PhoneNumberAction>
fun openKeyboard()
fun finish(result: HashMap<String, String?>)
}
@@ -71,6 +71,8 @@ class ContactsViewModel @Inject constructor(
}
}
private var shouldOpenKeyboard: Boolean = true
init {
syncContacts.execute(Unit)
}
@@ -78,6 +80,11 @@ class ContactsViewModel @Inject constructor(
override fun bindView(view: ContactsContract) {
super.bindView(view)
if (shouldOpenKeyboard) {
view.openKeyboard()
shouldOpenKeyboard = false
}
// Update the list of contact suggestions based on the query input, while also filtering out any contacts
// that have already been selected
Observables