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

[AN] 스레드 뷰 입력 편의성 향상 및 TextView 링크 클릭 및 입력 커서 테마 적용 #598

Merged
merged 8 commits into from
Nov 4, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.view.MotionEvent
import android.view.inputmethod.InputMethodManager
import android.text.Editable
import android.text.TextWatcher
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
Expand Down Expand Up @@ -48,23 +48,10 @@ class CertificationActivity :
setupGalleryButtonListener()
setupCameraButtonListener()
setupPostButtonListener()
setupBodyTextChangedListener()
observeUiState()
}

override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
onHideKeyBoard()

return super.dispatchTouchEvent(ev)
}

private fun onHideKeyBoard() {
val imm: InputMethodManager =
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(currentFocus?.windowToken, 0)
binding.etCertificationBody.clearFocus()
certificationViewModel.updateContent(binding.etCertificationBody.text.toString())
}

private fun setupBinding() {
binding.lifecycleOwner = this
}
Expand Down Expand Up @@ -134,10 +121,24 @@ class CertificationActivity :
private fun setupPostButtonListener() {
binding.tvCertificationPostButton.setOnClickListener {
val studyId = intent.getLongExtra(KEY_STUDY_ID, KEY_NOT_FOUND_STUDY_ID)
certificationViewModel.uiState.value.imageUrl.toUri().toAdjustImageFile(this)?.let { file ->
certificationViewModel.updateCertification(file, studyId)
certificationViewModel.uiState.value.imageUrl.toUri().toAdjustImageFile(this)
?.let { file ->
certificationViewModel.updateCertification(file, studyId)
}
}
}

private fun setupBodyTextChangedListener() {
val textWatcher = object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}

override fun afterTextChanged(s: Editable?) {
certificationViewModel.updateContent(binding.etCertificationBody.text.toString())
}
}
binding.etCertificationBody.addTextChangedListener(textWatcher)
}

