feat(log): check a typed grid before it reaches the log

The grid field accepted anything six characters long, so "ZZ99ZZ", "123456" and a callsign
all reached WavelogQso.gridsquare and then the ADIF GRIDSQUARE field. Wavelog stores what
arrives, and a wrong square is worse than a missing one: it pollutes grid statistics and VUCC
tracking, where the error is invisible until an award check disagrees with the log.

GridEntry follows the rule the callsign field settled on - refuse only what is certainly
wrong. It rejects a length Maidenhead does not have, a field pair past R (S-X decodes beyond
the poles, which is how a plausible entry produces an impossible position), a square pair
that is not digits, and a subsquare past X. Everything else is accepted.

Four characters is accepted with a note that it is only accurate to about 100km, because
plenty of satellite operators exchange only the square and refusing that would reject good
data. The app's own isValidLocator could not be reused: it requires six characters and is
private.

Two things the field does better now. It takes eight characters rather than six, since the
extended form exists and truncating it would silently move the location. And case is
normalised on commit rather than while typing, so the cursor no longer jumps mid-entry - the
logged value is OL72ap, the conventional rendering, whatever was typed.

14 tests, including a cross-check that anything accepted at six characters or more also
decodes through the app's own qthToPosition. Without that the two would be free to disagree
about what a grid is.
This commit is contained in:
mckero committed 2026-08-26 11:32:49 +00:00
1 parent cb3ebe7870
commit 6c67aa2718
5 files changed
+309 -3

No files matched your search

@@ -278,6 +278,8 @@
<string name="wavelog_call_hint">对方呼号</string>
<string name="wavelog_grid_hint">网格 (可选)</string>
<string name="wavelog_grid_help">对方报给你的网格。留空则从 QRZ 查询。</string>
<string name="wavelog_grid_bad">不是有效网格</string>
<string name="wavelog_grid_square_only">仅方格 - 精度约 100 公里</string>
<string name="wavelog_mode_hint">模式</string>
<string name="wavelog_mode_edit">修改模式</string>
<string name="wavelog_time_hint">时间</string>
@@ -309,6 +309,8 @@
<string name="wavelog_call_hint">Callsign</string>
<string name="wavelog_grid_hint">Grid (optional)</string>
<string name="wavelog_grid_help">What they sent you. Left empty, it is looked up on QRZ.</string>
<string name="wavelog_grid_bad">Not a grid square</string>
<string name="wavelog_grid_square_only">Square only - accurate to about 100 km</string>
<string name="wavelog_mode_hint">Mode</string>
<string name="wavelog_mode_edit">Edit the mode</string>
<string name="wavelog_time_hint">Time</string>