From fb7c91d6bbe548f861a5978e1a838963165fa25f Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Tue, 29 Jan 2019 11:08:32 -0600 Subject: [PATCH] Updated Navigation Architecture Component library version and tested it worked fine. Setted a maximum width to the MerchantsFragment's SearchView so that it does not move other items out of the screen. Added the auto hide keyboard feature to ReceiveTransactionFragment's AutoCompleteTextView when it loses focus. --- app/build.gradle | 2 +- .../bitsybitshareswallet/fragments/MerchantsFragment.kt | 3 +++ .../views/MyTextInputAutoCompleteTextView.kt | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index f24e747..c59a879 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { dependencies { def lifecycle_version = "2.0.0" def room_version = "2.1.0-alpha03" - def nav_version = "1.0.0-alpha09" + def nav_version = "1.0.0-alpha11" def rx_bindings_version = "3.0.0-alpha2" implementation fileTree(dir: 'libs', include: ['*.jar']) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt index b44ca17..1453506 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt @@ -182,6 +182,9 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio } mSearchView?.setOnSuggestionListener(this) + + // Adjust SearchView width to avoid pushing other menu items out of the screen + mSearchView?.maxWidth = screenWidth * 7 / 10 } private fun updateSearchViewSuggestions(query: String) { diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/views/MyTextInputAutoCompleteTextView.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/views/MyTextInputAutoCompleteTextView.kt index d37b60d..de20277 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/views/MyTextInputAutoCompleteTextView.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/views/MyTextInputAutoCompleteTextView.kt @@ -1,15 +1,18 @@ package cy.agorise.bitsybitshareswallet.views import android.content.Context +import android.graphics.Rect import android.util.AttributeSet import com.google.android.material.textfield.TextInputLayout import android.view.inputmethod.InputConnection import android.view.inputmethod.EditorInfo import androidx.appcompat.widget.AppCompatAutoCompleteTextView +import cy.agorise.bitsybitshareswallet.utils.hideKeyboard /** * Custom AutoCompleteTextView to be used inside a TextInputLayout, so that they can share their hint * From https://stackoverflow.com/a/41864063/5428997 + * And also hides the keyboard when it loses focus. */ class MyTextInputAutoCompleteTextView : AppCompatAutoCompleteTextView { @@ -42,4 +45,9 @@ class MyTextInputAutoCompleteTextView : AppCompatAutoCompleteTextView { } return ic } + + override fun onFocusChanged(focused: Boolean, direction: Int, previouslyFocusedRect: Rect?) { + super.onFocusChanged(focused, direction, previouslyFocusedRect) + if (!focused) this.hideKeyboard() + } } \ No newline at end of file