Compare commits
81 Commits
hotfix/2.1
...
hiqua-patc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a96b7f0fba | ||
|
|
f1a003fabf | ||
|
|
856a0726f7 | ||
|
|
df97b1fd4f | ||
| dc678e59df | |||
|
|
d95084500f | ||
|
6f7215b46f
|
|||
|
|
c423d2b3ca | ||
|
|
758fc56277 | ||
|
|
c7d1e92cae | ||
|
|
d24dcbf2ca | ||
|
|
579b33cc78 | ||
|
|
1a3e6315a1 | ||
|
|
7f4d06d15d | ||
|
|
b8033a6012 | ||
|
404671546c
|
|||
|
a94c6e8b9f
|
|||
|
da09df2dd1
|
|||
|
9f5da7b4fe
|
|||
|
e42d41ef30
|
|||
|
5498ff8a87
|
|||
|
20dcc7929b
|
|||
|
1283cf979d
|
|||
|
0a493ff065
|
|||
|
16cd249bae
|
|||
|
d136572960
|
|||
|
318aa3c821
|
|||
|
73712e0d10
|
|||
| bf504641c6 | |||
|
2154d8c192
|
|||
|
4c5a722dc5
|
|||
| ee39ff0eda | |||
|
|
6a9c3a36eb | ||
|
|
99ccb44ad3 | ||
|
|
8c0655c352 | ||
|
|
335f8c32fd | ||
|
|
f77c064722 | ||
|
|
8b0b757f04 | ||
| 458c9f3b15 | |||
| dfa74960b3 | |||
| f082842fbe | |||
| d4d818a085 | |||
|
|
f074d0331d | ||
|
|
f94bc62a94 | ||
| b0097fa45e | |||
|
|
15fa1fea8c | ||
| 31368cff45 | |||
| b44dd96dd3 | |||
|
|
08fab0cd8d | ||
|
|
a142685d2e | ||
| a7a95f2030 | |||
|
|
d3c90481be | ||
| f9bb0d7d7b | |||
| f23a1bedee | |||
| dcf31ba115 | |||
|
|
5409a324e8 | ||
|
|
504362e680 | ||
|
|
0ce2f8fae2 | ||
| 2fc6c67432 | |||
| 459cf02642 | |||
| 44cb64601f | |||
|
|
dd47d4cf08 | ||
|
|
8912a9d73c | ||
|
|
9bd1c6f685 | ||
|
|
e15e06034c | ||
|
|
a6180a5049 | ||
|
|
7c69b17e77 | ||
|
|
602a40a532 | ||
|
|
e00998f913 | ||
|
|
af5914c2db | ||
|
|
6c5f70638a | ||
|
|
ba88552919 | ||
|
|
8c90c4f68d | ||
|
|
08eb1a600d | ||
|
|
8ea0480d4a | ||
|
|
36ee39589e | ||
|
|
ac7a721940 | ||
|
|
b36ca8673a | ||
|
|
7cfac486f9 | ||
|
|
21dd413ab5 | ||
|
|
39e10638b5 |
3
.github/workflows/main.yml
vendored
@@ -9,6 +9,7 @@ on:
|
||||
jobs:
|
||||
Test:
|
||||
runs-on: self-hosted
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v1
|
||||
@@ -17,7 +18,7 @@ jobs:
|
||||
run: ./build.sh build
|
||||
|
||||
- name: Run Android tests
|
||||
run: ./build.sh android-tests-parallel 24 25 26 28 30 31
|
||||
run: ./build.sh android-tests-parallel 28 29 30 31 32 33
|
||||
|
||||
- name: Upload artifacts
|
||||
if: always()
|
||||
|
||||
5
.gitignore
vendored
@@ -12,13 +12,8 @@
|
||||
.idea
|
||||
.secret
|
||||
build
|
||||
build/
|
||||
captures
|
||||
local.properties
|
||||
node_modules
|
||||
*xcuserdata*
|
||||
*.sketch
|
||||
/design
|
||||
/releases
|
||||
/screenshots
|
||||
crowdin.yml
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
cd "$(dirname "$0")"
|
||||
if [ -z "$GPG_PASSWORD" ]; then
|
||||
echo Env variable GPG_PASSWORD must be defined
|
||||
exit 1
|
||||
fi
|
||||
gpg \
|
||||
--quiet \
|
||||
--batch \
|
||||
--yes \
|
||||
--decrypt \
|
||||
--passphrase="$GPG_PASSWORD" \
|
||||
--output secret.tar.gz \
|
||||
secret
|
||||
tar -xzf secret.tar.gz
|
||||
rm secret.tar.gz
|
||||
BIN
.secret/secret
15
CHANGELOG.md
@@ -1,20 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [2.1.2] -- 2023-05-26
|
||||
### Fixed
|
||||
- Fix bug that caused widget to enter checkmark on wrong date (@iSoron, #1541)
|
||||
- Fix widget corners on Android 12 (@iSoron)
|
||||
- Fix bug that caused notes to be lost when editing a checkmark (@iSoron, #1566)
|
||||
- Prevent soft keyboard from covering entry popup (@iSoron)
|
||||
- Accept comma (instead of dot) in certain locales (@iSoron)
|
||||
|
||||
### Changed
|
||||
- Remove update delay after entering a checkmark (@iSoron)
|
||||
|
||||
### Removed
|
||||
- Remove stack widgets (@iSoron)
|
||||
|
||||
|
||||
## [2.1.1] -- 2022-09-24
|
||||
### Fixed
|
||||
- Fix Tasker plugin (@iSoron, #1503)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
plugins {
|
||||
val kotlinVersion = "1.6.10"
|
||||
id("com.android.application") version ("7.0.3") apply (false)
|
||||
val kotlinVersion = "1.7.21"
|
||||
id("com.android.application") version ("7.3.1") apply (false)
|
||||
id("org.jetbrains.kotlin.android") version kotlinVersion apply (false)
|
||||
id("org.jetbrains.kotlin.kapt") version kotlinVersion apply (false)
|
||||
id("org.jetbrains.kotlin.android.extensions") version kotlinVersion apply (false)
|
||||
id("org.jetbrains.kotlin.multiplatform") version kotlinVersion apply (false)
|
||||
id("org.jlleitschuh.gradle.ktlint") version "10.2.1"
|
||||
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
|
||||
}
|
||||
|
||||
apply {
|
||||
|
||||
20
build.sh
@@ -85,10 +85,10 @@ android_setup() {
|
||||
$AVDMANAGER delete avd --name $AVDNAME
|
||||
|
||||
log_info "Creating new Android virtual device (API $API)..."
|
||||
(echo "y" | $SDKMANAGER --install "system-images;android-$API;default;x86_64") || return 1
|
||||
(echo "y" | $SDKMANAGER --install "system-images;android-$API;google_apis;x86_64") || return 1
|
||||
$AVDMANAGER create avd \
|
||||
--name $AVDNAME \
|
||||
--package "system-images;android-$API;default;x86_64" \
|
||||
--package "system-images;android-$API;google_apis;x86_64" \
|
||||
--device "Nexus 4" || return 1
|
||||
|
||||
flock -u 10
|
||||
@@ -217,28 +217,20 @@ android_test_parallel() {
|
||||
(
|
||||
LOG=build/android-test-$API.log
|
||||
log_info "API $API: Running tests..."
|
||||
android_test $API 1>$LOG 2>&1
|
||||
ret_code=$?
|
||||
if [ $ret_code = 0 ]; then
|
||||
if android_test $API 1>$LOG 2>&1; then
|
||||
log_info "API $API: Passed"
|
||||
else
|
||||
log_error "API $API: Failed"
|
||||
fi
|
||||
pkill -9 -f ${AVD_PREFIX}${API}
|
||||
exit $ret_code
|
||||
)&
|
||||
PIDS+=" $!"
|
||||
done
|
||||
|
||||
# Check exit codes
|
||||
success=0
|
||||
RET_CODE=0
|
||||
for pid in $PIDS; do
|
||||
wait $pid
|
||||
ret_code=$?
|
||||
if [ $ret_code != 0 ]; then
|
||||
success=1
|
||||
fi
|
||||
echo pid=$pid ret_code=$ret_code success=$success
|
||||
wait $pid || RET_CODE=1
|
||||
done
|
||||
|
||||
# Print all logs
|
||||
@@ -248,7 +240,7 @@ android_test_parallel() {
|
||||
echo "::endgroup::"
|
||||
done
|
||||
|
||||
return $success
|
||||
return $RET_CODE
|
||||
}
|
||||
|
||||
android_build() {
|
||||
|
||||
@@ -33,7 +33,7 @@ The repository will be downloaded to the directory `uhabits`.
|
||||
2. When the IDE asks you for the project location, select `uhabits` and click "Ok".
|
||||
3. Android Studio will spend some time indexing the project. When this is complete, click the toolbar icon "Sync Project with Gradle File", located near the right corner of the top toolbar.
|
||||
4. The operation will likely fail several times due to missing Android SDK components. Each time it fails, click the link "Install missing platforms", "Install build tools", etc, and try again.
|
||||
5. To test the application, create a virtual Android device using the menu "Tools" and "AVD Manager". The default options should work fine, but free to customize the device.
|
||||
5. To test the application, create a virtual Android device using the menu "Tools" and "AVD Manager". The default options should work fine, but feel free to customize the device.
|
||||
6. Click the menu "Run" and "uhabits-android". The application should launch.
|
||||
|
||||
|
||||
|
||||
54
docs/TEST.md
@@ -2,51 +2,25 @@
|
||||
|
||||
Loop Habit Tracker has a fairly large number of automated tests to reduce the chance of bugs being silently introduced in our code base. The tests are divided into three categories:
|
||||
|
||||
* **Small tests:** These tests run very quickly on the developer's computer, inside a JVM, and do not need an Android emulator or device. They typically test the correctness of core functions of the application, such as the computation of scores and streaks.
|
||||
* **Medium tests:** These tests require an Android emulator or device, but they are still quite fast to run, since only individual classes are tested. The app itself does not need to be launched. Examples include *view tests*, which render our custom views on the device and compare them against prerendered images.
|
||||
* **Large tests:** These are end-to-end tests, which launch the application on an Android emulator and interact with it by touching the screen, much like a regular user.
|
||||
- **Unit tests:** These tests run very quickly on the developer's computer, inside a JVM, and do not need an Android emulator or device. They typically test the correctness of core functions of the application, such as the computation of scores and streaks.
|
||||
- **Instrumented tests:** These tests require an Android emulator or device. _Medium_ instrumented tests are still quite fast to run, since only individual classes are tested. The app itself does not need to be launched. Examples include _view tests_, which render our custom views on the device and compare them against prerendered images. _Large_ instrumented tests launch the application on an Android emulator and interact with it by touching the screen, much like a regular user.
|
||||
|
||||
## Running small tests
|
||||
## Running unit tests
|
||||
|
||||
Small tests can be launched by running `./gradlew test` or by right-clicking a particular class/method in Android Studio and selecting "Run testMethod()" or "Run ClassTest". An alternative way is to use `build.sh`, the script used by our continuous integration server. By running `./build.sh build`, the script will automatically build and run all small tests.
|
||||
Unit tests can be launched by running `./gradlew test` or by right-clicking a particular class/method in Android Studio and selecting "Run testMethod()" or "Run ClassTest". An alternative way is to use `build.sh`, the script used by our continuous integration server. By running `./build.sh build`, the script will automatically build and run all small tests.
|
||||
|
||||
## Running medium tests
|
||||
## Running instrumented tests
|
||||
|
||||
To run medium tests, it is recommended to use the `build.sh` script:
|
||||
To run medium tests, it is recommended to use the `build.sh` script.
|
||||
|
||||
./build.sh build
|
||||
./build.sh medium-tests
|
||||
1. Run `./build.sh android-setup API` to create the emulator, where `API` is the desired API level.
|
||||
2. Run `./build.sh android-tests API` to run the tests on a single API.
|
||||
3. Run `./build.sh android-tests-parallel API API...` to run the tests on multiple APIs in parallel.
|
||||
|
||||
Note that instrumented tests are designed to run on a clean install, inside an emulator. They will not work on actual devices. All tests are also designed for a particular screen size, namely the Nexus 4 configuration (4.7" 768x1280 xhdpi), and a particular locale, namely English (US). Furthermore:
|
||||
|
||||
For this script to succeed, make sure that an emulator is currently running, or that a device (with developer mode activated) is connected via USB.
|
||||
- No additional apps should be installed on the device;
|
||||
- The homescreen must look exactly like it was when the emulator was originally created, with no additional icons or widgets;
|
||||
- All animations must be manually disabled.
|
||||
|
||||
**WARNING!** This script will uninstall the app prior to testing it, and therefore delete all user data!
|
||||
|
||||
|
||||
If there are failing view tests (that is, if some custom views do not render exactly like the prerendered images we have), then the script `./build.sh fetch-images` can be used to download both the actual and the expected images from the device. The images will be downloaded from the device into the folder `tmp/`. After verifying the differences, if you feel that the actual images are actually fine and should replace the prerendered ones, then run `./build.sh accept-images`.
|
||||
|
||||
## Running large tests
|
||||
|
||||
Large tests are significantly more complicated to run. In particular, they require:
|
||||
|
||||
* An Android emulator; they will **not** work on actual devices;
|
||||
* A vanilla x86 AOSP image; they will **not** work with Google API images;
|
||||
* A particular screen size, namely the Nexus 4 configuration on Android Studio (4.7 768x1280 xhdpi);
|
||||
* A particular locale, namely English (US).
|
||||
|
||||
Furthermore:
|
||||
|
||||
* No additional apps should be installed on the device;
|
||||
* The homescreen must look exactly like it was when the emulator was originally created, with no additional icons or widgets;
|
||||
* Developer mode must be activated, and all animations must be manually disabled.
|
||||
|
||||
Only the following Android versions are supported by our test suite:
|
||||
|
||||
* Android 7.0 (API 24)
|
||||
* Android 7.1.1 (API 25)
|
||||
* Android 8.0 (API 26)
|
||||
* Android 8.1 (API 27)
|
||||
* Android 9.0 (API 28)
|
||||
* Android 10.0 (API 29)
|
||||
|
||||
After creating an emulator and configuring it exactly as described above, launch it, wait for it to finish booting up, then run `./build.sh large-tests`. As mentioned before, this script will uninstall the app before testing it, and therefore will delete all the user data.
|
||||
If there are failing view tests (that is, if some custom views do not render exactly like the prerendered images we have), then both the actual and expected images will be automatically downloaded from the device to the folder `uhabits-android/build/outputs`. After verifying the differences, if you feel that the actual images are actually fine and should replace the prerendered ones, then run `./build.sh android-accept-images`.
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
2
landing/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
out/
|
||||
.sass-cache
|
||||
@@ -1,27 +0,0 @@
|
||||
haml := src/*.haml
|
||||
sass := src/*.sass
|
||||
|
||||
html := $(patsubst src/%, out/%, $(patsubst %.haml,%.html,$(wildcard $(haml))))
|
||||
css := $(patsubst src/%, out/%, $(patsubst %.sass,%.css,$(wildcard $(sass))))
|
||||
src := $(wildcard src/**)
|
||||
|
||||
compile: $(html) $(css)
|
||||
@rsync -rupE assets/ out/
|
||||
|
||||
out/%.css: src/%.sass $(src)
|
||||
@echo ' sass $<'
|
||||
@mkdir -p `dirname $@`
|
||||
@sass $< $@
|
||||
|
||||
out/%.html: src/%.haml $(src)
|
||||
@echo ' haml $<'
|
||||
@mkdir -p `dirname $@`
|
||||
@haml -E UTF-8 $< $@
|
||||
|
||||
push:
|
||||
rsync -avP out/ axavier.org:/www/loophabits.org/
|
||||
|
||||
clean:
|
||||
@rm -rfv out
|
||||
@rm -rfv tmp
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
Loop Habit Tracker Landing Page
|
||||
===============================
|
||||
|
||||
This folder contains the source code that generates the project landing page, currently hosted at https://loophabits.org/
|
||||
|
||||
Pull requests with ideas for improving it are very welcome.
|
||||
|
||||
Build instructions
|
||||
------------------
|
||||
|
||||
1. Install `haml`:
|
||||
```bash
|
||||
sudo apt install ruby-haml
|
||||
```
|
||||
2. Install `pandoc-ruby`:
|
||||
```bash
|
||||
gem install pandoc-ruby
|
||||
```
|
||||
3. Run `Makefile`
|
||||
```bash
|
||||
make
|
||||
```
|
||||
4. View the results (using, for example, [npm serve](https://www.npmjs.com/package/serve))
|
||||
```bash
|
||||
npm serve out/
|
||||
```
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<meta http-equiv="Refresh" content="0; url='https://github.com/iSoron/uhabits/discussions/689'" />
|
||||
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 458 KiB |
7
landing/assets/lib/css/bootstrap.min.css
vendored
2
landing/assets/lib/js/jquery.min.js
vendored
|
Before Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 28 KiB |
@@ -1,106 +0,0 @@
|
||||
!!! 5
|
||||
%html
|
||||
%head
|
||||
%meta(charset="UTF-8")
|
||||
%link(href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css")
|
||||
%meta(name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no")
|
||||
%title Loop Habit Tracker
|
||||
%link(rel="stylesheet" type="text/css" href="lib/css/bootstrap.min.css")
|
||||
%link(rel="stylesheet" type="text/css" href="index.css")
|
||||
|
||||
%body
|
||||
.navbar.navbar-expand-md.navbar-light.bg-light
|
||||
%a.navbar-brand(href="/")
|
||||
%b Loop
|
||||
Habit Tracker
|
||||
%button.navbar-toggler(type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation")
|
||||
%span.navbar-toggler-icon
|
||||
#navbar.collapse.navbar-collapse
|
||||
%ul.navbar-nav.mr-auto.mt-2.mt-lg-0
|
||||
%li.nav-item
|
||||
%a.nav-link(href="faq.html") FAQ
|
||||
%li.nav-item
|
||||
%a.nav-link(href="privacy.html") Privacy
|
||||
%li.nav-item
|
||||
%a.nav-link(href="https://source.loophabits.org") Source Code
|
||||
%li.nav-item
|
||||
%a.nav-link(href="https://translate.loophabits.org") Translate
|
||||
|
||||
.jumbotron.jumbotron-fluid
|
||||
.site-wrapper
|
||||
.container
|
||||
.row.vertical-align
|
||||
.col-md
|
||||
%h1.display-4
|
||||
Get your life on track
|
||||
%p.lead
|
||||
With daily reminders, beautiful charts and insightful statistics,
|
||||
Loop Habit Tracker™ helps you create and maintain great habits. Completely free and open-source.
|
||||
|
||||
.store-badges
|
||||
%a(href="https://play.google.com/store/apps/details?id=org.isoron.uhabits")
|
||||
%img(src="images/google-play.png")
|
||||
%a(href="https://f-droid.org/en/packages/org.isoron.uhabits/")
|
||||
%img(src="images/f-droid.png")
|
||||
.col-md
|
||||
.s2
|
||||
%img.screenshot(src="screenshots/uhabits1.png")
|
||||
.s1
|
||||
%img.screenshot(src="screenshots/uhabits4.png")
|
||||
|
||||
.section.screenshots
|
||||
%span
|
||||
%a(href="screenshots/uhabits1.png")
|
||||
%img(src="screenshots/uhabits1_th.png")
|
||||
%a(href="screenshots/uhabits2.png")
|
||||
%img(src="screenshots/uhabits2_th.png")
|
||||
%a(href="screenshots/uhabits3.png")
|
||||
%img(src="screenshots/uhabits3_th.png")
|
||||
%span
|
||||
%a(href="screenshots/uhabits4.png")
|
||||
%img(src="screenshots/uhabits4_th.png")
|
||||
%a(href="screenshots/uhabits5.png")
|
||||
%img(src="screenshots/uhabits5_th.png")
|
||||
|
||||
.section
|
||||
.feature-header
|
||||
%h1
|
||||
Features
|
||||
.container
|
||||
.row
|
||||
.col-md
|
||||
%ul
|
||||
%li
|
||||
%h3 Habit score
|
||||
Loop has an advanced formula for calculating the strength of your habits. Every repetition makes your habit stronger and every missed day makes it weaker. A few missed days after a long streak, however, will not completely destroy your progress, unlike many other don't-break-the-chain apps.
|
||||
|
||||
%li
|
||||
%h3 Flexible schedules
|
||||
In addition to daily habits, Loop supports habits with more complex schedules, such as 3 times per week or every other day.
|
||||
%li
|
||||
%h3 Reminders
|
||||
Schedule notifications to remind you of your habits. Each habit can have its own reminder, at a chosen time of the day. Easily check or dismiss your habit directly from the notification.
|
||||
%li
|
||||
%h3 Widgets
|
||||
Be reminded of your habits whenever you unlock your phone. Colorful widgets allow you to track your habits directly from your home screen, without even opening the app.
|
||||
.col-md
|
||||
%ul
|
||||
%li
|
||||
%h3 Take control of your data
|
||||
If you want to further analyze your data, or move it to another service, Loop allows you to export it to spreadsheets (CSV) or to a database file (SQLite). For power users, check marks can be added through task automation apps such as Tasker.
|
||||
%li
|
||||
%h3 No limitations
|
||||
Track as many habits as you wish. Loop imposes no artificial limits on how many habits you can have. All features are available to all users, and there are no in-app purchases.
|
||||
%li
|
||||
%h3 Completely ad-free and open source
|
||||
There are no advertisements, annoying notifications or intrusive permissions in this app, and there will never be. The app is completely open-source (GPLv3).
|
||||
%li
|
||||
%h3 Works offline and respects your privacy
|
||||
Loop doesn't require an Internet connection or online account registration. Your confidential data is never sent to anyone. Neither the developers nor any third-parties have access to it.
|
||||
|
||||
.section.footer
|
||||
Copyright © 2016–2020, Alinson Santos Xavier. All Rights Reserved.
|
||||
|
||||
|
||||
%script(type="text/javascript" src="lib/js/jquery.min.js")
|
||||
%script(type="text/javascript" src="lib/js/bootstrap.bundle.min.js")
|
||||
@@ -1,104 +0,0 @@
|
||||
html, body
|
||||
max-width: 100%
|
||||
overflow-x: hidden
|
||||
|
||||
body
|
||||
font-family: 'Open Sans', sans-serif
|
||||
padding-bottom: 0
|
||||
|
||||
a, a:hover
|
||||
text-decoration: none
|
||||
|
||||
.navbar
|
||||
box-shadow: rgba(0,0,0,0.4) 0px 0px 20px
|
||||
background-color: white !important
|
||||
|
||||
.nav-link
|
||||
margin: 0px 18px
|
||||
|
||||
.section
|
||||
background-color: transparent
|
||||
padding: 18px 0px
|
||||
|
||||
.container
|
||||
ul
|
||||
list-style-type: none
|
||||
h3
|
||||
font-size: 16px
|
||||
font-weight: bold
|
||||
margin: 18px 0px 0px 0px
|
||||
|
||||
.screenshots
|
||||
text-align: center
|
||||
background-color: #222
|
||||
img
|
||||
margin: 0.5%
|
||||
border-radius: 10px
|
||||
border: 3px solid #fff2
|
||||
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5)
|
||||
max-width: 17%
|
||||
|
||||
.footer
|
||||
color: #888
|
||||
background-color: #222
|
||||
text-align: center
|
||||
font-size: 12px
|
||||
|
||||
.jumbotron
|
||||
background: linear-gradient(rgba(0,30,200,0.8),rgba(90,30,150,0.5)), url("images/hero-background-filter.jpg")
|
||||
box-shadow: rgba(0,0,0,0.5) 0px 0px 20px
|
||||
margin: 0
|
||||
h1
|
||||
max-width: 25rem
|
||||
font-weight: bold
|
||||
color: white
|
||||
p
|
||||
max-width: 40rem
|
||||
color: white
|
||||
.screenshot
|
||||
box-shadow: rgba(0, 0, 0, 0.5) 5px 5px 20px
|
||||
padding: 0px 0px 0px 0px
|
||||
border-radius: 10px
|
||||
border: 2px solid rgba(255, 255, 255, 0.2)
|
||||
background-color: transparent
|
||||
max-width: 300px
|
||||
.store-badges
|
||||
margin: 2rem 1rem
|
||||
img
|
||||
opacity: 0.8
|
||||
height: 75px
|
||||
img:hover
|
||||
opacity: 1.0
|
||||
.s1
|
||||
padding-bottom: 50px
|
||||
padding-left: 50px
|
||||
.s2
|
||||
position: absolute
|
||||
top: 50px
|
||||
left: 175px
|
||||
|
||||
.feature-header
|
||||
text-align: center
|
||||
font-weight: bold
|
||||
padding: 18px
|
||||
|
||||
.align-right
|
||||
text-align: right
|
||||
|
||||
.vertical-align
|
||||
display: flex
|
||||
align-items: center
|
||||
|
||||
.content
|
||||
max-width: 800px
|
||||
margin: 18px auto
|
||||
padding: 0px 18px
|
||||
//padding-left: 120px
|
||||
h2, h3, h4
|
||||
margin: 27px 0px 9px 0px
|
||||
h2, h3
|
||||
//margin-left: -120px
|
||||
h4
|
||||
//margin-left: -60px
|
||||
font-size: 16px
|
||||
font-weight: bold
|
||||
@@ -1,32 +0,0 @@
|
||||
!!! 5
|
||||
%html
|
||||
%head
|
||||
%meta(charset="UTF-8")
|
||||
%link(href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css")
|
||||
%meta(name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no")
|
||||
%title Privacy | Loop Habit Tracker
|
||||
%link(rel="stylesheet" type="text/css" href="lib/css/bootstrap.min.css")
|
||||
%link(rel="stylesheet" type="text/css" href="index.css")
|
||||
|
||||
%body
|
||||
.navbar.navbar-expand-md.navbar-light.bg-light
|
||||
%a.navbar-brand(href="/")
|
||||
%b Loop
|
||||
Habit Tracker
|
||||
%button.navbar-toggler(type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation")
|
||||
%span.navbar-toggler-icon
|
||||
#navbar.collapse.navbar-collapse
|
||||
%ul.navbar-nav.mr-auto.mt-2.mt-lg-0
|
||||
%li.nav-item
|
||||
%a.nav-link(href="faq.html") FAQ
|
||||
%li.nav-item
|
||||
%a.nav-link(href="privacy.html") Privacy
|
||||
%li.nav-item
|
||||
%a.nav-link(href="https://source.loophabits.org") Source Code
|
||||
%li.nav-item
|
||||
%a.nav-link(href="https://translate.loophabits.org") Translate
|
||||
|
||||
%body
|
||||
.content
|
||||
:markdown
|
||||
#{File.open("src/privacy.md").read}
|
||||
@@ -1,14 +0,0 @@
|
||||
## Privacy Policy
|
||||
|
||||
- All data provided to Loop Habit Tracker is only stored locally in your
|
||||
device. Loop Habit Tracker does not upload your data anywhere. The
|
||||
developers of Loop Habit Tracker do not have access to your data.
|
||||
|
||||
- Your data is not shared with any 3rd parties. Loop Habit Tracker does not
|
||||
include any advertisement libraries or any 3rd party tracking (analytics)
|
||||
code, such as Google Analytics or Facebook SDK.
|
||||
|
||||
- If you have activated "backup & reset" in your phone settings (Settings /
|
||||
Backup & Reset / Back up my data), you should be aware that Android itself
|
||||
will periodically save a copy of your phone's data in Google's servers. The
|
||||
developers of Loop Habit Tracker do not have access to this data.
|
||||
@@ -32,12 +32,12 @@ tasks.compileLint {
|
||||
|
||||
android {
|
||||
|
||||
compileSdk = 31
|
||||
compileSdk = 32
|
||||
|
||||
defaultConfig {
|
||||
versionCode = 20103
|
||||
versionName = "2.1.3"
|
||||
minSdk = 23
|
||||
versionCode = 20101
|
||||
versionName = "2.1.1"
|
||||
minSdk = 28
|
||||
targetSdk = 31
|
||||
applicationId = "org.isoron.uhabits"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -68,12 +68,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
lint {
|
||||
isCheckReleaseBuilds = false
|
||||
isAbortOnError = false
|
||||
disable("GoogleAppIndexingWarning")
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
targetCompatibility(JavaVersion.VERSION_1_8)
|
||||
@@ -86,25 +80,25 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val daggerVersion = "2.41"
|
||||
val kotlinVersion = "1.6.21"
|
||||
val kxCoroutinesVersion = "1.6.1"
|
||||
val daggerVersion = "2.44.2"
|
||||
val kotlinVersion = "1.7.21"
|
||||
val kxCoroutinesVersion = "1.6.4"
|
||||
val ktorVersion = "1.6.8"
|
||||
val espressoVersion = "3.4.0"
|
||||
val espressoVersion = "3.5.0"
|
||||
|
||||
androidTestImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
|
||||
androidTestImplementation("com.google.dagger:dagger:$daggerVersion")
|
||||
androidTestImplementation("com.linkedin.dexmaker:dexmaker-mockito:2.28.1")
|
||||
androidTestImplementation("com.linkedin.dexmaker:dexmaker-mockito:2.28.3")
|
||||
androidTestImplementation("io.ktor:ktor-client-mock:$ktorVersion")
|
||||
androidTestImplementation("io.ktor:ktor-jackson:$ktorVersion")
|
||||
androidTestImplementation("androidx.annotation:annotation:1.3.0")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.3")
|
||||
androidTestImplementation("androidx.annotation:annotation:1.5.0")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.4")
|
||||
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
|
||||
androidTestImplementation("androidx.test:rules:1.4.0")
|
||||
androidTestImplementation("androidx.test:rules:1.5.0")
|
||||
androidTestImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
|
||||
compileOnly("javax.annotation:jsr250-api:1.0")
|
||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
|
||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.2.2")
|
||||
implementation("com.github.AppIntro:AppIntro:6.2.0")
|
||||
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||
implementation("com.google.dagger:dagger:$daggerVersion")
|
||||
@@ -116,11 +110,11 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kxCoroutinesVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kxCoroutinesVersion")
|
||||
implementation("androidx.appcompat:appcompat:1.4.1")
|
||||
implementation("androidx.appcompat:appcompat:1.5.1")
|
||||
implementation("androidx.legacy:legacy-preference-v14:1.0.0")
|
||||
implementation("androidx.legacy:legacy-support-v4:1.0.0")
|
||||
implementation("com.google.android.material:material:1.5.0")
|
||||
implementation("com.opencsv:opencsv:5.6")
|
||||
implementation("com.google.android.material:material:1.8.0")
|
||||
implementation("com.opencsv:opencsv:5.7.1")
|
||||
implementation(project(":uhabits-core"))
|
||||
kapt("com.google.dagger:dagger-compiler:$daggerVersion")
|
||||
kaptAndroidTest("com.google.dagger:dagger-compiler:$daggerVersion")
|
||||
|
||||
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 15 KiB |
@@ -20,6 +20,7 @@ package org.isoron.uhabits.acceptance.steps
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.os.Build.VERSION_CODES
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.espresso.Espresso
|
||||
@@ -73,7 +74,7 @@ object CommonSteps : BaseUserInterfaceTest() {
|
||||
}
|
||||
|
||||
fun offsetHeaders() {
|
||||
device.swipe(750, 160, 600, 160, 20)
|
||||
device.swipe(500, 160, 350, 160, 20)
|
||||
}
|
||||
|
||||
fun scrollToText(text: String?) {
|
||||
|
||||
@@ -53,6 +53,7 @@ object ListHabitsSteps {
|
||||
clickViewWithId(R.id.action_filter)
|
||||
CommonSteps.clickText(R.string.hide_completed)
|
||||
}
|
||||
else -> throw RuntimeException()
|
||||
}
|
||||
device.waitForIdle()
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class EntryButtonViewTest : BaseViewTest() {
|
||||
view = component.getEntryButtonViewFactory().create().apply {
|
||||
value = Entry.NO
|
||||
color = PaletteUtils.getAndroidTestColor(5)
|
||||
onToggle = { _, _ -> toggled = true }
|
||||
onToggle = { _, _, _ -> toggled = true }
|
||||
onEdit = { edited = true }
|
||||
}
|
||||
measureView(view, dpToPixels(48), dpToPixels(48))
|
||||
|
||||
@@ -77,7 +77,7 @@ class EntryPanelViewTest : BaseViewTest() {
|
||||
@Test
|
||||
fun testToggle() {
|
||||
val timestamps = mutableListOf<Timestamp>()
|
||||
view.onToggle = { t, _, _ -> timestamps.add(t) }
|
||||
view.onToggle = { t, _, _, _ -> timestamps.add(t) }
|
||||
view.buttons[0].performLongClick()
|
||||
view.buttons[2].performLongClick()
|
||||
view.buttons[3].performLongClick()
|
||||
@@ -88,7 +88,7 @@ class EntryPanelViewTest : BaseViewTest() {
|
||||
fun testToggle_withOffset() {
|
||||
val timestamps = mutableListOf<Timestamp>()
|
||||
view.dataOffset = 3
|
||||
view.onToggle = { t, _, _ -> timestamps += t }
|
||||
view.onToggle = { t, _, _, _ -> timestamps += t }
|
||||
view.buttons[0].performLongClick()
|
||||
view.buttons[2].performLongClick()
|
||||
view.buttons[3].performLongClick()
|
||||
|
||||
@@ -36,7 +36,6 @@ class CheckmarkWidgetViewTest : BaseViewTest() {
|
||||
@Before
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
similarityCutoff = 0.00025
|
||||
setTheme(R.style.WidgetTheme)
|
||||
val habit = fixtures.createShortHabit()
|
||||
val computedEntries = habit.computedEntries
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.animation.Keyframe;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Build;
|
||||
import android.text.format.Time;
|
||||
import android.view.View;
|
||||
|
||||
@@ -43,17 +42,13 @@ public class Utils {
|
||||
|
||||
static final String SHARED_PREFS_NAME = "com.android.calendar_preferences";
|
||||
|
||||
public static boolean isJellybeanOrLater() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to speak the specified text, for accessibility. Only available on JB or later.
|
||||
* @param text Text to announce.
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public static void tryAccessibilityAnnounce(View view, CharSequence text) {
|
||||
if (isJellybeanOrLater() && view != null && text != null) {
|
||||
if (view != null && text != null) {
|
||||
view.announceForAccessibility(text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,10 +383,6 @@ public abstract class DayPickerView extends ListView implements OnScrollListener
|
||||
if (child instanceof MonthView) {
|
||||
final CalendarDay focus = ((MonthView) child).getAccessibilityFocus();
|
||||
if (focus != null) {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
// Clear focus to avoid ListView bug in Jelly Bean MR1.
|
||||
((MonthView) child).clearAccessibilityFocus();
|
||||
}
|
||||
return focus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,60 +20,109 @@
|
||||
package org.isoron.uhabits.activities.common.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import org.isoron.uhabits.HabitsApplication
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.core.models.Entry.Companion.NO
|
||||
import org.isoron.uhabits.core.models.Entry.Companion.SKIP
|
||||
import org.isoron.uhabits.core.models.Entry.Companion.UNKNOWN
|
||||
import org.isoron.uhabits.core.models.Entry.Companion.YES_AUTO
|
||||
import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
|
||||
import org.isoron.uhabits.core.preferences.Preferences
|
||||
import org.isoron.uhabits.databinding.CheckmarkPopupBinding
|
||||
import org.isoron.uhabits.utils.InterfaceUtils.getFontAwesome
|
||||
import org.isoron.uhabits.utils.dimBehind
|
||||
import org.isoron.uhabits.utils.dismissCurrentAndShow
|
||||
import org.isoron.uhabits.utils.dp
|
||||
import org.isoron.uhabits.utils.sres
|
||||
|
||||
class CheckmarkDialog : AppCompatDialogFragment() {
|
||||
var onToggle: (Int, String) -> Unit = { _, _ -> }
|
||||
const val POPUP_WIDTH = 4 * 48f + 16f
|
||||
const val POPUP_HEIGHT = 48f * 2.5f + 8f
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val appComponent = (requireActivity().application as HabitsApplication).component
|
||||
val prefs = appComponent.preferences
|
||||
val view = CheckmarkPopupBinding.inflate(LayoutInflater.from(context))
|
||||
class CheckmarkPopup(
|
||||
private val context: Context,
|
||||
private val color: Int,
|
||||
private var notes: String,
|
||||
private var value: Int,
|
||||
private val prefs: Preferences,
|
||||
private val anchor: View,
|
||||
) {
|
||||
var onToggle: (Int, String) -> Unit = { _, _ -> }
|
||||
private lateinit var dialog: Dialog
|
||||
|
||||
private val view = CheckmarkPopupBinding.inflate(LayoutInflater.from(context)).apply {
|
||||
// Required for round corners
|
||||
container.clipToOutline = true
|
||||
}
|
||||
|
||||
init {
|
||||
view.booleanButtons.visibility = VISIBLE
|
||||
initColors()
|
||||
initTypefaces()
|
||||
hideDisabledButtons()
|
||||
populate()
|
||||
}
|
||||
|
||||
private fun initColors() {
|
||||
arrayOf(view.yesBtn, view.skipBtn).forEach {
|
||||
it.setTextColor(requireArguments().getInt("color"))
|
||||
it.setTextColor(color)
|
||||
}
|
||||
arrayOf(view.noBtn, view.unknownBtn).forEach {
|
||||
it.setTextColor(view.root.sres.getColor(R.attr.contrast60))
|
||||
}
|
||||
}
|
||||
|
||||
private fun initTypefaces() {
|
||||
arrayOf(view.yesBtn, view.noBtn, view.skipBtn, view.unknownBtn).forEach {
|
||||
it.typeface = getFontAwesome(requireContext())
|
||||
it.typeface = getFontAwesome(context)
|
||||
}
|
||||
view.notes.setText(requireArguments().getString("notes")!!)
|
||||
}
|
||||
|
||||
private fun hideDisabledButtons() {
|
||||
if (!prefs.isSkipEnabled) view.skipBtn.visibility = GONE
|
||||
if (!prefs.areQuestionMarksEnabled) view.unknownBtn.visibility = GONE
|
||||
view.booleanButtons.visibility = VISIBLE
|
||||
val dialog = Dialog(requireContext())
|
||||
}
|
||||
|
||||
private fun populate() {
|
||||
val selectedBtn = when (value) {
|
||||
YES_MANUAL -> view.yesBtn
|
||||
YES_AUTO -> view.noBtn
|
||||
NO -> view.noBtn
|
||||
UNKNOWN -> if (prefs.areQuestionMarksEnabled) view.unknownBtn else view.noBtn
|
||||
SKIP -> if (prefs.isSkipEnabled) view.skipBtn else view.noBtn
|
||||
else -> null
|
||||
}
|
||||
view.notes.setText(notes)
|
||||
}
|
||||
|
||||
fun show() {
|
||||
dialog = Dialog(context, android.R.style.Theme_NoTitleBar)
|
||||
dialog.setContentView(view.root)
|
||||
dialog.window?.apply {
|
||||
setLayout(
|
||||
view.root.dp(POPUP_WIDTH).toInt(),
|
||||
view.root.dp(POPUP_HEIGHT).toInt()
|
||||
)
|
||||
setBackgroundDrawableResource(android.R.color.transparent)
|
||||
}
|
||||
fun onClick(v: Int) {
|
||||
val notes = view.notes.text.toString().trim()
|
||||
onToggle(v, notes)
|
||||
requireDialog().dismiss()
|
||||
this.value = v
|
||||
save()
|
||||
}
|
||||
view.yesBtn.setOnClickListener { onClick(YES_MANUAL) }
|
||||
view.noBtn.setOnClickListener { onClick(NO) }
|
||||
view.skipBtn.setOnClickListener { onClick(SKIP) }
|
||||
view.unknownBtn.setOnClickListener { onClick(UNKNOWN) }
|
||||
view.notes.setOnEditorActionListener { v, actionId, event ->
|
||||
onClick(requireArguments().getInt("value"))
|
||||
true
|
||||
}
|
||||
dialog.setCanceledOnTouchOutside(true)
|
||||
dialog.dimBehind()
|
||||
dialog.dismissCurrentAndShow()
|
||||
}
|
||||
|
||||
return dialog
|
||||
fun save() {
|
||||
onToggle(value, view.notes.text.toString().trim())
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import org.isoron.uhabits.utils.toPaletteColor
|
||||
class ColorPickerDialog : ColorPickerDialog() {
|
||||
fun setListener(callback: OnColorPickedCallback) {
|
||||
super.setOnColorSelectedListener { c: Int ->
|
||||
val pc = c.toPaletteColor(context!!)
|
||||
val pc = c.toPaletteColor(requireContext())
|
||||
callback.onColorPicked(pc)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ class HistoryEditorDialog : AppCompatDialogFragment(), CommandRunner.Listener {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
clearCurrentDialog()
|
||||
val component = (activity!!.application as HabitsApplication).component
|
||||
val component = (requireActivity().application as HabitsApplication).component
|
||||
commandRunner = component.commandRunner
|
||||
habit = component.habitList.getById(arguments!!.getLong("habit"))!!
|
||||
habit = component.habitList.getById(requireArguments().getLong("habit"))!!
|
||||
preferences = component.preferences
|
||||
|
||||
val themeSwitcher = AndroidThemeSwitcher(activity!!, preferences)
|
||||
val themeSwitcher = AndroidThemeSwitcher(requireActivity(), preferences)
|
||||
themeSwitcher.apply()
|
||||
|
||||
chart = HistoryChart(
|
||||
@@ -71,10 +71,10 @@ class HistoryEditorDialog : AppCompatDialogFragment(), CommandRunner.Listener {
|
||||
onDateClickedListener = onDateClickedListener ?: object : OnDateClickedListener {},
|
||||
padding = 10.0,
|
||||
)
|
||||
dataView = AndroidDataView(context!!, null)
|
||||
dataView = AndroidDataView(requireContext(), null)
|
||||
dataView.view = chart!!
|
||||
|
||||
val dialog = Dialog(context!!).apply {
|
||||
val dialog = Dialog(requireContext()).apply {
|
||||
val metrics = resources.displayMetrics
|
||||
val maxHeight = resources.getDimensionPixelSize(R.dimen.history_editor_max_height)
|
||||
setContentView(dataView)
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
package org.isoron.uhabits.activities.common.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.text.method.DigitsKeyListener
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import org.isoron.uhabits.HabitsApplication
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.core.models.Entry
|
||||
import org.isoron.uhabits.databinding.CheckmarkPopupBinding
|
||||
import org.isoron.uhabits.utils.InterfaceUtils
|
||||
import org.isoron.uhabits.utils.requestFocusWithKeyboard
|
||||
import org.isoron.uhabits.utils.sres
|
||||
import java.text.DecimalFormat
|
||||
import java.text.DecimalFormatSymbols
|
||||
import java.text.NumberFormat
|
||||
import java.text.ParseException
|
||||
|
||||
class NumberDialog : AppCompatDialogFragment() {
|
||||
|
||||
var onToggle: (Double, String) -> Unit = { _, _ -> }
|
||||
var onDismiss: () -> Unit = {}
|
||||
|
||||
private var originalNotes: String = ""
|
||||
private var originalValue: Double = 0.0
|
||||
private lateinit var view: CheckmarkPopupBinding
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val appComponent = (requireActivity().application as HabitsApplication).component
|
||||
val prefs = appComponent.preferences
|
||||
view = CheckmarkPopupBinding.inflate(LayoutInflater.from(context))
|
||||
arrayOf(view.yesBtn, view.skipBtn).forEach {
|
||||
it.setTextColor(requireArguments().getInt("color"))
|
||||
}
|
||||
arrayOf(view.noBtn, view.unknownBtn).forEach {
|
||||
it.setTextColor(view.root.sres.getColor(R.attr.contrast60))
|
||||
}
|
||||
arrayOf(view.yesBtn, view.noBtn, view.skipBtn, view.unknownBtn).forEach {
|
||||
it.typeface = InterfaceUtils.getFontAwesome(requireContext())
|
||||
}
|
||||
if (!prefs.isSkipEnabled) view.skipBtnNumber.visibility = View.GONE
|
||||
view.numberButtons.visibility = View.VISIBLE
|
||||
fixDecimalSeparator(view)
|
||||
originalNotes = requireArguments().getString("notes")!!
|
||||
originalValue = requireArguments().getDouble("value")
|
||||
view.notes.setText(originalNotes)
|
||||
view.value.setText(
|
||||
when {
|
||||
originalValue < 0.01 -> "0"
|
||||
else -> DecimalFormat("#.##").format(originalValue)
|
||||
}
|
||||
)
|
||||
view.value.setOnKeyListener { _, keyCode, event ->
|
||||
if (event.action == MotionEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||
save()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
return@setOnKeyListener false
|
||||
}
|
||||
view.saveBtn.setOnClickListener {
|
||||
save()
|
||||
}
|
||||
view.skipBtnNumber.setOnClickListener {
|
||||
view.value.setText(DecimalFormat("#.###").format((Entry.SKIP.toDouble() / 1000)))
|
||||
save()
|
||||
}
|
||||
view.notes.setOnEditorActionListener { v, actionId, event ->
|
||||
save()
|
||||
true
|
||||
}
|
||||
view.value.requestFocusWithKeyboard()
|
||||
val dialog = Dialog(requireContext())
|
||||
dialog.setContentView(view.root)
|
||||
dialog.window?.apply {
|
||||
setBackgroundDrawableResource(android.R.color.transparent)
|
||||
}
|
||||
dialog.setOnDismissListener { onDismiss() }
|
||||
return dialog
|
||||
}
|
||||
|
||||
private fun fixDecimalSeparator(view: CheckmarkPopupBinding) {
|
||||
// https://stackoverflow.com/a/34256139
|
||||
val separator = DecimalFormatSymbols.getInstance().decimalSeparator
|
||||
view.value.keyListener = DigitsKeyListener.getInstance("0123456789$separator")
|
||||
|
||||
// https://github.com/flutter/flutter/issues/61175
|
||||
val currKeyboard = Settings.Secure.getString(
|
||||
requireContext().contentResolver,
|
||||
Settings.Secure.DEFAULT_INPUT_METHOD
|
||||
)
|
||||
if (currKeyboard.contains("swiftkey") || currKeyboard.contains("samsung")) {
|
||||
view.value.inputType = EditorInfo.TYPE_CLASS_TEXT
|
||||
}
|
||||
}
|
||||
|
||||
fun save() {
|
||||
var value = originalValue
|
||||
try {
|
||||
val numberFormat = NumberFormat.getInstance()
|
||||
val valueStr = view.value.text.toString()
|
||||
value = numberFormat.parse(valueStr)!!.toDouble()
|
||||
} catch (e: ParseException) {
|
||||
// NOP
|
||||
}
|
||||
val notes = view.notes.text.toString()
|
||||
onToggle(value, notes)
|
||||
requireDialog().dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.activities.common.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.view.KeyEvent.KEYCODE_ENTER
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent.ACTION_DOWN
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import org.isoron.uhabits.core.models.Entry
|
||||
import org.isoron.uhabits.core.preferences.Preferences
|
||||
import org.isoron.uhabits.databinding.CheckmarkPopupBinding
|
||||
import org.isoron.uhabits.utils.dimBehind
|
||||
import org.isoron.uhabits.utils.dismissCurrentAndShow
|
||||
import org.isoron.uhabits.utils.dp
|
||||
import org.isoron.uhabits.utils.requestFocusWithKeyboard
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class NumberPopup(
|
||||
private val context: Context,
|
||||
private var notes: String,
|
||||
private var value: Double,
|
||||
private val prefs: Preferences,
|
||||
private val anchor: View,
|
||||
) {
|
||||
var onToggle: (Double, String) -> Unit = { _, _ -> }
|
||||
var onDismiss: () -> Unit = {}
|
||||
private val originalValue = value
|
||||
private lateinit var dialog: Dialog
|
||||
|
||||
private val view = CheckmarkPopupBinding.inflate(LayoutInflater.from(context)).apply {
|
||||
// Required for round corners
|
||||
container.clipToOutline = true
|
||||
}
|
||||
|
||||
init {
|
||||
view.numberButtons.visibility = VISIBLE
|
||||
hideDisabledButtons()
|
||||
populate()
|
||||
}
|
||||
|
||||
private fun hideDisabledButtons() {
|
||||
if (!prefs.isSkipEnabled) view.skipBtnNumber.visibility = GONE
|
||||
}
|
||||
|
||||
private fun populate() {
|
||||
view.notes.setText(notes)
|
||||
view.value.setText(
|
||||
when {
|
||||
value < 0.01 -> "0"
|
||||
else -> DecimalFormat("#.##").format(value)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun show() {
|
||||
dialog = Dialog(context, android.R.style.Theme_NoTitleBar)
|
||||
dialog.setContentView(view.root)
|
||||
dialog.window?.apply {
|
||||
setLayout(
|
||||
view.root.dp(POPUP_WIDTH).toInt(),
|
||||
view.root.dp(POPUP_HEIGHT).toInt()
|
||||
)
|
||||
setBackgroundDrawableResource(android.R.color.transparent)
|
||||
}
|
||||
dialog.setOnDismissListener {
|
||||
onDismiss()
|
||||
}
|
||||
|
||||
view.value.setOnKeyListener { _, keyCode, event ->
|
||||
if (event.action == ACTION_DOWN && keyCode == KEYCODE_ENTER) {
|
||||
save()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
return@setOnKeyListener false
|
||||
}
|
||||
view.saveBtn.setOnClickListener {
|
||||
save()
|
||||
}
|
||||
view.skipBtnNumber.setOnClickListener {
|
||||
view.value.setText((Entry.SKIP.toDouble() / 1000).toString())
|
||||
save()
|
||||
}
|
||||
view.value.requestFocusWithKeyboard()
|
||||
dialog.setCanceledOnTouchOutside(true)
|
||||
dialog.dimBehind()
|
||||
dialog.dismissCurrentAndShow()
|
||||
}
|
||||
|
||||
fun save() {
|
||||
val value = view.value.text.toString().toDoubleOrNull() ?: originalValue
|
||||
val notes = view.notes.text.toString()
|
||||
onToggle(value, notes)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class WeekdayPickerDialog :
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val builder = AlertDialog.Builder(
|
||||
activity!!
|
||||
requireActivity()
|
||||
)
|
||||
builder
|
||||
.setTitle(R.string.select_weekdays)
|
||||
|
||||
@@ -40,13 +40,13 @@ class HabitTypeDialog : AppCompatDialogFragment() {
|
||||
val binding = SelectHabitTypeBinding.inflate(inflater, container, false)
|
||||
|
||||
binding.buttonYesNo.setOnClickListener {
|
||||
val intent = IntentFactory().startEditActivity(activity!!, HabitType.YES_NO.value)
|
||||
val intent = IntentFactory().startEditActivity(requireActivity(), HabitType.YES_NO.value)
|
||||
startActivity(intent)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
binding.buttonMeasurable.setOnClickListener {
|
||||
val intent = IntentFactory().startEditActivity(activity!!, HabitType.NUMERICAL.value)
|
||||
val intent = IntentFactory().startEditActivity(requireActivity(), HabitType.NUMERICAL.value)
|
||||
startActivity(intent)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.isoron.uhabits.inject.ActivityContextModule
|
||||
import org.isoron.uhabits.inject.DaggerHabitsActivityComponent
|
||||
import org.isoron.uhabits.inject.HabitsActivityComponent
|
||||
import org.isoron.uhabits.inject.HabitsApplicationComponent
|
||||
import org.isoron.uhabits.utils.dismissCurrentDialog
|
||||
import org.isoron.uhabits.utils.restartWithFade
|
||||
|
||||
class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
|
||||
@@ -92,7 +91,6 @@ class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
|
||||
midnightTimer.onPause()
|
||||
screen.onDetached()
|
||||
adapter.cancelRefresh()
|
||||
dismissCurrentDialog()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
@@ -101,7 +99,6 @@ class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
|
||||
screen.onAttached()
|
||||
rootView.postInvalidate()
|
||||
midnightTimer.onResume()
|
||||
appComponent.reminderScheduler.scheduleAll()
|
||||
taskRunner.run {
|
||||
try {
|
||||
AutoBackup(this@ListHabitsActivity).run()
|
||||
|
||||
@@ -22,15 +22,14 @@ package org.isoron.uhabits.activities.habits.list
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import dagger.Lazy
|
||||
import org.isoron.platform.gui.toInt
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkDialog
|
||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkPopup
|
||||
import org.isoron.uhabits.activities.common.dialogs.ColorPickerDialogFactory
|
||||
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
|
||||
import org.isoron.uhabits.activities.common.dialogs.NumberDialog
|
||||
import org.isoron.uhabits.activities.common.dialogs.NumberPopup
|
||||
import org.isoron.uhabits.activities.habits.edit.HabitTypeDialog
|
||||
import org.isoron.uhabits.activities.habits.list.views.HabitCardListAdapter
|
||||
import org.isoron.uhabits.core.commands.ArchiveHabitsCommand
|
||||
@@ -234,14 +233,17 @@ class ListHabitsScreen
|
||||
notes: String,
|
||||
callback: ListHabitsBehavior.NumberPickerCallback
|
||||
) {
|
||||
val fm = (context as AppCompatActivity).supportFragmentManager
|
||||
val dialog = NumberDialog()
|
||||
dialog.arguments = Bundle().apply {
|
||||
putDouble("value", value)
|
||||
putString("notes", notes)
|
||||
val view = rootView.get()
|
||||
NumberPopup(
|
||||
context = context,
|
||||
prefs = preferences,
|
||||
anchor = view,
|
||||
notes = notes,
|
||||
value = value,
|
||||
).apply {
|
||||
onToggle = { value, notes -> callback.onNumberPicked(value, notes) }
|
||||
show()
|
||||
}
|
||||
dialog.onToggle = { v, n -> callback.onNumberPicked(v, n) }
|
||||
dialog.dismissCurrentAndShow(fm, "numberDialog")
|
||||
}
|
||||
|
||||
override fun showCheckmarkPopup(
|
||||
@@ -250,16 +252,18 @@ class ListHabitsScreen
|
||||
color: PaletteColor,
|
||||
callback: ListHabitsBehavior.CheckMarkDialogCallback
|
||||
) {
|
||||
val theme = rootView.get().currentTheme()
|
||||
val fm = (context as AppCompatActivity).supportFragmentManager
|
||||
val dialog = CheckmarkDialog()
|
||||
dialog.arguments = Bundle().apply {
|
||||
putInt("color", theme.color(color).toInt())
|
||||
putInt("value", selectedValue)
|
||||
putString("notes", notes)
|
||||
val view = rootView.get()
|
||||
CheckmarkPopup(
|
||||
context = context,
|
||||
prefs = preferences,
|
||||
anchor = view,
|
||||
color = view.currentTheme().color(color).toInt(),
|
||||
notes = notes,
|
||||
value = selectedValue,
|
||||
).apply {
|
||||
onToggle = { value, notes -> callback.onNotesSaved(value, notes) }
|
||||
show()
|
||||
}
|
||||
dialog.onToggle = { v, n -> callback.onNotesSaved(v, n) }
|
||||
dialog.dismissCurrentAndShow(fm, "checkmarkDialog")
|
||||
}
|
||||
|
||||
private fun getExecuteString(command: Command): String? {
|
||||
|
||||
@@ -44,6 +44,8 @@ import org.isoron.uhabits.utils.sres
|
||||
import org.isoron.uhabits.utils.toMeasureSpec
|
||||
import javax.inject.Inject
|
||||
|
||||
const val TOGGLE_DELAY_MILLIS = 2000L
|
||||
|
||||
class CheckmarkButtonViewFactory
|
||||
@Inject constructor(
|
||||
@ActivityContext val context: Context,
|
||||
@@ -77,7 +79,7 @@ class CheckmarkButtonView(
|
||||
invalidate()
|
||||
}
|
||||
|
||||
var onToggle: (Int, String) -> Unit = { _, _ -> }
|
||||
var onToggle: (Int, String, Long) -> Unit = { _, _, _ -> }
|
||||
|
||||
var onEdit: () -> Unit = { }
|
||||
|
||||
@@ -88,25 +90,25 @@ class CheckmarkButtonView(
|
||||
setOnLongClickListener(this)
|
||||
}
|
||||
|
||||
fun performToggle() {
|
||||
fun performToggle(delay: Long) {
|
||||
value = Entry.nextToggleValue(
|
||||
value = value,
|
||||
isSkipEnabled = preferences.isSkipEnabled,
|
||||
areQuestionMarksEnabled = preferences.areQuestionMarksEnabled
|
||||
)
|
||||
onToggle(value, notes)
|
||||
onToggle(value, notes, delay)
|
||||
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
if (preferences.isShortToggleEnabled) performToggle()
|
||||
if (preferences.isShortToggleEnabled) performToggle(TOGGLE_DELAY_MILLIS)
|
||||
else onEdit()
|
||||
}
|
||||
|
||||
override fun onLongClick(v: View): Boolean {
|
||||
if (preferences.isShortToggleEnabled) onEdit()
|
||||
else performToggle()
|
||||
else performToggle(TOGGLE_DELAY_MILLIS)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class CheckmarkPanelView(
|
||||
setupButtons()
|
||||
}
|
||||
|
||||
var onToggle: (Timestamp, Int, String) -> Unit = { _, _, _ -> }
|
||||
var onToggle: (Timestamp, Int, String, Long) -> Unit = { _, _, _, _ -> }
|
||||
set(value) {
|
||||
field = value
|
||||
setupButtons()
|
||||
@@ -89,7 +89,7 @@ class CheckmarkPanelView(
|
||||
else -> ""
|
||||
}
|
||||
button.color = color
|
||||
button.onToggle = { value, notes -> onToggle(timestamp, value, notes) }
|
||||
button.onToggle = { value, notes, delay -> onToggle(timestamp, value, notes, delay) }
|
||||
button.onEdit = { onEdit(timestamp) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,13 @@ class HabitCardViewFactory
|
||||
fun create() = HabitCardView(context, checkmarkPanelFactory, numberPanelFactory, behavior)
|
||||
}
|
||||
|
||||
data class DelayedToggle(
|
||||
var habit: Habit,
|
||||
var timestamp: Timestamp,
|
||||
var value: Int,
|
||||
var notes: String
|
||||
)
|
||||
|
||||
class HabitCardView(
|
||||
@ActivityContext context: Context,
|
||||
checkmarkPanelFactory: CheckmarkPanelViewFactory,
|
||||
@@ -129,6 +136,7 @@ class HabitCardView(
|
||||
private var scoreRing: RingView
|
||||
|
||||
private var currentToggleTaskId = 0
|
||||
private var queuedToggles = mutableListOf<DelayedToggle>()
|
||||
|
||||
init {
|
||||
scoreRing = RingView(context).apply {
|
||||
@@ -152,9 +160,12 @@ class HabitCardView(
|
||||
}
|
||||
|
||||
checkmarkPanel = checkmarkPanelFactory.create().apply {
|
||||
onToggle = { timestamp, value, notes ->
|
||||
triggerRipple(timestamp)
|
||||
habit?.let { behavior.onToggle(it, timestamp, value, notes) }
|
||||
onToggle = { timestamp, value, notes, delay ->
|
||||
if (delay > 0) triggerRipple(timestamp)
|
||||
habit?.let {
|
||||
val taskId = queueToggle(it, timestamp, value, notes);
|
||||
{ runPendingToggles(taskId) }.delay(delay)
|
||||
}
|
||||
}
|
||||
onEdit = { timestamp ->
|
||||
triggerRipple(timestamp)
|
||||
@@ -194,6 +205,25 @@ class HabitCardView(
|
||||
addView(innerFrame)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun runPendingToggles(id: Int) {
|
||||
if (currentToggleTaskId != id) return
|
||||
for ((h, t, v, n) in queuedToggles) behavior.onToggle(h, t, v, n)
|
||||
queuedToggles.clear()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun queueToggle(
|
||||
it: Habit,
|
||||
timestamp: Timestamp,
|
||||
value: Int,
|
||||
notes: String,
|
||||
): Int {
|
||||
currentToggleTaskId += 1
|
||||
queuedToggles.add(DelayedToggle(it, timestamp, value, notes))
|
||||
return currentToggleTaskId
|
||||
}
|
||||
|
||||
override fun onModelChange() {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
habit?.let { copyAttributesFrom(it) }
|
||||
|
||||
@@ -34,10 +34,10 @@ import org.isoron.uhabits.HabitsApplication
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.activities.AndroidThemeSwitcher
|
||||
import org.isoron.uhabits.activities.HabitsDirFinder
|
||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkDialog
|
||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkPopup
|
||||
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
|
||||
import org.isoron.uhabits.activities.common.dialogs.HistoryEditorDialog
|
||||
import org.isoron.uhabits.activities.common.dialogs.NumberDialog
|
||||
import org.isoron.uhabits.activities.common.dialogs.NumberPopup
|
||||
import org.isoron.uhabits.core.commands.Command
|
||||
import org.isoron.uhabits.core.commands.CommandRunner
|
||||
import org.isoron.uhabits.core.models.Habit
|
||||
@@ -51,7 +51,6 @@ import org.isoron.uhabits.core.ui.views.OnDateClickedListener
|
||||
import org.isoron.uhabits.intents.IntentFactory
|
||||
import org.isoron.uhabits.utils.currentTheme
|
||||
import org.isoron.uhabits.utils.dismissCurrentAndShow
|
||||
import org.isoron.uhabits.utils.dismissCurrentDialog
|
||||
import org.isoron.uhabits.utils.showMessage
|
||||
import org.isoron.uhabits.utils.showSendFileScreen
|
||||
import org.isoron.uhabits.widgets.WidgetUpdater
|
||||
@@ -130,7 +129,6 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
dismissCurrentDialog()
|
||||
commandRunner.removeListener(this)
|
||||
super.onPause()
|
||||
}
|
||||
@@ -172,32 +170,41 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
||||
override fun showNumberPopup(
|
||||
value: Double,
|
||||
notes: String,
|
||||
preferences: Preferences,
|
||||
callback: ListHabitsBehavior.NumberPickerCallback
|
||||
) {
|
||||
val dialog = NumberDialog()
|
||||
dialog.arguments = Bundle().apply {
|
||||
putDouble("value", value)
|
||||
putString("notes", notes)
|
||||
val anchor = getPopupAnchor() ?: return
|
||||
NumberPopup(
|
||||
context = this@ShowHabitActivity,
|
||||
prefs = preferences,
|
||||
notes = notes,
|
||||
anchor = anchor,
|
||||
value = value,
|
||||
).apply {
|
||||
onToggle = { v, n -> callback.onNumberPicked(v, n) }
|
||||
show()
|
||||
}
|
||||
dialog.onToggle = { v, n -> callback.onNumberPicked(v, n) }
|
||||
dialog.dismissCurrentAndShow(supportFragmentManager, "numberDialog")
|
||||
}
|
||||
|
||||
override fun showCheckmarkPopup(
|
||||
selectedValue: Int,
|
||||
notes: String,
|
||||
preferences: Preferences,
|
||||
color: PaletteColor,
|
||||
callback: ListHabitsBehavior.CheckMarkDialogCallback
|
||||
) {
|
||||
val theme = view.currentTheme()
|
||||
val dialog = CheckmarkDialog()
|
||||
dialog.arguments = Bundle().apply {
|
||||
putInt("color", theme.color(color).toInt())
|
||||
putInt("value", selectedValue)
|
||||
putString("notes", notes)
|
||||
val anchor = getPopupAnchor() ?: return
|
||||
CheckmarkPopup(
|
||||
context = this@ShowHabitActivity,
|
||||
prefs = preferences,
|
||||
notes = notes,
|
||||
color = view.currentTheme().color(color).toInt(),
|
||||
anchor = anchor,
|
||||
value = selectedValue,
|
||||
).apply {
|
||||
onToggle = { v, n -> callback.onNotesSaved(v, n) }
|
||||
show()
|
||||
}
|
||||
dialog.onToggle = { v, n -> callback.onNotesSaved(v, n) }
|
||||
dialog.dismissCurrentAndShow(supportFragmentManager, "checkmarkDialog")
|
||||
}
|
||||
|
||||
private fun getPopupAnchor(): View? {
|
||||
@@ -214,6 +221,7 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
||||
ShowHabitMenuPresenter.Message.COULD_NOT_EXPORT -> {
|
||||
showMessage(resources.getString(R.string.could_not_export))
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ import android.app.backup.BackupManager
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||
import android.os.Build
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
@@ -45,6 +44,7 @@ import org.isoron.uhabits.core.utils.DateUtils.Companion.getLongWeekdayNames
|
||||
import org.isoron.uhabits.notifications.AndroidNotificationTray.Companion.createAndroidNotificationChannel
|
||||
import org.isoron.uhabits.notifications.RingtoneManager
|
||||
import org.isoron.uhabits.utils.StyledResources
|
||||
import org.isoron.uhabits.utils.startActivitySafely
|
||||
import org.isoron.uhabits.widgets.WidgetUpdater
|
||||
import java.util.Calendar
|
||||
|
||||
@@ -65,7 +65,7 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
addPreferencesFromResource(R.xml.preferences)
|
||||
val appContext = context!!.applicationContext
|
||||
val appContext = requireContext().applicationContext
|
||||
if (appContext is HabitsApplication) {
|
||||
prefs = appContext.component.preferences
|
||||
widgetUpdater = appContext.component.widgetUpdater
|
||||
@@ -94,24 +94,31 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
|
||||
|
||||
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||
val key = preference.key ?: return false
|
||||
if (key == "reminderSound") {
|
||||
showRingtonePicker()
|
||||
return true
|
||||
} else if (key == "reminderCustomize") {
|
||||
if (SDK_INT < Build.VERSION_CODES.O) return true
|
||||
createAndroidNotificationChannel(context!!)
|
||||
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, context!!.packageName)
|
||||
intent.putExtra(Settings.EXTRA_CHANNEL_ID, NotificationTray.REMINDERS_CHANNEL_ID)
|
||||
startActivity(intent)
|
||||
return true
|
||||
when (key) {
|
||||
"reminderSound" -> {
|
||||
showRingtonePicker()
|
||||
return true
|
||||
}
|
||||
"reminderCustomize" -> {
|
||||
createAndroidNotificationChannel(requireContext())
|
||||
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||
intent.putExtra(Settings.EXTRA_CHANNEL_ID, NotificationTray.REMINDERS_CHANNEL_ID)
|
||||
startActivity(intent)
|
||||
return true
|
||||
}
|
||||
"rateApp" -> {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.playStoreURL)))
|
||||
activity?.startActivitySafely(intent)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onPreferenceTreeClick(preference)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
ringtoneManager = RingtoneManager(activity!!)
|
||||
ringtoneManager = RingtoneManager(requireActivity())
|
||||
sharedPrefs = preferenceManager.sharedPreferences
|
||||
sharedPrefs!!.registerOnSharedPreferenceChangeListener(this)
|
||||
if (!prefs.isDeveloper) {
|
||||
@@ -120,11 +127,7 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
|
||||
}
|
||||
updateWeekdayPreference()
|
||||
|
||||
if (SDK_INT < Build.VERSION_CODES.O)
|
||||
findPreference("reminderCustomize").isVisible = false
|
||||
else {
|
||||
findPreference("reminderSound").isVisible = false
|
||||
}
|
||||
findPreference("reminderSound").isVisible = false
|
||||
}
|
||||
|
||||
private fun updateWeekdayPreference() {
|
||||
@@ -154,8 +157,8 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
|
||||
val pref = findPreference(key)
|
||||
pref.onPreferenceClickListener =
|
||||
Preference.OnPreferenceClickListener {
|
||||
activity!!.setResult(result)
|
||||
activity!!.finish()
|
||||
requireActivity().setResult(result)
|
||||
requireActivity().finish()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.app.AlarmManager.RTC_WAKEUP
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Context.ALARM_SERVICE
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import org.isoron.uhabits.core.AppScope
|
||||
import org.isoron.uhabits.core.models.Habit
|
||||
@@ -57,10 +56,6 @@ class IntentScheduler
|
||||
)
|
||||
return SchedulerResult.IGNORED
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !manager.canScheduleExactAlarms()) {
|
||||
Log.e("IntentScheduler", "No permission to schedule exact alarms")
|
||||
return SchedulerResult.IGNORED
|
||||
}
|
||||
manager.setExactAndAllowWhileIdle(alarmType, timestamp, intent)
|
||||
return SchedulerResult.OK
|
||||
}
|
||||
|
||||
@@ -168,14 +168,12 @@ class AndroidNotificationTray
|
||||
fun createAndroidNotificationChannel(context: Context) {
|
||||
val notificationManager = context.getSystemService(Activity.NOTIFICATION_SERVICE)
|
||||
as NotificationManager
|
||||
if (SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel(
|
||||
REMINDERS_CHANNEL_ID,
|
||||
context.resources.getString(R.string.reminder),
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
val channel = NotificationChannel(
|
||||
REMINDERS_CHANNEL_ID,
|
||||
context.resources.getString(R.string.reminder),
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ import org.isoron.uhabits.HabitsApplication
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.activities.AndroidThemeSwitcher
|
||||
import org.isoron.uhabits.core.models.Habit
|
||||
import org.isoron.uhabits.core.ui.ThemeSwitcher.Companion.THEME_LIGHT
|
||||
import org.isoron.uhabits.core.ui.views.DarkTheme
|
||||
import org.isoron.uhabits.core.ui.views.LightTheme
|
||||
import org.isoron.uhabits.receivers.ReminderController
|
||||
import org.isoron.uhabits.utils.SystemUtils
|
||||
import java.util.Calendar
|
||||
@@ -51,11 +52,8 @@ class SnoozeDelayPickerActivity : FragmentActivity(), OnItemClickListener {
|
||||
val app = applicationContext as HabitsApplication
|
||||
val appComponent = app.component
|
||||
val themeSwitcher = AndroidThemeSwitcher(this, appComponent.preferences)
|
||||
if (themeSwitcher.getSystemTheme() == THEME_LIGHT) {
|
||||
setTheme(R.style.BaseDialog)
|
||||
} else {
|
||||
setTheme(R.style.BaseDialogDark)
|
||||
}
|
||||
themeSwitcher.setTheme()
|
||||
|
||||
val data = intent.data
|
||||
if (data == null) {
|
||||
finish()
|
||||
@@ -75,6 +73,16 @@ class SnoozeDelayPickerActivity : FragmentActivity(), OnItemClickListener {
|
||||
SystemUtils.unlockScreen(this)
|
||||
}
|
||||
|
||||
private fun AndroidThemeSwitcher.setTheme() {
|
||||
if (this.isNightMode) {
|
||||
setTheme(R.style.BaseDialogDark)
|
||||
this.currentTheme = DarkTheme()
|
||||
} else {
|
||||
setTheme(R.style.BaseDialog)
|
||||
this.currentTheme = LightTheme()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showTimePicker() {
|
||||
val calendar = Calendar.getInstance()
|
||||
val dialog = TimePickerDialog.newInstance(
|
||||
|
||||
@@ -6,24 +6,16 @@ import androidx.fragment.app.FragmentManager
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
var currentDialog: WeakReference<Dialog> = WeakReference(null)
|
||||
var currentDialogFragment: WeakReference<DialogFragment> = WeakReference(null)
|
||||
|
||||
fun dismissCurrentDialog() {
|
||||
currentDialog.get()?.dismiss()
|
||||
currentDialog = WeakReference(null)
|
||||
currentDialogFragment.get()?.dismiss()
|
||||
currentDialogFragment = WeakReference(null)
|
||||
}
|
||||
|
||||
fun Dialog.dismissCurrentAndShow() {
|
||||
dismissCurrentDialog()
|
||||
currentDialog.get()?.dismiss()
|
||||
currentDialog = WeakReference(this)
|
||||
show()
|
||||
}
|
||||
|
||||
fun DialogFragment.dismissCurrentAndShow(fragmentManager: FragmentManager, tag: String) {
|
||||
dismissCurrentDialog()
|
||||
currentDialogFragment = WeakReference(this)
|
||||
currentDialog.get()?.dismiss()
|
||||
show(fragmentManager, tag)
|
||||
fragmentManager.executePendingTransactions()
|
||||
currentDialog = WeakReference(this.dialog)
|
||||
}
|
||||
|
||||
@@ -21,18 +21,11 @@ package org.isoron.uhabits.utils
|
||||
import android.app.Activity
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.view.WindowManager
|
||||
|
||||
object SystemUtils {
|
||||
|
||||
fun unlockScreen(activity: Activity) {
|
||||
if (SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val km = activity.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
km.requestDismissKeyguard(activity, null)
|
||||
} else {
|
||||
activity.window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD)
|
||||
}
|
||||
val km = activity.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
km.requestDismissKeyguard(activity, null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ package org.isoron.uhabits.widgets
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import androidx.annotation.RequiresApi
|
||||
import org.isoron.platform.gui.toInt
|
||||
import org.isoron.uhabits.core.models.Entry
|
||||
import org.isoron.uhabits.core.models.Habit
|
||||
@@ -43,13 +41,12 @@ open class CheckmarkWidget(
|
||||
|
||||
override fun getOnClickPendingIntent(context: Context): PendingIntent? {
|
||||
return if (habit.isNumerical) {
|
||||
pendingIntentFactory.showNumberPicker(habit, DateUtils.getTodayWithOffset())
|
||||
pendingIntentFactory.showNumberPicker(habit, DateUtils.getToday())
|
||||
} else {
|
||||
pendingIntentFactory.toggleCheckmark(habit, null)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun refreshData(widgetView: View) {
|
||||
(widgetView as CheckmarkWidgetView).apply {
|
||||
val today = DateUtils.getTodayWithOffset()
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.core.models.Habit
|
||||
import org.isoron.uhabits.core.models.HabitNotFoundException
|
||||
import org.isoron.uhabits.core.preferences.Preferences
|
||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
||||
import org.isoron.uhabits.intents.IntentFactory
|
||||
import org.isoron.uhabits.intents.PendingIntentFactory
|
||||
import org.isoron.uhabits.utils.InterfaceUtils.dpToPixels
|
||||
@@ -101,7 +101,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
|
||||
val landscapeViews = widget.landscapeRemoteViews
|
||||
val portraitViews = widget.portraitRemoteViews
|
||||
val factory = PendingIntentFactory(context, IntentFactory())
|
||||
val intent = StackWidgetType.getIntentFillIn(factory, widgetType, h, habits, getTodayWithOffset())
|
||||
val intent = StackWidgetType.getIntentFillIn(factory, widgetType, h, habits, getToday())
|
||||
landscapeViews.setOnClickFillInIntent(R.id.button, intent)
|
||||
portraitViews.setOnClickFillInIntent(R.id.button, intent)
|
||||
val remoteViews = RemoteViews(landscapeViews, portraitViews)
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID
|
||||
import android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.AbsListView.CHOICE_MODE_MULTIPLE
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Button
|
||||
import android.widget.ListView
|
||||
@@ -33,6 +34,7 @@ import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.activities.AndroidThemeSwitcher
|
||||
import org.isoron.uhabits.core.preferences.WidgetPreferences
|
||||
import org.isoron.uhabits.widgets.WidgetUpdater
|
||||
import java.util.ArrayList
|
||||
|
||||
class BooleanHabitPickerDialog : HabitPickerDialog() {
|
||||
override fun shouldHideNumerical() = true
|
||||
@@ -86,12 +88,20 @@ open class HabitPickerDialog : Activity() {
|
||||
with(listView) {
|
||||
adapter = ArrayAdapter(
|
||||
context,
|
||||
android.R.layout.simple_list_item_1,
|
||||
android.R.layout.simple_list_item_multiple_choice,
|
||||
habitNames
|
||||
)
|
||||
setOnItemClickListener { parent, view, position, id ->
|
||||
confirm(mutableListOf(habitIds[position]))
|
||||
choiceMode = CHOICE_MODE_MULTIPLE
|
||||
itemsCanFocus = false
|
||||
}
|
||||
saveButton.setOnClickListener {
|
||||
val selectedIds = mutableListOf<Long>()
|
||||
for (i in 0..listView.count) {
|
||||
if (listView.isItemChecked(i)) {
|
||||
selectedIds.add(habitIds[i])
|
||||
}
|
||||
}
|
||||
confirm(selectedIds)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,21 +66,23 @@ class CheckmarkWidgetView : HabitWidgetView {
|
||||
val res = StyledResources(context)
|
||||
val bgColor: Int
|
||||
val fgColor: Int
|
||||
setShadowAlpha(0x4f)
|
||||
when (entryState) {
|
||||
YES_MANUAL, SKIP -> {
|
||||
bgColor = activeColor
|
||||
fgColor = res.getColor(R.attr.contrast0)
|
||||
setShadowAlpha(0x4f)
|
||||
backgroundPaint!!.color = bgColor
|
||||
frame!!.setBackgroundDrawable(background)
|
||||
}
|
||||
YES_AUTO, NO, UNKNOWN -> {
|
||||
bgColor = res.getColor(R.attr.cardBgColor)
|
||||
fgColor = res.getColor(R.attr.contrast60)
|
||||
setShadowAlpha(0x00)
|
||||
}
|
||||
else -> {
|
||||
bgColor = res.getColor(R.attr.cardBgColor)
|
||||
fgColor = res.getColor(R.attr.contrast60)
|
||||
setShadowAlpha(0x00)
|
||||
}
|
||||
}
|
||||
ring.setPercentage(percentage)
|
||||
@@ -124,7 +126,7 @@ class CheckmarkWidgetView : HabitWidgetView {
|
||||
} else {
|
||||
width = min(width, height)
|
||||
}
|
||||
val textSize = min(0.175f * width, getDimension(context, R.dimen.smallTextSize))
|
||||
val textSize = min(0.2f * width, getDimension(context, R.dimen.smallerTextSize))
|
||||
label.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||
if (isNumerical) {
|
||||
ring.setTextSize(textSize * 0.9f)
|
||||
@@ -139,8 +141,7 @@ class CheckmarkWidgetView : HabitWidgetView {
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
val appComponent: HabitsApplicationComponent =
|
||||
(context.applicationContext as HabitsApplication).component
|
||||
val appComponent: HabitsApplicationComponent = (context.applicationContext as HabitsApplication).component
|
||||
preferences = appComponent.preferences
|
||||
ring = findViewById<View>(R.id.scoreRing) as RingView
|
||||
label = findViewById<View>(R.id.label) as TextView
|
||||
|
||||
@@ -69,7 +69,7 @@ abstract class HabitWidgetView : FrameLayout {
|
||||
val shadowRadius = dpToPixels(context, 2f).toInt()
|
||||
val shadowOffset = dpToPixels(context, 1f).toInt()
|
||||
val shadowColor = Color.argb(shadowAlpha, 0, 0, 0)
|
||||
val cornerRadius = dpToPixels(context, 12f)
|
||||
val cornerRadius = dpToPixels(context, 5f)
|
||||
val radii = FloatArray(8)
|
||||
Arrays.fill(radii, cornerRadius)
|
||||
val shape = RoundRectShape(radii, null, null)
|
||||
|
||||
@@ -7,3 +7,4 @@
|
||||
* Add skips to measurable habits
|
||||
* Bring back custom frequencies
|
||||
* Other minor improvements and bug fixes
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
~
|
||||
~ This file is part of Loop Habit Tracker.
|
||||
~
|
||||
~ Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by the
|
||||
~ Free Software Foundation, either version 3 of the License, or (at your
|
||||
~ option) any later version.
|
||||
~
|
||||
~ Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along
|
||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:top="1dp"
|
||||
android:left="1dp"
|
||||
android:bottom="3dp"
|
||||
android:right="3dp">
|
||||
<ripple
|
||||
android:color="#60ffffff">
|
||||
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="12dp"/>
|
||||
<solid android:color="?android:colorPrimary"/>
|
||||
</shape>
|
||||
<color android:color="@color/white"/>
|
||||
</item>
|
||||
</ripple>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
@@ -17,18 +17,23 @@
|
||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="true" android:state_pressed="true">
|
||||
<layer-list>
|
||||
<item android:bottom="3dp"
|
||||
android:left="1dp"
|
||||
android:right="3dp"
|
||||
android:top="1dp">
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:top="1dp"
|
||||
android:left="1dp"
|
||||
android:bottom="3dp"
|
||||
android:right="3dp">
|
||||
<ripple
|
||||
android:color="#60ffffff">
|
||||
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="5dp"/>
|
||||
<solid android:color="#30ffffff"/>
|
||||
<solid android:color="?android:colorPrimary"/>
|
||||
</shape>
|
||||
<color android:color="@color/white"/>
|
||||
</item>
|
||||
</layer-list>
|
||||
</ripple>
|
||||
</item>
|
||||
</selector>
|
||||
|
||||
</layer-list>
|
||||
|
||||
@@ -21,10 +21,8 @@
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="128dp"
|
||||
android:minWidth="208dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:divider="@drawable/checkmark_dialog_divider"
|
||||
app:showDividers="middle"
|
||||
android:orientation="vertical"
|
||||
|
||||
@@ -30,4 +30,10 @@
|
||||
android:layout_weight="1">
|
||||
</ListView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonSave"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:text="@string/save"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -35,7 +35,7 @@
|
||||
android:paddingTop="4dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingBottom="4dp"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<TextView
|
||||
@@ -44,7 +44,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/smallTextSize"
|
||||
android:maxLines="2"
|
||||
android:textColor="@color/white"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
0
uhabits-android/src/main/res/mipmap-anydpi
Normal file
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
~
|
||||
~ This file is part of Loop Habit Tracker.
|
||||
~
|
||||
~ Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by the
|
||||
~ Free Software Foundation, either version 3 of the License, or (at your
|
||||
~ option) any later version.
|
||||
~
|
||||
~ Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along
|
||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
</resources>
|
||||
@@ -160,11 +160,9 @@
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:key="rateApp"
|
||||
android:title="@string/pref_rate_this_app"
|
||||
app:iconSpaceReserved="false">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="@string/playStoreURL" />
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
|
||||
3
uhabits-core/assets/test/habitbull4.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
HabitName,HabitDescription,HabitCategory,CalendarDate,Value,CommentText
|
||||
Caffeine,,Coffee Consumption,2022-11-21,80,
|
||||
Caffeine,,Coffee Consumption,2022-11-22,80,
|
||||
|
@@ -43,13 +43,12 @@ kotlin {
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
compileOnly("com.google.dagger:dagger:2.41")
|
||||
compileOnly("com.google.dagger:dagger:2.44.2")
|
||||
implementation("com.google.guava:guava:31.1-android")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.1")
|
||||
implementation("androidx.annotation:annotation:1.3.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4")
|
||||
implementation("androidx.annotation:annotation:1.5.0")
|
||||
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||
implementation("com.opencsv:opencsv:5.6")
|
||||
implementation("com.opencsv:opencsv:5.7.1")
|
||||
implementation("commons-codec:commons-codec:1.15")
|
||||
implementation("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
@@ -59,7 +58,7 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
implementation(kotlin("test-junit"))
|
||||
implementation("org.xerial:sqlite-jdbc:3.36.0.3")
|
||||
implementation("org.xerial:sqlite-jdbc:3.40.0.0")
|
||||
implementation("org.hamcrest:hamcrest:2.2")
|
||||
implementation("org.apache.commons:commons-io:1.3.2")
|
||||
implementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
|
||||
|
||||
@@ -86,10 +86,12 @@ class HabitBullCSVImporter
|
||||
logger.info("Found a value of $value, considering this habit as numerical.")
|
||||
h.type = HabitType.NUMERICAL
|
||||
}
|
||||
h.originalEntries.add(Entry(timestamp, value, notes))
|
||||
h.originalEntries.add(Entry(timestamp, value * 1000, notes))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map.forEach { (_, habit) -> habit.recompute() }
|
||||
}
|
||||
|
||||
private fun parseTimestamp(rawValue: String): Timestamp {
|
||||
|
||||
@@ -149,7 +149,7 @@ class HabitsCSVExporter(
|
||||
|
||||
val timeframe = getTimeframe()
|
||||
val oldest = timeframe[0]
|
||||
val newest = DateUtils.getTodayWithOffset()
|
||||
val newest = DateUtils.getToday()
|
||||
val checkmarks: MutableList<ArrayList<Entry>> = ArrayList()
|
||||
val scores: MutableList<ArrayList<Score>> = ArrayList()
|
||||
for (habit in selectedHabits) {
|
||||
|
||||
@@ -204,16 +204,9 @@ open class EntryList {
|
||||
// Copy original entries
|
||||
original.forEach { entry ->
|
||||
val offset = entry.timestamp.daysUntil(to)
|
||||
val value = if (
|
||||
result[offset].value == UNKNOWN ||
|
||||
entry.value == SKIP ||
|
||||
entry.value == YES_MANUAL
|
||||
) {
|
||||
entry.value
|
||||
} else {
|
||||
YES_AUTO
|
||||
if (result[offset].value == UNKNOWN || entry.value == SKIP || entry.value == YES_MANUAL) {
|
||||
result[offset] = entry
|
||||
}
|
||||
result[offset] = Entry(entry.timestamp, value, entry.notes)
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
@@ -57,7 +57,7 @@ class BarCardPresenter(
|
||||
} else {
|
||||
boolBucketSizes[boolSpinnerPosition]
|
||||
}
|
||||
val today = DateUtils.getTodayWithOffset()
|
||||
val today = DateUtils.getToday()
|
||||
val oldest = habit.computedEntries.getKnown().lastOrNull()?.timestamp ?: today
|
||||
val entries = habit.computedEntries.getByInterval(oldest, today).groupedSum(
|
||||
truncateField = ScoreCardPresenter.getTruncateField(bucketSize),
|
||||
|
||||
@@ -91,6 +91,7 @@ class HistoryCardPresenter(
|
||||
screen.showCheckmarkPopup(
|
||||
entry.value,
|
||||
entry.notes,
|
||||
preferences,
|
||||
habit.color,
|
||||
) { newValue, newNotes ->
|
||||
commandRunner.run(
|
||||
@@ -129,6 +130,7 @@ class HistoryCardPresenter(
|
||||
screen.showNumberPopup(
|
||||
value = oldValue / 1000.0,
|
||||
notes = entry.notes,
|
||||
preferences = preferences,
|
||||
) { newValue: Double, newNotes: String ->
|
||||
val thousands = (newValue * 1000).roundToInt()
|
||||
commandRunner.run(
|
||||
@@ -201,11 +203,13 @@ class HistoryCardPresenter(
|
||||
fun showNumberPopup(
|
||||
value: Double,
|
||||
notes: String,
|
||||
preferences: Preferences,
|
||||
callback: ListHabitsBehavior.NumberPickerCallback,
|
||||
)
|
||||
fun showCheckmarkPopup(
|
||||
selectedValue: Int,
|
||||
notes: String,
|
||||
preferences: Preferences,
|
||||
color: PaletteColor,
|
||||
callback: ListHabitsBehavior.CheckMarkDialogCallback,
|
||||
)
|
||||
|
||||
@@ -125,30 +125,4 @@ class WidgetTheme : LightTheme() {
|
||||
override val highContrastTextColor = Color.WHITE
|
||||
override val mediumContrastTextColor = Color.WHITE.withAlpha(0.50)
|
||||
override val lowContrastTextColor = Color.WHITE.withAlpha(0.10)
|
||||
|
||||
override fun color(paletteIndex: Int): Color {
|
||||
return when (paletteIndex) {
|
||||
0 -> Color(0xD32F2F)
|
||||
1 -> Color(0xE64A19)
|
||||
2 -> Color(0xF57C00)
|
||||
3 -> Color(0xFF8F00)
|
||||
4 -> Color(0xF9A825)
|
||||
5 -> Color(0xAFB42B)
|
||||
6 -> Color(0x7CB342)
|
||||
7 -> Color(0x388E3C)
|
||||
8 -> Color(0x00897B)
|
||||
9 -> Color(0x00ACC1)
|
||||
10 -> Color(0x039BE5)
|
||||
11 -> Color(0x1976D2)
|
||||
12 -> Color(0x6275f0)
|
||||
13 -> Color(0x5E35B1)
|
||||
14 -> Color(0x8E24AA)
|
||||
15 -> Color(0xD81B60)
|
||||
16 -> Color(0x5D4037)
|
||||
17 -> Color(0x757575)
|
||||
18 -> Color(0x757575)
|
||||
19 -> Color(0x9E9E9E)
|
||||
else -> Color(0x000000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ abstract class DateUtils {
|
||||
fun getStartOfTodayWithOffset(): Long = getStartOfDayWithOffset(getLocalTime())
|
||||
|
||||
@JvmStatic
|
||||
fun millisecondsUntilTomorrowWithOffset(): Long = getStartOfTomorrowWithOffset() - applyTimezone(getLocalTime())
|
||||
fun millisecondsUntilTomorrowWithOffset(): Long = getStartOfTomorrowWithOffset() - getLocalTime()
|
||||
|
||||
@JvmStatic
|
||||
fun getStartOfTodayCalendar(): GregorianCalendar = getCalendar(getStartOfToday())
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.isoron.uhabits.core.utils
|
||||
|
||||
import org.isoron.uhabits.core.AppScope
|
||||
import org.isoron.uhabits.core.io.Logging
|
||||
import java.util.LinkedList
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.ScheduledExecutorService
|
||||
@@ -30,10 +29,9 @@ import javax.inject.Inject
|
||||
* A class that emits events when a new day starts.
|
||||
*/
|
||||
@AppScope
|
||||
open class MidnightTimer @Inject constructor(logging: Logging) {
|
||||
open class MidnightTimer @Inject constructor() {
|
||||
private val listeners: MutableList<MidnightListener> = LinkedList()
|
||||
private lateinit var executor: ScheduledExecutorService
|
||||
private val logger = logging.getLogger("MidnightTimer")
|
||||
|
||||
@Synchronized
|
||||
fun addListener(listener: MidnightListener) {
|
||||
@@ -41,10 +39,7 @@ open class MidnightTimer @Inject constructor(logging: Logging) {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun onPause(): MutableList<Runnable>? {
|
||||
logger.info("Pausing timer")
|
||||
return executor.shutdownNow()
|
||||
}
|
||||
fun onPause(): MutableList<Runnable>? = executor.shutdownNow()
|
||||
|
||||
@Synchronized
|
||||
fun onResume(
|
||||
@@ -52,11 +47,9 @@ open class MidnightTimer @Inject constructor(logging: Logging) {
|
||||
testExecutor: ScheduledExecutorService? = null
|
||||
) {
|
||||
executor = testExecutor ?: Executors.newSingleThreadScheduledExecutor()
|
||||
val initialDelay = DateUtils.millisecondsUntilTomorrowWithOffset() + delayOffsetInMillis
|
||||
logger.info("Scheduling refresh for $initialDelay ms from now")
|
||||
executor.scheduleAtFixedRate(
|
||||
{ notifyListeners() },
|
||||
initialDelay,
|
||||
DateUtils.millisecondsUntilTomorrowWithOffset() + delayOffsetInMillis,
|
||||
DateUtils.DAY_LENGTH,
|
||||
TimeUnit.MILLISECONDS
|
||||
)
|
||||
@@ -67,7 +60,6 @@ open class MidnightTimer @Inject constructor(logging: Logging) {
|
||||
|
||||
@Synchronized
|
||||
private fun notifyListeners() {
|
||||
logger.info("Midnight refresh")
|
||||
for (l in listeners) {
|
||||
l.atMidnight()
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ class ImportTest : BaseUnitTest() {
|
||||
assertThat(habit.type, equalTo(HabitType.NUMERICAL))
|
||||
assertThat(habit.description, equalTo(""))
|
||||
assertThat(habit.frequency, equalTo(Frequency.DAILY))
|
||||
assertThat(getValue(habit, 2021, 9, 1), equalTo(30))
|
||||
assertThat(getValue(habit, 2022, 1, 8), equalTo(100))
|
||||
assertThat(getValue(habit, 2021, 9, 1), equalTo(30000))
|
||||
assertThat(getValue(habit, 2022, 1, 8), equalTo(100000))
|
||||
|
||||
val habit2 = habitList.getByPosition(1)
|
||||
assertThat(habit2.name, equalTo("run"))
|
||||
@@ -98,6 +98,21 @@ class ImportTest : BaseUnitTest() {
|
||||
assertTrue(isChecked(habit2, 2022, 1, 19))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(IOException::class)
|
||||
fun testHabitBullCSV4() {
|
||||
importFromFile("habitbull4.csv")
|
||||
assertThat(habitList.size(), equalTo(1))
|
||||
|
||||
val habit = habitList.getByPosition(0)
|
||||
assertThat(habit.name, equalTo("Caffeine"))
|
||||
assertThat(habit.type, equalTo(HabitType.NUMERICAL))
|
||||
assertThat(habit.description, equalTo(""))
|
||||
assertThat(habit.frequency, equalTo(Frequency.DAILY))
|
||||
assertThat(getValue(habit, 2022, 11, 21), equalTo(80000))
|
||||
assertThat(getValue(habit, 2022, 11, 22), equalTo(80000))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(IOException::class)
|
||||
fun testLoopDB() {
|
||||
|
||||