Skip to content

Commit

Permalink
Merge pull request #80 from Team-Sopetit/feature/#79-fix-issue
Browse files Browse the repository at this point in the history
#79 [fix] 자잘한 이슈 해결
  • Loading branch information
emjayMJkim authored Jan 17, 2024
2 parents d2707f0 + 6645f91 commit 28ba7c7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand Down
19 changes: 15 additions & 4 deletions app/src/main/java/com/sopetit/softie/util/Context.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_onboarding_choice_theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_onboarding_choice_theme"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginHorizontal="21dp"
android:layout_marginTop="34dp"
android:layout_marginBottom="21dp"
android:layout_marginBottom="34dp"
android:overScrollMode="never"
app:layout_constraintBottom_toTopOf="@id/btn_onboarding_choice_theme"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_onboarding_choice_theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingHorizontal="10dp">

<ImageView
android:id="@+id/iv_theme_background"
Expand Down

0 comments on commit 28ba7c7

Please sign in to comment.