├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── vcs.xml
├── render.experimental.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
├── misc.xml
└── codeStyles
│ └── Project.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── logo.png
│ │ │ │ ├── phone.png
│ │ │ │ ├── logotwo.png
│ │ │ │ ├── project_logo.jpg
│ │ │ │ ├── undraw_empty_xct9.png
│ │ │ │ ├── undraw_calling_kpbp.png
│ │ │ │ ├── undraw_chatting_2yvo.png
│ │ │ │ ├── undraw_begin_chat_c6pj.png
│ │ │ │ ├── undraw_chatting_2yvopp.png
│ │ │ │ ├── undraw_synchronize_ccxk.png
│ │ │ │ ├── undraw_group_hangout_5gmq.png
│ │ │ │ ├── background.xml
│ │ │ │ ├── ic_home_black_24dp.xml
│ │ │ │ ├── ic_dashboard_black_24dp.xml
│ │ │ │ ├── button_bg.xml
│ │ │ │ ├── ic_chat_black_24dp.xml
│ │ │ │ ├── ic_account_box_black_24dp.xml
│ │ │ │ ├── ic_notifications_black_24dp.xml
│ │ │ │ ├── ic_sync_black_24dp.xml
│ │ │ │ ├── ic_call_black_24dp.xml
│ │ │ │ ├── ic_account_circle_black_24dp.xml
│ │ │ │ ├── ic_camera_alt_black_24dp.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── strings.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_splash.xml
│ │ │ │ ├── activity_chat.xml
│ │ │ │ ├── fragment_chat.xml
│ │ │ │ ├── item_message.xml
│ │ │ │ ├── activity_bottom_navigation.xml
│ │ │ │ ├── contactlist_row.xml
│ │ │ │ ├── activity_login.xml
│ │ │ │ ├── fragment_home.xml
│ │ │ │ ├── activity_home_chatting.xml
│ │ │ │ └── fragment_profile.xml
│ │ │ ├── menu
│ │ │ │ └── bottom_nav_menu.xml
│ │ │ ├── navigation
│ │ │ │ └── mobile_navigation.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── saumya
│ │ │ │ └── chattery
│ │ │ │ ├── Contacts.java
│ │ │ │ ├── ui
│ │ │ │ ├── home
│ │ │ │ │ ├── HomeViewModel.java
│ │ │ │ │ └── HomeFragment.java
│ │ │ │ ├── Chat
│ │ │ │ │ ├── ChatViewModel.java
│ │ │ │ │ └── ChatFragment.java
│ │ │ │ └── profile
│ │ │ │ │ ├── ProfileViewModel.java
│ │ │ │ │ └── ProfileFragment.java
│ │ │ │ ├── MessageModel.java
│ │ │ │ ├── BottomNavigation.java
│ │ │ │ ├── SplashActivity.java
│ │ │ │ ├── LoginActivity.java
│ │ │ │ ├── MessageAdapter.java
│ │ │ │ ├── RecyclerAdapter.java
│ │ │ │ ├── ChatActivity.java
│ │ │ │ └── HomeChattingActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── saumya
│ │ │ └── chattery
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── saumya
│ │ └── chattery
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
├── google-services.json
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | Chattery
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name='Chattery'
3 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/phone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/phone.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logotwo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/logotwo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/project_logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/project_logo.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/undraw_empty_xct9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/undraw_empty_xct9.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/undraw_calling_kpbp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/undraw_calling_kpbp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/undraw_chatting_2yvo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/undraw_chatting_2yvo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/undraw_begin_chat_c6pj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/undraw_begin_chat_c6pj.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/undraw_chatting_2yvopp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/undraw_chatting_2yvopp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/undraw_synchronize_ccxk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/undraw_synchronize_ccxk.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/undraw_group_hangout_5gmq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saumya1singh/CHATTERY/HEAD/app/src/main/res/drawable/undraw_group_hangout_5gmq.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/render.experimental.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Oct 10 13:31:04 IST 2019
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/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 20sp
7 | 18sp
8 | 14sp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_dashboard_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_bg.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
10 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/com/saumya/chattery/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/Contacts.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | public class Contacts {
4 |
5 | String name;
6 | String phone;
7 |
8 | public String getName() {
9 | return name;
10 | }
11 |
12 | public void setName(String name) {
13 | this.name = name;
14 | }
15 |
16 | public String getPhone() {
17 | return phone;
18 | }
19 |
20 | public void setPhone(String phone) {
21 | this.phone = phone;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_chat_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_account_box_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_notifications_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/ui/home/HomeViewModel.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery.ui.home;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.MutableLiveData;
5 | import androidx.lifecycle.ViewModel;
6 |
7 | public class HomeViewModel extends ViewModel {
8 |
9 | private MutableLiveData mText;
10 |
11 | public HomeViewModel() {
12 | mText = new MutableLiveData<>();
13 | mText.setValue("This is home fragment");
14 | }
15 |
16 | public LiveData getText() {
17 | return mText;
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_sync_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/ui/Chat/ChatViewModel.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery.ui.Chat;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.MutableLiveData;
5 | import androidx.lifecycle.ViewModel;
6 |
7 | public class ChatViewModel extends ViewModel {
8 |
9 | private MutableLiveData mText;
10 |
11 | public ChatViewModel() {
12 | mText = new MutableLiveData<>();
13 | mText.setValue("This is dashboard fragment");
14 | }
15 |
16 | public LiveData getText() {
17 | return mText;
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #A76BF8
4 | #000
5 | #b042f5
6 | #69C8F3
7 | #ffffff
8 | #00000000
9 | #AD3DF1
10 | #5D0A97
11 |
12 | #19AA8B
13 | #75CAE9
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/ui/profile/ProfileViewModel.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery.ui.profile;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.MutableLiveData;
5 | import androidx.lifecycle.ViewModel;
6 |
7 | public class ProfileViewModel extends ViewModel {
8 |
9 | private MutableLiveData mText;
10 |
11 | public ProfileViewModel() {
12 | mText = new MutableLiveData<>();
13 | mText.setValue("This is notifications fragment");
14 | }
15 |
16 | public LiveData getText() {
17 | return mText;
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_call_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_account_circle_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/bottom_nav_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_camera_alt_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/saumya/chattery/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.saumya.chattery", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/MessageModel.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | public class MessageModel {
4 |
5 | private String text;
6 | private String name;
7 | private String photoUrl;
8 |
9 | public MessageModel() {
10 | }
11 |
12 | public MessageModel(String text, String name, String photoUrl) {
13 | this.text = text;
14 | this.name = name;
15 | this.photoUrl = photoUrl;
16 | }
17 |
18 | public String getText() {
19 | return text;
20 | }
21 |
22 | public void setText(String text) {
23 | this.text = text;
24 | }
25 |
26 | public String getName() {
27 | return name;
28 | }
29 |
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 |
34 | public String getPhotoUrl() {
35 | return photoUrl;
36 | }
37 |
38 | public void setPhotoUrl(String photoUrl) {
39 | this.photoUrl = photoUrl;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/res/navigation/mobile_navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # App-Innovation-
2 |
3 | "Chattery" is a very interesting app that provides realtime chatting ❤.
4 | The app includes various new fetures in comparison to already existing messenger app "Whatsapp".
5 |
6 |
7 | Some fetures of the app are :
8 |
9 | Application is completely authenticated and secured .
10 | Sending and receiving messages .
11 | Receiving notification .
12 | Group messages .
13 | Conservational view (previous chats view)
14 | Complete Backups
15 | Search through all the messages #filtering
16 | Delete single message
17 | Password protect some group
18 | In profile photo: a added option of ‘only share with’.
19 |
20 | Screenshots :
21 |
22 |
23 | [](https://postimg.cc/K1mVjjdX)
24 | [](https://postimg.cc/v1FvTN14)
25 | [](https://postimg.cc/62zVH6MZ)
26 | [](https://postimg.cc/ThrCbGjT)
27 | [](https://postimg.cc/hz4T7WKt)
28 | [](https://postimg.cc/WtHgtHCs)
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
17 |
18 |
19 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
14 |
15 |
24 |
25 |
33 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/BottomNavigation.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.google.android.material.bottomnavigation.BottomNavigationView;
6 |
7 | import androidx.appcompat.app.AppCompatActivity;
8 | import androidx.navigation.NavController;
9 | import androidx.navigation.Navigation;
10 | import androidx.navigation.ui.AppBarConfiguration;
11 | import androidx.navigation.ui.NavigationUI;
12 |
13 | public class BottomNavigation extends AppCompatActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_bottom_navigation);
19 |
20 | BottomNavigationView navView = findViewById(R.id.nav_view);
21 | // Passing each menu ID as a set of Ids because each
22 | // menu should be considered as top level destinations.
23 | AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
24 | R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)
25 | .build();
26 | NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
27 | NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
28 | NavigationUI.setupWithNavController(navView, navController);
29 |
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/ui/Chat/ChatFragment.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery.ui.Chat;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.Button;
9 | import android.widget.TextView;
10 |
11 | import androidx.annotation.Nullable;
12 | import androidx.annotation.NonNull;
13 | import androidx.fragment.app.Fragment;
14 | import androidx.lifecycle.Observer;
15 | import androidx.lifecycle.ViewModelProviders;
16 |
17 | import com.saumya.chattery.ChatActivity;
18 | import com.saumya.chattery.R;
19 |
20 | public class ChatFragment extends Fragment {
21 |
22 | private ChatViewModel chatViewModel;
23 | Button btnSync;
24 |
25 | public View onCreateView(@NonNull LayoutInflater inflater,
26 | ViewGroup container, Bundle savedInstanceState) {
27 | chatViewModel =
28 | ViewModelProviders.of(this).get(ChatViewModel.class);
29 | View root = inflater.inflate(R.layout.fragment_chat, container, false);
30 |
31 | btnSync = root.findViewById(R.id.btnSync);
32 |
33 | btnSync.setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View view) {
36 |
37 | Intent intent = new Intent(getContext(), ChatActivity.class);
38 | startActivity(intent);
39 | }
40 | });
41 |
42 |
43 | return root;
44 | }
45 | }
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "662360538305",
4 | "firebase_url": "https://chattery-23cb9.firebaseio.com",
5 | "project_id": "chattery-23cb9",
6 | "storage_bucket": "chattery-23cb9.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:662360538305:android:5b75ff18487e2301462840",
12 | "android_client_info": {
13 | "package_name": "com.saumya.chattery"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "662360538305-ut53p0qndcji4u0n0romjla02hgofe7f.apps.googleusercontent.com",
19 | "client_type": 1,
20 | "android_info": {
21 | "package_name": "com.saumya.chattery",
22 | "certificate_hash": "8cff96e5e8b61cd5acff0d1e0f3e7268c2dda4a2"
23 | }
24 | },
25 | {
26 | "client_id": "662360538305-2he7ncanjig2fh5ssrivu8hmf15f02g9.apps.googleusercontent.com",
27 | "client_type": 3
28 | }
29 | ],
30 | "api_key": [
31 | {
32 | "current_key": "AIzaSyBcOdPkPjh0pbupuNNYyQJoILfSWm9ZbFg"
33 | }
34 | ],
35 | "services": {
36 | "appinvite_service": {
37 | "other_platform_oauth_client": [
38 | {
39 | "client_id": "662360538305-2he7ncanjig2fh5ssrivu8hmf15f02g9.apps.googleusercontent.com",
40 | "client_type": 3
41 | }
42 | ]
43 | }
44 | }
45 | }
46 | ],
47 | "configuration_version": "1"
48 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_bottom_navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/contactlist_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
25 |
26 |
34 |
35 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'com.google.gms.google-services'
3 |
4 | android {
5 | compileSdkVersion 29
6 | buildToolsVersion "29.0.2"
7 | defaultConfig {
8 | applicationId "com.saumya.chattery"
9 | minSdkVersion 16
10 | targetSdkVersion 29
11 | versionCode 2
12 | versionName "1.0"
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | vectorDrawables.useSupportLibrary = true
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | implementation fileTree(dir: 'libs', include: ['*.jar'])
26 | implementation 'androidx.appcompat:appcompat:1.1.0'
27 | implementation 'com.github.bumptech.glide:glide:4.8.0'
28 | implementation 'com.firebaseui:firebase-ui-storage:3.3.0'
29 | implementation 'com.google.code.gson:gson:2.8.5'
30 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
31 | implementation 'com.google.android.material:material:1.0.0'
32 | implementation 'de.hdodenhof:circleimageview:3.0.1'
33 | implementation 'com.github.msayan:tutorial-view:v1.0.10'
34 | implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
35 | implementation 'androidx.navigation:navigation-fragment:2.1.0'
36 | implementation 'androidx.navigation:navigation-ui:2.1.0'
37 | implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
38 | implementation 'com.google.firebase:firebase-auth:19.1.0'
39 | implementation 'com.google.firebase:firebase-database:19.1.0'
40 | implementation 'com.google.firebase:firebase-storage:19.1.0'
41 | testImplementation 'junit:junit:4.12'
42 | androidTestImplementation 'androidx.test:runner:1.2.0'
43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Chattery
3 | BottomNavigation
4 | Home
5 | Dashboard
6 | Notifications
7 |
8 |
9 | Chatting
10 | Grant Access
11 | Give Music Player access to files
12 | Begin Chatting
13 | Group Hangout
14 | Result is awesome!
15 | Tap open both of their chats, if it says both are online, proceed.
16 | The five senses exercise can help. It helps us to be better at picking up on what our senses tell us. As a result, it makes it easier for us to start a conversation.
17 | The end goal of small talk is to find a mutual interest – something BOTH of you love to talk about. When you find a mutual interest, the conversation stops being boring!
18 | Thank you, have fun
19 | The end goal of small talk is to find a mutual interest – something BOTH of you love to talk about. When you find a mutual interest, the conversation stops being boring!
20 | When you text someone new or someone you barely know, you need a clear REASON for why you are contacting them. The end goal of small talk is to find a mutual interest – something BOTH of you love to talk about. When you find a mutual interest, the conversation stops being boring!
21 | When you focus on someone else or something else than yourself, that makes you LESS SELF-CONSCIOUS and MORE CONFIDENT.
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
20 |
21 |
33 |
34 |
47 |
48 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/ui/home/HomeFragment.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery.ui.home;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.Button;
10 | import android.widget.TextView;
11 |
12 | import androidx.annotation.Nullable;
13 | import androidx.annotation.NonNull;
14 | import androidx.fragment.app.Fragment;
15 | import androidx.fragment.app.FragmentTransaction;
16 | import androidx.lifecycle.Observer;
17 | import androidx.lifecycle.ViewModelProviders;
18 |
19 | import com.saumya.chattery.R;
20 | import com.saumya.chattery.ui.Chat.ChatFragment;
21 |
22 | public class HomeFragment extends Fragment {
23 |
24 | private HomeViewModel homeViewModel;
25 | SharedPreferences sharedPreferences;
26 | String name , phone;
27 | Button btnChat;
28 |
29 | public View onCreateView(@NonNull LayoutInflater inflater,
30 | ViewGroup container, Bundle savedInstanceState) {
31 | homeViewModel =
32 | ViewModelProviders.of(this).get(HomeViewModel.class);
33 | View root = inflater.inflate(R.layout.fragment_home, container, false);
34 |
35 | sharedPreferences = getContext().getSharedPreferences("User", Context.MODE_PRIVATE);
36 | btnChat = root.findViewById(R.id.btnChat);
37 |
38 | name = sharedPreferences.getString("Name","");
39 | phone = sharedPreferences.getString("Phone","");
40 |
41 | final TextView textView = root.findViewById(R.id.text_home);
42 | homeViewModel.getText().observe(this, new Observer() {
43 | @Override
44 | public void onChanged(@Nullable String s) {
45 | textView.setText( " Welcome " + name + " to Chattery ❤");
46 | }
47 | });
48 |
49 | btnChat.setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View view) {
52 |
53 | FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
54 | fragmentTransaction.replace(R.id.container ,new ChatFragment() ).commit();
55 |
56 |
57 | }
58 | });
59 |
60 | return root;
61 | }
62 | }
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
25 |
26 |
33 |
34 |
35 |
42 |
43 |
54 |
55 |
56 |
57 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_home_chatting.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
22 |
23 |
38 |
39 |
40 |
41 |
57 |
58 |
59 |
68 |
69 |
70 |
81 |
82 |
83 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | import android.Manifest;
4 | import android.content.Intent;
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 | import android.widget.Toast;
8 |
9 | import com.hololo.tutorial.library.PermissionStep;
10 | import com.hololo.tutorial.library.Step;
11 | import com.hololo.tutorial.library.TutorialActivity;
12 |
13 | public class SplashActivity extends TutorialActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 |
19 |
20 | addFragment(
21 | new Step.Builder()
22 | .setTitle(getString(R.string.automatic_data))
23 | .setContent(getString(R.string.gm_finds_photos))
24 | .setBackgroundColor(Color.parseColor("#FF0957"))
25 | .setDrawable(R.drawable.undraw_chatting_2yvo)
26 | .setSummary(getString(R.string.continue_and_learn))
27 | .build());
28 | addFragment(
29 | new Step.Builder()
30 | .setTitle(getString(R.string.choose_the_song))
31 | .setContent(getString(R.string.swap_to_the_tab))
32 | .setBackgroundColor(Color.parseColor("#00D4BA"))
33 | .setDrawable(R.drawable.undraw_begin_chat_c6pj)
34 | .setSummary(getString(R.string.continue_and_update))
35 | .build());
36 | addFragment(
37 | new Step.Builder()
38 | .setTitle(getString(R.string.edit_data))
39 | .setContent(getString(R.string.update_easily))
40 | .setBackgroundColor(Color.parseColor("#1098FE"))
41 | .setDrawable(R.drawable.undraw_group_hangout_5gmq)
42 | .setSummary(getString(R.string.continue_and_result))
43 | .build());
44 | addFragment(
45 | new Step.Builder()
46 | .setTitle(getString(R.string.result_awesome))
47 | .setContent(getString(R.string.after_updating))
48 | .setBackgroundColor(Color.parseColor("#CA70F3"))
49 | .setDrawable(R.drawable.undraw_calling_kpbp)
50 | .setSummary(getString(R.string.thank_you))
51 | .build());
52 | }
53 | @Override
54 | public void finishTutorial() {
55 | //Toast.makeText(this, "Tutorial finished", Toast.LENGTH_SHORT).show();
56 | //finish();
57 |
58 | Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
59 | startActivity(intent);
60 | finish();
61 |
62 | }
63 |
64 | @Override
65 | public void currentFragmentPosition(int position) {
66 | Toast.makeText(this, "Position : " + position, Toast.LENGTH_SHORT).show();
67 |
68 |
69 |
70 |
71 |
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
17 |
18 |
29 |
30 |
31 |
32 |
46 |
47 |
48 |
49 |
50 |
58 |
59 |
67 |
68 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.SharedPreferences;
8 | import android.os.Bundle;
9 | import android.text.TextUtils;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.EditText;
14 | import android.widget.TextView;
15 |
16 | import com.google.firebase.database.DatabaseReference;
17 | import com.google.firebase.database.FirebaseDatabase;
18 |
19 | public class LoginActivity extends AppCompatActivity {
20 |
21 | EditText etName,etPhone;
22 | Button btnSubmit;
23 | String Name, Phone;
24 |
25 | FirebaseDatabase firebaseDatabase;
26 | DatabaseReference databaseReference;
27 |
28 | SharedPreferences sharedPreferences;
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_login);
34 | etName = findViewById(R.id.etName);
35 | etPhone = findViewById(R.id.etPhone);
36 | btnSubmit = findViewById(R.id.btnSubmit);
37 |
38 | sharedPreferences = getSharedPreferences("User", Context.MODE_PRIVATE);
39 |
40 | firebaseDatabase = FirebaseDatabase.getInstance("https://chattery-23cb9.firebaseio.com/");
41 | databaseReference = firebaseDatabase.getReference("Chatter/" );
42 |
43 | btnSubmit.setOnClickListener(new View.OnClickListener() {
44 | @Override
45 | public void onClick(View view) {
46 |
47 | Name = etName.getText().toString();
48 | Phone = etPhone.getText().toString();
49 | if (chekvalidation()){
50 |
51 | Name = etName.getText().toString();
52 | Phone = etPhone.getText().toString();
53 | Log.e("LOG0", "onClick: " + Name );
54 | // databaseReference.child("Name").setValue(Name);
55 | databaseReference.child(Name).child("Phone").setValue(Phone);
56 |
57 |
58 | Intent intent = new Intent(LoginActivity.this, BottomNavigation.class);
59 | startActivity(intent);
60 | finish();
61 | }
62 |
63 |
64 | SharedPreferences.Editor editor = sharedPreferences.edit();
65 |
66 | editor.putString("Phone", Phone);
67 | editor.putString("Name", Name);
68 | editor.apply();
69 |
70 | }
71 | });
72 |
73 |
74 | }
75 |
76 | public boolean chekvalidation() {
77 | boolean check = true;
78 |
79 | if (etName.getText().toString().isEmpty()) {
80 | etName.setError("Required");
81 | check = false;
82 | }
83 | if (etPhone.getText().toString().isEmpty()) {
84 | etPhone.setError("Required");
85 | check = false;
86 | }
87 | if(etPhone.getText().toString().length() != 10)
88 | {
89 | etPhone.setError("Enter Correct");
90 | check = false;
91 | }
92 | return check;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/MessageAdapter.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ArrayAdapter;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import androidx.annotation.NonNull;
14 |
15 | import com.bumptech.glide.Glide;
16 | import com.google.firebase.database.DataSnapshot;
17 | import com.google.firebase.database.DatabaseError;
18 | import com.google.firebase.database.DatabaseReference;
19 | import com.google.firebase.database.FirebaseDatabase;
20 | import com.google.firebase.database.ValueEventListener;
21 |
22 | import java.util.List;
23 |
24 | public class MessageAdapter extends ArrayAdapter {
25 |
26 |
27 | public MessageAdapter(Context context, int resource, List objects) {
28 | super(context, resource, objects);
29 | }
30 |
31 |
32 |
33 | @Override
34 | public View getView(int position, View convertView, ViewGroup parent) {
35 |
36 | if (convertView==null){
37 | convertView= LayoutInflater.from(getContext()).inflate(R.layout.item_message , parent , false);
38 | }
39 | ImageView photoImageView=convertView.findViewById(R.id.photoImageView);
40 | TextView messageTextView = (TextView) convertView.findViewById(R.id.messageTextView);
41 | TextView authorTextView = (TextView) convertView.findViewById(R.id.nameTextView);
42 |
43 |
44 | SharedPreferences sharedPreferences = getContext().getSharedPreferences("User", Context.MODE_PRIVATE);
45 |
46 | String name = sharedPreferences.getString("Name", "");
47 | String phone = sharedPreferences.getString("Phone ", "");
48 | FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance("https://chattery-23cb9.firebaseio.com/");
49 | DatabaseReference databaseReference = firebaseDatabase.getReference("Chatter/" + name + "/Friends");
50 |
51 | MessageModel message = getItem(position);
52 |
53 |
54 | boolean isPhoto=message.getPhotoUrl() != null;
55 | if (isPhoto){
56 | messageTextView.setVisibility(View.GONE);
57 | photoImageView.setVisibility(View.VISIBLE);
58 | Glide.with(photoImageView.getContext())
59 | .load(message.getPhotoUrl())
60 | .into(photoImageView);
61 | }else {
62 | messageTextView.setVisibility(View.VISIBLE);
63 | photoImageView.setVisibility(View.GONE);
64 | messageTextView.setText(message.getText());
65 | }
66 | authorTextView.setText(message.getName());
67 |
68 | databaseReference.addValueEventListener(new ValueEventListener() {
69 | @Override
70 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
71 |
72 | Log.e("Friends snap ", "onDataChange: " + dataSnapshot );
73 |
74 | for( DataSnapshot ds : dataSnapshot.getChildren()){
75 |
76 |
77 | Log.e("Friend child snap", "onDataChange: " + ds);
78 |
79 | }
80 |
81 | }
82 |
83 | @Override
84 | public void onCancelled(@NonNull DatabaseError databaseError) {
85 |
86 | }
87 | });
88 |
89 | return convertView;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | xmlns:android
11 |
12 | ^$
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | xmlns:.*
22 |
23 | ^$
24 |
25 |
26 | BY_NAME
27 |
28 |
29 |
30 |
31 |
32 |
33 | .*:id
34 |
35 | http://schemas.android.com/apk/res/android
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | .*:name
45 |
46 | http://schemas.android.com/apk/res/android
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | name
56 |
57 | ^$
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | style
67 |
68 | ^$
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | .*
78 |
79 | ^$
80 |
81 |
82 | BY_NAME
83 |
84 |
85 |
86 |
87 |
88 |
89 | .*
90 |
91 | http://schemas.android.com/apk/res/android
92 |
93 |
94 | ANDROID_ATTRIBUTE_ORDER
95 |
96 |
97 |
98 |
99 |
100 |
101 | .*
102 |
103 | .*
104 |
105 |
106 | BY_NAME
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/RecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 |
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.LinearLayout;
12 | import android.widget.TextView;
13 |
14 | import androidx.cardview.widget.CardView;
15 | import androidx.recyclerview.widget.RecyclerView;
16 |
17 | import com.google.firebase.database.DatabaseReference;
18 | import com.google.firebase.database.FirebaseDatabase;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | public class RecyclerAdapter extends RecyclerView.Adapter {
24 |
25 | private LayoutInflater layoutInflater;
26 | public List cont;
27 | Contacts list;
28 | private ArrayList arraylist;
29 | boolean checked = false;
30 | View vv;
31 |
32 | FirebaseDatabase firebaseDatabase;
33 | DatabaseReference databaseReference;
34 | SharedPreferences sharedPreferences;
35 |
36 |
37 |
38 | public RecyclerAdapter(LayoutInflater inflater, List items) {
39 | this.layoutInflater = inflater;
40 | this.cont = items;
41 | this.arraylist = new ArrayList();
42 | this.arraylist.addAll(cont);
43 | }
44 |
45 | @Override
46 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
47 |
48 | View v = layoutInflater.inflate(R.layout.contactlist_row, parent, false);
49 | ViewHolder viewHolder = new ViewHolder(v);
50 | return viewHolder;
51 | }
52 |
53 | @Override
54 | public void onBindViewHolder(final ViewHolder holder, final int position) {
55 | list = cont.get(position);
56 | final String name = (list.getName());
57 |
58 |
59 | firebaseDatabase = FirebaseDatabase.getInstance("https://chattery-23cb9.firebaseio.com/");
60 | databaseReference = firebaseDatabase.getReference("Chatter/" );
61 |
62 | holder.title.setText(name);
63 | holder.phone.setText(list.getPhone());
64 |
65 |
66 | holder.contactCard.setOnClickListener(new View.OnClickListener() {
67 | @Override
68 | public void onClick(View view) {
69 |
70 | Intent intent = new Intent(view.getContext(), HomeChattingActivity.class) ;
71 |
72 | Bundle bundle = new Bundle();
73 | bundle.putString("FriendName", name);
74 | bundle.putString("FriendPhone",list.getPhone());
75 | intent.putExtras(bundle);
76 | Log.e("Friend", name + list.getPhone());
77 | view.getContext().startActivity(intent);
78 |
79 | //intent.putExtra("Name",name);
80 | //intent.putExtra("Phone",list.getPhone());
81 |
82 | }
83 | });
84 |
85 | holder.contactCard.setOnLongClickListener(new View.OnLongClickListener() {
86 | @Override
87 | public boolean onLongClick(View view) {
88 |
89 | //code to show multi option on long click
90 | return false;
91 | }
92 | });
93 |
94 |
95 | }
96 |
97 | @Override
98 | public int getItemCount() {
99 | return cont.size();
100 | }
101 |
102 | class ViewHolder extends RecyclerView.ViewHolder {
103 | public TextView title;
104 | public TextView phone;
105 | CardView contactCard;
106 | public LinearLayout contact_select_layout;
107 |
108 | public ViewHolder(View itemView) {
109 | super(itemView);
110 | this.setIsRecyclable(false);
111 | title = (TextView) itemView.findViewById(R.id.name);
112 | phone = (TextView) itemView.findViewById(R.id.no);
113 | contactCard = itemView.findViewById(R.id.contactCard);
114 | contact_select_layout = (LinearLayout) itemView.findViewById(R.id.contact_select_layout);
115 |
116 |
117 | }
118 | }
119 |
120 | @Override
121 | public long getItemId(int position) {
122 | return position;
123 | }
124 |
125 | @Override
126 | public int getItemViewType(int position) {
127 | return position;
128 | }
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/ChatActivity.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | import android.Manifest;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.pm.PackageManager;
7 | import android.database.Cursor;
8 | import android.graphics.Bitmap;
9 | import android.os.AsyncTask;
10 | import android.os.Build;
11 | import android.os.Bundle;
12 | import android.provider.ContactsContract;
13 | import android.util.Log;
14 | import android.view.LayoutInflater;
15 | import android.view.MenuItem;
16 | import android.widget.Toast;
17 |
18 | import androidx.appcompat.app.AppCompatActivity;
19 | import androidx.recyclerview.widget.LinearLayoutManager;
20 | import androidx.recyclerview.widget.RecyclerView;
21 |
22 | import com.google.gson.Gson;
23 |
24 | import java.util.ArrayList;
25 |
26 | public class ChatActivity extends AppCompatActivity {
27 |
28 |
29 | ArrayList selectUsers;
30 | private RecyclerView recyclerView;
31 | private RecyclerView.LayoutManager layoutManager;
32 | RecyclerAdapter adapter;
33 | Cursor phones;
34 |
35 | private static final int PERMISSIONS_REQUEST_READ_CONTACTS = 100;
36 |
37 | @Override
38 | protected void onCreate (Bundle savedInstanceState)
39 | {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_chat);
42 |
43 | recyclerView = (RecyclerView) findViewById(R.id.contacts_list);
44 | recyclerView.setHasFixedSize(true);
45 |
46 | recyclerView.setLayoutManager(layoutManager);
47 | selectUsers = new ArrayList();
48 | showContacts();
49 |
50 |
51 |
52 |
53 | }
54 |
55 |
56 |
57 | private void showContacts () {
58 | // Check the SDK version and whether the permission is already granted or not.
59 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
60 | requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, PERMISSIONS_REQUEST_READ_CONTACTS);
61 | //After this point you wait for callback in onRequestPermissionsResult(int, String[], int[]) overriden method
62 | } else {
63 | // Android version is lesser than 6.0 or the permission is already granted.
64 | phones = getApplicationContext().getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC");
65 | LoadContact loadContact = new LoadContact();
66 | loadContact.execute();
67 | }
68 | }
69 |
70 | @Override
71 | public void onRequestPermissionsResult ( int requestCode, String[] permissions,
72 | int[] grantResults){
73 | if (requestCode == PERMISSIONS_REQUEST_READ_CONTACTS) {
74 | if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
75 | // Permission is granted
76 | showContacts();
77 | } else {
78 | Toast.makeText(this, "Until you grant the permission, we canot display the names", Toast.LENGTH_SHORT).show();
79 | }
80 | }
81 | }
82 |
83 | class LoadContact extends AsyncTask {
84 | @Override
85 | protected void onPreExecute() {
86 | super.onPreExecute();
87 |
88 | }
89 |
90 | @Override
91 | protected Void doInBackground(Void... voids) {
92 | // Get Contact list from Phone
93 |
94 | if (phones != null) {
95 | Log.e("count", "" + phones.getCount());
96 | if (phones.getCount() == 0) {
97 |
98 | }
99 |
100 | while (phones.moveToNext()) {
101 | Bitmap bit_thumb = null;
102 | String id = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));
103 | String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
104 | String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
105 |
106 |
107 | Contacts selectUser = new Contacts();
108 | selectUser.setName(name);
109 | selectUser.setPhone(phoneNumber);
110 | selectUsers.add(selectUser);
111 |
112 |
113 | }
114 | } else {
115 | Log.e("Cursor close 1", "----------------");
116 | }
117 |
118 | return null;
119 | }
120 |
121 | @Override
122 | protected void onPostExecute(Void aVoid) {
123 | super.onPostExecute(aVoid);
124 | LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
125 | // sortContacts();
126 | int count = selectUsers.size();
127 | ArrayList removed = new ArrayList<>();
128 | ArrayList contacts = new ArrayList<>();
129 | for (int i = 0; i < selectUsers.size(); i++) {
130 | Contacts inviteFriendsProjo = selectUsers.get(i);
131 |
132 | if (inviteFriendsProjo.getName().matches("\\d+(?:\\.\\d+)?") || inviteFriendsProjo.getName().trim().length() == 0) {
133 | removed.add(inviteFriendsProjo);
134 | Log.d("Removed Contact", new Gson().toJson(inviteFriendsProjo));
135 | } else {
136 | contacts.add(inviteFriendsProjo);
137 | }
138 | }
139 | contacts.addAll(removed);
140 | selectUsers = contacts;
141 | adapter = new RecyclerAdapter(inflater, selectUsers);
142 | recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
143 | recyclerView.setAdapter(adapter);
144 |
145 | }
146 | }
147 |
148 |
149 |
150 |
151 |
152 | }
153 |
154 |
155 |
156 |
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/ui/profile/ProfileFragment.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery.ui.profile;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.ContentResolver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.SharedPreferences;
8 | import android.graphics.Bitmap;
9 | import android.net.Uri;
10 | import android.os.Bundle;
11 | import android.provider.MediaStore;
12 | import android.util.Log;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.widget.Button;
17 | import android.widget.ImageView;
18 | import android.widget.TextView;
19 | import android.widget.Toast;
20 |
21 | import androidx.annotation.Nullable;
22 | import androidx.annotation.NonNull;
23 | import androidx.fragment.app.Fragment;
24 | import androidx.lifecycle.Observer;
25 | import androidx.lifecycle.ViewModelProviders;
26 |
27 | import com.bumptech.glide.Glide;
28 | import com.bumptech.glide.Registry;
29 | import com.bumptech.glide.annotation.GlideModule;
30 | import com.bumptech.glide.module.AppGlideModule;
31 | import com.firebase.ui.storage.images.FirebaseImageLoader;
32 | import com.google.android.gms.tasks.OnFailureListener;
33 | import com.google.android.gms.tasks.OnSuccessListener;
34 | import com.google.firebase.database.DataSnapshot;
35 | import com.google.firebase.database.DatabaseError;
36 | import com.google.firebase.database.DatabaseReference;
37 | import com.google.firebase.database.FirebaseDatabase;
38 | import com.google.firebase.database.ValueEventListener;
39 | import com.google.firebase.storage.FirebaseStorage;
40 | import com.google.firebase.storage.OnProgressListener;
41 | import com.google.firebase.storage.StorageReference;
42 | import com.google.firebase.storage.UploadTask;
43 | import com.saumya.chattery.R;
44 |
45 | import java.io.IOException;
46 | import java.io.InputStream;
47 | import java.util.UUID;
48 |
49 | import static android.app.Activity.RESULT_OK;
50 |
51 | public class ProfileFragment extends Fragment {
52 |
53 | private ProfileViewModel profileViewModel;
54 | FirebaseDatabase firebaseDatabase;
55 | DatabaseReference databaseReference;
56 |
57 |
58 | ImageView ProfilePicture;
59 | private Uri filePath;
60 | private ImageView ChoosePicture;
61 | Button btnUpload;
62 | FirebaseStorage storage;
63 | StorageReference storageReference;
64 |
65 | private final int PICK_IMAGE_REQUEST = 10;
66 | SharedPreferences sharedPreferences;
67 |
68 |
69 | TextView tvName, tvPhone;
70 | String name, phone, url;
71 |
72 | public View onCreateView(@NonNull LayoutInflater inflater,
73 | ViewGroup container, Bundle savedInstanceState) {
74 | profileViewModel =
75 | ViewModelProviders.of(this).get(ProfileViewModel.class);
76 | View root = inflater.inflate(R.layout.fragment_profile, container, false);
77 |
78 |
79 | ProfilePicture = root.findViewById(R.id.imgProfile);
80 | ChoosePicture = root.findViewById(R.id.imgChoose);
81 | btnUpload = root.findViewById(R.id.btnSavePic);
82 |
83 |
84 | sharedPreferences = getContext().getSharedPreferences("User", Context.MODE_PRIVATE);
85 |
86 | name = sharedPreferences.getString("Name", "");
87 | phone = sharedPreferences.getString("Phone", "");
88 |
89 | firebaseDatabase = FirebaseDatabase.getInstance("https://chattery-23cb9.firebaseio.com/");
90 | databaseReference = firebaseDatabase.getReference("Chatter/" + name + "/ImageUrl");
91 | storageReference = FirebaseStorage.getInstance().getReference();
92 |
93 | tvName = root.findViewById(R.id.tvName);
94 | tvPhone = root.findViewById(R.id.tvPhone);
95 |
96 | tvName.setText(name);
97 | tvPhone.setText(phone);
98 |
99 | databaseReference.addValueEventListener(new ValueEventListener() {
100 | @Override
101 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
102 |
103 | if(dataSnapshot.exists()){
104 |
105 | url = dataSnapshot.getValue().toString();
106 | Glide.with(requireContext())
107 | .load(url)
108 | .into(ProfilePicture);
109 |
110 | }
111 | }
112 |
113 | @Override
114 | public void onCancelled(@NonNull DatabaseError databaseError) {
115 |
116 | }
117 | });
118 |
119 |
120 |
121 |
122 | ChoosePicture.setOnClickListener(new View.OnClickListener() {
123 | @Override
124 | public void onClick(View v) {
125 | ChooseImage();
126 | }
127 | });
128 |
129 | btnUpload.setOnClickListener(new View.OnClickListener() {
130 | @Override
131 | public void onClick(View v) {
132 | uploadImage();
133 |
134 | Toast.makeText(getContext(), "Updating your profile", Toast.LENGTH_SHORT).show();
135 | }
136 |
137 | });
138 |
139 |
140 | return root;
141 | }
142 |
143 |
144 | private void ChooseImage() {
145 |
146 | Intent intent = new Intent();
147 | intent.setType("image/*");
148 | intent.setAction(Intent.ACTION_GET_CONTENT);
149 | startActivityForResult(Intent.createChooser(intent, "Select Profile Picture"), PICK_IMAGE_REQUEST);
150 |
151 | }
152 |
153 | @Override
154 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
155 | super.onActivityResult(requestCode, resultCode, data);
156 | if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
157 | filePath = data.getData();
158 | try {
159 | Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), filePath);
160 | ProfilePicture.setImageBitmap(bitmap);
161 | } catch (IOException e) {
162 | e.printStackTrace();
163 | }
164 | }
165 |
166 | }
167 |
168 | private void uploadImage() {
169 |
170 | if (filePath != null) {
171 | final ProgressDialog progressDialog = new ProgressDialog(getContext());
172 | progressDialog.setTitle("Uploading...");
173 | progressDialog.show();
174 |
175 | StorageReference ref = storageReference.child("images/" + UUID.randomUUID().toString());
176 | ref.putFile(filePath)
177 | .addOnSuccessListener(new OnSuccessListener() {
178 | @Override
179 | public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
180 | progressDialog.dismiss();
181 | Uri downloadUrl = taskSnapshot.getUploadSessionUri();
182 | Log.e("Upload", "onSuccess: " + downloadUrl.toString() );
183 | databaseReference.setValue(downloadUrl.toString());
184 | Toast.makeText(getContext(), "Uploaded", Toast.LENGTH_SHORT).show();
185 | }
186 | })
187 | .addOnFailureListener(new OnFailureListener() {
188 | @Override
189 | public void onFailure(@NonNull Exception e) {
190 | progressDialog.dismiss();
191 | Toast.makeText(getContext(), "Failed" + e.getMessage(), Toast.LENGTH_SHORT).show();
192 | }
193 | })
194 | .addOnProgressListener(new OnProgressListener() {
195 | @Override
196 | public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
197 | double progress = (100.0 * taskSnapshot.getBytesTransferred() / taskSnapshot
198 | .getTotalByteCount());
199 | progressDialog.setMessage("Uploaded " + (int) progress + "%");
200 | }
201 | });
202 | }
203 | }
204 |
205 |
206 | @GlideModule
207 | public class MyAppGlideModule extends AppGlideModule {
208 |
209 | @Override
210 | public void registerComponents(Context context, Glide glide, Registry registry) {
211 | // Register FirebaseImageLoader to handle StorageReference
212 | registry.append(StorageReference.class, InputStream.class,
213 | new FirebaseImageLoader.Factory());
214 | }
215 | }
216 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/saumya/chattery/HomeChattingActivity.java:
--------------------------------------------------------------------------------
1 | package com.saumya.chattery;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.text.Editable;
9 | import android.text.InputFilter;
10 | import android.text.TextWatcher;
11 | import android.util.Log;
12 | import android.view.View;
13 | import android.widget.Button;
14 | import android.widget.EditText;
15 | import android.widget.ImageButton;
16 | import android.widget.ListView;
17 | import android.widget.ProgressBar;
18 | import android.widget.TextView;
19 | import android.widget.Toast;
20 |
21 | import androidx.annotation.NonNull;
22 | import androidx.annotation.Nullable;
23 | import androidx.appcompat.app.AppCompatActivity;
24 |
25 | import com.google.android.gms.tasks.OnSuccessListener;
26 | import com.google.firebase.auth.FirebaseAuth;
27 | import com.google.firebase.auth.FirebaseUser;
28 | import com.google.firebase.database.ChildEventListener;
29 | import com.google.firebase.database.DataSnapshot;
30 | import com.google.firebase.database.DatabaseError;
31 | import com.google.firebase.database.DatabaseReference;
32 | import com.google.firebase.database.FirebaseDatabase;
33 | import com.google.firebase.storage.FirebaseStorage;
34 | import com.google.firebase.storage.StorageReference;
35 | import com.google.firebase.storage.UploadTask;
36 |
37 | import java.util.ArrayList;
38 | import java.util.Arrays;
39 | import java.util.List;
40 |
41 | public class HomeChattingActivity extends AppCompatActivity {
42 |
43 | private static final String TAG ="HomeChattingActivity";
44 |
45 | //Intent intent = getIntent().getStringExtra();
46 |
47 |
48 | public static final String ANONYMOUS = "anonymous";
49 | public static final int DEFAULT_MSG_LENGTH_LIMIT = 1000;
50 | public static final int RC_SIGN_IN = 1;
51 | private static final int RC_PHOTO_PICKER = 2;
52 |
53 | private ListView messageListView;
54 | private MessageAdapter messageAdapter;
55 |
56 |
57 | private ImageButton photoPickerButton;
58 | private EditText messageEditText;
59 | private Button sendButton;
60 |
61 | private String mUsername;
62 |
63 | Bundle bundle;
64 | String friendname,friendphone;
65 | private FirebaseDatabase firebaseDatabase;
66 | private DatabaseReference databaseReference;
67 | private FirebaseStorage mFirebaseStorage;
68 | private StorageReference mChatPhotosStorageReference;
69 |
70 | String name, phone;
71 | TextView tvFriend ;
72 | private ChildEventListener childEventListener;
73 |
74 | SharedPreferences sharedPreferences;
75 | @Override
76 | protected void onCreate(Bundle savedInstanceState) {
77 |
78 | super.onCreate(savedInstanceState);
79 | setContentView(R.layout.activity_home_chatting);
80 |
81 |
82 | bundle = this.getIntent().getExtras();
83 | friendname = bundle.getString("FriendName");
84 | friendphone = bundle.getString("FriendPhone");
85 |
86 | tvFriend = findViewById(R.id.friendName);
87 | mUsername = ANONYMOUS;
88 | Log.e("FriendHomeChat", "onCreate: " + friendname + friendphone);
89 |
90 | messageListView = (ListView) findViewById(R.id.messageListView);
91 | photoPickerButton = (ImageButton) findViewById(R.id.photoPickerButton);
92 | messageEditText = (EditText) findViewById(R.id.messageEditText);
93 | sendButton = (Button) findViewById(R.id.sendButton);
94 |
95 | sharedPreferences = getSharedPreferences("User", Context.MODE_PRIVATE);
96 | name = sharedPreferences.getString("Name","");
97 | phone = sharedPreferences.getString("Phone ","");
98 | firebaseDatabase = FirebaseDatabase.getInstance("https://chattery-23cb9.firebaseio.com/");
99 | databaseReference = firebaseDatabase.getReference("Chatter/" + name +"/Friends");
100 | mFirebaseStorage = FirebaseStorage.getInstance();
101 | mChatPhotosStorageReference = mFirebaseStorage.getReference().child("chat_photos");
102 |
103 | List messageModels = new ArrayList<>();
104 |
105 | messageAdapter = new MessageAdapter(getBaseContext() , R.layout.item_message , messageModels);
106 | messageListView.setAdapter(messageAdapter);
107 | tvFriend.setText(friendname + " " + "talking ✔");
108 |
109 | photoPickerButton.setOnClickListener(new View.OnClickListener() {
110 | @Override
111 | public void onClick(View v) {
112 |
113 | Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
114 | intent.setType("image/jpeg");
115 | intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
116 |
117 | startActivityForResult(Intent.createChooser(intent, "Complete action using"), RC_PHOTO_PICKER);
118 | }
119 | });
120 |
121 |
122 |
123 |
124 |
125 | messageEditText.addTextChangedListener(new TextWatcher() {
126 | @Override
127 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
128 |
129 | }
130 |
131 | @Override
132 | public void onTextChanged(CharSequence s, int start, int before, int count) {
133 |
134 | if (s.toString().trim().length()> 0){
135 | sendButton.setEnabled(true);
136 | }else{
137 | sendButton.setEnabled(false);
138 | }
139 | }
140 |
141 | @Override
142 | public void afterTextChanged(Editable s) {
143 |
144 | }
145 | });
146 |
147 |
148 | messageEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT)});
149 |
150 |
151 |
152 | sendButton.setOnClickListener(new View.OnClickListener() {
153 | @Override
154 | public void onClick(View view) {
155 |
156 | MessageModel messageModel = new MessageModel(messageEditText.getText().toString() , mUsername , null);
157 |
158 |
159 | databaseReference.child(friendname).child("Message").push().setValue(messageEditText.getText().toString());
160 | databaseReference.child(friendname).child("Phone").setValue(friendphone);
161 |
162 | // Clear input box
163 | messageEditText.setText("");
164 | Toast.makeText(getBaseContext(), friendname + " is receiving your messages" , Toast.LENGTH_SHORT).show();
165 |
166 | }
167 | });
168 |
169 |
170 |
171 |
172 | }
173 |
174 | @Override
175 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
176 | super.onActivityResult(requestCode, resultCode, data);
177 |
178 | if (requestCode == RC_PHOTO_PICKER && resultCode == RESULT_OK) {
179 | Uri selectedImageUri = data.getData();
180 |
181 | // Get a reference to store file at chat_photos/
182 | StorageReference photoRef = mChatPhotosStorageReference.child(selectedImageUri.getLastPathSegment());
183 |
184 | // Upload file to Firebase Storage
185 | photoRef.putFile(selectedImageUri)
186 | .addOnSuccessListener(this, new OnSuccessListener() {
187 |
188 | public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
189 | // When the image has successfully uploaded, we get its download URL
190 | Uri downloadUrl = taskSnapshot.getUploadSessionUri();
191 |
192 | // Set the download URL to the message box, so that the user can send it to the database
193 | MessageModel messageModel = new MessageModel(null, mUsername, downloadUrl.toString());
194 | databaseReference.child(friendname).child("Images").push().setValue(downloadUrl.toString());
195 | }
196 |
197 | });
198 | }
199 | }
200 |
201 |
202 | private void onSignedInInitialize(String username){
203 | mUsername=username;
204 | attachDataBaseListener();
205 | }
206 |
207 |
208 |
209 | private void onSignedOutCleanUp(){
210 | mUsername=ANONYMOUS;
211 | messageAdapter.clear();
212 | detachDatabaseListener();
213 | }
214 |
215 |
216 |
217 | private void attachDataBaseListener(){
218 |
219 | if (childEventListener==null){
220 | childEventListener=new ChildEventListener() {
221 | @Override
222 | public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
223 |
224 | Log.e(TAG, "onChildAdded Messages "+ dataSnapshot );
225 | MessageModel messageModel=dataSnapshot.getValue(MessageModel.class);
226 | messageAdapter.add(messageModel);
227 | }
228 |
229 | @Override
230 | public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
231 |
232 | }
233 |
234 | @Override
235 | public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {
236 |
237 | }
238 |
239 | @Override
240 | public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
241 |
242 | }
243 |
244 | @Override
245 | public void onCancelled(@NonNull DatabaseError databaseError) {
246 |
247 | }
248 | };
249 | databaseReference.addChildEventListener(childEventListener);
250 | }
251 | }
252 |
253 |
254 |
255 | private void detachDatabaseListener(){
256 | if (childEventListener!=null){
257 | databaseReference.removeEventListener(childEventListener);
258 | childEventListener=null;
259 | }
260 | }
261 |
262 |
263 | }
264 |
--------------------------------------------------------------------------------