Skip to content

Commit

Permalink
Merge pull request #325 from inaturalist/v2.12.3
Browse files Browse the repository at this point in the history
Merge 2.12.3 into main
  • Loading branch information
albullington authored Apr 12, 2021
2 parents f98182c + 81f62b6 commit a4abbe2
Show file tree
Hide file tree
Showing 124 changed files with 1,025 additions and 754 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ android {
applicationId "org.inaturalist.seek"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 177
versionName "2.12.2"
versionCode 182
versionName "2.12.3"
// for creating ic_seek_adaptiveappicon.xml
vectorDrawables.useSupportLibrary = true
}
Expand Down
8 changes: 4 additions & 4 deletions components/AboutScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
Image,
Text,
View,
Platform,
TouchableOpacity
} from "react-native";
import { getVersion, getBuildNumber } from "react-native-device-info";
import { useNavigation } from "@react-navigation/native";
import type { Node } from "react";

import styles from "../styles/about";
import logos from "../assets/logos";
Expand All @@ -18,14 +18,14 @@ import { UserContext } from "./UserContext";
import ScrollWithHeader from "./UIComponents/Screens/ScrollWithHeader";
import PrivacyAndTerms from "./UIComponents/PrivacyAndTerms";

const AboutScreen = () => {
const AboutScreen = (): Node => {
const navigation = useNavigation();
const appVersion = getVersion();
const buildVersion = getBuildNumber();
const { login } = useContext( UserContext );

const navToDebug = () => navigation.navigate( "DebugAndroid" );
const disabled = Platform.OS === "ios" || !login;
const navToDebug = () => navigation.navigate( "DebugEmailScreen" );
const disabled = !login;

return (
<ScrollWithHeader header="about.header">
Expand Down
8 changes: 5 additions & 3 deletions components/Achievements/AchievementsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useState, useEffect, useCallback } from "react";
import { View, Text, TouchableOpacity } from "react-native";
import { useNavigation } from "@react-navigation/native";
import Realm from "realm";
import type { Node } from "react";

import i18n from "../../i18n";
import taxonIds from "../../utility/dictionaries/taxonDict";
Expand All @@ -20,7 +21,7 @@ import { fetchNumberSpeciesSeen, localizeNumber, setRoute } from "../../utility/
import ScrollWithHeader from "../UIComponents/Screens/ScrollWithHeader";
import BannerHeader from "./BannerHeader";

const AchievementsScreen = () => {
const AchievementsScreen = (): Node => {
const navigation = useNavigation();
const [state, setState] = useState( {
speciesBadges: [],
Expand All @@ -42,8 +43,9 @@ const AchievementsScreen = () => {
iconicTaxonIds.forEach( ( id ) => {
if ( id === null ) { return; }
const highestEarned = badges
.filtered( `iconicTaxonName != null AND iconicTaxonId == ${id} AND earned == true` )
.sorted( "index", true );
.filtered( `iconicTaxonName != null AND iconicTaxonId == ${id}` )
.sorted( "index", true )
.sorted( "earned", true );
speciesBadges.push( highestEarned[0] );
} );

Expand Down
3 changes: 2 additions & 1 deletion components/Achievements/LevelHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TouchableOpacity
} from "react-native";
import LinearGradient from "react-native-linear-gradient";
import type { Node } from "react";

import LevelModal from "../Modals/LevelModal";
import i18n from "../../i18n";
Expand All @@ -23,7 +24,7 @@ type Props = {
+speciesCount: ?number
}

const LevelHeader = ( { level, nextLevelCount, speciesCount }: Props ) => {
const LevelHeader = ( { level, nextLevelCount, speciesCount }: Props ): Node => {
const [showModal, setModal] = useState( false );

const openModal = useCallback( ( ) => setModal( true ), [] );
Expand Down
4 changes: 2 additions & 2 deletions components/Achievements/SpeciesBadges.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useState, useCallback } from "react";
import { View, Image, TouchableOpacity } from "react-native";
import Realm from "realm";
import Modal from "react-native-modal";
import type { Node } from "react";

import i18n from "../../i18n";
import realmConfig from "../../models";
Expand All @@ -15,7 +16,7 @@ type Props = {
+speciesBadges: Array<Object>
}

const SpeciesBadges = ( { speciesBadges }: Props ) => {
const SpeciesBadges = ( { speciesBadges }: Props ): Node => {
const [showModal, setModal] = useState( false );
const [iconicSpeciesCount, setIconicSpeciesCount] = useState( 0 );
const [iconicTaxonBadges, setIconicTaxonBadges] = useState( [] );
Expand All @@ -27,7 +28,6 @@ const SpeciesBadges = ( { speciesBadges }: Props ) => {
Realm.open( realmConfig )
.then( ( realm ) => {
const badges = realm.objects( "BadgeRealm" ).filtered( `iconicTaxonId == ${taxaId}` ).sorted( "index" );
console.log( badges, "badges in iconic id" );
const collectedTaxa = realm.objects( "TaxonRealm" );
const collection = collectedTaxa.filtered( `iconicTaxonId == ${taxaId}` ).length;

Expand Down
38 changes: 9 additions & 29 deletions components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

import React, { useState, useEffect } from "react";
import * as RNLocalize from "react-native-localize";
import type { Node } from "react";

import RootStack from "./Navigation/RootStack";
import { checkINatAdminStatus, setupChallenges } from "../utility/challengeHelpers";
import { handleLocalizationChange, loadUserLanguagePreference } from "../utility/languageHelpers";
import { addARCameraFiles, hideLogs } from "../utility/helpers";
import { fetchAccessToken, savePostingSuccess } from "../utility/loginHelpers";
import { UserContext, CameraContext, LanguageContext, SpeciesDetailContext } from "./UserContext";
import { getScientificNames, getLanguage, getAutoCapture, getSeasonality } from "../utility/settingsHelpers";
import { UserContext, LanguageContext } from "./UserContext";
import { getLanguage, setupUserSettings } from "../utility/settingsHelpers";
import { setQuickActions } from "../utility/navigationHelpers";

const App = ( ) => {
const App = ( ): Node => {
const [login, setLogin] = useState( null );
const [scientificNames, setScientificNames] = useState( false );
const [preferredLanguage, setLanguage] = useState( null );
const [autoCapture, setAutoCapture] = useState( false );
const [localSeasonality, setLocalSeasonality] = useState( false );

const getLoggedIn = async ( ) => {
const token = await fetchAccessToken( );
Expand All @@ -30,26 +28,13 @@ const App = ( ) => {
}
setLogin( token );
};
const fetchScientificNames = async () => setScientificNames( await getScientificNames() );
const getLanguagePreference = async () => setLanguage( await getLanguage() );
const fetchAutoCapture = async () => setAutoCapture( await getAutoCapture() );
const fetchLocalSeasonality = async () => setLocalSeasonality( await getSeasonality() );

const toggleLogin = () => getLoggedIn();
const toggleNames = () => fetchScientificNames();
const toggleLanguagePreference = () => getLanguagePreference();
const toggleAutoCapture = () => fetchAutoCapture();
const toggleLocalSeasonality = () => fetchLocalSeasonality();

const userContextValue = { login, toggleLogin };
const CameraContextValue = {
scientificNames,
toggleNames,
autoCapture,
toggleAutoCapture
};
const languageValue = { preferredLanguage, toggleLanguagePreference };
const seasonalityValue = { localSeasonality, toggleLocalSeasonality };

useEffect( () => {
// wait until check for stored language is completed
Expand All @@ -60,13 +45,12 @@ const App = ( ) => {
useEffect( () => {
hideLogs();
setQuickActions();
// testing
setupUserSettings( );

// Context
getLoggedIn();
fetchScientificNames();
getLanguagePreference();
fetchAutoCapture();
fetchLocalSeasonality();

// reset posting to iNat
savePostingSuccess( false );
Expand All @@ -80,13 +64,9 @@ const App = ( ) => {

return (
<UserContext.Provider value={userContextValue}>
<CameraContext.Provider value={CameraContextValue}>
<LanguageContext.Provider value={languageValue}>
<SpeciesDetailContext.Provider value={seasonalityValue}>
<RootStack />
</SpeciesDetailContext.Provider>
</LanguageContext.Provider>
</CameraContext.Provider>
<LanguageContext.Provider value={languageValue}>
<RootStack />
</LanguageContext.Provider>
</UserContext.Provider>
);
};
Expand Down
3 changes: 2 additions & 1 deletion components/Auth/Login/ForgotPasswordScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React, { useState } from "react";
import { Text, View } from "react-native";
import { useNavigation } from "@react-navigation/native";
import type { Node } from "react";

import i18n from "../../../i18n";
import styles from "../../../styles/auth/login";
Expand All @@ -15,7 +16,7 @@ import createUserAgent from "../../../utility/userAgent";
import { createJwtToken } from "../../../utility/helpers";
import ScrollWithHeader from "../../UIComponents/Screens/ScrollWithHeader";

const ForgotPasswordScreen = () => {
const ForgotPasswordScreen = (): Node => {
const { navigate } = useNavigation();
const [email, setEmail] = useState( "" );
const [error, setError] = useState( false );
Expand Down
4 changes: 2 additions & 2 deletions components/Auth/Login/LoginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TouchableOpacity
} from "react-native";
import { useNavigation } from "@react-navigation/native";
import type { Node } from "react";

import i18n from "../../../i18n";
import styles from "../../../styles/auth/login";
Expand All @@ -20,7 +21,7 @@ import createUserAgent from "../../../utility/userAgent";
import { UserContext } from "../../UserContext";
import ScrollWithHeader from "../../UIComponents/Screens/ScrollWithHeader";

const LoginScreen = () => {
const LoginScreen = (): Node => {
const { navigate } = useNavigation();
const { toggleLogin } = useContext( UserContext );
const [username, setUsername] = useState( "" );
Expand Down Expand Up @@ -80,7 +81,6 @@ const LoginScreen = () => {
<InputField
handleTextChange={updatePassword}
placeholder="*********"
secureTextEntry
text={password}
type="password"
/>
Expand Down
3 changes: 2 additions & 1 deletion components/Auth/Signup/AgeVerifyScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React, { useState, useCallback } from "react";
import { View, Text, TouchableOpacity } from "react-native";
import { useNavigation } from "@react-navigation/native";
import type { Node } from "react";

import i18n from "../../../i18n";
import { requiresParent, formatYearMonthDay } from "../../../utility/dateHelpers";
Expand All @@ -12,7 +13,7 @@ import ViewWithHeader from "../../UIComponents/Screens/ViewWithHeader";
import DateTimePicker from "../../UIComponents/DateTimePicker";
import PrivacyAndTerms from "../../UIComponents/PrivacyAndTerms";

const AgeVerifyScreen = () => {
const AgeVerifyScreen = (): Node => {
const { navigate } = useNavigation();
const [date, setDate] = useState( formatYearMonthDay() );
const [isPickerVisible, setPicker] = useState( false );
Expand Down
3 changes: 2 additions & 1 deletion components/Auth/Signup/LicensePhotosScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useState } from "react";
import { View, Text, Alert } from "react-native";
import HTML from "react-native-render-html";
import { useNavigation } from "@react-navigation/native";
import type { Node } from "react";

import i18n from "../../../i18n";
import { colors } from "../../../styles/global";
Expand All @@ -16,7 +17,7 @@ import GreenButton from "../../UIComponents/Buttons/GreenButton";
import ScrollWithHeader from "../../UIComponents/Screens/ScrollWithHeader";
import CheckboxRow from "./CheckboxRow";

const LicensePhotosScreen = () => {
const LicensePhotosScreen = (): Node => {
const { navigate } = useNavigation();
const [email, setEmail] = useState( "" );
const [licensePhotos, setLicensePhotos] = useState( true );
Expand Down
3 changes: 2 additions & 1 deletion components/Auth/Signup/ParentalConsentScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React, { Component } from "react";
import { View, Text } from "react-native";
import type { Node } from "react";

import i18n from "../../../i18n";
import styles from "../../../styles/auth/signup";
Expand Down Expand Up @@ -86,7 +87,7 @@ class ParentalConsentScreen extends Component<Props, State> {
navigation.navigate( "ParentCheck" );
}

render() {
render(): Node {
const { email, error, loading } = this.state;

return (
Expand Down
4 changes: 2 additions & 2 deletions components/Auth/Signup/SignUpScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React, { Component } from "react";
import { View } from "react-native";
import * as RNLocalize from "react-native-localize";
import type { Node } from "react";

import i18n from "../../../i18n";
import config from "../../../config";
Expand Down Expand Up @@ -161,7 +162,7 @@ class SignUpScreen extends Component<Props, State> {
}
}

render() {
render(): Node {
const { username, password, error } = this.state;

return (
Expand All @@ -183,7 +184,6 @@ class SignUpScreen extends Component<Props, State> {
<InputField
handleTextChange={value => this.setState( { password: value } )}
placeholder="*********"
secureTextEntry
text={password}
type="password"
/>
Expand Down
14 changes: 5 additions & 9 deletions components/Camera/ARCamera/ARCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import {
import CameraRoll from "@react-native-community/cameraroll";
import { useNavigation, useIsFocused } from "@react-navigation/native";
import { INatCamera } from "react-native-inat-camera";
import type { Node } from "react";

import i18n from "../../../i18n";
import styles from "../../../styles/camera/arCamera";
import icons from "../../../assets/icons";
import CameraError from "../CameraError";
import { writeExifData } from "../../../utility/photoHelpers";
import {
checkForSystemVersion,
handleLog,
Expand All @@ -38,7 +38,7 @@ import { fetchOfflineResults } from "../../../utility/resultsHelpers";
import { useEmulator } from "../../../utility/customHooks";
import { colors } from "../../../styles/global";

const ARCamera = () => {
const ARCamera = (): Node => {
const navigation = useNavigation();
const isFocused = useIsFocused();
const camera = useRef<any>( null );
Expand Down Expand Up @@ -135,11 +135,7 @@ const ARCamera = () => {
navigateToResults( uri, predictions );
}, [navigateToResults] );

const savePhoto = useCallback( async ( photo: { uri: string, predictions: Array<Object> }, skipExif ) => {
// don't bother writing exif if camera roll permissions are off
if ( Platform.OS === "android" && !skipExif ) {
await writeExifData( photo.uri );
}
const savePhoto = useCallback( async ( photo: { uri: string, predictions: Array<Object> } ) => {
CameraRoll.save( photo.uri, { type: "photo", album: "Seek" } )
.then( uri => navigateToResults( uri, photo.predictions ) )
.catch( e => handleCameraRollSaveError( photo.uri, photo.predictions, e ) );
Expand Down Expand Up @@ -222,9 +218,9 @@ const ARCamera = () => {
const result = await checkSavePermissions( );

if ( result === "gallery" ) {
savePhoto( photo, true );
savePhoto( photo );
} else {
savePhoto( photo, false );
savePhoto( photo );
}
};
// on Android, this permission check will pop up every time; on iOS it only pops up first time a user opens camera
Expand Down
Loading

0 comments on commit a4abbe2

Please sign in to comment.