-
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.
- Loading branch information
1 parent
320b51c
commit 7970d26
Showing
39 changed files
with
2,574 additions
and
0 deletions.
There are no files selected for viewing
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,24 @@ | ||
package com.example.android.vedantsmessenger | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
|
||
class About_us : Fragment() { | ||
|
||
|
||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
val view = inflater.inflate(R.layout.fragment_about_us, container, false) | ||
|
||
return view ; | ||
} | ||
|
||
|
||
} |
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,81 @@ | ||
package com.example.android.vedantsmessenger | ||
|
||
import android.content.Intent | ||
import android.content.res.Configuration | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentActivity | ||
import androidx.viewpager2.adapter.FragmentStateAdapter | ||
import androidx.viewpager2.widget.ViewPager2 | ||
import com.google.android.material.tabs.TabLayout | ||
import com.google.android.material.tabs.TabLayoutMediator | ||
import com.google.firebase.auth.FirebaseAuth | ||
|
||
class AunthenticationActivity : AppCompatActivity(), FirebaseAuth.AuthStateListener { | ||
|
||
private lateinit var tab: TabLayout | ||
private lateinit var viewpager: ViewPager2 | ||
private lateinit var viewpageradapter: AuthenticationViewPager | ||
private var titles = arrayListOf("Sign Up", "Login") | ||
|
||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_aunthentication) | ||
|
||
tab = findViewById(R.id.tab_authentication) | ||
viewpager = findViewById(R.id.viewpager_authentication) | ||
viewpageradapter = AuthenticationViewPager(this) | ||
viewpager.adapter = viewpageradapter | ||
TabLayoutMediator(tab, viewpager) { tab, position -> | ||
tab.text = titles[position] | ||
|
||
|
||
}.attach() | ||
|
||
|
||
} | ||
|
||
class AuthenticationViewPager(fragmentActivity: FragmentActivity) : | ||
FragmentStateAdapter(fragmentActivity) { | ||
override fun getItemCount(): Int { | ||
return 2; | ||
} | ||
|
||
override fun createFragment(position: Int): Fragment { | ||
return when (position) { | ||
0 -> SignUp(); | ||
1 -> Login(); | ||
else -> SignUp(); | ||
} | ||
} | ||
|
||
} | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
FirebaseAuth.getInstance().addAuthStateListener(this) | ||
|
||
if (FirebaseAuth.getInstance().currentUser != null) | ||
|
||
startMainAct(); | ||
|
||
} | ||
|
||
override fun onAuthStateChanged(p0: FirebaseAuth) { | ||
if (p0.currentUser != null) { | ||
startMainAct(); | ||
} | ||
} | ||
|
||
override fun onStop() { | ||
super.onStop() | ||
FirebaseAuth.getInstance().removeAuthStateListener(this); | ||
} | ||
|
||
private fun startMainAct() { | ||
val intent = Intent(this@AunthenticationActivity, MainActivity::class.java) | ||
startActivity(intent); | ||
} | ||
} |
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,59 @@ | ||
package com.example.android.vedantsmessenger | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
|
||
// TODO: Rename parameter arguments, choose names that match | ||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER | ||
private const val ARG_PARAM1 = "param1" | ||
private const val ARG_PARAM2 = "param2" | ||
|
||
/** | ||
* A simple [Fragment] subclass. | ||
* Use the [Calls.newInstance] factory method to | ||
* create an instance of this fragment. | ||
*/ | ||
class Calls : Fragment() { | ||
// TODO: Rename and change types of parameters | ||
private var param1: String? = null | ||
private var param2: String? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
arguments?.let { | ||
param1 = it.getString(ARG_PARAM1) | ||
param2 = it.getString(ARG_PARAM2) | ||
} | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_calls, container, false) | ||
} | ||
|
||
companion object { | ||
/** | ||
* Use this factory method to create a new instance of | ||
* this fragment using the provided parameters. | ||
* | ||
* @param param1 Parameter 1. | ||
* @param param2 Parameter 2. | ||
* @return A new instance of fragment Calls. | ||
*/ | ||
// TODO: Rename and change types and number of parameters | ||
@JvmStatic | ||
fun newInstance(param1: String, param2: String) = | ||
Calls().apply { | ||
arguments = Bundle().apply { | ||
putString(ARG_PARAM1, param1) | ||
putString(ARG_PARAM2, param2) | ||
} | ||
} | ||
} | ||
} |
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,102 @@ | ||
package com.example.android.vedantsmessenger | ||
|
||
import android.app.Activity | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
const val SENDER = 1 | ||
const val RECEIVER = 2 | ||
const val MIDDLE = -1 | ||
|
||
class ChatAdapter(val context: Activity, val datalist: MutableList<Users>) : | ||
RecyclerView.Adapter<RecyclerView.ViewHolder>() { | ||
|
||
override fun getItemViewType(position: Int): Int { | ||
val obj = datalist[position] | ||
if (obj.pos == 1) return SENDER | ||
else if (obj.pos == 2) return RECEIVER | ||
else return MIDDLE | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { | ||
if (viewType == SENDER) { | ||
// right side pe | ||
val view = LayoutInflater.from(context).inflate(R.layout.sender_item, parent, false) | ||
val VIEW: senderVH = senderVH(view) | ||
return VIEW | ||
} else if (viewType == RECEIVER) { | ||
// left side pe | ||
val view = LayoutInflater.from(context).inflate(R.layout.receiver_item, parent, false) | ||
val VIEW: receiverVH = receiverVH(view) | ||
return VIEW | ||
} else { | ||
// bich me | ||
val view = LayoutInflater.from(context).inflate(R.layout.info_item, parent, false) | ||
val VIEW: info = info(view) | ||
return VIEW | ||
} | ||
|
||
} | ||
|
||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { | ||
if (getItemViewType(position) == SENDER) { | ||
val dataobj: Users = datalist[position] | ||
(holder as senderVH).bindDataSender(dataobj) | ||
} else if (getItemViewType(position) == RECEIVER) { | ||
|
||
(holder as receiverVH).bindDataReceiver(datalist[position]) | ||
} else { | ||
(holder as info).bindDataInfo(datalist[position]) | ||
} | ||
} | ||
|
||
// 3 viewtypes = 3 viewHolders! | ||
inner class senderVH(itemview: View) : RecyclerView.ViewHolder(itemview) { | ||
private lateinit var tv: TextView | ||
|
||
init { | ||
tv = itemview.findViewById(R.id.tvSender) | ||
} | ||
|
||
fun bindDataSender(obj: Users) { | ||
val name = obj.name | ||
val msg = obj.msg | ||
tv.text = "You: $msg" | ||
} | ||
} | ||
|
||
inner class receiverVH(itemview: View) : RecyclerView.ViewHolder(itemview) { | ||
private lateinit var tv: TextView | ||
|
||
init { | ||
tv = itemview.findViewById(R.id.tvReceiver) | ||
} | ||
|
||
fun bindDataReceiver(obj: Users) { | ||
val name = obj.name | ||
val msg = obj.msg | ||
tv.text = "${name}: $msg" | ||
} | ||
} | ||
|
||
inner class info(itemview: View) : RecyclerView.ViewHolder(itemview) { | ||
private lateinit var tv: TextView | ||
|
||
init { | ||
tv = itemview.findViewById(R.id.tvInfo) | ||
} | ||
|
||
fun bindDataInfo(obj: Users) { | ||
val name = obj.name | ||
val msg = obj.msg | ||
tv.text = "$name $msg" | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return datalist.size | ||
} | ||
} |
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,24 @@ | ||
package com.example.android.vedantsmessenger | ||
|
||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.widget.Button | ||
import android.widget.EditText | ||
|
||
class ChatApp : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_chat_app) | ||
val etEnterName = findViewById<EditText>(R.id.etEnterName) | ||
val etCode = findViewById<EditText>(R.id.etCode) | ||
val btnChat = findViewById<Button>(R.id.btnEnterRoom) | ||
btnChat.setOnClickListener { | ||
it.setBackgroundResource(R.drawable.btn_click_bg) | ||
val intent = Intent(this, ChatDashboard::class.java) | ||
intent.putExtra("NAME", etEnterName.text.toString().trim()) | ||
intent.putExtra("CODE", etCode.text.toString().trim()) | ||
startActivity(intent) | ||
} | ||
} | ||
} |
Oops, something went wrong.