Skip to content

Commit

Permalink
fridgecow#18 Adding total sleep time to the sleep summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukhpal Singh committed Aug 13, 2019
1 parent 72e21f7 commit 8b07068
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 Sleep 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 8b07068

Please sign in to comment.