Professional Documents
Culture Documents
Online Shopping System Synopsis by Atulya and Sakshi
Online Shopping System Synopsis by Atulya and Sakshi
Online Shopping System Synopsis by Atulya and Sakshi
AND MANAGEMENT
MARCH-2021
ONLINE SHOPPING SYSTEM
MCA-551
CASE STUDY ON MOBILE
APPLICATIONS
S. No. Headings
1. Project Specification
1. Project Overview
2.Project Need
2. Specific Requirements
3. External
Interface
Requirements
4. Hardware
3. Interfaces
5.Software Interfaces
Software Product Features
6. E-R Diagram
7. Data Flow Diagram
8. Use Case Diagram
4. Advantages 9. Screenshots
5. Limitations 10. Coding
6. Conclusion
7. Bibliography
1) Project Specification: -
1.1) Project Overview: -
The Project is aimed at online shopping in which customer need not to go anywhere they can just do it at
their home by registering themselves on the online shopping application and after that they can place
order whatever they require.
1.2) Project Need: -
The system displays the list of all issues that are open, closed, in progress. If the user can get registered
by clicking on the login button and provide the required information as specified. Each time the
registered customer come on to the application they can makes use of the user name and the password
that is allocated to him and get the details.
2.) Specific Requirements: -
Password C_Name
C_ID
A_Id Password
Mobile_No
Online
Admin Shopping Customer
System
Email Address
City
Mobile_No
Email
State
Pin_Code
Color
Product
Type
Manufacturing
date
P_Price P_ID
P_Description P_Name
3.2) Data Flow Diagram
Online Shopping
Seller System
Payment
Management
Management
Login
Register
User ID
Password
Admin Customer
Add Category
Add Item
Manage Item
Manage Order
View Item
Make Payment
Seller
Change Password
Logout
3.4) Screenshots
Main Activity Screenshots
3.5) Coding
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/main"
tools:context=".Buyers.MainActivity">
<ImageView
android:id="@+id/app_logo"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:background="@android:color/holo_red_light"
android:src="@drawable/tbs" />
<TextView
android:layout_width="300dp"
android:layout_height="100dp"
android:background="@drawable/tbs2"
android:layout_alignBottom="@id/app_log
o"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"
android:layout_marginBottom="-114dp" />
<Button
android:id="@+id/register"
android:layout_width="match
_parent"
android:layout_height="wrap_content"
android:layout_above="@id/login"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="5dp"
android:background="@android:color/transparent"
android:padding="20dp"
android:text="Join Now"
android:textAllCaps="false"
android:textColor="#3E2723"
android:textSize="24sp"
android:textStyle="bold" />
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/seller_begin"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#B00020"
android:padding="20dp"
android:textSize="24sp"
android:textAllCaps="false"
android:text="Already a customer?Login Here!"
android:textColor="@android:color/darker_gray"
/>
<TextView
android:id="@+id/seller_begin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wants to become a Seller?"
android:textSize="20dp"
android:textColor="@android:color/black"
android:textStyle="bold"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="19dp"
android:layout_marginBottom="10dp"
/>
</RelativeLayout>
MainActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import
androidx.annotation.NonNull;
import
androidx.appcompat.app.AppCom
patActivity;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
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 com.teamstogether.twentyfourbysevenshopping.Model.Users;
import com.teamstogether.twentyfourbysevenshopping.Prevalent.Prevalent;
import com.teamstogether.twentyfourbysevenshopping.R;
import
com.teamstogether.twentyfourbysevenshopping.Sellers.SellerHomeActivity;
import
com.teamstogether.twentyfourbysevenshopping.Sellers.SellerRegistrationAct
ivity;
import io.paperdb.Paper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sellerBegin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, SellerRegistrationActivity.class);
startActivity(intent);
}
});
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent2 = new Intent(MainActivity.this, RegisterActivity.class);
startActivity(intent2);
}
});
AllowAccess(UserPhoneKey, UserPasswordKey);
@Override
protected void onStart() {
super.onStart();
FirebaseUser firebaseUser =
FirebaseAuth.getInstance().getCurrentUser();
if (firebaseUser !=null)
{
Intent intent = new Intent(MainActivity.this, SellerHomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
}
}
private void
AllowAccess(final String
phone, final String
password)
{
final
DatabaseReference
RootRef;
RootRef =
FirebaseDatabase.getIn
stance().getReference()
;
RootRef.addListenerForSingleValueEvent(new ValueEventListener()
{ @Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{
if (dataSnapshot.child("Users").child(phone).exists())
{
Users usersData =
dataSnapshot.child("Users").child(phone).getValue(Users.class)
;
if (usersData.getPhone().equals(phone))
{
if (usersData.getPassword().equals(password))
{
Toast.makeText(MainActivity.this, "Please wait, you are already logged in...",
Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}
activity_home.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" /
>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
HomeActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import
androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import
com.google.android.material.floatingactionbutton.FloatingAct
ionButton;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.database.DatabaseReference; import
com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
import
com.teamstogether.twentyfourbysevenshopping.Admin.AdminMa
intainProductsActivity;
import com.teamstogether.twentyfourbysevenshopping.Model.Products;
import com.teamstogether.twentyfourbysevenshopping.Prevalent.Prevalent;
import com.teamstogether.twentyfourbysevenshopping.R;
import
com.teamstogether.twentyfourbysevenshopping.ViewHolder.ProductViewHo
lder;
import de.hdodenhof.circleimageview.CircleImageView;
import io.paperdb.Paper;
ProductsRef = FirebaseDatabase.getInstance().getReference().child("Products");
Paper.init(this);
NavigationView navigationView =
findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
if (!type.equals("Admin"))
{
userNameTextView.setText(Prevalent.currentOnlineUser.getName());
Picasso.get().load(Prevalent.currentOnlineUser.getImage()).placeholder(R.drawable.profile).i
nto(profile
ImageView);
}
recyclerView = findViewById(R.id.recycler_menu);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
}
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerOptions<Products> options =
new
FirebaseRecyclerOptions.Builder<Products>()
.setQuery(ProductsRef.orderByChild("productState").equalTo("Approved"),
Products.class)
.build();
holder.itemView.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
if (type.equals("Admin"))
{
Intent intent = new Intent(HomeActivity.this,
AdminMaintainProductsActivity.class);
intent.putExtra(
"pid",model.getPid());
startActivity(intent);
}
else
{
Intent intent = new Intent(HomeActivity.this,
ProductDetailsActivity.class); intent.putExtra("pid",model.getPid());
startActivity(intent);
}
}
});
}
@NonNull
@Override
public
ProductVie
wHolder
onCreateVi
ewHolder(
@NonNull
ViewGrou
p parent,
int
viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.product_items_layout,
parent, false);
ProductViewHolder holder = new
ProductViewHolder(view);
return holder;
}
};
recyclerView.setAd
apter(adapter);
adapter.startListening();
}
@Override
public void
onBackPressed() {
DrawerLayout
drawer = (DrawerLayout)
findViewById(R.id.drawer_layout
);
if (drawer.isDrawerOpen(GravityCompat.START)){
drawer.closeDrawer(GravityCompat.START);
}else {
super.onBackPressed();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it
is present.
// }
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull
MenuItem item) {
int id = item.getItemId();
if (id == R.id.nav_cart)
{
if (!type.equals("Admin"))
{
Intent intent = new Intent(HomeActivity.this, CartActivity.class);
startActivity(intent);
}
}
else if (id == R.id.nav_search)
{
if (!type.equals("Admin"))
{
Intent intent = new Intent(HomeActivity.this, SearchProductActivity.class);
startActivity(intent);
}
}
else if (id == R.id.categories)
{
}
else if (id == R.id.nav_settings)
{
if (!type.equals("Admin"))
{
Intent intent = new Intent(HomeActivity.this, SettingActivity.class);
startActivity(intent);
}
}
else if (id == R.id.logout)
{
if (!type.equals("Admin"))
{
Paper.book().destroy();
finish();
}
<ImageView
android:id="@+id/login_applogo"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"
android:src="@drawable/tbs" />
<EditText
android:id="@+id/register_username_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_applogo"
android:padding="20dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:hint="Name"
android:textColor="#FFDE03"
android:textColorHint="#FFDE03"
android:textSize="17sp"
android:textStyle="bold"
/>
<EditText
android:id="@+id/register_phone_number_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/register_username_input"
android:padding="20dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:hint="Phone Number"
android:inputType="number"
android:textColor="#FFDE03"
android:textColorHint="#FFDE03"
android:textSize="17sp"
android:textStyle="bold"
/>
<EditText
android:id="@+id/register_password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/register_phone_number_input"
android:padding="20dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="6dp"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#FFDE03"
android:textColorHint="#FFDE03"
android:textSize="17sp"
android:textStyle="bold"
/>
<Button
android:id="@+id/register_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/register_password_input"
android:layout_marginTop="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#B00020"
android:padding="17dp"
android:textSize="18sp"
android:textAllCaps="false"
android:text="Create
Account!"
android:textColor="@android:
color/darker_gray"
/>
</RelativeLayout>
RegisterActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
import android.app.ProgressDialog;
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
androidx.annotation.NonNull;
import
androidx.appcompat.app.AppCo
mpatActivity;
import
com.google.android.gms.tasks.O
nCompleteListener;
import
com.google.android.gms.tasks.Ta
sk;
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 com.teamstogether.twentyfourbysevenshopping.R;
import java.util.HashMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
createAccountBtn = (Button)
findViewById(R.id.register_btn);
InputName = (EditText) findViewById(R.id.register_username_input);
InputPhoneNumber = (EditText) findViewById(R.id.register_phone_number_input);
InputPassword= (EditText) findViewById(R.id.register_password_input); loadingBar
= new ProgressDialog(this);
createAccountBtn.setOnClickListener(new View.OnClickListener()
}
if(TextUtils.isEmpty(name))
{
Toast.makeText(this,"Please write your
name...",Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(phone))
{
Toast.makeText(this,"Please write your phone
number...",Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(password))
{
Toast.makeText(this, "Please write your password",
Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.setTitle("Create Account");
loadingBar.setMessage("Please wait, while we are checking the credentials");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
ValidatephoneNumber(name,phone,password);
}
}
RoofRef.addListenerForSingleValueEvent(new ValueEventListener()
{ @Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if(!(snapshot.child("Users").child(phone).exists()))
{ HashMap<String,Object> userdataMap = new
HashMap<>(); userdataMap.put("phone",phone);
userdataMap.put("password",password);
userdataMap.put("name",name);
RoofRef.child("Users").child(phone).updateChildren(userdataMap).addOnCompleteListener(new
OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Toast.makeText(RegisterActivity.this, "Congratulations, your account has been
created", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
Intent intent = new Intent(RegisterActivity.this,
LoginActivity.class); startActivity(intent);
}
else {
Toast.makeText(RegisterActivity.this,"Network Error: Please try again after
some time...",Toast.LENGTH_SHORT).show();
}
}
}
);
}
e
lse {
Toast.makeText(RegisterActivity.this, "This "+phone +" already exits",
Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
Toast.makeText(RegisterActivity.this, "Please try again later using another phone
number...", Toast.LENGTH_SHORT).show();
Intent intent = new
Intent(RegisterActivity.this,LoginActivity.class);
startActivity(intent);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
}
);
}
}
Login Activity Screenshot
activity_login.xml
Code
<?xml
version="1.0"
encoding="utf-
8"?>
<RelativeLayout
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/login"
tools:context=".Buyers.LoginActivity">
<ImageView
android:id="@+id/login_applogo"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"
android:src="@drawable/tbs" />
<EditText
android:id="@+id/login_phone_number_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_applogo"
android:padding="20dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:hint="Phone Number"
android:inputType="number"
android:textColor="@android:color/black"
android:textColorHint="@android:color/black"
android:textSize="17sp"
android:textStyle="bold"
/>
<EditText
android:id="@+id/login_password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_phone_number_input"
android:padding="20dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="6dp"
android:hint="Password"
android:inputType="textPassword"
android:textColor="@android:color/black"
android:textColorHint="@android:color/black"
android:textSize="17sp"
android:textStyle="bold"
/>
<LinearLayout
android:id="@+id/linear_layout_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/login_password_input"
android:layout_marginTop="5dp"
>
<com.rey.material.widget.CheckBox
android:id="@+id/remember_me_chkb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Material.Drawable.CheckBox"
android:text="Remember me"
android:textColor="@android:color/black"
app:cbd_strokeColor="@android:color/holo_green_light"
android:gravity="center_vertical"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginLeft="17dp"
/>
<TextView
android:id="@+id/forgot_password_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"
android:textColor="@android:color/black"
android:textSize="17sp"
android:textStyle="bold"
android:layout_marginLeft="80dp"
/>
</LinearLayout>
<Button
android:id="@+id/login_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_layout_1"
android:layout_marginTop="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#B00020"
android:padding="17dp"
android:textSize="18sp"
android:textAllCaps="false"
android:text="Login"
android:textColor="@andro
id:color/darker_gray"
/>
<TextView
android:id="@+id/admin_panel_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I'm an Admin?"
android:layout_alignParentEnd="true"
android:layout_below="@+id/login_btn"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginLeft="80dp"
android:layout_marginEnd="23dp"
/>
<TextView
android:id="@+id/not_admin_panel_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I'm not an Admin?"
android:layout_alignParentStart="true"
android:layout_below="@+id/login_btn"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginLeft="80dp"
android:layout_marginEnd="23dp"
android:layout_marginStart="25dp"
android:visibility="invisible"
/>
</RelativeLayout>
LoginActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
import android.app.ProgressDialog;
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.TextView;
import android.widget.Toast;
import
androidx.annotation.NonNull;
import
androidx.appcompat.app.AppCom
patActivity;
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 com.rey.material.widget.CheckBox;
import
com.teamstogether.twentyfourbysevenshopping.Admin.Ad
minHomeActivity;
import com.teamstogether.twentyfourbysevenshopping.Model.Users;
import com.teamstogether.twentyfourbysevenshopping.Prevalent.Prevalent;
import com.teamstogether.twentyfourbysevenshopping.R;
import io.paperdb.Paper;
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
LoginButton = (Button)
findViewById(R.id.login_btn);
NotAdminLink = (TextView) findViewById(R.id.not_admin_panel_link);
ForgetPasswordLink = (TextView) findViewById(R.id.forgot_password_link);
loadingBar = new ProgressDialog(this);
LoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginUser();
}
});
ForgetPasswordLink.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this, ResetPasswordActivity.class);
intent.putExtra("check","login");
startActivity(intent);
}
});
AdminLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{ LoginButton.setText("Login Admin");
AdminLink.setVisibility(View.INVISIBLE);
NotAdminLink.setVisibility(View.VISIBLE);
parentDbName = "Admins";
}
});
NotAdminLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{ LoginButton.setText("Login");
AdminLink.setVisibility(View.VISIBLE);
NotAdminLink.setVisibility(View.INVISIBLE);
parentDbName = "Users";
}
});
priv
ate
void
Logi
nUse
r() {
String phone = InputNumber.getText().toString(); String
password = InputPassword.getText().toString();
Toast.makeText(this, "Please write your phone number...", Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(password)){
Toast.makeText(this, "Please write your password...", Toast.LENGTH_SHORT).show();
}
else {
loadingBar.setTitle("Login Account");
loadingBar.setMessage("Please wait, while are checking the credentials...");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
AllowAccessToAccount(phone,password);
}
}
RootRef.addListenerForSingleValueEvent(new ValueEventListener()
{ @Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (snapshot.child(parentDbName).child(phone).exists())
{
Users usersData =
snapshot.child(parentDbName).child(phone).getValue(Users.cl
ass);
if (usersData.getPhone().equals(phone))
{
if (usersData.getPassword().equals(password))
{
if (parentDbName.equals("Admins")){
Toast.makeText(LoginActivity.this,
"Welcome Admin, you are logged in successfully",
Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
}
activity_admin_home.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".Admin.AdminHomeActivity">
<TextView
android:id="@+id/admin_welcome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome Dear Admin"
android:textAlignment="center"
android:textSize="17dp"
android:textColor="@color/colorPrimaryDark"
android:textStyle="bold"
android:layout_marginTop="10dp"
/>
<Button
android:id="@+id/maintain_btn"
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_below="@id/admin_welcome"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="25dp"
android:background="@color/colorPrimaryDark"
android:text="Maintain Products"
android:textColor="@android:color/white"
android:textSize="20dp"
android:textAllCaps="false"
/>
<Button
android:id="@+id/check_order_btn"
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_below="@id/maintain_btn"
android:layout_margin="20dp"
android:layout_marginRight="10dp"
android:background="@color/colorPrimaryDark"
android:text="Check New Orders"
android:textColor="@android:color/white"
android:textSize="20dp"
android:textAllCaps="false"
/>
<Button
android:id="@+id/check_approve_products_btn"
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_below="@id/check_order_btn"
android:layout_margin="20dp"
android:layout_marginRight="10dp"
android:background="@color/colorPrimaryDark"
android:text="Check and Approve New Products"
android:textColor="@android:color/white"
android:textSize="20dp"
android:textAllCaps="false"
/>
<Button
android:id="@+id/admin_logout_btn"
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="15dp"
android:background="@color/colorPrimaryDark"
android:text="Logout"
android:textColor="@android:color/white"
android:textSize="20dp"
android:textAllCaps="false"
/>
</RelativeLayout>
AdminHomeActivity.java
package com.teamstogether.twentyfourbysevenshopping.Admin;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import
androidx.appcompat.app.AppC
ompatActivity;
import com.teamstogether.twentyfourbysevenshopping.Buyers.HomeActivity;
import com.teamstogether.twentyfourbysevenshopping.Buyers.MainActivity;
import com.teamstogether.twentyfourbysevenshopping.R;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_home);
maintainProductsBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v)
{
Intent intent = new Intent(AdminHomeActivity.this, HomeActivity.class);
intent.putExtra("Admin", "Admin");
startActivity(intent);
}
});
LogoutBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AdminHomeActivity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
}
});
CheckOrdersBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AdminHomeActivity.this, AdminNewOrdersActivity.class);
startActivity(intent);
}
});
checkApproveProductsBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Intent intent = new Intent(AdminHomeActivity.this,
AdminCheckNewProductsActivity.class);
startActivi
ty(intent); finish();
}
}
);
}
}
activity_admin_check_new_products.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".Admin.AdminCheckNewProductsActivity">
<RelativeLayout
android:id="@+id/r3"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimaryDark"
android:layout_alignParentTop="true">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Approve New Products"
android:textColor="@android:color/white"
android:textSize="20dp"
android:textAlignment="center"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/admin_products_checklist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/r3"/>
</RelativeLayout>
AdminCheckNewProductActivity.java
package com.teamstogether.twentyfourbysevenshopping.Admin;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import
androidx.annotation.NonNull;
import
androidx.appcompat.app.AlertDial
og;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
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.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
import
com.teamstogether.twentyfourbysevenshopping.Model.Pr
oducts;
import com.teamstogether.twentyfourbysevenshopping.R;
import
com.teamstogether.twentyfourbysevenshopping.ViewHold
er.ProductViewHolder;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_check_new_products);
Log.i("NewProductActivity","Activity Created");
uProductsRef = FirebaseDatabase.getInstance().getReference().child("Products");
Log.i("NewProductActivity","Firebase Started");
recyclerView.setLayoutManager(layoutManager);
Toast.makeText(this,"Layout created",Toast.LENGTH_SHORT).show();
}
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerOptions<Products> options =
new FirebaseRecyclerOptions.Builder<Products>()
.setQuery(uProductsRef.orderByChild("productState").equalTo("Not Approved"),
Products.class)
.build();
holder.itemView.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v)
{
final String productID = products.getPid();
AlertDialog.Builder
builder = new
AlertDialog.Builder(AdminCheckNe
wProductsActivity.this);
builder.setTitle("Do you want to Approved this Product. Are you Sure?");
builder.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position)
{
if (position == 0)
{
ChangeProductState(productID);
}
if (position == 1)
{
}
}
});
bu
ild
er.
sh
o
w(
);
}
});
}
@NonNull
@Override
public
ProductVie
wHolder
onCreateVi
ewHolder(
@NonNull
ViewGrou
p parent,
int
viewType)
{
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.product_items_layout,
parent, false);
ProductViewHolder holder = new
ProductViewHolder(view);
return holder;
}
};
recyclerView.setAd
apter(adapter);
adapter.startListening();
}
private void
ChangeProductState(String
productID)
{
uProductsRef.child
(productID)
.
activity_admin_maintain_products
Code
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
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="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="5dp"
app:cardElevation="15dp"
tools:context=".Admin.AdminMaintainProductsActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/product_image_maintain"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="@+id/product_name"
android:scaleType="centerCrop"
android:layout_marginTop="2dp"
/>
<EditText
android:id="@+id/product_name_maintain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/product_image_maintain"
android:hint="Product Price"
android:textAlignment="center"
android:textSize="18dp"
android:padding="12dp"
android:layout_margin="5dp"
android:textColor="@color/colorPrimaryDark"/>
<EditText
android:id="@+id/product_price_maintain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/product_name_maintain"
android:hint="Product Price"
android:textAlignment="center"
android:textSize="18dp"
android:padding="12dp"
android:layout_margin="5dp"
android:textColor="@color/colorPrimaryDark"/>
<EditText
android:id="@+id/product_description_maintain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/product_price_maintain"
android:hint="Product Description"
android:layout_marginTop="2dp"
android:textAlignment="center"
android:textSize="16dp"
android:padding="12dp"
android:layout_margin="5dp"
android:textColor="@color/colorPrimary"
/>
<Button
android:id="@+id/apply_changes_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/product_description_maintain"
android:text="Apply Changes"
android:layout_marginTop="2dp"
android:textAlignment="center"
android:textSize="18dp"
android:padding="12dp"
android:layout_margin="5dp"
android:background="@android:color/holo_purple"
android:textColor="@android:color/white"
/>
<Button
android:id="@+id/delete_product_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/apply_changes_btn"
android:text="Delete This Product"
android:textAlignment="center"
android:textSize="18dp"
android:padding="12dp"
android:layout_margin="30dp"
android:background="@android:color/holo_purple"
android:textColor="@android:color/white"
/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
AdminMaintainProductActivity.java
package com.teamstogether.twentyfourbysevenshopping.Admin;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import
android.widget.ImageView;
import android.widget.Toast;
import
androidx.annotation.NonNull;
import
androidx.appcompat.app.AppCo
mpatActivity;
import
com.google.android.gms.tasks.O
nCompleteListener;
import
com.google.android.gms.tasks.Ta
sk;
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 com.squareup.picasso.Picasso;
import com.teamstogether.twentyfourbysevenshopping.R;
import
com.teamstogether.twentyfourbysevenshopping.Sellers.Sel
lerProductCategoryActivity;
import java.util.HashMap;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_maintain_products);
price = findViewById(R.id.product_price_maintain);
description = findViewById(R.id.product_description_maintain);
imageView = findViewById(R.id.product_image_maintain);
deleteBtn = findViewById(R.id.delete_product_btn);
displaySpecificProductInfo();
applyChangesBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
applyChanges();
}
});
deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
deleteThisProduct();
}
});
}
p
rivat
e
void
appl
yCha
nges(
){
String pName =
name.getText().toString(); String pPrice =
price.getText().toString();
else if(pPrice.equals(" ")){
Toast.makeText(this, "Write down Product Price", Toast.LENGTH_SHORT).show();
}
else if(pDescription.equals(" ")){
Toast.makeText(this, "Write down Product Description", Toast.LENGTH_SHORT).show();
}
else{
HashMap<String,Object> productMap = new HashMap<>();
productMap.put("pid",productId);
productMap.put("description",pDescription);
productMap.put("price",pPrice);
productMap.put("pname",pName);
productsRef.updateChildren(productMap).addOnCompleteL
istener(new
OnCompleteListener<Void>() {
@Override
public void
onComplete(@NonN
ull Task<Void> task)
{
if(task.isSuccessful()) {
Toast.makeText(AdminMaintainProductsActivity.this, "Changes applied
successfully.", Toast.LENGTH_SHORT)
.show();
p
rivate
void
display
Specifi
cProdu
ctInfo()
{
productsRef.addValueEventListener(new ValueEventListener()
{ @Override
public void onDataChange(@NonNull DataSnapshot snapshot)
{
if (snapshot.exists())
{
Picasso.get().load(pImage).into(imageView);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
}
activity_admin_new_orders.xml
activity_admin_new_orders.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".Admin.AdminNewOrdersActivity">
<RelativeLayout
android:id="@+id/r2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimaryDark"
android:layout_alignParentTop="true">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="New Orders"
android:textColor="@android:color/white"
android:textSize="25dp"
android:textAlignment="center"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/orders_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/r2"
>
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
AdminNewOrderActivity.java
package com.teamstogether.twentyfourbysevenshopping.Admin;
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
androidx.annotation.NonNull;
import
androidx.appcompat.app.AlertDial
og;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import
com.teamstogether.twentyfourbysevenshopping.Model.Ad
minOrders;
import com.teamstogether.twentyfourbysevenshopping.R;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_new_orders);
ordersRef =
FirebaseDatabase.getInstance().getReference().child("O
rders");
orderList = findViewById(R.id.orders_list);
orderList.setLayoutManager(new
LinearLayoutManager(this));
}
@Override
.setQuery(ordersRef, AdminOrders.class)
.build();
adminOrdersViewHolder.ShowOrdersBtn.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v)
{
String uID = getRef(i).getKey();
adminOrdersViewHolder.itemView.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
CharSequence options[] = new CharSequence[]
{
"Yes",
"No"
};
RemoverOrder(uID);
} else {
finish();
}
}
});
bu
ild
er.
sh
o
w(
);
}
});
}
@NonNull
@Override
public
AdminOrd
ersViewHo
lder
onCreateVi
ewHolder(
@NonNull
ViewGrou
p parent,
int
viewType)
{
View
view =
LayoutI
nflater.fr
om(pare
nt.getCo
ntext()).i
nflate(R.
layout.o
rders_la
yout,
parent , false);
return
new
AdminO
rdersVie
wHolder
private void RemoverOrder(String uID)
{
ordersRef.child(uID).removeValue();
}
}
activity_admin_user_products.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".Admin.AdminUserProductsActivity">
<RelativeLayout
android:id="@+id/r3"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimaryDark"
android:layout_alignParentTop="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Products"
android:textColor="@android:color/white"
android:textSize="25dp"
android:textAlignment="center"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/products_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/r3"
>
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
AdminUserProductsActivity.java
package com.teamstogether.twentyfourbysevenshopping.Admin;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import
com.teamstogether.twentyfourbysevenshopping.Model.Cart
;
import com.teamstogether.twentyfourbysevenshopping.R;
import
com.teamstogether.twentyfourbysevenshopping.ViewHolde
r.CartViewHolder;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_user_products);
userID = getIntent().getStringExtra("uid");
productsList = findViewById(R.id.products_list);
productsList.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
productsList.setLayoutManager(layoutManager);
cartListRef =
FirebaseDatabase.getInstance().getReference()
.child("Cart List").child("Admin
View").child(userID).child("Products");
protected void onStart() {
super.onStart();
FirebaseRecyclerOptions<Cart> options =
new FirebaseRecyclerOptions.Builder<Cart>()
.setQuery(cartListRef, Cart.class)
.build();
@
NonNull
@Override
pu
blic
CartViewH
older
onCreateVi
ewHolder(
@NonNull
ViewGrou
p parent,
int
viewType)
{
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cart_items_layout,
parent, false);
CartViewHolder holder = new CartViewHolder(view);
return holder;
}
};
productsList.setAdapter
(adapter); adapter.startListening();
}
}
activity_cart.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".Buyers.CartActivity">
<RelativeLayout
android:id="@+id/r111"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimaryDark"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/total_price"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Total Price = "
android:textColor="@android:color/white"
android:textSize="20dp"
android:textAlignment="center"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
<TextView
android:id="@+id/msg1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimaryDark"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:textAlignment="center"
android:layout_centerVertical="true"
android:text="Congratulations, your oder has been placed successfully. Soon it will be
verified."
android:textSize="20
dp"
android:visibility="gone"
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/cart_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/r111"
android:layout_above="@+id/next_btn"
>
</androidx.recyclerview.widget.RecyclerVi
ew>
<Button
android:id="@+id/codBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/next_btn"
android:background="@color/colorPrimary"
android:text="Cash on Delivery" />
<Button
android:id="@+id/next_btn"
android:layout_width="match_
parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimaryDark"
android:text="Next/RazorPay"
android:textColor="@android:color/white"
android:textSize="20dp"
/>
</RelativeLayout>
CartActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
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
androidx.annotation.NonNull;
import
androidx.appcompat.app.AlertDial
og;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
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.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 com.razorpay.Checkout;
import com.razorpay.PaymentResultListener;
import
com.teamstogether.twentyfourbysevenshopping.Model.Car
t;
import
com.teamstogether.twentyfourbysevenshopping.Prevalent.
Prevalent;
import com.teamstogether.twentyfourbysevenshopping.R;
import
com.teamstogether.twentyfourbysevenshopping.ViewHold
er.CartViewHolder;
import org.json.JSONException;
import org.json.JSONObject;
codBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(CartActivity.this,ConfirmFinalOrderActivity.class);
startActivity(intent);
finish();
recyclerView = findViewById(R.id.cart_list);
recyclerView.setHasFixedSize(true);
layoutManager= new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
NextProcessBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v)
{
txtTotalAmount.setText("Total Price = " +
String.valueOf(overTotalPrice));
checkout.setKeyID("rzp_test_VVG3ldpytJffar");
checkout.setImage(R.drawable.razorpay_logo);
@Over
ride
protect
ed
void
onSt
art()
{
supe
r.
on
St
art
();
Chec
k
Or
de
rS
tat
e()
;
FirebaseRecyclerOptions<Cart> options =
new FirebaseRecyclerOptions.Builder<Cart>()
.setQuery(cartListRef.child("User View")
.child(Prevalent.currentOnlineUser.getPhone()).child("Products"), Cart.class)
.build();
@No
nNul
l
@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);
return holder;
}
};
recyclerView.setAdapter(adapter);
adapter.startListening();
}
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 oder has been shipped successfully. Soon
you will received your order at your door step.");
NextProcessBtn.setVisibility(View.GONE);
Toast.makeText(CartActivity.this,
"you can purchase more products, once you received your first order.",
Toast.LENGTH_SHORT).show();
} else if (shippingState.equals("not shipped"))
{
txtTotalAmount.setText("Shipping
Sate = Not Shipped");
recyclerView.setVisibility(View.GONE);
txtMsg1.setVisibility(
View.VISIBLE);
Toast.makeText(CartActivity.this,
"you can purchase more products, once you received your first order.",
Toast.LENGTH_SHORT).show();
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
}
);
}
@
Overrid
e
p
ublic
void
onPay
mentSu
ccess(S
tring s)
{
AlertDialog.Builder builder = new
AlertDialog.Builder(this); builder.setTitle("Payment ID");
builder.setMessage(s);
}
@Override
public void onPaymentError(int i, String
s) {
Toast.makeText(getApplicationContext(
), s, Toast.LENGTH_SHORT).show();
}
}
activity_confirm_final_order.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".Buyers.ConfirmFinalOrderActivity">
<TextView
android:id="@+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please confirm your shipment details"
android:textSize="18dp"
android:textColor="@color/colorPrimaryDark"
android:layout_margin="25dp"
android:textAlignment="center"
android:textStyle="bold"
/>
<EditText
android:id="@+id/shipment_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txt"
android:layout_marginTop="60dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Your Name"
/>
<EditText
android:id="@+id/shipment_phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/shipment_name"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp"
android:inputType="number"
android:layout_marginRight="20dp"
android:hint="Your Phone Number"
/>
<EditText
android:id="@+id/shipment_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/shipment_phone_number"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" android:hint="Your
Home Address"
/>
<EditText
android:id="@+id/shipment_city"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/shipment_address"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Your City Name"
/>
<Button
android:id="@+id/confirm_final_order_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="20dp"
android:text="Confirm"
android:background="@android:color/holo_orange_dark"
android:textColor="@android:color/white"
android:textSize="20dp"
/>
</RelativeLayout>
ConfirmFinalOrderActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
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
androidx.annotation.NonNull;
import
androidx.appcompat.app.AppCo
mpatActivity;
import
com.google.android.gms.tasks.O
nCompleteListener;
import
com.google.android.gms.tasks.Ta
sk;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.razorpay.Checkout;
import
com.teamstogether.twentyfourbysevenshopping.Prevalent.
Prevalent;
import com.teamstogether.twentyfourbysevenshopping.R;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_confirm_final_order);
Checkout.preload(getApplicationContext());
totalAmount = getIntent().getStringExtra("Total
Price");
Toast.makeText(this, "Total Price = ₹" + totalAmount,
confirmOrderBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Check();
}
});
}
}
}
activity_product_details.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".Buyers.ProductDetailsActivity">
<ImageView
android:id="@+id/product_image_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
/>
<TextView
android:id="@+id/product_name_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/product_image_details"
android:text="Product Name"
android:textColor="@android:color/black"
android:textStyle="bold"
android:textSize="18sp"
android:gravity="center"
android:layout_marginTop="10dp"
/>
<TextView
android:id="@+id/product_description_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/product_name_details"
android:text="Product Description"
android:textColor="@android:color/black"
android:textStyle="bold"
android:textSize="18sp"
android:gravity="center"
android:layout_marginTop="10dp"
/>
<TextView
android:id="@+id/product_price_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/product_description_details"
android:text="Product Price"
android:textColor="@android:color/black"
android:textStyle="bold"
android:textSize="15dp"
android:gravity="center"
android:layout_marginTop="10dp"
/>
<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton
android:id="@+id/number_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="6dp"
app:textSize="16dp"
app:initialNumber="1"
app:finalNumber="10"
android:layout_centerHorizontal="true"
android:layout_below="@id/product_price_details"
android:layout_marginTop="10dp"
/>
<Button
android:id="@+id/pd_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:layout_margin="15dp"
android:layout_alignParentBottom="true"
android:text="Add to cart"
android:textColor="@android:color/white"
android:textSize="18dp"
/>
</RelativeLayout>
ProductDetailActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import
androidx.annotation.NonNull;
import
androidx.appcompat.app.AppComp
atActivity;
import
com.cepheuen.elegantnumberbutton
.view.ElegantNumberButton;
import
com.google.android.gms.tasks.OnC
ompleteListener;
import
com.google.android.gms.tasks.Task;
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 com.squareup.picasso.Picasso;
import com.teamstogether.twentyfourbysevenshopping.Model.Products;
import com.teamstogether.twentyfourbysevenshopping.Prevalent.Prevalent;
import com.teamstogether.twentyfourbysevenshopping.R;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
numberButton = (ElegantNumberButton) findViewById(R.id.number_btn);
productImage = (ImageView) findViewById(R.id.product_image_details);
productName = (TextView) findViewById(R.id.product_name_details);
productDescription = (TextView) findViewById(R.id.product_description_details);
productPrice = (TextView) findViewById(R.id.product_price_details);
getProductDetails(productId);
addToCartButton.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
addingToCartList();
if (state.equals("Order
Placed") ||
state.equals("Order
Shipped"))
{
Toast.makeText(ProductDetailsActivity.this, "you can add purchase more products, once
your order is shipped or confirmed.", Toast.LENGTH_LONG).show();
}
else {
addingToCartList();
}
}
}
);
}
@
Over
ride
p
rotec
ted
void
onSt
art()
{
s
up
er.
on
St
art
();
C
he
ck
Or
de
rS
cartMap.put("price", productPrice.getText().toString());
cartMap.put("date", saveCurrentDate);
cartMap.put("time", saveCurrentTime);
cartMap.put("quantity", numberButton.getNumber());
cartMap.put("discount", "");
cartListRef.child("User
View").child(Prevalent.currentOnlineUser.getPhone())
.child("Products").child(productId)
.updateChildren(cartMap)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful())
{
cartListRef.child("Admin
View").child(Prevalent.currentOnlineUser.getPhone())
.child("Products").child(productId)
.updateChildren(cartMap)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task)
{
if (task.isSuccessful())
{
Toast.makeText(ProductDetailsActivity.this, "Add to Cart List.",
Toast.LENGTH_SHORT).show();
private void
getProduc
tDetails(S
tring
productId
)
{
DatabaseReference productsRef =
FirebaseDatabase.getInstance().getReference().child("Products");
productsRef.child(productId).addValueEventListener(new ValueEventListener()
{ @Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
productName.setText(products.getPname());
productPrice.setText(products.getPrice());
productDescription.setText(products.getDescription());
Picasso.get().load(products.getImage()).into(productImage);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
priv
ate
void
Chec
kOrd
erSta
te()
{
DatabaseReference ordersRef;
ordersRef =
FirebaseDatabase.getInstance().getReference().child("Orders").child(Prevalent.currentOnlineUser.get
Phone());
ordersRef.addValueEventListener(new ValueEventListener()
{ @Override
public void onDataChange(@NonNull DataSnapshot snapshot)
{
if (snapshot.exists())
{
String shippingState =
snapshot.child("state").getValue().toString();
if (shippingState.equals("shipped"))
{
state = "Order shipped";
} else if (shippingState.equals("not shipped"))
{
state = "Order Placed";
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
activity_reset_password.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".Buyers.ResetPasswordActivity">
<RelativeLayout
android:id="@+id/relative123"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimaryDark"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/page_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Reset Password "
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
<EditText
android:id="@+id/find_phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:textColorHint="@android:color/white"
android:padding="14dp"
android:layout_margin="15dp"
android:layout_below="@id/relative123"
android:hint="Please write your phone number..."
/>
<TextView
android:id="@+id/title_questions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Answer the Following Secuirty Questions?"
android:gravity="center"
android:textSize="26dp"
android:layout_marginTop="35dp"
android:layout_below="@id/find_phone_number"
/>
<EditText
android:id="@+id/question_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:textColorHint="@android:color/white"
android:padding="14dp"
android:layout_margin="15dp"
android:layout_below="@id/title_questions"
android:hint="Where your parents met, first time?"
/>
<EditText
android:id="@+id/question_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:textColorHint="@android:color/white"
android:padding="14dp"
android:layout_margin="15dp"
android:layout_below="@id/question_1"
android:hint="Whats your favourite super hero?"
/>
<Button
android:id="@+id/verify_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:padding="14dp"
android:layout_margin="15dp"
android:layout_below="@id/question_2"
android:text="Verify"
android:textColor="@android:color/white"
android:textStyle="bold"
android:textSize="20dp"
/>
</RelativeLayout>
ResetPasswordActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import
androidx.annotation.NonNull;
import
androidx.appcompat.app.AlertDial
og;
import
androidx.appcompat.app.AppCom
patActivity;
import
com.google.android.gms.tasks.On
CompleteListener;
import
com.google.android.gms.tasks.Tas
k;
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
com.teamstogether.twentyfourbysevenshopping.Prevalent.
Prevalent;
import com.teamstogether.twentyfourbysevenshopping.R;
import java.util.HashMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reset_password);
}
@Override
protected void onStart() {
super.onStart();
phoneNumber.setVisibility(View.GONE);
if (check.equals("settings"))
{
pageTitle .setText("Set Questions");
titleQuestions.setText("Please set Answers for the following security Questions?");
verifyButton.setText("Set");
displayPreviousAnswers();
verifyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
setAnswers();
}
});
}
else if
(che
ck.e
quals
("lo
gin"
))
{
pho
ne
N
u
m
be
r.s
et
Vi
si
bil
ity
(V
ie
w.
VI
SI
B
L
else {
DatabaseReference ref = FirebaseDatabase.getInstance()
.getReference()
.child("Users")
.child(Prevalent.currentOnlineUser.getPhone());
ref.child("Security
Questions").updateChildren(userdataMap).addOnCompleteLi
stener(new
OnCompleteListener<Void>() {
@Override
public void
onComplete(@NonN
ull Task<Void> task)
{
if (task.isSuccessful())
{
Toast.makeText(ResetPasswordActivity.this, "you have set security questions
successfully.",
Toast.LENGTH_SHORT).show();
p
rivate
void
display
Previou
sAnswe
rs()
{
D
ataba
seRe
feren
ce
ref =
Fireb
aseD
ataba
se.ge
tInst
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
priv
ate
void
verif
yUse
r()
{
fi
na
l
St
rin
g
ph
on
e
=
ph
on
eN
u
m
be
r.
ge
tT
ex
t()
.to
St
rin
g()
;
final String answer1 = question1.getText().toString().toLowerCase();
final String answer2 = question2.getText().toString().toLowerCase();
ref.addValueEventListener(new ValueEventListener()
AlertDialog.Builder(ResetPasswordActivity.this);
builder.setTitle("New Password");
build
er.
sh
o
w(
);
}
}
else
{
Toast.makeText(ResetPasswordActivity.this, "you have not set the security
questions.", Toast.LENGTH_SHORT).show();
}
}
Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
else
{
To
ast
.m
ak
eT
ext
(t
hi
s,
"p
le
as
e
co
m
pl
et
e
th
e
fo
r
m.
",
To
ast
.L
E
N
G
T
H
_S
H
O
R
T)
.sh
o
w(
);
activity_search_product.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".Buyers.SearchProductActivity">
<RelativeLayout
android:id="@+id/r5"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/colorPrimaryDark"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<com.rey.material.widget.EditText
android:id="@+id/search_product_name"
android:layout_width="290dp"
android:layout_height="wrap_content"
android:hint="Product Name"
android:textSize="18dp"
android:textStyle="bold"
android:background="@android:color/white"
android:padding="9dp"
android:layout_marginStart="5dp"
android:layout_centerVertical="true"
android:textColorHint="@color/colorPrimaryD
ark"
/>
<Button
android:id="@+id/search_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search"
android:textColor="@android:color/white"
android:textSize="16dp"
android:textStyle="bold"
android:padding="9dp"
android:layout_centerInParent="true"
android:background="@color/colorPrimaryDark"
android:layout_toRightOf="@+id/search_product_name"/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/search_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/r5">
</androidx.recyclerview.widget.Recycler
View>
</RelativeLayout>
SearchProductActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
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
androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.rey.material.widget.EditText;
import com.squareup.picasso.Picasso;
import
com.teamstogether.twentyfourbysevenshopping.Model.Pro
ducts;
import com.teamstogether.twentyfourbysevenshopping.R;
import
com.teamstogether.twentyfourbysevenshopping.ViewHolde
r.ProductViewHolder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_product);
inputText = findViewById(R.id.search_product_name);
SearchBtn = (Button) findViewById(R.id.search_btn);
searchList = findViewById(R.id.search_list);
searchList.setLayoutManager(new
LinearLayoutManager(SearchProductActivity.this));
SearchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
@Ov
errid
e
prot
ecte
d
void
onSt
art()
{
su
pe
r.
on
St
art
();
holder.itemView.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Intent intent = new Intent(SearchProductActivity.this,
ProductDetailsActivity.class);
intent.putExtra("pid
",products.getPid());
startActivity(intent);
}
}
);
}
};
searchList.setAdapter(adapter);
adapter.startListening();
}
}
activity_setting.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".Buyers.SettingActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_settings"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimaryDark">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/close_settings_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Close"
android:textColor="@android:color/white"
android:textSize="17sp"
android:textStyle="bold"
android:layout_alignParentStart="true"/>
<TextView
android:id="@+id/update_account_settings_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Update"
android:textColor="@android:color/white"
android:textSize="17sp"
android:textStyle="bold"
android:layout_marginRight="10dp"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/settings_profile_image"
android:layout_width="130dp"
android:layout_height="130dp"
android:src="@drawable/profile"
android:layout_below="@+id/app_bar_settings"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/profile_image_change_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Profile"
android:textSize="17sp"
android:textStyle="bold"
android:layout_marginRight="10dp"
android:layout_marginTop="4dp"
android:textColor="@android:color/black"
android:layout_below="@+id/settings_profile_image"
android:layout_centerHorizontal="true"/>
<EditText
android:id="@+id/settings_phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/profile_image_change_btn"
android:hint="Phone Number..."
android:layout_margin="15dp"
android:padding="10dp"
/>
<EditText
android:id="@+id/settings_full_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_phone_number"
android:hint="Full Name..."
android:layout_margin="15dp"
android:padding="10dp"
/>
<EditText
android:id="@+id/settings_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_full_name"
android:hint="Address"
android:layout_margin="15dp"
android:padding="10dp"
/>
<Button
android:id="@+id/security_questions_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_address"
android:text="Set Security Questions"
android:background="@color/colorPrimaryDark"
android:textColor="@android:color/white"
android:layout_margin="15dp"
android:padding="10dp"
/>
</RelativeLayout>
SettingActivity.java
package com.teamstogether.twentyfourbysevenshopping.Buyers;
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.TextView;
import android.widget.Toast;
import
androidx.annotation.NonNull;
import
androidx.annotation.Nullable;
import
androidx.appcompat.app.AppCom
patActivity;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
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 com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.StorageTask;
import com.squareup.picasso.Picasso;
import
com.teamstogether.twentyfourbysevenshopping.Prevalent.
Prevalent;
import com.teamstogether.twentyfourbysevenshopping.R;
import com.theartofdev.edmodo.cropper.CropImage;
import java.util.HashMap;
import de.hdodenhof.circleimageview.CircleImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
profileImageView = (CircleImageView) findViewById(R.id.settings_profile_image);
fullNameEditText = (EditText) findViewById(R.id.settings_full_name);
userPhoneEditText = (EditText) findViewById(R.id.settings_phone_number);
addressEditText = (EditText) findViewById(R.id.settings_address);
profileChangeTextBtn = (TextView) findViewById(R.id.profile_image_change_btn);
closeTextBtn = (TextView) findViewById(R.id.close_settings_btn);
saveTextButton = (TextView) findViewById(R.id.update_account_settings_btn);
securityQuestionBtn = findViewById(R.id.security_questions_btn);
closeTextBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
securityQuestionBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Intent intent = new Intent(SettingActivity.this, ResetPasswordActivity.class);
intent.putExtra("check","settings");
startActivity(intent);
}
});
saveTextButton.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
if (checker.equals("clicked"))
{
userInfoSaved();
}
else
{
updateOnlyUserInfo();
}
}
});
profileChangeTextBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
checker = "clicked";
CropImage.activity(imageUri)
.setAspectRatio(1,1)
.start(SettingActivity.this);
}
});
}
priv
ate
void
upda
teOn
lyUs
erInf
o() {
userMap.put("name", fullNameEditText.getText().toString());
userMap.put("address", addressEditText.getText().toString());
userMap.put("phoneOrder", userPhoneEditText.getText().toString());
ref.child(Prevalent.currentOnlineUser.getPhone()).updateChildren(userMap);
finish();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
profileImageView.setImageURI(imageUri);
}
else
{
Toast.makeText(this, "Error, Try Again", Toast.LENGTH_SHORT).show();
startActivity(new
Intent(SettingActivity.this,SettingActivity.class)); finish();
}
}
if (imageUri != null)
{
final StorageReference fileRef = storageProfilePictureRef
.child(Prevalent.currentOnlineUser.getPhone() + ".jpg");
uploadTask = fileRef.putFile(imageUri);
uploadTask.continueWithTask(new Continuation() {
@Override
public Object then(@NonNull Task task) throws
Exception
{
if (!task.isSuccessful())
{
throw task.getException();
}
return fileRef.getDownloadUrl();
}
})
.addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful())
{
Uri downloadUri = task.getResult();
myUrl = downloadUri.toString();
progressDialog.dismiss();
startActivity(new Intent(SettingActivity.this,HomeActivity.class));
Toast.makeText(SettingActivity.this,
"Profile Info update successfully",
Toast.LENGTH_SHORT).show();
finish();
}
else
{
progressDialog.dismiss();
Toast.makeText(SettingActivity.this, "Error.",
Toast.LENGTH_SHORT).show();
}
}
});
}
else {
Toast
.m
ak
eT
ext
(t
private void userInfoDisplay(final CircleImageView profileImageView, final EditText fullNameEditText,
final EditText userPhoneEditText, final EditText addressEditText)
{
DatabaseReference UsersRef =
FirebaseDatabase.getInstance().getReference().child("Users").child(Prevalent.currentOnlineUser.getPhone());
UsersRef.addValueEventListener(new ValueEventListener()
{ @Override
public void onDataChange(@NonNull DataSnapshot
snapshot) {
if (snapshot.exists())
{
if (snapshot.child("image").exists())
{
String image= snapshot.child("image").getValue().toString(); String
name = snapshot.child("name").getValue().toString(); String
phone = snapshot.child("phone").getValue().toString(); String
address = snapshot.child("address").getValue().toString();
Picasso.get().load(image).into(profileImageView);
fullNameEditText.setText(name);
userPhoneEditText.setText(phone);
addressEditText.setText(address);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
}
activity_seller_registration.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".Sellers.SellerRegistrationActivity">
<ImageView
android:id="@+id/img_seller"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:src="@drawable/seller"
android:scaleType="centerCrop"
/>
<TextView
android:id="@+id/title_seller"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Seller Registration Form"
android:gravity="center"
android:layout_below="@+id/img_seller"
android:layout_marginTop="30dp"
android:textStyle="bold"
android:textSize="24dp"
android:textColor="@android:color/holo_gr
een_dark"
/>
<EditText
android:id="@+id/seller_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_below="@+id/title_seller"
android:hint="Name..."
android:inputType="text"
android:textSize="16dp"
android:layout_marginTop="10dp"
/>
<EditText
android:id="@+id/seller_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_below="@+id/seller_name"
android:hint="Phone..."
android:inputType="number"
android:textSize="16dp"
android:layout_marginTop="10dp"
/>
<EditText
android:id="@+id/seller_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_below="@+id/seller_phone"
android:hint="Email..."
android:inputType="textEmailAddress"
android:textSize="16dp"
android:layout_marginTop="10dp"
/>
<EditText
android:id="@+id/seller_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_below="@+id/seller_email"
android:hint="Password..."
android:inputType="textPassword"
android:textSize="16dp"
android:layout_marginTop="10dp"
/>
<EditText
android:id="@+id/seller_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_below="@+id/seller_password"
android:hint="Shop - Business Address..."
android:inputType="text"
android:textSize="16dp"
android:layout_marginTop="10dp"
/>
<Button
android:id="@+id/seller_register_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:layout_below="@+id/seller_address"
android:background="@android:color/white"
android:text="Register"
android:textAllCaps="false"
android:textSize="18dp"
/>
<Button
android:id="@+id/seller_already_have_account_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:background="@android:color/holo_green_dark"
android:text="Already have an Account?"
android:textAllCaps="false"
android:textSize="18dp"
android:layout_alignParentBottom="true"
android:textColor="@android:color/white"
android:layout_marginBottom="15dp"
/>
</RelativeLayout>
SellerRegistrationActivity.java
package com.teamstogether.twentyfourbysevenshopping.Sellers;
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
androidx.annotation.NonNull;
import
androidx.appcompat.app.AppCo
mpatActivity;
import
com.google.android.gms.tasks.O
nCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.teamstogether.twentyfourbysevenshopping.R;
import java.util.HashMap;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seller_registration);
mAuth = FirebaseAuth.getInstance();
loadingBar = new ProgressDialog(this);
sellerLoginBegin =
findViewById(R.id.seller_already_have_account_btn)
;
registerButton = findViewById(R.id.seller_register_btn);
nameInput = findViewById(R.id.seller_name);
phoneInput = findViewById(R.id.seller_phone);
emailInput = findViewById(R.id.seller_email);
passwordInput = findViewById(R.id.seller_password);
addressInput = findViewById(R.id.seller_address);
sellerLoginBegin.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Intent intent = new Intent(SellerRegistrationActivity.this, SellerLoginActivity.class);
startActivity(intent);
}
public void onClick(View v) {
registerSeller();
}
});
}
mAuth.createUserWithEmailAndPassword(email,password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
if (task.isSuccessful())
{
final DatabaseReference rootRef;
rootRef = FirebaseDatabase.getInstance().getReference();
rootRef.child("Sellers").child(sid).up
dateChildren(sellerMap)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task)
{
loadingBar.dismiss();
Toast.makeText(SellerRegistrationActivity.this,
"You are Registered Successfully",
Toast.LENGTH_SHORT).show();
<ImageView
android:id="@+id/img_seller"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:src="@drawable/sellerlogin"
android:scaleType="centerCrop"
/>
<TextView
android:id="@+id/title_seller"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Seller Login Form"
android:gravity="center"
android:layout_below="@+id/img_seller"
android:layout_marginTop="50dp"
android:textStyle="bold"
android:textSize="24dp"
android:textColor="@android:color/holo_gr
een_dark"
/>
<EditText
android:id="@+id/seller_login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_below="@+id/title_seller"
android:hint="Email..."
android:inputType="textEmailAddress"
android:textSize="16dp"
android:layout_marginTop="10dp"
/>
<EditText
android:id="@+id/seller_login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_below="@+id/seller_login_email"
android:hint="Password..."
android:inputType="textPassword"
android:textSize="16dp"
android:layout_marginTop="10dp"
/>
<Button
android:id="@+id/seller_login_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="20dp"
android:layout_below="@+id/seller_login_password"
android:background="@android:color/holo_purple"
android:textColor="@android:color/holo_red_dark"
android:text="Login"
android:textAllCaps="false"
android:textSize="18dp"
/>
</RelativeLayout>
SellerLoginActivity.java
package com.teamstogether.twentyfourbysevenshopping.Sellers;
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
androidx.annotation.NonNull;
import
androidx.appcompat.app.AppCo
mpatActivity;
import
com.google.android.gms.tasks.O
nCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import
com.teamstogether.twentyfourbysevenshopping.
R;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seller_login);
mAuth = FirebaseAuth.getInstance();
emailInput = findViewById(R.id.seller_login_email);
passwordInput = findViewById(R.id.seller_login_password);
loginSellerBtn = findViewById(R.id.seller_login_btn);
loadingBar = new ProgressDialog(this);
loginSellerBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
loginSeller();
}
});
}
<RelativeLayout
android:id="@+id/re11"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimaryDark"
android:layout_alignParentTop="true">
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/seller_home_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/nav_view"
android:layout_below="@id/re11"
>
</androidx.recyclerview.widget.RecyclerView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:text="My All Products"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="18dp"
android:textStyle="bold" />
<!-- <fragment-->
<!-- android:id="@+id/nav_host_fragment"-->
<!-- android:name="androidx.navigation.fragm
<!-- ent.NavHostFragment"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- app:defaultNavHost="true"-->
<!-- app:layout_constraintBottom_toTopOf="@id/nav_view"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
app:navGraph="@navigation/mobile_navigation" />-->
</RelativeLayout>
SellerHomeActivity.java
package com.teamstogether.twentyfourbysevenshopping.Sellers;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
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 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.android.material.bottomnavigation.BottomNavig
ationView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
import com.teamstogether.twentyfourbysevenshopping.Buyers.MainActivity;
import com.teamstogether.twentyfourbysevenshopping.Model.Products;
import com.teamstogether.twentyfourbysevenshopping.R;
import
com.teamstogether.twentyfourbysevenshopping.ViewHolder.ItemViewHolder;
private
BottomNavigationView.OnNavigationItemSelectedLi
stener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem
item) {
switch (item.getItemId())
{
case R.id.navigation_home:
Intent intentHome = new Intent(SellerHomeActivity.this,SellerHomeActivity.class);
startActivity(intentHome);
return true;
case R.id.navigation_add:
Intent intentCate = new Intent(SellerHomeActivity.this, SellerProductCategoryActivity.class);
startActivity(intentCate);
return true;
Intent intentMain = new Intent(SellerHomeActivity.this, MainActivity.class);
intentMain.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intentMain);
finish();
return true;
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seller_home);
BottomNavigationView navView =
findViewById(R.id.nav_view);
mTextMessage = findViewById(R.id.message);
navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
unverifiedProductsRef =
FirebaseDatabase.getInstance().getReference().child("Products");
recyclerView = findViewById(R.id.seller_home_recyclerview);
recyclerView.setHasFixedSize(true); layoutManager
= new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerOptions<Products> options =
new
FirebaseRecyclerOptions.Builder<Products>()
.setQuery(unverifiedProductsRef.orderByChild("sid").equalTo(FirebaseAuth.getInstance().getCurrentUser().getUid()),
Products.class)
.build();
holder.itemView.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v)
{
final String productsID = products.getPid();
CharSequence options[] = new CharSequence[]
{
"Yes",
"No"
};
}
}
});
bu
ild
er.
sh
o
w(
);
}
});
}
@NonNull
@Override
public
ItemView
Holder
onCreateVi
ewHolder(
@NonNull
ViewGrou
p parent,
int
viewType)
{
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.seller_item_view, parent, false);
ItemViewHolder holder = new ItemViewHolder(view);
return holder;
}
};
recyclerView.setAdapter(adapter);
adapter.startListening();
}
<TextView
android:id="@+id/slogan_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:textAlignment="center"
android:text="Add new Product"
android:textSize="26sp"
android:textStyle="bold"
/>
<LinearLayout
android:id="@+id/linear_category_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/slogan_category"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="100dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<ImageView
android:id="@+id/t_shirts"
android:layout_width="161dp"
android:layout_height="80dp"
android:src="@drawable/tshirt" />
<ImageView
android:id="@+id/shirt"
android:layout_width="115dp"
android:layout_height="80dp"
android:src="@drawable/shirt" />
<ImageView
android:id="@+id/sweater"
android:layout_width="161dp"
android:layout_height="80dp"
android:src="@drawable/sweater" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear_category_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_category_layout"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/pant"
android:layout_width="151dp"
android:layout_height="80dp"
android:src="@drawable/pant" />
<ImageView
android:id="@+id/watch"
android:layout_width="122dp"
android:layout_height="80dp"
android:src="@drawable/watch" />
<ImageView
android:id="@+id/washing_machine"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:src="@drawable/washingmachine"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_category_layout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_category_layout2"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/laptop"
android:layout_width="152dp"
android:layout_height="80dp"
android:src="@drawable/laptop" />
<ImageView
android:id="@+id/smartphone"
android:layout_width="112dp"
android:layout_height="80dp"
android:src="@drawable/smartphones" />
<ImageView
android:id="@+id/gaming_console"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:src="@drawable/gaming_consol
e"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_category_layout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_category_layout3"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/shoes"
android:layout_width="152dp"
android:layout_height="80dp"
android:src="@drawable/shoes" />
<ImageView
android:id="@+id/led_tv"
android:layout_width="112dp"
android:layout_height="80dp"
android:src="@drawable/ledtv" />
<ImageView
android:id="@+id/jeans"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:src="@drawable/jeans"
/>
</LinearLayout>
</RelativeLayout>
SellerProductCategoryActivity.java
package com.teamstogether.twentyfourbysevenshopping.Sellers;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import
android.widget.ImageView;
import
androidx.appcompat.app.App
CompatActivity;
import
com.teamstogether.twentyfour
bysevenshopping.R;
public class
SellerProductCategoryActivity
extends AppCompatActivity {
private ImageView tshirts,shirts,sweater;
private ImageView pant,watch,washingmachine;
private ImageView
laptop,smartphone,gamingconsole;
private ImageView shoes,ledtv,jeans;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seller_product_category);
tshirts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","tshirts");
startActivity(intent);
}
});
shirts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","shirts");
startActivity(intent);
}
});
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","sweater");
startActivity(intent);
}
});
pant.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","pant");
startActivity(intent);
}
});
watch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","watch");
startActivity(intent);
}
});
washingmachine.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","Washing Machine");
startActivity(intent);
}
});
laptop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","laptop");
startActivity(intent);
}
});
smartphone.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","smartphone");
startActivity(intent);
}
});
gamingconsole.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","Gaming Console");
startActivity(intent);
}
});
shoes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","shoes");
startActivity(intent);
}
});
ledtv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","Led TV");
startActivity(intent);
}
});
jeans.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SellerProductCategoryActivity.this, SellerAddNewProductActivity.class);
intent.putExtra("category","jeans");
startActivity(intent);
}
});
}
}
activity_seller_add_new_product.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="@color/colorPrimaryDark"
tools:context=".Sellers.SellerAddNewProductActivity">
<ImageView
android:id="@+id/select_product_image"
android:layout_width="350dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:cropToPadding="false"
android:scaleType="centerCrop"
android:src="@drawable/select_product_image" />
<EditText
android:id="@+id/product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/select_product_image"
android:layout_marginLeft="45dp"
android:layout_marginTop="20dp"
android:layout_marginRight="45dp"
android:background="@android:color/transparent"
android:textColor="@android:color/black"
android:textStyle="bold"
android:hint="Product Name..."
android:inputType="textMultiLine"
android:padding="20dp" />
<EditText
android:id="@+id/product_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/product_name"
android:layout_marginLeft="45dp"
android:layout_marginTop="6dp"
android:layout_marginRight="45dp"
android:background="@android:color/transparent"
android:textColor="@android:color/black"
android:textStyle="bold"
android:hint="Product Description..."
android:inputType="textMultiLine"
android:padding="20dp" />
<EditText
android:id="@+id/product_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/product_description"
android:layout_marginLeft="45dp"
android:layout_marginTop="6dp"
android:layout_marginRight="45dp"
android:background="@android:color/transparent"
android:textColor="@android:color/black"
android:textStyle="bold"
android:hint="Product Price..."
android:inputType="textMultiLine"
android:padding="20dp" />
<Button
android:id="@+id/add_new_product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/product_price"
android:layout_marginLeft="45dp"
android:layout_marginTop="20dp"
android:layout_marginRight="45dp"
android:padding="17dp"
android:text="Add Product"
android:textStyle="bold"
android:background="@android:color/transparent"
android:textColor="@android:color/black"
/>
</RelativeLayout>
SellerAddNewProductActivity.java
package com.teamstogether.twentyfourbysevenshopping.Sellers;
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
androidx.annotation.NonNull;
import
androidx.annotation.Nullable;
import
androidx.appcompat.app.AppCo
mpatActivity;
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.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 com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import com.teamstogether.twentyfourbysevenshopping.R;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seller_add_new_product);
CategoryName = getIntent().getExtras().get("category").toString();
ProductImageRef = FirebaseStorage.getInstance().getReference().child("Product Images");
ProductRef = FirebaseDatabase.getInstance().getReference().child("Products");
sellersRef = FirebaseDatabase.getInstance().getReference().child("Sellers");
InputProductImage.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View view) {
OpenGallery();
}
});
AddNewProductButton.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View view) {
ValidateProductData();
}
});
sellersRef.child(FirebaseAuth.getInstan
ce().getCurrentUser().getUid())
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot
snapshot)
{
if (snapshot.exists())
{
sName = snapshot.child("name").getValue().toString();
sAddress = snapshot.child("address").getValue().toString();
sPhone = snapshot.child("phone").getValue().toString();
sID = snapshot.child("sid").getValue().toString();
sEmail = snapshot.child("email").getValue().toString();
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
private
void
OpenGall
ery() {
Intent galleryIntent = new Intent();
galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("image/*");
startActivityForResult(galleryIntent,GalleryPick);
}
@Override
protected void onActivityResult(int requestCode, int
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == GalleryPick && resultCode == RESULT_OK && data != null) {
ImageUri = data.getData();
InputProductImage.setImageURI(ImageUri);
}
}
if(ImageUri == null)
{
Toast.makeText(this, "Product image is mandatory...",
Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(Description))
{
Toast.makeText(this, "Please write the 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 the product
name...",Toast.LENGTH_SHORT).show();
}
else {
StoreProductInformation();
}
}
productRandomKey = saveCurrentDate+saveCurrentTime;
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
String message = e.toString();
Toast.makeText(SellerAddNewProductActivity.this, "Error:" + message, Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>()
{ @Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot)
{ Toast.makeText(SellerAddNewProductActivity.this, "Product Image uploaded
Successfully...",
Toast.LENGTH_SHORT).show();
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot,
Task<Uri>>() {
@Override
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();
Intent intent = new Intent(SellerAddNewProductActivity.this, SellerProductCategoryActivity.class);
startActivity(intent);
loadingBar.dismiss();
Toast.makeText(SellerAddNewProductActivity.this, "got the Product image URL Successfully",
Toast.LENGTH_SHORT).show();
saveProductInfoToDatabase();
}
else
{
loadingBar.dismiss();
String message = task.getException().toString();
Toast.makeText(SellerAddNewProductActivity.this, "Error: " + message,
Toast.LENGTH_SHORT).show();
}
});
}
}
);
}
productMap.put("sellerName", sName);
productMap.put("sellerAddress", sAddress);
productMap.put("sellerPhone", sPhone);
productMap.put("sellerEmail", sEmail);
productMap.put("sid", sID);
productMap.put("productState", "Not Approved");
ProductRef.child(productRandomKey).updateChild
ren(productMap)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task)
{
if (task.isSuccessful())
{
Intent intent = new Intent(SellerAddNewProductActivity.this, SellerHomeActivity.class);
startActivity(intent);
loadingBar.dismiss();
Toast.makeText(SellerAddNewProductActivity.this, "Product is added successfully..",
Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.dismiss();
String message = task.getException().toString();
Toast.makeText(SellerAddNewProductActivity.this, "Error: " + message,
Toast.LENGTH_SHORT).show();
}
}
}
);
}
}
4. Advantages
Customer can buy anytime, anywhere at any place while going online.
Less time consuming.
Have options different options for payment.
24*7 hours services.
5. Limitations
Lack of interaction.
It is not possible to bargain.
Delivery time is too long.
Does not guarantee the products.
We cannot touch and check the material.
6. Conclusion
As a result, we provide best services to our customer and provide a better customer service response. The
customer here gets more facilities like if they did not like the product after delivery they can return and
even money is refunded. Company promises to give the warrantee along with the bill and can return the
order and replace the if it is damage or factory damage. With many brans their might me a chance of
fraud but we guarantee to check the products as many times that is original or copy and responsible for
providing original items by the company and takes action on the employee who are malpractice and
make some mistakes while packing the products.
Th a
nk
You