0% found this document useful (0 votes)
64 views32 pages

Android Report

The document presents a project report on the development of an Online Shopping System, submitted by Sayeda Zainab as part of her Master's degree requirements. The project aims to create a user-friendly e-commerce platform that allows users to purchase products online, with a focus on supporting rural communities and promoting traditional Indian culture. It includes details on the system's functionality, design, implementation, and the acknowledgment of contributors to the project.

Uploaded by

Shivani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views32 pages

Android Report

The document presents a project report on the development of an Online Shopping System, submitted by Sayeda Zainab as part of her Master's degree requirements. The project aims to create a user-friendly e-commerce platform that allows users to purchase products online, with a focus on supporting rural communities and promoting traditional Indian culture. It includes details on the system's functionality, design, implementation, and the acknowledgment of contributors to the project.

Uploaded by

Shivani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

“ONLINE SHOPPING SYSTEM”

Submitted to the
Department of Master of Computer Applications
in partial fulfilment of the requirements
for the Project (MCAE08)

by

Sayeda Zainab
1MY18MCA20

Under the guidance of


Abhishek K.L.
Asst. Professor

Ramaiah Institute of Technology


(Autonomous Institute, Affiliated to VTU)
Bangalore – 54

2020

1
DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS

CERTIFICATE

This is to certify that the project entitled Online Shopping is carried out by

Student Name USN


SAYEDA ZAINAB 1MY18MCA20

students of 5th semester, in partial fulfillment for the Project (MCAE08), during the academic year
2020-2021.

( Sign ) ( Sign )
Guide Head of the Department
Abhishek K.L Dr.Yogish H K

Name of Examiners Signature with Date


1.
2.

2
DECLARATION

I hereby declare that the project report entitled “Online Shopping System “ based on study
undertaken by me, towards the partial fulfilment for the Project (MCAE08) carried out during the
5th semester, has been compiled purely from the academic point of view and is, therefore, presented
in a true and sincere academic spirit. Contents of this report are based on my original study and
findings in relation there to are neither copied nor manipulated from other reports or similar
documents, either in part or in full, and it has not been submitted earlier to any
University/College/Academic institution for the award of any Degree/Diploma/Fellowship or
similar titles or prizes and that the work has not been published in any specific or popular
magazines.

Place: Bangalore SAYEDA ZAINAB


Date: 1MY18MCA20

3
Acknowledgment

A project work is a product of experience and it goes a long way in shaping a person in one aspect.
With great gratitude I would like to acknowledge the immense help of all those who contributed
with their valuable suggestions and timely assistance to complete this work. All that I have done is
only due to such supervision and assistance and I would not forget to thank them.

I would like to express my special thanks of gratitude to my Principal Dr. N.V.R.Naidu and would
also like to thank my HOD Dr. Yogish H K who gave me the golden opportunity to do this
wonderful project, which also helped me in doing a lot of Research. I thank Abhishek K.L for
providing me an opportunity to do the project giving all support and guidance which made me
complete the project duly. I am extremely thankful to him for providing such a nice support and
guidance, taking keen interest in my project work and guiding me all along, till the completion of
my project work by providing all the necessary information for developing a good system. Finally I
would like to thank my parents and friends who helped me a lot in completing this project within
the limited time frame

4
Abstract

Online shopping is a type of electronic business which enables purchasers to straightforwardly


purchase products from a vendor over the web utilizing android telephones. This undertaking
manages to build up a web-based business site for online distinctive sorts of items. It gives the
client an inventory of various sorts of items accessible for buy in the store. The Online shopping
venture has been produced to permit business becomes bigger and quicker. This website will let
customer view and request items online from any piece of the world. The site offers distinctive
sorts of. Under this site, numerous items and administrations can be requested

The Online Shopping application is planned from a client perspective. The easy to understand
configuration helps the clients in finishing their undertaking easily. Endeavors have been made to
keep the plan basic and justifiable. The screens were outlined in XML and the business rationale
was composed in Java. The aggregate lines of code written in this application are Java, XML.

