Skip to content

Commit

Permalink
Merge pull request #16 from Mofazzal874/Apan
Browse files Browse the repository at this point in the history
Admin add product, modify product spinner added
  • Loading branch information
Apn7 authored May 27, 2024
2 parents eba76fd + e05af1c commit 9e81763
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,4 @@ public void testQuantityDecrement() {
Espresso.onView(ViewMatchers.withId(R.id.quantity))
.check(ViewAssertions.matches(ViewMatchers.withText("1")));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

}
}
17 changes: 14 additions & 3 deletions app/src/main/java/com/example/projecto/activities/AddProducts.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<CharSequence> 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);
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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<CharSequence> 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);

Expand All @@ -73,7 +86,6 @@ public void onClick(View v) {
}
});


}

private void openImagePicker() {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -161,5 +173,4 @@ public void onSuccess(Uri uri) {
});
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,5 @@ private void logout() {
startActivity(intent);
getActivity().finish();
}

}
9 changes: 3 additions & 6 deletions app/src/main/res/layout/activity_add_products.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,14 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"/>

<EditText
<Spinner
android:id="@+id/etType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type"
android:textColorHint="#969696"
android:textColor="@color/black"
android:textSize="20sp"
android:layout_below="@id/etDiscount"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"/>
android:layout_marginBottom="16dp"
android:entries="@array/type_options"/>

<Button
android:id="@+id/btnUploadImage"
Expand Down
9 changes: 3 additions & 6 deletions app/src/main/res/layout/activity_modify_products.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,14 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"/>

<EditText
<Spinner
android:id="@+id/etType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#969696"
android:hint="Type"
android:textColor="@color/black"
android:textSize="20sp"
android:layout_below="@id/etDiscount"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"/>
android:layout_marginBottom="16dp"
android:entries="@array/type_options"/>

<Button
android:id="@+id/btnUploadImage"
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@
<string name="slogan">\t\t\t\tYour One-Stop \n Pharmacy Management Solution!</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>


<string-array name="type_options">
<item>health</item>
<item>medication</item>
<item>personal</item>
</string-array>
</resources>

0 comments on commit 9e81763

Please sign in to comment.