Skip to content

Commit

Permalink
v2.15.7 (#665)
Browse files Browse the repository at this point in the history
* Bump version

* Add TODOs

* Upgrade inaturalistjs

* Use global inatjs config instead of request specific user-agent

* Computer vision from file replacement for Android (#663)

* Use different plugin branch

* Replace prediction call with new plugin, add iOS

* Bump version

* Bundle update

* Use lates vision plugin

On Android this uses bilinear filter rescaling instead of nearest-neighbour.

* Upgrade RN 0.71.16

* Bump build

* Update Gemfile.lock
  • Loading branch information
jtklein authored Feb 9, 2024
1 parent 0c609f5 commit 4da580d
Show file tree
Hide file tree
Showing 21 changed files with 323 additions and 373 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ source "https://rubygems.org"
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '>= 2.6.10'

gem 'cocoapods', '>= 1.11.3'
# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
# bound in the template on Cocoapods with next React Native release.
gem 'cocoapods', '>= 1.13', '< 1.15'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
gem "fastlane"

Expand Down
55 changes: 27 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.881.0)
aws-sdk-core (3.190.3)
aws-partitions (1.887.0)
aws-sdk-core (3.191.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.76.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sdk-kms (1.77.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.142.0)
aws-sdk-core (~> 3, >= 3.189.0)
aws-sdk-s3 (1.143.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
Expand Down Expand Up @@ -74,7 +74,7 @@ GEM
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
Expand Down Expand Up @@ -159,38 +159,38 @@ GEM
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.2)
google-apis-androidpublisher_v3 (0.56.0)
google-apis-core (>= 0.12.0, < 2.a)
google-apis-core (0.13.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
googleauth (~> 1.9)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.31.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-iamcredentials_v1 (0.18.0)
google-apis-core (>= 0.12.0, < 2.a)
google-apis-playcustomapp_v1 (0.14.0)
google-apis-core (>= 0.12.0, < 2.a)
google-apis-storage_v1 (0.33.0)
google-apis-core (>= 0.12.0, < 2.a)
google-cloud-core (1.6.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.1.0)
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.3.1)
google-cloud-storage (1.47.0)
google-cloud-storage (1.48.1)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.31.0)
google-apis-core (~> 0.13)
google-apis-iamcredentials_v1 (~> 0.18)
google-apis-storage_v1 (~> 0.33)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
googleauth (~> 1.9)
mini_mime (~> 1.0)
googleauth (1.9.1)
googleauth (1.9.2)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
jwt (>= 1.4, < 3.0)
Expand All @@ -208,7 +208,7 @@ GEM
jwt (2.7.1)
mini_magick (4.12.0)
mini_mime (1.1.5)
minitest (5.21.1)
minitest (5.22.0)
molinillo (0.8.0)
multi_json (1.15.0)
multipart-post (2.3.0)
Expand Down Expand Up @@ -254,9 +254,8 @@ GEM
concurrent-ruby (~> 1.0)
uber (0.1.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcodeproj (1.23.0)
xcodeproj (1.24.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand All @@ -273,7 +272,7 @@ PLATFORMS

DEPENDENCIES
activesupport (>= 6.1.7.3, < 7.1.0)
cocoapods (>= 1.11.3)
cocoapods (>= 1.13, < 1.15)
fastlane
fastlane-plugin-versioning_android

Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ android {
applicationId "org.inaturalist.seek"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 332
versionName "2.15.6"
versionCode 335
versionName "2.15.7"
// for creating ic_seek_adaptiveappicon.xml
vectorDrawables.useSupportLibrary = true
}
Expand Down
31 changes: 15 additions & 16 deletions components/Camera/Gallery/GalleryImageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useCallback, useContext, useEffect, useState } from "react";
import { Platform, FlatList } from "react-native";
import type { Node } from "react";
import { getPredictionsForImage } from "react-native-inat-camera";
import { getPredictionsForImage } from "vision-camera-plugin-inatvision";
import { useNavigation } from "@react-navigation/native";

import { checkForPhotoMetaData } from "../../../utility/photoHelpers";
Expand Down Expand Up @@ -85,30 +85,29 @@ const GalleryImageList = ( { onEndReached, photos, setLoading }: Props ): Node =

const getPredictions = useCallback( ( uri, timestamp, location ) => {
const path = uri.split( "file://" );
const reactUri = path[1];
const reactUri = Platform.OS === "android" ? path[1] : uri;

getPredictionsForImage( {
uri: reactUri,
modelFilename: dirModel,
taxonomyFilename: dirTaxonomy
} ).then( ( { predictions } ) => {
navigateToResults( uri, timestamp, location, predictions );
} ).catch( ( err ) => {
console.log( "Error", err );
} );
modelPath: dirModel,
taxonomyPath: dirTaxonomy,
version: "1.0"
} )
.then( ( result ) => {
const { predictions } = result;
navigateToResults( uri, timestamp, location, Platform.OS === "android" ? predictions : result );
} )
.catch( ( err ) => {
console.log( "Error", err );
} );
}, [navigateToResults] );

