forked from N0BOY/FT8CN
-
Notifications
You must be signed in to change notification settings - Fork 5
Export QSOs: date-range filter uses a Material date picker (typing still works) #627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
patrickrb
merged 2 commits into
dev
from
optio/task-ff6d8752-c276-4e54-8b0e-237c3639af6e
Jul 22, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="@color/help_dialog_text_color"> | ||
| <path | ||
| android:fillColor="#FFFFFFFF" | ||
| android:pathData="M19,3h-1V1h-2v2H8V1H6v2H5C3.9,3 3,3.9 3,5v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5C21,3.9 20.1,3 19,3zM19,19H5V9h14V19zM19,7H5V5h14V7z" /> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
ft8af/app/src/test/java/com/k1af/ft8af/ui/ExportLogSheetDateTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| package com.k1af.ft8af.ui; | ||
|
|
||
| import static com.google.common.truth.Truth.assertThat; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| import java.util.TimeZone; | ||
|
|
||
| /** | ||
| * Unit tests for the date parsing/validation/formatting helpers in | ||
| * {@link ExportLogSheet} that back the Export QSOs date-range picker. These | ||
| * guarantee the picker path and the typed path both yield the strict | ||
| * {@code YYYYMMDD} string the {@code ShareLogs} query layer expects. | ||
| */ | ||
| public class ExportLogSheetDateTest { | ||
|
|
||
| // MaterialDatePicker.todayInUtcMilliseconds() is UTC-based, so all conversions | ||
| // must be UTC regardless of the test machine's default zone. | ||
| private static final long UTC_20260722 = utc(2026, 7, 22); | ||
|
|
||
| private static long utc(int year, int month, int day) { | ||
| java.util.Calendar c = java.util.Calendar.getInstance(TimeZone.getTimeZone("UTC")); | ||
| c.clear(); | ||
| c.set(year, month - 1, day, 0, 0, 0); | ||
| return c.getTimeInMillis(); | ||
| } | ||
|
|
||
| // ---- isValidOptionalDate: empty means "no bound" and is valid ---- | ||
|
|
||
| @Test | ||
| public void nullIsValid() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate(null)).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void emptyIsValid() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate("")).isTrue(); | ||
| assertThat(ExportLogSheet.isValidOptionalDate(" ")).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void wellFormedDateIsValid() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20260722")).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void surroundingWhitespaceIsTolerated() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate(" 20260722 ")).isTrue(); | ||
| } | ||
|
|
||
| // ---- isValidOptionalDate: malformed non-empty input is rejected ---- | ||
|
|
||
| @Test | ||
| public void wrongLengthIsInvalid() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate("2026072")).isFalse(); // 7 digits | ||
| assertThat(ExportLogSheet.isValidOptionalDate("202607221")).isFalse(); // 9 digits | ||
| } | ||
|
|
||
| @Test | ||
| public void nonNumericIsInvalid() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate("2026-07-22")).isFalse(); | ||
| assertThat(ExportLogSheet.isValidOptionalDate("2026Jul2")).isFalse(); | ||
| } | ||
|
|
||
| @Test | ||
| public void impossibleMonthIsInvalid() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20261301")).isFalse(); // month 13 | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20260001")).isFalse(); // month 00 | ||
| } | ||
|
|
||
| @Test | ||
| public void impossibleDayIsInvalid() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20260230")).isFalse(); // Feb 30 | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20260231")).isFalse(); // Feb 31 | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20260732")).isFalse(); // day 32 | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20260700")).isFalse(); // day 00 | ||
| } | ||
|
|
||
| @Test | ||
| public void leapDayValidatesCorrectly() { | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20240229")).isTrue(); // 2024 is a leap year | ||
| assertThat(ExportLogSheet.isValidOptionalDate("20260229")).isFalse(); // 2026 is not | ||
| } | ||
|
|
||
| @Test | ||
| public void yearZeroIsRejected() { | ||
| // SimpleDateFormat would otherwise silently normalize this — the round-trip guards it. | ||
| assertThat(ExportLogSheet.isValidOptionalDate("00000101")).isFalse(); | ||
| } | ||
|
|
||
| // ---- parseYyyyMmddUtc: preselect value for the picker ---- | ||
|
|
||
| @Test | ||
| public void parseReturnsUtcMidnightMillis() { | ||
| assertThat(ExportLogSheet.parseYyyyMmddUtc("20260722")).isEqualTo(UTC_20260722); | ||
| } | ||
|
|
||
| @Test | ||
| public void parseInvalidReturnsNull() { | ||
| assertThat(ExportLogSheet.parseYyyyMmddUtc("not-a-date")).isNull(); | ||
| assertThat(ExportLogSheet.parseYyyyMmddUtc("")).isNull(); | ||
| assertThat(ExportLogSheet.parseYyyyMmddUtc(null)).isNull(); | ||
| } | ||
|
|
||
| // ---- formatYyyyMmddUtc: what a picker selection becomes ---- | ||
|
|
||
| @Test | ||
| public void formatProducesYyyyMmdd() { | ||
| assertThat(ExportLogSheet.formatYyyyMmddUtc(UTC_20260722)).isEqualTo("20260722"); | ||
| } | ||
|
|
||
| @Test | ||
| public void formatAndParseRoundTrip() { | ||
| Long millis = ExportLogSheet.parseYyyyMmddUtc("20250101"); | ||
| assertThat(millis).isNotNull(); | ||
| assertThat(ExportLogSheet.formatYyyyMmddUtc(millis)).isEqualTo("20250101"); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.