An E Com App is a portal which allows merchants in developing counters to advertise and sell
their goods. This would permit rural communities to make their wares available to the rest of the
world. The objective of this project is to create a portal which would allow product information to
be updated securely using a mobile device and will allow users to buy goods form the merchant.
The main concern is given to the village women’s to explore their talents and to enhance our
traditional Indian culture. In future the internet become whole and soul to the business fields, each
and every trades are going to be done through it so this portal may helpful to the women as a
business person in this running world.

5
Table of Contents

Sl. No Topic Page No.


1 Introduction
1.1 Problem Definition
2 Functional Requirements
3 Module Description
4 Design Model
4.1 Flow diagram of the project
5 Implementation
5.1 Code snippets of the functional requirements
6 User Interfaces/Screenshots with Descriptions
7 Conclusion and Scope for Further Enhancement.

8 Bibliography

6
List of figures

Figure.No Figure name Page no


1 Flow diagram of online shopping system
2 Home page
3 Registration page
4 User login page
5 Admin login page
6 Submit Cart
7 Edit Profile
8 Admin view orders page
9 Admin confirm orders page

1. Introduction

Online shopping through app has become very popular these days because people find it convenient
and easy to shop from their home or office. People can save their time and energy by purchasing
products online with some discounts. The offers on the internet can be easily compared, and the buyer
can buy the product according to their favourable conditions like price, quality and other discounts
for their individual needs. The next generation of mobile phone “SMART Phones”, has opened the

7
new paths of using specially designed apps. We have most of the companies making use of this trend
of getting their company products available on their website for sale, to be accessed via the app. They
are also coming out with some great offers to attract customers to download and use their apps more
rather than accessing their website.
E-Commerce has improved business methods by giving the businesses the opportunity of selling
goods and services on a universal basis. The Internet provides traders the possibility of spreading
out their shops into infinite number of sites, and also gave the consumers the advantage of shopping
across all borders. To give the customers not only the advantage of buying anytime, but also the
advantage of buying anywhere, using a mobile device for E-commerce has become an alternative.
Progression of wireless technology made mobile devices more popular. From the customers’ point
of view in one hand, it is advantageous to use mobile devices such as smart phones and take
advantage of their mobility while surfing an online store, while in the other hand the shop owners
benefit from fulfilling the customers desires. This new method of purchasing, which is more
convenient for the consumers and more profitable for the shop owners, is called mobile commerce
or in abbreviation m-commerce.

1.1 Problem Definition

Online Shopping System is an APP which is designed to allow owners and customers to sell or buy
product online without going into the website. As online shopping became a trend nowadays the
regular shops are losing their customers to online brands. Customers have effortless
shopping experience and saving time through shopping online. For competing with those
online brands , If shops are providing an online portal where their customers can shop
through internet and get the products at their doors it will increase the number of customers.

2. Functional Requirements

User Login

This feature used by the user to login into system. A user must login with his user name and
password to the system after registration. If they are invalid, the user not allowed to enter the
system. Username and password will be provided after user registration is confirmed. - Password
should be hidden from others while typing it in the field.
8
Register New User

A new user will have to register in the system by providing essential details in order to view the
products in the system. System must be able to verify and validate information. - The system must
encrypt the password of the customer to provide security.

Purchasing an Item

The user can add the desired product into his cart by clicking add to cart option on the product. He
can view his cart by clicking on the cart button. All products added by cart can be viewed in the
cart. User can remove an item from the cart by clicking remove. After confirming the items in the
cart the user can submit the cart by providing a delivery address. On successful submitting the cart
will become empty. System must ensure that, only a registered customer can purchase items.

3. Module Description

1. Admin Module

Login
Admin must login with his email id and password to the system after registration.

Add Product
The online shopping system project contains different kind of products. The products can be
classified into different categories by name. Admin can add new products into the existing system
with all its details including an image.

View Order

9
The admin will have a list of all the orders placed by users. Admin can view all the details of each
order in the list.

Confirm Order
Once the order is placed by the user the admin has the privilege of confirming the order.

2. User Module

Register
A new user will have to register in the system by providing essential details in order to view
the products in the system.

Login
A user must login with his user name and password to the system after registration.

View Products
User can view the list of products based on their names after successful login. A detailed
description of a particular product with product name, products details, product image, and price
can be viewed by users.

Add products to cart


