<repo_name>kaajalbgupta/smartpad<file_sep>/app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "30.0.1"

    defaultConfig {
        applicationId "com.example.smartpad"
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.fragment:fragment:1.2.5'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.jakewharton:butterknife:10.2.3'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
    implementation "androidx.recyclerview:recyclerview:1.1.0"
    implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc03"
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation platform('com.google.firebase:firebase-bom:26.3.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-database'
    implementation 'com.google.firebase:firebase-auth'
    implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
    implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
    implementation 'com.github.npanigrahy:Custom-Calendar-View:v1.0'
    implementation 'sun.bob:mcalendarview:1.0.0'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}<file_sep>/SmartPad/app/build/generated/ap_generated_sources/debug/out/com/example/smartpad/RegisterActivity_ViewBinding.java
// Generated code from Butter Knife. Do not modify!
package com.example.smartpad;

import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import androidx.annotation.CallSuper;
import androidx.annotation.UiThread;
import androidx.appcompat.widget.AppCompatEditText;
import butterknife.Unbinder;
import butterknife.internal.Utils;
import java.lang.IllegalStateException;
import java.lang.Override;

public class RegisterActivity_ViewBinding implements Unbinder {
  private RegisterActivity target;

  @UiThread
  public RegisterActivity_ViewBinding(RegisterActivity target) {
    this(target, target.getWindow().getDecorView());
  }

  @UiThread
  public RegisterActivity_ViewBinding(RegisterActivity target, View source) {
    this.target = target;

    target.backButton = Utils.findRequiredViewAsType(source, R.id.back, "field 'backButton'", ImageButton.class);
    target.continueButton = Utils.findRequiredViewAsType(source, R.id.continue_button, "field 'continueButton'", Button.class);
    target.nameText = Utils.findRequiredViewAsType(source, R.id.name_sign_up_edit_text, "field 'nameText'", AppCompatEditText.class);
    target.emailText = Utils.findRequiredViewAsType(source, R.id.email_sign_up_edit_text, "field 'emailText'", AppCompatEditText.class);
    target.passwordText = Utils.findRequiredViewAsType(source, R.id.password_sign_up_edit_text, "field 'passwordText'", AppCompatEditText.class);
  }

  @Override
  @CallSuper
  public void unbind() {
    RegisterActivity target = this.target;
    if (target == null) throw new IllegalStateException("Bindings already cleared.");
    this.target = null;

    target.backButton = null;
    target.continueButton = null;
    target.nameText = null;
    target.emailText = null;
    target.passwordText = null;
  }
}
<file_sep>/SmartPad/app/build/generated/ap_generated_sources/debug/out/com/example/smartpad/MainActivity_ViewBinding.java
// Generated code from Butter Knife. Do not modify!
package com.example.smartpad;

import android.view.View;
import android.widget.Button;
import androidx.annotation.CallSuper;
import androidx.annotation.UiThread;
import butterknife.Unbinder;
import butterknife.internal.Utils;
import java.lang.IllegalStateException;
import java.lang.Override;

public class MainActivity_ViewBinding implements Unbinder {
  private MainActivity target;

  @UiThread
  public MainActivity_ViewBinding(MainActivity target) {
    this(target, target.getWindow().getDecorView());
  }

  @UiThread
  public MainActivity_ViewBinding(MainActivity target, View source) {
    this.target = target;

    target.registerButton = Utils.findRequiredViewAsType(source, R.id.register_button, "field 'registerButton'", Button.class);
    target.signInButton = Utils.findRequiredViewAsType(source, R.id.sign_in_button, "field 'signInButton'", Button.class);
  }

  @Override
  @CallSuper
  public void unbind() {
    MainActivity target = this.target;
    if (target == null) throw new IllegalStateException("Bindings already cleared.");
    this.target = null;

    target.registerButton = null;
    target.signInButton = null;
  }
}
<file_sep>/app/src/main/java/com/example/smartpad/SignInActivity.java
package com.example.smartpad;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.example.smartpad.utils.Utils;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.auth.AuthResult;
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 butterknife.BindView;
import butterknife.ButterKnife;

import static com.example.smartpad.utils.PadContract.USERS;

public class SignInActivity extends AppCompatActivity {

    @BindView(R.id.back)
    ImageButton backButton;
    @BindView(R.id.sign_in_button) Button signInButton;
    @BindView(R.id.email_edit_text)
    AppCompatEditText emailText;
    @BindView(R.id.password_edit_text) AppCompatEditText passwordText;
    @BindView(R.id.constraint_layout)
    ConstraintLayout constraintLayout;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sign_in_activity);

        ButterKnife.bind(this);

        backButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
                overridePendingTransition(R.anim.fade_out, R.anim.fade_in);
            }
        });

        signInButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(!Utils.getTrimmedString(passwordText).isEmpty() && !Utils.getTrimmedString(emailText).isEmpty()){
                    FirebaseAuth firebaseAuth=FirebaseAuth.getInstance();
                    firebaseAuth.signInWithEmailAndPassword(Utils.getTrimmedString(emailText),Utils.getTrimmedString(passwordText)).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            Intent intent=new Intent(SignInActivity.this, UserActivity.class);
                            startActivity(intent);
                            overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                        };
                    });
                }else{
                    Snackbar.make(constraintLayout,"Please enter your email and password.",Snackbar.LENGTH_SHORT).show();
                }
            }
        });
    }

    @Override
    public void onBackPressed() {
        finish();
        overridePendingTransition(R.anim.fade_out, R.anim.fade_in);
    }
}
<file_sep>/README.md
# Smart Pad
An app to analyze menstrual blood and inform the user of their flow and health.

Made during the Yale CBIT Healthcare Hackathon by <NAME>, <NAME>, and <NAME>
<file_sep>/app/src/main/java/com/example/smartpad/objects/PeriodDay.java
package com.example.smartpad.objects;

import android.util.Log;

import com.example.smartpad.utils.Utils;

import java.util.ArrayList;
import java.util.LinkedHashMap;

public class PeriodDay {

    private LinkedHashMap<String, HourlyInstance> hourlyInstances;
    private long dayTime;

    public PeriodDay(LinkedHashMap<String, HourlyInstance> hourlyInstances, long dayTime){
        this.hourlyInstances=hourlyInstances;
        this.dayTime=dayTime;
    }

    public LinkedHashMap<String, HourlyInstance> getHourlyInstances() {
        return hourlyInstances;
    }

    public void setHourlyInstances(LinkedHashMap<String, HourlyInstance> hourlyInstances) {
        this.hourlyInstances = hourlyInstances;
    }

    public long getDayTime() {
        return dayTime;
    }

    public void setDayTime(long dayTime) {
        this.dayTime = dayTime;
    }

    public String getAverageColor(){
        int red=0;
        int green=0;
        int blue=0;
        ArrayList<HourlyInstance> hourlyInstances=new ArrayList<>(this.hourlyInstances.values());
        for (HourlyInstance hourlyInstance: hourlyInstances){
            red+=hourlyInstance.getColor().getRed();
            green+=hourlyInstance.getColor().getGreen();
            blue+=hourlyInstance.getColor().getBlue();
        }
        red=red/this.hourlyInstances.size();
        green=green/this.hourlyInstances.size();
        blue=blue/this.hourlyInstances.size();
        return Utils.getHexFromRGB(red, green, blue);
    }

    public Color getAverageColorRGB(){
        int red=0;
        int green=0;
        int blue=0;
        ArrayList<HourlyInstance> hourlyInstances=new ArrayList<>(this.hourlyInstances.values());
        for (HourlyInstance hourlyInstance: hourlyInstances){
            red+=hourlyInstance.getColor().getRed();
            green+=hourlyInstance.getColor().getGreen();
            blue+=hourlyInstance.getColor().getBlue();
        }
        red=red/this.hourlyInstances.size();
        green=green/this.hourlyInstances.size();
        blue=blue/this.hourlyInstances.size();
        return new Color(red, green, blue);
    }

    public int getAverageHeaviness(){
        int heaviness=0;
        ArrayList<HourlyInstance> hourlyInstances=new ArrayList<>(this.hourlyInstances.values());
        for (HourlyInstance hourlyInstance: hourlyInstances){
            heaviness+=hourlyInstance.getHeaviness();
        }
        heaviness=heaviness/hourlyInstances.size();
        return heaviness;
    }

    public int getAverageClotting(){
        int clotting=0;
        ArrayList<HourlyInstance> hourlyInstances=new ArrayList<>(this.hourlyInstances.values());
        for (HourlyInstance hourlyInstance: hourlyInstances){
            clotting+=hourlyInstance.getClotting();
        }
        clotting=clotting/hourlyInstances.size();
        Log.v("Period day: ", String.valueOf(clotting));
        return clotting;
    }

}
<file_sep>/app/src/main/java/com/example/smartpad/objects/Period.java
package com.example.smartpad.objects;

import android.util.Log;

import java.util.ArrayList;
import java.util.LinkedHashMap;

public class Period {

  private long startTime, endTime;
  private LinkedHashMap<String, PeriodDay> days;

  public Period(long startTime, LinkedHashMap<String, PeriodDay> days, long endTime){
    this.startTime=startTime;
    this.endTime=endTime;
    this.days=days;
  }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public LinkedHashMap<String, PeriodDay> getDays() {
        return days;
    }

    public void setDays(LinkedHashMap<String, PeriodDay> days) {
        this.days = days;
    }

    public int getAverageHeaviness(){
        int heaviness=0;
        ArrayList<PeriodDay> periodDays=new ArrayList<>(this.days.values());
        for (PeriodDay periodDay: periodDays){
            heaviness+=periodDay.getAverageHeaviness();
        }
        heaviness=heaviness/periodDays.size();
        return heaviness;
    }

    public int getAverageClotting(){
      int clotting=0;
        ArrayList<PeriodDay> periodDays=new ArrayList<>(this.days.values());
        for (PeriodDay periodDay: periodDays){
            clotting+=periodDay.getAverageClotting();
        }
        clotting=clotting/periodDays.size();
        Log.v("Period: ", String.valueOf(clotting));
        return clotting;
    }

    public Color getAverageColorRGB(){
        int red=0;
        int green=0;
        int blue=0;
        ArrayList<PeriodDay> periodDays=new ArrayList<>(this.days.values());
        for (PeriodDay periodDay: periodDays){
            red+=periodDay.getAverageColorRGB().getRed();
            green+=periodDay.getAverageColorRGB().getGreen();
            blue+=periodDay.getAverageColorRGB().getBlue();
        }
        red=red/this.days.size();
        green=green/this.days.size();
        blue=blue/this.days.size();
        return new Color(red, green, blue);
    }
}
<file_sep>/app/src/main/java/com/example/smartpad/RegisterActivity.java
package com.example.smartpad;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatEditText;

import com.example.smartpad.utils.Utils;

import butterknife.BindView;
import butterknife.ButterKnife;

import static com.example.smartpad.utils.PadContract.EMAIL;
import static com.example.smartpad.utils.PadContract.NAME;
import static com.example.smartpad.utils.PadContract.PASSWORD;

public class RegisterActivity extends AppCompatActivity {

    @BindView(R.id.back)
    ImageButton backButton;
    @BindView(R.id.continue_button)
    Button continueButton;
    @BindView(R.id.name_sign_up_edit_text)
    AppCompatEditText nameText;
    @BindView(R.id.email_sign_up_edit_text)
    AppCompatEditText emailText;
    @BindView(R.id.password_sign_up_edit_text)
    AppCompatEditText passwordText;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register_activity);

        ButterKnife.bind(this);

        backButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
                overridePendingTransition(R.anim.fade_out, R.anim.fade_in);
            }
        });
        continueButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String email= Utils.getTrimmedString(emailText);
                String password=Utils.getTrimmedString(passwordText);
                String name=Utils.getTrimmedString(nameText);
                if(!email.isEmpty() && !password.isEmpty() && !name.isEmpty()){
                    Intent intent=new Intent(RegisterActivity.this, SignUpDetailActivity.class);
                    intent.putExtra(NAME, name);
                    intent.putExtra(EMAIL, email);
                    intent.putExtra(PASSWORD, <PASSWORD>);
                    startActivity(intent);
                    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                }
            }
        });
    }

    @Override
    public void onBackPressed() {
        finish();
        overridePendingTransition(R.anim.fade_out, R.anim.fade_in);
    }
}
<file_sep>/app/src/main/java/com/example/smartpad/utils/FirebaseUtils.java
package com.example.smartpad.utils;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.example.smartpad.R;
import com.example.smartpad.UserActivity;
import com.example.smartpad.objects.Color;
import com.example.smartpad.objects.HourlyInstance;
import com.example.smartpad.objects.Period;
import com.example.smartpad.objects.PeriodDay;
import com.example.smartpad.objects.User;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;

import static com.example.smartpad.utils.PadContract.AGE;
import static com.example.smartpad.utils.PadContract.BLUE;
import static com.example.smartpad.utils.PadContract.CLOTTING;
import static com.example.smartpad.utils.PadContract.COLOR;
import static com.example.smartpad.utils.PadContract.DAYS;
import static com.example.smartpad.utils.PadContract.DAY_TIME;
import static com.example.smartpad.utils.PadContract.END_TIME;
import static com.example.smartpad.utils.PadContract.GREEN;
import static com.example.smartpad.utils.PadContract.HEAVINESS;
import static com.example.smartpad.utils.PadContract.HOURLY_INSTANCES;
import static com.example.smartpad.utils.PadContract.HOUR_TIME;
import static com.example.smartpad.utils.PadContract.NAME;
import static com.example.smartpad.utils.PadContract.PADS_CHANGED;
import static com.example.smartpad.utils.PadContract.PAD_NUMBER;
import static com.example.smartpad.utils.PadContract.PERIODS;
import static com.example.smartpad.utils.PadContract.RED;
import static com.example.smartpad.utils.PadContract.SATURATION;
import static com.example.smartpad.utils.PadContract.START_TIME;
import static com.example.smartpad.utils.PadContract.THEIR_LENGTH_BETWEEN;
import static com.example.smartpad.utils.PadContract.THEIR_PERIOD_LENGTH;
import static com.example.smartpad.utils.PadContract.UID;
import static com.example.smartpad.utils.PadContract.USERS;

public class FirebaseUtils {

    public static User getUserFromDataSnapshot(DataSnapshot dataSnapshot){
        HashMap<Object, Object> map=(HashMap<Object,Object>) dataSnapshot.getValue();
        return getUserFromHashMap(map);
    }

    public static User getUserFromHashMap(HashMap<Object,Object> map){
        String name=map.get(NAME).toString();
        int age=Integer.parseInt(map.get(AGE).toString());
        int theirPeriodLength=Integer.parseInt(map.get(THEIR_PERIOD_LENGTH).toString());
        int theirLengthBetween=Integer.parseInt(map.get(THEIR_LENGTH_BETWEEN).toString());
        String uid=map.get(UID).toString();

        LinkedHashMap<String, Period> periods=new LinkedHashMap<>();
        if(map.get(PERIODS)!=null){
            HashMap<String, Object> hashMap=(HashMap<String, Object>) map.get(PERIODS);
            Iterator iterator=hashMap.entrySet().iterator();
            while (iterator.hasNext()){
                HashMap.Entry<String, Object> pair=(HashMap.Entry<String, Object>) iterator.next();
                periods.put(pair.getKey(),getPeriodFromHashMap((HashMap<Object,Object>) pair.getValue()));
            }
        }

        int padNumber=Integer.parseInt(map.get(PAD_NUMBER).toString());

        User user=new User(name, uid, age, theirPeriodLength, theirLengthBetween, periods, padNumber);
        return user;
    }

