Flash Chat
Flash Chat is an android application. Let’s go on it and get how is working and which technologies used on it.
What is Flash Chat app?
Flash Chat is a messaging application. Which is developed in Android studio with Kotlin. You can Login and start chatting.
Which Technologies are used in this app?
- Animations
- View Binding
- MVVM
- Live Data
- Retrofit
- Moshi
- Firebase Authentication
- Firebase FireStore
- Recycler View
- Dynamic View Holder
- Navigation Graph
Usage of Animations
Get Abdulbasit ODUK’s stories in your inbox
Join Medium for free to get updates from this writer.
animator.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="2000"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
<translate
android:duration="2000"
android:fromYDelta="-100%"
android:toYDelta="0" />
</set>Typescript extension function
fun TextView.typeWrite(lifecycleOwner: LifecycleOwner, text: String, intervalMs: Long) {
this@typeWrite.text = ""
lifecycleOwner.lifecycleScope.launch {
repeat(text.length) {
delay(intervalMs)
this@typeWrite.text = text.take(it + 1)
}
}
}Usage of this animator.xml and typescript extension function in Fragment
val animationFadeIn = AnimationUtils.loadAnimation(this.requireContext(), R.anim.animator)
view.splashText.startAnimation(animationFadeIn)
view.splashText.typeWrite(viewLifecycleOwner, "Flash Chat", 300L)Usage of Firebase Authentication and Firebase FireStore:
We have to add Firebase Authentication and FireStore libraries to the build gradle files to use Firebase services.
// Firebase BoM
implementation platform('com.google.firebase:firebase-bom:31.2.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
// Firebase Authentication library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-auth-ktx'
// Declare the dependency for the Cloud Firestore library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-firestore-ktx'Firebase Authentication
We used Firebase Authentication to register the user to chat app. Let’s see how to save new user.
fun signUpNewUser(email: String, password: String){
try {
auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d("Status", "createUserWithEmail:success")
//updated live date accrding to resolt
_isUserCreatedSuccessfully.value = RegisterLoginUiState.SuccessfullyCreatedNewUser
} else {
// If sign in fails, display a message to the user.
_isUserCreatedSuccessfully.value = RegisterLoginUiState.FailedCreateNewUser("Register Failed. Please try Again")
}
}
}catch (e : Exception){
e.printStackTrace()
}
}Firebase FireStore
We used Firebase FireStore to save chat messages. Let’s see how to save new chat message.
@SuppressLint("NewApi")
fun sendMessage(messageText : String){
val simpleDateFormat = SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z")
val currentDateAndTime: String = simpleDateFormat.format(Date())
Log.d("Date", "$currentDateAndTime")
fireStore.collection("messages")
.add(mapOf("text" to messageText, "sender" to loggedUser.email, "date" to currentDateAndTime))
.addOnSuccessListener { documentReference ->
Log.d("Success", "DocumentSnapshot added with ID: ${documentReference.id}")
}
.addOnFailureListener { e ->
Log.w("Failure", "Error adding document", e)
}
}Finally our app is ready, you can find the project in link below:








