Skip to content

Commit

Permalink
Merge pull request #27 from WonderWoman-Team/feature/26-채팅기능
Browse files Browse the repository at this point in the history
Feat #26: 채팅기능구현, fragment간 연결
  • Loading branch information
sominyun authored Aug 2, 2023
2 parents 94605e2 + 279ca41 commit 747d747
Show file tree
Hide file tree
Showing 25 changed files with 475 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 0 additions & 39 deletions app/google-services.json

This file was deleted.

20 changes: 7 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,20 @@
android:theme="@style/Theme.WonderWoman"
tools:targetApi="31">
<activity android:name=".Main1Activity" android:exported="true">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Main2Activity" android:exported="true"/>
<activity android:name=".LoginActivity" android:exported="true"/>
<activity android:name=".Login" android:exported="true"/>
<activity android:name=".Main2Activity" android:exported="true"/>
<activity android:name=".MainActivity" android:exported="true"/>
<activity android:name=".SchoolActivity" android:exported="true"/>
<activity android:name=".EmailActivity" android:exported="true"/>
<activity android:name=".PasswordActivity" android:exported="true"/>
<activity android:name=".NameActivity" android:exported="true"/>
<activity android:name=".CheckActivity" android:exported="true"/>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".delivery.PostActivity"/>
<meta-data
android:name="preloaded_fonts"
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/java/com/example/wonderwoman/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ package com.example.wonderwoman
import android.os.Bundle
import android.os.Binder
import android.os.PersistableBundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.wonderwoman.databinding.ActivityChatBinding
import com.example.wonderwoman.databinding.ActivityChatGuiBinding
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.*
import org.w3c.dom.Text

class ChatActivity : AppCompatActivity() {
private lateinit var receiverName: String
private lateinit var receiverUid: String

//바인딩 객체
private lateinit var binding: ActivityChatBinding
private lateinit var binding: ActivityChatGuiBinding

lateinit var mAuth: FirebaseAuth
lateinit var mDbRef: DatabaseReference
Expand All @@ -27,7 +30,7 @@ class ChatActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding= ActivityChatBinding.inflate(layoutInflater)
binding= ActivityChatGuiBinding.inflate(layoutInflater)
setContentView(binding.root)

//초기화
Expand Down Expand Up @@ -55,7 +58,15 @@ class ChatActivity : AppCompatActivity() {
receiverRoom=senderUid+receiverUid

//액션바에 상대방 이름 보여주기
supportActionBar?.title=receiverName
//supportActionBar?.title=receiverName


val supportaction = findViewById<TextView>(R.id.receive_name_id)
supportaction.text=receiverName

val supportaction2= findViewById<TextView>(R.id.receive_name_text)
supportaction2.text=receiverName


//메세지전송
binding.sendBtn.setOnClickListener{
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/wonderwoman/Login.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Login : AppCompatActivity() {

private lateinit var mDbRef: DatabaseReference

val name = "somin333"
val name = "익명3"
val email = "[email protected]"
val password = "somin455"

Expand Down Expand Up @@ -48,7 +48,7 @@ class Login : AppCompatActivity() {
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
val intent2: Intent = Intent(this,UserList::class.java)
val intent2: Intent = Intent(this,Main1Activity::class.java)
startActivity(intent2)
finish()
Toast.makeText(this,"로그인성공", Toast.LENGTH_SHORT).show()
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/example/wonderwoman/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class LoginActivity : AppCompatActivity() {
if(type.equals("success")){
dialog.setTitle("로그인 성공")
dialog.setMessage("로그인 성공!")
val intent: Intent = Intent(this,MainActivity::class.java)
startActivity(intent)
finish()
}
else if(type.equals("fail")){
dialog.setTitle("로그인 실패")
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/example/wonderwoman/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ class MainActivity : AppCompatActivity() {
writeBtn.visibility = View.VISIBLE
}
R.id.chat_menu -> {
chatFragment = ChatFragment.newInstance()
supportFragmentManager.beginTransaction().replace(R.id.fragment,chatFragment).commit()
val intent = Intent(this, UserList.newInstance()::class.java)
// startActivity(intent)
// writeBtn.visibility = View.INVISIBLE
// chatFragment = UserList.newInstance()
supportFragmentManager.beginTransaction().replace(R.id.fragment,UserList.newInstance()).commit()
writeBtn.visibility = View.INVISIBLE
}
R.id.mypage_menu -> {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/wonderwoman/UserAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

class UserAdapter (val context: Context, private val userList:ArrayList<User>):
RecyclerView.Adapter<UserAdapter.UserViewHolder>(){
RecyclerView.Adapter<UserAdapter.UserViewHolder>(){

//화면설정
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserViewHolder {
val view: View = LayoutInflater.from(context).
inflate(R.layout.activity_userlist_item,parent,false)
inflate(R.layout.activity_userlist_item_gui,parent,false)

return UserViewHolder(view)
}
Expand Down
32 changes: 23 additions & 9 deletions app/src/main/java/com/example/wonderwoman/UserList.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.example.wonderwoman

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.wonderwoman.databinding.ActivityUserlistBinding
import com.example.wonderwoman.databinding.ActivityUserlistGuiBinding
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.database.DataSnapshot
Expand All @@ -14,21 +19,30 @@ import com.google.firebase.database.ValueEventListener
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase

class UserList :AppCompatActivity() {
class UserList :Fragment() {

lateinit var binding: ActivityUserlistBinding
lateinit var binding: ActivityUserlistGuiBinding
lateinit var adapter: UserAdapter

lateinit var mAuth: FirebaseAuth
lateinit var mDbRef: DatabaseReference

lateinit var userList: ArrayList<User>

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding=ActivityUserlistBinding.inflate(layoutInflater)
setContentView(binding.root)

companion object {
fun newInstance() : UserList {
return UserList()
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = ActivityUserlistGuiBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//인증초기화
mAuth= Firebase.auth

Expand All @@ -39,9 +53,9 @@ class UserList :AppCompatActivity() {
userList=ArrayList()

//
adapter=UserAdapter(this,userList)
adapter=UserAdapter(context = requireContext(), userList = userList)

binding.userRecyclerview.layoutManager=LinearLayoutManager(this)
binding.userRecyclerview.layoutManager=LinearLayoutManager(requireContext())
binding.userRecyclerview.adapter=adapter

//사용자정보가져오기
Expand Down
Binary file added app/src/main/res/drawable/chat_announcement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/chat_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/chat_dot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/chat_ing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/chat_place.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/chat_send.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_chating_ing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions app/src/main/res/drawable/ic_userlist_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="360dp"
android:height="93dp"
android:viewportWidth="360"
android:viewportHeight="93"
>
<group>
<clip-path
android:pathData="M15 0H345C353.284 0 360 6.71573 360 15V78C360 86.2843 353.284 93 345 93H15C6.71573 93 0 86.2843 0 78V15C0 6.71573 6.71573 0 15 0Z"
/>
<path
android:pathData="M0 0V93H360V0"
android:fillColor="#FFFFFF"
/>
</group>
</vector>


10 changes: 6 additions & 4 deletions app/src/main/res/font/noto_sans.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Noto Sans"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="700"
android:font="@font/regular"/>

</font-family>

10 changes: 6 additions & 4 deletions app/src/main/res/font/noto_sans_bold.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="name=Noto Sans&amp;weight=700"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="700"
android:font="@font/bold"/>

</font-family>
Loading

0 comments on commit 747d747

Please sign in to comment.