diff --git a/frontend/app/src/main/java/com/example/speechbuddy/AuthActivity.kt b/frontend/app/src/main/java/com/example/speechbuddy/AuthActivity.kt index 14432390..3baa377b 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/AuthActivity.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/AuthActivity.kt @@ -1,7 +1,11 @@ package com.example.speechbuddy import android.content.Intent +import android.graphics.Rect import android.os.Bundle +import android.view.MotionEvent +import android.view.inputmethod.InputMethodManager +import android.widget.EditText import androidx.activity.compose.setContent import androidx.activity.viewModels import androidx.core.view.WindowCompat @@ -47,4 +51,16 @@ class AuthActivity : BaseActivity() { loginViewModel.checkPreviousUser() } + // hides keyboard + override fun dispatchTouchEvent(event: MotionEvent): Boolean { + if (event.action == MotionEvent.ACTION_DOWN) { + val v = currentFocus + if (v != null) { + v.clearFocus() + val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(v.getWindowToken(), 0) + } + } + return super.dispatchTouchEvent(event) + } } \ No newline at end of file diff --git a/frontend/app/src/main/java/com/example/speechbuddy/HomeActivity.kt b/frontend/app/src/main/java/com/example/speechbuddy/HomeActivity.kt index 043e3e9c..9f546e40 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/HomeActivity.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/HomeActivity.kt @@ -1,13 +1,18 @@ package com.example.speechbuddy import android.content.Intent +import android.graphics.Rect import android.os.Bundle +import android.view.MotionEvent +import android.view.inputmethod.InputMethodManager +import android.widget.EditText import androidx.activity.compose.setContent import androidx.core.view.WindowCompat import com.example.speechbuddy.compose.SpeechBuddyHome import com.example.speechbuddy.ui.SpeechBuddyTheme import dagger.hilt.android.AndroidEntryPoint + @AndroidEntryPoint class HomeActivity : BaseActivity() { @@ -37,5 +42,17 @@ class HomeActivity : BaseActivity() { startActivity(intent) finish() } + // hides keyboard + override fun dispatchTouchEvent(event: MotionEvent): Boolean { + if (event.action == MotionEvent.ACTION_DOWN) { + val v = currentFocus + if (v != null) { + v.clearFocus() + val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(v.getWindowToken(), 0) + } + } + return super.dispatchTouchEvent(event) + } } \ No newline at end of file