diff --git a/App.js b/App.js index c247795..c46ae1d 100644 --- a/App.js +++ b/App.js @@ -17,6 +17,7 @@ import ConnectionManager from "./src/managers/ConnectionManager"; import URLHandler from "./src/utils/URLHandler"; import {setSafeBounceHeight} from "react-navigation-collapsible"; import {enableScreens} from 'react-native-screens'; +import SplashScreen from 'react-native-splash-screen' // Native optimizations https://reactnavigation.org/docs/react-native-screens enableScreens(true); @@ -175,6 +176,7 @@ export default class App extends React.Component { showUpdate: this.storageManager.preferences.updateNumber.current !== Update.number.toString(), showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && this.storageManager.preferences.showAprilFoolsStart.current === '1', }); + SplashScreen.hide(); } /** diff --git a/android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java b/android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java index df6893f..59aaa6f 100644 --- a/android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java +++ b/android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java @@ -1,5 +1,6 @@ package fr.amicaleinsat.application; +import android.os.Bundle; import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactRootView; @@ -7,6 +8,8 @@ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView; import android.content.Intent; import android.content.res.Configuration; +import org.devio.rn.splashscreen.SplashScreen; + public class MainActivity extends ReactActivity { // Added automatically by Expo Config @@ -18,6 +21,11 @@ public class MainActivity extends ReactActivity { sendBroadcast(intent); } + @Override + protected void onCreate(Bundle savedInstanceState) { + SplashScreen.show(this); + super.onCreate(savedInstanceState); + } /** * Returns the name of the main component registered from JavaScript. diff --git a/android/app/src/main/java/fr/amicaleinsat/application/generated/BasePackageList.java b/android/app/src/main/java/fr/amicaleinsat/application/generated/BasePackageList.java index 23e3aef..0b8a095 100644 --- a/android/app/src/main/java/fr/amicaleinsat/application/generated/BasePackageList.java +++ b/android/app/src/main/java/fr/amicaleinsat/application/generated/BasePackageList.java @@ -21,7 +21,6 @@ public class BasePackageList { new expo.modules.permissions.PermissionsPackage(), new expo.modules.securestore.SecureStorePackage(), new expo.modules.sqlite.SQLitePackage(), - new expo.modules.updates.UpdatesPackage(), new expo.modules.webbrowser.WebBrowserPackage() ); } diff --git a/android/app/src/main/res/drawable-xxhdpi/launch_screen.png b/android/app/src/main/res/drawable-xxhdpi/launch_screen.png new file mode 100644 index 0000000..7629d1a Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/launch_screen.png differ diff --git a/android/app/src/main/res/layout/launch_screen.xml b/android/app/src/main/res/layout/launch_screen.xml new file mode 100644 index 0000000..cf02f24 --- /dev/null +++ b/android/app/src/main/res/layout/launch_screen.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index ae05383..df66843 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -4,4 +4,5 @@ #121212 #be1522 #be1522 + #be1522 \ No newline at end of file diff --git a/ios/Campus/AppDelegate.m b/ios/Campus/AppDelegate.m index a498a1f..b7481af 100644 --- a/ios/Campus/AppDelegate.m +++ b/ios/Campus/AppDelegate.m @@ -14,10 +14,20 @@ #import #import +#import + @implementation AppDelegate @synthesize window = _window; +- (BOOL)application:(UIApplication *)application + openURL:(NSURL *)url + options:(NSDictionary *)options +{ + return [RCTLinkingManager application:application openURL:url options:options]; +} + + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]]; diff --git a/ios/Podfile b/ios/Podfile index 71d2d82..2600a9c 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -43,4 +43,5 @@ target 'Campus' do # react-native-cli autolinking use_native_modules! + end diff --git a/package.json b/package.json index 1f57527..03dbad8 100644 --- a/package.json +++ b/package.json @@ -18,21 +18,13 @@ ] }, "dependencies": { - "expo": "^37.0.0", - "react": "~16.9.0", - "react-dom": "16.9.0", - "react-native": "~0.61.5", - "react-native-gesture-handler": "~1.6.0", - "react-native-reanimated": "~1.7.0", - "react-native-screens": "~2.2.0", - "react-native-unimodules": "~0.9.0", - "react-native-web": "~0.11.7", "@expo/vector-icons": "^10.0.0", "@react-native-community/masked-view": "0.1.6", "@react-navigation/bottom-tabs": "^5.1.1", "@react-navigation/drawer": "^5.1.1", "@react-navigation/native": "^5.0.9", "@react-navigation/stack": "^5.1.1", + "expo": "^37.0.0", "expo-barcode-scanner": "~8.1.0", "expo-camera": "latest", "expo-linear-gradient": "~8.1.0", @@ -40,17 +32,26 @@ "expo-permissions": "~8.1.0", "expo-secure-store": "~8.1.0", "i18n-js": "^3.3.0", + "react": "~16.9.0", + "react-dom": "16.9.0", + "react-native": "~0.61.5", "react-native-animatable": "^1.3.3", "react-native-app-intro-slider": "^4.0.0", "react-native-appearance": "~0.3.3", "react-native-autolink": "^3.0.0", "react-native-calendars": "^1.260.0", "react-native-collapsible": "^1.5.2", + "react-native-gesture-handler": "~1.6.0", "react-native-image-modal": "^1.0.6", "react-native-modalize": "^1.3.6", "react-native-paper": "^3.8.0", + "react-native-reanimated": "~1.7.0", "react-native-render-html": "^4.1.2", "react-native-safe-area-context": "0.7.3", + "react-native-screens": "~2.2.0", + "react-native-splash-screen": "^3.2.0", + "react-native-unimodules": "~0.9.0", + "react-native-web": "~0.11.7", "react-native-webview": "8.1.1", "react-navigation-collapsible": "^5.5.0", "react-navigation-header-buttons": "^3.0.5" diff --git a/src/utils/URLHandler.js b/src/utils/URLHandler.js index 481317d..e9f0e89 100644 --- a/src/utils/URLHandler.js +++ b/src/utils/URLHandler.js @@ -1,9 +1,11 @@ // @flow -import {Linking} from 'expo'; +import {Linking} from 'react-native'; export default class URLHandler { + static SCHEME = "campus-insat://"; + static CLUB_INFO_URL_PATH = "club"; static EVENT_INFO_URL_PATH = "event"; @@ -20,21 +22,47 @@ export default class URLHandler { listen() { Linking.addEventListener('url', this.onUrl); - Linking.parseInitialURLAsync().then(this.onInitialUrl); + Linking.getInitialURL().then(this.onInitialUrl); } - onUrl = ({url}: Object) => { - let data = URLHandler.getUrlData(Linking.parse(url)); - if (data !== null) - this.onDetectURL(data); + onUrl = ({url}: { url: string }) => { + if (url != null) { + let data = URLHandler.getUrlData(URLHandler.parseUrl(url)); + if (data !== null) + this.onDetectURL(data); + } }; - onInitialUrl = ({path, queryParams}: Object) => { - let data = URLHandler.getUrlData({path, queryParams}); - if (data !== null) - this.onInitialURLParsed(data); + onInitialUrl = (url: ?string) => { + if (url != null) { + let data = URLHandler.getUrlData(URLHandler.parseUrl(url)); + if (data !== null) + this.onInitialURLParsed(data); + } }; + static parseUrl(url: string) { + let params = {}; + let path = ""; + let temp = url.replace(URLHandler.SCHEME, ""); + if (temp != null) { + let array = temp.split("?"); + if (array != null && array.length > 0) { + path = array[0]; + } + if (array != null && array.length > 1) { + let tempParams = array[1].split("&"); + for (let i = 0; i < tempParams.length; i++) { + let paramsArray = tempParams[i].split("="); + if (paramsArray.length > 1) { + params[paramsArray[0]] = paramsArray[1]; + } + } + } + } + return {path: path, queryParams: params}; + } + static getUrlData({path, queryParams}: Object) { let data = null; if (path !== null) { @@ -47,7 +75,7 @@ export default class URLHandler { } static isUrlValid(url: string) { - return this.getUrlData(Linking.parse(url)) !== null; + return this.getUrlData(URLHandler.parseUrl(url)) !== null; } static isClubInformationLink(path: string) {