Skip to content

Commit

Permalink
Merge pull request #19 from sukhpalsingh/master
Browse files Browse the repository at this point in the history
#18 Adding total sleep time to the sleep summary
  • Loading branch information
fridgecow authored Aug 29, 2019
2 parents 72e21f7 + 8644200 commit b94cb7b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ protected void onCreate(Bundle savedInstanceState) {
currentMetric = findViewById(R.id.detectedwaketime);
Date wakeDate = new Date((long) mData.get(mData.size() - 1).getStart());
currentMetric.setText(timeFormat.format(wakeDate));

currentMetric = findViewById(R.id.totalsleeptime);
int sleepHours = (int) ((totalTime / (1000 * 60 * 60)) % 24);
int mins = (int) ((totalTime / (1000 * 60)) % 60);
currentMetric.setText(
(sleepHours > 9 ? sleepHours : "0" + sleepHours)
+ ":"
+ (mins > 9 ? mins : "0" + mins)
);
}

private void loadIntentExtras(){
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/layout/activity_sleep_summary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@
android:text="TextView"
android:textAppearance="@style/TextAppearance.AppCompat" />

<TextView
android:id="@+id/label_totalsleeptime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Total Tracking Time" />

<TextView
android:id="@+id/totalsleeptime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="TextView"
android:textAppearance="@style/TextAppearance.AppCompat" />

<Button
android:id="@+id/summary_export_button"
android:layout_width="match_parent"
Expand Down

0 comments on commit b94cb7b

Please sign in to comment.