├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── sign.png
│ │ │ │ ├── borrow1.jpeg
│ │ │ │ ├── society.jpg
│ │ │ │ ├── chat_image.png
│ │ │ │ ├── ic_logout.png
│ │ │ │ ├── meet_people.gif
│ │ │ │ ├── nav_header_bg.png
│ │ │ │ ├── profile_header.jpg
│ │ │ │ ├── circle.xml
│ │ │ │ ├── chat_date_divider_bg.xml
│ │ │ │ ├── their_message.xml
│ │ │ │ ├── bg_edittext.xml
│ │ │ │ ├── my_message.xml
│ │ │ │ ├── ic_send.xml
│ │ │ │ ├── ic_home.xml
│ │ │ │ ├── ic_delete_white.xml
│ │ │ │ ├── ic_verified.xml
│ │ │ │ ├── launch_screen.xml
│ │ │ │ ├── ic_chat_white.xml
│ │ │ │ ├── ic_save.xml
│ │ │ │ ├── ic_feedback.xml
│ │ │ │ ├── ic_error.xml
│ │ │ │ ├── ic_chat.xml
│ │ │ │ ├── ic_mode_edit.xml
│ │ │ │ ├── bg_edittext_normal.xml
│ │ │ │ ├── bg_edittext_focused.xml
│ │ │ │ ├── ic_location_city_black_24dp.xml
│ │ │ │ ├── ic_delete_forever.xml
│ │ │ │ ├── ic_account_circle_black_24dp.xml
│ │ │ │ ├── ic_my_location.xml
│ │ │ │ ├── ic_share.xml
│ │ │ │ └── ic_face.xml
│ │ │ ├── font
│ │ │ │ └── font_montserrat.ttf
│ │ │ ├── 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.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_maps.xml
│ │ │ │ ├── activity_peer_to_peer_chat.xml
│ │ │ │ ├── activity_pick_location.xml
│ │ │ │ ├── activity_contact_list.xml
│ │ │ │ ├── activity_splash.xml
│ │ │ │ ├── activity_chat.xml
│ │ │ │ ├── chat_date_divider_layout.xml
│ │ │ │ ├── chat_list_item.xml
│ │ │ │ ├── my_message_layout.xml
│ │ │ │ ├── nav_header.xml
│ │ │ │ ├── recent_chat_list_user.xml
│ │ │ │ ├── fragment_recent_chats.xml
│ │ │ │ ├── fragment_dashboard.xml
│ │ │ │ ├── activity_address.xml
│ │ │ │ ├── fragment_post_dashboard.xml
│ │ │ │ ├── their_message_layout.xml
│ │ │ │ ├── fragment_group_chat.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── fragment_pending_requests.xml
│ │ │ │ ├── shared_item_layout.xml
│ │ │ │ ├── activity_edit_profile.xml
│ │ │ │ ├── your_post_query_item.xml
│ │ │ │ ├── pending_post_item.xml
│ │ │ │ ├── post_item_layout.xml
│ │ │ │ ├── activity_post.xml
│ │ │ │ ├── pending_post_query_item.xml
│ │ │ │ └── show_profile.xml
│ │ │ └── menu
│ │ │ │ ├── post_menu.xml
│ │ │ │ ├── edit_profile_menu.xml
│ │ │ │ └── drawer_menu.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── zero
│ │ │ │ └── shareby
│ │ │ │ ├── Utils
│ │ │ │ └── DialogBuilder.java
│ │ │ │ ├── activities
│ │ │ │ ├── SplashActivity.java
│ │ │ │ ├── MyAppIntro.java
│ │ │ │ ├── PickLocation.java
│ │ │ │ ├── UserProfile.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── PostActivity.java
│ │ │ │ ├── adapters
│ │ │ │ ├── ChatPagerAdapter.java
│ │ │ │ ├── PagerAdapter.java
│ │ │ │ ├── GroupContactsAdapter.java
│ │ │ │ ├── RecentChatsAdapter.java
│ │ │ │ ├── DashboardAdapter.java
│ │ │ │ ├── ChatsAdapter.java
│ │ │ │ └── PendingRequestsAdapter.java
│ │ │ │ ├── models
│ │ │ │ ├── SampleSlide.java
│ │ │ │ ├── CreateGroup.java
│ │ │ │ ├── UserDetails.java
│ │ │ │ └── Post.java
│ │ │ │ ├── chats
│ │ │ │ ├── ChatActivity.java
│ │ │ │ ├── Chat.java
│ │ │ │ ├── ContactListActivity.java
│ │ │ │ └── RecentChats.java
│ │ │ │ ├── fcm
│ │ │ │ └── FirebaseMessaging.java
│ │ │ │ └── utils
│ │ │ │ └── Utilities.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── zero
│ │ │ └── shareby
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── zero
│ │ └── shareby
│ │ └── ExampleInstrumentedTest.java
├── release
│ └── output.json
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── caches
│ ├── gradle_models.ser
│ └── build_file_checksums.ser
├── vcs.xml
├── runConfigurations.xml
├── gradle.xml
├── codeStyles
│ └── Project.xml
├── assetWizardSettings.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── scrnshots
├── Screenshot_20190330-211559.png
├── Screenshot_20190330-211703.png
├── Screenshot_20190330-211722.png
├── Screenshot_20190330-211921.png
├── Screenshot_20190330-211927.png
├── Screenshot_20190419-181817.png
├── Screenshot_20190424-112317.png
└── Screenshot_20190424-112327.png
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
├── firebase function
└── index.js
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sign.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/drawable/sign.png
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/app/src/main/res/drawable/borrow1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/drawable/borrow1.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/society.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/drawable/society.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chat_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/drawable/chat_image.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_logout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/drawable/ic_logout.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/meet_people.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/drawable/meet_people.gif
--------------------------------------------------------------------------------
/app/src/main/res/font/font_montserrat.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/font/font_montserrat.ttf
--------------------------------------------------------------------------------
/scrnshots/Screenshot_20190330-211559.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/scrnshots/Screenshot_20190330-211559.png
--------------------------------------------------------------------------------
/scrnshots/Screenshot_20190330-211703.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/scrnshots/Screenshot_20190330-211703.png
--------------------------------------------------------------------------------
/scrnshots/Screenshot_20190330-211722.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/scrnshots/Screenshot_20190330-211722.png
--------------------------------------------------------------------------------
/scrnshots/Screenshot_20190330-211921.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/scrnshots/Screenshot_20190330-211921.png
--------------------------------------------------------------------------------
/scrnshots/Screenshot_20190330-211927.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/scrnshots/Screenshot_20190330-211927.png
--------------------------------------------------------------------------------
/scrnshots/Screenshot_20190419-181817.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/scrnshots/Screenshot_20190419-181817.png
--------------------------------------------------------------------------------
/scrnshots/Screenshot_20190424-112317.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/scrnshots/Screenshot_20190424-112317.png
--------------------------------------------------------------------------------
/scrnshots/Screenshot_20190424-112327.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/scrnshots/Screenshot_20190424-112327.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/nav_header_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/drawable/nav_header_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/profile_header.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/drawable/profile_header.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/HEAD/app/src/main/res/mipmap-anydpi-v26/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/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/jpatel0/ShareBy/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpatel0/ShareBy/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/jpatel0/ShareBy/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/jpatel0/ShareBy/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chat_date_divider_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jan 17 23:12:38 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-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/their_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_maps.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_edittext.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/my_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_send.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/libraries
5 | /.idea/modules.xml
6 | /.idea/workspace.xml
7 | .DS_Store
8 | /build
9 | /captures
10 | /app/release/output.json
11 | .externalNativeBuild
12 | *.apk
13 | /app/google-services.json
14 | /app/src/debug/res/values/google_maps_api.xml
15 | /app/src/release/res/values/google_maps_api.xml
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/post_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete_white.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_peer_to_peer_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_verified.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/launch_screen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_chat_white.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_save.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_feedback.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_error.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/test/java/com/zero/shareby/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby;
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/res/drawable/ic_chat.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_mode_edit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_edittext_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_edittext_focused.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_pick_location.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_location_city_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/Utils/DialogBuilder.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.Utils;
2 |
3 | import android.content.Context;
4 | import android.support.v7.app.AlertDialog;
5 |
6 | public class DialogBuilder {
7 | public static AlertDialog.Builder getDialogBuilder(Context context, String title, String message){
8 | AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(context);
9 | builder.setTitle(title);
10 | builder.setMessage(message);
11 | return builder;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete_forever.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_contact_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.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/menu/edit_profile_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_my_location.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_face.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/chat_date_divider_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/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/zero/shareby/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.zero.shareby", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #A9A9A9
7 | #004C00
8 | #4b49d3
9 | #64bdcf
10 | #FFFFFF
11 | #EEEAEA
12 | #48B3FF
13 | #0b0
14 | #FF0000
15 | #feefc3
16 | #FFFFFF
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
18 |
19 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/chat_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ShareBy
3 |
4 | Open Navigation Drawer
5 | Close Navigation Drawer
6 | Sign Out
7 | Map
8 | lat
9 | lng
10 | old_lat
11 | old_lng
12 | country
13 | pin
14 | key1
15 | key2
16 | Cheers Everyone!!!
17 |
18 |
19 | Hello blank fragment
20 | Pick Location
21 |
22 |
23 | - Select from here
24 | - Ask a Question
25 | - Request an Item
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/my_message_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
21 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/activities/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.activities;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.os.Handler;
6 | import android.preference.PreferenceManager;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.os.Bundle;
9 |
10 | import com.zero.shareby.R;
11 |
12 | import static com.zero.shareby.activities.MyAppIntro.APP_INTRO_KEY;
13 |
14 | public class SplashActivity extends AppCompatActivity {
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_splash);
20 |
21 | final SharedPreferences pref= PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
22 |
23 |
24 |
25 | new Handler().postDelayed(new Runnable() {
26 | @Override
27 | public void run() {
28 | if(!pref.getBoolean(APP_INTRO_KEY,true)){
29 | startActivity(new Intent(SplashActivity.this,LoginActivity.class));
30 | finish();
31 | }
32 | startActivity(new Intent(SplashActivity.this,MyAppIntro.class));
33 | finish();
34 | }
35 | },400);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recent_chat_list_user.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/adapters/ChatPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.adapters;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentStatePagerAdapter;
7 |
8 | import com.zero.shareby.chats.GroupChatFragment;
9 | import com.zero.shareby.chats.RecentChats;
10 |
11 |
12 | public class ChatPagerAdapter extends FragmentStatePagerAdapter {
13 |
14 | public ChatPagerAdapter(FragmentManager fm) {
15 | super(fm);
16 | }
17 |
18 | @Override
19 | public Fragment getItem(int position) {
20 | switch(position){
21 | case 0:
22 | return new GroupChatFragment();
23 |
24 | case 1:
25 | return new RecentChats();
26 |
27 | default:
28 | return null;
29 | }
30 | }
31 |
32 | @Override
33 | public int getCount() {
34 | return 2;
35 | }
36 |
37 | @Nullable
38 | @Override
39 | public CharSequence getPageTitle(int position) {
40 | switch(position){
41 | case 0:
42 | return "Group Chat";
43 |
44 | case 1:
45 | return "Recent Chats";
46 |
47 | default:
48 | return "default";
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/drawer_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/models/SampleSlide.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.models;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | public class SampleSlide extends Fragment {
11 |
12 | private static final String ARG_LAYOUT_RES_ID = "layoutResId";
13 | private int layoutResId;
14 |
15 | public static SampleSlide newInstance(int layoutResId) {
16 | SampleSlide sampleSlide = new SampleSlide();
17 |
18 | Bundle args = new Bundle();
19 | args.putInt(ARG_LAYOUT_RES_ID, layoutResId);
20 | sampleSlide.setArguments(args);
21 |
22 | return sampleSlide;
23 | }
24 |
25 | @Override
26 | public void onCreate(@Nullable Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 |
29 | if (getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) {
30 | layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID);
31 | }
32 | }
33 |
34 | @Nullable
35 | @Override
36 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
37 | @Nullable Bundle savedInstanceState) {
38 | return inflater.inflate(layoutResId, container, false);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/models/CreateGroup.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.models;
2 |
3 | public class CreateGroup {
4 | private String grpName;
5 | private int memberCount;
6 | private double radius;
7 | private double latitude;
8 | private double longitude;
9 |
10 | public CreateGroup(String gName,int mCount,double rad,double lat,double lng){
11 | grpName=gName;
12 | memberCount=mCount;
13 | radius=rad;
14 | latitude=lat;
15 | longitude=lng;
16 | }
17 |
18 | public String getGrpName() {
19 | return grpName;
20 | }
21 |
22 | public void setGrpName(String grpName) {
23 | this.grpName = grpName;
24 | }
25 |
26 | public int getMemberCount() {
27 | return memberCount;
28 | }
29 |
30 | public void setMemberCount(int memberCount) {
31 | this.memberCount = memberCount;
32 | }
33 |
34 | public double getRadius() {
35 | return radius;
36 | }
37 |
38 | public void setRadius(double radius) {
39 | this.radius = radius;
40 | }
41 |
42 | public double getLatitude() {
43 | return latitude;
44 | }
45 |
46 | public void setLatitude(double latitude) {
47 | this.latitude = latitude;
48 | }
49 |
50 | public double getLongitude() {
51 | return longitude;
52 | }
53 |
54 | public void setLongitude(double longitude) {
55 | this.longitude = longitude;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/chats/ChatActivity.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.chats;
2 |
3 | import android.support.design.widget.TabLayout;
4 | import android.support.v4.view.ViewPager;
5 | import android.support.v7.app.ActionBar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 |
9 | import com.zero.shareby.R;
10 | import com.zero.shareby.adapters.ChatPagerAdapter;
11 |
12 | public class ChatActivity extends AppCompatActivity {
13 | private static final String TAG = "ChatsActivity";
14 |
15 | ViewPager viewPager;
16 | ChatPagerAdapter pagerAdapter;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_chat);
22 |
23 | ActionBar actionBar=getSupportActionBar();
24 | if (actionBar != null) {
25 | actionBar.setDisplayHomeAsUpEnabled(true);
26 | }
27 |
28 | viewPager= findViewById(R.id.chat_view_pager);
29 | pagerAdapter=new ChatPagerAdapter(getSupportFragmentManager());
30 | viewPager.setAdapter(pagerAdapter);
31 | TabLayout tab=findViewById(R.id.chat_tab_layout);
32 | tab.setupWithViewPager(viewPager);
33 | }
34 |
35 |
36 | @Override
37 | protected void onResume() {
38 | super.onResume();
39 | viewPager.setCurrentItem(1);
40 |
41 | }
42 |
43 | @Override
44 | protected void onPause() {
45 | super.onPause();
46 |
47 | }
48 |
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_recent_chats.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
18 |
19 |
20 |
21 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/adapters/PagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.adapters;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentPagerAdapter;
8 |
9 | import com.zero.shareby.fragments.DashboardFragment;
10 | import com.zero.shareby.fragments.PendingRequestsFragment;
11 | import com.zero.shareby.fragments.PostDashboard;
12 |
13 | public class PagerAdapter extends FragmentPagerAdapter {
14 |
15 | private Context mContext;
16 | public PagerAdapter(Context context,FragmentManager fm) {
17 | super(fm);
18 | mContext=context;
19 | }
20 |
21 | @Override
22 | public Fragment getItem(int position) {
23 | switch (position){
24 | case 0:
25 | return DashboardFragment.getInstance();
26 |
27 | case 1:
28 | return PendingRequestsFragment.getInstance();
29 |
30 | case 2:
31 | return PostDashboard.getInstance();
32 |
33 | }
34 | return null;
35 | }
36 |
37 | @Override
38 | public int getCount() {
39 | return 3;
40 | }
41 |
42 | @Nullable
43 | @Override
44 | public CharSequence getPageTitle(int position) {
45 | switch (position){
46 | case 0:
47 | return "Dashboard";
48 |
49 | case 1:
50 | return "Requests";
51 |
52 | case 2:
53 | return "Your Posts";
54 | }
55 | return "Default";
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_dashboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
31 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_address.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
22 |
23 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/chats/Chat.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.chats;
2 |
3 | public class Chat {
4 | private String sentBy,receivedBy,message;
5 | private long timestamp;
6 | boolean belongsToCurrentUser,isDivider;
7 |
8 | public Chat() {
9 | }
10 |
11 | public boolean isDivider() {
12 | return isDivider;
13 | }
14 |
15 | public void setDivider(boolean divider) {
16 | isDivider = divider;
17 | }
18 |
19 | public Chat(String sentBy, String receivedBy, String message, long timestamp) {
20 | this.sentBy = sentBy;
21 | this.receivedBy = receivedBy;
22 | this.message = message;
23 | this.timestamp = timestamp;
24 | }
25 |
26 | public boolean isBelongsToCurrentUser() {
27 | return belongsToCurrentUser;
28 | }
29 |
30 | public void setBelongsToCurrentUser(boolean belongsToCurrentUser) {
31 | this.belongsToCurrentUser = belongsToCurrentUser;
32 | }
33 |
34 | public String getSentBy() {
35 | return sentBy;
36 | }
37 |
38 | public void setSentBy(String sentBy) {
39 | this.sentBy = sentBy;
40 | }
41 |
42 | public String getReceivedBy() {
43 | return receivedBy;
44 | }
45 |
46 | public void setReceivedBy(String receivedBy) {
47 | this.receivedBy = receivedBy;
48 | }
49 |
50 | public String getMessage() {
51 | return message;
52 | }
53 |
54 | public void setMessage(String message) {
55 | this.message = message;
56 | }
57 |
58 | public long getTimestamp() {
59 | return timestamp;
60 | }
61 |
62 | public void setTimestamp(long timestamp) {
63 | this.timestamp = timestamp;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_post_dashboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
20 |
21 |
28 |
29 |
30 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/their_message_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
24 |
25 |
38 |
39 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_group_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
19 |
23 |
33 |
34 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/adapters/GroupContactsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.adapters;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ArrayAdapter;
10 | import android.widget.TextView;
11 |
12 | import com.bumptech.glide.Glide;
13 | import com.zero.shareby.R;
14 | import com.zero.shareby.models.UserDetails;
15 |
16 | import java.util.List;
17 |
18 | import de.hdodenhof.circleimageview.CircleImageView;
19 |
20 | public class GroupContactsAdapter extends ArrayAdapter {
21 |
22 | private MyListenerInterface listenerInterface;
23 |
24 | public interface MyListenerInterface{
25 | void clicked(UserDetails user);
26 | }
27 |
28 |
29 | public GroupContactsAdapter(@NonNull Context context, @NonNull List objects,MyListenerInterface listener) {
30 | super(context, R.layout.recent_chat_list_user, objects);
31 | listenerInterface = listener;
32 | }
33 |
34 | @NonNull
35 | @Override
36 | public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
37 | View v=convertView;
38 | if (convertView==null)
39 | v=LayoutInflater.from(getContext()).inflate(R.layout.recent_chat_list_user,parent,false);
40 | final UserDetails user = getItem(position);
41 | CircleImageView userImage = v.findViewById(R.id.friend_profile_image);
42 | TextView userNameTextView = v.findViewById(R.id.friend_name);
43 | Glide.with(getContext()).load(user.getPhotoUrl()).into(userImage);
44 | userNameTextView.setText(user.getName());
45 | v.setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | listenerInterface.clicked(user);
49 | }
50 | });
51 | return v;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/.idea/assetWizardSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/activities/MyAppIntro.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.activities;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 | import android.preference.PreferenceManager;
8 | import android.support.v4.app.Fragment;
9 |
10 | import com.github.paolorotolo.appintro.AppIntro2;
11 | import com.github.paolorotolo.appintro.AppIntro2Fragment;
12 | import com.zero.shareby.R;
13 |
14 |
15 | public class MyAppIntro extends AppIntro2 {
16 | public static final String APP_INTRO_KEY="app_intro_check_key";
17 | SharedPreferences pref;
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 |
22 | pref= PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
23 |
24 | if(!pref.getBoolean(APP_INTRO_KEY,true)){
25 | startActivity(new Intent(this,LoginActivity.class));
26 | finish();
27 | }
28 |
29 | addSlide(AppIntro2Fragment.newInstance("Welcome","This is Share NearBy App",R.drawable.society, Color.parseColor("#E91E63")));
30 | addSlide(AppIntro2Fragment.newInstance("Borrow","Post request to all neighbors instantly",R.drawable.borrow1, Color.parseColor("#9C27B0")));
31 | addSlide(AppIntro2Fragment.newInstance("Chat within app","Personal chats for privacy",R.drawable.chat_image, Color.parseColor("#2196F3")));
32 | addSlide(AppIntro2Fragment.newInstance("Time to get Started","Interact to know your neighbours",R.drawable.meet_people, Color.parseColor("#2196F3")));
33 |
34 | //setColorTransitionsEnabled(true);
35 | setSlideOverAnimation();
36 | }
37 |
38 | @Override
39 | public void onSkipPressed(Fragment currentFragment) {
40 | super.onSkipPressed(currentFragment);
41 | gotoLoginActivity();
42 | }
43 |
44 |
45 |
46 | @Override
47 | public void onDonePressed(Fragment currentFragment) {
48 | super.onDonePressed(currentFragment);
49 | gotoLoginActivity();
50 | }
51 |
52 | private void gotoLoginActivity(){
53 | SharedPreferences.Editor editor=pref.edit();
54 | editor.putBoolean(APP_INTRO_KEY,false);
55 | editor.apply();
56 | startActivity(new Intent(this,LoginActivity.class));
57 | finish();
58 | }
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
25 |
26 |
27 |
31 |
32 |
36 |
37 |
38 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/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/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | signingConfigs {
5 | config_release {
6 | try {
7 | storeFile file("D:/android/release_key.jks")
8 | storePassword KEYSTORE_PASSWORD
9 | keyAlias "sharebyKey"
10 | keyPassword KEY_PASSWORD
11 | }
12 | catch (ex) {
13 | throw new InvalidUserDataException("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
14 | }
15 | }
16 | }
17 | compileSdkVersion 27
18 | defaultConfig {
19 | applicationId "com.zero.shareby"
20 | minSdkVersion 21
21 | targetSdkVersion 29
22 | versionCode 1
23 | versionName "1.0"
24 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
25 | }
26 | buildTypes {
27 | release {
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
29 | signingConfig signingConfigs.config_release
30 | }
31 | }
32 | }
33 |
34 | dependencies {
35 | implementation fileTree(include: ['*.jar'], dir: 'libs')
36 | implementation 'com.android.support:appcompat-v7:27.1.1'
37 | implementation 'com.android.support:design:27.1.1'
38 | implementation 'com.android.support:support-compat:27.1.1'
39 | implementation 'com.google.android.gms:play-services-maps:16.1.0'
40 |
41 | implementation 'com.android.support:support-v4:27.1.1'
42 | implementation 'com.android.support:recyclerview-v7:27.1.1'
43 | implementation 'com.android.support:cardview-v7:27.1.1'
44 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
45 | testImplementation 'junit:junit:4.12'
46 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
47 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
48 | implementation 'com.github.apl-devs:appintro:v4.2.3'
49 | implementation 'com.google.firebase:firebase-core:19.2.0'
50 | implementation 'com.google.firebase:firebase-database:19.3.1'
51 | implementation 'com.google.firebase:firebase-storage:19.1.1'
52 | implementation 'com.google.firebase:firebase-auth:19.3.1'
53 | implementation 'com.firebaseui:firebase-ui-auth:6.3.0'
54 | implementation 'com.google.firebase:firebase-messaging:17.3.4'
55 | //for circular imageView
56 | implementation 'de.hdodenhof:circleimageview:3.1.0'
57 | implementation 'com.github.bumptech.glide:glide:4.11.0'
58 | annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
59 | implementation 'com.google.android.gms:play-services-ads:18.2.0'
60 |
61 | }
62 | apply plugin: 'com.google.gms.google-services'
63 |
--------------------------------------------------------------------------------
/.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 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_pending_requests.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
25 |
35 |
36 |
37 |
38 |
41 |
42 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/models/UserDetails.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.models;
2 |
3 | import java.io.Serializable;
4 |
5 | public class UserDetails implements Serializable {
6 | private String name,email,about;
7 | private String uid;
8 | private double latitude;
9 | private double longitude;
10 | private String phone,photoUrl;
11 | private String country,pin,key1,key2,tokenId;
12 | private int age;
13 |
14 | public UserDetails(){
15 | latitude=0.0;
16 | longitude=0.0;
17 | country="null";
18 | pin="null";
19 | key1="null";
20 | key2="null";
21 | name="null";
22 | }
23 |
24 | public String getEmail() {
25 | return email;
26 | }
27 |
28 | public void setEmail(String email) {
29 | this.email = email;
30 | }
31 |
32 | public String getAbout() {
33 | return about;
34 | }
35 |
36 | public void setAbout(String about) {
37 | this.about = about;
38 | }
39 |
40 | public int getAge() {
41 | return age;
42 | }
43 |
44 | public void setAge(int age) {
45 | this.age = age;
46 | }
47 |
48 | public String getTokenId() {
49 | return tokenId;
50 | }
51 |
52 | public void setTokenId(String tokenId) {
53 | this.tokenId = tokenId;
54 | }
55 |
56 | public void setUid(String uid) {
57 | this.uid = uid;
58 | }
59 |
60 | public void setName(String name){
61 | this.name=name;
62 | }
63 |
64 | public void setPhone(String phone){
65 | this.phone=phone;
66 | }
67 |
68 | public double getLatitude() {
69 | return latitude;
70 | }
71 |
72 | public double getLongitude() {
73 | return longitude;
74 | }
75 |
76 | public void setLatitude(double latitude) {
77 | this.latitude = latitude;
78 | }
79 |
80 | public void setLongitude(double longitude) {
81 | this.longitude = longitude;
82 | }
83 |
84 | public String getName() {
85 | return name;
86 | }
87 |
88 | public String getUid() {
89 | return uid;
90 | }
91 |
92 | public String getPhone() {
93 | return phone;
94 | }
95 |
96 | public String getCountry() {
97 | return country;
98 | }
99 |
100 | public void setCountry(String country) {
101 | this.country = country;
102 | }
103 |
104 | public String getPin() {
105 | return pin;
106 | }
107 |
108 | public void setPin(String pin) {
109 | this.pin = pin;
110 | }
111 |
112 | public String getKey1() {
113 | return key1;
114 | }
115 |
116 | public void setKey1(String key1) {
117 | this.key1 = key1;
118 | }
119 |
120 | public String getKey2() {
121 | return key2;
122 | }
123 |
124 | public void setKey2(String key2) {
125 | this.key2 = key2;
126 | }
127 |
128 | public String getPhotoUrl() {
129 | return photoUrl;
130 | }
131 |
132 | public void setPhotoUrl(String photoUrl) {
133 | this.photoUrl = photoUrl;
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ShareBy
2 | This is an Android based, social media App.
3 | Its main purpose is to bring neighborhood activities and chats closer by providing an online medium.
4 | Create your neighborhood group via Google Maps Location and invite your neighbors, friends, and families.
5 | Ask questions, borrow something, help others, and much more.
6 | Be friendly to others and keep growing.
7 | Inbuilt Chats to discuss among each other as well as among the whole group.
8 |
9 |
10 | The whole Project is based on Firebase Cloud Service. User data is NOT stored locally on the device, so Internet connection is necessary to run the App.
11 |
12 | More features coming soon...
13 |
14 | ### Screenshot
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | #### Quick explanation of project directory :
28 | 1. [firebase function](https://github.com/jpatel0/ShareBy/tree/master/firebase%20function) : It contains single file named index.js having cloud function.
29 | 2. [scrnshots](https://github.com/jpatel0/ShareBy/tree/master/scrnshots): Sample screenshot from mobile.
30 |
31 | ### Prerequisites
32 |
33 | - Firebase project with Realtime database for android having package name "com.zero.shareby".
34 | - google-services.json: during firebase project creation, you will get the google-services.json file, download and save this file.
35 | - Android SDK v28
36 | - Android Support Repository
37 |
38 | ### Open and Run Project
39 |
40 | For Android App:
41 | 1. open android studio, select File -> Import -> "Existing Projects into your workspace".
42 | 2. Go to the path where you cloned the Repo: (repoFolder)\code
43 | 3. paste the google-services.json to "app" folder.
44 | 4. rebuild the project and run.
45 |
46 | For cloud function:
47 | 1. initialize Firebase SDK for Cloud Functions as explained [here](https://firebase.google.com/docs/functions/get-started),
48 | 2. open index.js and paste the code from "(repoFolder)\cloud function\index.js".
49 | 3. deploy the cloud function.
50 |
51 |
52 | ### Built With
53 |
54 | - Language: java for android, javascript for cloud function.
55 | - [Firebase](https://firebase.google.com) : Realtime database, Firebase Auth, Firebase storage, Firebase config, Functions
56 |
57 | ### Author
58 |
59 | - **Jay Patel**
60 |
61 |
62 | ### Support
63 |
64 | Please feel free to submit [issues](https://github.com/jpatel0/ShareBy/issues) with any bugs or other unforeseen issues you experience.
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/models/Post.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.models;
2 |
3 | public class Post {
4 | private String refKey,reqUid,sharedUid,repliedUid,repliedName,name,title,desc;
5 | private int priority,status,type;
6 | private long timestamp;
7 | /*
8 | type: 0-question
9 | 1-req item
10 | priority: 0-new user
11 | 1-item post normal
12 | 2-urgent item req
13 | */
14 | public Post(){
15 | }
16 |
17 | public Post(String uid1,String uid2,String n,String tit,String des,int prior,int stat,int type){
18 | reqUid=uid1;
19 | sharedUid=uid2;
20 | name=n;
21 | title=tit;
22 | desc=des;
23 | priority=prior;
24 | status=stat;
25 | this.type = type;
26 | timestamp=System.currentTimeMillis();
27 | }
28 |
29 | public Post(String u,String n){
30 | reqUid=u;
31 | name=n;
32 | title="Welcome "+name+" as the new member";
33 | priority=0;
34 | timestamp=System.currentTimeMillis();
35 | }
36 |
37 | public int getType() {
38 | return type;
39 | }
40 |
41 | public void setType(int type) {
42 | this.type = type;
43 | }
44 |
45 | public String getRepliedUid() {
46 | return repliedUid;
47 | }
48 |
49 | public void setRepliedUid(String repliedUid) {
50 | this.repliedUid = repliedUid;
51 | }
52 |
53 | public String getRepliedName() {
54 | return repliedName;
55 | }
56 |
57 | public void setRepliedName(String repliedName) {
58 | this.repliedName = repliedName;
59 | }
60 |
61 | public void setRefKey(String refKey) {
62 | this.refKey = refKey;
63 | }
64 |
65 | public String getRefKey() {
66 | return refKey;
67 | }
68 |
69 | public String getReqUid() {
70 | return reqUid;
71 | }
72 |
73 | public void setReqUid(String reqUid) {
74 | this.reqUid = reqUid;
75 | }
76 |
77 | public String getSharedUid() {
78 | return sharedUid;
79 | }
80 |
81 | public void setSharedUid(String sharedUid) {
82 | this.sharedUid = sharedUid;
83 | }
84 |
85 | public String getName() {
86 | return name;
87 | }
88 |
89 | public void setName(String name) {
90 | this.name = name;
91 | }
92 |
93 | public String getTitle() {
94 | return title;
95 | }
96 |
97 | public void setTitle(String title) {
98 | this.title = title;
99 | }
100 |
101 | public String getDesc() {
102 | return desc;
103 | }
104 |
105 | public void setDesc(String desc) {
106 | this.desc = desc;
107 | }
108 |
109 | public int getPriority() {
110 | return priority;
111 | }
112 |
113 | public void setPriority(int priority) {
114 | this.priority = priority;
115 | }
116 |
117 | public int getStatus() {
118 | return status;
119 | }
120 |
121 | public void setStatus(int status) {
122 | this.status = status;
123 | }
124 |
125 | public long getTimestamp() {
126 | return timestamp;
127 | }
128 |
129 | public void setTimestamp(long timestamp) {
130 | this.timestamp = timestamp;
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/shared_item_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
18 |
19 |
27 |
28 |
43 |
44 |
58 |
59 |
60 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/fcm/FirebaseMessaging.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.fcm;
2 |
3 | import android.app.Notification;
4 | import android.support.annotation.NonNull;
5 | import android.support.v4.app.NotificationCompat;
6 | import android.support.v4.app.NotificationManagerCompat;
7 | import android.util.Log;
8 |
9 | import com.google.android.gms.tasks.OnCompleteListener;
10 | import com.google.android.gms.tasks.Task;
11 | import com.google.firebase.auth.FirebaseAuth;
12 | import com.google.firebase.database.DatabaseReference;
13 | import com.google.firebase.database.FirebaseDatabase;
14 | import com.google.firebase.messaging.FirebaseMessagingService;
15 | import com.google.firebase.messaging.RemoteMessage;
16 | import com.zero.shareby.R;
17 |
18 | import org.json.JSONObject;
19 |
20 | import java.util.HashMap;
21 | import java.util.Map;
22 |
23 | public class FirebaseMessaging extends FirebaseMessagingService {
24 | public static final String CHANNEL_ID="myChannel";
25 | public FirebaseMessaging() {
26 | super();
27 | }
28 |
29 | @Override
30 | public void onMessageReceived(RemoteMessage remoteMessage) {
31 | Log.d("inside","yes");
32 | NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
33 | .setSmallIcon(R.drawable.ic_home)
34 | .setColor(getResources().getColor(R.color.colorPrimary))
35 | .setContentTitle(remoteMessage.getNotification().getTitle())
36 | .setContentText(remoteMessage.getNotification().getBody())
37 | .setPriority(NotificationCompat.PRIORITY_DEFAULT)
38 | .setDefaults(Notification.DEFAULT_SOUND)
39 | .setVibrate(new long[]{0,250,250,250});
40 |
41 | NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
42 |
43 | // notificationId is a unique int for each notification that you must define
44 | notificationManager.notify(22, mBuilder.build());
45 |
46 | Log.d("dataChat",remoteMessage.getData().toString()+"\n"+remoteMessage.getNotification().getTitle());
47 | try
48 | {
49 | Map params = remoteMessage.getData();
50 | JSONObject object = new JSONObject(params);
51 | Log.d("JSON_OBJECT", object.toString());
52 | }catch (Exception e){
53 | e.printStackTrace();
54 | }
55 | }
56 |
57 | @Override
58 | public void onDeletedMessages() {
59 | super.onDeletedMessages();
60 | }
61 |
62 |
63 | @Override
64 | public void onNewToken(String s) {
65 | uploadDeviceTokenId(s);
66 |
67 | super.onNewToken(s);
68 | }
69 |
70 | public static void uploadDeviceTokenId(String id){
71 | if (FirebaseAuth.getInstance().getCurrentUser()!=null) {
72 | DatabaseReference userReference = FirebaseDatabase.getInstance().getReference()
73 | .child("UserDetails").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child("tokenId");
74 | userReference.setValue(id).addOnCompleteListener(new OnCompleteListener() {
75 | @Override
76 | public void onComplete(@NonNull Task task) {
77 | Log.d("Token Id", "generated");
78 | }
79 | });
80 | }
81 |
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/adapters/RecentChatsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.adapters;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.google.firebase.database.DataSnapshot;
13 | import com.google.firebase.database.DatabaseError;
14 | import com.google.firebase.database.DatabaseReference;
15 | import com.google.firebase.database.FirebaseDatabase;
16 | import com.google.firebase.database.ValueEventListener;
17 | import com.zero.shareby.R;
18 | import com.zero.shareby.models.UserDetails;
19 |
20 | import java.util.ArrayList;
21 |
22 | import de.hdodenhof.circleimageview.CircleImageView;
23 |
24 | public class RecentChatsAdapter extends RecyclerView.Adapter {
25 |
26 | private Context context;
27 | private ArrayList uid;
28 | private ClickListener listener;
29 | public interface ClickListener{
30 | void onItemClick(String uid);
31 | }
32 |
33 | public RecentChatsAdapter(Context context,ArrayList uid,ClickListener listener) {
34 | this.uid=uid;
35 | this.context = context;
36 | this.listener = listener;
37 | }
38 |
39 | @NonNull
40 | @Override
41 | public RecentChatViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
42 | return new RecentChatViewHolder(LayoutInflater.from(context).inflate(R.layout.recent_chat_list_user,parent,false));
43 | }
44 |
45 | @Override
46 | public void onBindViewHolder(@NonNull final RecentChatViewHolder holder, int position) {
47 | String friendId = uid.get(position);
48 | DatabaseReference userIdReference = FirebaseDatabase.getInstance().getReference().child("UserDetails").child(friendId);
49 | userIdReference.addListenerForSingleValueEvent(new ValueEventListener() {
50 | @Override
51 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
52 | if (dataSnapshot.exists() && dataSnapshot.getChildrenCount()>0){
53 | UserDetails user = dataSnapshot.getValue(UserDetails.class);
54 | if (user!=null){
55 | holder.friend_name.setText(user.getName());
56 | Glide.with(context).load(user.getPhotoUrl()).into(holder.friend_profile_image);
57 | }
58 | }
59 | }
60 |
61 | @Override
62 | public void onCancelled(@NonNull DatabaseError databaseError) {
63 | }
64 | });
65 | }
66 |
67 | @Override
68 | public int getItemCount() {
69 | if (uid!=null)
70 | return uid.size();
71 | return 0;
72 | }
73 |
74 | public class RecentChatViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
75 | CircleImageView friend_profile_image;
76 | TextView friend_name;
77 | public RecentChatViewHolder(View itemView) {
78 | super(itemView);
79 | friend_name = itemView.findViewById(R.id.friend_name);
80 | friend_profile_image = itemView.findViewById(R.id.friend_profile_image);
81 | itemView.setOnClickListener(this);
82 | }
83 |
84 | @Override
85 | public void onClick(View v) {
86 | listener.onItemClick(uid.get(getAdapterPosition()));
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
22 |
23 |
34 |
35 |
43 |
44 |
51 |
52 |
60 |
61 |
62 |
66 |
67 |
77 |
78 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/chats/ContactListActivity.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.chats;
2 |
3 | import android.content.Intent;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.app.ActionBar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.util.Log;
9 | import android.widget.ListView;
10 | import android.widget.Toast;
11 |
12 | import com.google.firebase.database.DataSnapshot;
13 | import com.google.firebase.database.DatabaseError;
14 | import com.google.firebase.database.DatabaseReference;
15 | import com.google.firebase.database.FirebaseDatabase;
16 | import com.google.firebase.database.ValueEventListener;
17 | import com.zero.shareby.R;
18 | import com.zero.shareby.models.UserDetails;
19 | import com.zero.shareby.Utils.Utilities;
20 | import com.zero.shareby.adapters.GroupContactsAdapter;
21 |
22 | import java.util.ArrayList;
23 | import java.util.List;
24 |
25 | public class ContactListActivity extends AppCompatActivity implements GroupContactsAdapter.MyListenerInterface{
26 |
27 | List groupContactUsers;
28 | ListView listView;
29 | GroupContactsAdapter adapter;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_contact_list);
35 |
36 | ActionBar actionBar=getSupportActionBar();
37 | if (actionBar != null) {
38 | actionBar.setDisplayHomeAsUpEnabled(true);
39 | }
40 |
41 | groupContactUsers = new ArrayList<>();
42 | listView = findViewById(R.id.group_contacts_list_view);
43 | adapter = new GroupContactsAdapter(this,groupContactUsers,this);
44 | listView.setAdapter(adapter);
45 | getContactList();
46 | }
47 |
48 | private void getContactList(){
49 | DatabaseReference groupRef = Utilities.getGroupReference(this);
50 | if (groupRef!=null){
51 | groupRef.child("members").addListenerForSingleValueEvent(new ValueEventListener() {
52 | @Override
53 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
54 | if (dataSnapshot.exists() && dataSnapshot.getChildrenCount()>0){
55 | Log.d("ContactsList",dataSnapshot.toString());
56 | for (DataSnapshot userID:dataSnapshot.getChildren()){
57 | if (!userID.getKey().equals(Utilities.getUserUid())) {
58 | DatabaseReference userRef = FirebaseDatabase.getInstance().getReference()
59 | .child("UserDetails").child(userID.getKey());
60 | userRef.addListenerForSingleValueEvent(new ValueEventListener() {
61 | @Override
62 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
63 | Log.d("ContactsUser",dataSnapshot.toString());
64 | if (dataSnapshot.exists())
65 | groupContactUsers.add(dataSnapshot.getValue(UserDetails.class));
66 | adapter.notifyDataSetChanged();
67 | }
68 |
69 | @Override
70 | public void onCancelled(@NonNull DatabaseError databaseError) {
71 | }
72 | });
73 |
74 | }
75 | }
76 | }
77 | }
78 |
79 | @Override
80 | public void onCancelled(@NonNull DatabaseError databaseError) {
81 | }
82 | });
83 | }else Toast.makeText(this,"Couldn't obtain group Data",Toast.LENGTH_SHORT).show();
84 | }
85 |
86 | @Override
87 | public void clicked(UserDetails user) {
88 | Intent startChat = new Intent(this,PeerToPeerChat.class);
89 | startChat.putExtra("userObject",user);
90 | startActivity(startChat);
91 | finish();
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/your_post_query_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
20 |
21 |
29 |
30 |
44 |
45 |
59 |
60 |
61 |
75 |
76 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/firebase function/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const functions = require('firebase-functions');
4 | const admin = require('firebase-admin');
5 |
6 | admin.initializeApp(functions.config().firebase);
7 |
8 | exports.sendNotification = functions.database.ref('/Groups/{country}/{pin}/{key1}/{key2}/posts/{push_id}')
9 | .onWrite((snapshot, context) => {
10 |
11 | const country = context.params.country;
12 | const pin = context.params.pin;
13 | const key1 = context.params.key1;
14 | const key2 = context.params.key2;
15 | const push_id = context.params.push_id;
16 | const data = snapshot.after.val();
17 |
18 | if (data) {
19 | admin.database().ref(`/Groups/${country}/${pin}/${key1}/${key2}/posts/${push_id}`)
20 | .once("value", (snapshot) => {
21 | var data = snapshot.val();
22 | const reqUid = data.reqUid;
23 | var payload;
24 | console.log(data);
25 | if (data.sharedUid == undefined || data.sharedUid == null) {
26 |
27 | if (data.priority == 0) {
28 | payload = {
29 | "notification":{
30 | "title" : "A new member has joined",
31 | "body" : `${data.name} has joined your neighborhood`,
32 | "sound" : "default",
33 | "icon" : "ic_home"
34 | },
35 | "data" : {
36 | "extra" : "some extra"
37 | }
38 | };
39 | }else {
40 | payload = {
41 | "notification" : {
42 | "title" : "Item Request",
43 | "body" : `${data.name} has requested a/an ${data.title}`,
44 | "sound" : "default",
45 | "icon" : "ic_home"
46 | },
47 | "data" : {
48 | "extra" : "some extra"
49 | }
50 | };
51 | }
52 |
53 | admin.database().ref(`/Groups/${country}/${pin}/${key1}/${key2}/members`).once("value", (snapshot) => {
54 | var memberTokens = [];
55 |
56 | snapshot.forEach((childSnapshot) => {
57 | if (childSnapshot.key != reqUid) {
58 | memberTokens.push(childSnapshot.val());
59 | }
60 | });
61 | if (memberTokens.length>0) {
62 | admin.messaging().sendToDevice(memberTokens, payload)
63 | .then(function(response) {
64 | console.log('Successfully sent message:', response);
65 | })
66 | .catch(function(error) {
67 | console.log('Error sending message:', error);
68 | });
69 | }
70 | });
71 | }
72 | });
73 | }else {
74 | console.log('Node deleted');
75 | }
76 | });
77 |
78 |
79 |
80 | // exports.updateTokenInGroup = functions.database.ref('/Groups/{country}/{pin}/{key1}/{key2}/members/{member_id}')
81 | // .onWrite((snapshot,context) => {
82 | //
83 | // const member_id = context.params.member_id;
84 | // var token = snapshot.after.val();
85 | // if (member) {
86 | // if (token != undefined && token != 'true') {
87 | // return admin.database().ref(`/UserDetails/${}`)
88 | // }
89 | // }else {
90 | // console.log('Member left',snapshot.before.val());
91 | // }
92 | // });
93 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/activities/PickLocation.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.activities;
2 |
3 | import android.Manifest;
4 | import android.content.DialogInterface;
5 | import android.content.pm.PackageManager;
6 | import android.support.v4.app.ActivityCompat;
7 | import android.support.v4.app.FragmentActivity;
8 | import android.os.Bundle;
9 | import android.support.v7.app.AlertDialog;
10 |
11 | import com.google.android.gms.maps.GoogleMap;
12 | import com.google.android.gms.maps.OnMapReadyCallback;
13 | import com.google.android.gms.maps.SupportMapFragment;
14 | import com.google.android.gms.maps.model.LatLng;
15 | import com.google.android.gms.maps.model.MarkerOptions;
16 | import com.zero.shareby.R;
17 | import com.zero.shareby.Utils.DialogBuilder;
18 |
19 | public class PickLocation extends FragmentActivity implements OnMapReadyCallback, GoogleMap.OnMapLongClickListener {
20 |
21 | private GoogleMap mMap;
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_pick_location);
27 | // Obtain the SupportMapFragment and get notified when the map is ready to be used.
28 | SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
29 | .findFragmentById(R.id.pick_loc_map);
30 | mapFragment.getMapAsync(this);
31 | }
32 |
33 |
34 | /**
35 | * Manipulates the map once available.
36 | * This callback is triggered when the map is ready to be used.
37 | * This is where we can add markers or lines, add listeners or move the camera. In this case,
38 | * we just add a marker near Sydney, Australia.
39 | * If Google Play services is not installed on the device, the user will be prompted to install
40 | * it inside the SupportMapFragment. This method will only be triggered once the user has
41 | * installed Google Play services and returned to the app.
42 | */
43 | @Override
44 | public void onMapReady(GoogleMap googleMap) {
45 | mMap = googleMap;
46 | mMap.setOnMapLongClickListener(this);
47 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
48 | // TODO: Consider calling
49 | // ActivityCompat#requestPermissions
50 | // here to request the missing permissions, and then overriding
51 | // public void onRequestPermissionsResult(int requestCode, String[] permissions,
52 | // int[] grantResults)
53 | // to handle the case where the user grants the permission. See the documentation
54 | // for ActivityCompat#requestPermissions for more details.
55 | return;
56 | }
57 | mMap.setMyLocationEnabled(true);
58 | mMap.getUiSettings().setMyLocationButtonEnabled(true);
59 | // Add a marker in Sydney and move the camera
60 | // LatLng sydney = new LatLng(-34, 151);
61 | // mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
62 | // mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
63 | }
64 |
65 | @Override
66 | public void onMapLongClick(final LatLng latLng) {
67 | mMap.addMarker(new MarkerOptions().position(latLng).title("selecting this"));
68 |
69 | AlertDialog.Builder builder = DialogBuilder.getDialogBuilder(this,"Select this Location?","Are you sure you want to set this as your location address?");
70 | builder.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
71 | @Override
72 | public void onClick(DialogInterface dialog, int which) {
73 | dialog.dismiss();
74 | getIntent().putExtra("coordinates",latLng);
75 | setResult(RESULT_OK,getIntent());
76 | finish();
77 | }
78 | });
79 | builder.setNegativeButton("No, Change it", new DialogInterface.OnClickListener() {
80 | @Override
81 | public void onClick(DialogInterface dialog, int which) {
82 | dialog.dismiss();
83 | mMap.clear();
84 | }
85 | });
86 | builder.show();
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/adapters/DashboardAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.adapters;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ArrayAdapter;
12 | import android.widget.TextView;
13 |
14 | import com.bumptech.glide.Glide;
15 |
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 | import com.zero.shareby.models.Post;
22 | import com.zero.shareby.R;
23 | import com.zero.shareby.models.UserDetails;
24 | import com.zero.shareby.Utils.Utilities;
25 |
26 | import java.util.ArrayList;
27 |
28 | import de.hdodenhof.circleimageview.CircleImageView;
29 |
30 | public class DashboardAdapter extends ArrayAdapter {
31 |
32 | public DashboardAdapter(@NonNull Context context, ArrayList list) {
33 | super(context, R.layout.shared_item_layout,list);
34 | }
35 |
36 | @NonNull
37 | @Override
38 | public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
39 | LayoutInflater layoutInflater=LayoutInflater.from(getContext());
40 | View newView=convertView;
41 | if (convertView==null){
42 | newView=layoutInflater.inflate(R.layout.shared_item_layout,parent,false);
43 | }
44 | final Post post=getItem(position);
45 | final TextView titleTextView=newView.findViewById(R.id.offering_user);
46 | final TextView descriptionTextView=newView.findViewById(R.id.offered_to_para);
47 | TextView timestampTextView=newView.findViewById(R.id.timestamp_dashboard);
48 | final CircleImageView imageView=newView.findViewById(R.id.offering_user_profile);
49 |
50 | if (post.getPriority()>0) {
51 |
52 | DatabaseReference sharedUserRef= FirebaseDatabase.getInstance().getReference()
53 | .child("UserDetails").child(post.getSharedUid());
54 | sharedUserRef.addListenerForSingleValueEvent(new ValueEventListener() {
55 | @Override
56 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
57 | Log.d("DashboardAdapter",dataSnapshot.toString());
58 | UserDetails u=dataSnapshot.getValue(UserDetails.class);
59 | if (u.getPhotoUrl()!=null){
60 | Glide.with(getContext())
61 | .load(Uri.parse(u.getPhotoUrl()))
62 | .into(imageView);
63 | }
64 | titleTextView.setText(u.getName());
65 | String sentence = "shared a/an " + post.getTitle() + " to " + post.getName();
66 | descriptionTextView.setText(sentence);
67 | }
68 |
69 | @Override
70 | public void onCancelled(@NonNull DatabaseError databaseError) {}
71 | });
72 | }
73 | else {
74 | titleTextView.setText(R.string.new_user_applause);
75 | String sentence = post.getName() + " has joined your Neighborhood";
76 | descriptionTextView.setText(sentence);
77 | DatabaseReference sharedUserRef= FirebaseDatabase.getInstance().getReference()
78 | .child("UserDetails").child(post.getReqUid()).child("photoUrl");
79 | sharedUserRef.addListenerForSingleValueEvent(new ValueEventListener() {
80 | @Override
81 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
82 | String photoUrl=dataSnapshot.getValue(String.class);
83 | if (photoUrl!=null){
84 | Glide.with(getContext())
85 | .load(Uri.parse(photoUrl))
86 | .into(imageView);
87 | }
88 | }
89 |
90 | @Override
91 | public void onCancelled(@NonNull DatabaseError databaseError) {}
92 | });
93 | }
94 |
95 |
96 | timestampTextView.setText(Utilities.calculateTimeDisplay(post.getTimestamp()));
97 | return newView;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/pending_post_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
21 |
22 |
30 |
31 |
46 |
47 |
61 |
62 |
63 |
76 |
77 |
91 |
92 |
102 |
103 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/chats/RecentChats.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.chats;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.Nullable;
8 | import android.support.design.widget.FloatingActionButton;
9 | import android.support.v4.app.Fragment;
10 | import android.support.v4.widget.SwipeRefreshLayout;
11 | import android.support.v7.widget.LinearLayoutManager;
12 | import android.support.v7.widget.RecyclerView;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.widget.Toast;
17 |
18 | import com.google.firebase.database.DataSnapshot;
19 | import com.google.firebase.database.DatabaseError;
20 | import com.google.firebase.database.DatabaseReference;
21 | import com.google.firebase.database.FirebaseDatabase;
22 | import com.google.firebase.database.ValueEventListener;
23 | import com.zero.shareby.R;
24 | import com.zero.shareby.models.UserDetails;
25 | import com.zero.shareby.Utils.Utilities;
26 | import com.zero.shareby.adapters.RecentChatsAdapter;
27 |
28 | import java.util.ArrayList;
29 |
30 | public class RecentChats extends Fragment implements RecentChatsAdapter.ClickListener {
31 |
32 | //private static final int RC_CONTACT = 10;
33 | RecyclerView recentChatList;
34 | private ArrayList friends_Uids;
35 | private RecentChatsAdapter chatsAdapter;
36 | SwipeRefreshLayout refreshLayout;
37 | public RecentChats() {
38 | }
39 |
40 |
41 | @Override
42 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
43 | Bundle savedInstanceState) {
44 | // Inflate the layout for this fragment
45 | friends_Uids = new ArrayList<>();
46 | return inflater.inflate(R.layout.fragment_recent_chats, container, false);
47 | }
48 |
49 | @Override
50 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
51 | super.onViewCreated(view, savedInstanceState);
52 | recentChatList = view.findViewById(R.id.recent_chats_recycler_view);
53 | RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false);
54 | recentChatList.setLayoutManager(layoutManager);
55 | chatsAdapter = new RecentChatsAdapter(getActivity().getApplicationContext(),friends_Uids,this);
56 | recentChatList.setAdapter(chatsAdapter);
57 | refreshLayout = view.findViewById(R.id.recent_chats_refresh);
58 | FloatingActionButton fab = view.findViewById(R.id.recent_chat_fab_button);
59 | fab.setOnClickListener(new View.OnClickListener() {
60 | @Override
61 | public void onClick(View v) {
62 | Intent getContactIntent = new Intent(getContext(),ContactListActivity.class);
63 | startActivity(getContactIntent);
64 | Toast.makeText(getContext(),"FAB",Toast.LENGTH_SHORT).show();
65 | }
66 | });
67 | refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
68 | @Override
69 | public void onRefresh() {
70 | friends_Uids.clear();
71 | getFriendList();
72 | }
73 | });
74 | getFriendList();
75 | }
76 |
77 | @Override
78 | public void onItemClick(String uid) {
79 | DatabaseReference userRef = FirebaseDatabase.getInstance().getReference().child("UserDetails")
80 | .child(uid);
81 | userRef.addListenerForSingleValueEvent(new ValueEventListener() {
82 | @Override
83 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
84 | if (dataSnapshot.exists()){
85 | Intent goToChat = new Intent(getActivity(),PeerToPeerChat.class);
86 | goToChat.putExtra("userObject",dataSnapshot.getValue(UserDetails.class));
87 | startActivity(goToChat);
88 | }
89 | }
90 |
91 | @Override
92 | public void onCancelled(@NonNull DatabaseError databaseError) {
93 |
94 | }
95 | });
96 | }
97 |
98 | private void getFriendList(){
99 | try {
100 | refreshLayout.setRefreshing(true);
101 | DatabaseReference recentChatReference = FirebaseDatabase.getInstance().getReference().child("RecentChats").child(Utilities.getUserUid());
102 | recentChatReference.addListenerForSingleValueEvent(new ValueEventListener() {
103 | @Override
104 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
105 | if (dataSnapshot.exists() && dataSnapshot.getChildrenCount()>0){
106 | for (DataSnapshot friendId:dataSnapshot.getChildren()){
107 | friends_Uids.add(friendId.getKey());
108 | }
109 | chatsAdapter.notifyDataSetChanged();
110 | }
111 | if (refreshLayout.isRefreshing())
112 | refreshLayout.setRefreshing(false);
113 | }
114 |
115 | @Override
116 | public void onCancelled(@NonNull DatabaseError databaseError) {
117 | }
118 | });
119 | }catch (NullPointerException e){
120 | e.printStackTrace();
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/post_item_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
20 |
21 |
29 |
30 |
44 |
45 |
59 |
60 |
73 |
74 |
75 |
90 |
91 |
105 |
106 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_post.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
15 |
16 |
17 |
22 |
23 |
32 |
33 |
43 |
44 |
45 |
51 |
52 |
64 |
65 |
75 |
76 |
87 |
88 |
89 |
101 |
102 |
114 |
115 |
116 |
117 |
123 |
124 |
125 |
126 |
132 |
133 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/adapters/ChatsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.adapters;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.support.annotation.NonNull;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 | import com.bumptech.glide.Glide;
13 | import com.google.firebase.database.DataSnapshot;
14 | import com.google.firebase.database.DatabaseError;
15 | import com.google.firebase.database.DatabaseReference;
16 | import com.google.firebase.database.FirebaseDatabase;
17 | import com.google.firebase.database.ValueEventListener;
18 | import com.zero.shareby.R;
19 | import com.zero.shareby.models.UserDetails;
20 | import com.zero.shareby.Utils.Utilities;
21 | import com.zero.shareby.chats.Chat;
22 |
23 | import java.util.ArrayList;
24 |
25 | import de.hdodenhof.circleimageview.CircleImageView;
26 |
27 | public class ChatsAdapter extends RecyclerView.Adapter {
28 | private ArrayList mChatList;
29 | private Context context;
30 |
31 | public ChatsAdapter(Context context,ArrayList chats){
32 | mChatList = chats;
33 | this.context=context;
34 | }
35 |
36 |
37 | @NonNull
38 | @Override
39 | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
40 | View v;
41 | switch (viewType){
42 | case 0:
43 | v=LayoutInflater.from(parent.getContext())
44 | .inflate(R.layout.my_message_layout, parent, false);
45 | return new MyMessageViewHolder(v);
46 |
47 |
48 | case 1:
49 | v=LayoutInflater.from(parent.getContext())
50 | .inflate(R.layout.their_message_layout, parent, false);
51 | return new TheirMessageViewHolder(v);
52 |
53 | default:
54 | v=LayoutInflater.from(parent.getContext())
55 | .inflate(R.layout.chat_date_divider_layout, parent, false);
56 | return new DateDividerViewHolder(v);
57 | }
58 | }
59 |
60 |
61 | @Override
62 | public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
63 | final Chat chatObj=mChatList.get(position);
64 | if (chatObj.isDivider()){
65 | ((DateDividerViewHolder) holder).dateDivider.setText(Utilities.getDateString(chatObj.getTimestamp()));
66 | }
67 | else if (chatObj.isBelongsToCurrentUser()){
68 | ((MyMessageViewHolder) holder).myMessage.setText(chatObj.getMessage());
69 | ((MyMessageViewHolder) holder).myTimestamp.setText(Utilities.getTimeString(chatObj.getTimestamp()));
70 | }else {
71 | DatabaseReference otherUserRef = FirebaseDatabase.getInstance().getReference().child("UserDetails").child(chatObj.getSentBy());
72 | otherUserRef.addListenerForSingleValueEvent(new ValueEventListener() {
73 | @Override
74 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
75 | if (dataSnapshot.exists()) {
76 | UserDetails otherUser = dataSnapshot.getValue(UserDetails.class);
77 | if (otherUser.getPhotoUrl()!=null)
78 | Glide.with(context).load(Uri.parse(otherUser.getPhotoUrl())).into(((TheirMessageViewHolder)holder).theirAvatar);
79 | ((TheirMessageViewHolder) holder).theirName.setText(otherUser.getName());
80 | ((TheirMessageViewHolder) holder).theirMessage.setText(chatObj.getMessage());
81 | ((TheirMessageViewHolder) holder).theirTimestamp.setText(Utilities.getTimeString(chatObj.getTimestamp()));
82 | }
83 | }
84 |
85 | @Override
86 | public void onCancelled(@NonNull DatabaseError databaseError) {
87 | }
88 | });
89 | }
90 | }
91 |
92 | @Override
93 | public int getItemCount() {
94 | if (mChatList==null)
95 | return 0;
96 | else return mChatList.size();
97 | }
98 |
99 | @Override
100 | public int getItemViewType(int position) {
101 | if (mChatList.get(position).isDivider())
102 | return 2;
103 | else if (mChatList.get(position).isBelongsToCurrentUser()){
104 | return 0;
105 | }else return 1;
106 | }
107 |
108 | public class MyMessageViewHolder extends RecyclerView.ViewHolder {
109 | TextView myMessage,myTimestamp;
110 | public MyMessageViewHolder(View layoutView) {
111 | super(layoutView);
112 | myMessage= layoutView.findViewById(R.id.my_message_body);
113 | myTimestamp = layoutView.findViewById(R.id.my_message_timestamp);
114 | }
115 |
116 | }
117 |
118 | public class TheirMessageViewHolder extends RecyclerView.ViewHolder {
119 | CircleImageView theirAvatar;
120 | TextView theirMessage,theirName,theirTimestamp;
121 | public TheirMessageViewHolder(View layoutView) {
122 | super(layoutView);
123 | theirAvatar = layoutView.findViewById(R.id.their_avatar);
124 | theirName= layoutView.findViewById(R.id.their_name);
125 | theirMessage= layoutView.findViewById(R.id.their_message_body);
126 | theirTimestamp = layoutView.findViewById(R.id.their_message_timestamp);
127 | }
128 | }
129 |
130 | public class DateDividerViewHolder extends RecyclerView.ViewHolder {
131 | TextView dateDivider;
132 | public DateDividerViewHolder(View itemView) {
133 | super(itemView);
134 | dateDivider = itemView.findViewById(R.id.chat_date_divider);
135 | }
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/activities/UserProfile.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.activities;
2 |
3 | import android.content.Intent;
4 | import android.graphics.drawable.Drawable;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.design.widget.CollapsingToolbarLayout;
8 | import android.support.design.widget.FloatingActionButton;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.os.Bundle;
11 | import android.support.v7.widget.Toolbar;
12 | import android.util.Log;
13 | import android.view.View;
14 | import android.widget.ImageView;
15 | import android.widget.ProgressBar;
16 |
17 | import com.bumptech.glide.Glide;
18 | import com.bumptech.glide.load.DataSource;
19 | import com.bumptech.glide.load.engine.GlideException;
20 | import com.bumptech.glide.request.RequestListener;
21 | import com.bumptech.glide.request.target.Target;
22 | import com.google.firebase.auth.FirebaseAuth;
23 | import com.google.firebase.database.DataSnapshot;
24 | import com.google.firebase.database.DatabaseError;
25 | import com.google.firebase.database.DatabaseReference;
26 | import com.google.firebase.database.FirebaseDatabase;
27 | import com.google.firebase.database.ValueEventListener;
28 | import com.zero.shareby.R;
29 | import com.zero.shareby.models.UserDetails;
30 |
31 | public class UserProfile extends AppCompatActivity {
32 | private static final String TAG="UserProfile";
33 |
34 | FirebaseAuth mAuth;
35 | ProgressBar progressBar;
36 | ImageView profileImageView;
37 | ImageView addressApprovedImageView;
38 | Toolbar toolbar;
39 | CollapsingToolbarLayout collapsingToolbarLayout;
40 | FloatingActionButton fab;
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | setContentView(R.layout.show_profile_new);
46 |
47 | toolbar = findViewById(R.id.profile_toolbar);
48 | setSupportActionBar(toolbar);
49 | // ActionBar actionBar=getSupportActionBar();
50 | // if (actionBar != null) {
51 | // actionBar.setDisplayHomeAsUpEnabled(true);
52 | // }
53 |
54 | mAuth=FirebaseAuth.getInstance();
55 | collapsingToolbarLayout = findViewById(R.id.profile_collapsing_toolbar);
56 | progressBar= findViewById(R.id.user_profile_progress_bar);
57 | profileImageView= findViewById(R.id.profile_image);
58 | fab = findViewById(R.id.floatingActionButton);
59 | addressApprovedImageView= findViewById(R.id.address_approved_image_view);
60 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
61 | }
62 |
63 | @Override
64 | protected void onResume() {
65 | super.onResume();
66 | progressBar.setVisibility(View.VISIBLE);
67 | if(mAuth.getCurrentUser()!=null){
68 | collapsingToolbarLayout.setTitle(mAuth.getCurrentUser().getDisplayName());
69 | if (mAuth.getCurrentUser().getPhotoUrl()==null) {
70 | profileImageView.setImageResource(R.drawable.sign);
71 | progressBar.setVisibility(View.GONE);
72 | }
73 | else{
74 | Log.d(TAG,"PHOTO:"+mAuth.getCurrentUser().getPhotoUrl().toString());
75 | Glide.with(this)
76 | .load(mAuth.getCurrentUser().getPhotoUrl())
77 | .listener(new RequestListener() {
78 | @Override
79 | public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
80 | progressBar.setVisibility(View.GONE);
81 | return false;
82 | }
83 |
84 | @Override
85 | public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
86 | progressBar.setVisibility(View.GONE);
87 | return false;
88 | }
89 | })
90 | .into(profileImageView);
91 | }
92 |
93 | fab.setOnClickListener(new View.OnClickListener() {
94 | @Override
95 | public void onClick(View v) {
96 | startActivity(new Intent(UserProfile.this,UserSettings.class));
97 | }
98 | });
99 |
100 | DatabaseReference databaseReference= FirebaseDatabase.getInstance().getReference().child("UserDetails").child(FirebaseAuth.getInstance().getCurrentUser().getUid());
101 | databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
102 | @Override
103 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
104 | UserDetails userDetails=dataSnapshot.getValue(UserDetails.class);
105 | Log.d(TAG,String.valueOf(userDetails.getLatitude()));
106 | if (userDetails.getLongitude()==0){
107 | addressApprovedImageView.setImageResource(R.drawable.ic_error);
108 | }
109 | else
110 | addressApprovedImageView.setImageResource(R.drawable.ic_verified);
111 | }
112 |
113 | @Override
114 | public void onCancelled(@NonNull DatabaseError databaseError) {
115 |
116 | }
117 | });
118 |
119 | }
120 | else
121 | progressBar.setVisibility(View.GONE);
122 | }
123 |
124 | @Override
125 | protected void onPause() {
126 | super.onPause();
127 |
128 | new Thread(new Runnable() {
129 | @Override
130 | public void run() {
131 | Glide.get(UserProfile.this).clearDiskCache();
132 | }
133 | }).start();
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/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/layout/pending_post_query_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
21 |
22 |
30 |
31 |
46 |
47 |
61 |
62 |
63 |
76 |
77 |
90 |
91 |
98 |
99 |
111 |
112 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
24 |
25 |
33 |
36 |
37 |
40 |
43 |
46 |
49 |
50 |
55 |
56 |
60 |
65 |
68 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
102 |
107 |
110 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/show_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
16 |
22 |
23 |
24 |
33 |
34 |
43 |
44 |
53 |
54 |
57 |
58 |
67 |
68 |
76 |
77 |
78 |
79 |
82 |
83 |
92 |
93 |
101 |
102 |
103 |
106 |
107 |
116 |
117 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
140 |
141 |
152 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/adapters/PendingRequestsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.adapters;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.transition.TransitionManager;
8 | import android.util.Log;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ArrayAdapter;
13 | import android.widget.Button;
14 | import android.widget.ListView;
15 | import android.widget.TextView;
16 | import android.widget.Toast;
17 |
18 | import com.bumptech.glide.Glide;
19 | import com.google.firebase.database.DataSnapshot;
20 | import com.google.firebase.database.DatabaseError;
21 | import com.google.firebase.database.DatabaseReference;
22 | import com.google.firebase.database.FirebaseDatabase;
23 | import com.google.firebase.database.ValueEventListener;
24 | import com.zero.shareby.models.Post;
25 | import com.zero.shareby.R;
26 | import com.zero.shareby.models.UserDetails;
27 | import com.zero.shareby.Utils.Utilities;
28 |
29 | import java.util.ArrayList;
30 |
31 | import de.hdodenhof.circleimageview.CircleImageView;
32 |
33 | public class PendingRequestsAdapter extends ArrayAdapter{
34 |
35 | private ButtonClickListener listener;
36 | private int mExpandedPosition=-1;
37 | public interface ButtonClickListener {
38 | void onReplyButtonClick(String otherUserId);
39 | void onHaveItemButtonClick(Post post);
40 | }
41 |
42 | public PendingRequestsAdapter(Context context, ArrayList postArrayList,ButtonClickListener listener){
43 | super(context, R.layout.pending_post_item,postArrayList);
44 | this.listener = listener;
45 | }
46 |
47 | @NonNull
48 | @Override
49 | public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
50 | View newView=convertView;
51 | if (convertView==null){
52 | newView= LayoutInflater.from(getContext()).inflate(R.layout.pending_post_item,parent,false);
53 | }
54 |
55 | final Post post=getItem(position);
56 | TextView reqUserTextView=newView.findViewById(R.id.requesting_user_name);
57 | TextView titleTextView=newView.findViewById(R.id.pending_request_title);
58 | TextView descriptionTextView=newView.findViewById(R.id.pending_request_description);
59 | TextView timestampTextView=newView.findViewById(R.id.timestamp_pending_post);
60 | final Button haveButton = newView.findViewById(R.id.i_have_it);
61 | final CircleImageView imageView=newView.findViewById(R.id.pending_user_profile_photo);
62 | final Button replyButton=newView.findViewById(R.id.pending_reply_button);
63 |
64 | reqUserTextView.setText(post.getName());
65 | titleTextView.setText(post.getTitle());
66 | if (post.getDesc()!=null){
67 | descriptionTextView.setText(post.getDesc());
68 | }
69 | else
70 | descriptionTextView.setHeight(0);
71 | DatabaseReference reqUserRef= FirebaseDatabase.getInstance().getReference()
72 | .child("UserDetails").child(post.getReqUid());
73 | reqUserRef.addListenerForSingleValueEvent(new ValueEventListener() {
74 | @Override
75 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
76 | Log.d("DashboardAdapter",dataSnapshot.toString());
77 | UserDetails u=dataSnapshot.getValue(UserDetails.class);
78 | if (u.getPhotoUrl()!=null){
79 | Glide.with(getContext())
80 | .load(Uri.parse(u.getPhotoUrl()))
81 | .into(imageView);
82 | }
83 | }
84 |
85 | @Override
86 | public void onCancelled(@NonNull DatabaseError databaseError) {}
87 | });
88 |
89 | timestampTextView.setText(Utilities.calculateTimeDisplay(post.getTimestamp()));
90 |
91 |
92 |
93 | // handling card collapse
94 | final ListView postListView = parent.findViewById(R.id.pending_requests_listview);
95 |
96 | if (Utilities.getUserUid().equals(post.getReqUid())){
97 | // replyButton.setBackgroundTintList(getContext().getResources().getColorStateList(android.R.color.darker_gray));
98 | // replyButton.setTextColor(getContext().getResources().getColor(android.R.color.white));
99 | newView.findViewById(R.id.pending_card_view).setBackgroundTintList(getContext().getResources().getColorStateList(R.color.yellow));
100 | replyButton.setVisibility(View.GONE);
101 | haveButton.setVisibility(View.GONE);
102 | }else {
103 |
104 | newView.findViewById(R.id.pending_card_view).setBackgroundTintList(getContext().getResources().getColorStateList(R.color.white));
105 | final boolean isExpanded = position==mExpandedPosition;
106 | replyButton.setVisibility(isExpanded?View.VISIBLE:View.GONE);
107 | haveButton.setVisibility(isExpanded?View.VISIBLE:View.GONE);
108 | newView.setActivated(isExpanded);
109 | newView.setOnClickListener(new View.OnClickListener() {
110 | @Override
111 | public void onClick(View v) {
112 | mExpandedPosition = isExpanded ? -1:position;
113 | TransitionManager.beginDelayedTransition(postListView);
114 | notifyDataSetChanged();
115 | }
116 | });
117 | replyButton.setOnClickListener(new View.OnClickListener() {
118 | @Override
119 | public void onClick(View v) {
120 | Toast.makeText(getContext(), post.getReqUid(), Toast.LENGTH_SHORT).show();
121 | listener.onReplyButtonClick(post.getReqUid());
122 | }
123 | });
124 |
125 | haveButton.setOnClickListener(new View.OnClickListener() {
126 | @Override
127 | public void onClick(View v) {
128 | listener.onHaveItemButtonClick(post);
129 | mExpandedPosition=-1;
130 | replyButton.setVisibility(isExpanded?View.VISIBLE:View.GONE);
131 | haveButton.setVisibility(isExpanded?View.VISIBLE:View.GONE);
132 | }
133 | });
134 | }
135 |
136 | return newView;
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/activities/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.activities;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 | import android.support.annotation.NonNull;
7 | import android.support.design.widget.NavigationView;
8 | import android.support.design.widget.TabLayout;
9 | import android.support.v4.view.GravityCompat;
10 | import android.support.v4.view.ViewPager;
11 | import android.support.v4.widget.DrawerLayout;
12 | import android.support.v7.app.ActionBarDrawerToggle;
13 | import android.support.v7.app.AppCompatActivity;
14 | import android.os.Bundle;
15 | import android.support.v7.widget.Toolbar;
16 | import android.util.Log;
17 | import android.view.MenuItem;
18 | import android.widget.ImageView;
19 | import android.widget.TextView;
20 |
21 | import com.bumptech.glide.Glide;
22 | import com.firebase.ui.auth.AuthUI;
23 | import com.firebase.ui.auth.util.data.ProviderAvailability;
24 | import com.google.android.gms.ads.AdRequest;
25 | import com.google.android.gms.ads.AdView;
26 | import com.google.android.gms.ads.MobileAds;
27 | import com.google.android.gms.tasks.OnCompleteListener;
28 | import com.google.android.gms.tasks.Task;
29 | import com.google.firebase.auth.FirebaseAuth;
30 | import com.google.firebase.auth.FirebaseUser;
31 | import com.google.firebase.auth.UserInfo;
32 | import com.zero.shareby.R;
33 | import com.zero.shareby.chats.ChatActivity;
34 | import com.zero.shareby.adapters.PagerAdapter;
35 |
36 | public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
37 | private static final String TAG=MainActivity.class.getSimpleName();
38 | public static final String MAP_KEY="map_key";
39 | FirebaseAuth auth;
40 | NavigationView navigationView;
41 | private DrawerLayout drawer;
42 |
43 | ViewPager viewPager;
44 | PagerAdapter pagerAdapter;
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(R.layout.activity_main);
50 |
51 | Toolbar toolbar=findViewById(R.id.toolbar);
52 | setSupportActionBar(toolbar);
53 | drawer=findViewById(R.id.nav_drawer_layout);
54 |
55 | ActionBarDrawerToggle toggle=new ActionBarDrawerToggle(this,drawer,toolbar,R.string.nav_open,R.string.nav_close);
56 | drawer.addDrawerListener(toggle);
57 | toggle.syncState();
58 |
59 | navigationView=findViewById(R.id.nav_view);
60 | navigationView.setNavigationItemSelectedListener(this);
61 |
62 | viewPager= findViewById(R.id.viewpager);
63 | pagerAdapter=new PagerAdapter(this,getSupportFragmentManager());
64 | viewPager.setAdapter(pagerAdapter);
65 | TabLayout tab=findViewById(R.id.tabs);
66 | tab.setupWithViewPager(viewPager);
67 |
68 |
69 | auth=FirebaseAuth.getInstance();
70 | navigationView.setCheckedItem(R.id.nav_home);
71 | // for testing: ca-app-pub-3940256099942544/6300978111
72 | // for production : ca-app-pub-7619421557353367~5342952132
73 | MobileAds.initialize(this, "ca-app-pub-7619421557353367~5342952132");
74 |
75 |
76 |
77 | }
78 |
79 |
80 | @Override
81 | public boolean onNavigationItemSelected(@NonNull MenuItem item) {
82 |
83 | switch (item.getItemId()){
84 |
85 | case R.id.nav_home:
86 | viewPager.setCurrentItem(0);
87 | break;
88 |
89 | case R.id.nav_logout:
90 | if(auth.getCurrentUser()!=null){
91 | SharedPreferences.Editor prefEditor= PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit();
92 | prefEditor.putBoolean(MAP_KEY,true);
93 | prefEditor.putBoolean("uploaded",false);
94 | prefEditor.putBoolean("app_intro_check_key",false);
95 | prefEditor.clear();
96 | prefEditor.commit();
97 | AuthUI.getInstance().signOut(getApplicationContext())
98 | .addOnCompleteListener(new OnCompleteListener() {
99 | @Override
100 | public void onComplete(@NonNull Task task) {
101 | Intent backToLoginIntent = new Intent(MainActivity.this,LoginActivity.class);
102 | backToLoginIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_CLEAR_TASK);
103 | startActivity(backToLoginIntent);
104 | finish();
105 | }
106 | });
107 | }
108 | break;
109 |
110 | case R.id.nav_profile:
111 | startActivity(new Intent(MainActivity.this,UserProfile.class));
112 | break;
113 |
114 | case R.id.nav_chat:
115 | startActivity(new Intent(this,ChatActivity.class));
116 | break;
117 |
118 | case R.id.nav_share:
119 | Intent shareIntent=new Intent(Intent.ACTION_SEND);
120 | shareIntent.setType("text/plain");
121 | shareIntent.putExtra(Intent.EXTRA_SUBJECT,"ShareBy App");
122 | shareIntent.putExtra(Intent.EXTRA_TITLE,"ShareBy App");
123 | shareIntent.putExtra(Intent.EXTRA_TEXT,"Hey! Check out this awesome app for sharing things in your neighborhood..");
124 | startActivity(Intent.createChooser(shareIntent,"Complete action using"));
125 | break;
126 |
127 | default:
128 | break;
129 | }
130 | drawer.closeDrawer(GravityCompat.START);
131 | return true;
132 | }
133 |
134 | @Override
135 | protected void onResume() {
136 | super.onResume();
137 | ImageView nav_image=navigationView.getHeaderView(0).findViewById(R.id.nav_profile_image);
138 | TextView nav_user_name=navigationView.getHeaderView(0).findViewById(R.id.nav_profile_name);
139 | navigationView.setCheckedItem(R.id.nav_home);
140 | if (auth.getCurrentUser()!=null){
141 | nav_user_name.setText(auth.getCurrentUser().getDisplayName());
142 | if (auth.getCurrentUser().getPhotoUrl()==null) {
143 | nav_image.setImageResource(R.drawable.sign);
144 | }
145 | else{
146 | Log.d(TAG,"Glide image load");
147 | Glide.with(getApplicationContext())
148 | .load(auth.getCurrentUser().getPhotoUrl())
149 | .into(nav_image);
150 | }
151 | }
152 | }
153 |
154 | @Override
155 | public void onBackPressed() {
156 | if(drawer.isDrawerOpen(GravityCompat.START))
157 | drawer.closeDrawer(GravityCompat.START);
158 | else
159 | finish();
160 | }
161 |
162 | }
163 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/activities/PostActivity.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.activities;
2 |
3 | import android.content.SharedPreferences;
4 | import android.preference.PreferenceManager;
5 | import android.support.v7.app.ActionBar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.text.Editable;
9 | import android.text.TextWatcher;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.AdapterView;
14 | import android.widget.Button;
15 | import android.widget.EditText;
16 | import android.widget.LinearLayout;
17 | import android.widget.ProgressBar;
18 | import android.widget.Spinner;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | import com.google.android.gms.ads.AdRequest;
23 | import com.google.android.gms.ads.AdView;
24 | import com.google.android.gms.tasks.OnSuccessListener;
25 | import com.google.firebase.auth.FirebaseAuth;
26 | import com.google.firebase.auth.FirebaseUser;
27 | import com.google.firebase.database.DatabaseReference;
28 | import com.google.firebase.database.FirebaseDatabase;
29 | import com.zero.shareby.R;
30 | import com.zero.shareby.models.Post;
31 |
32 |
33 | public class PostActivity extends AppCompatActivity {
34 |
35 | Button postButton;
36 | EditText titleEditText,descriptionEditText;
37 | TextView titleTextView,descTextView;
38 | SharedPreferences preferences;
39 | FirebaseUser user;
40 | Spinner categorySpinner;
41 | ProgressBar progressBar;
42 | LinearLayout selectionLayout;
43 | int type = 0;
44 |
45 | @Override
46 | protected void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 | setContentView(R.layout.activity_post);
49 | ActionBar actionBar=getSupportActionBar();
50 | if (actionBar != null) {
51 | actionBar.setDisplayHomeAsUpEnabled(true);
52 | }
53 |
54 | selectionLayout = findViewById(R.id.post_selection_view);
55 | titleTextView=findViewById(R.id.post_title_text_view);
56 | descTextView=findViewById(R.id.post_description_text_view);
57 | preferences= PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
58 | user=FirebaseAuth.getInstance().getCurrentUser();
59 | categorySpinner = findViewById(R.id.post_category_spinner);
60 | titleEditText=findViewById(R.id.title_edit_text);
61 | descriptionEditText=findViewById(R.id.description_edit_text);
62 | postButton=findViewById(R.id.post_button);
63 | postButton.setBackgroundTintList(getResources().getColorStateList(android.R.color.darker_gray));
64 | postButton.setTextColor(getResources().getColor(android.R.color.white));
65 |
66 | categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
67 | @Override
68 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
69 | if (position==1){
70 | type =0;
71 | titleTextView.setText("What is your Query?");
72 | titleEditText.setHint("Let others know your question");
73 | descTextView.setText("Give a Little Explanation(optional)");
74 | descriptionEditText.setHint("A description helps others to understand your query better");
75 | selectionLayout.setVisibility(View.VISIBLE);
76 | }else if (position==2){
77 | type =1;
78 | titleTextView.setText("What do you want?");
79 | titleEditText.setHint("Your Request Item Title");
80 | descTextView.setText("Item Description(optional)");
81 | descriptionEditText.setHint("Let your neighbors know exactly what you want..");
82 | selectionLayout.setVisibility(View.VISIBLE);
83 | }else {
84 | selectionLayout.setVisibility(View.GONE);
85 | }
86 | }
87 |
88 | @Override
89 | public void onNothingSelected(AdapterView> parent) {
90 | selectionLayout.setVisibility(View.GONE);
91 | }
92 | }
93 | );
94 |
95 |
96 |
97 | titleEditText.addTextChangedListener(new TextWatcher() {
98 | @Override
99 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
100 |
101 | }
102 |
103 | @Override
104 | public void onTextChanged(CharSequence s, int start, int before, int count) {
105 | if (s.toString().trim().length()>0 && categorySpinner.getSelectedItemPosition()!=0) {
106 | postButton.setEnabled(true);
107 | postButton.setTextColor(getResources().getColor(android.R.color.white));
108 | postButton.setBackgroundTintList(getResources().getColorStateList(R.color.colorAccent));
109 | }
110 | else {
111 | postButton.setEnabled(false);
112 | postButton.setBackgroundTintList(getResources().getColorStateList(android.R.color.darker_gray));
113 | postButton.setTextColor(getResources().getColor(android.R.color.white));
114 | }
115 | }
116 |
117 | @Override
118 | public void afterTextChanged(Editable s) {
119 |
120 | }
121 | });
122 |
123 | postButton.setOnClickListener(new View.OnClickListener() {
124 | @Override
125 | public void onClick(View v) {
126 | postMessage();
127 | }
128 | });
129 | progressBar = findViewById(R.id.post_progress);
130 | AdView adView = findViewById(R.id.post_ad);
131 | AdRequest adRequest = new AdRequest.Builder().build();
132 | adView.loadAd(adRequest);
133 | }
134 |
135 | private void postMessage() {
136 | progressBar.setVisibility(View.VISIBLE);
137 | String title=titleEditText.getText().toString().trim();
138 | String description=null;
139 | if (descriptionEditText.getText().toString().trim().length()>0){
140 | description=descriptionEditText.getText().toString().trim();
141 | }
142 | if (user!=null){
143 | String country = preferences.getString(getString(R.string.pref_country), "null");
144 | String pin = preferences.getString(getString(R.string.pref_pin), "null");
145 | String key1 = preferences.getString(getString(R.string.pref_key1), "null");
146 | String key2 = preferences.getString(getString(R.string.pref_key2), "null");
147 |
148 | DatabaseReference uploadPost = FirebaseDatabase.getInstance().getReference().child("Groups").child(country).child(pin)
149 | .child(key1).child(key2).child("posts");
150 | Post newPost=new Post(user.getUid(),null,user.getDisplayName(),title,description,1,0,categorySpinner.getSelectedItemPosition()-1);
151 | uploadPost.push().setValue(newPost).addOnSuccessListener(this, new OnSuccessListener() {
152 | @Override
153 | public void onSuccess(Void aVoid) {
154 | progressBar.setVisibility(View.GONE);
155 | Toast.makeText(PostActivity.this,"Your Post Request Sent",Toast.LENGTH_SHORT).show();
156 | finish();
157 | }
158 | });
159 |
160 | }
161 | else {
162 | Toast.makeText(this, "An Error occurred", Toast.LENGTH_SHORT).show();
163 | progressBar.setVisibility(View.GONE);
164 | }
165 | }
166 |
167 | @Override
168 | public boolean onCreateOptionsMenu(Menu menu) {
169 | getMenuInflater().inflate(R.menu.post_menu,menu);
170 | return true;
171 | }
172 |
173 | @Override
174 | public boolean onOptionsItemSelected(MenuItem item) {
175 | switch (item.getItemId()){
176 |
177 | case android.R.id.home:
178 | case R.id.discard_changes_menu:
179 | finish();
180 | break;
181 |
182 | }
183 | return true;
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zero/shareby/utils/Utilities.java:
--------------------------------------------------------------------------------
1 | package com.zero.shareby.Utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.Nullable;
8 | import android.text.format.DateFormat;
9 | import android.util.Log;
10 |
11 | import com.google.firebase.auth.FirebaseAuth;
12 | import com.google.firebase.database.DataSnapshot;
13 | import com.google.firebase.database.DatabaseError;
14 | import com.google.firebase.database.DatabaseReference;
15 | import com.google.firebase.database.FirebaseDatabase;
16 | import com.google.firebase.database.ValueEventListener;
17 | import com.zero.shareby.R;
18 | import com.zero.shareby.models.UserDetails;
19 |
20 | import java.text.ParseException;
21 | import java.text.SimpleDateFormat;
22 | import java.util.Date;
23 | import java.util.HashMap;
24 | import java.util.Locale;
25 | import java.util.Map;
26 |
27 | public class Utilities {
28 |
29 | public static DatabaseReference getGroupReference(Context context){
30 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
31 | String key1 = preferences.getString("key1","nothing");
32 | if (key1.equals("nothing")){
33 | return null;
34 | }else {
35 | String country = preferences.getString("country","nothing");
36 | String key2 = preferences.getString("key2","nothing");
37 | String pin = preferences.getString("pin","nothing");
38 |
39 | return FirebaseDatabase.getInstance().getReference()
40 | .child("Groups").child(country).child(pin).child(key1).child(key2);
41 | }
42 | }
43 |
44 | public static void setPreferences(Context context) {
45 | final SharedPreferences myPreferences = PreferenceManager.getDefaultSharedPreferences(context);
46 | if (FirebaseAuth.getInstance().getCurrentUser() != null) {
47 | DatabaseReference currentUserRef = FirebaseDatabase.getInstance().getReference()
48 | .child("UserDetails").child(FirebaseAuth.getInstance().getCurrentUser().getUid());
49 | currentUserRef.addListenerForSingleValueEvent(new ValueEventListener() {
50 | @Override
51 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
52 | if (dataSnapshot.exists() && dataSnapshot.getChildrenCount() > 1) {
53 | UserDetails currentUserObject = dataSnapshot.getValue(UserDetails.class);
54 | SharedPreferences.Editor editor = myPreferences.edit();
55 | if (dataSnapshot.hasChild("country") && currentUserObject.getCountry() != null && !currentUserObject.getCountry().equals("null"))
56 | editor.putString("country", currentUserObject.getCountry());
57 |
58 | if (dataSnapshot.hasChild("pin") && currentUserObject.getPin() != null && !currentUserObject.getPin().equals("null"))
59 | editor.putString("pin", currentUserObject.getPin());
60 |
61 | if (dataSnapshot.hasChild("key1") && currentUserObject.getKey1() != null && !currentUserObject.getKey1().equals("null"))
62 | editor.putString("key1", currentUserObject.getKey1());
63 |
64 | if (dataSnapshot.hasChild("key2") && currentUserObject.getKey2() != null && !currentUserObject.getKey2().equals("null"))
65 | editor.putString("key2", currentUserObject.getKey2());
66 |
67 | if (dataSnapshot.hasChild("latitutde") && currentUserObject.getLatitude() != 0)
68 | editor.putFloat("lat", (float) currentUserObject.getLatitude());
69 |
70 | if (dataSnapshot.hasChild("longitude") && currentUserObject.getLongitude() != 0)
71 | editor.putFloat("lng", (float) currentUserObject.getLongitude());
72 |
73 | if (dataSnapshot.hasChild("photoUrl") && !currentUserObject.getPhotoUrl().equals(""))
74 | editor.putString("photoUrl", currentUserObject.getPhotoUrl());
75 |
76 | editor.apply();
77 | }
78 | }
79 |
80 | @Override
81 | public void onCancelled(@NonNull DatabaseError databaseError) {
82 | }
83 | });
84 | }
85 | }
86 |
87 | public static void uploadUserLocation(final Context context, final double lat, final double lng){
88 | if (FirebaseAuth.getInstance().getCurrentUser()!=null){
89 | final SharedPreferences mPref = PreferenceManager.getDefaultSharedPreferences(context);
90 | DatabaseReference dbRef = FirebaseDatabase.getInstance().getReference().child("UserDetails").child(FirebaseAuth.getInstance().getCurrentUser().getUid());
91 | Map latLngMap = new HashMap<>();
92 | latLngMap.put("latitude", lat);
93 | latLngMap.put("longitude", lng);
94 | dbRef.updateChildren(latLngMap, new DatabaseReference.CompletionListener() {
95 | @Override
96 | public void onComplete(@Nullable DatabaseError databaseError, @NonNull DatabaseReference databaseReference) {
97 | float oldLat=mPref.getFloat(context.getResources().getString(R.string.pref_lat),0.0F),
98 | oldLng=mPref.getFloat(context.getResources().getString(R.string.pref_lng),0.0F);
99 | SharedPreferences.Editor editLoc=mPref.edit();
100 | editLoc.putFloat(context.getResources().getString(R.string.pref_old_lat),oldLat);
101 | editLoc.putFloat(context.getResources().getString(R.string.pref_old_lng),oldLng);
102 | editLoc.putFloat(context.getResources().getString(R.string.pref_lat),(float) lat);
103 | editLoc.putFloat(context.getResources().getString(R.string.pref_lng),(float) lng);
104 | editLoc.apply();
105 | }
106 | });
107 | }
108 | }
109 |
110 | public static String calculateTimeDisplay(long timestamp){
111 | long diff=System.currentTimeMillis()-timestamp;
112 | /*
113 | sec(s) ago
114 | min(s) ago,
115 | hrs(s) ago,
116 | day(s) ago,
117 | rest dd,mon yy
118 | */
119 | String convertedTime="";
120 | if (diff<60000)
121 | convertedTime="a few sec(s) ago";
122 | else if (diff<3600000)
123 | convertedTime=Long.toString(diff/60000)+" min(s) ago";
124 | else if (diff<86400000)
125 | convertedTime=Long.toString(diff/3600000)+" hr(s) ago";
126 | else if (diff<129600000)
127 | convertedTime=Long.toString(diff/86400000)+" day(s) ago";
128 | else{
129 | convertedTime=DateFormat.format("dd, MMM yy",timestamp).toString();
130 | }
131 |
132 | return convertedTime+" ";
133 | }
134 |
135 | public static String compareUid(String currentUserUid,String otherUserUid){
136 | if (currentUserUid.compareTo(otherUserUid)>=0)
137 | return currentUserUid+otherUserUid;
138 | else return otherUserUid+currentUserUid;
139 | }
140 |
141 |
142 | public static boolean compareTimestamps(long t1,long t2){
143 | SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy",Locale.getDefault());
144 |
145 | Date d1,d2;
146 | try {
147 | d1 = df.parse(DateFormat.format("dd-MM-yyyy",t1).toString());
148 | d2 = df.parse(DateFormat.format("dd-MM-yyyy",t2).toString());
149 | Log.d("Dates:",""+d1+" "+d2+" "+d1.compareTo(d2));
150 | return d1.compareTo(d2)<0;
151 | } catch (ParseException e) {
152 | e.printStackTrace();
153 | }
154 | return false;
155 | }
156 |
157 | public static String getDateString(long timestamp){
158 | return DateFormat.format("MMM dd, yy",timestamp).toString();
159 | }
160 |
161 | public static String getTimeString(long timestamp){
162 | return DateFormat.format("hh:mm aaa",timestamp).toString();
163 | }
164 |
165 | public static String getUserUid() throws NullPointerException{
166 | return FirebaseAuth.getInstance().getCurrentUser().getUid();
167 | }
168 | }
169 |
--------------------------------------------------------------------------------