├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ ├── ic_send.png │ │ │ ├── ic_discuss.png │ │ │ ├── ic_people.png │ │ │ ├── ic_logo_white.png │ │ │ ├── ic_not_found.png │ │ │ ├── circle_blue.xml │ │ │ ├── thread_bg_you.xml │ │ │ ├── thread_bg_me.xml │ │ │ ├── toolbar_gradient.xml │ │ │ ├── baseline_done_24.xml │ │ │ ├── round_success_24.xml │ │ │ ├── unknown_avatar.xml │ │ │ ├── round_info_24.xml │ │ │ ├── round_error_24.xml │ │ │ ├── baseline_done_all_24.xml │ │ │ ├── baseline_exit_to_app_24.xml │ │ │ ├── round_warning_24.xml │ │ │ ├── layout_click.xml │ │ │ └── button_send.xml │ │ ├── mipmap │ │ │ └── ic_launcher.png │ │ ├── anim │ │ │ └── slide_in_bottom.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ ├── menu │ │ │ └── menu_main.xml │ │ ├── layout │ │ │ ├── toolbar.xml │ │ │ ├── activity_new_chat.xml │ │ │ ├── custom_meaasge.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_splash.xml │ │ │ ├── row_friends.xml │ │ │ ├── fragment_chat.xml │ │ │ ├── row_chat_details.xml │ │ │ ├── row_chats.xml │ │ │ └── activity_chat.xml │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── dimens.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ └── values-v21 │ │ │ └── styles.xml │ │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── sample │ │ │ └── fchat │ │ │ ├── model │ │ │ ├── Friend.kt │ │ │ └── ChatMessage.kt │ │ │ ├── ui │ │ │ ├── ViewHelper.kt │ │ │ └── CustomToast.kt │ │ │ ├── util │ │ │ ├── Constants.kt │ │ │ └── Tools.java │ │ │ ├── fragment │ │ │ ├── FragmentAdapter.java │ │ │ └── ConversationListFragment.kt │ │ │ ├── data │ │ │ ├── SettingsAPI.java │ │ │ └── ParseFirebaseData.java │ │ │ ├── widget │ │ │ ├── CircleTransform.java │ │ │ └── DividerItemDecoration.java │ │ │ ├── service │ │ │ ├── MyFirebaseMessagingService.java │ │ │ └── NotificationService.kt │ │ │ ├── adapter │ │ │ ├── ChatDetailsListAdapter.kt │ │ │ ├── FriendsListAdapter.kt │ │ │ └── ChatsListAdapter.kt │ │ │ └── activity │ │ │ ├── SelectFriendActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── ChatActivity.java │ │ │ └── SplashActivity.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro ├── google-services.json └── build.gradle ├── settings.gradle ├── screenshots ├── screenshot_1.png ├── screenshot_2.png ├── screenshot_3.png └── screenshot_4.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── LICENSE ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /screenshots/screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/screenshots/screenshot_1.png -------------------------------------------------------------------------------- /screenshots/screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/screenshots/screenshot_2.png -------------------------------------------------------------------------------- /screenshots/screenshot_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/screenshots/screenshot_3.png -------------------------------------------------------------------------------- /screenshots/screenshot_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/screenshots/screenshot_4.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/app/src/main/res/drawable/ic_send.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_discuss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/app/src/main/res/drawable/ic_discuss.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_people.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/app/src/main/res/drawable/ic_people.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/app/src/main/res/mipmap/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_logo_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/app/src/main/res/drawable/ic_logo_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_not_found.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g0g0l/FChat/HEAD/app/src/main/res/drawable/ic_not_found.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /.gradle 10 | /.idea 11 | /captures 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/model/Friend.kt: -------------------------------------------------------------------------------- 1 | package com.app.sample.fchat.model 2 | 3 | import java.io.Serializable 4 | 5 | class Friend(val id: String, val name: String, val photo: String) : Serializable 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/circle_blue.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/thread_bg_you.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Feb 19 16:08:22 IST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/thread_bg_me.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_in_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/toolbar_gradient.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_done_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/round_success_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/unknown_avatar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/round_info_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/round_error_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_done_all_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | FChat 4 | 5 | 6 | Press again to exit 7 | 8 | com.app.sample.fchat.temp 9 | Authentication failed. 10 | Could not connect 11 | Login failed 12 | No Chat found 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_exit_to_app_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/round_warning_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_new_chat.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/layout_click.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\COMPETITION\Android Studio\Android Studio SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/ui/ViewHelper.kt: -------------------------------------------------------------------------------- 1 | package com.app.sample.fchat.ui 2 | 3 | import android.app.NotificationManager 4 | import android.app.ProgressDialog 5 | import android.content.Context 6 | 7 | 8 | /** 9 | *Created by Bibaswann Bandyopadhyay on 20-02-2020. 10 | */ 11 | class ViewHelper(private val mContext: Context) { 12 | private var progressDialog: ProgressDialog? = null 13 | public fun showProgressDialog() { 14 | progressDialog = ProgressDialog(mContext) 15 | progressDialog?.setCancelable(false) 16 | progressDialog?.show() 17 | } 18 | 19 | public fun dismissProgressDialog() { 20 | progressDialog?.hide() 21 | } 22 | 23 | fun clearNotofication() { 24 | val notificationManager = mContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager 25 | notificationManager.cancelAll() 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/custom_meaasge.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/model/ChatMessage.kt: -------------------------------------------------------------------------------- 1 | package com.app.sample.fchat.model 2 | 3 | import com.app.sample.fchat.util.Tools 4 | 5 | class ChatMessage(var text: String?, var timestamp: String, var friendId: String?, var friendName: String?, var friendPhoto: String?, var senderId: String?, var senderName: String?, var senderPhoto: String?, var isRead: Boolean?) { 6 | 7 | val readableTime: String? 8 | get() { 9 | return try { 10 | Tools.formatTime(java.lang.Long.valueOf(timestamp)) 11 | } catch (ignored: NumberFormatException) { 12 | null 13 | } 14 | 15 | } 16 | 17 | val receiver: Friend 18 | get() = Friend(friendId!!, friendName!!, friendPhoto!!) 19 | 20 | val sender: Friend 21 | get() = Friend(senderId!!, senderName!!, senderPhoto!!) 22 | 23 | val comparableTimestamp: Long 24 | get() = java.lang.Long.parseLong(timestamp) 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/util/Constants.kt: -------------------------------------------------------------------------------- 1 | package com.app.sample.fchat.util 2 | 3 | object Constants { 4 | //Chat nodes 5 | const val NODE_TEXT = "text" 6 | const val NODE_TIMESTAMP = "timestamp" 7 | const val NODE_RECEIVER_ID = "receiverid" 8 | const val NODE_RECEIVER_NAME = "receivername" 9 | const val NODE_RECEIVER_PHOTO = "receiverphoto" 10 | const val NODE_SENDER_ID = "senderid" 11 | const val NODE_SENDER_NAME = "sendername" 12 | const val NODE_SENDER_PHOTO = "senderphoto" 13 | const val NODE_IS_READ = "isread" 14 | //User nodes 15 | const val NODE_USER_ID = "id" 16 | const val NODE_NAME = "name" 17 | const val NODE_PHOTO = "photo" 18 | const val LOG_TAG = "fchat" 19 | const val MESSAGE_CHILD = "messages" 20 | const val PREF_MY_ID = "myid" 21 | const val PREF_MY_NAME = "myname" 22 | const val PREF_MY_DP = "mydp" 23 | 24 | //Fragment tags 25 | const val TAG_CHAT_HISTORY = "Chat History" 26 | } -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 10dp 6 | 26dp 7 | 8 | 3dp 9 | 2dp 10 | 4dp 11 | 10dp 12 | 16dp 13 | 20dp 14 | 32dp 15 | 16 | 9dp 17 | 12dp 18 | 25dp 19 | 16dp 20 | 21 | 22 | 192dp 23 | 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | android.enableJetifier=true 20 | android.useAndroidX=true 21 | org.gradle.jvmargs=-XX\:MaxHeapSize\=1024m -Xmx512m -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Bibaswann Bandyopadhyay 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/fragment/FragmentAdapter.java: -------------------------------------------------------------------------------- 1 | package com.app.sample.fchat.fragment; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import androidx.fragment.app.Fragment; 7 | import androidx.fragment.app.FragmentManager; 8 | import androidx.fragment.app.FragmentPagerAdapter; 9 | 10 | public class FragmentAdapter extends FragmentPagerAdapter { 11 | private final List mFragments = new ArrayList<>(); 12 | private final List mFragmentTitles = new ArrayList<>(); 13 | 14 | public FragmentAdapter(FragmentManager fm) { 15 | super(fm); 16 | } 17 | 18 | public void addFragment(Fragment fragment, String title) { 19 | mFragments.add(fragment); 20 | mFragmentTitles.add(title); 21 | } 22 | 23 | @Override 24 | public Fragment getItem(int position) { 25 | return mFragments.get(position); 26 | } 27 | 28 | 29 | @Override 30 | public int getCount() { 31 | return mFragments.size(); 32 | } 33 | 34 | @Override 35 | public CharSequence getPageTitle(int position) { 36 | return mFragmentTitles.get(position); 37 | } 38 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #9b59b6 6 | #8e44ad 7 | #d7ccc8 8 | 9 | #2ecc71 10 | #27ae60 11 | #2ecc71 12 | @color/grey_hard 13 | 14 | @color/background_material_light 15 | 16 | #767676 17 | 18 | #E0E0E0 19 | 20 | #96989A 21 | #BDBFC1 22 | #F5F5F5 23 | 24 | #EBEFF0 25 | #222D31 26 | #FFE0B2 27 | 28 | #ff9933 29 | #8b0000 30 | #000080 31 | #008000 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 17 | 18 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_send.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FChat 2 | This is a simple real time one-to-one chat app for android using firebase database. Users can login using their google accounts and have conversations with other registered members. 3 | 4 | ![ScreenShot](https://raw.github.com/g0g0l/FChat/master/screenshots/screenshot_1.png) 5 | ![ScreenShot](https://raw.github.com/g0g0l/FChat/master/screenshots/screenshot_2.png) 6 | ![ScreenShot](https://raw.github.com/g0g0l/FChat/master/screenshots/screenshot_3.png) 7 | ![ScreenShot](https://raw.github.com/g0g0l/FChat/master/screenshots/screenshot_4.png) 8 | 9 | Before you use: 10 | 1. Create a firebase project in your firebase console 11 | 2. Enable google login for firebase in your firebase project (more http://www.androidhive.info/2016/06/android-getting-started-firebase-simple-login-registration-auth/) 12 | 3. Create SHA1 fingerprint in your system 13 | 14 | Windows: keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android (From Java->jdk-bin) 15 | 16 | Mac/Linux: keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 17 | 18 | (For production, the json file is to be created from play store console) 19 | 20 | 4. Download and add google-services.json file in the app directory (more https://firebase.google.com/docs/android/setup) 21 | 22 | 23 | For reference, see https://codelabs.developers.google.com/codelabs/firebase-android/#0 24 | 25 | I have provided my google-services.json as a sample (DO NOT USE IT IN YOUR OWN PROJECT, IT WILL NOT WORK) 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/data/SettingsAPI.java: -------------------------------------------------------------------------------- 1 | package com.app.sample.fchat.data; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | import com.app.sample.fchat.R; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Bibaswann on 20-02-2017. 14 | */ 15 | 16 | public class SettingsAPI { 17 | Context mContext; 18 | private SharedPreferences sharedSettings; 19 | 20 | public SettingsAPI(Context context) { 21 | mContext = context; 22 | sharedSettings = mContext.getSharedPreferences(mContext.getString(R.string.settings_file_name), Context.MODE_PRIVATE); 23 | } 24 | 25 | public String readSetting(String key) { 26 | return sharedSettings.getString(key, "na"); 27 | } 28 | 29 | public void addUpdateSettings(String key, String value) { 30 | SharedPreferences.Editor editor = sharedSettings.edit(); 31 | editor.putString(key, value); 32 | editor.apply(); 33 | } 34 | 35 | public void deleteAllSettings() { 36 | sharedSettings.edit().clear().apply(); 37 | } 38 | 39 | public List readAll() { 40 | List allUser = new ArrayList<>(); 41 | Map allEntries = sharedSettings.getAll(); 42 | for (Map.Entry entry : allEntries.entrySet()) { 43 | if (entry.getKey().contains("@")) 44 | allUser.add(entry.getKey() + " (" + entry.getValue() + ")"); 45 | } 46 | return allUser; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 19 | 20 | 26 | 27 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/widget/CircleTransform.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.app.sample.fchat.widget; 4 | 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapShader; 7 | import android.graphics.Canvas; 8 | import android.graphics.Paint; 9 | 10 | import com.squareup.picasso.Transformation; 11 | 12 | public class CircleTransform implements Transformation { 13 | 14 | @Override 15 | public Bitmap transform(Bitmap source) { 16 | int size = Math.min(source.getWidth(), source.getHeight()); 17 | 18 | int x = (source.getWidth() - size) / 2; 19 | int y = (source.getHeight() - size) / 2; 20 | 21 | Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size); 22 | if (squaredBitmap != source) { 23 | source.recycle(); 24 | } 25 | 26 | Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig()); 27 | 28 | Canvas canvas = new Canvas(bitmap); 29 | Paint paint = new Paint(); 30 | BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP); 31 | paint.setShader(shader); 32 | paint.setAntiAlias(true); 33 | 34 | float r = size / 2f; 35 | canvas.drawCircle(r, r, r, paint); 36 | 37 | squaredBitmap.recycle(); 38 | return bitmap; 39 | } 40 | 41 | // public Drawable circleDrawable(Drawable d){ 42 | // Bitmap bitmap = ((BitmapDrawable)d).getBitmap(); 43 | // Drawable drawable=new BitmapDrawable(transform(bitmap)); 44 | // return drawable; 45 | // } 46 | 47 | @Override 48 | public String key() { 49 | return "circle"; 50 | } 51 | } -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "419301899506", 4 | "firebase_url": "https://fchat-68dac.firebaseio.com", 5 | "project_id": "fchat-68dac", 6 | "storage_bucket": "fchat-68dac.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:419301899506:android:6d7d160511e27a92", 12 | "android_client_info": { 13 | "package_name": "com.app.sample.fchat" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "419301899506-j40g754jlj25sou8gb24dd0hu4lri0fn.apps.googleusercontent.com", 19 | "client_type": 1, 20 | "android_info": { 21 | "package_name": "com.app.sample.fchat", 22 | "certificate_hash": "ee1d98581e339bc19421806c92f8afbf8cf23255" 23 | } 24 | }, 25 | { 26 | "client_id": "419301899506-6m8ispsckoi1pq9i6gu7pmk0i44mbjbe.apps.googleusercontent.com", 27 | "client_type": 3 28 | } 29 | ], 30 | "api_key": [ 31 | { 32 | "current_key": "AIzaSyDv1uvqv1efL3NmgUEd5KFfgpDlX4P8xk8" 33 | } 34 | ], 35 | "services": { 36 | "analytics_service": { 37 | "status": 1 38 | }, 39 | "appinvite_service": { 40 | "status": 2, 41 | "other_platform_oauth_client": [ 42 | { 43 | "client_id": "419301899506-6m8ispsckoi1pq9i6gu7pmk0i44mbjbe.apps.googleusercontent.com", 44 | "client_type": 3 45 | } 46 | ] 47 | }, 48 | "ads_service": { 49 | "status": 2 50 | } 51 | } 52 | } 53 | ], 54 | "configuration_version": "1" 55 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/row_friends.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 24 | 25 | 32 | 33 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/util/Tools.java: -------------------------------------------------------------------------------- 1 | package com.app.sample.fchat.util; 2 | 3 | import android.app.Activity; 4 | import android.os.Build; 5 | import android.view.Window; 6 | import android.view.WindowManager; 7 | 8 | import com.app.sample.fchat.R; 9 | 10 | import java.text.SimpleDateFormat; 11 | import java.util.Calendar; 12 | import java.util.Locale; 13 | 14 | import androidx.annotation.RequiresApi; 15 | 16 | 17 | public class Tools { 18 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) 19 | public static void systemBarLolipop(Activity act) { 20 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { 21 | Window window = act.getWindow(); 22 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 23 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 24 | window.setStatusBarColor(act.getResources().getColor(R.color.colorPrimaryDark)); 25 | } 26 | } 27 | 28 | public static String formatTime(long time) { 29 | // income time 30 | Calendar date = Calendar.getInstance(); 31 | date.setTimeInMillis(time); 32 | 33 | // current time 34 | Calendar curDate = Calendar.getInstance(); 35 | curDate.setTimeInMillis(System.currentTimeMillis()); 36 | 37 | SimpleDateFormat dateFormat = null; 38 | if (date.get(Calendar.YEAR) == curDate.get(Calendar.YEAR)) { 39 | if (date.get(Calendar.DAY_OF_YEAR) == curDate.get(Calendar.DAY_OF_YEAR)) { 40 | dateFormat = new SimpleDateFormat("h:mm a", Locale.US); 41 | } else { 42 | dateFormat = new SimpleDateFormat("MMM d", Locale.US); 43 | } 44 | } else { 45 | dateFormat = new SimpleDateFormat("MMM yyyy", Locale.US); 46 | } 47 | return dateFormat.format(time); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/service/MyFirebaseMessagingService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.app.sample.fchat.service; 17 | 18 | import android.util.Log; 19 | 20 | import com.google.firebase.iid.FirebaseInstanceId; 21 | import com.google.firebase.messaging.FirebaseMessaging; 22 | import com.google.firebase.messaging.FirebaseMessagingService; 23 | import com.google.firebase.messaging.RemoteMessage; 24 | 25 | import androidx.annotation.NonNull; 26 | 27 | import static com.app.sample.fchat.util.Constants.LOG_TAG; 28 | 29 | public class MyFirebaseMessagingService extends FirebaseMessagingService { 30 | 31 | private static final String FRIENDLY_ENGAGE_TOPIC = "friendly_engage"; 32 | 33 | @Override 34 | public void onMessageReceived(RemoteMessage remoteMessage) { 35 | // Handle data payload of FCM messages. 36 | Log.d(LOG_TAG, "FCM Message Id: " + remoteMessage.getMessageId()); 37 | Log.d(LOG_TAG, "FCM Notification Message: " + remoteMessage.getNotification()); 38 | Log.d(LOG_TAG, "FCM Data Message: " + remoteMessage.getData()); 39 | } 40 | 41 | @Override 42 | public void onNewToken(@NonNull String s) { 43 | super.onNewToken(s); 44 | String token = FirebaseInstanceId.getInstance().getToken(); 45 | 46 | // Once a token is generated, we subscribe to topic. 47 | FirebaseMessaging.getInstance().subscribeToTopic(FRIENDLY_ENGAGE_TOPIC); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/sample/fchat/ui/CustomToast.kt: -------------------------------------------------------------------------------- 1 | package com.app.sample.fchat.ui 2 | 3 | import android.content.Context 4 | import android.view.Gravity 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.widget.ImageView 8 | import android.widget.TextView 9 | import android.widget.Toast 10 | import androidx.core.content.ContextCompat 11 | import com.app.sample.fchat.R 12 | 13 | class CustomToast(val context: Context) { 14 | val text: TextView 15 | val icon: ImageView 16 | val layout: View 17 | 18 | init { 19 | val inflater: LayoutInflater = LayoutInflater.from(context) 20 | layout = inflater.inflate(R.layout.custom_meaasge, null) 21 | text = layout.findViewById(R.id.text) 22 | icon = layout.findViewById(R.id.icon) 23 | } 24 | 25 | private fun showActualToast() { 26 | val toast = Toast(context) 27 | toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0) 28 | toast.duration = Toast.LENGTH_LONG 29 | toast.view = layout 30 | toast.show() 31 | 32 | //More subtle way 33 | // with(Toast(context)) { 34 | // setGravity(Gravity.CENTER_VERTICAL, 0, 0) 35 | // duration = Toast.LENGTH_LONG 36 | // view = layout 37 | // show() 38 | // } 39 | } 40 | 41 | fun showError(msg: String) { 42 | text.text = msg 43 | icon.setImageResource(R.drawable.round_error_24) 44 | icon.setColorFilter(ContextCompat.getColor(context, R.color.error), android.graphics.PorterDuff.Mode.MULTIPLY) 45 | 46 | showActualToast() 47 | } 48 | 49 | fun showInfo(msg: String) { 50 | text.text = msg 51 | icon.setImageResource(R.drawable.round_info_24) 52 | icon.setColorFilter(ContextCompat.getColor(context, R.color.info), android.graphics.PorterDuff.Mode.MULTIPLY) 53 | 54 | showActualToast() 55 | } 56 | 57 | fun showSuccess(msg: String) { 58 | text.text = msg 59 | icon.setImageResource(R.drawable.round_success_24) 60 | icon.setColorFilter(ContextCompat.getColor(context, R.color.success), android.graphics.PorterDuff.Mode.MULTIPLY) 61 | 62 | showActualToast() 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_chat.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 20 | 21 | 35 | 36 | 41 | 42 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/row_chat_details.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | 27 | 35 | 36 | 43 | 44 | 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion 29 7 | buildToolsVersion '29.0.0' 8 | 9 | defaultConfig { 10 | applicationId "com.app.sample.fchat" 11 | minSdkVersion 16 12 | targetSdkVersion 29 13 | versionCode 1 14 | versionName "1.0" 15 | vectorDrawables.useSupportLibrary = true 16 | multiDexEnabled true 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | compileOptions { 25 | sourceCompatibility = 1.8 26 | targetCompatibility = 1.8 27 | } 28 | } 29 | 30 | /* IMPORTANT : 31 | * Be careful when update dependencies, different version library may caused error */ 32 | dependencies { 33 | implementation fileTree(dir: 'libs', include: ['*.jar']) 34 | testImplementation 'junit:junit:4.12' 35 | implementation 'androidx.appcompat:appcompat:1.1.0' 36 | implementation 'androidx.browser:browser:1.2.0' 37 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 38 | implementation 'androidx.cardview:cardview:1.0.0' 39 | implementation 'androidx.recyclerview:recyclerview:1.1.0' 40 | implementation 'com.google.android.material:material:1.1.0' 41 | implementation 'com.squareup.picasso:picasso:2.5.2' 42 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 43 | implementation 'com.balysv:material-ripple:1.0.2' 44 | implementation 'com.android.support:multidex:1.0.3' 45 | 46 | // Google 47 | implementation 'com.google.android.gms:play-services-auth:17.0.0' 48 | implementation 'com.google.android.gms:play-services-appinvite:18.0.0' 49 | implementation 'com.google.android.gms:play-services-measurement-base:17.2.2' 50 | 51 | // Firebase 52 | implementation 'com.google.firebase:firebase-database:19.2.1' 53 | implementation 'com.google.firebase:firebase-auth:19.2.0' 54 | implementation 'com.google.firebase:firebase-config:19.1.1' 55 | implementation 'com.google.firebase:firebase-messaging:20.1.0' 56 | implementation 'com.google.firebase:firebase-appindexing:19.1.0' 57 | implementation 'com.google.firebase:firebase-crash:16.2.1' 58 | implementation 'com.google.firebase:firebase-analytics:17.2.2' 59 | 60 | //UI 61 | implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4" 62 | 63 | //Kotlin 64 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 65 | } 66 | apply plugin: 'com.google.gms.google-services' 67 | repositories { 68 | mavenCentral() 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/res/layout/row_chats.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 18 | 19 | 25 | 26 | 34 | 35 | 43 | 44 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 50 | 51 | 52 | 56 | 57 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_chat.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 15 | 16 | 26 | 27 | 28 | 29 | 37 | 38 | 39 | 46 | 47 | 58 | 59 | 67 | 68 | 69 | 70 |