    public static Period getPeriodFromHashMap(HashMap<Object,Object> map){
        long startTime=Long.parseLong(map.get(START_TIME).toString());
        long endTime=Long.parseLong(map.get(END_TIME).toString());
        LinkedHashMap<String, PeriodDay> days=new LinkedHashMap<>();
        if(map.get(DAYS)!=null){
            HashMap<String, Object> hashMap=(HashMap<String, Object>) map.get(DAYS);
            Iterator iterator=hashMap.entrySet().iterator();
            while (iterator.hasNext()){
                HashMap.Entry<String, Object> pair=(HashMap.Entry<String, Object>) iterator.next();
                days.put(pair.getKey(),getPeriodDayFromHashMap((HashMap<Object,Object>) pair.getValue()));
            }
        }
        Period period=new Period(startTime, days, endTime);
        return period;
    }

    public static PeriodDay getPeriodDayFromHashMap(HashMap<Object,Object> map){
        LinkedHashMap<String, HourlyInstance> hourlyInstances=new LinkedHashMap<>();
        if(map.get(HOURLY_INSTANCES)!=null){
            HashMap<String, Object> hashMap=(HashMap<String, Object>) map.get(HOURLY_INSTANCES);
            Iterator iterator=hashMap.entrySet().iterator();
            while (iterator.hasNext()){
                HashMap.Entry<String, Object> pair=(HashMap.Entry<String, Object>) iterator.next();
                ArrayList<HourlyInstance> pastHours=new ArrayList<>(hourlyInstances.values());
                hourlyInstances.put(pair.getKey(),getHourlyInstanceFromHashMap((HashMap<Object,Object>) pair.getValue(), pastHours));
            }
        }
        ArrayList<HourlyInstance> hourlyInstancesArrayList=new ArrayList<>(hourlyInstances.values());
        Collections.sort(hourlyInstancesArrayList, new Comparator<HourlyInstance>() {
            @Override
            public int compare(HourlyInstance o1, HourlyInstance o2) {
                return Long.compare(o1.getHourTime(),o2.getHourTime());
            }
        });
        for(int i=0;i<hourlyInstancesArrayList.size();i++){
            HourlyInstance hourlyInstance=hourlyInstancesArrayList.get(i);
            int totalPadsChanged=0;
            for (int j=0; j<i; j++){
                totalPadsChanged+=hourlyInstancesArrayList.get(j).getPadsChanged();
            }
            Log.v("position", String.valueOf(i));
            Log.v("total pads changed", String.valueOf(totalPadsChanged));
            if((i==1 || i==2) && (totalPadsChanged>=1)){
                hourlyInstances.get(String.valueOf(hourlyInstance.getHourTime())).setHeaviness(90);
            }else if((totalPadsChanged==2) && (i==3)){
                hourlyInstances.get(String.valueOf(hourlyInstance.getHourTime())).setHeaviness(70);
            }else if((totalPadsChanged==1) && (i==3)){
                hourlyInstances.get(String.valueOf(hourlyInstance.getHourTime())).setHeaviness(50);
            }else if((totalPadsChanged==1) && (i>3)){
                hourlyInstances.get(String.valueOf(hourlyInstance.getHourTime())).setHeaviness(30);
            }else{

                hourlyInstances.get(String.valueOf(hourlyInstance.getHourTime())).setHeaviness(10);
            }
        }
        long dayTime=Long.parseLong(map.get(DAY_TIME).toString());
        PeriodDay periodDay=new PeriodDay(hourlyInstances, dayTime);
        return periodDay;
    }

