Professional Documents
Culture Documents
On
“Project Rudra”
AUGUST-2022
DECLARATION
We hereby declare that the project entitled “Project Rudra” submitted to JC Bose
University Of Science and Technology Faridabad, Haryana (India), is a record of an
original work done by us under the guidance of Ms Amita Pathania (Assistant
Professor) in Computer Science and Engineering, ARAVALI COLLEGE OF
ENGINEERING AND MANAGEMENT, FARIDABAD, and this project work
is submitted in the partial fulfillment of requirements for the award of the degree of
Bachelor of Technology in COMPUTER SCIENCE AND ENGINEERING.
AUGUST-2022
CERTIFICATE
This is to certify that the project titled “Project Rudra” is the bonafide work carried
out by Akshay Ratra, Vipul Jha, students of B.Tech (CSE) of Aravali College of
Engineering and Management, Jasana, Faridabad affiliated to J.C. Bose University
of Science and Technology, during the academic year 2021-22, in partial fulfillment
of the requirements for the award of the degree of Bachelor of Technology
(Computer Science and Engineering ) and that the project has not formed the basis
for the award previously of any other degree, diploma, fellowship or any other
similar title.
Place:
Date:
AUGUST-2022
TABLE OF CONTENTS
1. INTRODUCTION
● Brief about project
● Hardware and Software Requirements
2. JAVA
● What is JAVA?
● What is JAVA used for?
● Benefits of JAVA
● Disadvantages of JAVA
● Best Practices for using JAVA
3. XML
● What is XML?
● What is Mark Up Language?
● Why XML?
4. Django Rest Framework
● What is an API
● Why use an API
● Why Django Rest Framework
5. System Analysis and Design
● Frontend
● Backend
● Integration Test
6. Future Scope
7. Conclusion
AUGUST-2022
Introduction
This project was made by taking the safety of a citizen into consideration and giving
high priority. As we live in a free country everyone has a right to move around
without any fear but this often gets compromised due to inevitable circumstances
and evil social elements.
To reduce this gap of theory practical live we would like to introduce an app that
gives citizens confidence to move feeling without any fear. The purpose of this app
is to give women confidence and provide them safety
Rudra is a safety application to every local citizens. High priority- women safety.
Rudra is a one of the kind application that's role is to safe guard every citizen, high
priority for women. The action is done by alerting the police, blood relation and the
nearby citizens to help the one who was in threat.
For software part we are using XML and Java for frontend part and django rest
framework 3.11 for making APIs.
AUGUST-2022
JAVA
What is Java?
Java is a general-purpose programming language that is class-based and object-
oriented. The programming language is structured in such a way that developers can
write code anywhere and run it anywhere without worrying about the underlying
computer architecture. It is also referred to as write once, run anywhere (WORA).
This means Java code compiled once can be run on all platforms that run Java
Runtime Environment without the need for recompilation.
Java was developed inside Sun Microsystems (acquired by Oracle) by James
Gosling. It was developed to be similar to C++ and shares a lot of syntax with it.
Java, currently maintained by Oracle, receives regular updates to accommodate the
evolving needs of the developer community.
AUGUST-2022
● Middleware applications
● Web applications
● Mobile applications
● Embedded systems
● Enterprise applications
Benefits of Java
Java has evolved over the years as Oracle maintains the language and provides
updates regularly. The support from the huge developer community is a definite
advantage for new Java programmers, as well. Having been around for more than
two decades, Java has a substantial collection of available open-source libraries and
functions. Here’s a look at some of the key benefits of the Java programming
language.
● Simple and easy to learn. Java shares syntax with C and C++. Explicit
pointers, operator overloading, storage classes, and other elements that are
present in C++ are not available in Java. This makes it a less complex language
for writing code.
● Object-oriented programming language. Everything in Java is treated as an
object and has accompanying features like class, encapsulation, abstraction,
inheritance, and polymorphism.
● Multithreading is supported by Java. Large applications can be converted to
multiple threads and executed simultaneously. This reduces the resources and
time needed to execute a program.
● Platform agnostic language. Since Java runs within its virtual machine
sandbox, the platform and its computer architecture need not be considered
while writing Java applications. The same code can be executed by different
platforms without recompiling for each device, making project management
easy.
● Secure platform. Java programs are executed within its runtime environments.
It also provides a classloader to load classes to the runtime environment. This
provides a buffer and is inherently secure. That said, Java browser plugins are
extremely insecure and are better deactivated as most of the web now runs on
JavaScript.
AUGUST-2022
Disadvantages of Java
While there are many advantages to using Java, it’s not free of downsides or room
for improvement. Some of the disadvantages are:
1. Applications must be run on JRE. Java sandbox makes the applications
platform agnostic, but this also means that applications can be run only on top
of JRE, which requires more resources. Memory consumption is high as
applications have to run on top of a Java virtual machine.
2. UIs built using Java are less attractive. There are multiple Java frameworks to
create UIs for applications, but none of them are advanced enough to handle
complex UI elements that can be easily achieved by programming languages
such as JavaScript.
3. No backup facility. Java provides no backup facility and works from storage.
4. Garbage collectors provided with Java are automatic. That may seem like an
advantage, but it does not provide any facility for programmers to control
garbage collection. This is a problem when advanced functionalities are coded
in Java.
AUGUST-2022
● Re-scale images to use less resources. Buffer the original image and use the
re-scaled one.
Java is a popular programming language that is easy to learn, platform agnostic, and
can be used for a wide range of devices. Oracle provides excellent support for Java,
and the large and growing base of Java programmers also makes it an appealing
language to lean and code with.
AUGUST-2022
XML
What is xml
● XML (eXtensible Markup Language) is a markup language.
● XML is designed to store and transport data.
● XML was released in late 90’s. it was created to provide an easy to use and
store self describing data.
● XML became a W3C Recommendation on February 10, 1998.
● XML is not a replacement for HTML.
● XML is designed to be self-descriptive.
● XML is designed to carry data, not to display data.
● XML tags are not predefined. You must define your own tags.
● XML is platform independent and language independent.
Note: Self-describing data is the data that describes both its content and structure.
Prerequisite
Before you start to learn xml, you should know basic of HTML & JavaScript.
Why xml?
Platform Independent and Language Independent: The main benefit of xml is that
you can use it to take data from a program like Microsoft SQL, convert it into XML
then share that XML with other programs and platforms. You can communicate
between two platforms which are generally very difficult.
The main thing which makes XML truly powerful is its international acceptance.
Many corporation use XML interfaces for databases, programming, office
application mobile phones and more. It is due to its platform independent feature.
AUGUST-2022
What is an API?
Django Rest Framework lets you create RESTful APIs: A way to transfer
information between an interface and a database in a simple way.
It separates user interface and data storage and communicates user and database
sending a .json file. Just like this one:
AUGUST-2022
ARAVALI COLLEGE OF ENGINEERING AND MANAGEMENT
FARIDABAD, HARYANA
AUGUST-2022
Why use an API?
You can’t understand what an API is unless you understand what it can do. Imagine
that you want to create a web application. Obviously, you would choose Django.
You create it and it’s a hit! Everybody loves your web application! They love it so
much, that they want a mobile phone version! Time to create an Android Version!
And an iOS version. And then you have to replicate 2 times the same code to Add,
View, Remove, Update and Delete data, with different languages. That opens the
door to many possible mistakes…
But despite that, let’s say you managed and created the same application, using 3
different languages. Now, you notice that your website is static. You want your web
app to be more dynamic and modern. You need Javascript for that. While, you can
do it with just Vanilla Javascript, it is better to use a JS framework as React or Vue.
Now you need to re-do what you did in Django, iOS and Android again or you can
create a REST API.
With DRF, you can create an API to serve information to the user’s interface.
You can create a FrontEnd with Vue, an Android and iOS application, and all three
different platforms are connected to the same API
AUGUST-2022
You only need to create the logic once, and each of your platforms connect to the
same API.
This way, if you want to update it or add more functionality, you only need to change
in one side, not on each platform.
It is easier this way, right? Easier, more scalable and more reliable.
DRF takes the heavyweight of the database interaction and logic to just serve you
the information. No matter how many platforms you use or the language they are
built. As simple as that.
AUGUST-2022
Why Django Rest Framework?
We know now that REST APIs are important because they let us interact in an easy
way with the database and we can use it with different platforms.
But why use Django Rest Framework and not Node.js, Golang, Rust, etc?
Well, for starters, DRF uses Python, an easy to learn language.
DRF, as much as Django, makes everything simple and easier. Do you know Django
views? You have them in DRF too!
Do you want an end-point (an HTTP address) that returns you a list with each user,
with all of their fields and another one to create new users? Cool, here’s the code:
class UserList(generics.ListCreateAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
That’s it. You create a class called UserList that inherits methods from
ListCreateAPIView.
As the name says, you can List and Create users. If you ask for the URL (GET), you
get the list of the users, if you send (POST) information to that URL it will create a
new user.
3 lines of code. That’s all you need.
Another great thing about DRF? documentation. Alongside with Scrapy, it has the
best docs I have seen for a Django Framework. There are more technical things like
how migrations are handled, how each object has a model, how easy to switch
databases is and more.
AUGUST-2022
Existing System:
As there are numerous apps on women safety but they cover only one aspect and are
often paid.
Proposed System:
An app that is built on the top of it’s predecessor rather then from ground up. It
includes features of the existing apps with new add once.
Following are some reasons for why this app is made and why it gives a good
competition to its counter-parts if not beat them:
3. It gives an SOS call to your close contact which again can be very handy if one
don’t have the time to call someone for help or to tell their condition.
4. It gives the user freedom to do their duties as they have something which can
reach out to them before anyone and help them.
AUGUST-2022
SYSTEM ANALYSIS & DESIGN
Requirement Specification:
AUGUST-2022
ARAVALI COLLEGE OF ENGINEERING AND MANAGEMENT
FARIDABAD, HARYANA
AUGUST-2022
Frontend
Backend
For our backend part we have several APIs to test. We can use postman
to test our APIs
AUGUST-2022
Integration Test:
It is done to check how the backend and frontend behaves when
integrated. First we combine and sync our two components snd run our
fully app. If it work as intended then it has passed the test if not then either
there is problem in the components or they are not synced or properly
integrated.
AUGUST-2022
UI screenshots :
Register Screen
Login Screen
AUGUST-2022
Home Screen
Add SOS
Contacts
AUGUST-2022
Emergency Numbers
Trigger Screen
AUGUST-2022
Code :
Xml :-
1. Register Page
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background"
tools:context=".Registration">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp">
<ImageView
AUGUST-2022
android:layout_width="800dp"
android:layout_height="90dp"
android:src="@drawable/logo"></ImageView>
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="120dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:textColor="#FFFFFF"
android:textStyle="bold|italic"
android:gravity="center_horizontal"
android:text="WELCOME"
android:textSize="35sp" />
</RelativeLayout>
<TextView
AUGUST-2022
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:gravity="center_horizontal"
android:text="Register Here"
android:textSize="20sp" />
<EditText
android:id="@+id/fullName"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="45dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:background="@android:color/background_light"
AUGUST-2022
android:ems="10"
android:gravity="center_horizontal"
android:hint="Full Name"
android:inputType="textPersonName" />
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:background="@android:color/background_light"
android:ems="10"
android:gravity="center_horizontal"
android:hint="Email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/phone"
AUGUST-2022
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:background="@android:color/background_light"
android:ems="10"
android:gravity="center_horizontal"
android:hint="Phone Number"
android:inputType="phone" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:background="@android:color/background_light"
AUGUST-2022
android:ems="10"
android:gravity="center_horizontal"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="@+id/registerbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="120dp"
android:layout_marginTop="21dp"
android:layout_marginRight="120dp"
android:layout_marginBottom="3dp"
android:background="@color/colorPrimaryDark"
android:text="Register"
android:textColor="#FFFFFF"
android:textSize="24sp" />
<TextView
android:id="@+id/createText"
AUGUST-2022
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="3dp"
android:textColor="@color/colorPrimaryDark"
android:gravity="center_horizontal"
android:text="Already registered? Login Here"
android:textSize="18sp" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible" />
</LinearLayout>
AUGUST-2022
2. Login page
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background"
tools:context=".Registration">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp">
<ImageView
android:layout_width="800dp"
android:layout_height="90dp"
AUGUST-2022
android:src="@drawable/logo"></ImageView>
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="120dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:textColor="#FFFFFF"
android:textStyle="bold|italic"
android:gravity="center_horizontal"
android:text="WELCOME"
android:textSize="35sp" />
</RelativeLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
AUGUST-2022
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:gravity="center_horizontal"
android:text="Register Here"
android:textSize="20sp" />
<EditText
android:id="@+id/fullName"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="45dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:background="@android:color/background_light"
android:ems="10"
android:gravity="center_horizontal"
AUGUST-2022
android:hint="Full Name"
android:inputType="textPersonName" />
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:background="@android:color/background_light"
android:ems="10"
android:gravity="center_horizontal"
android:hint="Email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/phone"
android:layout_width="match_parent"
android:layout_height="37dp"
AUGUST-2022
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:background="@android:color/background_light"
android:ems="10"
android:gravity="center_horizontal"
android:hint="Phone Number"
android:inputType="phone" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:background="@android:color/background_light"
android:ems="10"
android:gravity="center_horizontal"
AUGUST-2022
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="@+id/registerbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="120dp"
android:layout_marginTop="21dp"
android:layout_marginRight="120dp"
android:layout_marginBottom="3dp"
android:background="@color/colorPrimaryDark"
android:text="Register"
android:textColor="#FFFFFF"
android:textSize="24sp" />
<TextView
android:id="@+id/createText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
AUGUST-2022
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="3dp"
android:textColor="@color/colorPrimaryDark"
android:gravity="center_horizontal"
android:text="Already registered? Login Here"
android:textSize="18sp" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible" />
</LinearLayout>
AUGUST-2022
3. Home Screen
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
tools:context=".MainScreen">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp">
AUGUST-2022
<ImageView
android:layout_width="800dp"
android:layout_height="90dp"
android:src="@drawable/logo">
</ImageView>
</RelativeLayout>
<GridLayout
android:layout_marginTop="10dp"
android:columnCount="2"
android:rowCount="3"
android:columnOrderPreserved="false"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
AUGUST-2022
app:cardElevation="6dp"
app:cardCornerRadius="12dp"
android:layout_margin="12dp"
>
<LinearLayout
android:orientation="vertical"
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/myprofile">
</ImageView>
<TextView
android:layout_marginTop="12dp"
android:textColor="@color/black"
AUGUST-2022
android:textSize="18sp"
android:text="My Profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:cardElevation="6dp"
app:cardCornerRadius="12dp"
android:layout_margin="12dp"
>
<LinearLayout
android:orientation="vertical"
android:padding="16dp"
AUGUST-2022
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/relative">
</ImageView>
<TextView
android:layout_marginTop="12dp"
android:textColor="@color/black"
android:textSize="18sp"
android:text="Add Relative"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</androidx.cardview.widget.CardView>
AUGUST-2022
//2
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:cardElevation="6dp"
app:cardCornerRadius="12dp"
android:layout_margin="12dp"
>
<LinearLayout
android:orientation="vertical"
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="80dp"
AUGUST-2022
android:layout_height="80dp"
android:src="@drawable/helpline">
</ImageView>
<TextView
android:layout_marginTop="12dp"
android:textColor="@color/black"
android:textSize="18sp"
android:text="Helpline Numbers"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:cardElevation="6dp"
AUGUST-2022
app:cardCornerRadius="12dp"
android:layout_margin="12dp"
>
<LinearLayout
android:orientation="vertical"
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/triggers">
</ImageView>
<TextView
android:layout_marginTop="12dp"
android:textColor="@color/black"
android:textSize="18sp"
AUGUST-2022
android:text="Triggers"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</androidx.cardview.widget.CardView>
//3
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:cardElevation="6dp"
app:cardCornerRadius="12dp"
android:layout_margin="12dp"
>
<LinearLayout
AUGUST-2022
android:orientation="vertical"
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/developedby">
</ImageView>
<TextView
android:layout_marginTop="12dp"
android:textColor="@color/black"
android:textSize="18sp"
android:text="Developed By"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
AUGUST-2022
</androidx.cardview.widget.CardView>
</GridLayout>
</LinearLayout>
</ScrollView>
AUGUST-2022
Java Code :-
1. Registration
package com.dan.rudra;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
AUGUST-2022
public class Registration extends AppCompatActivity {
EditText mFullName,mEmail,mPassword,mPhone;
Button mRegisterbtn;
TextView mCreateText;
FirebaseAuth fAuth;
ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
mFullName = findViewById(R.id.fullName);
mEmail = findViewById(R.id.email);
mPassword = findViewById(R.id.password);
mPhone = findViewById(R.id.phone);
mRegisterbtn = findViewById(R.id.registerbtn);
mCreateText = findViewById(R.id.createText);
fAuth = FirebaseAuth.getInstance();
AUGUST-2022
progressBar = findViewById(R.id.progressBar);
if (fAuth.getCurrentUser() != null) {
startActivity(new Intent(getApplicationContext(),
MainActivity.class));
finish();
}
mRegisterbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = mEmail.getText().toString().trim();
String password = mPassword.getText().toString().trim();
if (TextUtils.isEmpty(email)) {
mEmail.setError("Email is Required.");
return;
if (TextUtils.isEmpty(password)) {
mPassword.setError("Password is Required");
AUGUST-2022
return;
}
if(password.length() < 6) {
mPassword.setError("Password Must be >= 6 Characters");
return;
}
progressBar.setVisibility(View.VISIBLE);
fAuth.createUserWithEmailAndPassword(email,password).addOnComp
leteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
if (task.isSuccessful()) {
Toast.makeText(Registration.this, "User Created.",
Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(),
MainActivity.class));
} else {
Toast.makeText(Registration.this, "Error" +
task.getException().getMessage(), Toast.LENGTH_SHORT).show();
AUGUST-2022
progressBar.setVisibility(View.GONE);
}
}
});
}
});
mCreateText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(),
Login.class));
}
});
}
}
AUGUST-2022
2. Login
package com.dan.rudra;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
EditText mEmail,mPassword;
Button mLoginBtn;
TextView mCreateBtn;
// FirebaseAuth fAuth;
AUGUST-2022
ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mEmail = findViewById(R.id.email);
mPassword = findViewById(R.id.password);
mLoginBtn = findViewById(R.id.loginBtn);
mCreateBtn = findViewById(R.id.createText);
//fAuth = FirebaseAuth.getInstance();
progressBar = findViewById(R.id.progressBar);
mLoginBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(),
MainActivity.class));
AUGUST-2022
String email = mEmail.getText().toString().trim();
String password = mPassword.getText().toString().trim();
if (TextUtils.isEmpty(email)) {
mEmail.setError("Email is Required.");
return;
if (TextUtils.isEmpty(password)) {
mPassword.setError("Password is Required");
return;
}
if(password.length() < 6) {
mPassword.setError("Password Must be >= 6 Characters");
return;
}
progressBar.setVisibility(View.VISIBLE);
AUGUST-2022
//
fAuth.signInWithEmailAndPassword(email,password).addOnComplete
Listener(new OnCompleteListener<AuthResult>() {
// @Override
// public void onComplete(@NonNull Task<AuthResult>
task) {
// if(task.isSuccessful()) {
// Toast.makeText(Login.this, "Logged in Successfully",
Toast.LENGTH_SHORT).show();
//
// startActivity(new Intent(getApplicationContext(),
MainActivity.class));
//
//
// } else {
// Toast.makeText(Login.this, "Error! " +
task.getException().getMessage(),Toast.LENGTH_SHORT).show();
// }
// }
// });
AUGUST-2022
}
});
mCreateBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(),
Registration.class));
}
});
}
}
AUGUST-2022
3. HomePage
package com.dan.rudra;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
}
}
Output:
The app work as intended and it is a successful project.
AUGUST-2022
Future Scope
We will try to improve this app by adding voice messages and AI voice recognition
so that in case of emergency AI will recognize the voice and according to that it will
show you the emergency numbers according to your situation.
AUGUST-2022
Conclusion
AUGUST-2022
References
● www.stackoverflow.com
● www.geekforgeeks.org
● www.javapoint.com
●
AUGUST-2022