diff --git a/app/src/main/java/com/sopetit/softie/ui/onboarding/OnboardingActivity.kt b/app/src/main/java/com/sopetit/softie/ui/onboarding/OnboardingActivity.kt index b42cc9e1..abcd70f6 100644 --- a/app/src/main/java/com/sopetit/softie/ui/onboarding/OnboardingActivity.kt +++ b/app/src/main/java/com/sopetit/softie/ui/onboarding/OnboardingActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.text.SpannableStringBuilder import android.text.Spanned import android.text.style.ForegroundColorSpan +import android.view.MotionEvent import androidx.activity.viewModels import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment @@ -16,6 +17,7 @@ import com.sopetit.softie.ui.onboarding.routinechoice.RoutineChoiceFragment import com.sopetit.softie.ui.onboarding.themechoice.ChoiceThemeFragment import com.sopetit.softie.util.binding.BindingActivity import com.sopetit.softie.util.binding.BindingAdapter.setImage +import com.sopetit.softie.util.hideKeyboard import com.sopetit.softie.util.setStatusBarColorFromResource import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.CoroutineScope @@ -38,6 +40,11 @@ class OnboardingActivity : initChangeFragment() } + override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { + hideKeyboard(currentFocus) + return super.dispatchTouchEvent(ev) + } + private fun initMakeFragment() { val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_onboarding_fragment) if (currentFragment == null) { diff --git a/app/src/main/java/com/sopetit/softie/util/Context.kt b/app/src/main/java/com/sopetit/softie/util/Context.kt index f873a238..0d531f9b 100644 --- a/app/src/main/java/com/sopetit/softie/util/Context.kt +++ b/app/src/main/java/com/sopetit/softie/util/Context.kt @@ -4,16 +4,23 @@ import android.app.Activity import android.content.Context import android.content.Intent import android.os.Build +import android.os.Handler +import android.os.Looper import android.view.View import android.view.inputmethod.InputMethodManager +import android.widget.EditText import android.widget.Toast import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import java.io.Serializable -fun Context.hideKeyboard(view: View) { - val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager - inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) +fun Context.hideKeyboard(view: View?) { + if (view is EditText) { + view.clearFocus() + val inputMethodManager = + getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) + } } fun snackBar( @@ -24,7 +31,11 @@ fun snackBar( } fun Context.toast(message: String) { - Toast.makeText(this, message, Toast.LENGTH_SHORT).show() + val toast = Toast.makeText(this, message, Toast.LENGTH_SHORT) + toast.show() + Handler(Looper.getMainLooper()).postDelayed({ + run() { toast.cancel() } + }, 1000) } fun Fragment.setStatusBarColor(colorResId: Int) { diff --git a/app/src/main/res/layout/fragment_onboarding_choice_routine.xml b/app/src/main/res/layout/fragment_onboarding_choice_routine.xml index cdb65905..a10655d3 100644 --- a/app/src/main/res/layout/fragment_onboarding_choice_routine.xml +++ b/app/src/main/res/layout/fragment_onboarding_choice_routine.xml @@ -63,9 +63,9 @@ android:layout_marginTop="37dp" android:layout_marginBottom="90dp" android:layout_marginStart="30dp" - android:layout_marginEnd="10dp" + android:layout_marginEnd="20dp" android:scrollbars="vertical" - android:scrollbarStyle="outsideInset" + android:scrollbarStyle="outsideOverlay" android:scrollbarThumbVertical="@drawable/ic_scrollbar" app:layout_constraintTop_toBottomOf="@id/iv_onboarding_choice_routine_speech_background" app:layout_constraintBottom_toTopOf="@id/btn_onboarding_routine_back_theme" diff --git a/app/src/main/res/layout/fragment_onboarding_choice_theme.xml b/app/src/main/res/layout/fragment_onboarding_choice_theme.xml index 83f3ec14..2778b5ac 100644 --- a/app/src/main/res/layout/fragment_onboarding_choice_theme.xml +++ b/app/src/main/res/layout/fragment_onboarding_choice_theme.xml @@ -23,11 +23,11 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + android:paddingHorizontal="10dp">