Customer could add a product to the shopping cart. .Customer should click on add to cart button.
System must add the selected product to the items on the customer’s shopping cart.

Submit Cart
After confirming the items in the cart the user can submit the cart by providing a delivery address.

Edit Profile
The user can view and edit the profile.
4. Design Model

In the proposed system customer need not go to the shop for buying the products. He can order the
product he wish to buy through the application in his Smartphone. The shop owner will be admin of
the system. The user needs to register and login with the required details to view products. The user
can then add products to cart and place order. Once the user places and order the admin will
confirm the order.

4.1 Flow diagram of the project

10
Fig1: Flow diagram of online shopping system

5. Implementation

5.1 Code snippets of the functional requirements

Home Page
package com.onlineshopping;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

11
public class MainActivity extends AppCompatActivity {
private Button signUpButton, signInButton, signInAdminBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
signUpButton = (Button) findViewById(R.id.main_sign_up_btn);
signInButton = (Button) findViewById(R.id.main_sign_in_btn);
signInAdminBtn =(Button) findViewById(R.id.main_admin_sign_in_btn);
signUpButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this,RegisterActivity.class);
startActivity(intent);
}
});
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this,LoginActivity.class);
startActivity(intent);
}
});

signInAdminBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this,AdminLoginActivity.class);
startActivity(intent);
}
});
}
}

Registration Page
package com.onlineshopping;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
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;
import com.google.firebase.database.FirebaseDatabase;
import Model.Users;
12
public class RegisterActivity extends AppCompatActivity {
private EditText inputEmail, inputPassword;
private FirebaseAuth auth;
private ProgressDialog loadingBar;
private Button btnSignUp;
private Button btnAdminSignUp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
loadingBar = new ProgressDialog(this);
loadingBar.setMessage("Loading....");
loadingBar.setCancelable(true);
loadingBar.setCanceledOnTouchOutside(false);
auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser()!= null){
startActivity(new Intent(RegisterActivity.this,MainActivity.class));
finish();
}
inputEmail = (EditText) findViewById(R.id.register_input_email);
inputPassword = (EditText) findViewById(R.id.register_input_password);
btnSignUp = (Button) findViewById(R.id.sign_up_btn);
btnAdminSignUp = (Button) findViewById(R.id.admin_register_btn);
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final String email = inputEmail.getText().toString();
final String password = inputPassword.getText().toString();
try {
if (password.length() > 0 && email.length() > 0) {
loadingBar.show();
auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(RegisterActivity.this, new
OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
Toast.makeText(RegisterActivity.this, "Authentication Failed",
Toast.LENGTH_LONG
).show();
Log.v("error", task.getResult().toString());
} else {
Toast.makeText(RegisterActivity.this,"Congratulations your account
has been created successfully",Toast.LENGTH_LONG).show();
loadingBar.dismiss();
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
if (task.isSuccessful()){
Users users = new Users(email,password);

13
FirebaseDatabase.getInstance().getReference("Users")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(users).addOnCompleteListener(new
OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
Toast.makeText(RegisterActivity.this,"Congratulations your
account has been created successfully",Toast.LENGTH_LONG).show();
loadingBar.dismiss();
Intent intent = new Intent(RegisterActivity.this,
LoginActivity.class);
startActivity(intent);
} else {

Toast.makeText(RegisterActivity.this,task.getException().getMessage(),Toast.LENGTH_LONG).s
how();
}
}
});
}
loadingBar.dismiss();
}
});
} else {
Toast.makeText(RegisterActivity.this, "All Fields are mandatory",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});

btnAdminSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final String email = inputEmail.getText().toString();
final String password = inputPassword.getText().toString();

try {
if (password.length() > 0 && email.length() > 0) {
loadingBar.show();
auth.createUserWithEmailAndPassword(email,
password).addOnCompleteListener(RegisterActivity.this, new OnCompleteListener<AuthResult>()
{
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Users users = new Users(email, password);
FirebaseDatabase.getInstance().getReference("Admins")

14
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(users).addOnCompleteListener(new
OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(RegisterActivity.this, "Congratulations, Admin
Account has been created successfully", Toast.LENGTH_LONG).show();
loadingBar.dismiss();
Intent intent = new Intent(RegisterActivity.this,
AdminLoginActivity.class);
startActivity(intent);
} else {
Toast.makeText(RegisterActivity.this,
task.getException().getMessage(), Toast.LENGTH_LONG).show();

}
}
});
}
loadingBar.dismiss();
}
});
} else {
Toast.makeText(RegisterActivity.this, "All Fields are mandatory",
Toast.LENGTH_LONG).show();
}

} catch (Exception e){


e.printStackTrace();
}
}
});
}
}

