Skip to content

Commit

Permalink
merging to main
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond123 committed Oct 21, 2022
2 parents 9870070 + 7e38974 commit 4eaa2e5
Show file tree
Hide file tree
Showing 36 changed files with 401 additions and 155 deletions.
Binary file modified .gradle/7.4.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.4.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.4.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.4.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.4.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
37 changes: 37 additions & 0 deletions .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
android:supportsRtl="true"
android:theme="@style/Theme.RealMealer"
tools:targetApi="31">
<activity
android:name=".LandingPage"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".ForgotPassword"
android:exported="false">
Expand Down
52 changes: 52 additions & 0 deletions app/src/main/java/com/mealer/app/Admin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.mealer.app;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

public class Admin implements Parcelable {
private String admin;

public Admin(){

}

public Admin(boolean isAdmin){
this.admin = "administrator";
}

protected Admin(Parcel in) {
admin = in.readString();
}

public static final Creator<Admin> CREATOR = new Creator<Admin>() {
@Override
public Admin createFromParcel(Parcel in) {
return new Admin(in);
}

@Override
public Admin[] newArray(int size) {
return new Admin[size];
}
};

public String getUserType() {
return this.admin;
}

public String getAdmin(){
return this.admin;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(@NonNull Parcel parcel, int i) {
parcel.writeString(admin);
}
}
9 changes: 5 additions & 4 deletions app/src/main/java/com/mealer/app/ClientUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public ClientUser(){
* attributes pulled from the firebase realtime database
*/
public ClientUser(HashMap<String, String> attributes){
super(attributes.get("firstName"), attributes.get("lastName"), attributes.get("email"),
attributes.get("address"), attributes.get("userType"));
super(attributes.get("firstName"), attributes.get("lastName"),
attributes.get("email"), attributes.get("userType"), attributes.get("city"),
attributes.get("houseNumber"), attributes.get("street"));

this.cardNumber = attributes.get("cardNumber");
this.cardExpiry = attributes.get("cardExpiry");
Expand All @@ -40,9 +41,9 @@ public ClientUser(HashMap<String, String> attributes){
* @param userType this attribute is always "client" for this class,
* but having specific attribute allows for displaying type
*/
public ClientUser(String firstName, String lastName, String email, String address,
public ClientUser(String firstName, String lastName, String email, String city, String houseNumber, String street,
String cardNumber, String cardExpiry, String cardSecurity, String uID, String userType){
super(firstName, lastName, email, address, userType);
super(firstName, lastName, email, userType, city, houseNumber, street);
this.cardNumber = cardNumber;
this.cardExpiry = cardExpiry;
this.cardSecurity = cardSecurity;
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/com/mealer/app/CookUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public class CookUser extends User implements Parcelable {
* attributes pulled from the firebase realtime database
*/
public CookUser(HashMap<String, String> attributes){
super(attributes.get("firstName"), attributes.get("lastName"), attributes.get("email"),
attributes.get("address"), attributes.get("userType"));
super(attributes.get("firstName"), attributes.get("lastName"),
attributes.get("email"), attributes.get("userType"), attributes.get("city"),
attributes.get("houseNumber"), attributes.get("street"));

this.description = attributes.get("description");
}
Expand All @@ -38,11 +39,13 @@ public CookUser(HashMap<String, String> attributes){
* but having specific attribute allows for displaying type
*/
public CookUser(String firstName, String lastName, String email,
String address, String description, String uID, String userType) {
super(firstName, lastName, email, address, userType);
String city, String houseNumber, String street, String description, String uID, String userType) {
super(firstName, lastName, email, userType, city, houseNumber, street);
this.description = description;

// get database reference to the "users" tree
DatabaseReference databaseReference = getReference("users");
// add user to database under uID
databaseReference.child(uID).setValue(this);

}
Expand Down
84 changes: 31 additions & 53 deletions app/src/main/java/com/mealer/app/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,53 @@

import androidx.annotation.NonNull;

import com.google.android.gms.common.util.ArrayUtils;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Locale;
import java.util.Random;
import java.util.UUID;


public class User implements Parcelable {
public class User extends Admin implements Parcelable {

private int mData;

// initializing user attributes
private String firstName;
private String lastName;
private String email;
private Address address;
private String userType;

private static class Address implements Parcelable{
private final String street;
private final String houseNumber;
private final String city;

public Address(String city, String street, String houseNumber){
this.city = city;
this.street = street;
this.houseNumber = houseNumber;
}

protected Address(Parcel in) {
street = in.readString();
houseNumber = in.readString();
city = in.readString();
}

public static final Creator<Address> CREATOR = new Creator<Address>() {
@Override
public Address createFromParcel(Parcel in) {
return new Address(in);
}

@Override
public Address[] newArray(int size) {
return new Address[size];
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(@NonNull Parcel parcel, int i) {
parcel.writeString(street);
parcel.writeString(houseNumber);
parcel.writeString(city);
}
}
// address strings
private String city;
private String houseNumber;
private String street;

// user constructor
public User(String firstName, String lastName, String email, String address, String userType){
public User(String firstName, String lastName, String email, String userType,
String city, String houseNumber, String street){
super();
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.address = newAddress(address);
this.userType = userType;
this.city = city;
this.houseNumber = houseNumber;
this.street = street;
}

private Address newAddress(String address){
String[] tempAddress = address.replace(",", "").split(" ");
return new Address(tempAddress[0], tempAddress[2], tempAddress[1]);
public static String[] parseAddress(String address){
String[] addressMap = address.replace(",", "").split(" ");
if(addressMap.length > 3){
// combine all "arrays" in case that street name had spaces
}
return addressMap;
}

// empty user constructor required for taking firebase snapshot
Expand All @@ -94,7 +66,9 @@ protected User(Parcel in) {
firstName = in.readString();
lastName = in.readString();
email = in.readString();
address = in.readParcelable(address.getClass().getClassLoader());
city = in.readString();
houseNumber = in.readString();
street = in.readString();
userType = in.readString();
}

Expand Down Expand Up @@ -134,9 +108,11 @@ public String getEmail() {
return email;
}

public Address getAddress() {
return address;
}
public String getCity(){ return city; }

public String getHouseNumber() { return houseNumber; }

public String getStreet() { return street; }

public String getUserType(){ return userType;}

Expand All @@ -153,7 +129,9 @@ public void writeToParcel(@NonNull Parcel parcel, int i) {
parcel.writeString(firstName);
parcel.writeString(lastName);
parcel.writeString(email);
parcel.writeParcelable(address, i);
parcel.writeString(city);
parcel.writeString(houseNumber);
parcel.writeString(street);
parcel.writeString(userType);
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/mealer/ui/DietaryPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ protected void onCreate(Bundle savedInstanceState) {
private void setRestriction(String type){
DatabaseReference databaseReference =
FirebaseDatabase.getInstance("https://mealer-app-58f99-default-rtdb.firebaseio.com/")
.getReference("users/client");
.getReference("users");

HashMap<String, Object> update = new HashMap<>();
update.put("dietary restriction", type);

FirebaseUser currentFirebaseUser = this.mAuth.getCurrentUser();
if(currentFirebaseUser!=null){
databaseReference.child(currentFirebaseUser.getUid()).updateChildren(update);

}

finish();
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/mealer/ui/ForgotPassword.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ protected void onCreate(Bundle savedInstanceState) {

}

/**
* uses firebase authentication built in method to send user password reset email
*/
private void sendPasswordReset(){
if(!username.getText().toString().isEmpty()){
mAuth.sendPasswordResetEmail(username.getText().toString())
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/mealer/ui/LandingPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.mealer.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

/**
* IMPORTANT: ACTIVITY NOT CURRENTLY BEING USED
* to be implemented in the next deliverable
*/

public class LandingPage extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_landing_page);
}
}
Loading

0 comments on commit 4eaa2e5

Please sign in to comment.