Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta PR: Implement offline support #1239

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
26d600a
feat(RN0.73): Update packages
zatteo Oct 10, 2024
d525f7b
feat(RN0.73): Use new @react-native/babel-preset
zatteo Oct 10, 2024
9ce5fca
feat(RN0.73): Update Android build files
zatteo Oct 10, 2024
d1bb437
feat(RN0.73): Update iOS build files
zatteo Oct 10, 2024
ca7bd9a
feat(RN0.73): Update Flipper setup
zatteo Oct 10, 2024
3eff0bd
feat(RN0.73): Upgrade CI to node 20
zatteo Oct 10, 2024
0e5aca2
refactor(RN0.73): Remove style props not understood by RN
zatteo Oct 10, 2024
105b698
docs(RN0.73): Update types after RN update
zatteo Oct 10, 2024
7d00852
feat: Update ShareViewController to support iOS 18
zatteo Oct 17, 2024
7a41c31
fix: Disable Flipper in iOS release builds
Ldoppea Nov 18, 2024
bb73393
feat: Add react-native modules for PouchDB
Ldoppea May 22, 2024
9209d05
feat: Configure PouchDB to run on the project
Ldoppea May 28, 2024
c2387d4
feat: Add cozy-pouch-link module
Ldoppea May 28, 2024
4e067f3
feat: Configure CozyClient to use CozyPouchLink
Ldoppea May 31, 2024
26e731d
feat: Configure CozyClient to also use StackLink (when online)
Ldoppea May 31, 2024
27436dc
feat: Add PouchDBFind plugin to the PouchDB configuration
Ldoppea May 31, 2024
b3984d9
feat: Add clientCachedStorage to handle CozyClient's requests cache
Ldoppea Jul 11, 2024
435799c
feat: Cache `/apps/:slug/open` request for offline support
Ldoppea Jul 11, 2024
43df99e
feat: Upgrade cozy-intent to `2.23.0`
Ldoppea Sep 24, 2024
2b421fa
feat: Implement FlagshipLinkRequest interface through localMethods
Ldoppea Jul 30, 2024
dc753f9
feat: Enable CacheMode for CozyProxyWebView on android when offline
Ldoppea Jul 11, 2024
4d7c460
feat: Ignore queries warmup on PouchLink
Ldoppea Jul 30, 2024
1678258
feat: Declare schemas into cozy-client instance
Ldoppea Jul 26, 2024
21ad737
feat: Add react-native-mail plugin
Ldoppea Jul 26, 2024
2bd4f08
feat: Allow to send Pouch databases through email for debug purpose
Ldoppea Jul 26, 2024
00145a4
feat: Declare offline support in cozy-apps injected metadata
Ldoppea Jul 30, 2024
7394c95
feat: Prevent local PouchDB modification to be replicated to remote DB
Ldoppea Sep 13, 2024
e92554d
feat: Add `downloadFile` in localMethods and handle offline files
Ldoppea Aug 8, 2024
12c1cf4
feat: Make import files automatically available offline
Ldoppea Aug 8, 2024
c8913a5
feat: Clean non-important offline files when too old
Ldoppea Aug 8, 2024
32bacfd
feat: Use NetStatusBoundary only when logged out
Ldoppea Aug 22, 2024
0546007
fix: Set correct return objects for `getIndexHtmlForSlug`
Ldoppea Aug 22, 2024
f8558ba
feat: Enable offline mode only for cozy-home and mespapiers
Ldoppea Aug 22, 2024
7778abc
feat: Display an error message when opening unsupported offline cozy-app
Ldoppea Aug 22, 2024
f152171
feat: Enable HttpServer on iOS when offline
Ldoppea Aug 22, 2024
61f6aa8
feat: Open cozy-app when offline only if it supports Offline mode
Ldoppea Sep 13, 2024
2f11214
docs: Document how to make a cozy-app compatible with Offline mode
Ldoppea Sep 13, 2024
ef7e8fd
refactor: Handle SendDb deeplink in its own hook
Ldoppea Sep 15, 2024
059c3ec
feat: Allow to reset local PouchDB using UniversalLinks
Ldoppea Sep 15, 2024
d909645
feat: Display an error dialog when trying to download a file offline
Ldoppea Sep 24, 2024
c4ba49a
feat: Allow cozy-apps to verify if offline file downloading is available
Ldoppea Sep 24, 2024
1419b66
fix: Skip io.cozy.jobs queries
Ldoppea Sep 24, 2024
f895a92
docs: Document how to debug Offline mode
Ldoppea Sep 24, 2024
82e6204
docs: Update docs' table of content
Ldoppea Sep 24, 2024
09276f6
fix: Upload DB files to the Cozy instead of sending them by email
Ldoppea Oct 1, 2024
9a09a1b
fix: Remove unused plugin rn-fetch-blob
Ldoppea Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions .github/workflows/build-android-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,13 @@ jobs:
- name: Set NodeJS version
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20

- name: Set up our JDK environment
uses: actions/setup-java@v3
with:
distribution: 'adopt-hotspot'
java-version: '11'

- name: Fixing Android Build Tool Issue
run: |
cd $ANDROID_HOME/build-tools/33.0.0
mv d8 dx
cd lib
mv d8.jar dx.jar
java-version: '17'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/build-android-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set NodeJS version
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20

- name: Check out Git repository
uses: actions/checkout@v3
Expand All @@ -31,14 +31,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'adopt-hotspot'
java-version: '11'

