Commit Graph

118 Commits

Author SHA1 Message Date
Amanda Bullington
182196a205 Change url for connectivity check (#1868)
* Change connectivity url to ping inat; remove unnecessary useIsConnected hook; closes #1770

* Ensure inaturalist.org/ping is being pinged

* Fix e2e tests by using isConnected, not isInternetReachable
2024-07-26 20:16:32 -07:00
Ken-ichi
10bbea44c4 e2e mock for Geolocation.watchPosition to deflake tests (#1842) 2024-07-24 17:15:03 -07:00
Amanda Bullington
abd4bcee23 Refactored location fetching for accurate locations (#1788)
* Refactor to use watchPosition

* Update useWatchPosition with permissions/retry

* Replace useUserLocation with useWatchPosition and fix tests; return userLocation from watch position hook

* Only update observation keys when there's an observation

* Improve TypeScript definitions

* Revert TypeScript commit

* Revert "Only update observation keys when there's an observation"

This reverts commit a4cd17a513.

* Code cleanup: make useWatchPosition more modular

* Code cleanup; location permission in ObsEdit instead of subcomponent

* Use correct accuracy in Camera photos

* Camera fixes

* Fixes to watching position in ObsEdit

* Fix useWatchPosition tests

* Fix tests

* Make sure state updates when renavigating to OsEdit; test fixes
2024-07-16 09:23:09 -07:00
Johannes Klein
a52996f535 Changes to the way permissions are asked for (#1793)
* Replace name in permission requests

* TakePhoto TS

* PermissionGate TS

* Type

* PermissionGateContainer TS

* Interface

* Types

* LocationGate TS

* Remove LocationPermissionGate from Camera

* Remove write only permission

* Type

* ObsPhotoSelectionList TS

* Code style

* Show the improve with location button

* Create useLocationPermission.tsx

* Use new hook on suggestions

* Doc comment

* Use new hook in camera view

* Add strings

* Refactor Explore main content

* Use permission hook on RootExplore

* Add no location permission component

* Rename function

* Prop request permissions and use with button

* Default to Nearby label

* Remove Node type

* Projects TS

* Use useLocationPermission hook in projects screen

* Add string

* Prop permission down

* Refactor list render

* Refactor tab id into enum

* Tab type

* On nearby tab if without permission show button to prompt

* Leftovers

* Remove location permission gate from ObsEdit

* Use location permission hook on evidence section

* SearchBar TS

* Do not autoFocus on search bar in location picker.

Closes #1743

* Update type

* LocationSearch TS

* Show location permission gate on location picker's mount

* Add location permission to CurrentLocationButton

* Remove unused props of Map

* Remove unused exports from useMapLocation

* Migration

* Revert "Show location permission gate on location picker's mount"

This reverts commit 30ff75698c53d54d0b14cd2bd629f7155b743bf8.

* Add callbacks to useLocationPermission hook

* Show location permission ask on Obs Edit

* Remove unused string

* Reset explore filters should set location always to worldwide

* Add helper function to show place text in Explore

* Remove unused state of filter modal

* Show place text in filters modal with helper

* Show location permission button only for Nearby explore state

* Add a placeMode state

* Do not send placeMode to API

* Also treat limited permission as yes

* useLocationPermission in ExploreLocationSearch

* Refactor to setting place mode

Instead of logic based on the translated text of the place_guess string that is stored in ExploreContext, we are switching to an enum state that signifies which mode to show on explore:
1.) Nearby: Filters explore results based on the user's location. This also has a state without location permission that does not query the API.
2.) Place: Filtering by a specific place (as retrieved by /places API).
3.) Worldwide: Retrieve worldwide results, i.e. not having a place filter set.
4.) Map area: Filtering explore results precisely to the map rectangle shown on the explore map.

* Remove import from test

* Remove export

* Use blocked title only for blocked permission asks

* Move gallery permission container to Tab navigator as are the others

* Add gallery save title

* Split location permission explanation into two

* Update strings.ftl

* Only nav to location picker if permission was not  granted

* Check permission on app being foregrounded

* The location permission part is handled by useLocationPermission

* Do not store permission result in hook

* Use hasPermission from permissions hook

* Update fetchUserLocation.e2e-mock

* Move hook one higher

* Show user location if permission is given

* PermissionGate callbacks should use useCallback

* Add permission hook to map usage

* Fix test

* Update layout to be asserted

* Add location permission hook to Explore

* Remove console.log

* Few TS fixes

* Indentation

* Remove superficial check

* Update Podfile.lock
2024-07-12 11:00:24 +02:00
Ken-ichi
fe0229291e Restore photo deletion (#1789)
* Restore photo deletion
* Rename methods for accessing media files
* Added integration test for photo deletion
* Cleaned up some accessibility labels

Closes #1429
2024-07-10 15:23:53 -07:00
Ken-ichi
50d9d1e60c Media clearing (#1771)
* (Re-)Fix bug where shared photo got deleted before it could be used
* Only run cleanup when MyObs has focus
* Only run cleanup once a minute
* Only delete files that are a day old or more
2024-07-05 21:33:52 -07:00
Ken-ichi
464899f111 Restore removal of synced photos (#1768)
Closes #1741
2024-07-04 13:25:04 -07:00
Johannes Klein
230646e2ae 1684 explore map null (#1760) 2024-07-03 16:33:08 +02:00
Johannes Klein
09f4abdf9b Revert "Vision camera update with orientation support (#1713)"
This reverts commit de36644fe8.
2024-06-29 16:01:46 +02:00
Johannes Klein
103db8b99a Revert "Fix rotation value (#1714)"
This reverts commit ecde900a9e.
2024-06-29 16:01:26 +02:00
Ken-ichi
effbb01fd9 Try to ensure we send a valid URI to getPredictionsForImage() (#1724)
Closes #1715
2024-06-28 20:13:55 -07:00
Johannes Klein
ecde900a9e Fix rotation value (#1714) 2024-06-27 10:15:15 +02:00
Johannes Klein
de36644fe8 Vision camera update with orientation support (#1713)
* Update vision camera

* Remove no longer needed VeryBadIpadRotator

* Remove orientation prop

* Update vision plugin

* Remove frame processor patch

* Remove unused import

* Update rotation patch

* Remove unused param
2024-06-26 12:01:10 +02:00
Ken-ichi Ueda
917894068d Try to handle an edge case with API errors 2024-06-25 14:19:27 -07:00
Amanda Bullington
d9d7a6ff06 Suggestions screen UI fixes, location toggle, and offline reloading state (#1708)
* UI changes to suggestions screen

* Update offline suggestions UI and allow refetch

* Allow user to search online suggestions with and without evidence location

* Add improve location button and refactor header

* Use loading screen correctly between location/ignore location

* Hide location permission button and code cleanup

* Fix test for suggestions changes
2024-06-24 16:26:40 -07:00
Ken-ichi
835b3ecb1f Location fixes (#1691)
* Try to avoid stale coordinates when fetching from cameras by removing the location in state when the screen blurs... I think. This might not be working. The other approach I tried was to wrap the Camera in Mortal, but that led to test problems. Might be worth revisiting if this approach doesn't work
* Bugfix: shared photos w/o coords were fetching current location
* Restored relative path to get fetchUserLocation.e2e-mock working again
2024-06-18 11:40:30 -07:00
Ken-ichi Ueda
bc44cf61e9 Try to log around bug uploading photos 2024-06-17 16:29:52 -07:00
Johannes Klein
7c91bdf950 Obsedit add photo with StandardCamera, two fixes (#1677)
* Reorder hooks dependencies

* Return uri from take photo hook

* Keep state of photos added in this instance of the camera

* List2 TS

* INatIconButton TS

* Refactor useBackPress to show discard modal only if photos taken during this instance of the camera

* Remove newPhotoCount var

* TS refactors

* fetchUserLocation TS

* Increase timeout

* Fix error

* Hoist deletePhotoByUri

* Delete photos on discard

* Reorder code

* Set saving photo on checkmark press

Closes #1556

* Update snapshots

* Remove delete test

* Create StandardCamera.test.js

* Check if image is there before deletion

* Update react-native-share-menu+6.0.0.patch

* Update e2e_ios.yml

* Update some types
2024-06-14 14:04:24 +02:00
Ken-ichi
f3bcec2d2e Continuous location fetch in the cameras (#1673)
* Fetch location continuously in cameras until accuracy falls below threshold
* Unit test for useUserLocation
* Added untilAcc option to useUserLocation
* Bugfix: ObsEdit was not always fetching location for new camera photos

Closes #1340
2024-06-12 11:18:12 -07:00
Ken-ichi Ueda
33d93439a5 Some defense around some common errors 2024-06-10 14:55:47 -07:00
Ken-ichi
5c6e88cbc1 Typescrpt path aliases (#1648)
* Typescrpt path aliases;
* Tried to resolve all ts errors in one file
2024-06-05 14:35:49 -07:00
Ken-ichi
8dbbca04d9 Fail upload when network request failed (#1651)
* Fixed cancel upload button
* Uploads will timeout after 15s
* Moved MyObs tests unrelated to unsynced into the synced block
2024-06-04 18:23:59 -07:00
Amanda Bullington
34f18dc6bc Handle modified but remotely deleted obs in upload process (#1628)
* Map realm observations to smaller objects for displaying in MyObservations

* Handle obs remotely deleted in upload UI and process; closes #1579

* Multiple modified and remotely deleted observations handled in upload process

* Revert to using full Realm objects in FlashList
2024-05-31 18:16:23 -07:00
Amanda Bullington
aa167c669d Refactor upload functionality into hook/zustand (#1606)
* Refactor upload code into hook and zustand slice

* Create a single source of truth for toolbar and individual progress

* Fix unit tests

* Fix more tests

* Continue trying to simplify upload progress and status code

* Continued overhaul of upload code

* Fix exclamation point in Toolbar

* Fix total toolbar progress

* Fix tests

* Update snapshots

* Code cleanup

* Update MyObs test

* Fix most tests by not deleting realm

* Keep attempting to make toolbar text clear in subsequent tests

* Mock Zustand and reset state after all tests

In theory this should make testing with Zustand simpler. The real kicker is
that resetting state will fail if we're not careful about manually replacing
nested objects in Zustand state updates.

* Bugfix: removeAllFilesFromDirectory works with File objects, not raw paths

* Update status text when uploads canceled

* Only show red exclamation rotating icon after all uploads attempted

* Fix progress bar with zustand nested object

* Fix toolbar progress

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2024-05-30 20:36:50 -07:00
Ken-ichi Ueda
1aed88b9f9 Several attempts at error handling
* Catch 401 errors when we try to fetch remotely deleted obs for signed out
  users
* Skip the check to see if a user is a friend on UserProfile when signed out
* Replace uses of RNFS.unlink() with a wrapper that ignores errors about files
  not existing
* Tried to get safeRealmWrite to preserve error type before re-throwing
2024-05-29 17:32:43 -07:00
Ken-ichi
7ea60f7b9b Add X-Installation-ID logging (#1608)
* Add X-Installation-ID logging
* Allow logged out logging
* Log whether user has enabled advanced add obs btn
2024-05-24 21:06:20 -07:00
Ken-ichi
3d2550ffee Stop upload button (#1605)
Uses an altered version of inaturalistjs to pass in an AbortController signal
that will be passed through to fetch requests and can be used to cancel those
requests.
2024-05-23 16:24:01 -07:00
Ken-ichi
84c3b3c96d Track number of failed uploads (#1601) 2024-05-22 17:40:06 -07:00
budowski
fac15eb1e6 Use latest react-native-exif-reader package version; use writeLocation instead of writeExif (#1268)
* Use latest react-native-exif-reader package version; use writeLocation instead of writeExif
* Use react-native-exif-reader v0.4.0
2024-05-21 13:58:42 -07:00
Ken-ichi Ueda
9e4e652070 Bugfix: useClearSyncedPhotosForUpload should keep all unsynced obs photos
I.e. not just the first for an observation.
2024-05-15 17:13:32 -07:00
Ken-ichi
059c4ab8c4 Return to ObsEdit after taking additional photo (#1555)
* Renamed parseExif test
* Bugfix: could not import photo w/o exif from ObsEdit for new obs
* Ensure Camera screen is pushed onto stack from ObsEdit
2024-05-15 13:22:48 -07:00
Ken-ichi Ueda
7ca96536c2 Wrap react-native-sensitive-info methods with retry
Errors from this library with a message like "Protected data not available
yet" are the most-logged error from the app, even if the user doesn't see
them, so this will hopefully stop them from polluting our logs so much.
2024-05-14 14:49:52 -07:00
Amanda Bullington
36806b1bec Clear uploaded sounds to reduce app document size (#1530)
* Clear uploaded sounds to reduce app document size

* Code cleanup
2024-05-13 11:23:54 -07:00
Amanda Bullington
e7c4fdbe5e Store original rotated photos temporarily during Camera -> ObsEdit flow (#1522)
* Check for CV directory

* Save original, rotated photos for processing; clear directory when user lands on MyObs

* Reset evidenceToAdd when user lands on StandardCamera

* Disable photo taking while loading so one photo doesn't overwrite another
2024-05-09 22:24:45 -07:00
Amanda Bullington
917f9da7be Clear cached photos for computervision/score_image (#1518)
* Refactor image-resizer into helper function for easy logging

* Create a folder for computerVisionSuggestions

* Display iNat app directories in Debug

* Delete old images from computerVisionSuggestions/ when navigating away from Suggestions

* Fix online suggestions API call

* Fix tests

* Clear computer vision directory when landing on Suggestions screen
2024-05-09 13:32:52 -07:00
Amanda Bullington
e19221ddf0 Reduce app size (fonts and model/taxonomy assets) (#1513)
* Remove material community icons

* Remove unneeded font files from app

* Show app size in Debug on Android

* Update snapshots

* Code cleanup
2024-05-08 09:22:01 -07:00
Johannes Klein
ea6539e35a Vision camera v4.0.3 (#1515)
* Upgrade vision-camera, worklets and plugin

* Update Podfile.lock

* Update runAsync patch

* Update comment

* Update jest.setup.js
2024-05-08 13:48:16 +02:00
Ken-ichi
a7a2e1c10f Show up-to-date metadata for observations immediately after upload (#1497)
This fetches a remote copy of each observation after upload to make sure the
client has the freshest copy of the data immediately.
2024-05-06 17:50:46 -07:00
Johannes Klein
05b6309307 Vision camera 4.0.1 (#1437)
* Update camera and plugin packages

* Remove one patch

* Replace deprecated function

* Update runAsync patch

Removing this patch leads to non-functioning frame processors in release builds. Contrary to what the original issue's solution states.
2024-04-23 14:27:27 +02:00
Amanda Bullington
21b9cc6a97 Update Eslint to support TypeScript (#1419)
* Add typescript parser and fix Flow errors in JS files

* Uninstall packages from react-native/eslint-config

* Fix all flow errors (or ignore them for unknowns
2024-04-18 21:35:26 -07:00
Ken-ichi
205122d74e Sound model (#1416)
* Sound model; refactor for basic sound creation and playback
* Fetch sound attribution and license_code fields
2024-04-18 12:07:20 -07:00
Ken-ichi
fbf93e40d1 Add pre-commit checks for unused i18n keys and used keys not in strings.ftl (#1343)
FYI, this also essentially outlaws variables in translation keys because a key
that is only used with interpolated strings will never appear as "used".

Also starts using a convention of adding info to i18n keys that do not relate
to the text after double dashes, e.g. `Unknown--taxon = Unknown` for a string
that is specifically meant to describe a missing taxon but only needs to have
the word "Unknown".

* Changed several accessibilityHints to 3rd person
* Made several accessibilityLabels shorter and more verb-oriented
* Removed many unused i18n keys
* Refactored variables in i18n keys
* Removed some unused code from the old Settings
2024-04-02 12:17:57 -07:00
Amanda Bullington
4916e960c3 Show Suggestions after camera in ObsEdit flow (#1294)
* Navigate user to Suggestions after Camera; add location check to usePrepareStateForObsEdit function

* Test that Camera advances to Suggestions when checkmark tapped

* Use vision result as top suggestion on Suggestions screen

* Write AR nav test; filter vision result from all suggestions list

* Show LocationPermission on camera screen; navigate back from ObsEdit

* Updates to flow so user can back out of ObsEdit to cameras

* Fixes

* Add evidence to existing observation when backing out of ObsEdit flow

* Fix tests

* Add mocks for worklet functions

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2024-03-27 12:34:37 -07:00
Johannes Klein
0e0a6560ac Vision camera v3 (#1121)
* Bump vision-camera

* Refactor patch

* Move patched orientation into patch functions file

* Update react-native-vision-camera+3.4.1.patch

* Switch to MacOS 13 runner

Vision camera requires XCode 15 to compile.

* Add step to specify XCode 15

* Higher level of logging

* Increase test timeout

* Add comment

* Remove navigation to obs without evidence for signed out user

* Patch for location permission not working on iOS

* Increase setup timeout

* Increase some more timeouts

* Revert back to less logging in CI

* Does it have to do with timeouts?

* Trace log level

* Update README.md

* Disable Homebrew’s auto update and install cleanup

* Setup ruby step

* Install pods only if not cached

* Revert "Install pods only if not cached"

This reverts commit 42a2ea02f9.

* Run simulator in headless mode, record all logs

* Increase timeouts again

* Revert "Remove navigation to obs without evidence for signed out user"

This reverts commit 2b4718f5ce.

* Add boolean to run use effect only once

* Did merge wrong code

* There is one more permission gate when entering obs edit now

* Add permission gate dismissal to signed out user test

* Add comment, rename state

* Lower action timeout

* Update react-native-vision-camera to 3.6, update Reanimated to v3 (#838)

* Bump camera and plugin

* Upgrade Reanimated and libs using it

* Update vision-camera mock

* Remove superfluous patch

* Fix type

* Add mocks for e2e tests because bottom sheet does not work on AOSP

* Update package-lock.json

* Update vision camera

* Bump vision camera

* Update vision camera patch version

* Remove superfluous patch

* Update vision camera

* Update vision-camera and plugin

* Use latest vision plugin = rebased v3

* Run npm clean-start

* No longer needed

* Duplicate prop

* Switch back to v3 code

* Upgrading Detox fixes issue with iOS tests failing

Because of previous lack of permissions.

* Update to latest detox version

* Npm i force

* Vision 3 e2e testing, (#1126)

* Remove jest detox config

* Revert e2e timeout increase

* Revert jest config timeout

* Use macos 14 runner which has XCode 15 per default

* Use latest bottom sheet

* Revert "Use latest bottom sheet"

This reverts commit c66cd09838.

* Adding comma back in

* Remove spaces

* Use latest vision-camera and plugin

* Use release version of vision-camera

* Remove force flag

* Update react-native-worklets-core

* Upgrade reanimated

* Update babel.config to allow nested worklets

* Run frame processor async

* Remove enableGpuBuffers flag

* Remove no longer needed comment

* Update comments about version

* Update vision-camera and plugin

* Code format

* Rename param

* Use latest-plugin

* Remove fps param from camera view

* Change confidenceThreshold to number

* API change for results structure

* Refactor fps to be checked inside hook

As of vision-camera 3.9.1 our camera feed is stuttering when calling the runAtTargetFps function inside the useFrameProcessor hook.
So, what I did here is to track the time and skip the frames that are received before the target fps is reached.

* Remove updates of non-camera related

* Update comment

* Code format

* Snapshot updates

* Revert changes to ios e2e

* Add a log for the average time it takes a frame to be processed

* Use release version of plugin

* Add a patch for runAsync to work in release builds

* Update react-native-worklets-core to 0.4.0

* Use latest plugin version

* Add a shift method to worklet arrays

* Use latest vision-plugin

This makes use of .shift() in worklet array and depends on the previous patch.

* Set result timestamp and show age of result in debug mode

* Fix an error with timestamp being undefined

* Remove log

* Use latest vision plugin

* Change result timestamp to pink

* Comment

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2024-03-27 00:47:43 +01:00
Ken-ichi
97fd4f2874 Try to catch and log errors during upload (#1283)
* Try to catch and log errors during upload
* Wraps some upload async methods with try/catch to attempt to log some
  potential bugs
* Adjusts upload param mappings
* Try to get upload status to more accurately reflect the upload state
* Consistent upload success messaging after single upload
2024-03-22 19:17:45 -07:00
budowski
1671ce20a1 Improve algorithm for detecting nearby points when tapping on Explore map
Closes #1214
2024-03-14 16:46:45 -07:00
Johannes Klein
0b73cef457 Update counting of increments on uploading / also count sounds (#1263)
* Only emit progress on finished upload

* Set one initial progress increment on upload start

* Comments

* Send only half step increment on evidence upload

Because this function gets called twice per evidence.

* Update comment

* Also calculate sounds as increments towards progress bar

* Wrong order

* Only emit progress on finished upload

* Set one initial progress increment on upload start

* Comments

* Send only half step increment on evidence upload

Because this function gets called twice per evidence.

* Update comment

* Also calculate sounds as increments towards progress bar

* Wrong order

* Remove the initial progress being set as totalProgressIncrement

* Show an initial toolbar progress even if no progress made yet

* Fix for completion of no media obs upload

* Add comment
2024-03-08 16:37:58 +01:00
Ken-ichi
71a154b432 Bugfix: undead observations arose if sync happened too soon after death (#1240)
* Wait to fetch until at least 10s after deletion finished
* Bottom sheet warning and immediate departure when landing on ObsDetails for
  an obs that was deleted
2024-03-01 09:40:55 -08:00
Johannes Klein
e4d7e337e7 Consolidate vision returns (#1239)
* Use latest vision-plugin from feature branch

* Change model helper to TS

* Update prediction from image to the new return structure

* Rename variable

* Change ARCamera to new return structure

* Update all test that make use of predictions

* Update to use plugins main branch
2024-03-01 00:23:52 +01:00
budowski
26701312de Try to fill out missing metadata using all photos in an obs
* when importing photos, try to fill out EXIF data (location+date) from all photos, by order
* handle cases of adding photos to existing unsynced obs

Closes #1093
2024-02-23 18:34:30 -08:00