Login Page

package com.onlineshopping;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;

15
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import Model.Users;
import Prevalent.Prevalent;
public class LoginActivity extends AppCompatActivity {
private EditText inputEmail, inputPassword;
private FirebaseAuth auth;
private Button btnSigIn, btnChangePassword;
private ProgressDialog loadingBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
loadingBar = new ProgressDialog(this);
loadingBar.setMessage("Loading.....");
loadingBar.setCancelable(true);
loadingBar.setCanceledOnTouchOutside(false);
auth = FirebaseAuth.getInstance();

inputEmail = (EditText) findViewById(R.id.login_input_email);


inputPassword = (EditText) findViewById(R.id.login_input_password);
btnSigIn = (Button) findViewById(R.id.sign_in_btn);
btnChangePassword =(Button) findViewById(R.id.forgot_or_change__password_btn);
btnSigIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final String email = inputEmail.getText().toString();
final String password = inputPassword.getText().toString();
try {
if (password.length()> 0 && email.length()> 0){
loadingBar.show();

auth.signInWithEmailAndPassword(email,password).addOnCompleteListener(LoginActivity.this,
new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()){
Toast.makeText(LoginActivity.this, "Authentication Failed",
Toast.LENGTH_SHORT).show();
Log.v("error", task.getResult().toString());
} else{
Toast.makeText(LoginActivity.this,"You logged in
successfully",Toast.LENGTH_LONG).show();
loadingBar.dismiss();
Intent intent = new Intent(LoginActivity.this,HomeActivity.class);
Users users = new Users(email,password);
Prevalent.currentOnLineUsers = users;
startActivity(intent);
finish();
}
loadingBar.dismiss();

16
}
});
} else{
Toast.makeText(LoginActivity.this,"All fields are
mandatory",Toast.LENGTH_LONG).show();
}
} catch (Exception e){
e.printStackTrace();
}
}
});
btnChangePassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this,ForgotAndChangePasswordActivity.class);
startActivity(intent);
}
});
}
}

Admin Add New Products Page

package com.onlineshopping;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
public class AdminAddNewProductActivity extends AppCompatActivity {

17
private String categoryName, description, price, pname,saveCurrentDate, saveCurrentTime;
private Button addNewProductButton;
private ImageView inputProductImage;
private EditText inputProductName, inputProductDescription, inputProductPrice;
private static final int GalleryPick = 1;
private Uri imageUri;
private String productRandomKey,downLoadImageUrl;
private StorageReference productImagesRef;
private DatabaseReference productsRef;
private ProgressDialog loadingBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_add_new_product);
categoryName = getIntent().getExtras().get("category").toString();
productImagesRef = FirebaseStorage.getInstance().getReference().child("Product Images");
productsRef = FirebaseDatabase.getInstance().getReference().child("Products");
addNewProductButton = (Button) findViewById(R.id.add_new_product);
inputProductImage = (ImageView) findViewById(R.id.select_product_image);
inputProductName = (EditText) findViewById(R.id.product_name);
inputProductDescription = (EditText) findViewById(R.id.product_description);
inputProductPrice = (EditText) findViewById(R.id.product_price);
loadingBar = new ProgressDialog(this);
inputProductImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openGallery();
}
});
addNewProductButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
validateProductData();

}
});
}
private void openGallery() {
Intent galleryIntent = new Intent();
galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("image/*");
startActivityForResult(galleryIntent, GalleryPick);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == GalleryPick && resultCode == RESULT_OK && data != null) {


imageUri = data.getData();
inputProductImage.setImageURI(imageUri);
}

