react-native-stallion 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/android/build.gradle +100 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/com/stallion/Stallion.java +26 -0
- package/android/src/main/java/com/stallion/StallionConstants.java +27 -0
- package/android/src/main/java/com/stallion/StallionDefaultErrorActivity.java +27 -0
- package/android/src/main/java/com/stallion/StallionModule.java +250 -0
- package/android/src/main/java/com/stallion/StallionPackage.java +29 -0
- package/android/src/main/java/com/stallion/StallionStorage.java +54 -0
- package/android/src/main/java/com/stallion/StallionZip.java +127 -0
- package/android/src/main/res/layout/stallion_default_error_activity.xml +60 -0
- package/android/src/noop/java/com/stallion/Stallion.java +13 -0
- package/android/src/noop/java/com/stallion/StallionConstants.java +10 -0
- package/android/src/noop/java/com/stallion/StallionModule.java +26 -0
- package/android/src/noop/java/com/stallion/StallionPackage.java +29 -0
- package/ios/Stallion.xcodeproj/project.pbxproj +283 -0
- package/ios/main/Stallion-Bridging-Header.h +3 -0
- package/ios/main/Stallion.m +21 -0
- package/ios/main/Stallion.swift +69 -0
- package/ios/main/StallionConstants.swift +42 -0
- package/ios/main/StallionDownloader.swift +124 -0
- package/ios/main/StallionModule.h +13 -0
- package/ios/main/StallionModule.m +71 -0
- package/ios/main/StallionUtil.swift +29 -0
- package/ios/noop/Stallion-Bridging-Header.h +2 -0
- package/ios/noop/Stallion.m +12 -0
- package/ios/noop/Stallion.swift +7 -0
- package/ios/noop/StallionModule.h +13 -0
- package/ios/noop/StallionModule.m +20 -0
- package/package.json +62 -0
- package/react-native-stallion.podspec +50 -0
- package/src/StallionNativeModule.js +5 -0
- package/src/StallionNativeModule.js.map +1 -0
- package/src/index.js +29 -0
- package/src/index.js.map +1 -0
- package/src/main/components/common/ButtonFullWidth/index.js +20 -0
- package/src/main/components/common/ButtonFullWidth/index.js.map +1 -0
- package/src/main/components/common/ButtonFullWidth/styles.js +42 -0
- package/src/main/components/common/ButtonFullWidth/styles.js.map +1 -0
- package/src/main/components/common/ErrorView/index.js +18 -0
- package/src/main/components/common/ErrorView/index.js.map +1 -0
- package/src/main/components/common/ErrorView/styles.js +20 -0
- package/src/main/components/common/ErrorView/styles.js.map +1 -0
- package/src/main/components/common/Footer/index.js +49 -0
- package/src/main/components/common/Footer/index.js.map +1 -0
- package/src/main/components/common/Footer/styles.js +76 -0
- package/src/main/components/common/Footer/styles.js.map +1 -0
- package/src/main/components/common/Header/index.js +50 -0
- package/src/main/components/common/Header/index.js.map +1 -0
- package/src/main/components/common/Header/styles.js +63 -0
- package/src/main/components/common/Header/styles.js.map +1 -0
- package/src/main/components/common/OverlayLoader/index.js +26 -0
- package/src/main/components/common/OverlayLoader/index.js.map +1 -0
- package/src/main/components/common/OverlayLoader/styles.js +33 -0
- package/src/main/components/common/OverlayLoader/styles.js.map +1 -0
- package/src/main/components/common/ProfileOverlay/index.js +39 -0
- package/src/main/components/common/ProfileOverlay/index.js.map +1 -0
- package/src/main/components/common/ProfileOverlay/styles.js +37 -0
- package/src/main/components/common/ProfileOverlay/styles.js.map +1 -0
- package/src/main/components/common/Spinner/index.js +9 -0
- package/src/main/components/common/Spinner/index.js.map +1 -0
- package/src/main/components/modules/listing/components/BucketCard.js +33 -0
- package/src/main/components/modules/listing/components/BucketCard.js.map +1 -0
- package/src/main/components/modules/listing/components/BucketCardInfoSection.js +56 -0
- package/src/main/components/modules/listing/components/BucketCardInfoSection.js.map +1 -0
- package/src/main/components/modules/listing/components/BundleCard.js +36 -0
- package/src/main/components/modules/listing/components/BundleCard.js.map +1 -0
- package/src/main/components/modules/listing/components/BundleCardInfoSection.js +72 -0
- package/src/main/components/modules/listing/components/BundleCardInfoSection.js.map +1 -0
- package/src/main/components/modules/listing/components/CardDescriptionContent.js +34 -0
- package/src/main/components/modules/listing/components/CardDescriptionContent.js.map +1 -0
- package/src/main/components/modules/listing/components/styles/index.js +65 -0
- package/src/main/components/modules/listing/components/styles/index.js.map +1 -0
- package/src/main/components/modules/listing/hooks/useListing.js +71 -0
- package/src/main/components/modules/listing/hooks/useListing.js.map +1 -0
- package/src/main/components/modules/listing/index.js +39 -0
- package/src/main/components/modules/listing/index.js.map +1 -0
- package/src/main/components/modules/listing/styles.js +12 -0
- package/src/main/components/modules/listing/styles.js.map +1 -0
- package/src/main/components/modules/login/components/Email.js +37 -0
- package/src/main/components/modules/login/components/Email.js.map +1 -0
- package/src/main/components/modules/login/components/Otp.js +41 -0
- package/src/main/components/modules/login/components/Otp.js.map +1 -0
- package/src/main/components/modules/login/components/styles/index.js +24 -0
- package/src/main/components/modules/login/components/styles/index.js.map +1 -0
- package/src/main/components/modules/login/hooks/useLoginFlow.js +60 -0
- package/src/main/components/modules/login/hooks/useLoginFlow.js.map +1 -0
- package/src/main/components/modules/login/index.js +54 -0
- package/src/main/components/modules/login/index.js.map +1 -0
- package/src/main/components/modules/login/styles/index.js +34 -0
- package/src/main/components/modules/login/styles/index.js.map +1 -0
- package/src/main/components/modules/modal/StallionModal.js +73 -0
- package/src/main/components/modules/modal/StallionModal.js.map +1 -0
- package/src/main/components/modules/modal/hooks/useStallionModal.js +92 -0
- package/src/main/components/modules/modal/hooks/useStallionModal.js.map +1 -0
- package/src/main/constants/apiConstants.js +10 -0
- package/src/main/constants/apiConstants.js.map +1 -0
- package/src/main/constants/appConstants.js +71 -0
- package/src/main/constants/appConstants.js.map +1 -0
- package/src/main/constants/colors.js +14 -0
- package/src/main/constants/colors.js.map +1 -0
- package/src/main/index.js +7 -0
- package/src/main/index.js.map +1 -0
- package/src/main/state/actionCreators/useBucketActions.js +37 -0
- package/src/main/state/actionCreators/useBucketActions.js.map +1 -0
- package/src/main/state/actionCreators/useBundleActions.js +45 -0
- package/src/main/state/actionCreators/useBundleActions.js.map +1 -0
- package/src/main/state/actionCreators/useDownloadActions.js +47 -0
- package/src/main/state/actionCreators/useDownloadActions.js.map +1 -0
- package/src/main/state/actionCreators/useMetaActions.js +19 -0
- package/src/main/state/actionCreators/useMetaActions.js.map +1 -0
- package/src/main/state/actionCreators/useUserActions.js +97 -0
- package/src/main/state/actionCreators/useUserActions.js.map +1 -0
- package/src/main/state/actions/bucketActions.js +19 -0
- package/src/main/state/actions/bucketActions.js.map +1 -0
- package/src/main/state/actions/bundleActions.js +25 -0
- package/src/main/state/actions/bundleActions.js.map +1 -0
- package/src/main/state/actions/downloadActions.js +19 -0
- package/src/main/state/actions/downloadActions.js.map +1 -0
- package/src/main/state/actions/metaActions.js +8 -0
- package/src/main/state/actions/metaActions.js.map +1 -0
- package/src/main/state/actions/userActions.js +31 -0
- package/src/main/state/actions/userActions.js.map +1 -0
- package/src/main/state/index.js +70 -0
- package/src/main/state/index.js.map +1 -0
- package/src/main/state/reducers/bucketReducer.js +36 -0
- package/src/main/state/reducers/bucketReducer.js.map +1 -0
- package/src/main/state/reducers/bundleReducer.js +47 -0
- package/src/main/state/reducers/bundleReducer.js.map +1 -0
- package/src/main/state/reducers/downloadReducer.js +39 -0
- package/src/main/state/reducers/downloadReducer.js.map +1 -0
- package/src/main/state/reducers/metaReducer.js +17 -0
- package/src/main/state/reducers/metaReducer.js.map +1 -0
- package/src/main/state/reducers/userReducer.js +70 -0
- package/src/main/state/reducers/userReducer.js.map +1 -0
- package/src/main/utils/ErrorBoundary.js +13 -0
- package/src/main/utils/ErrorBoundary.js.map +1 -0
- package/src/main/utils/SharedDataManager.js +25 -0
- package/src/main/utils/SharedDataManager.js.map +1 -0
- package/src/main/utils/StallionNaitveUtils.js +7 -0
- package/src/main/utils/StallionNaitveUtils.js.map +1 -0
- package/src/main/utils/apiUtils.js +16 -0
- package/src/main/utils/apiUtils.js.map +1 -0
- package/src/main/utils/dateUtil.js +39 -0
- package/src/main/utils/dateUtil.js.map +1 -0
- package/src/main/utils/errorUtil.js +10 -0
- package/src/main/utils/errorUtil.js.map +1 -0
- package/src/main/utils/useStallionModal.js +18 -0
- package/src/main/utils/useStallionModal.js.map +1 -0
- package/src/main/utils/withStallion.js +16 -0
- package/src/main/utils/withStallion.js.map +1 -0
- package/src/nativeScripts/getStallionEnabled.js +8 -0
- package/src/nativeScripts/getStallionEnabled.js.map +1 -0
- package/src/noop/useStallionModal.js +12 -0
- package/src/noop/useStallionModal.js.map +1 -0
- package/src/noop/withStallion.js +13 -0
- package/src/noop/withStallion.js.map +1 -0
- package/src/types/bucket.types.js +7 -0
- package/src/types/bucket.types.js.map +1 -0
- package/src/types/bundle.types.js +8 -0
- package/src/types/bundle.types.js.map +1 -0
- package/src/types/download.types.js +7 -0
- package/src/types/download.types.js.map +1 -0
- package/src/types/globalProvider.types.js +2 -0
- package/src/types/globalProvider.types.js.map +1 -0
- package/src/types/meta.types.js +6 -0
- package/src/types/meta.types.js.map +1 -0
- package/src/types/user.types.js +9 -0
- package/src/types/user.types.js.map +1 -0
- package/src/types/utils.types.js +2 -0
- package/src/types/utils.types.js.map +1 -0
- package/types/StallionNativeModule.d.ts +4 -0
- package/types/StallionNativeModule.d.ts.map +1 -0
- package/types/__tests__/index.test.d.ts +1 -0
- package/types/__tests__/index.test.d.ts.map +1 -0
- package/types/index.d.ts +4 -0
- package/types/index.d.ts.map +1 -0
- package/types/main/components/common/ButtonFullWidth/index.d.ts +10 -0
- package/types/main/components/common/ButtonFullWidth/index.d.ts.map +1 -0
- package/types/main/components/common/ButtonFullWidth/styles.d.ts +39 -0
- package/types/main/components/common/ButtonFullWidth/styles.d.ts.map +1 -0
- package/types/main/components/common/ErrorView/index.d.ts +7 -0
- package/types/main/components/common/ErrorView/index.d.ts.map +1 -0
- package/types/main/components/common/ErrorView/styles.d.ts +17 -0
- package/types/main/components/common/ErrorView/styles.d.ts.map +1 -0
- package/types/main/components/common/Footer/index.d.ts +13 -0
- package/types/main/components/common/Footer/index.d.ts.map +1 -0
- package/types/main/components/common/Footer/styles.d.ts +73 -0
- package/types/main/components/common/Footer/styles.d.ts.map +1 -0
- package/types/main/components/common/Header/index.d.ts +11 -0
- package/types/main/components/common/Header/index.d.ts.map +1 -0
- package/types/main/components/common/Header/styles.d.ts +59 -0
- package/types/main/components/common/Header/styles.d.ts.map +1 -0
- package/types/main/components/common/OverlayLoader/index.d.ts +7 -0
- package/types/main/components/common/OverlayLoader/index.d.ts.map +1 -0
- package/types/main/components/common/OverlayLoader/styles.d.ts +30 -0
- package/types/main/components/common/OverlayLoader/styles.d.ts.map +1 -0
- package/types/main/components/common/ProfileOverlay/index.d.ts +10 -0
- package/types/main/components/common/ProfileOverlay/index.d.ts.map +1 -0
- package/types/main/components/common/ProfileOverlay/styles.d.ts +34 -0
- package/types/main/components/common/ProfileOverlay/styles.d.ts.map +1 -0
- package/types/main/components/common/Spinner/index.d.ts +4 -0
- package/types/main/components/common/Spinner/index.d.ts.map +1 -0
- package/types/main/components/modules/listing/components/BucketCard.d.ts +13 -0
- package/types/main/components/modules/listing/components/BucketCard.d.ts.map +1 -0
- package/types/main/components/modules/listing/components/BucketCardInfoSection.d.ts +11 -0
- package/types/main/components/modules/listing/components/BucketCardInfoSection.d.ts.map +1 -0
- package/types/main/components/modules/listing/components/BundleCard.d.ts +14 -0
- package/types/main/components/modules/listing/components/BundleCard.d.ts.map +1 -0
- package/types/main/components/modules/listing/components/BundleCardInfoSection.d.ts +12 -0
- package/types/main/components/modules/listing/components/BundleCardInfoSection.d.ts.map +1 -0
- package/types/main/components/modules/listing/components/CardDescriptionContent.d.ts +8 -0
- package/types/main/components/modules/listing/components/CardDescriptionContent.d.ts.map +1 -0
- package/types/main/components/modules/listing/components/styles/index.d.ts +62 -0
- package/types/main/components/modules/listing/components/styles/index.d.ts.map +1 -0
- package/types/main/components/modules/listing/hooks/useListing.d.ts +11 -0
- package/types/main/components/modules/listing/hooks/useListing.d.ts.map +1 -0
- package/types/main/components/modules/listing/index.d.ts +4 -0
- package/types/main/components/modules/listing/index.d.ts.map +1 -0
- package/types/main/components/modules/listing/styles.d.ts +10 -0
- package/types/main/components/modules/listing/styles.d.ts.map +1 -0
- package/types/main/components/modules/login/components/Email.d.ts +13 -0
- package/types/main/components/modules/login/components/Email.d.ts.map +1 -0
- package/types/main/components/modules/login/components/Otp.d.ts +12 -0
- package/types/main/components/modules/login/components/Otp.d.ts.map +1 -0
- package/types/main/components/modules/login/components/styles/index.d.ts +21 -0
- package/types/main/components/modules/login/components/styles/index.d.ts.map +1 -0
- package/types/main/components/modules/login/hooks/useLoginFlow.d.ts +18 -0
- package/types/main/components/modules/login/hooks/useLoginFlow.d.ts.map +1 -0
- package/types/main/components/modules/login/index.d.ts +4 -0
- package/types/main/components/modules/login/index.d.ts.map +1 -0
- package/types/main/components/modules/login/styles/index.d.ts +31 -0
- package/types/main/components/modules/login/styles/index.d.ts.map +1 -0
- package/types/main/components/modules/modal/StallionModal.d.ts +4 -0
- package/types/main/components/modules/modal/StallionModal.d.ts.map +1 -0
- package/types/main/components/modules/modal/hooks/useStallionModal.d.ts +23 -0
- package/types/main/components/modules/modal/hooks/useStallionModal.d.ts.map +1 -0
- package/types/main/constants/apiConstants.d.ts +9 -0
- package/types/main/constants/apiConstants.d.ts.map +1 -0
- package/types/main/constants/appConstants.d.ts +65 -0
- package/types/main/constants/appConstants.d.ts.map +1 -0
- package/types/main/constants/colors.d.ts +14 -0
- package/types/main/constants/colors.d.ts.map +1 -0
- package/types/main/index.d.ts +7 -0
- package/types/main/index.d.ts.map +1 -0
- package/types/main/state/actionCreators/useBucketActions.d.ts +7 -0
- package/types/main/state/actionCreators/useBucketActions.d.ts.map +1 -0
- package/types/main/state/actionCreators/useBundleActions.d.ts +8 -0
- package/types/main/state/actionCreators/useBundleActions.d.ts.map +1 -0
- package/types/main/state/actionCreators/useDownloadActions.d.ts +7 -0
- package/types/main/state/actionCreators/useDownloadActions.d.ts.map +1 -0
- package/types/main/state/actionCreators/useMetaActions.d.ts +7 -0
- package/types/main/state/actionCreators/useMetaActions.d.ts.map +1 -0
- package/types/main/state/actionCreators/useUserActions.d.ts +12 -0
- package/types/main/state/actionCreators/useUserActions.d.ts.map +1 -0
- package/types/main/state/actions/bucketActions.d.ts +5 -0
- package/types/main/state/actions/bucketActions.d.ts.map +1 -0
- package/types/main/state/actions/bundleActions.d.ts +6 -0
- package/types/main/state/actions/bundleActions.d.ts.map +1 -0
- package/types/main/state/actions/downloadActions.d.ts +5 -0
- package/types/main/state/actions/downloadActions.d.ts.map +1 -0
- package/types/main/state/actions/metaActions.d.ts +3 -0
- package/types/main/state/actions/metaActions.d.ts.map +1 -0
- package/types/main/state/actions/userActions.d.ts +7 -0
- package/types/main/state/actions/userActions.d.ts.map +1 -0
- package/types/main/state/index.d.ts +6 -0
- package/types/main/state/index.d.ts.map +1 -0
- package/types/main/state/reducers/bucketReducer.d.ts +4 -0
- package/types/main/state/reducers/bucketReducer.d.ts.map +1 -0
- package/types/main/state/reducers/bundleReducer.d.ts +4 -0
- package/types/main/state/reducers/bundleReducer.d.ts.map +1 -0
- package/types/main/state/reducers/downloadReducer.d.ts +4 -0
- package/types/main/state/reducers/downloadReducer.d.ts.map +1 -0
- package/types/main/state/reducers/metaReducer.d.ts +4 -0
- package/types/main/state/reducers/metaReducer.d.ts.map +1 -0
- package/types/main/state/reducers/userReducer.d.ts +4 -0
- package/types/main/state/reducers/userReducer.d.ts.map +1 -0
- package/types/main/utils/ErrorBoundary.d.ts +7 -0
- package/types/main/utils/ErrorBoundary.d.ts.map +1 -0
- package/types/main/utils/SharedDataManager.d.ts +14 -0
- package/types/main/utils/SharedDataManager.d.ts.map +1 -0
- package/types/main/utils/StallionNaitveUtils.d.ts +7 -0
- package/types/main/utils/StallionNaitveUtils.d.ts.map +1 -0
- package/types/main/utils/apiUtils.d.ts +7 -0
- package/types/main/utils/apiUtils.d.ts.map +1 -0
- package/types/main/utils/dateUtil.d.ts +3 -0
- package/types/main/utils/dateUtil.d.ts.map +1 -0
- package/types/main/utils/errorUtil.d.ts +10 -0
- package/types/main/utils/errorUtil.d.ts.map +1 -0
- package/types/main/utils/useStallionModal.d.ts +4 -0
- package/types/main/utils/useStallionModal.d.ts.map +1 -0
- package/types/main/utils/withStallion.d.ts +4 -0
- package/types/main/utils/withStallion.d.ts.map +1 -0
- package/types/noop/useStallionModal.d.ts +4 -0
- package/types/noop/useStallionModal.d.ts.map +1 -0
- package/types/noop/withStallion.d.ts +4 -0
- package/types/noop/withStallion.d.ts.map +1 -0
- package/types/types/bucket.types.d.ts +33 -0
- package/types/types/bucket.types.d.ts.map +1 -0
- package/types/types/bundle.types.d.ts +41 -0
- package/types/types/bundle.types.d.ts.map +1 -0
- package/types/types/download.types.d.ts +27 -0
- package/types/types/download.types.d.ts.map +1 -0
- package/types/types/globalProvider.types.d.ts +36 -0
- package/types/types/globalProvider.types.d.ts.map +1 -0
- package/types/types/meta.types.d.ts +15 -0
- package/types/types/meta.types.d.ts.map +1 -0
- package/types/types/user.types.d.ts +40 -0
- package/types/types/user.types.d.ts.map +1 -0
- package/types/types/utils.types.d.ts +26 -0
- package/types/types/utils.types.d.ts.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# react-native-stallion
|
|
2
|
+
Stallion is the ultimate testing framework for React Native apps !
|
|
3
|
+
It is a simplified build sharing and testing system that skips all the tedious hastle of generating a new new APK or IPA build everytime you make react native code changes.
|
|
4
|
+
With stallion a developer can directly publish a react native build to Stallion servers and any tester can simply download updates through the Stallion app SDK without re installing the app.
|
|
5
|
+
|
|
6
|
+
## SDK Installation
|
|
7
|
+
|
|
8
|
+
### npm
|
|
9
|
+
```
|
|
10
|
+
npm install --save react-native-stallion
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### yarn
|
|
14
|
+
```
|
|
15
|
+
yarn add react-native-stallion
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
check complete SDK installation steps from [here](https://docs.redhorse.tech/docs/install)
|
|
19
|
+
|
|
20
|
+
## Documentation
|
|
21
|
+
Document contains installation steps, usage and how to disable stallion in production
|
|
22
|
+
|
|
23
|
+
https://redhorse-tech.github.io/stallion-docs/
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
Please see the [contributing](./CONTRIBUTING.MD) file
|
|
28
|
+
for an introduction to the codebase and what the various moving parts are.
|
|
29
|
+
|
|
30
|
+
## Open issues
|
|
31
|
+
|
|
32
|
+
Check out [open issues](https://github.com/redhorse-tech/react-native-stallion/issues) for a list of known issues, and discussions.
|
|
33
|
+
|
|
34
|
+
## Code of Conduct
|
|
35
|
+
|
|
36
|
+
You can find the code of conduct [here](./CODE_OF_CONDUCT.md)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def isNewArchitectureEnabled() {
|
|
13
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
apply plugin: "com.android.library"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
20
|
+
|
|
21
|
+
if (isNewArchitectureEnabled()) {
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def getExtOrDefault(name) {
|
|
26
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Stallion_" + name]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def getExtOrIntegerDefault(name) {
|
|
30
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Stallion_" + name]).toInteger()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
def enabledOutput = new ByteArrayOutputStream()
|
|
34
|
+
try {
|
|
35
|
+
exec {
|
|
36
|
+
commandLine "node", "../src/nativeScripts/getStallionEnabled.js"
|
|
37
|
+
standardOutput = enabledOutput;
|
|
38
|
+
}
|
|
39
|
+
enabledOutput = enabledOutput.toString().trim()
|
|
40
|
+
} catch(Exception e) {
|
|
41
|
+
this.logger.error("Error evaluating stallion enabled script. Make sure node is installed on your system")
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
def stallionEnabled = enabledOutput == "true"
|
|
46
|
+
|
|
47
|
+
android {
|
|
48
|
+
sourceSets {
|
|
49
|
+
if(stallionEnabled) {
|
|
50
|
+
main.java.srcDirs = ["src/main/java"]
|
|
51
|
+
} else {
|
|
52
|
+
main.java.srcDirs = ["src/noop/java"]
|
|
53
|
+
this.logger.warn("Stallion is disabled, falling back to noop version. Check your stallion.config.js file")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
58
|
+
|
|
59
|
+
defaultConfig {
|
|
60
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
61
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
62
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
63
|
+
}
|
|
64
|
+
buildTypes {
|
|
65
|
+
release {
|
|
66
|
+
minifyEnabled false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
lintOptions {
|
|
71
|
+
disable "GradleCompatible"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
compileOptions {
|
|
75
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
76
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
repositories {
|
|
82
|
+
mavenCentral()
|
|
83
|
+
google()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
dependencies {
|
|
88
|
+
// For < 0.71, this will be from the local maven repo
|
|
89
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
90
|
+
//noinspection GradleDynamicVersion
|
|
91
|
+
implementation "com.facebook.react:react-native:+"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (isNewArchitectureEnabled()) {
|
|
95
|
+
react {
|
|
96
|
+
jsRootDir = file("../src/")
|
|
97
|
+
libraryName = "Stallion"
|
|
98
|
+
codegenJavaPackageName = "com.stallion"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.stallion;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
public class Stallion {
|
|
6
|
+
|
|
7
|
+
public static String getJSBundleFile(Context applicationContext) {
|
|
8
|
+
return getJSBundleFile(applicationContext, null);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public static String getJSBundleFile(Context applicationContext, String defaultBundlePath) {
|
|
12
|
+
StallionStorage.getInstance().Initialize(applicationContext);
|
|
13
|
+
StallionStorage stallionStorageInstance = StallionStorage.getInstance();
|
|
14
|
+
if (
|
|
15
|
+
stallionStorageInstance.get(StallionConstants.ACTIVE_BUCKET_IDENTIFIER) != null &&
|
|
16
|
+
stallionStorageInstance.get(StallionConstants.STALLION_SWITCH_STATE_IDENTIFIER) != null &&
|
|
17
|
+
stallionStorageInstance.get(StallionConstants.STALLION_SWITCH_STATE_IDENTIFIER).equals(StallionConstants.STALLION_SWITCH_ON)
|
|
18
|
+
) {
|
|
19
|
+
int currentActiveSlot = stallionStorageInstance.getInt(StallionConstants.ACTIVE_SLOT_IDENTIFIER);
|
|
20
|
+
return applicationContext.getFilesDir().getAbsolutePath() + StallionConstants.STALLION_PACKAGE_PATH + StallionConstants.BUNDLE_DEST_FOLDER_DIR + StallionConstants.SLOT_FOLDER_DIR + currentActiveSlot + "/" + StallionConstants.UNZIP_FOLDER_NAME + "/" + StallionConstants.ANDROID_BUNDLE_FILE_NAME;
|
|
21
|
+
} else {
|
|
22
|
+
if (defaultBundlePath != null) return defaultBundlePath;
|
|
23
|
+
return StallionConstants.DEFAULT_JS_BUNDLE_LOCATION_BASE + StallionConstants.ANDROID_BUNDLE_FILE_NAME;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package com.stallion;
|
|
2
|
+
|
|
3
|
+
public class StallionConstants {
|
|
4
|
+
public static final String MODULE_NAME = "Stallion";
|
|
5
|
+
public static final String STALLION_PACKAGE_PATH = "/StallionPackage";
|
|
6
|
+
public static final int DOWNLOAD_BUFFER_SIZE = 1024 * 256;
|
|
7
|
+
public static final String API_BASE = "https://stallion-api.redhorse.tech/api/v1";
|
|
8
|
+
public static final String DOWNLOAD_API_PATH = "/bundle/download";
|
|
9
|
+
public static final String DOWNLOAD_FOLDER_DIR = "/downloads";
|
|
10
|
+
public static final String BUNDLE_DEST_FOLDER_DIR = "/stallion-build";
|
|
11
|
+
public static final String SLOT_FOLDER_DIR = "/slots/";
|
|
12
|
+
public static final String ZIP_FILE_NAME = "build.zip";
|
|
13
|
+
public static final String UNZIP_FOLDER_NAME = "build";
|
|
14
|
+
public static final String ANDROID_BUNDLE_FILE_NAME = "index.android.bundle";
|
|
15
|
+
public static final String DEFAULT_JS_BUNDLE_LOCATION_BASE = "assets://";
|
|
16
|
+
public static final String DOWNLOAD_PROGRESS_EVENT = "StallionDownloadProgress";
|
|
17
|
+
|
|
18
|
+
public static final String ACTIVE_BUCKET_IDENTIFIER = "activeBucket";
|
|
19
|
+
public static final String ACTIVE_VERSION_IDENTIFIER = "activeVersion";
|
|
20
|
+
public static final String ACTIVE_SLOT_IDENTIFIER = "activeSlot";
|
|
21
|
+
public static final String STALLION_SWITCH_STATE_IDENTIFIER = "switchState";
|
|
22
|
+
public static final String API_KEY_IDENTIFIER = "apiKey";
|
|
23
|
+
public static final String STALLION_SWITCH_ON = "STALLION_ON";
|
|
24
|
+
public static final String STALLION_SWITCH_OFF = "DEFAULT";
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package com.stallion;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.os.Bundle;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
import android.widget.Button;
|
|
7
|
+
import android.widget.TextView;
|
|
8
|
+
|
|
9
|
+
public class StallionDefaultErrorActivity extends Activity {
|
|
10
|
+
private TextView stackTraceView;
|
|
11
|
+
private Button continueButton;
|
|
12
|
+
@Override
|
|
13
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
14
|
+
super.onCreate(savedInstanceState);
|
|
15
|
+
Log.d("StallionDefault", "StallionDefaultErrorActivity");
|
|
16
|
+
String receivedStackTrace = getIntent().getExtras().getString("stack_trace_string");
|
|
17
|
+
String stackTraceString = receivedStackTrace != null ? receivedStackTrace : "null";
|
|
18
|
+
setContentView(R.layout.stallion_default_error_activity);
|
|
19
|
+
stackTraceView = findViewById(R.id.seb_stack_trace_text_view);
|
|
20
|
+
stackTraceView.setText(stackTraceString);
|
|
21
|
+
continueButton = findViewById(R.id.seb_continue_button);
|
|
22
|
+
continueButton.setOnClickListener(view -> continueExceptionFlow());
|
|
23
|
+
}
|
|
24
|
+
private void continueExceptionFlow() {
|
|
25
|
+
StallionModule.continueExcetionFlow();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
package com.stallion;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Arguments;
|
|
6
|
+
import com.facebook.react.bridge.Callback;
|
|
7
|
+
import com.facebook.react.bridge.Promise;
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
10
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
12
|
+
import com.facebook.react.bridge.WritableMap;
|
|
13
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
14
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
15
|
+
|
|
16
|
+
import android.app.Activity;
|
|
17
|
+
import android.content.Intent;
|
|
18
|
+
import android.os.Handler;
|
|
19
|
+
import android.os.Looper;
|
|
20
|
+
import android.util.Log;
|
|
21
|
+
|
|
22
|
+
import java.io.BufferedInputStream;
|
|
23
|
+
import java.io.BufferedOutputStream;
|
|
24
|
+
import java.io.File;
|
|
25
|
+
import java.io.FileOutputStream;
|
|
26
|
+
import java.io.IOException;
|
|
27
|
+
import java.io.OutputStream;
|
|
28
|
+
import java.net.HttpURLConnection;
|
|
29
|
+
import java.net.URL;
|
|
30
|
+
import java.nio.ByteBuffer;
|
|
31
|
+
import java.util.concurrent.ExecutorService;
|
|
32
|
+
import java.util.concurrent.Executors;
|
|
33
|
+
|
|
34
|
+
@ReactModule(name = StallionConstants.MODULE_NAME)
|
|
35
|
+
public class StallionModule extends ReactContextBaseJavaModule {
|
|
36
|
+
private ReactApplicationContext currentReactContext;
|
|
37
|
+
private String baseDir;
|
|
38
|
+
private StallionStorage stallionStorage;
|
|
39
|
+
private DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter;
|
|
40
|
+
public static Thread.UncaughtExceptionHandler _androidUncaughtExceptionHandler;
|
|
41
|
+
public static Thread _exceptionThread;
|
|
42
|
+
public static Throwable _exceptionThrowable;
|
|
43
|
+
|
|
44
|
+
public StallionModule(ReactApplicationContext reactContext) {
|
|
45
|
+
super(reactContext);
|
|
46
|
+
this.currentReactContext = reactContext;
|
|
47
|
+
this.baseDir = reactContext.getFilesDir().getAbsolutePath() + StallionConstants.STALLION_PACKAGE_PATH;
|
|
48
|
+
StallionStorage.getInstance().Initialize(reactContext);
|
|
49
|
+
this.stallionStorage = StallionStorage.getInstance();
|
|
50
|
+
_androidUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
|
51
|
+
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
|
52
|
+
@Override
|
|
53
|
+
public void uncaughtException(Thread thread, Throwable throwable) {
|
|
54
|
+
_exceptionThread = thread;
|
|
55
|
+
_exceptionThrowable = throwable;
|
|
56
|
+
String stackTraceString = Log.getStackTraceString(throwable);
|
|
57
|
+
if(stallionStorage.get(StallionConstants.STALLION_SWITCH_STATE_IDENTIFIER) == StallionConstants.STALLION_SWITCH_ON) {
|
|
58
|
+
toggleStallionSwitch(false);
|
|
59
|
+
Activity currentActivity = getCurrentActivity();
|
|
60
|
+
Intent myIntent = new Intent(currentActivity, StallionDefaultErrorActivity.class);
|
|
61
|
+
myIntent.putExtra("stack_trace_string", stackTraceString);
|
|
62
|
+
currentActivity.startActivity(myIntent);
|
|
63
|
+
currentActivity.finish();
|
|
64
|
+
} else {
|
|
65
|
+
continueExcetionFlow();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public static void continueExcetionFlow() {
|
|
72
|
+
_androidUncaughtExceptionHandler.uncaughtException(_exceptionThread, _exceptionThrowable);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
@NonNull
|
|
78
|
+
public String getName() {
|
|
79
|
+
return StallionConstants.MODULE_NAME;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@ReactMethod
|
|
83
|
+
public void setApiKey(String apiKey) {
|
|
84
|
+
this.stallionStorage.set(StallionConstants.API_KEY_IDENTIFIER, apiKey);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@ReactMethod
|
|
88
|
+
public void getApiKey(Callback callback) {
|
|
89
|
+
callback.invoke(
|
|
90
|
+
this.stallionStorage.get(StallionConstants.API_KEY_IDENTIFIER)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@ReactMethod
|
|
95
|
+
public void getStallionMeta(Callback callback) {
|
|
96
|
+
WritableMap bundleMeta = Arguments.createMap();
|
|
97
|
+
String activeBucket = this.stallionStorage.get(StallionConstants.ACTIVE_BUCKET_IDENTIFIER);
|
|
98
|
+
String switchState = this.stallionStorage.get(StallionConstants.STALLION_SWITCH_STATE_IDENTIFIER);
|
|
99
|
+
int activeVersion = this.stallionStorage.getInt(StallionConstants.ACTIVE_VERSION_IDENTIFIER);
|
|
100
|
+
|
|
101
|
+
bundleMeta.putString(StallionConstants.ACTIVE_BUCKET_IDENTIFIER, activeBucket);
|
|
102
|
+
bundleMeta.putBoolean(StallionConstants.STALLION_SWITCH_STATE_IDENTIFIER,
|
|
103
|
+
switchState == null ? false : this.stallionStorage.get(StallionConstants.STALLION_SWITCH_STATE_IDENTIFIER).equals(StallionConstants.STALLION_SWITCH_ON)
|
|
104
|
+
);
|
|
105
|
+
bundleMeta.putString(StallionConstants.ACTIVE_VERSION_IDENTIFIER, String.valueOf(activeVersion));
|
|
106
|
+
callback.invoke(bundleMeta);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@ReactMethod
|
|
110
|
+
public void toggleStallionSwitch(Boolean stallionBundleIsOn) {
|
|
111
|
+
this.stallionStorage.set(StallionConstants.STALLION_SWITCH_STATE_IDENTIFIER, stallionBundleIsOn ? StallionConstants.STALLION_SWITCH_ON : StallionConstants.STALLION_SWITCH_OFF);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private DeviceEventManagerModule.RCTDeviceEventEmitter getEventEmitter() {
|
|
115
|
+
if(this.eventEmitter == null) {
|
|
116
|
+
this.eventEmitter = this.currentReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
|
|
117
|
+
}
|
|
118
|
+
return this.eventEmitter;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@ReactMethod
|
|
122
|
+
public void downloadPackage(ReadableMap bundleInfo, Promise promise) {
|
|
123
|
+
ExecutorService executor = Executors.newSingleThreadExecutor();
|
|
124
|
+
Handler handler = new Handler(Looper.getMainLooper());
|
|
125
|
+
|
|
126
|
+
executor.execute(new Runnable() {
|
|
127
|
+
@Override
|
|
128
|
+
public void run() {
|
|
129
|
+
String receivedBucketId = bundleInfo.getString("bucketId");
|
|
130
|
+
String receivedProjectId = bundleInfo.getString("projectId");
|
|
131
|
+
Integer receivedVersion = bundleInfo.getInt("version");
|
|
132
|
+
String platformValue = "android";
|
|
133
|
+
DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter = getEventEmitter();
|
|
134
|
+
|
|
135
|
+
FileOutputStream fout = null;
|
|
136
|
+
BufferedOutputStream bout = null;
|
|
137
|
+
BufferedInputStream inputStream = null;
|
|
138
|
+
HttpURLConnection connection = null;
|
|
139
|
+
File downloadedZip = null;
|
|
140
|
+
boolean isZip = false;
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
int DOWNLOAD_BUFFER_SIZE = StallionConstants.DOWNLOAD_BUFFER_SIZE;
|
|
144
|
+
URL url = new URL(StallionConstants.API_BASE + StallionConstants.DOWNLOAD_API_PATH);
|
|
145
|
+
connection = (HttpURLConnection) url.openConnection();
|
|
146
|
+
connection.setRequestMethod( "POST" );
|
|
147
|
+
connection.setRequestProperty("x-access-token", stallionStorage.get(StallionConstants.API_KEY_IDENTIFIER));
|
|
148
|
+
connection.setRequestProperty("Content-Type", "application/json");
|
|
149
|
+
|
|
150
|
+
String jsonInputString = String.format("{\"bucketId\":\"%s\",\"projectId\":\"%s\",\"version\":%d,\"platform\":\"%s\"}", receivedBucketId, receivedProjectId, receivedVersion, platformValue);
|
|
151
|
+
|
|
152
|
+
connection.setDoOutput(true);
|
|
153
|
+
connection.setDoInput(true);
|
|
154
|
+
OutputStream os = connection.getOutputStream();
|
|
155
|
+
os.write(jsonInputString.getBytes("UTF-8"));
|
|
156
|
+
os.close();
|
|
157
|
+
|
|
158
|
+
connection.connect();
|
|
159
|
+
inputStream = new BufferedInputStream(connection.getInputStream());
|
|
160
|
+
File downloadFolder = new File(baseDir + StallionConstants.DOWNLOAD_FOLDER_DIR);
|
|
161
|
+
downloadFolder.getParentFile().mkdirs();
|
|
162
|
+
|
|
163
|
+
downloadedZip = new File(downloadFolder, StallionConstants.ZIP_FILE_NAME);
|
|
164
|
+
downloadedZip.getParentFile().mkdirs();
|
|
165
|
+
|
|
166
|
+
fout = new FileOutputStream(downloadedZip, false);
|
|
167
|
+
bout = new BufferedOutputStream(fout, DOWNLOAD_BUFFER_SIZE);
|
|
168
|
+
byte[] data = new byte[DOWNLOAD_BUFFER_SIZE];
|
|
169
|
+
byte[] header = new byte[4];
|
|
170
|
+
|
|
171
|
+
long totalBytes = connection.getContentLength();
|
|
172
|
+
long receivedBytes = 0;
|
|
173
|
+
int numBytesRead;
|
|
174
|
+
double prevDownloadFraction = 0;
|
|
175
|
+
double progressEventThrehold = 0.02;
|
|
176
|
+
while ((numBytesRead = inputStream.read(data, 0, DOWNLOAD_BUFFER_SIZE)) >= 0) {
|
|
177
|
+
if (receivedBytes < 4) {
|
|
178
|
+
for (int i = 0; i < numBytesRead; i++) {
|
|
179
|
+
int headerOffset = (int) (receivedBytes) + i;
|
|
180
|
+
if (headerOffset >= 4) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
header[headerOffset] = data[i];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
receivedBytes += numBytesRead;
|
|
188
|
+
bout.write(data, 0, numBytesRead);
|
|
189
|
+
double currentDownloadFraction = (double) receivedBytes / (double) totalBytes;
|
|
190
|
+
if(currentDownloadFraction - prevDownloadFraction > progressEventThrehold) {
|
|
191
|
+
prevDownloadFraction = currentDownloadFraction;
|
|
192
|
+
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
|
|
193
|
+
@Override
|
|
194
|
+
public void run() {
|
|
195
|
+
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(StallionConstants.DOWNLOAD_PROGRESS_EVENT, currentDownloadFraction);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
isZip = ByteBuffer.wrap(header).getInt() == 0x504b0304;
|
|
202
|
+
Log.d("", String.valueOf(isZip));
|
|
203
|
+
|
|
204
|
+
} catch (Exception e) {
|
|
205
|
+
Log.d("DOWNLOAD_ERROR", e.toString());
|
|
206
|
+
promise.reject(e.toString());
|
|
207
|
+
} finally {
|
|
208
|
+
try {
|
|
209
|
+
if (bout != null) bout.close();
|
|
210
|
+
if (fout != null) fout.close();
|
|
211
|
+
if (inputStream != null) inputStream.close();
|
|
212
|
+
if (connection != null) connection.disconnect();
|
|
213
|
+
} catch (IOException e) {
|
|
214
|
+
promise.reject(e.toString());
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (!isZip) {
|
|
219
|
+
promise.reject("Not a zip file");
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
int currentActiveSlot = stallionStorage.getInt(StallionConstants.ACTIVE_SLOT_IDENTIFIER);
|
|
225
|
+
int targetSlot;
|
|
226
|
+
if(currentActiveSlot == 1) {
|
|
227
|
+
targetSlot = 2;
|
|
228
|
+
} else if(currentActiveSlot == 2) {
|
|
229
|
+
targetSlot = 1;
|
|
230
|
+
} else {
|
|
231
|
+
targetSlot = 1;
|
|
232
|
+
}
|
|
233
|
+
StallionZip.unzipFile(downloadedZip.getAbsolutePath(), baseDir + StallionConstants.BUNDLE_DEST_FOLDER_DIR + StallionConstants.SLOT_FOLDER_DIR + targetSlot);
|
|
234
|
+
// setting active bucket ID, slot and version after downloading and all other jobs done
|
|
235
|
+
stallionStorage.setInt(StallionConstants.ACTIVE_SLOT_IDENTIFIER, targetSlot);
|
|
236
|
+
stallionStorage.set(StallionConstants.ACTIVE_BUCKET_IDENTIFIER, receivedBucketId);
|
|
237
|
+
if (receivedVersion != null) {
|
|
238
|
+
stallionStorage.setInt(StallionConstants.ACTIVE_VERSION_IDENTIFIER, receivedVersion);
|
|
239
|
+
}
|
|
240
|
+
promise.resolve("Success");
|
|
241
|
+
} catch (Exception e) {
|
|
242
|
+
promise.reject(e.toString());
|
|
243
|
+
} finally {
|
|
244
|
+
StallionZip.deleteFileOrFolderSilently(downloadedZip);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.stallion;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.ReactPackage;
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
+
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
import java.util.Collections;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
|
|
14
|
+
public class StallionPackage implements ReactPackage {
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
@Override
|
|
18
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
19
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
20
|
+
modules.add(new StallionModule(reactContext));
|
|
21
|
+
return modules;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@NonNull
|
|
25
|
+
@Override
|
|
26
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
27
|
+
return Collections.emptyList();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package com.stallion;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.SharedPreferences;
|
|
5
|
+
import android.preference.PreferenceManager;
|
|
6
|
+
|
|
7
|
+
public class StallionStorage {
|
|
8
|
+
private static StallionStorage mInstance;
|
|
9
|
+
private Context mContext;
|
|
10
|
+
|
|
11
|
+
private SharedPreferences sharedPreference;
|
|
12
|
+
|
|
13
|
+
public static StallionStorage getInstance(){
|
|
14
|
+
if (mInstance == null) mInstance = new StallionStorage();
|
|
15
|
+
return mInstance;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public void Initialize(Context context){
|
|
19
|
+
mContext = context;
|
|
20
|
+
sharedPreference = PreferenceManager.getDefaultSharedPreferences(mContext);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public void set(String key, String value) {
|
|
24
|
+
SharedPreferences.Editor editor = sharedPreference.edit();
|
|
25
|
+
editor.putString(key, value);
|
|
26
|
+
editor.commit();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public void setInt(String key, Integer value) {
|
|
30
|
+
SharedPreferences.Editor editor = sharedPreference.edit();
|
|
31
|
+
editor.putInt(key, value);
|
|
32
|
+
editor.commit();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public Integer getInt(String key) {
|
|
36
|
+
return sharedPreference.getInt(key, -1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public String get(String key) {
|
|
40
|
+
return sharedPreference.getString(key, null);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public void delete(String key, Boolean deleteAll) {
|
|
44
|
+
SharedPreferences.Editor editor = sharedPreference.edit();
|
|
45
|
+
if(deleteAll == true){
|
|
46
|
+
editor.clear();
|
|
47
|
+
return;
|
|
48
|
+
} else {
|
|
49
|
+
editor.remove(key);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|