diff --git a/app/src/main/java/com/cmput301f17t11/cupofjava/HabitEventTimeLineActivity.java b/app/src/main/java/com/cmput301f17t11/cupofjava/HabitEventTimeLineActivity.java index f250c9a..6a08e77 100644 --- a/app/src/main/java/com/cmput301f17t11/cupofjava/HabitEventTimeLineActivity.java +++ b/app/src/main/java/com/cmput301f17t11/cupofjava/HabitEventTimeLineActivity.java @@ -82,7 +82,7 @@ public void onItemClick(AdapterView parent, View view, int position, long id) ViewHabitEventActivity.class); intent5.putExtra("userName", userName); intent5.putExtra("userIndex", userIndex); - intent5.putExtra("habitIndex", position); + intent5.putExtra("habitEventIndex", position); startActivity(intent5); } }); diff --git a/app/src/main/java/com/cmput301f17t11/cupofjava/ViewHabitEventActivity.java b/app/src/main/java/com/cmput301f17t11/cupofjava/ViewHabitEventActivity.java index 9dde00d..3753db9 100644 --- a/app/src/main/java/com/cmput301f17t11/cupofjava/ViewHabitEventActivity.java +++ b/app/src/main/java/com/cmput301f17t11/cupofjava/ViewHabitEventActivity.java @@ -2,12 +2,14 @@ import android.app.Activity; import android.content.DialogInterface; +import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; +import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; @@ -27,8 +29,15 @@ //TODO: get the habit list in spinner dropdown public class ViewHabitEventActivity extends Activity { - ArrayList habitEvents; - + private TextView headingTextView; + private TextView habitTitleTextView; + private TextView habitDateBoxTextView; + private TextView habitCommentTextView; + private String userName; + private int userIndex; + //private int habitIndex; + private int habitEventIndex; + private Habit habit; /** * Launches Interface displaying the habit events and their * basic details. @@ -39,51 +48,24 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_habit_event); - FloatingActionButton newActivity = (FloatingActionButton) findViewById(R.id.eventAdder); - newActivity.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - - View view = LayoutInflater.from(ViewHabitEventActivity.this).inflate(R.layout.activity_new_habit_event, null); - - final EditText editComment = (EditText) view.findViewById(R.id.edit_comment); - - // Create dialog to add counter - AlertDialog.Builder builder = new AlertDialog.Builder(ViewHabitEventActivity.this); - builder.setMessage("Add Habit Event"); - builder.setView(view); - builder.setPositiveButton("Add", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { + final Intent intent = getIntent(); + this.userName = intent.getStringExtra("userName"); + this.userIndex = intent.getIntExtra("userIndex", 0); + this.habitEventIndex = intent.getIntExtra("habitEventIndex", 0); - // Check if counter Title and Reason are valid entires - if (!(editComment.getText().toString().equals("")) ) { - String comment = editComment.getText().toString(); - //Habit habit = new Habit("ok","ok",new Date()); //remove this; testing + SaveFileController saveFileController = new SaveFileController(); + ArrayList allEvents = saveFileController.getAllHabitEvents(getApplicationContext(), + this.userIndex); + HabitEvent habitEvent = allEvents.get(this.habitEventIndex); + headingTextView = (TextView) findViewById(R.id.habitEventDetailHeadingTextView); + habitTitleTextView = (TextView) + } - //HabitEvent myObject = new HabitEvent(habit, comment); - //habitEvents.add(myObject); - dialog.dismiss(); - } - - // Show error toast on invalid entry - else { - Toast.makeText(getApplicationContext(), "Make sure Habit and Comment are not blank", Toast.LENGTH_SHORT).show(); - } - - } - }); - builder.setNegativeButton("Cancel", null); - builder.setCancelable(false); - AlertDialog alert = builder.create(); - alert.show(); - } - }); - } + //public void deleteEventButton(View view){} } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_habit_time_line.xml b/app/src/main/res/layout/activity_habit_time_line.xml index ed7b39c..fa1d032 100644 --- a/app/src/main/res/layout/activity_habit_time_line.xml +++ b/app/src/main/res/layout/activity_habit_time_line.xml @@ -13,27 +13,14 @@ android:layout_height="65dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" - android:textAlignment="center" - android:padding="4dp" android:background="@drawable/check_box_dimens" + android:padding="4dp" + android:textAlignment="center" app:layout_constraintHorizontal_bias="0.484" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"/> - - + + diff --git a/app/src/main/res/layout/activity_view_habit_event.xml b/app/src/main/res/layout/activity_view_habit_event.xml index 3a48948..9dc43a7 100644 --- a/app/src/main/res/layout/activity_view_habit_event.xml +++ b/app/src/main/res/layout/activity_view_habit_event.xml @@ -6,19 +6,77 @@ android:layout_height="match_parent" tools:context="com.cmput301f17t11.cupofjava.ViewHabitEventActivity"> - + + + + + + + +