-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] #146 Add Leave Chat & Report User
- Loading branch information
Showing
11 changed files
with
238 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/src/main/java/com/infra/infraandroid/chat/view/LeaveChatRoomDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="16dp" | ||
android:height="20dp" | ||
android:viewportWidth="16" | ||
android:viewportHeight="20"> | ||
<path | ||
android:pathData="M0,10C0,10.2652 0.1054,10.5196 0.2929,10.7071C0.4804,10.8946 0.7348,11 1,11H8.59L6.29,13.29C6.1963,13.383 6.1219,13.4936 6.0711,13.6154C6.0203,13.7373 5.9942,13.868 5.9942,14C5.9942,14.132 6.0203,14.2627 6.0711,14.3846C6.1219,14.5064 6.1963,14.617 6.29,14.71C6.383,14.8037 6.4936,14.8781 6.6154,14.9289C6.7373,14.9797 6.868,15.0058 7,15.0058C7.132,15.0058 7.2627,14.9797 7.3846,14.9289C7.5064,14.8781 7.617,14.8037 7.71,14.71L11.71,10.71C11.801,10.6149 11.8724,10.5028 11.92,10.38C12.02,10.1365 12.02,9.8635 11.92,9.62C11.8724,9.4972 11.801,9.3851 11.71,9.29L7.71,5.29C7.6168,5.1968 7.5061,5.1228 7.3843,5.0723C7.2624,5.0219 7.1319,4.9959 7,4.9959C6.8681,4.9959 6.7376,5.0219 6.6157,5.0723C6.4939,5.1228 6.3832,5.1968 6.29,5.29C6.1968,5.3832 6.1228,5.4939 6.0723,5.6157C6.0219,5.7376 5.9959,5.8681 5.9959,6C5.9959,6.1319 6.0219,6.2624 6.0723,6.3843C6.1228,6.5061 6.1968,6.6168 6.29,6.71L8.59,9H1C0.7348,9 0.4804,9.1054 0.2929,9.2929C0.1054,9.4804 0,9.7348 0,10ZM13,0H3C2.2043,0 1.4413,0.3161 0.8787,0.8787C0.3161,1.4413 0,2.2043 0,3V6C0,6.2652 0.1054,6.5196 0.2929,6.7071C0.4804,6.8946 0.7348,7 1,7C1.2652,7 1.5196,6.8946 1.7071,6.7071C1.8946,6.5196 2,6.2652 2,6V3C2,2.7348 2.1054,2.4804 2.2929,2.2929C2.4804,2.1054 2.7348,2 3,2H13C13.2652,2 13.5196,2.1054 13.7071,2.2929C13.8946,2.4804 14,2.7348 14,3V17C14,17.2652 13.8946,17.5196 13.7071,17.7071C13.5196,17.8946 13.2652,18 13,18H3C2.7348,18 2.4804,17.8946 2.2929,17.7071C2.1054,17.5196 2,17.2652 2,17V14C2,13.7348 1.8946,13.4804 1.7071,13.2929C1.5196,13.1054 1.2652,13 1,13C0.7348,13 0.4804,13.1054 0.2929,13.2929C0.1054,13.4804 0,13.7348 0,14V17C0,17.7956 0.3161,18.5587 0.8787,19.1213C1.4413,19.6839 2.2043,20 3,20H13C13.7956,20 14.5587,19.6839 15.1213,19.1213C15.6839,18.5587 16,17.7956 16,17V3C16,2.2043 15.6839,1.4413 15.1213,0.8787C14.5587,0.3161 13.7956,0 13,0Z" | ||
android:fillColor="#ffffff"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="20dp" | ||
android:height="20dp" | ||
android:viewportWidth="20" | ||
android:viewportHeight="20"> | ||
<path | ||
android:pathData="M17,0H3C2.2043,0 1.4413,0.3161 0.8787,0.8787C0.3161,1.4413 0,2.2043 0,3V12.9998C0,13.7955 0.3161,14.5585 0.8787,15.1211C1.4413,15.6837 2.2043,15.9998 3,15.9998H14.59L18.29,19.7097C18.3834,19.8024 18.4943,19.8757 18.6161,19.9255C18.7379,19.9753 18.8684,20.0005 19,19.9997C19.1312,20.0031 19.2613,19.9757 19.38,19.9197C19.5626,19.8447 19.7189,19.7173 19.8293,19.5536C19.9396,19.3899 19.999,19.1972 20,18.9997V3C20,2.2043 19.6839,1.4413 19.1213,0.8787C18.5587,0.3161 17.7956,0 17,0ZM18,16.5898L15.71,14.2898C15.6166,14.1971 15.5057,14.1238 15.3839,14.074C15.2621,14.0243 15.1316,13.999 15,13.9998H3C2.7348,13.9998 2.4804,13.8944 2.2929,13.7069C2.1054,13.5194 2,13.265 2,12.9998V3C2,2.7348 2.1054,2.4804 2.2929,2.2929C2.4804,2.1053 2.7348,2 3,2H17C17.2652,2 17.5196,2.1053 17.7071,2.2929C17.8946,2.4804 18,2.7348 18,3V16.5898ZM10,9.9999C9.8022,9.9999 9.6089,10.0585 9.4444,10.1684C9.28,10.2783 9.1518,10.4344 9.0761,10.6172C9.0004,10.7999 8.9806,11.001 9.0192,11.1949C9.0578,11.3889 9.153,11.5671 9.2929,11.7069C9.4327,11.8468 9.6109,11.942 9.8049,11.9806C9.9989,12.0192 10.2,11.9994 10.3827,11.9237C10.5654,11.848 10.7216,11.7199 10.8315,11.5554C10.9414,11.391 11,11.1976 11,10.9998C11,10.7346 10.8946,10.4803 10.7071,10.2927C10.5196,10.1052 10.2652,9.9999 10,9.9999ZM10,3.9999C9.7348,3.9999 9.4804,4.1053 9.2929,4.2928C9.1054,4.4804 9,4.7347 9,4.9999V7.9999C9,8.2651 9.1054,8.5195 9.2929,8.707C9.4804,8.8945 9.7348,8.9999 10,8.9999C10.2652,8.9999 10.5196,8.8945 10.7071,8.707C10.8946,8.5195 11,8.2651 11,7.9999V4.9999C11,4.7347 10.8946,4.4804 10.7071,4.2928C10.5196,4.1053 10.2652,3.9999 10,3.9999Z" | ||
android:fillColor="#ffffff"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="200dp" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_marginHorizontal="20dp" | ||
android:background="@drawable/warning_background" | ||
tools:context="com.infra.infraandroid.chat.view.LeaveChatRoomDialog"> | ||
|
||
<ImageView | ||
android:id="@+id/warning_red_iv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:src="@drawable/ic_warning_red" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
android:layout_marginTop="21dp"/> | ||
<TextView | ||
android:id="@+id/warning_team_mem_name_tv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="정말로 채팅방을 나가시겠습니까?" | ||
android:fontFamily="@font/noto_sans_kr_medium" | ||
android:textSize="15sp" | ||
android:textColor="@color/black" | ||
android:includeFontPadding="false" | ||
android:layout_marginTop="15dp" | ||
app:layout_constraintTop_toBottomOf="@+id/warning_red_iv" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_chainStyle="packed"/> | ||
|
||
<TextView | ||
android:id="@+id/warning_delete_project_tv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="채팅방을 나갈 시 채팅 기록이 모두 삭제됩니다." | ||
android:fontFamily="@font/noto_sans_kr_medium" | ||
android:textSize="10sp" | ||
android:textColor="@color/infra_light_gray_e" | ||
android:includeFontPadding="false" | ||
android:layout_marginTop="4dp" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/warning_team_mem_name_tv" | ||
app:layout_constraintHorizontal_chainStyle="packed"/> | ||
|
||
<TextView | ||
android:id="@+id/warning_okay_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="확인" | ||
android:background="@drawable/warning_button_red_background" | ||
android:paddingVertical="9dp" | ||
android:paddingHorizontal="25dp" | ||
android:textSize="14sp" | ||
android:fontFamily="@font/noto_sans_kr_medium" | ||
android:textColor="@color/white" | ||
android:includeFontPadding="false" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:layout_marginBottom="33dp" | ||
android:layout_marginTop="22dp" | ||
android:layout_marginLeft="54dp" | ||
app:layout_constraintRight_toLeftOf="@id/warning_cancel_button" | ||
app:layout_constraintTop_toBottomOf="@id/warning_delete_project_tv"/> | ||
<TextView | ||
android:id="@+id/warning_cancel_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="취소" | ||
android:background="@drawable/warning_button_light_red_background" | ||
android:paddingVertical="9dp" | ||
android:paddingHorizontal="25dp" | ||
android:textSize="14sp" | ||
android:fontFamily="@font/noto_sans_kr_medium" | ||
android:textColor="@color/infra_red_b" | ||
android:includeFontPadding="false" | ||
android:layout_marginRight="54dp" | ||
app:layout_constraintLeft_toRightOf="@id/warning_okay_button" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="@id/warning_okay_button"/> | ||
|
||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters