Skip to content

Commit

Permalink
Merge pull request #752 from Plant-for-the-Planet-org/release/1.0.8_v2
Browse files Browse the repository at this point in the history
Release/1.0.8 v2
  • Loading branch information
norbertschuler authored Mar 20, 2024
2 parents a2ffa21 + 0d5b2ca commit 7e10874
Show file tree
Hide file tree
Showing 18 changed files with 8,457 additions and 34,263 deletions.
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ android {
applicationId "org.pftp.treemapper"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 25
versionName "1.0.8"
versionCode 37
versionName "1.0.9"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'general'
Expand All @@ -160,7 +160,7 @@ android {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
universalApk true
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:exported="true"
android:theme="@style/AppTheme.LaunchScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
16 changes: 11 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

buildscript {
ext {
buildToolsVersion = "30.0.2"
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
compileSdkVersion = 33
targetSdkVersion = 33
ndkVersion = "22.1.7171670"
androidXVersion = "1.2.0"
androidXVersion = "1.2.0"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
classpath("com.android.tools.build:gradle:7.0.0") // Update as needed for compatibility

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -40,3 +40,9 @@ allprojects {
jcenter()
}
}

subprojects { subproject ->
if(project['name'] == 'react-native-reanimated'){
project.configurations { compile { } }
}
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
41 changes: 22 additions & 19 deletions app/actions/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export const auth0Login = (dispatch: any, inventoryDispatch: any) => {
prompt: 'login',
audience: 'urn:plant-for-the-planet',
},
{ ephemeralSession: false },
{ ephemeralSession: false, customScheme: 'org.pftp.treemapper' },
)
.then((credentials) => {
.then(credentials => {
const expirationTime = getExpirationTimeStamp(credentials.accessToken);

// logs success info in DB
Expand All @@ -62,7 +62,7 @@ export const auth0Login = (dispatch: any, inventoryDispatch: any) => {

// fetches the user details from server by passing the accessToken which is used while requesting the API
getUserDetailsFromServer(dispatch)
.then((userDetails) => {
.then(userDetails => {
// destructured and modified variable names which is used to set user state
const {
email,
Expand Down Expand Up @@ -90,11 +90,11 @@ export const auth0Login = (dispatch: any, inventoryDispatch: any) => {
});
resolve(true);
})
.catch((err) => {
.catch(err => {
reject(err);
});
})
.catch((err) => {
.catch(err => {
if (err?.error !== 'a0.session.user_cancelled') {
dbLog.error({
logType: LogTypes.USER,
Expand All @@ -104,14 +104,14 @@ export const auth0Login = (dispatch: any, inventoryDispatch: any) => {
// if any error is found then deletes the user and clear the user app state
deleteUser();
clearUserDetails()(dispatch);
bugsnag.notify(err);
} else {
dbLog.info({
logType: LogTypes.USER,
message: 'User cancelled auth0 login',
logStack: JSON.stringify(err),
});
}
bugsnag.notify(err);
reject(err);
});
});
Expand All @@ -126,17 +126,17 @@ export const auth0Login = (dispatch: any, inventoryDispatch: any) => {
export const auth0Logout = async (userDispatch = null) => {
const isConnected = await isInternetConnected();

return new Promise((resolve) => {
return new Promise(resolve => {
if (!isConnected) {
resolve(false);
return;
}
auth0.webAuth
.clearSession()
.clearSession({}, { customScheme: 'org.pftp.treemapper' })
.then(async () => {
// deletes the user from DB
await deleteUser();
await deleteAllProjects()
await deleteAllProjects();

await resetAllSpecies();

Expand All @@ -154,7 +154,7 @@ export const auth0Logout = async (userDispatch = null) => {
});
resolve(true);
})
.catch((err) => {
.catch(err => {
if (err?.error !== 'a0.session.user_cancelled') {
console.error('Error at /actions/user/auth0Logout', err);
dbLog.error({
Expand All @@ -163,7 +163,6 @@ export const auth0Logout = async (userDispatch = null) => {
logStack: JSON.stringify(err),
});
resolve(false);
bugsnag.notify(err);
} else {
dbLog.info({
logType: LogTypes.USER,
Expand All @@ -172,6 +171,7 @@ export const auth0Logout = async (userDispatch = null) => {
});
resolve(false);
}
bugsnag.notify(err);
});
});
};
Expand All @@ -183,7 +183,7 @@ export const auth0Logout = async (userDispatch = null) => {
*/
export const getNewAccessToken = async (refreshToken: string) => {
const isConnected = await isInternetConnected();
return new Promise((resolve) => {
return new Promise(resolve => {
if (!isConnected) {
resolve(false);
return;
Expand All @@ -192,7 +192,7 @@ export const getNewAccessToken = async (refreshToken: string) => {
// calls the refreshToken function of auth0 by passing the refreshToken
auth0.auth
.refreshToken({ refreshToken })
.then((data) => {
.then(data => {
const expirationTime = getExpirationTimeStamp(data.accessToken);
// calls the repo function which modifies the accessToken, idToken and refreshToken from the fetched data
createOrModifyUserToken({ ...data, expirationTime });
Expand All @@ -204,7 +204,7 @@ export const getNewAccessToken = async (refreshToken: string) => {
// resolves the access token
resolve(data.accessToken);
})
.catch((err) => {
.catch(err => {
auth0Logout();
// logs the error in Db and notifies the same to bugsnag
console.error('Error at /actions/user/getNewAccessToken', err);
Expand Down Expand Up @@ -290,9 +290,10 @@ export const getUserDetailsFromServer = (userDispatch: any) => {
});
resolve(data?.data);
})
.catch(async (err) => {
.catch(async err => {
// calls this function to check for the error code and either logout the user or ask to signup
await checkErrorCode(err, userDispatch);
bugsnag.notify(err);
console.error(
'Error at /actions/user/getUserDetailsFromServer: GET - /app/profile,',
err.response,
Expand All @@ -314,7 +315,7 @@ export const SignupService = (payload: any, dispatch: any) => {
// try {
return new Promise((resolve, reject) => {
postRequest('/app/profile', payload)
.then(async (res) => {
.then(async res => {
const { status, data }: any = res;
if (status === 200) {
await modifyUserDetails({
Expand All @@ -336,7 +337,8 @@ export const SignupService = (payload: any, dispatch: any) => {
resolve(data);
}
})
.catch((err) => {
.catch(err => {
bugsnag.notify(err);
console.error(
`Error at /actions/user/SignupService: POST - /app/profile, ${JSON.stringify(
err.response,
Expand All @@ -363,7 +365,7 @@ export const SignupService = (payload: any, dispatch: any) => {
export const getAllProjects = () => {
return new Promise((resolve, reject) => {
getAuthenticatedRequest('/app/profile/projects?_scope=extended')
.then(async (res) => {
.then(async res => {
const { status, data }: any = res;
if (status === 200) {
await addProjects(data);
Expand All @@ -376,7 +378,8 @@ export const getAllProjects = () => {
resolve(true);
}
})
.catch((err) => {
.catch(err => {
bugsnag.notify(err);
console.error(
'Error at /actions/user/getAllProjects: GET - /app/profile/projects,',
err.response ? err.response : err,
Expand Down
22 changes: 7 additions & 15 deletions app/components/AdditionalData/AdditionalDataSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Colors, Typography } from '../../styles';
import { readJsonFileAndAddAdditionalData } from '../../utils/additionalData/functions';
import { toBase64 } from '../../utils/base64';
import { LogTypes } from '../../utils/constants';
import { askExternalStoragePermission } from '../../utils/permissions';
import { AlertModal, Header, LargeButton } from '../Common';

const AdditionalDataSettings = () => {
Expand All @@ -22,14 +21,8 @@ const AdditionalDataSettings = () => {
const [alertMessage, setAlertMessage] = useState<string>('');
const [showSecondaryButton, setShowSecondaryButton] = useState<boolean>(false);

const {
forms,
metadata,
addFormsToState,
addMetadataInState,
setTreeType,
setRegistrationType,
} = useContext(AdditionalDataContext);
const { forms, metadata, addFormsToState, addMetadataInState, setTreeType, setRegistrationType } =
useContext(AdditionalDataContext);

const exportAdditionalData = () => {
const exportData = {
Expand All @@ -44,10 +37,12 @@ const AdditionalDataSettings = () => {
filename: `TreeMapper-Additional-Data`,
saveToFiles: true,
failOnCancel: false,
useInternalStorage: true,
};

Share.open(options).catch((err) => {
if (err?.error?.code != 'ECANCELLED500') { // iOS cancel button pressed
Share.open(options).catch(err => {
if (err?.error?.code != 'ECANCELLED500') {
// iOS cancel button pressed
setAlertHeading(i18next.t('label.something_went_wrong'));
setAlertMessage(i18next.t('label.share_additional_data_error'));
setShowSecondaryButton(false);
Expand All @@ -64,10 +59,7 @@ const AdditionalDataSettings = () => {

const handleImportExport = async (option: 'import' | 'export') => {
if (option === 'export') {
const permissionResult = await askExternalStoragePermission();
if (permissionResult) {
exportAdditionalData();
}
exportAdditionalData();
} else if (option === 'import') {
if ((forms && forms.length > 0) || (metadata && metadata.length > 0)) {
setAlertHeading(i18next.t('label.confirm_wipe_additional_data_import'));
Expand Down
9 changes: 6 additions & 3 deletions app/components/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import Config from 'react-native-config';
import 'react-native-gesture-handler';
import Provider from '../../reducers/provider';
import AppNavigator from '../Navigator';
import { Auth0Provider } from 'react-native-auth0';

MapboxGL.setAccessToken(Config.MAPBOXGL_ACCCESS_TOKEN);

const App = () => {
return (
<Provider>
<AppNavigator />
</Provider>
<Auth0Provider domain={Config.AUTH0_DOMAIN} clientId={Config.AUTH0_CLIENT_ID}>
<Provider>
<AppNavigator />
</Provider>
</Auth0Provider>
);
};

Expand Down
9 changes: 3 additions & 6 deletions app/components/Common/ExportGeoJSON/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import Share from 'react-native-share';
import { toBase64 } from '../../../utils/base64';
import getGeoJsonData from '../../../utils/convertInventoryToGeoJson';
import { askExternalStoragePermission } from '../../../utils/permissions';
import LargeButton from '../LargeButton';

interface ExportGeoJSONProps {
Expand All @@ -21,12 +20,13 @@ const ExportGeoJSON: React.FunctionComponent<ExportGeoJSONProps> = ({ inventory
title: i18next.t('label.inventory_overview_export_json_title'),
filename: `TreeMapper GeoJSON ${inventory.inventory_id}`,
saveToFiles: true,
useInternalStorage:true
};
Share.open(options)
.then(() => {
alert(i18next.t('label.inventory_overview_export_json_success'));
})
.catch((err) => {
.catch(err => {
// shows error if occurred and not canceled by the user
if (err?.error?.code != 'ECANCELLED500' && err?.message !== 'User did not share') {
// iOS cancel button pressed
Expand All @@ -36,10 +36,7 @@ const ExportGeoJSON: React.FunctionComponent<ExportGeoJSONProps> = ({ inventory
}
};
const onPressExportJSON = async () => {
const permissionResult = await askExternalStoragePermission();
if (permissionResult) {
await exportGeoJSONFile();
}
await exportGeoJSONFile();
};

return (
Expand Down
2 changes: 1 addition & 1 deletion app/components/Common/MapMarking/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export default function MapMarking({
const checkPermission = async ({ showAlert = false, isOffsite = false }) => {
try {
await locationPermission();
MapboxGL.setTelemetryEnabled(false);
// MapboxGL.setTelemetryEnabled(false);
updateCurrentPosition();
return true;
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions app/components/Common/Syncing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import dbLog from '../../../repositories/logs';
import { LogTypes } from '../../../utils/constants';
import { useNetInfo } from '@react-native-community/netinfo';
import AlertModal from '../AlertModal';
import { bugsnag } from '../../../utils';

interface ISyncingProps {
uploadCount: number;
Expand Down Expand Up @@ -70,6 +71,7 @@ export default function Syncing({
const onPressUploadNow = () => {
if (netInfo.isConnected && netInfo.isInternetReachable) {
uploadInventoryData(dispatch, userDispatch).catch(err => {
bugsnag.notify(err);
dbLog.error({
logType: LogTypes.INVENTORY,
message: 'Failed to upload Inventories',
Expand Down
Loading

0 comments on commit 7e10874

Please sign in to comment.