{"id":22336741,"url":"https://github.com/kavicastelo/chat_app","last_synced_at":"2025-03-26T08:21:19.426Z","repository":{"id":159383962,"uuid":"578732706","full_name":"kavicastelo/Chat_app","owner":"kavicastelo","description":"This is a text-based chat application(emojis and stickers are in development). users can sign up to the system using an image, username, email, and password. they can use email and password for the login. after login or signup, users navigate to the chat dashboard.","archived":false,"fork":false,"pushed_at":"2023-10-08T19:36:54.000Z","size":211,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T09:42:56.238Z","etag":null,"topics":["android","chat-application","firebase","java","online","social-media"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kavicastelo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-12-15T18:51:39.000Z","updated_at":"2023-10-07T22:13:31.000Z","dependencies_parsed_at":"2023-06-12T11:30:44.761Z","dependency_job_id":null,"html_url":"https://github.com/kavicastelo/Chat_app","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kavicastelo%2FChat_app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kavicastelo%2FChat_app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kavicastelo%2FChat_app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kavicastelo%2FChat_app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kavicastelo","download_url":"https://codeload.github.com/kavicastelo/Chat_app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245615103,"owners_count":20644391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","chat-application","firebase","java","online","social-media"],"created_at":"2024-12-04T06:07:53.356Z","updated_at":"2025-03-26T08:21:19.400Z","avatar_url":"https://github.com/kavicastelo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Technical Documentation:\n\n## 1. Introduction:\n\nThis is a text-based chat application(emojis and stickers are in development). users can sign up to the system using an\nimage, username, email, and password. they can use email and password for the login. after login or signup, users\nnavigate to the chat dashboard.\n\n- Version number: **1.0.0**\n- Platform: **Android**\n- Language: **Java**\n- JDK: **17**\n- SDK: **Up to Android 5**\n- Database: **Firebase**\n- IDE: **Android Studio**\n- Type: **Online social media**\n- Users Coverage: **Small**\n\n## 2. Architecture:\n\nThe Chat Application is an **android** base application built using **Java**. It follows a client-server architecture.\n\n## 3. Authentication:\n\n### Sign Up:\n\nUsers can sign up for the application using the following information\n\n- Username: This will show to the others\n- Email: One email can register once only\n- Password: Use strong password\n- Re-password: Verify the password\n\n### Sign In:\n\nUse the following information to log in to the system\n\n- Email: Use registered email\n- Password: Use the correct password according above email\n\nUsed Firebase Firestore to store user data. Images are encoded to String using Bitmap.\n\n```groovy\nFirebaseFirestore db = FirebaseFirestore.getInstance();\nHashMap\u003cString, Object\u003e user = new HashMap\u003c\u003e();\nuser.put(Constants.KEY_NAME, binding.inputName.getText().toString());\nuser.put(Constants.KEY_EMAIL, binding.inputEmail.getText().toString());\nuser.put(Constants.KEY_PASSWORD, binding.inputPassword.getText().toString());\nuser.put(Constants.KEY_IMAGE, encodedImg);\ndb.collection(Constants.KEY_COLLECTION_USERS)\n        .add(user)\n        .addOnSuccessListener(documentReference -\u003e {\n            preManager.putBoolean(Constants.KEY_IS_SIGNED_IN, true);\n            preManager.putString(Constants.KEY_USER_ID, documentReference.getId());\n            preManager.putString(Constants.KEY_NAME, binding.inputName.getText().toString());\n            preManager.putString(Constants.KEY_IMAGE, encodedImg);\n            Intent i = new Intent(getApplicationContext(), MainActivity.class);\n            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);\n            startActivity(i);\n        })\n        .addOnFailureListener(exception -\u003e {\n            showToasts(exception.getMessage());\n        });\n```\n\n```groovy\nFirebaseFirestore db = FirebaseFirestore.getInstance();\ndb.collection(Constants.KEY_COLLECTION_USERS)\n        .whereEqualTo(Constants.KEY_EMAIL, binding.inputEmail.getText().toString())\n        .whereEqualTo(Constants.KEY_PASSWORD, binding.inputPassword.getText().toString())\n        .get()\n        .addOnCompleteListener(task -\u003e {\n            if (task.isSuccessful() \u0026\u0026 task.getResult() != null \u0026\u0026 task.getResult().getDocuments().size() \u003e 0) {\n                DocumentSnapshot documentSnapshot = task.getResult().getDocuments().get(0);\n                preManager.putBoolean(Constants.KEY_IS_SIGNED_IN, true);\n                preManager.putString(Constants.KEY_USER_ID, documentSnapshot.getId());\n                preManager.putString(Constants.KEY_NAME, documentSnapshot.getString(Constants.KEY_NAME));\n                preManager.putString(Constants.KEY_IMAGE, documentSnapshot.getString(Constants.KEY_IMAGE));\n                Intent i = new Intent(getApplicationContext(), MainActivity.class);\n                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);\n                startActivity(i);\n            } else {\n                showToasts(\"Unable to SignIn\");\n            }\n        });\n```\n\n## 4. User Interface:\n\n- Used user-friendly and attractive user interfaces.\n- User experiences are improved\n- Very similar to Whatsapp application\n\n## 5. Chat Functionality:\n\nUsers need to sign in or sign up first before starting the chats. After logging in or signing up they will navigate to\nthe main dashboard. Current chats are displayed here. The bottom of the screen shows a `+` button and users can start\nnew chats from here. After clicking the `+` button user can view the application's users list with their profile picture\nand username. After clicking any of them user navigates to the chat area and both can chat in there. Both users can see\nwhether their last seen times, messages are delivered, seen, or only sent status.\n\n## 6. Media Handling (Under Development):\n\nImages, Audio, and Video sending are under the development process. I hope all functions will be integrated next release\nversion.\n\n## 7. Notifications:\n\nWhen the user gets a message, the application sends a notification when the application is in the background or closed.\nnotifications are handled by FirebaseMessagingService. Here is how to handle notifications by FirebaseMessagingService.\n\n```groovy\npublic class MessagingService extends FirebaseMessagingService {\n    @Override\n    public void onNewToken(@NonNull String token) {\n        super.onNewToken(token);\n    }\n\n    @Override\n    public void onMessageReceived(@NonNull RemoteMessage message) {\n        super.onMessageReceived(message);\n        User user = new User();\n        user.id = message.getData().get(Constants.KEY_USER_ID);\n        user.name = message.getData().get(Constants.KEY_NAME);\n        user.token = message.getData().get(Constants.KEY_FCM_TOKEN);\n\n        int notificationId = new Random().nextInt();\n        String chanelId = \"chat_message\";\n\n        Intent i = new Intent(this, chatActivity.class);\n        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);\n        i.putExtra(Constants.KEY_USER, user);\n        PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);\n\n        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, chanelId);\n        builder.setSmallIcon(R.drawable.ic_notification);\n        builder.setContentTitle(user.name);\n        builder.setContentText(message.getData().get(Constants.KEY_MESSAGE));\n        builder.setStyle(new NotificationCompat.BigTextStyle().bigText(\n                message.getData().get(Constants.KEY_MESSAGE)\n        ));\n        builder.setPriority(NotificationCompat.PRIORITY_DEFAULT);\n        builder.setContentIntent(pi);\n        builder.setAutoCancel(true);\n\n        if (Build.VERSION.SDK_INT \u003e= Build.VERSION_CODES.O) {\n            CharSequence chanelName = \"Chat\";\n            String chanelDescription = \"This notification chanel is used for chat notifications\";\n            int importance = NotificationManager.IMPORTANCE_DEFAULT;\n            NotificationChannel channel = new NotificationChannel(chanelId, chanelName, importance);\n            channel.setDescription(chanelDescription);\n            NotificationManager notificationManager = getSystemService(NotificationManager.class);\n            notificationManager.createNotificationChannel(channel);\n        }\n        NotificationManagerCompat managerCompat = NotificationManagerCompat.from(this);\n        managerCompat.notify(notificationId, builder.build());\n    }\n}\n```\n\n## 8. Offline Handling:\n\nWhen the user is offline application completely terminates. Senders can see messages with a `sent` status. When the user\ncomes back online, he/she gets all notifications for every message.\n\n## 9. Dependencies:\n\n```groovy\n    // default\nimplementation 'androidx.appcompat:appcompat:1.4.1'\nimplementation 'com.google.android.material:material:1.5.0'\nimplementation 'androidx.constraintlayout:constraintlayout:2.1.3'\ntestImplementation 'junit:junit:4.13.2'\nandroidTestImplementation 'androidx.test.ext:junit:1.1.3'\nandroidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'\n\n// scalable size (different sizes screens support)\nimplementation 'com.intuit.sdp:sdp-android:1.0.6'\nimplementation 'com.intuit.ssp:ssp-android:1.0.6'\n\n//rounded image view\nimplementation 'com.makeramen:roundedimageview:2.3.0'\n\n//firebase\nimplementation platform('com.google.firebase:firebase-bom:30.4.1')\nimplementation 'com.google.firebase:firebase-messaging:23.0.8'\nimplementation 'com.google.firebase:firebase-firestore:24.3.1'\n\n//multidex\nimplementation 'androidx.multidex:multidex:2.0.1'\n\n//Retrofit\nimplementation 'com.squareup.retrofit2:retrofit:2.9.0'\nimplementation 'com.squareup.retrofit2:converter-scalars:2.9.0'\n```\n\n# Database Documentation:\n\n## 1. Database Schema:\n\n### User\n\nThe User entity represents the users' information including their name, profile picture, email, and password.\n\n- `name`(String)\n- `image`(String)\n- `email`(String)\n- `token`(String)\n- `id`(String)\n\n### chatMessage\n\nchatMessage entity represents all messaging service information.\n\n- `senderId`(String)\n- `receiverId`(String)\n- `message`(String)\n- `dateTime`(String)\n- `dateObj`(Date)\n- `conversionId`(String)\n- `conversionName`(String)\n- `conversionImage`(String)\n\n## 2. User Data:\n\n- `name`(String) - Username (Nick name).\n- `image`(String) - User's profile picture.\n- `email`(String) - User's email address.\n- `token`(String) - Unique user token.\n- `id`(String) - Unique identifier for the user.\n\nUser data are stored when signing up to the application. Update and Delete methods are not integrated yet.\n\n## 3. Chat Data:\n\n- `senderId`(String) - Unique identifier for the sender\n- `receiverId`(String) - Unique identifier for the receiver\n- `message`(String) - Message content\n- `dateTime`(String) - Date and time of the message\n- `dateObj`(Date) - Date object\n- `conversionId`(String) - Unique identifier for the conversion\n- `conversionName`(String) - Name of the conversion\n- `conversionImage`(String) - Profile picture of the conversion\n\nChat data are stored when sending messages. Update and Delete methods are not integrated yet.\n\n# API Documentation\n\n## ApiClient:\n\n```groovy\npublic class ApiClient {\n\n    private static Retrofit retrofit = null;\n    private static ScalarsConverterFactory scalarsConverterFactory;\n\n    public static Retrofit getClient() {\n        if (retrofit == null) {\n            retrofit = new Retrofit.Builder()\n                    .baseUrl(\"https://fcm.googleapis.com/fcm/\")\n                    .addConverterFactory(scalarsConverterFactory.create())\n                    .build();\n        }\n        return retrofit;\n    }\n\n}\n```\n\n## API Services\n\n```groovy\npublic interface ApiService {\n\n    @POST(\"send\")\n    Call\u003cString\u003e sendMessage(\n            @HeaderMap HashMap\u003cString, String\u003e headers,\n            @Body String messageBody\n    );\n\n}\n```\n\nOnly `sendMessage` API call is used here. Other database operations are done inside of functions themselves.\n\n# Additional Considerations:\n\n- **Security:** Mainly used register and sign-in options for security. Also used FCM tokens for users. Restricted\n  multiple accounts for one email.\n- **Performance:** Images are encoded into strings to increase the performance of the application.\n- **Future Enhancements:** This application is now based on only texts. Future releases will support images, audio, and\n  video too.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkavicastelo%2Fchat_app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkavicastelo%2Fchat_app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkavicastelo%2Fchat_app/lists"}