From 5494cd71ccc8761f825ba3f97bd9aba038b0f4b8 Mon Sep 17 00:00:00 2001
From: Iltwats <2012atulsharma@gmail.com>
Date: Fri, 4 Dec 2020 18:16:15 +0530
Subject: [PATCH] New Improvements - Users Orders Can be accepted and rejected
now.
---
app/build.gradle | 5 +
app/src/main/AndroidManifest.xml | 37 ++++-
.../android/ecommerce/CatalogActivity.java | 52 ++++++
.../ecommerce/Constants/Constants.java | 5 +
.../atul/android/ecommerce/MainActivity.java | 2 +
.../ecommerce/NotificationActivity.java | 18 +++
.../atul/android/ecommerce/OrderActivity.java | 81 ++++++++++
.../ecommerce/adapter/OrdersAdapter.java | 149 ++++++++++++++++++
.../ecommerce/adapter/OrdersViewHolder.java | 13 ++
.../atul/android/ecommerce/fcm/AdminFCM.java | 55 +++++++
.../atul/android/ecommerce/fcm/FCMSender.java | 33 ++++
.../ecommerce/fcm/MessageFormatter.java | 16 ++
.../android/ecommerce/model/CartItem.java | 36 +++++
.../atul/android/ecommerce/model/Order.java | 34 ++++
app/src/main/res/layout/activity_catalog.xml | 58 +++++++
.../main/res/layout/activity_notification.xml | 9 ++
app/src/main/res/layout/activity_order.xml | 21 +++
app/src/main/res/layout/order_items.xml | 51 ++++++
app/src/main/res/layout/orderdetails.xml | 134 ++++++++++++++++
app/src/main/res/values/strings.xml | 7 +-
build.gradle | 1 +
21 files changed, 813 insertions(+), 4 deletions(-)
create mode 100644 app/src/main/java/com/atul/android/ecommerce/CatalogActivity.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/NotificationActivity.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/OrderActivity.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/adapter/OrdersAdapter.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/adapter/OrdersViewHolder.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/fcm/AdminFCM.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/fcm/FCMSender.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/fcm/MessageFormatter.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/model/CartItem.java
create mode 100644 app/src/main/java/com/atul/android/ecommerce/model/Order.java
create mode 100644 app/src/main/res/layout/activity_catalog.xml
create mode 100644 app/src/main/res/layout/activity_notification.xml
create mode 100644 app/src/main/res/layout/activity_order.xml
create mode 100644 app/src/main/res/layout/order_items.xml
create mode 100644 app/src/main/res/layout/orderdetails.xml
diff --git a/app/build.gradle b/app/build.gradle
index 879e204..9974074 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
+ id 'com.google.firebase.crashlytics'
}
android {
@@ -39,10 +40,14 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-firestore'
+ implementation 'com.google.firebase:firebase-crashlytics'
+ implementation 'com.google.firebase:firebase-analytics'
+ implementation 'com.google.firebase:firebase-messaging'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
+ implementation("com.squareup.okhttp3:okhttp:4.9.0")
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 39ed98e..3b08c05 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,22 +5,53 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/atul/android/ecommerce/CatalogActivity.java b/app/src/main/java/com/atul/android/ecommerce/CatalogActivity.java
new file mode 100644
index 0000000..f9488f9
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/CatalogActivity.java
@@ -0,0 +1,52 @@
+package com.atul.android.ecommerce;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Toast;
+
+import com.atul.android.ecommerce.databinding.ActivityCatalogBinding;
+
+public class CatalogActivity extends AppCompatActivity {
+
+ private ActivityCatalogBinding bind;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ bind = ActivityCatalogBinding.inflate(getLayoutInflater());
+ setContentView(bind.getRoot());
+
+ userActivity();
+ }
+
+ private void userActivity() {
+ bind.editProducts.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Toast.makeText(CatalogActivity.this,"Clicked Edit Products",Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(CatalogActivity.this,MainActivity.class);
+ startActivity(intent);
+ }
+ });
+ bind.orders.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Toast.makeText(CatalogActivity.this,"Clicked Orders",Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(CatalogActivity.this,OrderActivity.class);
+ startActivity(intent);
+ }
+ });
+ bind.notifyUsers.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Toast.makeText(CatalogActivity.this,"Clicked Notify Users",Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(CatalogActivity.this,NotificationActivity.class);
+ startActivity(intent);
+ }
+ });
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/atul/android/ecommerce/Constants/Constants.java b/app/src/main/java/com/atul/android/ecommerce/Constants/Constants.java
index 089d66c..0b4549d 100644
--- a/app/src/main/java/com/atul/android/ecommerce/Constants/Constants.java
+++ b/app/src/main/java/com/atul/android/ecommerce/Constants/Constants.java
@@ -3,4 +3,9 @@
public class Constants {
public static final String INVENTORY = "inventory";
public static final String PRODUCTS = "products";
+ public static final String ORDERS = "Orders";
+ public static final String DETAILS = "Order Info";
+ public static final String ADMIN = "admin";
+ public static final String USER = "users";
+ public static final String ORDER_TIME = "orderTime";
}
diff --git a/app/src/main/java/com/atul/android/ecommerce/MainActivity.java b/app/src/main/java/com/atul/android/ecommerce/MainActivity.java
index ddaa6a2..e806641 100644
--- a/app/src/main/java/com/atul/android/ecommerce/MainActivity.java
+++ b/app/src/main/java/com/atul/android/ecommerce/MainActivity.java
@@ -29,6 +29,7 @@
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.firestore.DocumentSnapshot;
+import com.google.firebase.messaging.FirebaseMessaging;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@@ -58,6 +59,7 @@ protected void onCreate(Bundle savedInstanceState) {
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
+ FirebaseMessaging.getInstance().subscribeToTopic(Constants.ADMIN);
sharedPreferences = getSharedPreferences(sharedPreferencesFile, MODE_PRIVATE);
gson = new Gson();
setup();
diff --git a/app/src/main/java/com/atul/android/ecommerce/NotificationActivity.java b/app/src/main/java/com/atul/android/ecommerce/NotificationActivity.java
new file mode 100644
index 0000000..fa3861d
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/NotificationActivity.java
@@ -0,0 +1,18 @@
+package com.atul.android.ecommerce;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+
+import com.atul.android.ecommerce.databinding.ActivityNotificationBinding;
+
+public class NotificationActivity extends AppCompatActivity {
+
+ private ActivityNotificationBinding notifyb;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ notifyb = ActivityNotificationBinding.inflate(getLayoutInflater());
+ setContentView(notifyb.getRoot());
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/atul/android/ecommerce/OrderActivity.java b/app/src/main/java/com/atul/android/ecommerce/OrderActivity.java
new file mode 100644
index 0000000..f6428f0
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/OrderActivity.java
@@ -0,0 +1,81 @@
+package com.atul.android.ecommerce;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.recyclerview.widget.LinearLayoutManager;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.atul.android.ecommerce.Constants.Constants;
+import com.atul.android.ecommerce.adapter.OrdersAdapter;
+import com.atul.android.ecommerce.databinding.ActivityOrderBinding;
+import com.atul.android.ecommerce.fcm.FCMSender;
+import com.atul.android.ecommerce.fcm.MessageFormatter;
+import com.atul.android.ecommerce.model.Order;
+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.firestore.Query;
+import com.google.firebase.firestore.QueryDocumentSnapshot;
+import com.google.firebase.firestore.QuerySnapshot;
+import com.google.firebase.firestore.SetOptions;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
+
+public class OrderActivity extends AppCompatActivity {
+
+ private ActivityOrderBinding orderBinding;
+ private MyApp myApp;
+ OrdersAdapter ordersAdapter;
+ List orderList = new ArrayList<>();
+ ArrayList orderIDs=new ArrayList<>();
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ orderBinding = ActivityOrderBinding.inflate(getLayoutInflater());
+ setContentView(orderBinding.getRoot());
+
+ myApp = (MyApp) getApplicationContext();
+ fetchAllOrdersFromDB();
+ }
+
+ private void fetchAllOrdersFromDB() {
+ myApp.db.collection(Constants.ORDERS)
+ .orderBy(Constants.ORDER_TIME, Query.Direction.DESCENDING)
+ .get()
+ .addOnCompleteListener(new OnCompleteListener() {
+ @Override
+ public void onComplete(@NonNull Task task) {
+ for (QueryDocumentSnapshot snapshot : task.getResult()) {
+ Order order = snapshot.toObject(Order.class);
+ orderList.add(order);
+ orderIDs.add(snapshot.getId());
+ }
+ setupAdapter();
+ }
+ });
+ }
+
+ private void setupAdapter() {
+ ordersAdapter = new OrdersAdapter(OrderActivity.this, orderList,myApp,orderIDs);
+ orderBinding.allOrders.setAdapter(ordersAdapter);
+ orderBinding.allOrders.setLayoutManager(new LinearLayoutManager(OrderActivity.this));
+ orderBinding.allOrders.addItemDecoration(
+ new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)
+ );
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/atul/android/ecommerce/adapter/OrdersAdapter.java b/app/src/main/java/com/atul/android/ecommerce/adapter/OrdersAdapter.java
new file mode 100644
index 0000000..05a976e
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/adapter/OrdersAdapter.java
@@ -0,0 +1,149 @@
+package com.atul.android.ecommerce.adapter;
+
+import android.content.Context;
+import android.graphics.Color;
+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.recyclerview.widget.RecyclerView;
+
+import com.atul.android.ecommerce.Constants.Constants;
+import com.atul.android.ecommerce.MyApp;
+import com.atul.android.ecommerce.OrderActivity;
+import com.atul.android.ecommerce.databinding.OrderItemsBinding;
+import com.atul.android.ecommerce.databinding.OrderdetailsBinding;
+import com.atul.android.ecommerce.fcm.FCMSender;
+import com.atul.android.ecommerce.fcm.MessageFormatter;
+import com.atul.android.ecommerce.model.Order;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
+
+public class OrdersAdapter extends RecyclerView.Adapter {
+
+ public Context context;
+ public List orderList;
+ public int lastSelectedItemPosition;
+ public static final int PLACED = 1, DELIVERED = 0, DECLINED = -1;
+ MyApp app;
+ ArrayList orderIDs;
+ Order order;
+
+
+ public OrdersAdapter(Context context, List orderList, MyApp app, ArrayList ordersIDs) {
+ this.context = context;
+ this.orderList = new ArrayList<>(orderList);
+ this.app = app;
+ this.orderIDs=ordersIDs;
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ OrderdetailsBinding b = OrderdetailsBinding.inflate(
+ LayoutInflater.from(context),
+ parent,
+ false
+ );
+ return new OrdersViewHolder(b);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ String orderId= orderIDs.get(position);
+ Order order = orderList.get(position);
+ OrderdetailsBinding b = ((OrdersViewHolder) holder).bin;
+ b.orderUserName.setText("" + order.name);
+ b.orderTotalItems.setText("Items: " + order.total_items);
+ b.orderTotalPrice.setText("Rs. " + order.total_price);
+ setupOrderStatus(b, order.action);
+ setupProductsView(b, order);
+ b.accept.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ b.orderStatus.setText("ACCEPTED");
+ b.orderStatus.setTextColor(Color.GREEN);
+ updateStatus(orderId,DELIVERED);
+ sendNotification(orderId,"Has been Accepted and Will be delivered shortly.");
+ }
+ });
+ b.reject.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ b.orderStatus.setText("DECLINED");
+ b.orderStatus.setTextColor(Color.RED);
+ updateStatus(orderId,DECLINED);
+ sendNotification(orderId,"Has been declined, sorry for the Inconvenience.");
+
+ }
+ });
+ holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ lastSelectedItemPosition = holder.getAdapterPosition();
+ return false;
+ }
+ });
+
+ }
+
+ private void setupProductsView(OrderdetailsBinding b, Order order) {
+ b.allOrderItems.removeAllViews();
+ for (int i = 0; i< order.orderItems.size(); i++) {
+ OrderItemsBinding bindingNew = OrderItemsBinding.inflate(LayoutInflater.from(context));
+ bindingNew.itemName.setText("" + order.orderItems.get(i).name);
+ bindingNew.itemQuantity.setText("Total Items/Quantity: " + order.orderItems.get(i).quantity);
+ bindingNew.itemPrice.setText(" Rs." + order.orderItems.get(i).price);
+
+ b.allOrderItems.addView(bindingNew.getRoot());
+ }
+ }
+
+ private void setupOrderStatus(OrderdetailsBinding b, int action) {
+ if (action == Order.OrderStatus.PLACED) {
+ b.orderStatus.setText("PLACED");
+ b.orderStatus.setTextColor(Color.YELLOW);
+ } else if (action == Order.OrderStatus.DECLINED) {
+ b.orderStatus.setText("DECLINED");
+ b.orderStatus.setTextColor(Color.RED);
+ } else {
+ b.orderStatus.setText("ACCEPTED");
+ b.orderStatus.setTextColor(Color.GREEN);
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return orderList.size();
+ }
+
+ private void updateStatus(String id, int status) {
+ app.db.collection(Constants.ORDERS).document(id).update("action",status);
+ }
+ public void sendNotification(String orderId,String message) {
+ new FCMSender().send(MessageFormatter.getSampleMessage("users", "Your Order ID. "+ orderId, message), new Callback() {
+
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ Log.e("mssg",response.toString());
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ Log.e("mssg",e.toString());
+ }
+ });
+ }
+
+}
diff --git a/app/src/main/java/com/atul/android/ecommerce/adapter/OrdersViewHolder.java b/app/src/main/java/com/atul/android/ecommerce/adapter/OrdersViewHolder.java
new file mode 100644
index 0000000..11444b9
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/adapter/OrdersViewHolder.java
@@ -0,0 +1,13 @@
+package com.atul.android.ecommerce.adapter;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.atul.android.ecommerce.databinding.OrderdetailsBinding;
+
+public class OrdersViewHolder extends RecyclerView.ViewHolder {
+ OrderdetailsBinding bin;
+ public OrdersViewHolder(OrderdetailsBinding bin) {
+ super(bin.getRoot());
+ this.bin =bin;
+ }
+}
diff --git a/app/src/main/java/com/atul/android/ecommerce/fcm/AdminFCM.java b/app/src/main/java/com/atul/android/ecommerce/fcm/AdminFCM.java
new file mode 100644
index 0000000..71b5646
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/fcm/AdminFCM.java
@@ -0,0 +1,55 @@
+package com.atul.android.ecommerce.fcm;
+
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.os.Build;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+import androidx.core.app.NotificationCompat;
+import androidx.core.app.NotificationManagerCompat;
+
+import com.atul.android.ecommerce.R;
+import com.google.firebase.messaging.FirebaseMessagingService;
+import com.google.firebase.messaging.RemoteMessage;
+
+import java.util.Random;
+
+public class AdminFCM extends FirebaseMessagingService {
+ private static final String CHANNEL_ID = "notification";
+
+ @Override
+ public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
+ super.onMessageReceived(remoteMessage);
+ String version = remoteMessage.getData()
+ .get("value");
+
+ createNotificationChannel();
+
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
+ .setSmallIcon(R.mipmap.ic_launcher)
+ .setContentTitle(remoteMessage.getNotification().getTitle())
+ .setContentText(remoteMessage.getNotification().getBody())
+ .setPriority(NotificationCompat.PRIORITY_DEFAULT);
+
+ NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
+
+ notificationManager.notify(new Random().nextInt(5000) + 5000, builder.build());
+ }
+
+ private void createNotificationChannel() {
+ // Create the NotificationChannel, but only on API 26+ because
+ // the NotificationChannel class is new and not in the support library
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ CharSequence name = getString(R.string.channel_name);
+ String description = getString(R.string.channel_description);
+ int importance = NotificationManager.IMPORTANCE_DEFAULT;
+ NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
+ channel.setDescription(description);
+ // Register the channel with the system; you can't change the importance
+ // or other notification behaviors after this
+ NotificationManager notificationManager = getSystemService(NotificationManager.class);
+ notificationManager.createNotificationChannel(channel);
+ }
+ }
+}
diff --git a/app/src/main/java/com/atul/android/ecommerce/fcm/FCMSender.java b/app/src/main/java/com/atul/android/ecommerce/fcm/FCMSender.java
new file mode 100644
index 0000000..dafebc6
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/fcm/FCMSender.java
@@ -0,0 +1,33 @@
+package com.atul.android.ecommerce.fcm;
+
+import com.atul.android.ecommerce.Constants.Keys;
+
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+
+
+public class FCMSender {
+ private static final String FCM_URL = "https://fcm.googleapis.com/fcm/send";
+ private static final String KEY_STRING = Keys.FCMKEY;
+
+ OkHttpClient client = new OkHttpClient();
+
+ public void send(String message, Callback callback){
+ RequestBody reqBody = RequestBody.create(message, MediaType.get("application/json"));
+
+ Request request = new Request.Builder()
+ .url(FCM_URL)
+ .addHeader("Content-Type", "application/json")
+ .addHeader("Authorization", KEY_STRING)
+ .post(reqBody)
+ .build();
+
+ Call call = client.newCall(request);
+ call.enqueue(callback);
+ }
+}
diff --git a/app/src/main/java/com/atul/android/ecommerce/fcm/MessageFormatter.java b/app/src/main/java/com/atul/android/ecommerce/fcm/MessageFormatter.java
new file mode 100644
index 0000000..23ea8b4
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/fcm/MessageFormatter.java
@@ -0,0 +1,16 @@
+package com.atul.android.ecommerce.fcm;
+
+public class MessageFormatter {
+ private static String sampleMsgFormat = "{" +
+ " \"to\": \"/topics/%s\"," +
+ " \"notification\": {" +
+ " \"title\":\"%s\"," +
+ " \"body\":\"%s\"" +
+ " }" +
+ "}";
+
+ public static String getSampleMessage(String topic, String title, String body){
+ return String.format(sampleMsgFormat, topic, title, body);
+ }
+
+}
diff --git a/app/src/main/java/com/atul/android/ecommerce/model/CartItem.java b/app/src/main/java/com/atul/android/ecommerce/model/CartItem.java
new file mode 100644
index 0000000..fab20ed
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/model/CartItem.java
@@ -0,0 +1,36 @@
+package com.atul.android.ecommerce.model;
+
+import java.io.Serializable;
+
+public class CartItem implements Serializable {
+
+ public String name;
+ public float quantity;
+ public int price;
+
+ public CartItem() {
+ }
+
+ public CartItem(String name, float quantity, int price) {
+ this.name = name;
+ this.quantity = quantity;
+ this.price = price;
+ }
+
+ public CartItem(String name, int price) {
+ this.name = name;
+ this.price = price;
+ quantity = 1;
+ }
+
+ @Override
+ public String toString() {
+ return "CartItem{" +
+ "name='" + name + '\'' +
+ ", quantity=" + quantity +
+ ", price=" + price +
+ '}';
+ }
+
+}
+
diff --git a/app/src/main/java/com/atul/android/ecommerce/model/Order.java b/app/src/main/java/com/atul/android/ecommerce/model/Order.java
new file mode 100644
index 0000000..140cbf3
--- /dev/null
+++ b/app/src/main/java/com/atul/android/ecommerce/model/Order.java
@@ -0,0 +1,34 @@
+package com.atul.android.ecommerce.model;
+
+import com.google.firebase.Timestamp;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class Order implements Serializable {
+ public Timestamp orderTime;
+ public String name;
+ public List orderItems;
+ public int action;
+ public int total_price, total_items;
+
+ public Order() {
+ }
+
+ public Order(String name, Timestamp orderTime, List orderItems, int action, int total_price, int total_items) {
+ this.orderTime = orderTime;
+ this.name = name;
+ this.orderItems = orderItems;
+ this.action = action;
+ this.total_price = total_price;
+ this.total_items = total_items;
+ }
+
+ public static class OrderStatus {
+
+ public static final int PLACED = 1 // Initially (U)
+ , DELIVERED = 0, DECLINED = -1; //(A)
+
+ }
+
+}
diff --git a/app/src/main/res/layout/activity_catalog.xml b/app/src/main/res/layout/activity_catalog.xml
new file mode 100644
index 0000000..5abe613
--- /dev/null
+++ b/app/src/main/res/layout/activity_catalog.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_notification.xml b/app/src/main/res/layout/activity_notification.xml
new file mode 100644
index 0000000..c7d4e92
--- /dev/null
+++ b/app/src/main/res/layout/activity_notification.xml
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_order.xml b/app/src/main/res/layout/activity_order.xml
new file mode 100644
index 0000000..db5751c
--- /dev/null
+++ b/app/src/main/res/layout/activity_order.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/order_items.xml b/app/src/main/res/layout/order_items.xml
new file mode 100644
index 0000000..5058905
--- /dev/null
+++ b/app/src/main/res/layout/order_items.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/orderdetails.xml b/app/src/main/res/layout/orderdetails.xml
new file mode 100644
index 0000000..cb719a2
--- /dev/null
+++ b/app/src/main/res/layout/orderdetails.xml
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index fc4310e..94a42b2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,4 +1,9 @@
- EComs
+ Admin Ecom
Add Product
+ notification
+ General Notification
+ Edit Products
+ Orders
+ Notify Users
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index cf79719..c22996e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,6 +7,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.4'
+ classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files