    public static HourlyInstance getHourlyInstanceFromHashMap(HashMap<Object,Object> map, ArrayList<HourlyInstance> pastHours){
        Color color=getColorFromHashMap((HashMap<Object,Object>) map.get(COLOR));
        int clotting=Integer.parseInt(map.get(CLOTTING).toString());
        int saturation=Integer.parseInt(map.get(SATURATION).toString());
        long hourTime=Long.parseLong(map.get(HOUR_TIME).toString());
        int padsChanged=Integer.parseInt(map.get(PADS_CHANGED).toString());
        int heaviness=0;
        return new HourlyInstance(color, heaviness, clotting, saturation, hourTime, padsChanged);
    }

    public static Color getColorFromHashMap(HashMap<Object,Object> map){
        int red=Integer.parseInt(map.get(RED).toString());
        int green=Integer.parseInt(map.get(GREEN).toString());
        int blue=Integer.parseInt(map.get(BLUE).toString());
        return new Color(red, green, blue);
    }

    public static void createUserInFirebase(final User user, final String email, final String password, final View view, final Context context, final AppCompatActivity activity){
        FirebaseAuth firebaseAuth=FirebaseAuth.getInstance();
        firebaseAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                if(task.isSuccessful()){
                    String uid=task.getResult().getUser().getUid();
                    user.setUid(uid);
                    setValueOfUserInFirebase(user);
                    Intent intent=new Intent(context, UserActivity.class);
                    context.startActivity(intent);
                    activity.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                }else{
                    Exception e = task.getException();
                    if (e!=null) Snackbar.make(view,e.getLocalizedMessage(),Snackbar.LENGTH_SHORT).show();
                }
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Snackbar.make(view,e.getLocalizedMessage(),Snackbar.LENGTH_SHORT).show();
            }
        });
    }

    public static void setValueOfUserInFirebase(User user){
        DatabaseReference databaseReference=FirebaseDatabase.getInstance().getReference();
        databaseReference.child(USERS).child(user.getUid()).child(NAME).setValue(user.getName());
        databaseReference.child(USERS).child(user.getUid()).child(UID).setValue(user.getUid());
        databaseReference.child(USERS).child(user.getUid()).child(AGE).setValue(user.getAge());
        databaseReference.child(USERS).child(user.getUid()).child(THEIR_PERIOD_LENGTH).setValue(user.getTheirPeriodLength());
        databaseReference.child(USERS).child(user.getUid()).child(THEIR_LENGTH_BETWEEN).setValue(user.getTheirLengthBetween());
        databaseReference.child(USERS).child(user.getUid()).child(PERIODS).setValue(user.getPeriods());
        databaseReference.child(USERS).child(user.getUid()).child(PAD_NUMBER).setValue(user.getPadNumber());
    }
}
<file_sep>/app/src/main/java/com/example/smartpad/utils/PadContract.java
package com.example.smartpad.utils;

public class PadContract {
    public static final String NAME="name";
    public static final String UID="uid";
    public static final String EMAIL="email";
    public static final String PASSWORD="<PASSWORD>";
    public static final String AGE="age";
    public static final String THEIR_PERIOD_LENGTH="theirPeriodLength";
    public static final String THEIR_LENGTH_BETWEEN="theirLengthBetween";
    public static final String USERS="users";
    public static final String PERIODS="periods";
    public static final String START_TIME="startTime";
    public static final String DAYS="days";
    public static final String END_TIME="endTime";
    public static final String HOURLY_INSTANCES="hourlyInstances";
    public static final String DAY_TIME="dayTime";
    public static final String COLOR="color";
    public static final String HEAVINESS="heaviness";
    public static final String CLOTTING="clotting";
    public static final String SATURATION="saturation";
    public static final String RED="red";
    public static final String GREEN="green";
    public static final String BLUE="blue";
    public static final String HOUR_TIME="hourTime";
    public static final String PAD_NUMBER="padNumber";
    public static final String PADS_CHANGED="padsChanged";
}