18
}
private void validateProductData() {
description = inputProductDescription.getText().toString();
price = inputProductPrice.getText().toString();
pname = inputProductName.getText().toString();
if (imageUri == null) {
Toast.makeText(this, "Product image is mandatory...", Toast.LENGTH_SHORT).show();
} else if (TextUtils.isEmpty(description)) {
Toast.makeText(this, "Please write product description...",
Toast.LENGTH_SHORT).show();
} else if (TextUtils.isEmpty(price)) {
Toast.makeText(this, "Please write product price...", Toast.LENGTH_SHORT).show();
} else if (TextUtils.isEmpty(pname)) {
Toast.makeText(this, "Please write product name...", Toast.LENGTH_SHORT).show();
}
else{
storeProductInformation();
}
}

private void storeProductInformation() {


loadingBar.setTitle("Add New Product");
loadingBar.setMessage("Dear Admin , Please wait while we are adding the new product.");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
Calendar calender = Calendar.getInstance();
SimpleDateFormat currentDate = new SimpleDateFormat("MMM dd,yyyy");
saveCurrentDate = currentDate.format(calender.getTime());
SimpleDateFormat currentTime = new SimpleDateFormat("HH:mm:ss a");
saveCurrentTime = currentTime.format(calender.getTime());
productRandomKey = saveCurrentDate + saveCurrentTime;
final StorageReference filePath = productImagesRef.child(imageUri.getLastPathSegment() +
productRandomKey + ".jpg");
final UploadTask uploadTask = filePath.putFile(imageUri);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
String message = e.toString();
Toast.makeText(AdminAddNewProductActivity.this, "Error: " + message,
Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(AdminAddNewProductActivity.this, "Product Image uploaded
Successfully....", Toast.LENGTH_SHORT).show();
Task<Uri> uriTask = uploadTask.continueWithTask(new
Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override

19
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws
Exception {
if (!task.isSuccessful()){
throw task.getException();
}
downLoadImageUrl = filePath.getDownloadUrl().toString();
return filePath.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()){
downLoadImageUrl = task.getResult().toString();
Toast.makeText(AdminAddNewProductActivity.this, "got the Product image Url
Successfully...", Toast.LENGTH_SHORT).show();
saveProductInfoToDatabase();
}
}
});
}
});
}
private void saveProductInfoToDatabase() {
HashMap<String, Object> productMap = new HashMap<>();
productMap.put("pid" , productRandomKey);
productMap.put("date" , saveCurrentDate);
productMap.put("time" , saveCurrentTime);
productMap.put("description" , description);
productMap.put("image" , downLoadImageUrl);
productMap.put("category" , categoryName);
productMap.put("price" , price);
productMap.put("pname" , pname);
productsRef.child(productRandomKey).updateChildren(productMap)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
Intent intent = new
Intent(AdminAddNewProductActivity.this,AdminCategoryActivity.class);
startActivity(intent);
loadingBar.dismiss();
Toast.makeText(AdminAddNewProductActivity.this, "Product is added
successfully...", Toast.LENGTH_SHORT).show();
}
else{
loadingBar.dismiss();
String message = task.getException().toString();
Toast.makeText(AdminAddNewProductActivity.this, "Error: " + message,
Toast.LENGTH_SHORT).show();
}
}

20
});
}
}

Admin Confirm Order Page