private fun observeUiState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ class ThreadActivity : BindingActivity<ActivityThreadBinding>(R.layout.activity_
threadViewModel.dispatchFeed(message)
binding.etThreadInput.run {
text.clear()
clearFocus()
hideKeyboard()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions android/app/src/main/res/drawable/cursor_color.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:width="2dp" />
<solid android:color="@color/green09_799E82" />
</shape>
<solid android:color="@color/green04_26A641" />
</shape>
3 changes: 2 additions & 1 deletion android/app/src/main/res/layout/activity_certification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@
android:background="@drawable/bg_rectangle_radius_5dp"
android:gravity="top"
android:hint="@string/certification_post_body_hint"
android:maxLength="250"
android:maxLength="1000"
android:maxLines="6"
android:paddingHorizontal="16dp"
android:paddingVertical="12dp"
android:scrollbars="vertical"
android:textAppearance="@style/text_r14"
android:textColor="@color/white"
android:textColorHint="@color/grey02_78808B"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="40dp"
android:background="@drawable/bg_rectangle_radius_5dp"
android:fadeScrollbars="false"
android:gravity="top"
android:paddingHorizontal="16dp"
android:paddingVertical="12dp"
android:scrollbars="vertical"
android:textAppearance="@style/text_r14"
android:textColor="@color/white"
android:textCursorDrawable="@drawable/cursor_color"
Expand All @@ -55,4 +57,4 @@
tools:text="링링 머슷두 완료" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</layout>
4 changes: 3 additions & 1 deletion android/app/src/main/res/layout/activity_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,15 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="24dp"
android:autoLink="email|web"
android:background="@drawable/bg_rectangle_radius_5dp"
android:lines="8"
android:maxLines="8"
android:padding="16dp"
android:lines="8"
android:text="@{viewModel.profile.profile.profileInformation.introduction}"
android:textAppearance="@style/text_r16"
android:textColor="@color/white"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_profile_study_success_rate"
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/res/layout/activity_study_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,14 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="20dp"
android:autoLink="web|email"
android:background="@drawable/bg_rectangle_radius_5dp"
android:minHeight="150dp"
android:padding="16dp"
android:text="@{viewModel.study.introduction}"
android:textAppearance="@style/text_r16"
android:textColor="@color/white"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cl_study_detail_inform"
Expand Down
31 changes: 17 additions & 14 deletions android/app/src/main/res/layout/activity_thread.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
android:layout_marginStart="12dp"
android:textAppearance="@style/picker_sb18"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="@+id/iv_thread_back_button"
app:layout_constraintEnd_toStartOf="@+id/spinner_thread"
app:layout_constraintStart_toEndOf="@+id/iv_thread_back_button"
app:layout_constraintTop_toTopOf="@+id/iv_thread_back_button"
app:layout_constraintBottom_toBottomOf="@id/iv_thread_back_button"
app:layout_constraintEnd_toStartOf="@id/spinner_thread"
app:layout_constraintStart_toEndOf="@id/iv_thread_back_button"
app:layout_constraintTop_toTopOf="@id/iv_thread_back_button"
tools:text="자두타먹는 스터디" />

<Spinner
Expand All @@ -46,7 +46,7 @@
android:popupBackground="#20232B"
android:popupElevation="10dp"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="@+id/iv_thread_back_button"
app:layout_constraintBottom_toBottomOf="@id/iv_thread_back_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/iv_thread_back_button" />

Expand All @@ -61,7 +61,7 @@
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iv_thread_back_button"
app:layout_constraintTop_toBottomOf="@id/iv_thread_back_button"
tools:listitem="@layout/item_thread_must_do" />

<androidx.recyclerview.widget.RecyclerView
Expand All @@ -75,7 +75,7 @@
app:layout_constraintBottom_toTopOf="@+id/view_thread_border"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rv_must_do"
app:layout_constraintTop_toBottomOf="@id/rv_must_do"
app:reverseLayout="true"
tools:itemCount="2"
tools:listitem="@layout/item_thread_comment" />
Expand All @@ -99,27 +99,30 @@
android:layout_marginBottom="12dp"
android:background="@drawable/bg_rectangle_radius_10dp_black02"
android:ems="10"
android:hint="잡담 및 질답하기"
android:inputType="text"
android:maxLength="200"
android:hint="@string/thread_input_hint"
android:inputType="textMultiLine"
android:maxLength="1000"
android:maxLines="4"
android:minHeight="40dp"
android:padding="8dp"
android:scrollbars="vertical"
android:textAppearance="@style/text_r16"
android:textColor="@color/white"
android:textColorHint="@color/grey02_78808B"
android:textCursorDrawable="@drawable/cursor_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_thread_direct_button"
app:layout_constraintEnd_toStartOf="@id/iv_thread_direct_button"
app:layout_constraintStart_toStartOf="parent" />

<ImageView
android:id="@+id/iv_thread_direct_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginBottom="12dp"
android:src="@drawable/icn_direct_message_btn"
app:layout_constraintBottom_toBottomOf="@+id/et_thread_input"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/et_thread_input" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
4 changes: 3 additions & 1 deletion android/app/src/main/res/layout/dialog_study_informaion.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,18 @@
android:layout_width="0dp"
android:layout_height="150dp"
android:layout_marginTop="20dp"
android:autoLink="email|web"
android:background="@drawable/bg_rectangle_radius_5dp"
android:padding="16dp"
android:text="@{studyDetail.introduction}"
android:textAppearance="@style/text_r16"
android:textColor="@color/white"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cl_study_information_header"
tools:text="안녕하세요 기깔나게 자바 스터디하실 분들 구합니다. 언제부터 할지는 미정인데요 미정이니? 어 잘지내? 음 .그렇구나 잘지내 " />

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
</layout>
2 changes: 2 additions & 0 deletions android/app/src/main/res/layout/item_home_study_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="20dp"
android:autoLink="email|web"
android:maxLines="2"
android:text="@{item.mustDo.blank ? @string/hom_study_list_must_do_default_message : item.mustDo}"
android:textAppearance="@style/text_r16"
android:textColor="@{item.mustDo.blank ? @color/grey06_30363D : @color/white}"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_home_study_list_must_do"
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/res/layout/item_thread_comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:maxLines="10"
android:autoLink="web|email"
android:text="@{item.content}"
android:textAppearance="@style/subtitle_r20"
android:textColor="@color/white"
Expand All @@ -105,7 +105,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cl_member_info"
tools:text="아아 언제다하냐 진짜 ㅋㅋ" />
tools:text="스터디 날짜가 언제인가요?" />

<View
android:id="@+id/view_thread_comment_border"
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@

<!-- 스레드 뷰 -->
<string name="thread_blank_input_toast_title">내용을 입력해 주세요</string>
<string name="thread_input_hint">잡담 및 질답하기</string>

<!-- 스레드 Must Do 바텀시트 다이얼로그 -->
<string name="thread_must_do_bottom_sheet_fragment_weeks">%d주차</string>
Expand Down
5 changes: 5 additions & 0 deletions android/app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

<!-- 바텀 시트 다이얼로그 스타일 적용 -->
<item name="bottomSheetDialogTheme">@style/BottomSheetDialogTheme</item>

<!-- Text, EditText 하이라이트 및 입력 커서 스타일 적용 -->
<item name="android:textColorLink">@color/green02_E639D353</item>
<item name="android:textColorHighlight">@color/green04_26A641</item>
<item name="colorControlActivated">@color/green04_26A641</item>
Comment on lines +20 to +22
Copy link
Member

Choose a reason for hiding this comment

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

이렇게 세부적으로 줄 수 있군요 배워갑니당

</style>

<style name="Theme.Team201" parent="Base.Theme.Team201" />
Expand Down