- name: Fixing Android Build Tool Issue
run: |
cd $ANDROID_HOME/build-tools/33.0.0
mv d8 dx
cd lib
mv d8.jar dx.jar
java-version: '17'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build-ios-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set NodeJS version
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20

- name: Setup Ruby (bundle)
uses: ruby/setup-ruby@v1
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
run: yarn brand:configure:${{ inputs.brand }} --force

- name: Install Pods
run: cd ios && pod install --repo-update && cd ..
run: cd ios && NO_FLIPPER=1 pod install --repo-update && cd ..

- name: Build IOS App
id: ios_build
Expand Down Expand Up @@ -107,4 +107,3 @@ jobs:
with:
name: XCode Build Logs
path: '/Users/runner/Library/Logs/gym/CozyReactNative-CozyReactNative.log'

6 changes: 3 additions & 3 deletions .github/workflows/build-ios-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:

- name: Select Xcode 15.3
run: sudo xcode-select -s /Applications/Xcode_15.3.app/Contents/Developer

- name: Check out Git repository
uses: actions/checkout@v3

- name: Set NodeJS version
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20

- name: Setup Ruby (bundle)
uses: ruby/setup-ruby@v1
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
run: yarn brand:configure:${{ inputs.brand }} --force

- name: Install Pods
run: cd ios && pod install --repo-update && cd ..
run: cd ios && NO_FLIPPER=1 pod install --repo-update && cd ..

- name: Build IOS App
id: ios_build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quality_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: 20
cache: 'yarn'

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ 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.13'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 6.1.7.3, < 7.1.0)
activesupport (>= 6.1.7.5, < 7.1.0)
cocoapods (~> 1.13)

RUBY VERSION
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This notably includes the possiblity to run client-side konnectors, to get your
- [iOS only] Install XCode
- [Android only] Install Android Studio (or Android SDK)
- [Android only] Java 11
- [Android only] Install NDK (21.4.7075529) and CMake (3.10.2) from Android Studio's SDK Manager
- [Android only] Copy the Android's `debug.keystore` from Cozy's password-store into `android/app/debug.keystore`
- Run `pass show app-amirale/Certificates/debug.keystore > android/app/debug.keystore`
- If you don't have access to Cozy's password-store, just generate a new `debug.keystore` file
Expand Down
2 changes: 1 addition & 1 deletion __tests__/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config = {
'<rootDir>/__tests__/transformer/imageTransformer.js'
},
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native(-.*)?|@react-native(-community)?|p-timeout?|p-wait-for?|@notifee?)|@fengweichong/react-native-gzip?/)'
'node_modules/(?!((jest-)?react-native(-.*)?|@react-native(-community)?|p-timeout?|p-wait-for?|@notifee?)|@fengweichong/react-native-gzip|@craftzdog/*?/)'
],
rootDir: '../'
}
Expand Down
17 changes: 17 additions & 0 deletions __tests__/jestSetupFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,20 @@ jest.mock('../src/core/tools/env', () => ({
devlog: jest.fn(),
shouldDisableAutolock: jest.fn().mockReturnValue(false)
}))

jest.mock('../src/pouchdb/pouchdb', () => ({}))
jest.mock('react-native-quick-websql', () => ({}))

class mockPouchLink {
constructor() {}
}

jest.mock('cozy-pouch-link', () => {
return jest.fn().mockImplementation(() => {
return new mockPouchLink()
})
})

jest.mock('react-native-mail', () => ({
mail: jest.fn()
}))
12 changes: 3 additions & 9 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
Expand Down Expand Up @@ -91,6 +92,7 @@ def jscFlavor = 'org.webkit:android-jsc:+'
android {
ndkVersion rootProject.ext.ndkVersion

buildToolsVersion rootProject.ext.buildToolsVersion
compileSdkVersion rootProject.ext.compileSdkVersion

namespace "io.cozy.flagship.mobile"
Expand Down Expand Up @@ -146,15 +148,7 @@ android {
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")



debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
implementation("com.facebook.react:flipper-integration")

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
Expand Down
3 changes: 0 additions & 3 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<uses-sdk tools:overrideLibrary="androidx.core.splashscreen" />

<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
<meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" />
<meta-data android:name="google_analytics_ssaid_collection_enabled" android:value="false" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.react.flipper.ReactNativeFlipper;
import com.facebook.soloader.SoLoader;
import java.util.List;
import android.webkit.WebView;
Expand Down

This file was deleted.

14 changes: 11 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ buildscript {
googlePlayServicesLocationVersion = "20.0.0"
DocumentScanner_compileSdkVersion = 34
DocumentScanner_targetSdkVersion = 34
kotlinVersion = '1.8.0' // react-native-receive-sharing-intent requires a global kotlin version else the build fails
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
QuickBase64_compileSdkVersion = 34
QuickBase64_targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
// To solve a conflict between flipper and react-native-background-geolocation
// https://github.com/transistorsoft/react-native-background-geolocation/issues/1983
slf4jVersion = "2.0.7"
logbackVersion = "3.0.0"
}
repositories {
google()
Expand All @@ -21,10 +26,13 @@ buildscript {
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
classpath("com.google.gms:google-services:4.3.15")
}
}

apply plugin: "com.facebook.react.rootproject"

allprojects {
repositories {
maven {
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android.useAndroidX=true
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.182.0
FLIPPER_VERSION=0.269.0

# Helps against out of memory errors
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=4096m -XX:+HeapDumpOnOutOfMemoryError
Expand Down
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
14 changes: 9 additions & 5 deletions android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down Expand Up @@ -197,6 +198,9 @@ if "$cygwin" || "$msys" ; then
done
fi

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Loading
Loading