Chat App
Submitted in partial fulfilment of the requirements of the degree
BACHELOR OF ENGINEERING IN
COMPUTER ENGINEERING
By
Pradnyeel Patil (49)
Raj Patil(50)
Abhishake Kate (37 )
Supervisor
Prof. Shilpa Tandale
Department of COMPUTER ENGINEERING
A. C. Patil College of Engineering
Kharghar, Navi Mumbai
University of Mumbai
(AY 2024-25)
Introduction
A Chat Application is a real-time communication platform that allows users to send and receive messages
instantly over the internet. In this project, we have developed a modern Android-based chat application
using Java and Firebase.
The application provides features such as user authentication, real-time messaging, user profiles, and
contact management. Users can create accounts, search for other users, and initiate conversations
seamlessly.
This project helps in understanding concepts like real-time databases, cloud storage, UI/UX design, and
client-server communication.
Algorithm and Process Design
Step 1: User Registration
• Input name, email, password
• Store in Firebase Authentication
Step 2: Login
• Verify credentials
• Redirect to home screen
Step 3: Search Users
• Fetch users from database
• Display in contact list
Step 4: Send Message
• User types message
• Message stored in database
Step 5: Receive Message
• Real-time listener fetches new messages
• Display instantly
Step 6: Profile Management
• Update name, bio, profile image
CODE:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class GameActivity extends AppCompatActivity {
private Button[][] buttons = new Button[3][3];
private TextView tvTurn;
private boolean playerXTurn = true;
private int moveCount = 0;
private boolean gameActive = true;
private AlertDialog resultDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_game);
tvTurn = findViewById([Link]);
// Initialize buttons
initializeButtons();
Button btnReset = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
resetGame();
}
});
}
private void initializeButtons() {
buttons[0][0] = findViewById([Link].btn00);
buttons[0][1] = findViewById([Link].btn01);
buttons[0][2] = findViewById([Link].btn02);
buttons[1][0] = findViewById([Link].btn10);
buttons[1][1] = findViewById([Link].btn11);
buttons[1][2] = findViewById([Link].btn12);
buttons[2][0] = findViewById([Link].btn20);
buttons[2][1] = findViewById([Link].btn21);
buttons[2][2] = findViewById([Link].btn22);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
buttons[i][j].setOnClickListener(new ButtonClickListener(i, j));
}
}
}
private void showResultPopup(String title, String message, String emoji) {
// Create custom dialog view
View dialogView = [Link](this).inflate([Link].dialog_result, null);
TextView tvTitle = [Link]([Link]);
TextView tvMessage = [Link]([Link]);
TextView tvEmoji = [Link]([Link]);
[Link](title);
[Link](message);
[Link](emoji);
[Link] builder = new [Link](this);
[Link](dialogView);
[Link](true); // Allow dismissing by tapping outside
resultDialog = [Link]();
// Set background transparent
if ([Link]() != null) {
[Link]().setBackgroundDrawableResource([Link]);
// Add animation to the dialog window
[Link]().getAttributes().windowAnimations =
[Link].Animation_Dialog;
}
[Link]();
// REMOVED the auto-dismiss delay logic
// The popup will now stay until user taps anywhere outside
}
private class ButtonClickListener implements [Link] {
private int row, col;
ButtonClickListener(int row, int col) {
[Link] = row;
[Link] = col;
}
@Override
public void onClick(View v) {
if (gameActive && buttons[row][col].getText().toString().isEmpty()) {
if (playerXTurn) {
buttons[row][col].setText("X");
buttons[row][col].setTextColor([Link]([Link],
[Link]));
buttons[row][col].setTextSize(48);
} else {
buttons[row][col].setText("O");
buttons[row][col].setTextColor([Link]([Link],
[Link]));
buttons[row][col].setTextSize(48);
}
moveCount++;
if (checkWin()) {
if (playerXTurn) {
showResultPopup("VICTORY!", "Player X Wins the Game!", " ");
[Link]("Player X Wins!");
} else {
showResultPopup("VICTORY!", "Player O Wins the Game!", " ");
[Link]("Player O Wins!");
}
gameActive = false;
} else if (moveCount == 9) {
showResultPopup("DRAW!", "It's a Tie Game!", " ");
[Link]("Game Draw!");
gameActive = false;
} else {
playerXTurn = !playerXTurn;
if (playerXTurn) {
[Link]("Player X's Turn");
} else {
[Link]("Player O's Turn");
}
}
}
}
}
private boolean checkWin() {
return checkRows() || checkColumns() || checkDiagonals();
}
private boolean checkRows() {
for (int i = 0; i < 3; i++) {
if (!buttons[i][0].getText().toString().isEmpty() &&
buttons[i][0].getText().toString().equals(buttons[i][1].getText().toString()) &&
buttons[i][1].getText().toString().equals(buttons[i][2].getText().toString())) {
return true;
}
}
return false;
}
private boolean checkColumns() {
for (int j = 0; j < 3; j++) {
if (!buttons[0][j].getText().toString().isEmpty() &&
buttons[0][j].getText().toString().equals(buttons[1][j].getText().toString()) &&
buttons[1][j].getText().toString().equals(buttons[2][j].getText().toString())) {
return true;
}
}
return false;
}
private boolean checkDiagonals() {
if (!buttons[0][0].getText().toString().isEmpty() &&
buttons[0][0].getText().toString().equals(buttons[1][1].getText().toString()) &&
buttons[1][1].getText().toString().equals(buttons[2][2].getText().toString())) {
return true;
}
if (!buttons[0][2].getText().toString().isEmpty() &&
buttons[0][2].getText().toString().equals(buttons[1][1].getText().toString()) &&
buttons[1][1].getText().toString().equals(buttons[2][0].getText().toString())) {
return true;
}
return false;
}
private void resetGame() {
// Clear all buttons
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
buttons[i][j].setText("");
buttons[i][j].setTextSize(48);
}
}
// Reset game state
playerXTurn = true;
moveCount = 0;
gameActive = true;
[Link]("Player X's Turn");
// Dismiss dialog if showing
if (resultDialog != null && [Link]()) {
[Link]();
}
}
@Override
protected void onDestroy() {
[Link]();
// Clean up dialog to prevent memory leaks
if (resultDialog != null && [Link]()) {
[Link]();
}
}
}
Output :
Conclusion:
The Chat Application project demonstrates how real-time communication systems work
using modern technologies like Firebase and Android development.
It helped in understanding:
• Cloud-based databases
• Real-time data synchronisation
• User authentication systems
• Mobile UI/UX design
This project can be further enhanced by adding features like voice calls, video calls, and
advanced security.
References:
[Link]
[Link]
[Link]