From b9cb705a4fc9099e604d204fc7ed7e81456e60bf Mon Sep 17 00:00:00 2001 From: KKJ Date: Tue, 6 Feb 2024 14:03:27 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=EA=BF=80=ED=8C=81=20=EA=B3=B5?= =?UTF-8?q?=EC=9C=A0=ED=95=98=EA=B8=B0=20=ED=99=94=EB=A9=B4=20=EB=B0=B0?= =?UTF-8?q?=EB=84=88=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hometown/WriteCommunicationActivity.kt | 182 ++++----- .../hometown/WriteTogetherActivity.kt | 374 +++++++++--------- .../honeytip/ImageViewActivity.kt | 9 - .../honeytip/adapter/HoneyTipListRVA.kt | 3 +- .../res/layout/fragment_share_honey_tip.xml | 35 +- 5 files changed, 281 insertions(+), 322 deletions(-) diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationActivity.kt index 8fd012e0..d1736cf2 100644 --- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationActivity.kt +++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationActivity.kt @@ -1,92 +1,92 @@ -package com.umc.ttoklip.presentation.hometown - -import android.content.Context -import android.graphics.Rect -import android.net.Uri -import android.util.Log -import android.view.MotionEvent -import android.view.View -import android.view.inputmethod.InputMethodManager -import android.widget.EditText -import androidx.activity.result.PickVisualMediaRequest -import androidx.activity.result.contract.ActivityResultContracts -import com.umc.ttoklip.R -import com.umc.ttoklip.databinding.ActivityWriteCommunicationBinding -import com.umc.ttoklip.presentation.base.BaseActivity -import com.umc.ttoklip.presentation.honeytip.adapter.Image -import com.umc.ttoklip.presentation.honeytip.adapter.ImageRVA -import com.umc.ttoklip.presentation.honeytip.dialog.ImageDialogFragment -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class WriteCommunicationActivity : - BaseActivity(R.layout.activity_write_communication) { - private val imageAdapter by lazy { - ImageRVA() - } - - private val pickMultipleMedia = registerForActivityResult( - ActivityResultContracts.PickMultipleVisualMedia( - 100 - ) - ) { uris -> - if (uris.isNotEmpty()) { - updateImages(uris) - } else { - Log.d("PhotoPicker", "No media selected") - } - } - - override fun initView() { - initImageRVA() - addImage() - - binding.backBtn.setOnClickListener { - finish() - } - } - - override fun initObserver() { - - } - - private fun initImageRVA() { - binding.imageRv.adapter = imageAdapter - } - - private fun addImage() { - binding.addImageBtn.setOnClickListener { - val imageDialog = ImageDialogFragment() - imageDialog.setDialogClickListener(object : ImageDialogFragment.DialogClickListener { - override fun onClick() { - binding.imageRv.visibility = View.VISIBLE - pickMultipleMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) - } - }) - imageDialog.show(supportFragmentManager, imageDialog.tag) - } - } - - private fun updateImages(uriList: List) { - val images = uriList.map { Image(it) } - val updatedImages = imageAdapter.currentList.toMutableList().apply { addAll(images) } - imageAdapter.submitList(updatedImages) - } - - override fun dispatchTouchEvent(event: MotionEvent?): Boolean { - if (event?.action == MotionEvent.ACTION_DOWN) { - val v = currentFocus - if (v is EditText) { - val outRect = Rect() - v.getGlobalVisibleRect(outRect) - if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) { - v.clearFocus() - val imm: InputMethodManager = - getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - imm.hideSoftInputFromWindow(v.getWindowToken(), 0) - } - } - } - return super.dispatchTouchEvent(event) - } +package com.umc.ttoklip.presentation.hometown + +import android.content.Context +import android.graphics.Rect +import android.net.Uri +import android.util.Log +import android.view.MotionEvent +import android.view.View +import android.view.inputmethod.InputMethodManager +import android.widget.EditText +import androidx.activity.result.PickVisualMediaRequest +import androidx.activity.result.contract.ActivityResultContracts +import com.umc.ttoklip.R +import com.umc.ttoklip.databinding.ActivityWriteCommunicationBinding +import com.umc.ttoklip.presentation.base.BaseActivity +import com.umc.ttoklip.presentation.honeytip.adapter.Image +import com.umc.ttoklip.presentation.honeytip.adapter.ImageRVA +import com.umc.ttoklip.presentation.honeytip.dialog.ImageDialogFragment +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class WriteCommunicationActivity : + BaseActivity(R.layout.activity_write_communication) { + private val imageAdapter by lazy { + ImageRVA{} + } + + private val pickMultipleMedia = registerForActivityResult( + ActivityResultContracts.PickMultipleVisualMedia( + 100 + ) + ) { uris -> + if (uris.isNotEmpty()) { + updateImages(uris) + } else { + Log.d("PhotoPicker", "No media selected") + } + } + + override fun initView() { + initImageRVA() + addImage() + + binding.backBtn.setOnClickListener { + finish() + } + } + + override fun initObserver() { + + } + + private fun initImageRVA() { + binding.imageRv.adapter = imageAdapter + } + + private fun addImage() { + binding.addImageBtn.setOnClickListener { + val imageDialog = ImageDialogFragment() + imageDialog.setDialogClickListener(object : ImageDialogFragment.DialogClickListener { + override fun onClick() { + binding.imageRv.visibility = View.VISIBLE + pickMultipleMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) + } + }) + imageDialog.show(supportFragmentManager, imageDialog.tag) + } + } + + private fun updateImages(uriList: List) { + val images = uriList.map { Image(it) } + val updatedImages = imageAdapter.currentList.toMutableList().apply { addAll(images) } + imageAdapter.submitList(updatedImages) + } + + override fun dispatchTouchEvent(event: MotionEvent?): Boolean { + if (event?.action == MotionEvent.ACTION_DOWN) { + val v = currentFocus + if (v is EditText) { + val outRect = Rect() + v.getGlobalVisibleRect(outRect) + if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) { + v.clearFocus() + val imm: InputMethodManager = + getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(v.getWindowToken(), 0) + } + } + } + return super.dispatchTouchEvent(event) + } } \ No newline at end of file diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteTogetherActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteTogetherActivity.kt index f41c5eac..6b5fc467 100644 --- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteTogetherActivity.kt +++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteTogetherActivity.kt @@ -1,188 +1,188 @@ -package com.umc.ttoklip.presentation.hometown - -import android.content.Context -import android.content.Intent -import android.graphics.PorterDuff -import android.graphics.PorterDuffColorFilter -import android.graphics.Rect -import android.icu.text.DecimalFormat -import android.net.Uri -import android.util.Log -import android.view.MotionEvent -import android.view.View -import android.view.inputmethod.EditorInfo -import android.view.inputmethod.InputMethodManager -import android.widget.EditText -import androidx.activity.result.ActivityResultLauncher -import androidx.activity.result.PickVisualMediaRequest -import androidx.activity.result.contract.ActivityResultContracts -import com.umc.ttoklip.R -import com.umc.ttoklip.databinding.ActivityWriteTogetherBinding -import com.umc.ttoklip.presentation.base.BaseActivity -import com.umc.ttoklip.presentation.hometown.dialog.InputMaxMemberDialogFragment -import com.umc.ttoklip.presentation.honeytip.adapter.Image -import com.umc.ttoklip.presentation.honeytip.adapter.ImageRVA -import com.umc.ttoklip.presentation.honeytip.dialog.ImageDialogFragment -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class WriteTogetherActivity : - BaseActivity(R.layout.activity_write_together) { - private val activityResultLauncher: ActivityResultLauncher = - registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { - val addressIntent = it.data - addressIntent?.let { aIntent -> - val address = aIntent.getStringExtra("address") - val addressDetail = aIntent.getStringExtra("addressDetail") - binding.tradingPlaceTv.setTextColor(getColor(R.color.black)) - binding.tradingPlaceTv.compoundDrawables.forEach { drawable -> - if (drawable != null) { - drawable.colorFilter = - PorterDuffColorFilter(getColor(R.color.black), PorterDuff.Mode.SRC_IN) - } - } - binding.tradingPlaceTv.text = - StringBuilder().append(address).append(" ").append(addressDetail).toString() - } - } - private val imageAdapter by lazy { - ImageRVA() - } - - private val pickMultipleMedia = registerForActivityResult( - ActivityResultContracts.PickMultipleVisualMedia( - 100 - ) - ) { uris -> - if (uris.isNotEmpty()) { - updateImages(uris) - } else { - Log.d("PhotoPicker", "No media selected") - } - } - - override fun initView() { - initImageRVA() - addImage() - addLink() - binding.backBtn.setOnClickListener { - finish() - } - - binding.totalPriceTv.setOnEditorActionListener { v, actionId, event -> - var current = binding.totalPriceTv.text.toString() - if (current.contains(",")) { - current = current.replace(",", "") - } - if (actionId == EditorInfo.IME_ACTION_NEXT) { - Log.d("price", current) - if (current.length > 3) { - val currentAmount = AMOUNT_FORMAT.format(current.toLong()) - binding.totalPriceTv.setText(currentAmount) - binding.totalPriceTv.compoundDrawables.forEach { drawable -> - if (drawable != null) { - drawable.colorFilter = - PorterDuffColorFilter( - getColor(R.color.black), - PorterDuff.Mode.SRC_IN - ) - } - } - } - } - false - } - - binding.maxMemberTv.setOnClickListener { - val bottomSheet = InputMaxMemberDialogFragment { member -> - binding.maxMemberTv.text = getString(R.string.max_member_format, member) - binding.maxMemberTv.compoundDrawables.forEach { drawable -> - if (drawable != null) { - drawable.colorFilter = - PorterDuffColorFilter( - getColor(R.color.black), - PorterDuff.Mode.SRC_IN - ) - } - } - binding.maxMemberTv.hint = "" - } - bottomSheet.show(supportFragmentManager, bottomSheet.tag) - } - - binding.openChatLinkTv.setOnEditorActionListener { v, actionId, event -> - if (actionId == EditorInfo.IME_ACTION_NEXT) { - binding.openChatLinkTv.compoundDrawables.forEach { drawable -> - if (drawable != null) { - drawable.colorFilter = - PorterDuffColorFilter( - getColor(R.color.black), - PorterDuff.Mode.SRC_IN - ) - } - } - } - false - } - - binding.tradingPlaceTv.setOnClickListener { - val intent = Intent(this, TradeLocationActivity::class.java) - activityResultLauncher.launch(intent) - } - } - - override fun initObserver() { - - } - - private fun addLink() { - binding.addLinkBtn.setOnClickListener { - binding.addLinkBtn.visibility = View.GONE - binding.inputUrlBtn.visibility = View.VISIBLE - } - } - - private fun initImageRVA() { - binding.imageRv.adapter = imageAdapter - } - - private fun addImage() { - binding.addImageBtn.setOnClickListener { - val imageDialog = ImageDialogFragment() - imageDialog.setDialogClickListener(object : ImageDialogFragment.DialogClickListener { - override fun onClick() { - binding.imageRv.visibility = View.VISIBLE - pickMultipleMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) - } - }) - imageDialog.show(supportFragmentManager, imageDialog.tag) - } - } - - private fun updateImages(uriList: List) { - val images = uriList.map { Image(it) } - val updatedImages = imageAdapter.currentList.toMutableList().apply { addAll(images) } - imageAdapter.submitList(updatedImages) - } - - override fun dispatchTouchEvent(event: MotionEvent?): Boolean { - if (event?.action == MotionEvent.ACTION_DOWN) { - val v = currentFocus - if (v is EditText) { - val outRect = Rect() - v.getGlobalVisibleRect(outRect) - if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) { - v.clearFocus() - val imm: InputMethodManager = - getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - imm.hideSoftInputFromWindow(v.getWindowToken(), 0) - } - } - } - return super.dispatchTouchEvent(event) - } - - companion object { - private val AMOUNT_FORMAT = DecimalFormat("#,###") - } +package com.umc.ttoklip.presentation.hometown + +import android.content.Context +import android.content.Intent +import android.graphics.PorterDuff +import android.graphics.PorterDuffColorFilter +import android.graphics.Rect +import android.icu.text.DecimalFormat +import android.net.Uri +import android.util.Log +import android.view.MotionEvent +import android.view.View +import android.view.inputmethod.EditorInfo +import android.view.inputmethod.InputMethodManager +import android.widget.EditText +import androidx.activity.result.ActivityResultLauncher +import androidx.activity.result.PickVisualMediaRequest +import androidx.activity.result.contract.ActivityResultContracts +import com.umc.ttoklip.R +import com.umc.ttoklip.databinding.ActivityWriteTogetherBinding +import com.umc.ttoklip.presentation.base.BaseActivity +import com.umc.ttoklip.presentation.hometown.dialog.InputMaxMemberDialogFragment +import com.umc.ttoklip.presentation.honeytip.adapter.Image +import com.umc.ttoklip.presentation.honeytip.adapter.ImageRVA +import com.umc.ttoklip.presentation.honeytip.dialog.ImageDialogFragment +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class WriteTogetherActivity : + BaseActivity(R.layout.activity_write_together) { + private val activityResultLauncher: ActivityResultLauncher = + registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { + val addressIntent = it.data + addressIntent?.let { aIntent -> + val address = aIntent.getStringExtra("address") + val addressDetail = aIntent.getStringExtra("addressDetail") + binding.tradingPlaceTv.setTextColor(getColor(R.color.black)) + binding.tradingPlaceTv.compoundDrawables.forEach { drawable -> + if (drawable != null) { + drawable.colorFilter = + PorterDuffColorFilter(getColor(R.color.black), PorterDuff.Mode.SRC_IN) + } + } + binding.tradingPlaceTv.text = + StringBuilder().append(address).append(" ").append(addressDetail).toString() + } + } + private val imageAdapter by lazy { + ImageRVA{} + } + + private val pickMultipleMedia = registerForActivityResult( + ActivityResultContracts.PickMultipleVisualMedia( + 100 + ) + ) { uris -> + if (uris.isNotEmpty()) { + updateImages(uris) + } else { + Log.d("PhotoPicker", "No media selected") + } + } + + override fun initView() { + initImageRVA() + addImage() + addLink() + binding.backBtn.setOnClickListener { + finish() + } + + binding.totalPriceTv.setOnEditorActionListener { v, actionId, event -> + var current = binding.totalPriceTv.text.toString() + if (current.contains(",")) { + current = current.replace(",", "") + } + if (actionId == EditorInfo.IME_ACTION_NEXT) { + Log.d("price", current) + if (current.length > 3) { + val currentAmount = AMOUNT_FORMAT.format(current.toLong()) + binding.totalPriceTv.setText(currentAmount) + binding.totalPriceTv.compoundDrawables.forEach { drawable -> + if (drawable != null) { + drawable.colorFilter = + PorterDuffColorFilter( + getColor(R.color.black), + PorterDuff.Mode.SRC_IN + ) + } + } + } + } + false + } + + binding.maxMemberTv.setOnClickListener { + val bottomSheet = InputMaxMemberDialogFragment { member -> + binding.maxMemberTv.text = getString(R.string.max_member_format, member) + binding.maxMemberTv.compoundDrawables.forEach { drawable -> + if (drawable != null) { + drawable.colorFilter = + PorterDuffColorFilter( + getColor(R.color.black), + PorterDuff.Mode.SRC_IN + ) + } + } + binding.maxMemberTv.hint = "" + } + bottomSheet.show(supportFragmentManager, bottomSheet.tag) + } + + binding.openChatLinkTv.setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_NEXT) { + binding.openChatLinkTv.compoundDrawables.forEach { drawable -> + if (drawable != null) { + drawable.colorFilter = + PorterDuffColorFilter( + getColor(R.color.black), + PorterDuff.Mode.SRC_IN + ) + } + } + } + false + } + + binding.tradingPlaceTv.setOnClickListener { + val intent = Intent(this, TradeLocationActivity::class.java) + activityResultLauncher.launch(intent) + } + } + + override fun initObserver() { + + } + + private fun addLink() { + binding.addLinkBtn.setOnClickListener { + binding.addLinkBtn.visibility = View.GONE + binding.inputUrlBtn.visibility = View.VISIBLE + } + } + + private fun initImageRVA() { + binding.imageRv.adapter = imageAdapter + } + + private fun addImage() { + binding.addImageBtn.setOnClickListener { + val imageDialog = ImageDialogFragment() + imageDialog.setDialogClickListener(object : ImageDialogFragment.DialogClickListener { + override fun onClick() { + binding.imageRv.visibility = View.VISIBLE + pickMultipleMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) + } + }) + imageDialog.show(supportFragmentManager, imageDialog.tag) + } + } + + private fun updateImages(uriList: List) { + val images = uriList.map { Image(it) } + val updatedImages = imageAdapter.currentList.toMutableList().apply { addAll(images) } + imageAdapter.submitList(updatedImages) + } + + override fun dispatchTouchEvent(event: MotionEvent?): Boolean { + if (event?.action == MotionEvent.ACTION_DOWN) { + val v = currentFocus + if (v is EditText) { + val outRect = Rect() + v.getGlobalVisibleRect(outRect) + if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) { + v.clearFocus() + val imm: InputMethodManager = + getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(v.getWindowToken(), 0) + } + } + } + return super.dispatchTouchEvent(event) + } + + companion object { + private val AMOUNT_FORMAT = DecimalFormat("#,###") + } } \ No newline at end of file diff --git a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/ImageViewActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/honeytip/ImageViewActivity.kt index 2a61ad36..a75ea1be 100644 --- a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/ImageViewActivity.kt +++ b/app/src/main/java/com/umc/ttoklip/presentation/honeytip/ImageViewActivity.kt @@ -7,15 +7,6 @@ import com.umc.ttoklip.presentation.base.BaseActivity class ImageViewActivity: BaseActivity(R.layout.activity_image_view) { override fun initView() { - setSupportActionBar() - binding.root.setOnClickListener { - if(supportActionBar?.isShowing == true){ - supportActionBar?.hide() - } - else{ - supportActionBar?.show() - } - } } override fun initObserver() { diff --git a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/adapter/HoneyTipListRVA.kt b/app/src/main/java/com/umc/ttoklip/presentation/honeytip/adapter/HoneyTipListRVA.kt index 8851b303..793a13bb 100644 --- a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/adapter/HoneyTipListRVA.kt +++ b/app/src/main/java/com/umc/ttoklip/presentation/honeytip/adapter/HoneyTipListRVA.kt @@ -6,6 +6,7 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.umc.ttoklip.databinding.ItemListHoneyTipBinding +import java.io.Serializable class HoneyTipListRVA(private var listener: OnItemClickListener): ListAdapter(object: DiffUtil.ItemCallback(){ override fun areItemsTheSame(oldItem: HoneyTips, newItem: HoneyTips): Boolean { @@ -54,4 +55,4 @@ data class HoneyTips( var body: String, var date: String, var chatCnt: Int = 0, -) \ No newline at end of file +): Serializable \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_share_honey_tip.xml b/app/src/main/res/layout/fragment_share_honey_tip.xml index 443a1fb7..978c8c61 100644 --- a/app/src/main/res/layout/fragment_share_honey_tip.xml +++ b/app/src/main/res/layout/fragment_share_honey_tip.xml @@ -11,50 +11,17 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - - + app:layout_constraintTop_toTopOf="parent" /> Date: Tue, 6 Feb 2024 14:20:44 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20fragment=20news=20banner=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/fragment_news.xml | 424 +++++++++++----------- 1 file changed, 211 insertions(+), 213 deletions(-) diff --git a/app/src/main/res/layout/fragment_news.xml b/app/src/main/res/layout/fragment_news.xml index 598615e2..923c1caf 100644 --- a/app/src/main/res/layout/fragment_news.xml +++ b/app/src/main/res/layout/fragment_news.xml @@ -1,214 +1,212 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file