diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 00000000..0a8bc552
Binary files /dev/null and b/.DS_Store differ
diff --git a/README.md b/README.md
index 8485fa33..a75030aa 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,8 @@
# disaster-management
Lynk Hackathon 2019 - Disaster Management
+
+# Techstack
+Android (Java)
+Firebase
+WiFi Direct (Peer - Peer connection)
+
diff --git a/lynkhack/.DS_Store b/lynkhack/.DS_Store
new file mode 100644
index 00000000..5008ddfc
Binary files /dev/null and b/lynkhack/.DS_Store differ
diff --git a/lynkhack/LynkHack.iml b/lynkhack/LynkHack.iml
new file mode 100644
index 00000000..e92507e2
--- /dev/null
+++ b/lynkhack/LynkHack.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lynkhack/app/.gitignore b/lynkhack/app/.gitignore
new file mode 100644
index 00000000..796b96d1
--- /dev/null
+++ b/lynkhack/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/lynkhack/app/app.iml b/lynkhack/app/app.iml
new file mode 100644
index 00000000..08d88c68
--- /dev/null
+++ b/lynkhack/app/app.iml
@@ -0,0 +1,152 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lynkhack/app/build.gradle b/lynkhack/app/build.gradle
new file mode 100644
index 00000000..91d91316
--- /dev/null
+++ b/lynkhack/app/build.gradle
@@ -0,0 +1,34 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ defaultConfig {
+ applicationId "com.lynkhack"
+ minSdkVersion 23
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'com.google.android.material:material:1.0.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+ implementation 'com.android.support:cardview-v7:28.0.0'
+ implementation 'com.google.firebase:firebase-database:19.1.0'
+ implementation 'com.google.android.gms:play-services-location:17.0.0'
+
+}
+apply plugin: 'com.google.gms.google-services'
diff --git a/lynkhack/app/google-services.json b/lynkhack/app/google-services.json
new file mode 100644
index 00000000..290778f8
--- /dev/null
+++ b/lynkhack/app/google-services.json
@@ -0,0 +1,40 @@
+{
+ "project_info": {
+ "project_number": "119895911024",
+ "firebase_url": "https://lynksaver.firebaseio.com",
+ "project_id": "lynksaver",
+ "storage_bucket": "lynksaver.appspot.com"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:119895911024:android:9d071ef3ce2cc996dba2b5",
+ "android_client_info": {
+ "package_name": "com.lynkhack"
+ }
+ },
+ "oauth_client": [
+ {
+ "client_id": "119895911024-ghn7vnvopdmfkqads09ughu03s2d0qda.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ],
+ "api_key": [
+ {
+ "current_key": "AIzaSyBiFOrO0nqFKRbFPiXO9hXdFZ7ssKlyHN8"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": [
+ {
+ "client_id": "119895911024-ghn7vnvopdmfkqads09ughu03s2d0qda.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/lynkhack/app/proguard-rules.pro b/lynkhack/app/proguard-rules.pro
new file mode 100644
index 00000000..f1b42451
--- /dev/null
+++ b/lynkhack/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/lynkhack/app/src/androidTest/java/com/lynkhack/ExampleInstrumentedTest.java b/lynkhack/app/src/androidTest/java/com/lynkhack/ExampleInstrumentedTest.java
new file mode 100644
index 00000000..1a0e0d64
--- /dev/null
+++ b/lynkhack/app/src/androidTest/java/com/lynkhack/ExampleInstrumentedTest.java
@@ -0,0 +1,27 @@
+package com.lynkhack;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ assertEquals("com.lynkhack", appContext.getPackageName());
+ }
+}
diff --git a/lynkhack/app/src/main/AndroidManifest.xml b/lynkhack/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..32210fd4
--- /dev/null
+++ b/lynkhack/app/src/main/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lynkhack/app/src/main/java/com/lynkhack/ChatActivity.java b/lynkhack/app/src/main/java/com/lynkhack/ChatActivity.java
new file mode 100755
index 00000000..98de792f
--- /dev/null
+++ b/lynkhack/app/src/main/java/com/lynkhack/ChatActivity.java
@@ -0,0 +1,204 @@
+package com.lynkhack;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import org.drulabs.localdash.model.ChatDTO;
+import org.drulabs.localdash.notification.NotificationToast;
+import org.drulabs.localdash.transfer.DataSender;
+import org.drulabs.localdash.utils.ConnectionUtils;
+import org.drulabs.localdash.utils.Utility;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ChatActivity extends AppCompatActivity {
+
+ public static final String ACTION_CHAT_RECEIVED = "com.lynkhack";
+ public static final String KEY_CHAT_DATA = "chat_data_key";
+
+ public static final String KEY_CHATTING_WITH = "chattingwith";
+ public static final String KEY_CHAT_IP = "chatterip";
+ public static final String KEY_CHAT_PORT = "chatterport";
+
+ EditText etChat;
+ RecyclerView chatListHolder;
+ private List chatList;
+ private ChatListAdapter chatListAdapter;
+
+ private String chattingWith;
+ private String destIP;
+ private int destPort;
+ private String data ="";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_chat);
+ TextView chat= (TextView) findViewById(R.id.cardview_user_info);
+ initialize();
+ chat.setText(data);
+
+ chatListHolder = (RecyclerView) findViewById(R.id.chat_list);
+ etChat = (EditText) findViewById(R.id.et_chat_box);
+
+ chatList = new ArrayList<>();
+ chatListAdapter = new ChatListAdapter(chatList);
+ chatListHolder.setAdapter(chatListAdapter);
+
+ LinearLayoutManager linearLayoutManager = new LinearLayoutManager(ChatActivity.this);
+ linearLayoutManager.setStackFromEnd(true);
+ chatListHolder.setLayoutManager(linearLayoutManager);
+ data = getIntent().getStringExtra("FROM_LYNK");
+ sendUserDetails(data);
+ }
+
+ private void initialize() {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(ACTION_CHAT_RECEIVED);
+ LocalBroadcastManager.getInstance(ChatActivity.this).registerReceiver(chatReceiver, filter);
+
+ Bundle extras = getIntent().getExtras();
+ if (extras == null) {
+ NotificationToast.showToast(ChatActivity.this, "Invalid arguments to open chat");
+ finish();
+ }
+
+ chattingWith = extras.getString(KEY_CHATTING_WITH);
+ destIP = extras.getString(KEY_CHAT_IP);
+ destPort = extras.getInt(KEY_CHAT_PORT);
+
+ setToolBarTitle("Chat with " + chattingWith);
+ data = getIntent().getStringExtra("FROM_LYNK");
+
+ }
+
+
+ private void sendUserDetails(String message){
+
+
+ ChatDTO myChat = new ChatDTO();
+ myChat.setPort(ConnectionUtils.getPort(ChatActivity.this));
+ myChat.setFromIP(Utility.getString(ChatActivity.this, "myip"));
+ myChat.setLocalTimestamp(System.currentTimeMillis());
+ myChat.setMessage(message);
+ myChat.setSentBy(chattingWith);
+ myChat.setMyChat(true);
+ DataSender.sendChatInfo(ChatActivity.this, destIP, destPort, myChat);
+
+// chatListHolder.smoothScrollToPosition(chatList.size() - 1);
+ updateChatView(myChat);
+ }
+
+ public void SendChatInfo(View v) {
+ String message = etChat.getText().toString();
+
+ ChatDTO myChat = new ChatDTO();
+ myChat.setPort(ConnectionUtils.getPort(ChatActivity.this));
+ myChat.setFromIP(Utility.getString(ChatActivity.this, "myip"));
+ myChat.setLocalTimestamp(System.currentTimeMillis());
+ myChat.setMessage(message);
+ myChat.setSentBy(chattingWith);
+ myChat.setMyChat(true);
+ DataSender.sendChatInfo(ChatActivity.this, destIP, destPort, myChat);
+
+ etChat.setText("");
+// chatListHolder.smoothScrollToPosition(chatList.size() - 1);
+ updateChatView(myChat);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ private BroadcastReceiver chatReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ switch (intent.getAction()) {
+ case ACTION_CHAT_RECEIVED:
+ ChatDTO chat = (ChatDTO) intent.getSerializableExtra(KEY_CHAT_DATA);
+ chat.setMyChat(false);
+ updateChatView(chat);
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
+ private void updateChatView(ChatDTO chatObj) {
+ chatList.add(chatObj);
+ chatListAdapter.notifyDataSetChanged();
+ chatListHolder.smoothScrollToPosition(chatList.size() - 1);
+ }
+
+ private class ChatListAdapter extends RecyclerView.Adapter {
+
+ private List chatList;
+
+ ChatListAdapter(List chatList) {
+ this.chatList = chatList;
+ }
+
+ @Override
+ public ChatHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (viewType == 0) {
+ View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.chat_item_mine,
+ parent, false);
+ return new ChatHolder(itemView);
+ } else {
+ View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.chat_item_other,
+ parent, false);
+ return new ChatHolder(itemView);
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(ChatHolder holder, int position) {
+ holder.bind(chatList.get(position));
+ }
+
+ @Override
+ public int getItemCount() {
+ return chatList == null ? 0 : chatList.size();
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ ChatDTO chatObj = chatList.get(position);
+ return (chatObj.isMyChat() ? 0 : 1);
+ }
+
+ class ChatHolder extends RecyclerView.ViewHolder {
+ TextView tvChatMessage;
+
+ public ChatHolder(View itemView) {
+ super(itemView);
+ tvChatMessage = (TextView) itemView.findViewById(R.id.tv_chat_msg);
+ }
+
+ public void bind(ChatDTO singleChat) {
+ tvChatMessage.setText(singleChat.getMessage());
+ }
+ }
+ }
+
+ private void setToolBarTitle(String title) {
+ if (getSupportActionBar() != null) {
+ getSupportActionBar().setTitle(title);
+ }
+ }
+}
diff --git a/lynkhack/app/src/main/java/com/lynkhack/DashboardActivity.java b/lynkhack/app/src/main/java/com/lynkhack/DashboardActivity.java
new file mode 100644
index 00000000..65821746
--- /dev/null
+++ b/lynkhack/app/src/main/java/com/lynkhack/DashboardActivity.java
@@ -0,0 +1,93 @@
+package com.lynkhack;
+
+import android.location.Location;
+import android.os.Bundle;
+
+import com.google.android.gms.location.FusedLocationProviderClient;
+import com.google.android.gms.location.LocationServices;
+import com.google.android.gms.tasks.OnSuccessListener;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.snackbar.Snackbar;
+import com.google.firebase.database.DataSnapshot;
+import com.google.firebase.database.DatabaseError;
+import com.google.firebase.database.DatabaseReference;
+import com.google.firebase.database.FirebaseDatabase;
+import com.google.firebase.database.ValueEventListener;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+
+import org.w3c.dom.Text;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DashboardActivity extends AppCompatActivity {
+
+
+ RecyclerView recyclerView;
+ DatabaseReference mDatabase;
+ private RecyclerView.Adapter mAdapter;
+ FusedLocationProviderClient fusedLocationClient;
+ Location locationLocal;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_dashboard);
+ recyclerView = findViewById(R.id.recycler_dashboard);
+ mDatabase = FirebaseDatabase.getInstance().getReference();
+ recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
+ fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
+
+ fusedLocationClient.getLastLocation()
+ .addOnSuccessListener(this, new OnSuccessListener() {
+ @Override
+ public void onSuccess(Location location) {
+ // Got last known location. In some rare situations this can be null.
+ if (location != null) {
+ // Logic to handle location object
+ locationLocal = location;
+ }
+ }
+ });
+
+ mDatabase.child("users").addListenerForSingleValueEvent(new ValueEventListener() {
+ @Override
+ public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
+// DataSnapshot snapshot = (DataSnapshot) dataSnapshot.getValue();
+// snapshot.child(snapshot.getKey()).getValue();
+ List