-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial progress made on SleepLog functionality(storing, displaying sleep data) Back button now works returning from settings to main view
- Loading branch information
1 parent
6fed0b8
commit a8601d7
Showing
9 changed files
with
220 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.sleeplog; | ||
|
||
public class LogEntry { | ||
private SleepSession _sleepSession; | ||
|
||
public LogEntry(SleepSession sleepSession) { | ||
_sleepSession = sleepSession; | ||
} | ||
|
||
public SleepSession get_sleepSession() { | ||
return _sleepSession; | ||
} | ||
|
||
//Outputs the ByteArray needed to write to SleepLog.txt | ||
// public byte[] toByteArray(){ | ||
// return _sleepSession.get(); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/example/sleeplog/SleepLogActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.example.sleeplog; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
/*TODO implement SleepLogActivity, make it list "bedtime -> waketime: duration date of the night" | ||
parse lines in txt, pass into new SleepSessions, send to Buttons in recyclerview. | ||
*/ | ||
public class SleepLogActivity extends AppCompatActivity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.sleeplog_main); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.example.sleeplog; | ||
|
||
import java.time.Duration; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
public class SleepSession { | ||
private Duration _sleepDuration; | ||
private LocalDateTime _bedTime, _wakeTime; | ||
private long _hours, _minutes, _seconds ; | ||
|
||
public SleepSession(LocalDateTime bedTime, LocalDateTime wakeTime) { | ||
|
||
_sleepDuration = Duration.between(bedTime, wakeTime); | ||
_bedTime = bedTime; | ||
_wakeTime = wakeTime; | ||
_hours = (long)_sleepDuration.toHours(); | ||
_minutes = (long)_sleepDuration.minusHours(_seconds).toMinutes(); | ||
_seconds = (long)_sleepDuration.minusHours(_seconds).minusMinutes(_minutes).getSeconds(); | ||
} | ||
|
||
public long get_hours() { | ||
return _hours; | ||
} | ||
|
||
public long get_minutes() { | ||
return _minutes; | ||
} | ||
|
||
public long get_seconds() { | ||
return _seconds; | ||
} | ||
|
||
// public String get_bedTime() { | ||
// return _bedTime.toString(); | ||
// } | ||
// | ||
// public String get_wakeTime() { | ||
// return _wakeTime.toString(); | ||
// } | ||
|
||
public byte[] get_bedBytes() { | ||
return _bedTime.toString().getBytes(); | ||
} | ||
|
||
public byte[] get_wakeBytes() { | ||
return _wakeTime.toString().getBytes(); | ||
} | ||
|
||
public byte[] get_byteArray() { | ||
return (_bedTime.toString() + _wakeTime.toString()).getBytes(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%02d", _hours) + ":" + String.format("%02d", _minutes) | ||
+ ":" + String.format("%02d", _seconds); | ||
} | ||
|
||
public static SleepSession parse(String text) { | ||
//substring it | ||
return new SleepSession(LocalDateTime.parse(text), LocalDateTime.parse(text)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<ScrollView | ||
android:layout_width="479dp" | ||
android:layout_height="835dp" | ||
tools:layout_editor_absoluteX="3dp" | ||
tools:layout_editor_absoluteY="-1dp"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" > | ||
|
||
<Button | ||
android:id="@+id/button5" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:text="Button" /> | ||
</LinearLayout> | ||
</ScrollView> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters