diff --git a/app/src/main/java/com/wilderpereira/lmgtfygen/presentation/MainActivity.kt b/app/src/main/java/com/wilderpereira/lmgtfygen/presentation/MainActivity.kt index 4d7d786..9ddb7ff 100644 --- a/app/src/main/java/com/wilderpereira/lmgtfygen/presentation/MainActivity.kt +++ b/app/src/main/java/com/wilderpereira/lmgtfygen/presentation/MainActivity.kt @@ -16,6 +16,7 @@ import com.jakewharton.rxbinding.widget.RxTextView import com.kobakei.ratethisapp.RateThisApp import com.wilderpereira.lmgtfygen.App import com.wilderpereira.lmgtfygen.R +import com.wilderpereira.lmgtfygen.utils.UIUtils import kotlinx.android.synthetic.main.activity_main.* import javax.inject.Inject @@ -98,6 +99,8 @@ class MainActivity : AppCompatActivity(), MainContract.View { .subscribe { text -> presenter.updateSearchValue(text.toString(), generatedUrlTv.text)} RxCompoundButton.checkedChanges(internetExplainerCb).subscribe{ checked -> presenter.includeInternetExplainer(checked) } + + RxView.focusChanges(searchEt).subscribe{ hasFocus -> if (!hasFocus) UIUtils.hideKeyboard(this, searchEt) } } } \ No newline at end of file diff --git a/app/src/main/java/com/wilderpereira/lmgtfygen/utils/UIUtils.kt b/app/src/main/java/com/wilderpereira/lmgtfygen/utils/UIUtils.kt new file mode 100644 index 0000000..cd8e280 --- /dev/null +++ b/app/src/main/java/com/wilderpereira/lmgtfygen/utils/UIUtils.kt @@ -0,0 +1,20 @@ +package com.wilderpereira.lmgtfygen.utils + +import android.app.Activity +import android.content.Context +import android.view.View +import android.view.inputmethod.InputMethodManager + + +/** + * Created by Wilder on 18/04/17. + */ + +class UIUtils { + companion object { + fun hideKeyboard(context: Context, view: View) { + val inputMethodManager = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6959fc6..e6e01f3 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -7,6 +7,8 @@ android:gravity="center" android:layout_width="match_parent" android:layout_height="match_parent" + android:clickable="true" + android:focusableInTouchMode="true" tools:context="com.wilderpereira.lmgtfygen.presentation.MainActivity">