package com.example.habitrack;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;

import java.io.ByteArrayOutputStream;
import java.util.Calendar;

import io.searchbox.annotations.JestId;


/**
 * HabitEvent
 *
 * Version 1.0
 *
 * Created by sshussai on 10/21/17.
 *
 */



public class HabitEvent {
    /**
     * Version 1.0
     * This class is the template for a habit event entity.
     *
     */

    private final Integer habitEventID;         // ID for the event
    private final Integer habitTypeID;          // ID for the corresponding habit type
    private String title;                       // title of the habit event
    private String comment;                     // comment for the habit event
    private Calendar date;                      // date of the habit event
    @JestId
    private String id;
    private String encodedPhoto;


    public HabitEvent(Integer heID, Integer htID) {
        this.habitEventID = heID;
        this.habitTypeID = htID;
        this.date = Calendar.getInstance();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Calendar getDate() {
        return date;
    }

    public void setDate(Calendar date) {
        this.date = date;
    }

    public Integer getHabitEventID() {
        return habitEventID;
    }

    public Integer getHabitTypeID() {
        return habitTypeID;
    }

    public String getPhoto() {
        return this.encodedPhoto;
    }

    public void setPhoto(String newEncodedPhoto) {
        this.encodedPhoto = newEncodedPhoto;
    }

    public Boolean searchInComment(String key){
        Boolean retVal = Boolean.FALSE;
        if(this.comment.contains(key)){
            retVal = Boolean.TRUE;
        }
        return retVal;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return (getHabitEventID() + "\n" + getTitle() + "\n" + getComment());
    }
}

@@ -863,24 +863,50 @@
  String id;%0A
+    // Photo related vars%0A
     private 
@@ -929,172 +929,1021 @@
 oto;
-%0A%0A%0A    public HabitEvent(Integer heID, Integer htID) %7B%0A        this.habitEventID = heID;%0A        this.habitTypeID = htID;%0A        this.date = Calendar.getInstance()
+                // compressed string representation of the photo%0A    private Bitmap decodedPhoto;                // Contains the actual photo. Will be null when saved on elastic search%0A    // isEmpty - true when event is default created by the app%0A    private Boolean isEmpty;                    // default event or not%0A%0A%0A    public HabitEvent(Integer heID, Integer htID) %7B%0A        this.habitEventID = heID;%0A        this.habitTypeID = htID;%0A        this.date = Calendar.getInstance();%0A        this.isEmpty = Boolean.TRUE;%0A    %7D%0A%0A    public String getEncodedPhoto() %7B%0A        return encodedPhoto;%0A    %7D%0A%0A    public void setEncodedPhoto(String encodedPhoto) %7B%0A        this.encodedPhoto = encodedPhoto;%0A    %7D%0A%0A    public Bitmap getDecodedPhoto() %7B%0A        return decodedPhoto;%0A    %7D%0A%0A    public void setDecodedPhoto(Bitmap decodedPhoto) %7B%0A        this.decodedPhoto = decodedPhoto;%0A    %7D%0A%0A    public Boolean getEmpty() %7B%0A        return isEmpty;%0A    %7D%0A%0A    public void setEmpty(Boolean empty) %7B%0A        isEmpty = empty
 ;%0A  
@@ -2577,32 +2577,34 @@
 edPhoto;%0A    %7D%0A%0A
+//
     public void 
@@ -2630,32 +2630,34 @@
 EncodedPhoto) %7B%0A
+//
         this.enc
@@ -2689,211 +2689,10 @@
 to;%0A
-    %7D%0A%0A    public Boolean searchInComment(String key)%7B%0A        Boolean retVal = Boolean.FALSE;%0A        if(this.comment.contains(key))%7B%0A            retVal = Boolean.TRUE;%0A        %7D%0A        return retVal;%0A
+//
     

edit habit event to take in a photo