package com.onlineshopping;
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.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
public class ConfirmFinalOrderActivity extends AppCompatActivity {
private EditText nameEditText, phoneEditText, addressEditText, cityEditText;
private Button confirmOrderBtn;
private String totalAmount = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_confirm_final_order);
totalAmount = getIntent().getStringExtra("Total Price");
Toast.makeText(this, "Total Price = R" + totalAmount, Toast.LENGTH_SHORT).show();
confirmOrderBtn = (Button) findViewById(R.id.confirm_final_order);
nameEditText = (EditText) findViewById(R.id.shipment_name);
phoneEditText = (EditText) findViewById(R.id.shipment_phone_number);
addressEditText = (EditText) findViewById(R.id.shipment_address);
cityEditText = (EditText) findViewById(R.id.shipment_city);
confirmOrderBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Check();
}
});
}
private void Check() {
if (TextUtils.isEmpty(nameEditText.getText().toString())){
Toast.makeText(this, "Please provide your full name", Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(phoneEditText.getText().toString())){

21
Toast.makeText(this, "Please provide your phone number ",
Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(addressEditText.getText().toString())){
Toast.makeText(this, "Please provide your address", Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(cityEditText.getText().toString())){
Toast.makeText(this, "Please provide your city name ", Toast.LENGTH_SHORT).show();
}
else{
ConfirmOrder();
}
}
private void ConfirmOrder() {
final String saveCurrentDate,saveCurrentTime;
Calendar calForDate = Calendar.getInstance();
SimpleDateFormat currentDate = new SimpleDateFormat("MMM dd, yyyy");
saveCurrentDate = currentDate.format(calForDate.getTime());
SimpleDateFormat currentTime = new SimpleDateFormat("HH:mm:ss a");
saveCurrentTime = currentTime.format(calForDate.getTime());
HashMap<String, Object> ordersMap = new HashMap<>();
ordersMap.put("totalAmount",totalAmount);
ordersMap.put("name",nameEditText.getText().toString());
ordersMap.put("phone",phoneEditText.getText().toString());
ordersMap.put("address",addressEditText.getText().toString());
ordersMap.put("city",cityEditText.getText().toString());
ordersMap.put("date",saveCurrentDate);
ordersMap.put("time",saveCurrentTime);
ordersMap.put("state","not shipped");
FirebaseDatabase.getInstance().getReference("Orders")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.updateChildren(ordersMap).addOnCompleteListener(new OnCompleteListener<Void>()
{
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful())
{
FirebaseDatabase.getInstance().getReference("CartList")
.child("UserView")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.removeValue()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
Toast.makeText(ConfirmFinalOrderActivity.this, "your final order has
been placed successfully", Toast.LENGTH_SHORT).show();
Intent intent = new
Intent(ConfirmFinalOrderActivity.this,HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);

22
startActivity(intent);
finish();
}
}
});
}
}
});
}
}

Cart Page

package com.onlineshopping;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.apo.etito.ViewHolder.CartViewHolder;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
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 Model.Cart;
import Prevalent.Prevalent;
public class CartActivity extends AppCompatActivity ;
private RecyclerView recyclerView;
private RecyclerView.LayoutManager layoutManager;
private Button nextProcessBtn;
private TextView txtTotalAmount, txtMsg1 ;
private int overTotalPrice = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cart);

23
recyclerView = findViewById(R.id.cart_list);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
nextProcessBtn = (Button) findViewById(R.id.next_process_btn);
txtTotalAmount = (TextView) findViewById(R.id.total_price);
txtMsg1 = (TextView) findViewById(R.id.msg1);
nextProcessBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
txtTotalAmount.setText("Total Price = R" + String.valueOf(overTotalPrice));
} catch (NumberFormatException e){
return;
}
txtTotalAmount.setText("Total Price = R" + String.valueOf(overTotalPrice));
Intent intent = new Intent(CartActivity.this,ConfirmFinalOrderActivity.class);
intent.putExtra("Total Price",String.valueOf(overTotalPrice));
startActivity(intent);
finish();
}
});
}
@Override
protected void onStart() {
super.onStart();
checkOrderState();
final DatabaseReference cartListRef =
FirebaseDatabase.getInstance().getReference("CartList");
FirebaseRecyclerOptions<Cart> options =
new FirebaseRecyclerOptions.Builder<Cart>()
.setQuery(cartListRef.child("UserView")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.child("Products"),Cart.class)
.build();
FirebaseRecyclerAdapter<Cart, CartViewHolder> adapter =
new FirebaseRecyclerAdapter<Cart, CartViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull CartViewHolder cartViewHolder, int
position, @NonNull final Cart model) {
try {
cartViewHolder.txtProductQuantity.setText("Quantity = " +
model.getQuantity());
cartViewHolder.txtProductPrice.setText("Price = R" + model.getPrice());
cartViewHolder.txtProductName.setText(model.getPname());
int oneTypeTotalProduct = (Integer.valueOf(model.getPrice())) *
Integer.valueOf(model.getQuantity());
overTotalPrice = overTotalPrice + oneTypeTotalProduct;
} catch(NumberFormatException e){
return;
}

24
cartViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CharSequence options[] = new CharSequence[]
{
"Edit",
"Delete"
};
AlertDialog.Builder builder = new AlertDialog.Builder(CartActivity.this);
builder.setTitle("Cart Options:");
builder.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which==0){
Intent intent = new
Intent(CartActivity.this,ProductDetailsActivity.class);
intent.putExtra("pid",model.getPid());
startActivity(intent);
}
if (which==1){
cartListRef.child("UserView")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.child("Products")
.child(model.getPid())
.removeValue()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
Toast.makeText(CartActivity.this, "Item deleted
successfully.", Toast.LENGTH_SHORT).show();
Intent intent = new
Intent(CartActivity.this,HomeActivity.class);
startActivity(intent);
}
}
});
}
}
});
builder.show();
}
});
}
@NonNull
@Override
public CartViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.cart_items_layout,parent,false);
CartViewHolder holder = new CartViewHolder(view);

