diff --git a/app/src/androidTest/java/com/example/projecto/activities/DetailActivityTest.java b/app/src/androidTest/java/com/example/projecto/activities/DetailActivityTest.java index 4c068bc..f1f77c2 100644 --- a/app/src/androidTest/java/com/example/projecto/activities/DetailActivityTest.java +++ b/app/src/androidTest/java/com/example/projecto/activities/DetailActivityTest.java @@ -74,5 +74,4 @@ public void testQuantityDecrement() { Espresso.onView(ViewMatchers.withId(R.id.quantity)) .check(ViewAssertions.matches(ViewMatchers.withText("1"))); } - } diff --git a/app/src/androidTest/java/com/example/projecto/activities/PaymentActivityTest.java b/app/src/androidTest/java/com/example/projecto/activities/PaymentActivityTest.java index 3e0c1b6..87f3a4f 100644 --- a/app/src/androidTest/java/com/example/projecto/activities/PaymentActivityTest.java +++ b/app/src/androidTest/java/com/example/projecto/activities/PaymentActivityTest.java @@ -29,6 +29,5 @@ public void testPayButtonNavigatesToOrderPlaced() { // Verify if the OrderPlaced activity is launched by checking a view in OrderPlaced Espresso.onView(ViewMatchers.withId(R.id.order_placed_view_id)) // replace with actual ID in OrderPlaced activity .check(ViewAssertions.matches(ViewMatchers.isDisplayed())); - } } \ No newline at end of file diff --git a/app/src/main/java/com/example/projecto/activities/AddProducts.java b/app/src/main/java/com/example/projecto/activities/AddProducts.java index c71db17..6f3fba5 100644 --- a/app/src/main/java/com/example/projecto/activities/AddProducts.java +++ b/app/src/main/java/com/example/projecto/activities/AddProducts.java @@ -7,8 +7,10 @@ import android.net.Uri; import android.os.Bundle; import android.view.View; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; +import android.widget.Spinner; import android.widget.Toast; import com.example.projecto.R; @@ -21,7 +23,9 @@ public class AddProducts extends AppCompatActivity { - EditText name, description, gname, price, type, discount; + EditText name, description, gname, price, discount; + + Spinner typeSpinner; Button uploadImg, addProduct; FirebaseFirestore db; @@ -41,7 +45,14 @@ protected void onCreate(Bundle savedInstanceState) { description = findViewById(R.id.etDescription); gname = findViewById(R.id.etGenericName); price = findViewById(R.id.etPrice); - type = findViewById(R.id.etType); + + typeSpinner = findViewById(R.id.etType); + ArrayAdapter adapter = ArrayAdapter.createFromResource(this, + R.array.type_options, android.R.layout.simple_spinner_item); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + typeSpinner.setAdapter(adapter); + + discount = findViewById(R.id.etDiscount); uploadImg = findViewById(R.id.btnUploadImage); @@ -74,7 +85,7 @@ private void addP() { String productDescription = description.getText().toString().trim(); String productGenericName = gname.getText().toString().trim(); String productPrice = price.getText().toString().trim(); - String productType = type.getText().toString().trim(); + String productType = typeSpinner.getSelectedItem().toString(); String productDiscount = discount.getText().toString().trim(); if (productName.isEmpty() || productDescription.isEmpty() || productGenericName.isEmpty() diff --git a/app/src/main/java/com/example/projecto/activities/ModifyProducts.java b/app/src/main/java/com/example/projecto/activities/ModifyProducts.java index ae8849b..8c0f205 100644 --- a/app/src/main/java/com/example/projecto/activities/ModifyProducts.java +++ b/app/src/main/java/com/example/projecto/activities/ModifyProducts.java @@ -8,8 +8,10 @@ import android.net.Uri; import android.os.Bundle; import android.view.View; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; +import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -29,7 +31,9 @@ public class ModifyProducts extends AppCompatActivity { - EditText etProductName, etGenericName, etPrice, etDiscount, etType,etDescription; + EditText etProductName, etGenericName, etPrice, etDiscount,etDescription; + + Spinner etType; Button btnUploadImage, btnModify; String imageUrl; @@ -49,7 +53,16 @@ protected void onCreate(Bundle savedInstanceState) { etDescription = findViewById(R.id.etDescription); etPrice = findViewById(R.id.etPrice); etDiscount = findViewById(R.id.etDiscount); + + etType = findViewById(R.id.etType); + ArrayAdapter adapter = ArrayAdapter.createFromResource(this, + R.array.type_options, android.R.layout.simple_spinner_item); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + etType.setAdapter(adapter); + + + btnUploadImage = findViewById(R.id.btnUploadImage); btnModify = findViewById(R.id.btnModifyProducts); @@ -73,7 +86,6 @@ public void onClick(View v) { } }); - } private void openImagePicker() { @@ -107,7 +119,7 @@ private void modifyProduct(String productId) { String modifiedDescription = etDescription.getText().toString().trim(); String modifiedPrice = etPrice.getText().toString().trim(); String modifiedDiscount = etDiscount.getText().toString().trim(); - String modifiedType = etType.getText().toString().trim(); + String modifiedType = etType.getSelectedItem().toString(); // Use the singleton instance of ViewAllModel ViewAllModel modifiedProduct = ViewAllModel.getInstance(); @@ -161,5 +173,4 @@ public void onSuccess(Uri uri) { }); } } - } diff --git a/app/src/main/java/com/example/projecto/adapters/SuggestedAdapters.java b/app/src/main/java/com/example/projecto/adapters/SuggestedAdapters.java index 32307fa..01add06 100644 --- a/app/src/main/java/com/example/projecto/adapters/SuggestedAdapters.java +++ b/app/src/main/java/com/example/projecto/adapters/SuggestedAdapters.java @@ -65,7 +65,6 @@ public class ViewHolder extends RecyclerView.ViewHolder { TextView name,description,gname,discount; public ViewHolder(@NonNull View itemView) { super(itemView); - sugImg = itemView.findViewById(R.id.sug_img); name = itemView.findViewById(R.id.sug_name); description = itemView.findViewById(R.id.sug_des); diff --git a/app/src/main/java/com/example/projecto/ui/home/HomeFragment.java b/app/src/main/java/com/example/projecto/ui/home/HomeFragment.java index c57565a..0f4a6db 100644 --- a/app/src/main/java/com/example/projecto/ui/home/HomeFragment.java +++ b/app/src/main/java/com/example/projecto/ui/home/HomeFragment.java @@ -278,5 +278,5 @@ private void logout() { startActivity(intent); getActivity().finish(); } - + } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_add_products.xml b/app/src/main/res/layout/activity_add_products.xml index 491a877..5aef11b 100644 --- a/app/src/main/res/layout/activity_add_products.xml +++ b/app/src/main/res/layout/activity_add_products.xml @@ -73,17 +73,14 @@ android:layout_marginTop="8dp" android:layout_marginBottom="16dp"/> - + android:layout_marginBottom="16dp" + android:entries="@array/type_options"/>