shakebug-react-native 1.0.14
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/DeviceInfo/index.js.flow +177 -0
- package/DeviceInfo/index.ts +1034 -0
- package/DeviceInfo/internal/asyncHookWrappers.ts +59 -0
- package/DeviceInfo/internal/devicesWithDynamicIsland.ts +30 -0
- package/DeviceInfo/internal/devicesWithNotch.ts +374 -0
- package/DeviceInfo/internal/nativeInterface.ts +28 -0
- package/DeviceInfo/internal/privateTypes.ts +231 -0
- package/DeviceInfo/internal/supported-platform-info.ts +97 -0
- package/DeviceInfo/internal/types.ts +19 -0
- package/DeviceInfo/web/index.js +223 -0
- package/GetLocals/src/NativeRNLocalize.ts +18 -0
- package/GetLocals/src/constants.ts +269 -0
- package/GetLocals/src/index.ts +56 -0
- package/GetLocals/src/module.ts +51 -0
- package/GetLocals/src/module.web.ts +148 -0
- package/GetLocals/src/types.ts +31 -0
- package/GetLocation/LocationError.ts +20 -0
- package/GetLocation/index.ts +46 -0
- package/GetLocation/utils.ts +89 -0
- package/ImageOrVedioPicker/src/index.ts +28 -0
- package/ImageOrVedioPicker/src/platforms/NativeImagePicker.ts +10 -0
- package/ImageOrVedioPicker/src/platforms/native.ts +61 -0
- package/ImageOrVedioPicker/src/platforms/web.ts +159 -0
- package/ImageOrVedioPicker/src/types.ts +74 -0
- package/NetInfo/src/__tests__/eventListenerCallbacks.spec.ts +332 -0
- package/NetInfo/src/__tests__/fetch.spec.ts +479 -0
- package/NetInfo/src/index.ts +186 -0
- package/NetInfo/src/internal/__mocks__/nativeModule.ts +13 -0
- package/NetInfo/src/internal/defaultConfiguration.ts +17 -0
- package/NetInfo/src/internal/defaultConfiguration.web.ts +17 -0
- package/NetInfo/src/internal/internetReachability.ts +180 -0
- package/NetInfo/src/internal/nativeInterface.ts +43 -0
- package/NetInfo/src/internal/nativeInterface.web.ts +27 -0
- package/NetInfo/src/internal/nativeModule.ts +15 -0
- package/NetInfo/src/internal/nativeModule.web.ts +306 -0
- package/NetInfo/src/internal/privateTypes.ts +41 -0
- package/NetInfo/src/internal/state.ts +137 -0
- package/NetInfo/src/internal/types.ts +128 -0
- package/README.md +246 -0
- package/RecordScreen/src/index.tsx +75 -0
- package/ScreenShot/src/RNViewShot.js +3 -0
- package/ScreenShot/src/RNViewShot.web.js +42 -0
- package/ScreenShot/src/index.js +308 -0
- package/Sensor/src/index.js +14 -0
- package/Sensor/src/rnsensors.js +57 -0
- package/Sensor/src/sensors.js +97 -0
- package/VideoPlayer/PlayVideo.tsx +51 -0
- package/VideoPlayer/index.js +69 -0
- package/android/README.md +14 -0
- package/android/build/generated/source/buildConfig/debug/com/shakebug/BuildConfig.java +10 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +42 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +6 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +47 -0
- package/android/build/intermediates/compiled_local_resources/debug/out/xml_imagepicker_provider_paths.xml.flat +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +12 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/CustomMediaMetadataRetriever.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ImageMetadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ImagePickerProvider.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Metadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Options.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/RecordScreenModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/RecordScreenModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Shakebug.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ShakebugPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Utility.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Utils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/VideoMetadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$Formats.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$Results.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$ReusableByteArrayOutputStream.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +49 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +82 -0
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +42 -0
- package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
- package/android/build/intermediates/packaged_res/debug/values/values.xml +25 -0
- package/android/build/intermediates/packaged_res/debug/xml/imagepicker_provider_paths.xml +4 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/CustomMediaMetadataRetriever.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ImageMetadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ImagePickerProvider.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Metadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Options.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/RecordScreenModule$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/RecordScreenModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Shakebug.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ShakebugPackage.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Utility.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Utils.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/VideoMetadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$Formats.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$Results.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$ReusableByteArrayOutputStream.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot.class +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +48 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +97 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +235 -0
- package/android/src/main/AndroidManifest.xml +40 -0
- package/android/src/main/java/com/shakebug/AmazonFireDeviceConnectivityPoller.java +170 -0
- package/android/src/main/java/com/shakebug/BaseUtils.java +33 -0
- package/android/src/main/java/com/shakebug/BroadcastReceiverConnectivityReceiver.java +131 -0
- package/android/src/main/java/com/shakebug/ConnectivityReceiver.java +318 -0
- package/android/src/main/java/com/shakebug/CrashLoggerModule.java +48 -0
- package/android/src/main/java/com/shakebug/DateUtil.java +64 -0
- package/android/src/main/java/com/shakebug/DeviceType.java +18 -0
- package/android/src/main/java/com/shakebug/DeviceUtil.java +46 -0
- package/android/src/main/java/com/shakebug/DrawingView.java +90 -0
- package/android/src/main/java/com/shakebug/DrawingViewManager.java +38 -0
- package/android/src/main/java/com/shakebug/GetLocation.java +147 -0
- package/android/src/main/java/com/shakebug/ImageMetadata.java +42 -0
- package/android/src/main/java/com/shakebug/ImagePickerProvider.java +8 -0
- package/android/src/main/java/com/shakebug/Metadata.java +46 -0
- package/android/src/main/java/com/shakebug/NetInfoModule.java +79 -0
- package/android/src/main/java/com/shakebug/NetInfoUtils.java +50 -0
- package/android/src/main/java/com/shakebug/NetworkCallbackConnectivityReceiver.java +209 -0
- package/android/src/main/java/com/shakebug/Options.java +42 -0
- package/android/src/main/java/com/shakebug/RNDeviceModule.java +1036 -0
- package/android/src/main/java/com/shakebug/RNInstallReferrerClient.java +124 -0
- package/android/src/main/java/com/shakebug/RNLocalizeModule.java +79 -0
- package/android/src/main/java/com/shakebug/RNLocalizeModuleImpl.java +258 -0
- package/android/src/main/java/com/shakebug/ReactNativeGetLocationModule.java +95 -0
- package/android/src/main/java/com/shakebug/RecordScreenModule.java +202 -0
- package/android/src/main/java/com/shakebug/ScreenshotDetectorModule.java +63 -0
- package/android/src/main/java/com/shakebug/SettingsUtil.java +44 -0
- package/android/src/main/java/com/shakebug/Shakebug.java +181 -0
- package/android/src/main/java/com/shakebug/ShakebugPackage.java +75 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKImagePickerModule.java +56 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKImagePickerModuleImpl.java +230 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKScreenShotModule.java +196 -0
- package/android/src/main/java/com/shakebug/SharedPreferencesModule.java +39 -0
- package/android/src/main/java/com/shakebug/UnitConverter.java +48 -0
- package/android/src/main/java/com/shakebug/Utility.java +29 -0
- package/android/src/main/java/com/shakebug/Utils.java +593 -0
- package/android/src/main/java/com/shakebug/VideoMetadata.java +91 -0
- package/android/src/main/java/com/shakebug/VideoPlayerModule.java +199 -0
- package/android/src/main/java/com/shakebug/VideoThumbnailModule.java +215 -0
- package/android/src/main/java/com/shakebug/VideoTrimModule.java +372 -0
- package/android/src/main/java/com/shakebug/ViewShot.java +627 -0
- package/android/src/main/java/com/shakebug/adapters/VideoTrimmerAdapter.java +54 -0
- package/android/src/main/java/com/shakebug/callback/SingleCallback.java +11 -0
- package/android/src/main/java/com/shakebug/interfaces/IVideoTrimmerView.java +5 -0
- package/android/src/main/java/com/shakebug/interfaces/VideoPlayerListner.java +5 -0
- package/android/src/main/java/com/shakebug/interfaces/VideoTrimListener.java +10 -0
- package/android/src/main/java/com/shakebug/resolver/DeviceIdResolver.java +87 -0
- package/android/src/main/java/com/shakebug/resolver/DeviceTypeResolver.java +94 -0
- package/android/src/main/java/com/shakebug/thread/BackgroundExecutor.java +246 -0
- package/android/src/main/java/com/shakebug/thread/UiThreadExecutor.java +120 -0
- package/android/src/main/java/com/shakebug/types/CellularGeneration.java +60 -0
- package/android/src/main/java/com/shakebug/types/ConnectionType.java +26 -0
- package/android/src/main/java/com/shakebug/utils/StorageUtil.java +139 -0
- package/android/src/main/java/com/shakebug/utils/VideoTrimmerUtil.java +89 -0
- package/android/src/main/java/com/shakebug/widgets/RangeSeekBarView.java +534 -0
- package/android/src/main/java/com/shakebug/widgets/SpacesItemDecoration2.java +32 -0
- package/android/src/main/java/com/shakebug/widgets/VideoPlayerView.java +429 -0
- package/android/src/main/java/com/shakebug/widgets/VideoTrimmerView.java +477 -0
- package/android/src/main/java/com/shakebug/widgets/ZVideoView.java +48 -0
- package/android/src/main/res/drawable/custom_progress.xml +16 -0
- package/android/src/main/res/drawable/custom_thumb.xml +4 -0
- package/android/src/main/res/drawable/ic_close_button.xml +10 -0
- package/android/src/main/res/drawable/ic_video_pause_black.png +0 -0
- package/android/src/main/res/drawable/ic_video_play_black.png +0 -0
- package/android/src/main/res/drawable/ic_video_thumb_handle.png +0 -0
- package/android/src/main/res/drawable/icon_seek_bar.png +0 -0
- package/android/src/main/res/layout/video_player_view.xml +121 -0
- package/android/src/main/res/layout/video_thumb_item_layout.xml +16 -0
- package/android/src/main/res/layout/video_trimmer_view.xml +148 -0
- package/android/src/main/res/values/colors.xml +17 -0
- package/android/src/main/res/values/strings.xml +14 -0
- package/android/src/main/res/xml/imagepicker_provider_paths.xml +4 -0
- package/ios/CammeraPermission/RNCameraPermission.h +16 -0
- package/ios/CammeraPermission/RNCameraPermission.m +46 -0
- package/ios/DeviceInfo/DeviceUID.h +14 -0
- package/ios/DeviceInfo/DeviceUID.m +202 -0
- package/ios/DeviceInfo/EnvironmentUtil.h +41 -0
- package/ios/DeviceInfo/EnvironmentUtil.m +56 -0
- package/ios/DeviceInfo/RNDeviceInfo.h +22 -0
- package/ios/DeviceInfo/RNDeviceInfo.m +918 -0
- package/ios/GetLocals/ShakebugSDKRNLocalize.h +21 -0
- package/ios/GetLocals/ShakebugSDKRNLocalize.m +296 -0
- package/ios/GetLocation/SettingsUtil.h +16 -0
- package/ios/GetLocation/SettingsUtil.m +21 -0
- package/ios/GetLocation/ShakebugSDKLocationModule.h +17 -0
- package/ios/GetLocation/ShakebugSDKLocationModule.m +218 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerManager.h +40 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerManager.m +588 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerUtils.h +26 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerUtils.m +194 -0
- package/ios/MicrophonePermissionManager.h +14 -0
- package/ios/MicrophonePermissionManager.m +35 -0
- package/ios/NetInfo/RNCConnectionState.h +42 -0
- package/ios/NetInfo/RNCConnectionState.m +119 -0
- package/ios/NetInfo/RNCConnectionStateWatcher.h +31 -0
- package/ios/NetInfo/RNCConnectionStateWatcher.m +136 -0
- package/ios/NetInfo/RNCNetInfo.h +13 -0
- package/ios/NetInfo/RNCNetInfo.m +269 -0
- package/ios/RecordScreen/ShakebugSDKRecordScreen.h +31 -0
- package/ios/RecordScreen/ShakebugSDKRecordScreen.m +309 -0
- package/ios/ScreenShot/ShakebugSDKRNViewShot.h +6 -0
- package/ios/ScreenShot/ShakebugSDKRNViewShot.m +186 -0
- package/ios/ScreenshotDetector/ScreenShotDetector.h +12 -0
- package/ios/ScreenshotDetector/ScreenShotDetector.m +37 -0
- package/ios/Senors/RNSensorsAccelerometer.h +22 -0
- package/ios/Senors/RNSensorsAccelerometer.m +162 -0
- package/ios/Senors/RNSensorsBarometer.h +22 -0
- package/ios/Senors/RNSensorsBarometer.m +141 -0
- package/ios/Senors/RNSensorsGravity.h +22 -0
- package/ios/Senors/RNSensorsGravity.m +165 -0
- package/ios/Senors/RNSensorsGyroscope.h +22 -0
- package/ios/Senors/RNSensorsGyroscope.m +160 -0
- package/ios/Senors/RNSensorsMagnetometer.h +22 -0
- package/ios/Senors/RNSensorsMagnetometer.m +163 -0
- package/ios/Senors/RNSensorsOrientation.h +22 -0
- package/ios/Senors/RNSensorsOrientation.m +189 -0
- package/ios/Senors/RNSensorsUtils.h +7 -0
- package/ios/Senors/RNSensorsUtils.m +9 -0
- package/ios/Shakebug.h +7 -0
- package/ios/Shakebug.m +16 -0
- package/ios/Shakebug.xcodeproj/project.pbxproj +872 -0
- package/ios/Shakebug.xcodeproj/xcshareddata/xcschemes/Shakebug.xcscheme +66 -0
- package/ios/Shakebug.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/Shakebug.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/SketchCanvas/DrawingView.h +18 -0
- package/ios/SketchCanvas/DrawingView.m +96 -0
- package/ios/SketchCanvas/DrawingViewManager.h +12 -0
- package/ios/SketchCanvas/DrawingViewManager.m +35 -0
- package/ios/Storage/SharedPreferencesModule.h +13 -0
- package/ios/Storage/SharedPreferencesModule.m +35 -0
- package/ios/Thumbnaill/VideoThumbnailManager.h +12 -0
- package/ios/Thumbnaill/VideoThumbnailManager.m +73 -0
- package/ios/TrimVideo/ShakebugSDKVideoTrim.swift +372 -0
- package/ios/TrimVideo/VideoTrim-Bridging-Header.h +10 -0
- package/ios/TrimVideo/VideoTrim.m +23 -0
- package/ios/TrimVideo/VideoTrimmer.swift +810 -0
- package/ios/TrimVideo/VideoTrimmerThumb.swift +119 -0
- package/ios/TrimVideo/VideoTrimmerViewController.swift +301 -0
- package/ios/VideoPlayer/VideoPlayerModule.h +14 -0
- package/ios/VideoPlayer/VideoPlayerModule.m +29 -0
- package/ios/VideoPlayer/VideoPlayerViewController.h +18 -0
- package/ios/VideoPlayer/VideoPlayerViewController.m +29 -0
- package/package.json +45 -0
- package/shakebug-react-native.podspec +50 -0
- package/src/APIs/AddIssue.js +70 -0
- package/src/APIs/EndSession.js +32 -0
- package/src/APIs/Event.js +39 -0
- package/src/APIs/MatchKey.js +40 -0
- package/src/APIs/StartSession.js +84 -0
- package/src/Assets/images/OpenSketch.png +0 -0
- package/src/Assets/images/Push.png +0 -0
- package/src/Assets/images/RemoveTextView.png +0 -0
- package/src/Assets/images/black.png +0 -0
- package/src/Assets/images/blue.png +0 -0
- package/src/Assets/images/borderdBlack.png +0 -0
- package/src/Assets/images/borderdBlue.png +0 -0
- package/src/Assets/images/borderdGreen.png +0 -0
- package/src/Assets/images/borderdRed.png +0 -0
- package/src/Assets/images/borderdYellow.png +0 -0
- package/src/Assets/images/clear.png +0 -0
- package/src/Assets/images/close.png +0 -0
- package/src/Assets/images/green.png +0 -0
- package/src/Assets/images/next.png +0 -0
- package/src/Assets/images/play.png +0 -0
- package/src/Assets/images/red.png +0 -0
- package/src/Assets/images/shake.png +0 -0
- package/src/Assets/images/shakebugLogo.png +0 -0
- package/src/Assets/images/stopButton.png +0 -0
- package/src/Assets/images/text_icon.png +0 -0
- package/src/Assets/images/yellow.png +0 -0
- package/src/Componanats/CustomAlert.js +80 -0
- package/src/Componanats/ErrorHandler.js +80 -0
- package/src/Componanats/GlobalStateContext.js +22 -0
- package/src/Componanats/KeyboardAvoidingWrapper.js +43 -0
- package/src/Componanats/NavigationContext.js +42 -0
- package/src/Componanats/ShakeFunction.js +562 -0
- package/src/Componanats/localization.js +482 -0
- package/src/Screens/AddDetailsScreen.js +462 -0
- package/src/Screens/FirstScreen.js +629 -0
- package/src/Screens/Shakebug.js +487 -0
- package/src/Screens/StrockView.js +20 -0
- package/src/Screens/TrimVideoScreen.js +81 -0
- package/src/Screens/TutorialScreen.js +36 -0
- package/src/index.tsx +117 -0
- package/trimVideo/src/index.tsx +141 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// android/build.gradle
|
|
2
|
+
|
|
3
|
+
// based on:
|
|
4
|
+
//
|
|
5
|
+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
|
|
6
|
+
// previous location:
|
|
7
|
+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
|
|
8
|
+
//
|
|
9
|
+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
|
|
10
|
+
// previous location:
|
|
11
|
+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
|
+
|
|
13
|
+
// These defaults should reflect the SDK versions used by
|
|
14
|
+
// the minimum React Native version supported.
|
|
15
|
+
def DEFAULT_COMPILE_SDK_VERSION = 34
|
|
16
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '34.0.0'
|
|
17
|
+
def DEFAULT_MIN_SDK_VERSION = 24
|
|
18
|
+
def DEFAULT_TARGET_SDK_VERSION = 34
|
|
19
|
+
|
|
20
|
+
def isNewArchitectureEnabled() {
|
|
21
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
import java.nio.file.Paths
|
|
26
|
+
|
|
27
|
+
apply plugin: "com.android.library"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if (isNewArchitectureEnabled()) {
|
|
31
|
+
apply plugin: "com.facebook.react"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def getExtOrDefault(name) {
|
|
35
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["AwesomeLibrary_" + name]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
def getExtOrIntegerDefault(name) {
|
|
39
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AwesomeLibrary_" + name]).toInteger()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def supportsNamespace() {
|
|
44
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
45
|
+
def major = parsed[0].toInteger()
|
|
46
|
+
def minor = parsed[1].toInteger()
|
|
47
|
+
|
|
48
|
+
// Namespace support was added in 7.3.0
|
|
49
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static def safePackageName(String packageName) {
|
|
53
|
+
packageName.replace("-lts", "")
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
def safePackageVersion(String packageName) {
|
|
57
|
+
def version = project.properties['ffmpegKit.android.main.version']
|
|
58
|
+
def ltsVersion = project.properties['ffmpegKit.android.lts.version']
|
|
59
|
+
|
|
60
|
+
// try to get ffmpegKitPackageVersion if possible
|
|
61
|
+
safeExtGet("ffmpegKitPackageVersion", packageName.contains("-lts") ? ltsVersion + ".LTS" : version)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
buildscript {
|
|
67
|
+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
68
|
+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
69
|
+
// module dependency in an application project.
|
|
70
|
+
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
|
|
71
|
+
ext {
|
|
72
|
+
ffmpegKitPackage = "min"
|
|
73
|
+
ext.kotlin_version = '1.4.10'
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (project == rootProject) {
|
|
78
|
+
repositories {
|
|
79
|
+
google()
|
|
80
|
+
}
|
|
81
|
+
dependencies {
|
|
82
|
+
// This should reflect the Gradle plugin version used by
|
|
83
|
+
// the minimum React Native version supported.
|
|
84
|
+
classpath 'com.android.tools.build:gradle:3.4.1'
|
|
85
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
android {
|
|
92
|
+
|
|
93
|
+
if (supportsNamespace()) {
|
|
94
|
+
namespace "com.shakebug"
|
|
95
|
+
|
|
96
|
+
sourceSets {
|
|
97
|
+
main {
|
|
98
|
+
manifest.srcFile 'src/main/AndroidManifest.xml'
|
|
99
|
+
|
|
100
|
+
if (isNewArchitectureEnabled()) {
|
|
101
|
+
java.srcDirs += ["src/newarch",
|
|
102
|
+
"${project.buildDir}/generated/source/codegen/java"]
|
|
103
|
+
} else {
|
|
104
|
+
java.srcDirs += ["src/oldarch"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
111
|
+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
112
|
+
defaultConfig {
|
|
113
|
+
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
|
|
114
|
+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
|
|
115
|
+
versionCode 1
|
|
116
|
+
versionName "1.0"
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
buildTypes {
|
|
121
|
+
release {
|
|
122
|
+
minifyEnabled false
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
lintOptions {
|
|
127
|
+
abortOnError false
|
|
128
|
+
disable "GradleCompatible"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
repositories {
|
|
133
|
+
// ref: https://www.baeldung.com/maven-local-repository
|
|
134
|
+
mavenLocal()
|
|
135
|
+
maven {
|
|
136
|
+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
137
|
+
url "$rootDir/../node_modules/react-native/android"
|
|
138
|
+
}
|
|
139
|
+
maven {
|
|
140
|
+
// Android JSC is installed from npm
|
|
141
|
+
url "$rootDir/../node_modules/jsc-android/dist"
|
|
142
|
+
}
|
|
143
|
+
google()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
dependencies {
|
|
147
|
+
//noinspection GradleDynamicVersion
|
|
148
|
+
implementation "com.github.HBiSoft:HBRecorder:3.0.3"
|
|
149
|
+
|
|
150
|
+
implementation 'commons-io:commons-io:2.11.0'
|
|
151
|
+
|
|
152
|
+
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
153
|
+
implementation 'androidx.appcompat:appcompat:1.0.2'
|
|
154
|
+
implementation 'androidx.annotation:annotation:1.0.2'
|
|
155
|
+
implementation "androidx.core:core:1.3.1"
|
|
156
|
+
implementation "androidx.exifinterface:exifinterface:1.3.3"
|
|
157
|
+
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
|
158
|
+
implementation 'com.arthenica:ffmpeg-kit-full:6.0-2'
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def firebaseBomVersion = safeExtGet("firebaseBomVersion", null)
|
|
162
|
+
def firebaseIidVersion = safeExtGet('firebaseIidVersion', null)
|
|
163
|
+
if (firebaseBomVersion) {
|
|
164
|
+
implementation platform("com.google.firebase:firebase-bom:${firebaseBomVersion}")
|
|
165
|
+
implementation "com.google.firebase:firebase-iid"
|
|
166
|
+
} else if(firebaseIidVersion){
|
|
167
|
+
implementation "com.google.firebase:firebase-iid:${firebaseIidVersion}"
|
|
168
|
+
}else{
|
|
169
|
+
def iidVersion = safeExtGet('googlePlayServicesIidVersion', safeExtGet('googlePlayServicesVersion', '17.0.0'))
|
|
170
|
+
implementation "com.google.android.gms:play-services-iid:$iidVersion"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static def findNodeModulePath(baseDir, packageName) {
|
|
175
|
+
def basePath = baseDir.toPath().normalize()
|
|
176
|
+
// Node's module resolution algorithm searches up to the root directory,
|
|
177
|
+
// after which the base path will be null
|
|
178
|
+
while (basePath) {
|
|
179
|
+
def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
|
|
180
|
+
if (candidatePath.toFile().exists()) {
|
|
181
|
+
return candidatePath.toString()
|
|
182
|
+
}
|
|
183
|
+
basePath = basePath.getParent()
|
|
184
|
+
}
|
|
185
|
+
return null
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
def findNodeModulePath(packageName) {
|
|
189
|
+
// Don't start in the project dir, as its path ends with node_modules/react-native-mlkit-ocr/android
|
|
190
|
+
// we want to go two levels up, so we end up in the first_node modules and eventually
|
|
191
|
+
// search upwards if the package is not found there
|
|
192
|
+
return findNodeModulePath(projectDir.toPath().parent.parent.toFile(), packageName)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
def safeExtGet(prop, fallback) {
|
|
196
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
def resolveReactNativeDirectory() {
|
|
200
|
+
def reactNativeLocation = safeExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
|
|
201
|
+
if (reactNativeLocation != null) {
|
|
202
|
+
return file(reactNativeLocation)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// monorepo workaround
|
|
206
|
+
// react-native can be hoisted or in project's own node_modules
|
|
207
|
+
def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
|
|
208
|
+
if (reactNativeFromProjectNodeModules.exists()) {
|
|
209
|
+
return reactNativeFromProjectNodeModules
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
def reactNativeFromNodeModulesWithImagePicker = file("${projectDir}/../../react-native")
|
|
213
|
+
if (reactNativeFromNodeModulesWithImagePicker.exists()) {
|
|
214
|
+
return reactNativeFromNodeModulesWithImagePicker
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
throw new Exception(
|
|
218
|
+
"[react-native-image-picker] Unable to resolve react-native location in " +
|
|
219
|
+
"node_modules. You should add project extension property (in app/build.gradle) " +
|
|
220
|
+
"`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
def getReactNativeMinorVersion() {
|
|
225
|
+
def REACT_NATIVE_DIR = resolveReactNativeDirectory()
|
|
226
|
+
|
|
227
|
+
def reactProperties = new Properties()
|
|
228
|
+
file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
|
|
229
|
+
|
|
230
|
+
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
|
|
231
|
+
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
|
|
232
|
+
|
|
233
|
+
return REACT_NATIVE_MINOR_VERSION
|
|
234
|
+
}
|
|
235
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
package="com.shakebug">
|
|
3
|
+
|
|
4
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
<!-- If you intend to use the microphone -->
|
|
9
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
10
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
|
11
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
12
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
13
|
+
|
|
14
|
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
15
|
+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
|
16
|
+
|
|
17
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
|
|
18
|
+
|
|
19
|
+
<application
|
|
20
|
+
android:hardwareAccelerated="true"
|
|
21
|
+
>
|
|
22
|
+
<provider
|
|
23
|
+
android:name=".ImagePickerProvider"
|
|
24
|
+
android:authorities="${applicationId}.imagepickerprovider"
|
|
25
|
+
android:exported="false"
|
|
26
|
+
android:grantUriPermissions="true">
|
|
27
|
+
<meta-data
|
|
28
|
+
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
29
|
+
android:resource="@xml/imagepicker_provider_paths" />
|
|
30
|
+
</provider>
|
|
31
|
+
|
|
32
|
+
<receiver android:name=".ScreenshotReceiver"
|
|
33
|
+
android:exported="true"> <!-- Specify android:exported="true" -->
|
|
34
|
+
<intent-filter>
|
|
35
|
+
<action android:name="android.intent.action.SCREENSHOT" />
|
|
36
|
+
</intent-filter>
|
|
37
|
+
</receiver>
|
|
38
|
+
</application>
|
|
39
|
+
</manifest>
|
|
40
|
+
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import android.content.BroadcastReceiver;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.Intent;
|
|
6
|
+
import android.content.IntentFilter;
|
|
7
|
+
import android.os.Build;
|
|
8
|
+
import android.os.Handler;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A component similar to ConnectivityReceiver (and its implementations) that goes through
|
|
12
|
+
* register/unregister cycles. It is only active on an Amazon Fire device (e.g. FireTV Stick). It
|
|
13
|
+
* will continuously issue an intent to FireOS to check for internet connectivity and listen to the
|
|
14
|
+
* response via broadcast receiver.
|
|
15
|
+
*
|
|
16
|
+
* <p>This is required since FireOs does not report network capabilities correctly
|
|
17
|
+
* (NetworkCapabilities.NET_CAPABILITY_VALIDATED is true when offline) even when the OS knows that
|
|
18
|
+
* the internet is not reachable.
|
|
19
|
+
*
|
|
20
|
+
* <p>The caller component is responsible to responding to callbacks of the device going online or
|
|
21
|
+
* offline.
|
|
22
|
+
*/
|
|
23
|
+
public class AmazonFireDeviceConnectivityPoller {
|
|
24
|
+
/** Intent action for triggering FireOS connectivity checking. */
|
|
25
|
+
private static final String ACTION_CONNECTIVITY_CHECK =
|
|
26
|
+
"com.amazon.tv.networkmonitor.CONNECTIVITY_CHECK";
|
|
27
|
+
|
|
28
|
+
/** Broadcast sent by NetMon FireOS component when the device cannot reach the internet. */
|
|
29
|
+
private static final String ACTION_INTERNET_DOWN = "com.amazon.tv.networkmonitor.INTERNET_DOWN";
|
|
30
|
+
|
|
31
|
+
/** Broadcast sent by NetMon FireOS component when the can reach the internet. */
|
|
32
|
+
private static final String ACTION_INTERNET_UP = "com.amazon.tv.networkmonitor.INTERNET_UP";
|
|
33
|
+
|
|
34
|
+
/** Interval (in milliseconds) of how often to check for connectivity. */
|
|
35
|
+
private static final long POLLING_INTERVAL_MS = 10 * 1000;
|
|
36
|
+
|
|
37
|
+
private final Receiver receiver = new Receiver();
|
|
38
|
+
private final Context context;
|
|
39
|
+
private final ConnectivityChangedCallback callback;
|
|
40
|
+
|
|
41
|
+
private final Runnable checker = new PollerTask();
|
|
42
|
+
private Handler handler;
|
|
43
|
+
private boolean pollerRunning = false;
|
|
44
|
+
|
|
45
|
+
/** Callback interface that will be invoked when internet connectivity status changes. */
|
|
46
|
+
public interface ConnectivityChangedCallback {
|
|
47
|
+
/**
|
|
48
|
+
* Called when internet connectivity status changes.
|
|
49
|
+
*
|
|
50
|
+
* @param isConnected
|
|
51
|
+
*/
|
|
52
|
+
void onAmazonFireDeviceConnectivityChanged(boolean isConnected);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
AmazonFireDeviceConnectivityPoller(Context context, ConnectivityChangedCallback callback) {
|
|
56
|
+
this.context = context;
|
|
57
|
+
this.callback = callback;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public void register() {
|
|
61
|
+
if (!isFireOsDevice()) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
registerReceiver();
|
|
66
|
+
startPoller();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public void unregister() {
|
|
70
|
+
if (!isFireOsDevice()) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
stopPoller();
|
|
75
|
+
unregisterReceiver();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private boolean isFireOsDevice() {
|
|
79
|
+
// https://developer.amazon.com/docs/fire-tv/identify-amazon-fire-tv-devices.html
|
|
80
|
+
// https://developer.amazon.com/docs/fire-tablets/ft-specs-custom.html
|
|
81
|
+
return Build.MANUFACTURER.equals("Amazon")
|
|
82
|
+
&& (Build.MODEL.startsWith("AF") || Build.MODEL.startsWith("KF"));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private void registerReceiver() {
|
|
86
|
+
if (receiver.registered) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
IntentFilter filter = new IntentFilter();
|
|
91
|
+
filter.addAction(ACTION_INTERNET_DOWN);
|
|
92
|
+
filter.addAction(ACTION_INTERNET_UP);
|
|
93
|
+
NetInfoUtils.compatRegisterReceiver(context, receiver, filter, false);
|
|
94
|
+
|
|
95
|
+
receiver.registered = true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private void startPoller() {
|
|
99
|
+
if (pollerRunning) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// NOTE: since this is usually called on the right thread, we construct
|
|
104
|
+
// the handler here rather than in the constructor.
|
|
105
|
+
handler = new Handler();
|
|
106
|
+
pollerRunning = true;
|
|
107
|
+
handler.post(checker);
|
|
108
|
+
|
|
109
|
+
// NOTE: In the future, WorkManager or another approach to the polling task
|
|
110
|
+
// would work better. For now though this is the simpler way to keep
|
|
111
|
+
// checking for connectivity.
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private void unregisterReceiver() {
|
|
115
|
+
if (!receiver.registered) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
context.unregisterReceiver(receiver);
|
|
120
|
+
receiver.registered = false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private void stopPoller() {
|
|
124
|
+
if (!pollerRunning) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
pollerRunning = false;
|
|
129
|
+
handler.removeCallbacksAndMessages(null);
|
|
130
|
+
handler = null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private class Receiver extends BroadcastReceiver {
|
|
134
|
+
boolean registered = false;
|
|
135
|
+
|
|
136
|
+
private Boolean lastIsConnected;
|
|
137
|
+
|
|
138
|
+
@Override
|
|
139
|
+
public void onReceive(Context context, Intent intent) {
|
|
140
|
+
String action = intent == null ? null : intent.getAction();
|
|
141
|
+
boolean isConnected;
|
|
142
|
+
if (ACTION_INTERNET_DOWN.equals(action)) {
|
|
143
|
+
isConnected = false;
|
|
144
|
+
} else if (ACTION_INTERNET_UP.equals(action)) {
|
|
145
|
+
isConnected = true;
|
|
146
|
+
} else {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (lastIsConnected == null || lastIsConnected != isConnected) {
|
|
151
|
+
lastIsConnected = isConnected;
|
|
152
|
+
callback.onAmazonFireDeviceConnectivityChanged(isConnected);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private class PollerTask implements Runnable {
|
|
158
|
+
@Override
|
|
159
|
+
public void run() {
|
|
160
|
+
if (!pollerRunning) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
Intent checkIntent = new Intent(ACTION_CONNECTIVITY_CHECK);
|
|
165
|
+
context.sendBroadcast(checkIntent);
|
|
166
|
+
|
|
167
|
+
handler.postDelayed(checker, POLLING_INTERVAL_MS);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import java.lang.ref.WeakReference;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Author:J.Chou
|
|
9
|
+
* Date: 2016.07.21 11:45.
|
|
10
|
+
* Email: who_know_me@163.com
|
|
11
|
+
* Describe:
|
|
12
|
+
*/
|
|
13
|
+
public class BaseUtils {
|
|
14
|
+
|
|
15
|
+
private static final String ERROR_INIT = "Initialize BaseUtils with invoke init()";
|
|
16
|
+
|
|
17
|
+
private static WeakReference<Context> mWeakReferenceContext;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* init in Application
|
|
21
|
+
*/
|
|
22
|
+
public static void init(Context ctx){
|
|
23
|
+
mWeakReferenceContext = new WeakReference<>(ctx);
|
|
24
|
+
//something to do...
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public static Context getContext() {
|
|
28
|
+
if (mWeakReferenceContext == null) {
|
|
29
|
+
throw new IllegalArgumentException(ERROR_INIT);
|
|
30
|
+
}
|
|
31
|
+
return mWeakReferenceContext.get().getApplicationContext();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
package com.shakebug;
|
|
8
|
+
|
|
9
|
+
import android.annotation.SuppressLint;
|
|
10
|
+
import android.content.BroadcastReceiver;
|
|
11
|
+
import android.content.Context;
|
|
12
|
+
import android.content.Intent;
|
|
13
|
+
import android.content.IntentFilter;
|
|
14
|
+
import android.net.ConnectivityManager;
|
|
15
|
+
import android.net.NetworkInfo;
|
|
16
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
+
import com.shakebug.types.CellularGeneration;
|
|
18
|
+
import com.shakebug.types.ConnectionType;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This gets the connectivity status using a BroadcastReceiver. This method was deprecated on
|
|
22
|
+
* Android from API level 24 (N) but we use this method still for any devices running below level
|
|
23
|
+
* 24.
|
|
24
|
+
*
|
|
25
|
+
* <p>It has a few differences from the new NetworkCallback method: - Changes to the cellular
|
|
26
|
+
* network effective type (eg. from 2g to 3g) will not trigger a callback
|
|
27
|
+
*/
|
|
28
|
+
@SuppressWarnings("deprecation")
|
|
29
|
+
public class BroadcastReceiverConnectivityReceiver extends ConnectivityReceiver {
|
|
30
|
+
private final ConnectivityBroadcastReceiver mConnectivityBroadcastReceiver;
|
|
31
|
+
public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
|
|
32
|
+
|
|
33
|
+
public BroadcastReceiverConnectivityReceiver(ReactApplicationContext reactContext) {
|
|
34
|
+
super(reactContext);
|
|
35
|
+
mConnectivityBroadcastReceiver = new ConnectivityBroadcastReceiver();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public void register() {
|
|
40
|
+
IntentFilter filter = new IntentFilter();
|
|
41
|
+
filter.addAction(CONNECTIVITY_ACTION);
|
|
42
|
+
NetInfoUtils.compatRegisterReceiver(
|
|
43
|
+
getReactContext(),
|
|
44
|
+
mConnectivityBroadcastReceiver,
|
|
45
|
+
filter,
|
|
46
|
+
false
|
|
47
|
+
);
|
|
48
|
+
mConnectivityBroadcastReceiver.setRegistered(true);
|
|
49
|
+
updateAndSendConnectionType();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
public void unregister() {
|
|
54
|
+
if (mConnectivityBroadcastReceiver.isRegistered()) {
|
|
55
|
+
getReactContext().unregisterReceiver(mConnectivityBroadcastReceiver);
|
|
56
|
+
mConnectivityBroadcastReceiver.setRegistered(false);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@SuppressLint("MissingPermission")
|
|
61
|
+
private void updateAndSendConnectionType() {
|
|
62
|
+
ConnectionType connectionType = ConnectionType.UNKNOWN;
|
|
63
|
+
CellularGeneration cellularGeneration = null;
|
|
64
|
+
boolean isInternetReachable = false;
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
NetworkInfo networkInfo = getConnectivityManager().getActiveNetworkInfo();
|
|
68
|
+
if (networkInfo == null || !networkInfo.isConnected()) {
|
|
69
|
+
connectionType = ConnectionType.NONE;
|
|
70
|
+
} else {
|
|
71
|
+
// Check if the internet is reachable
|
|
72
|
+
isInternetReachable = networkInfo.isConnected();
|
|
73
|
+
|
|
74
|
+
// Get the connection type
|
|
75
|
+
int networkType = networkInfo.getType();
|
|
76
|
+
switch (networkType) {
|
|
77
|
+
case ConnectivityManager.TYPE_BLUETOOTH:
|
|
78
|
+
connectionType = ConnectionType.BLUETOOTH;
|
|
79
|
+
break;
|
|
80
|
+
case ConnectivityManager.TYPE_ETHERNET:
|
|
81
|
+
connectionType = ConnectionType.ETHERNET;
|
|
82
|
+
break;
|
|
83
|
+
case ConnectivityManager.TYPE_MOBILE:
|
|
84
|
+
case ConnectivityManager.TYPE_MOBILE_DUN:
|
|
85
|
+
connectionType = ConnectionType.CELLULAR;
|
|
86
|
+
cellularGeneration = CellularGeneration.fromNetworkInfo(networkInfo);
|
|
87
|
+
break;
|
|
88
|
+
case ConnectivityManager.TYPE_WIFI:
|
|
89
|
+
connectionType = ConnectionType.WIFI;
|
|
90
|
+
break;
|
|
91
|
+
case ConnectivityManager.TYPE_WIMAX:
|
|
92
|
+
connectionType = ConnectionType.WIMAX;
|
|
93
|
+
break;
|
|
94
|
+
case ConnectivityManager.TYPE_VPN:
|
|
95
|
+
connectionType = ConnectionType.VPN;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} catch (SecurityException e) {
|
|
100
|
+
connectionType = ConnectionType.UNKNOWN;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
updateConnectivity(connectionType, cellularGeneration, isInternetReachable);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Class that receives intents whenever the connection type changes. NB: It is possible on some
|
|
108
|
+
* devices to receive certain connection type changes multiple times.
|
|
109
|
+
*/
|
|
110
|
+
private class ConnectivityBroadcastReceiver extends BroadcastReceiver {
|
|
111
|
+
|
|
112
|
+
// TODO: Remove registered check when source of crash is found. t9846865
|
|
113
|
+
private boolean isRegistered = false;
|
|
114
|
+
|
|
115
|
+
public void setRegistered(boolean registered) {
|
|
116
|
+
isRegistered = registered;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public boolean isRegistered() {
|
|
120
|
+
return isRegistered;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@Override
|
|
124
|
+
public void onReceive(Context context, Intent intent) {
|
|
125
|
+
String action = intent.getAction();
|
|
126
|
+
if (action != null && action.equals(CONNECTIVITY_ACTION)) {
|
|
127
|
+
updateAndSendConnectionType();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|