Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30126523 authored by moezbhatti's avatar moezbhatti Committed by Moez Bhatti
Browse files

Show keyboard when selecting contact and contact selected

parent 8d43d60e
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -24,8 +24,7 @@ import android.view.inputmethod.InputMethodManager

fun Activity.dismissKeyboard() {
    window.currentFocus?.let { focus ->
        val imm = getSystemService(
                Context.INPUT_METHOD_SERVICE) as InputMethodManager
        val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        imm.hideSoftInputFromWindow(focus.windowToken, 0)

        focus.clearFocus()
+7 −2
Original line number Diff line number Diff line
@@ -39,11 +39,16 @@ var ViewGroup.animateLayoutChanges: Boolean
        layoutTransition = if (value) LayoutTransition() else null
    }


fun EditText.showKeyboard() {
    requestFocus()
    val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
    imm.showSoftInput(this, 0)
    imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT)
}

fun EditText.hideKeyboard() {
    requestFocus()
    val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
    imm.hideSoftInputFromWindow(windowToken, 0)
}

fun ImageView.setTint(color: Int) {
+8 −4
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.base.QkThemedActivity
import com.moez.QKSMS.common.util.DateFormatter
import com.moez.QKSMS.common.util.extensions.autoScrollToStart
import com.moez.QKSMS.common.util.extensions.hideKeyboard
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
import com.moez.QKSMS.common.util.extensions.scrapViews
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
@@ -207,10 +208,6 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
        toolbar.menu.findItem(R.id.next)?.isVisible = state.selectedMessages == 0 && state.query.isNotEmpty()
        toolbar.menu.findItem(R.id.clear)?.isVisible = state.selectedMessages == 0 && state.query.isNotEmpty()

        if (chipsAdapter.data.isEmpty() && state.selectedChips.isNotEmpty()) {
            message.showKeyboard()
        }

        chipsAdapter.data = state.selectedChips

        loading.setVisible(state.loading)
@@ -289,12 +286,19 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
    }

    override fun showContacts(chips: List<Chip>) {
        message.hideKeyboard()
        val serialized = HashMap(chips.associate { chip -> chip.address to chip.contact?.lookupKey })
        val intent = Intent(this, ContactsActivity::class.java)
                .putExtra(ContactsActivity.ChipsKey, serialized)
        startActivityForResult(intent, SELECT_CONTACT_REQUEST_CODE)
    }

    override fun showKeyboard() {
        message.postDelayed({
            message.showKeyboard()
        }, 200)
    }

    override fun requestCamera() {
        cameraDestination = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
                .let { timestamp -> ContentValues().apply { put(MediaStore.Images.Media.TITLE, timestamp) } }
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ interface ComposeView : QkView<ComposeState> {
    fun requestStoragePermission()
    fun requestSmsPermission()
    fun showContacts(chips: List<Chip>)
    fun showKeyboard()
    fun requestCamera()
    fun requestGallery()
    fun requestDatePicker()
+1 −0
Original line number Diff line number Diff line
@@ -243,6 +243,7 @@ class ComposeViewModel @Inject constructor(
                .autoDisposable(view.scope())
                .subscribe { chips ->
                    chipsReducer.onNext { list -> list + chips }
                    view.showKeyboard()
                }

        // Set the contact suggestions list to visible when the add button is pressed
Loading