25
return holder;
}
};
recyclerView.setAdapter(adapter);
adapter.startListening();
}
private void checkOrderState(){
FirebaseDatabase.getInstance().getReference("Orders")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()){
String shippingState = dataSnapshot.child("state").getValue().toString();
String userName = dataSnapshot.child("name").getValue().toString();
if (shippingState.equals("shipped")){
txtTotalAmount.setText("Dear " + userName + "\n order is shipped
successfully.");
recyclerView.setVisibility(View.GONE);
txtMsg1.setVisibility(View.VISIBLE);
txtMsg1.setText("Congratulations, your final order has been Shipped
successfully.Soon you will receive your order by your door step ");
nextProcessBtn.setVisibility(View.GONE);
Toast.makeText(CartActivity.this, "You can purchase more products once you
receive your first order", Toast.LENGTH_SHORT).show();
} else if (shippingState.equals("not shipped")){
txtTotalAmount.setText("Shipping State = not shipped");
recyclerView.setVisibility(View.GONE);
txtMsg1.setVisibility(View.VISIBLE);
nextProcessBtn.setVisibility(View.GONE);
Toast.makeText(CartActivity.this, "You can purchase more products once you
receive your first order", Toast.LENGTH_SHORT).show();
}} }
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
}); } }

26
6. User Interfaces/Screenshots with Descriptions

HOME PAGE

Fig2: Home Page

Registration

27
Fig3: Registration Page

USER LOGIN PAGE

Fig4: user login page

ADMIN LOGIN PAGE

28
Fig5: Admin login page

Submit Cart Page

Fig6: Cart Page

Edit Profile Page

29
Fig7: Edit Profile page
Admin View Orders Page

Fig8:Admin view orders page

Admin Confirm Order Page

30
Fig9: Admin confirm order page

7. Conclusion and Scope for Further Enhancement

Conclusion

As the demand for the online shopping is increasing the requirement of more secure, safe and
reliable transaction is of utmost demand. Smart phones, that have become an important part of
today’s life, have reduced all the efforts that are required for shopping. With camera feature in
it, the user can scan the barcode of the item to be purchased and then directly add it into the
cart. There are two advantages of it: first no need to stand in the queue for a long time in malls
just for scanning the item, second there will be no scope for the frauds that happen in online
shopping. The items so far purchased by the customer will be maintained in the app that can be
used by the customer in the next purchase. The transactions that will take place frequently with
the shop’s database will be made secured. This will ensure no modifications in the shop’s
database either by the customer or by any unauthorized user.

Further Enhancement

The current system can be extended to allow the users to create accounts and save products in
to wish list. The users could subscribe for price alerts which would enable them to receive
messages when price for products fall below a particular level. The current system is confined

31
only to the shopping cart process. It can be extended to have an easy to use check out process.
Users can have multiple shipping and billing information saved. During checkout they can use
the drag and drop feature to select shipping and billing information

8. Bibliography

https://www.academia.edu/35185477/Mini_Project_Report_On_ONLINE_SHOPPING_SYSTEM
http://ijarcet.org/wp-content/uploads/IJARCET-VOL-4-ISSUE-3-874-878
https://www.researchgate.net/publication/
318463396_Survey_on_Development_of_Android_Based_Mobile_App_for_Prestashop_eCommer
ce_Shopping_Cart_ALC
https://core.ac.uk/download/pdf/5165156

32

You might also like