WIP
This project was forked from https://github.com/j4velin/Pedometer. I asked GitHub support to detach this from the parent repo, because my intention is to continue making changes and publish it to the Play Store.
Lightweight (and MAD) Pedometer app for Android using the hardware step sensor to track your steps without being tracked.
License: Apache License 2.0
WIP
This project was forked from https://github.com/j4velin/Pedometer. I asked GitHub support to detach this from the parent repo, because my intention is to continue making changes and publish it to the Play Store.
The StepsWorkManager runs a process that creates a notification every 15 minutes. We don't want this notification to alert the user or produce a sound.
The current targetSdk/compileSdk is 30, but several of the latest libraries (AppCompat, ViewModel, WorkManager, Material Components, etc.) require targetSdk/compileSdk 31. Check #14 out for some complications with WorkManager.
The app is currently using the milliseconds since January 1st, 1970 as the id for the steps table. This is problematic because the milliseconds since that date are different for different time zones. Also, we don't need that much granularity, because the app is only interested in tracking and showing the steps on a daily basis.
For that reason, using the day number since January 1st, 1970 is good enough.
The HomeFragment is currently obtaining the data it requires directly from the repository and in the Main dispatcher.
Instead of doing it this way, we should introduce a HomeViewModel that provides all the information HomeFragment requires in the form of a HomeUiState.
In order to simplify the code, and facilitate the migration to Kotlin and Jetpack Compose, the already existing Widget code was deleted. Consider re-implementing the functionality in the future in case it provides enough value.
There is an issue with the CSV import feature, because it adds the current count since last boot time to today's count.
The allowMainThreadQueries()
configuration was added to PedometerDatabase
as a temporary measure to be able to query directly from the main (or UI) thread. This is discouraged, but it was added to simplify the migration to Room.
The circular reveal animation when switching the theme was introduced to the Android world by the guys at Telegram. That transition looks great and it would be awesome to get my hands dirty trying to implement it here.
The Telegram Android app is open source and this blogpost breaks down how that animation is accomplished.
DataStore is Google's recommended solution to store data locally, and is the suggested replacement for the SharedPreferences.
Pedometer currently uses the SensorListener
service to listen to SensorManager
updates, however this is very inefficient, because it attempts to keep on listening all the time.
This post suggests using JobScheduler instead to query for the steps count every few minutes (every 15 minutes for example).
JobScheduler
however, is a system specific library, and is available on Android API 23+ only. For that reason, the app should be migrated to use Jetpack's WorkManager instead.
Timber is a small and cool library that is helpful to log data.
Currently the app is trying to log data to a file in Logger#log(String)
, but that fails and is probably no longer a good practice.
Dagger Hilt is Google's recommended library for Dependency Injection in Android.
KSP is Google's replacement for kapt
. It basically provides the same functionality but in a much more efficient way.
The Navigation Component is Google's recommended library to perform Navigation in Android apps. I want to introduce it to the Codebase and configure it with a BottomNavigationView, that will have two tabs at the beginning: Home and Settings.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
androidx.hilt:hilt-compiler
, androidx.hilt:hilt-work
)com.google.dagger:hilt-android-testing
, com.google.dagger:hilt-android-gradle-plugin
, com.google.dagger:hilt-compiler
, com.google.dagger:hilt-android
)androidx.room:room-runtime
, androidx.room:room-ktx
, androidx.room:room-compiler
)androidx.work:work-testing
, androidx.work:work-runtime-ktx
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
androidx.activity:activity-ktx
, androidx.activity:activity-compose
)androidx.test:runner
, androidx.test:rules
)androidx.compose.ui:ui-tooling
, androidx.compose.ui:ui-test-junit4
, androidx.compose.material:material
, androidx.compose.foundation:foundation
)androidx.lifecycle:lifecycle-viewmodel-ktx
, androidx.lifecycle:lifecycle-viewmodel-compose
)androidx.navigation:navigation-ui-ktx
, androidx.navigation:navigation-fragment-ktx
).github/workflows/android.yml
actions/checkout v3
actions/setup-java v3
actions/checkout v3
actions/setup-java v3
gradle.properties
settings.gradle.kts
build.gradle.kts
app/build.gradle.kts
com.android.tools:desugar_jdk_libs 1.1.5
gradle/libs.versions.toml
androidx.activity:activity-compose 1.4.0
androidx.activity:activity-ktx 1.4.0
com.android.tools.build:gradle 7.2.0
androidx.hilt:hilt-work 1.0.0
androidx.hilt:hilt-compiler 1.0.0
androidx.test.ext:junit 1.1.3
androidx.test:rules 1.4.0
androidx.test:runner 1.4.0
androidx.appcompat:appcompat 1.4.2
androidx.compose.foundation:foundation 1.1.1
androidx.compose.material:material 1.1.1
com.google.android.material:compose-theme-adapter 1.1.5
androidx.compose.ui:ui-test-junit4 1.1.1
androidx.compose.ui:ui-tooling 1.1.1
androidx.arch.core:core-testing 2.1.0
com.github.j4velin.EazeGraph:EazeGraph 1.0.3
androidx.fragment:fragment-ktx 1.4.1
com.google.dagger:hilt-android 2.42
com.google.dagger:hilt-compiler 2.42
com.google.dagger:hilt-android-gradle-plugin 2.42
com.google.dagger:hilt-android-testing 2.42
junit:junit 4.13.2
org.jetbrains.kotlin:kotlin-gradle-plugin 1.6.10
com.squareup.logcat:logcat 0.1
com.google.android.material:material 1.4.0
androidx.navigation:navigation-fragment-ktx 2.4.2
androidx.navigation:navigation-ui-ktx 2.4.2
androidx.preference:preference-ktx 1.2.0
androidx.room:room-compiler 2.4.2
androidx.room:room-ktx 2.4.2
androidx.room:room-runtime 2.4.2
androidx.lifecycle:lifecycle-viewmodel-compose 2.4.1
androidx.lifecycle:lifecycle-viewmodel-ktx 2.4.1
androidx.work:work-runtime-ktx 2.7.1
androidx.work:work-testing 2.7.1
org.jlleitschuh.gradle.ktlint 10.3.0
gradle/wrapper/gradle-wrapper.properties
gradle 7.4.2
The app is currently using SQLiteOpenHelper
, which works fine, however we can't do things like observing the database to be automatically notified about changes.
That is why we want to migrate to Room
We might go with showing the last 7 days only, as the app currently does.
Starting with API 29, the android.permission.ACTIVITY_RECOGNITION permission is required on devices running Android 10+.
The app should be properly asking for this permission using runtime permissions best practices.
Also, the com.google.android.gms.permission.ACTIVITY_RECOGNITION
permission can be removed from the Manifest, as it is not required.
Taking the idea from the Official Jetpack Compose Samples, I wanna rename the app to JetCounter.
Rename the package to dev.sjaramillo.jetcounter
.
The current logic to store the steps count in the daily_steps
db table is as follows:
day (long) | steps (long) |
---|---|
-1 | steps since boot |
... | that day's steps |
yesterday | yesterday's steps |
today | offset (probably negative) |
That makes today's steps different than the rest of the days, and in order to obtain the real number of today's steps we need to sum the sensor steps since boot plus today's offset. This is a bit cumbersome and error prone.
The proposed new solution is:
day (long) | steps (long) |
---|---|
-2 | steps offset |
-1 | steps since boot |
... | that day's steps |
yesterday | yesterday's steps |
today | today's steps |
As can be observed, today's steps are simply today's steps, no need to calculate anything else. There are a few considerations that we will have to take into account to make this work correctly. Like what to do when the device is rebooted when the user has done some steps that day already.
Material You is the new kid in the design block. Migrate to it when possible ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.