diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index b71f718..9f2134d 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -1,17 +1,17 @@ - + - + - - + + - - + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 4fe7e5c..2fcba98 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,7 +16,7 @@ android { applicationId "com.infra.infraandroid" minSdk 23 targetSdk 31 - versionCode 2 + versionCode 3 versionName "1.1" buildConfigField("String", "WEB_CLIENT_ID", '"953936170275-n0h7o7932npcdaa9n0e97ihuruugspeg.apps.googleusercontent.com"') testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' diff --git a/app/release/app-release.aab b/app/release/app-release.aab index 26d2003..fc1b2da 100644 Binary files a/app/release/app-release.aab and b/app/release/app-release.aab differ diff --git a/app/src/main/java/com/infra/infraandroid/chat/view/ChatFragment.kt b/app/src/main/java/com/infra/infraandroid/chat/view/ChatFragment.kt index b647157..974a4cb 100644 --- a/app/src/main/java/com/infra/infraandroid/chat/view/ChatFragment.kt +++ b/app/src/main/java/com/infra/infraandroid/chat/view/ChatFragment.kt @@ -1,5 +1,8 @@ package com.infra.infraandroid.chat.view +import android.annotation.SuppressLint +import android.content.Intent +import android.net.Uri import android.os.Bundle import android.util.Log import android.view.LayoutInflater @@ -9,6 +12,7 @@ import android.widget.ImageButton import android.widget.Toast import androidx.fragment.app.Fragment import androidx.navigation.findNavController +import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.infra.infraandroid.util.InfraApplication import com.infra.infraandroid.R @@ -44,6 +48,7 @@ class ChatFragment : Fragment() { return mBinding?.root } + @SuppressLint("SimpleDateFormat") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -140,7 +145,8 @@ class ChatFragment : Fragment() { if(chatRoomIndex==null){ var i = 0 for(chatIndex in snapshot.children){ - i += 1 + Log.d(TAG, "채팅방번호 ${chatIndex.key}") + i = chatIndex.key.toString().toInt() if(chatIndex.child("users").child("user1").value.toString()==opponentNickName && chatIndex.child("users").child("user2").value.toString()==InfraApplication.prefs.getString("userNickName", "null")){ chatRoomIndex = i @@ -219,6 +225,16 @@ class ChatFragment : Fragment() { mBinding?.backToChatListButton?.setOnClickListener { it.findNavController().navigate(R.id.action_chat_fragment_to_chatting_room_list_fragment) } + + mBinding?.reportChatImageButton?.setOnClickListener { + val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://docs.google.com/forms/d/e/1FAIpQLSeiWgqtOehxOe-YCDpn5mFca9bWK3NcxfyVRC2O56xvz4xeLw/viewform?usp=sf_link")) + startActivity(intent) + } + + mBinding?.leaveChatImageButton?.setOnClickListener { + val warningDialog = LeaveChatRoomDialog(chatRoomIdx = chatRoomIndex.toString()) + activity?.supportFragmentManager?.let{it1 -> warningDialog.show(it1, warningDialog.tag)} + } } override fun onDestroyView() { diff --git a/app/src/main/java/com/infra/infraandroid/chat/view/LeaveChatRoomDialog.kt b/app/src/main/java/com/infra/infraandroid/chat/view/LeaveChatRoomDialog.kt new file mode 100644 index 0000000..78cb107 --- /dev/null +++ b/app/src/main/java/com/infra/infraandroid/chat/view/LeaveChatRoomDialog.kt @@ -0,0 +1,74 @@ +package com.infra.infraandroid.chat.view + +import android.content.res.Resources +import android.graphics.Rect +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.DialogFragment +import androidx.lifecycle.ViewModelProvider +import androidx.navigation.fragment.findNavController +import com.google.firebase.database.ktx.database +import com.google.firebase.ktx.Firebase +import com.infra.infraandroid.R +import com.infra.infraandroid.databinding.LeaveChatRoomDialogBinding +import com.infra.infraandroid.databinding.MyInfoMyProjectDeleteWarningBinding +import com.infra.infraandroid.myinfo.myideamanage.model.MyProjectViewModel + + +class LeaveChatRoomDialog(val chatRoomIdx : String) : DialogFragment() { + private lateinit var viewModel : MyProjectViewModel + private var mBinding : LeaveChatRoomDialogBinding? = null + private val database = Firebase.database + private val mRef = database.getReference("chatting") + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + activity?.run{ + viewModel = ViewModelProvider(this, ViewModelProvider.NewInstanceFactory()) + .get(MyProjectViewModel::class.java) + } + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + val binding = LeaveChatRoomDialogBinding.inflate(inflater, container, false) + mBinding = binding + + return mBinding?.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + mBinding?.warningOkayButton?.setOnClickListener { + mRef.child(chatRoomIdx).removeValue() + dismiss() + findNavController().navigate(R.id.action_chat_fragment_to_chatting_room_list_fragment) + } + + mBinding?.warningCancelButton?.setOnClickListener { + dismiss() + } + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + + setWidthPercent(90) + } + + fun DialogFragment.setWidthPercent(percentage: Int) { + val percent = percentage.toFloat() / 100 + val dm = Resources.getSystem().displayMetrics + val rect = dm.run { Rect(0, 0, widthPixels, heightPixels) } + val percentWidth = rect.width() * percent + dialog?.window?.setLayout(percentWidth.toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) + dialog?.window?.setBackgroundDrawableResource(R.drawable.warning_background) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/infra/infraandroid/util/SplashFragment.kt b/app/src/main/java/com/infra/infraandroid/util/SplashFragment.kt index b8a7de8..5e9138f 100644 --- a/app/src/main/java/com/infra/infraandroid/util/SplashFragment.kt +++ b/app/src/main/java/com/infra/infraandroid/util/SplashFragment.kt @@ -38,7 +38,7 @@ class SplashFragment : BaseFragment(R.layout.fragment_spl InfraApplication.prefs.setString("userId", response.body()?.result?.userId.toString()) InfraApplication.prefs.setString("userNickName", response.body()?.result?.userNickName.toString()) InfraApplication.prefs.setString("userProfileImg", response.body()?.result?.userProfileImg.toString()) - Toast.makeText(requireActivity(),"요청에 성공하셨습니다.", Toast.LENGTH_SHORT).show() + Toast.makeText(requireActivity(),"인프라에 오신걸 환영합니다 :)", Toast.LENGTH_SHORT).show() // 로그인 버튼을 누르면 home_fragment로 이동 findNavController().navigate(R.id.action_splashFragment_to_home_fragment) } diff --git a/app/src/main/res/drawable/ic_leave_chat.xml b/app/src/main/res/drawable/ic_leave_chat.xml new file mode 100644 index 0000000..770f862 --- /dev/null +++ b/app/src/main/res/drawable/ic_leave_chat.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_report.xml b/app/src/main/res/drawable/ic_report.xml new file mode 100644 index 0000000..c7c97e5 --- /dev/null +++ b/app/src/main/res/drawable/ic_report.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_chat.xml b/app/src/main/res/layout/fragment_chat.xml index 9b2661d..5282945 100644 --- a/app/src/main/res/layout/fragment_chat.xml +++ b/app/src/main/res/layout/fragment_chat.xml @@ -43,6 +43,30 @@ app:layout_constraintBottom_toBottomOf="@id/back_to_chat_list_button" app:layout_constraintLeft_toRightOf="@id/back_to_chat_list_button"/> + + diff --git a/app/src/main/res/layout/leave_chat_room_dialog.xml b/app/src/main/res/layout/leave_chat_room_dialog.xml new file mode 100644 index 0000000..d585ec5 --- /dev/null +++ b/app/src/main/res/layout/leave_chat_room_dialog.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 4d4dd95..6a04b77 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -440,6 +440,15 @@ android:id="@+id/action_myIdeaCategoryModifyFragment_to_myInfoProjectModifyFragment" app:destination="@id/myInfoProjectModifyFragment" /> + + + \ No newline at end of file