Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New timer implementation #66

Merged
merged 62 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
1db3d09
Standardize colors for events, add new button bar
MrApplejuice Mar 7, 2024
54c18c0
Merge branch 'master' into new-timer-implementation-2
MrApplejuice Mar 10, 2024
d22fd44
Merge branch 'master' into new-timer-implementation-2
MrApplejuice Mar 10, 2024
12dcd19
Partial: Implement new diaper logging
MrApplejuice Mar 11, 2024
b94fad4
Merge branch 'master' into new-timer-implementation-2
MrApplejuice Mar 12, 2024
454d5d0
Update dependencies
MrApplejuice Mar 13, 2024
2c0efa6
Add logic for saving diaper changes state
MrApplejuice Mar 21, 2024
4a8ae41
Fix bug
MrApplejuice Mar 21, 2024
9c72dae
Fix serialization code for changes
MrApplejuice Mar 23, 2024
1f56d52
Instant update for newly created data items
MrApplejuice Mar 23, 2024
6a350aa
Remove old diaper logging interface
MrApplejuice Mar 23, 2024
a6d0316
Implement sleep-timer support for new interface
MrApplejuice Mar 25, 2024
c4926e9
Saving sleep times using new interface works
MrApplejuice Mar 25, 2024
811d98f
Add tummy-times logging
MrApplejuice Mar 26, 2024
c23feb4
Implement timer starting
MrApplejuice Mar 26, 2024
4f13f68
Add generic timer logging
MrApplejuice Mar 26, 2024
3792ca9
Add new autogrid layout
MrApplejuice Mar 27, 2024
858eb5b
Implement row-equalizer logic
MrApplejuice Mar 28, 2024
49477fa
Implement timer stopping
MrApplejuice Mar 28, 2024
7e538f7
Fix bug where controls were not added when a timer was already active
MrApplejuice Mar 29, 2024
1136145
Fix timer storing, not very elegant
MrApplejuice Apr 13, 2024
bc39ed2
Move TimerControllers to a more logical package
MrApplejuice Apr 13, 2024
83d15a3
Refactor TimerControllersV2
MrApplejuice Apr 14, 2024
fe21113
Fix bug with conflict resolution not limiting on child_id
MrApplejuice Apr 14, 2024
a53c97b
Implement notes entries
MrApplejuice Apr 16, 2024
9ba165c
Extract internal AmoutValuesGenerator class
MrApplejuice Apr 16, 2024
2e55a98
Fix basic storin of feedings
MrApplejuice Apr 23, 2024
debccad
Route debug messages through debug logger
MrApplejuice Apr 23, 2024
f34c47d
Fix visibility resetting
MrApplejuice Apr 23, 2024
316dc24
Merge remote-tracking branch 'github/master' into new-timer-implement…
MrApplejuice May 22, 2024
20770e7
Fix error handling
MrApplejuice May 24, 2024
2ae5d32
Fix notes editor not being submittable until a text message is entered
MrApplejuice May 25, 2024
f548b61
Remove a bunch replaced code
MrApplejuice May 27, 2024
6e779ca
Remove more dead code
MrApplejuice May 27, 2024
b810d09
Tune layout, fix AutoHGrid
MrApplejuice May 27, 2024
baedf11
Add warning if timer is running for more than 10 s already and someon…
MrApplejuice May 28, 2024
64cd0b1
Add separator line between logging and timeline items
MrApplejuice May 29, 2024
0eea892
Redesign feeding element
MrApplejuice Jun 19, 2024
178656f
Layout standardization
MrApplejuice Jun 27, 2024
f70e526
Implement pumping logging
MrApplejuice Jul 9, 2024
bcbb4ca
Fix amount implementation for pumping entries
MrApplejuice Jul 24, 2024
85488d5
Fix authcookie injection for clientv2
MrApplejuice Aug 6, 2024
abb26b7
Fix error handling during concurrent event handling
MrApplejuice Aug 7, 2024
f74d65d
Mostly fixed the storing and stopping race conditions
MrApplejuice Aug 9, 2024
d3c6621
Fix data deletion when logging out
MrApplejuice Aug 12, 2024
58423c3
Unify layout margins to not blend into each other
MrApplejuice Aug 12, 2024
e694a72
Fix overlapping time entries query
MrApplejuice Aug 21, 2024
117a147
Let time-ranges collapse to single time entry when start-time == end-…
MrApplejuice Aug 21, 2024
db0be97
Fix "adjust overlapping time entry" to not always adjust the start-time
MrApplejuice Aug 26, 2024
65a4b69
Update in-app help files to newest version
MrApplejuice Aug 28, 2024
1f6efc0
Update Dutch translation
MrApplejuice Aug 28, 2024
f152f38
Update target SDK version
MrApplejuice Sep 1, 2024
34df8c8
Fix doubly added notes and diaper editors
MrApplejuice Sep 1, 2024
02b84b2
Update all libraries, add babybuddy test version
MrApplejuice Sep 1, 2024
3e02837
Fix translations, bump version
MrApplejuice Sep 1, 2024
8da39e2
Fix logout dialog
MrApplejuice Sep 2, 2024
35e82d1
Reduce number of queried history items for increased reactivity
MrApplejuice Sep 2, 2024
b7ab746
Stage pre-release 2.4.0a
MrApplejuice Sep 2, 2024
06490ed
Fix async object reference issue
MrApplejuice Sep 2, 2024
4e2664a
Update store listing images
MrApplejuice Sep 2, 2024
266c3f3
Move save button to the right, remove old "quick_timer_entry"
MrApplejuice Sep 2, 2024
bb9f6de
Auto-select all text for horizontal dec/inc editor
MrApplejuice Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ android {
defaultConfig {
applicationId "eu.pkgsoftware.babybuddywidgets"
minSdkVersion 24
targetSdkVersion 33
versionCode 38
versionName "2.3.3"
targetSdk 34
versionCode 40
versionName "2.4.0b"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -105,28 +105,34 @@ android {
namespace 'eu.pkgsoftware.babybuddywidgets'
}

ext.camerax_version = "1.3.1"
ext.camerax_version = "1.3.4"

dependencies {
implementation 'com.squareup.phrase:phrase:1.2.0'

// Retrofit and jackson need to be compatible. Maybe(?) the matching the major versions
// is enough, but I'm not sure. This version works.
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-jackson:2.9.0'

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.1'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.10.1'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.10'

implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.7'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.concurrent:concurrent-futures:1.1.0'
implementation 'androidx.concurrent:concurrent-futures:1.2.0'

implementation "androidx.camera:camera-core:$camerax_version"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:$camerax_version"

implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-ktx:1.13.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
Expand All @@ -136,9 +142,9 @@ dependencies {
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4"
testImplementation 'org.json:json:20230618'

androidTestImplementation 'androidx.test:core-ktx:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test:core-ktx:1.6.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'

implementation project(':zxing-cpp')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package eu.pkgsoftware.babybuddywidgets

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import eu.pkgsoftware.babybuddywidgets.debugging.GlobalDebugObject
import java.io.IOException

class ActivityDatabaseV1(context: Context) : SQLiteOpenHelper(
context, "store", null, 1
) {
override fun onCreate(db: SQLiteDatabase) {
db.execSQL("create table global_kv (key_name text primary key, value text)")
db.execSQL("create table login_kv (key_name text primary key, value text)")
db.execSQL("create table child_kv (child INTEGER, key_name text, value text, primary key (child, key_name))")
}

override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
TODO("Not yet implemented")
}
}

class ActivityStore(context: Context) {
val openHelper = ActivityDatabaseV1(context)
val database = openHelper.writableDatabase
val jackOM = jacksonObjectMapper()

inline fun <reified K> genSet(table: String, value: K?, selectors: Map<String, String>) {
if (value == null) {
val query = "delete from $table where " + selectors.keys.joinToString(" and ") { "$it = ?" }
val args = selectors.values.toTypedArray()
database.execSQL(query, args)
} else {
val query = "insert or replace into $table (" +
selectors.keys.joinToString(", ") + ", value) values (" +
selectors.keys.joinToString(", ") { "?" } + ", ?)"
val valueString = jackOM.writeValueAsString(value)
database.execSQL(query, selectors.values.toTypedArray() + valueString)
}
}

inline fun <reified K> genGet(table: String, selectors: Map<String, String>): K? {
val query = "select value from $table where " + selectors.keys.joinToString(" and ") { "$it = ?" }
val cursor = database.rawQuery(query, selectors.values.toTypedArray())
var value = ""
try {
if (cursor.moveToNext()) {
value = cursor.getString(0)
cursor.close()
return jackOM.readValue(value, K::class.java)
}
}
catch (e: IOException) {
GlobalDebugObject.log("Failed to deserialize value from table $table: '$value'")
}
finally {
cursor.close()
}
return null
}

inline fun <reified K> globals(key: String): K? {
return genGet("global_kv", mapOf("key_name" to key))
}

inline fun <reified K> globals(key: String, value: K) {
genSet("global_kv", value, mapOf("key_name" to key))
}

inline fun <reified K> login(key: String): K? {
return genGet("login_kv", mapOf("key_name" to key))
}

inline fun <reified K> login(key: String, value: K) {
genSet("login_kv", value, mapOf("key_name" to key))
}

inline fun <reified K> child(child: Int, key: String): K? {
return genGet("child_kv", mapOf("child" to child.toString(), "key_name" to key))
}

inline fun <reified K> child(child: Int, key: String, value: K) {
genSet("child_kv", value, mapOf("child" to child.toString(), "key_name" to key))
}

fun close() {
database.close()
openHelper.close()
}

fun deleteAllData() {
database.delete("global_kv", "1", arrayOf())
database.delete("login_kv", "1", arrayOf())
database.delete("child_kv", "1", arrayOf())
}
}
Loading
Loading