const selectImage = useCallback( ( item ) => {
setImageSelected( true );
setLoading( );
const { timestamp, location, image } = item.node;

if ( Platform.OS === "android" ) {
getPredictions( image.uri, timestamp, location );
} else {
navigateToResults( image.uri, timestamp, location );
}
}, [getPredictions, navigateToResults, setLoading] );
getPredictions( image.uri, timestamp, location );
}, [getPredictions, setLoading] );

const renderImage = useCallback( ( { item } ) => <GalleryImage item={item} selectImage={selectImage} />, [selectImage] );

Expand Down
17 changes: 10 additions & 7 deletions components/Home/Announcements/Announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import makeWebshell, {
useAutoheight
} from "@formidable-webview/webshell";

import createUserAgent from "../../../utility/userAgent";
import { UserContext } from "../../UserContext";
import { viewStyles, textStyles } from "../../../styles/home/announcements";
import GreenButton from "../../UIComponents/Buttons/GreenButton";
Expand Down Expand Up @@ -65,9 +64,7 @@ const Announcements = ( ): React.Node => {
};
const accessToken = await fetchAccessToken();
const apiToken = await fetchJSONWebToken( accessToken );
const headers = {};
headers["user-agent"] = createUserAgent();
const options = { api_token: apiToken, headers };
const options = { api_token: apiToken };
inatjs.announcements
.search( params, options )
.then( ( { total_results, results } ) => {
Expand All @@ -80,7 +77,10 @@ const Announcements = ( ): React.Node => {
.sort( ( a, b ) => new Date( a.start ) - new Date( b.start ) );
setAnnouncements( homeAnnouncements );
} )
.catch( ( err ) => console.log( err, "err fetching announcements" ) );
.catch( ( err ) => {
// TODO: handle error
console.log( err, "err fetching announcements" );
} );
}, [locale] );

const { userProfile } = useContext( UserContext );
Expand Down Expand Up @@ -109,7 +109,7 @@ const Announcements = ( ): React.Node => {
const dismiss = async ( ) => {
const accessToken = await fetchAccessToken();
const apiToken = await fetchJSONWebToken( accessToken );
const options = { api_token: apiToken, user_agent: createUserAgent() };
const options = { api_token: apiToken };
inatjs.announcements
.dismiss( { id }, options )
.then( ( ) => {
Expand All @@ -120,7 +120,10 @@ const Announcements = ( ): React.Node => {
// Refetch announcements
fetchAnnouncements();
} )
.catch( ( err ) => console.log( err, "err dismissing announcement" ) );
.catch( ( err ) => {
// TODO: handle error
console.log( err, "err dismissing announcement" );
} );
};

return (
Expand Down
7 changes: 1 addition & 6 deletions components/PostToiNat/hooks/postingHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import inatjs from "inaturalistjs";

import i18n from "../../../i18n";
import { capitalizeNames } from "../../../utility/helpers";
import createUserAgent from "../../../utility/userAgent";
import { fetchUserLocation } from "../../../utility/locationHelpers";

const useSearchSpecies = ( speciesName: ?string ): any => {
Expand All @@ -20,11 +19,7 @@ const useSearchSpecies = ( speciesName: ?string ): any => {
locale: i18n.locale
};

const headers = {};
headers["user-agent"] = createUserAgent();
const options = { headers };

inatjs.taxa.autocomplete( params, options ).then( ( { results } ) => {
inatjs.taxa.autocomplete( params ).then( ( { results } ) => {
if ( results.length === 0 ) { return; }

const newSuggestions = results.map( ( s ) => {
Expand Down
11 changes: 2 additions & 9 deletions components/Providers/ObservationProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Platform } from "react-native";
import inatjs from "inaturalistjs";

import iconicTaxaIds from "../../utility/dictionaries/iconicTaxonDictById";
import createUserAgent from "../../utility/userAgent";
import { fetchSpeciesSeenDate, serverBackOnlineTime } from "../../utility/dateHelpers";
import { addToCollection } from "../../utility/observationHelpers";
import { createLocationAlert } from "../../utility/locationHelpers";
Expand Down Expand Up @@ -57,14 +56,10 @@ const ObservationProvider = ( { children }: Props ): Node => {
};

const fetchPhoto = useCallback( async ( id ) => {
const headers = {};
headers["user-agent"] = createUserAgent();
const options = { headers };

// probably should break this into a helper function to use in other places
// like species nearby fetches for better offline experience
const fetchWithTimeout = ( timeout ) => Promise.race( [
inatjs.taxa.fetch( id, options ),
inatjs.taxa.fetch( id ),
new Promise( ( _, reject ) =>
setTimeout( ( ) => reject( new Error( "timeout" ) ), timeout )
)
Expand Down Expand Up @@ -285,9 +280,7 @@ const ObservationProvider = ( { children }: Props ): Node => {
const fetchOnlineVisionResults = async ( ) => {
const uploadParams = await flattenUploadParameters( image );
const token = createJwtToken( );
const headers = {};
headers["user-agent"] = createUserAgent();
const options = { api_token: token, headers };
const options = { api_token: token };

try {
const r = await inatjs.computervision.score_image( uploadParams, options );
Expand Down
7 changes: 1 addition & 6 deletions components/Species/OnlineOnlyCards/INatObs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import i18n from "../../../i18n";
import { viewStyles, textStyles, imageStyles } from "../../../styles/species/iNatObs";
import logos from "../../../assets/logos";
import SpeciesDetailCard from "../../UIComponents/SpeciesDetailCard";
import createUserAgent from "../../../utility/userAgent";
import { localizeNumber } from "../../../utility/helpers";
import StyledText from "../../UIComponents/StyledText";

Expand All @@ -38,11 +37,7 @@ const INatObs = ( { id, timesSeen, region }: Props ): Node => {
taxon_id: id
};

const headers = {};
headers["user-agent"] = createUserAgent();
const options = { headers };

inatjs.observations.speciesCounts( params, options ).then( ( { results } ) => {
inatjs.observations.speciesCounts( params ).then( ( { results } ) => {
if ( isFocused ) {
setNearbySpeciesCount( results.length > 0 ? results[0].count : 0 );
}
Expand Down
7 changes: 1 addition & 6 deletions components/Species/OnlineOnlyCards/SimilarSpecies.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { colors } from "../../../styles/global";
import styles from "../../../styles/species/similarSpecies";
import SpeciesNearbyList from "../../UIComponents/SpeciesNearby/SpeciesNearbyList";
import GreenText from "../../UIComponents/GreenText";
import createUserAgent from "../../../utility/userAgent";

type Props = {
+id: ?number
Expand Down Expand Up @@ -59,11 +58,7 @@ const SimilarSpecies = ( { id }: Props ): Node => {
locale: i18n.locale
};

const headers = {};
headers["user-agent"] = createUserAgent();
const options = { headers };

inatjs.identifications.similar_species( params, options ).then( ( { results } ) => {
inatjs.identifications.similar_species( params ).then( ( { results } ) => {
const species = results.map( r => r.taxon );

if ( isActive ) {
Expand Down
7 changes: 1 addition & 6 deletions components/Species/OnlineOnlyCards/SpeciesStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type { Node } from "react";

import i18n from "../../../i18n";
import { viewStyles, textStyles } from "../../../styles/species/speciesStats";
import createUserAgent from "../../../utility/userAgent";
import StyledText from "../../UIComponents/StyledText";

type Props = {
Expand Down Expand Up @@ -44,11 +43,7 @@ const SpeciesStats = ( { loading, stats, region, id, seenDate }: Props ): Node =
taxon_id: id
};

const headers = {};
headers["user-agent"] = createUserAgent();
const options = { headers };

inatjs.observations.search( params, options ).then( ( { results } ) => {
inatjs.observations.search( params ).then( ( { results } ) => {
if ( results.length > 0 ) {
const taxonStats = results[0].taxon;
if ( taxonStats ) {
Expand Down
7 changes: 1 addition & 6 deletions components/iNaturalist/hooks/inatHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useNetInfo } from "@react-native-community/netinfo";
import i18n from "../../../i18n";
import { capitalizeNames, shuffleList } from "../../../utility/helpers";
import { localizeAttributions } from "../../../utility/photoHelpers";
import createUserAgent from "../../../utility/userAgent";

const useFetchPhotos = ( ): any => {
const netInfo = useNetInfo();
Expand All @@ -29,11 +28,7 @@ const useFetchPhotos = ( ): any => {
locale: i18n.locale
};

const headers = {};
headers["user-agent"] = createUserAgent();
const options = { headers };

inatjs.observations.search( params, options ).then( ( { results } ) => {
inatjs.observations.search( params ).then( ( { results } ) => {
const taxa = results.map( ( r ) => r.taxon );

const projectPhotos = [];
Expand Down
Loading

0 comments on commit 4da580d

Please sign in to comment.