Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#79 [fix] 자잘한 이슈 해결 #80

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Comment on lines +43 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿짭입니다! 제가 놓쳤는데 잘 잡아주셨네요


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?) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

키보드를 숨기는 메소드인가요?? 멋져요

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