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,147 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import android.location.Criteria;
|
|
4
|
+
import android.location.Location;
|
|
5
|
+
import android.location.LocationListener;
|
|
6
|
+
import android.location.LocationManager;
|
|
7
|
+
import android.os.Bundle;
|
|
8
|
+
import android.os.Looper;
|
|
9
|
+
import android.util.Log;
|
|
10
|
+
|
|
11
|
+
import com.facebook.react.bridge.Promise;
|
|
12
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
13
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
14
|
+
|
|
15
|
+
import java.util.Timer;
|
|
16
|
+
import java.util.TimerTask;
|
|
17
|
+
|
|
18
|
+
public class GetLocation {
|
|
19
|
+
|
|
20
|
+
private final LocationManager locationManager;
|
|
21
|
+
|
|
22
|
+
private Timer timer;
|
|
23
|
+
private LocationListener listener;
|
|
24
|
+
private Promise promise;
|
|
25
|
+
|
|
26
|
+
public GetLocation(LocationManager locationManager) {
|
|
27
|
+
this.locationManager = locationManager;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public void get(ReadableMap options, final Promise promise) {
|
|
31
|
+
this.promise = promise;
|
|
32
|
+
try {
|
|
33
|
+
if (!isLocationEnabled()) {
|
|
34
|
+
promise.reject("UNAVAILABLE", "Location not available");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
boolean enableHighAccuracy = options.hasKey("enableHighAccuracy") && options.getBoolean("enableHighAccuracy");
|
|
39
|
+
long timeout = options.hasKey("timeout") ? (long) options.getDouble("timeout") : 0;
|
|
40
|
+
|
|
41
|
+
Criteria criteria = new Criteria();
|
|
42
|
+
criteria.setAccuracy(enableHighAccuracy ? Criteria.ACCURACY_FINE : Criteria.ACCURACY_COARSE);
|
|
43
|
+
|
|
44
|
+
listener = new LocationListener() {
|
|
45
|
+
private boolean locationFound = false;
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
public synchronized void onLocationChanged(Location location) {
|
|
49
|
+
if (location != null && !locationFound) {
|
|
50
|
+
locationFound = true;
|
|
51
|
+
WritableNativeMap resultLocation = new WritableNativeMap();
|
|
52
|
+
resultLocation.putString("provider", location.getProvider());
|
|
53
|
+
resultLocation.putDouble("latitude", location.getLatitude());
|
|
54
|
+
resultLocation.putDouble("longitude", location.getLongitude());
|
|
55
|
+
resultLocation.putDouble("accuracy", location.getAccuracy());
|
|
56
|
+
resultLocation.putDouble("altitude", location.getAltitude());
|
|
57
|
+
resultLocation.putDouble("speed", location.getSpeed());
|
|
58
|
+
resultLocation.putDouble("bearing", location.getBearing());
|
|
59
|
+
resultLocation.putDouble("time", location.getTime());
|
|
60
|
+
promise.resolve(resultLocation);
|
|
61
|
+
stop();
|
|
62
|
+
clearReferences();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
public void onProviderEnabled(String provider) {
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
public void onProviderDisabled(String provider) {
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
locationManager.requestLocationUpdates(0L, 0F, criteria, listener, Looper.myLooper());
|
|
83
|
+
|
|
84
|
+
if (timeout > 0) {
|
|
85
|
+
timer = new Timer();
|
|
86
|
+
timer.schedule(new TimerTask() {
|
|
87
|
+
@Override
|
|
88
|
+
public void run() {
|
|
89
|
+
try {
|
|
90
|
+
promise.reject("TIMEOUT", "Location timed out");
|
|
91
|
+
stop();
|
|
92
|
+
clearReferences();
|
|
93
|
+
} catch (Exception ex) {
|
|
94
|
+
ex.printStackTrace();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, timeout);
|
|
98
|
+
}
|
|
99
|
+
} catch (SecurityException ex) {
|
|
100
|
+
ex.printStackTrace();
|
|
101
|
+
stop();
|
|
102
|
+
promise.reject("UNAUTHORIZED", "Location permission denied", ex);
|
|
103
|
+
} catch (Exception ex) {
|
|
104
|
+
ex.printStackTrace();
|
|
105
|
+
stop();
|
|
106
|
+
promise.reject("UNAVAILABLE", "Location not available", ex);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public synchronized void cancel() {
|
|
111
|
+
if (promise == null) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
promise.reject("CANCELLED", "Location cancelled by another request");
|
|
116
|
+
stop();
|
|
117
|
+
clearReferences();
|
|
118
|
+
} catch (Exception ex) {
|
|
119
|
+
ex.printStackTrace();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private void stop() {
|
|
124
|
+
if (timer != null) {
|
|
125
|
+
timer.cancel();
|
|
126
|
+
}
|
|
127
|
+
if (listener != null) {
|
|
128
|
+
locationManager.removeUpdates(listener);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private void clearReferences() {
|
|
133
|
+
promise = null;
|
|
134
|
+
timer = null;
|
|
135
|
+
listener = null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private boolean isLocationEnabled() {
|
|
139
|
+
try {
|
|
140
|
+
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) ||
|
|
141
|
+
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
|
142
|
+
} catch (Exception ex) {
|
|
143
|
+
ex.printStackTrace();
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.net.Uri;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
7
|
+
import androidx.exifinterface.media.ExifInterface;
|
|
8
|
+
|
|
9
|
+
import java.io.InputStream;
|
|
10
|
+
|
|
11
|
+
public class ImageMetadata extends Metadata {
|
|
12
|
+
public ImageMetadata(Uri uri, Context context) {
|
|
13
|
+
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
|
|
14
|
+
ExifInterface exif = new ExifInterface(inputStream);
|
|
15
|
+
String datetimeTag = exif.getAttribute(ExifInterface.TAG_DATETIME);
|
|
16
|
+
|
|
17
|
+
// Extract anymore metadata here...
|
|
18
|
+
if (datetimeTag != null)
|
|
19
|
+
this.datetime = getDateTimeInUTC(datetimeTag, "yyyy:MM:dd HH:mm:ss");
|
|
20
|
+
} catch (Exception e) {
|
|
21
|
+
// This error does not bubble up to RN as we don't want failed datetime retrieval to prevent selection
|
|
22
|
+
Log.e("RNIP", "Could not load image metadata: " + e.getMessage());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Override
|
|
27
|
+
public String getDateTime() {
|
|
28
|
+
return datetime;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// At the moment we are not using the ImageMetadata class to get width/height
|
|
32
|
+
// TODO: to use this class for extracting image width and height in the future
|
|
33
|
+
@Override
|
|
34
|
+
public int getWidth() {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public int getHeight() {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import androidx.core.content.FileProvider;
|
|
4
|
+
|
|
5
|
+
// Two FileProvider class with same name will conflict during manifest merger, so we create a class which inherits from FileProvider with different name.
|
|
6
|
+
// This prevents conflict if library users already have used the default FileProvider class.
|
|
7
|
+
public class ImagePickerProvider extends FileProvider {
|
|
8
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.Nullable;
|
|
6
|
+
|
|
7
|
+
import java.text.SimpleDateFormat;
|
|
8
|
+
import java.util.Date;
|
|
9
|
+
import java.util.Locale;
|
|
10
|
+
|
|
11
|
+
abstract class Metadata {
|
|
12
|
+
protected String datetime;
|
|
13
|
+
protected int height;
|
|
14
|
+
protected int width;
|
|
15
|
+
|
|
16
|
+
abstract public String getDateTime();
|
|
17
|
+
|
|
18
|
+
abstract public int getWidth();
|
|
19
|
+
|
|
20
|
+
abstract public int getHeight();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Converts a timestamp to a UTC timestamp
|
|
24
|
+
*
|
|
25
|
+
* @param value - timestamp
|
|
26
|
+
* @param format - input format
|
|
27
|
+
* @return formatted timestamp
|
|
28
|
+
*/
|
|
29
|
+
protected @Nullable
|
|
30
|
+
String getDateTimeInUTC(String value, String format) {
|
|
31
|
+
try {
|
|
32
|
+
Date datetime = new SimpleDateFormat(format, Locale.US).parse(value);
|
|
33
|
+
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US);
|
|
34
|
+
|
|
35
|
+
if (datetime != null) {
|
|
36
|
+
return formatter.format(datetime);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
} catch (Exception e) {
|
|
41
|
+
// This error does not bubble up to RN as we don't want failed datetime parsing to prevent selection
|
|
42
|
+
Log.e("RNIP", "Could not parse image datetime to UTC: " + e.getMessage());
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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.os.Build;
|
|
10
|
+
import com.facebook.react.bridge.Promise;
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
13
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
14
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
15
|
+
|
|
16
|
+
/** Module that monitors and provides information about the connectivity state of the device. */
|
|
17
|
+
@ReactModule(name = NetInfoModule.NAME)
|
|
18
|
+
public class NetInfoModule extends ReactContextBaseJavaModule implements AmazonFireDeviceConnectivityPoller.ConnectivityChangedCallback {
|
|
19
|
+
public static final String NAME = "ShakebugSDKRNCNetInfo";
|
|
20
|
+
|
|
21
|
+
private final ConnectivityReceiver mConnectivityReceiver;
|
|
22
|
+
private final AmazonFireDeviceConnectivityPoller mAmazonConnectivityChecker;
|
|
23
|
+
|
|
24
|
+
private int numberOfListeners = 0;
|
|
25
|
+
|
|
26
|
+
public NetInfoModule(ReactApplicationContext reactContext) {
|
|
27
|
+
super(reactContext);
|
|
28
|
+
// Create the connectivity receiver based on the API level we are running on
|
|
29
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
30
|
+
mConnectivityReceiver = new NetworkCallbackConnectivityReceiver(reactContext);
|
|
31
|
+
} else {
|
|
32
|
+
mConnectivityReceiver = new BroadcastReceiverConnectivityReceiver(reactContext);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
mAmazonConnectivityChecker = new AmazonFireDeviceConnectivityPoller(reactContext, this);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public void initialize() {
|
|
40
|
+
mConnectivityReceiver.register();
|
|
41
|
+
mAmazonConnectivityChecker.register();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public void onCatalystInstanceDestroy() {
|
|
46
|
+
mAmazonConnectivityChecker.unregister();
|
|
47
|
+
mConnectivityReceiver.unregister();
|
|
48
|
+
mConnectivityReceiver.hasListener = false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
public String getName() {
|
|
53
|
+
return NAME;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@ReactMethod
|
|
57
|
+
public void getCurrentState(final String requestedInterface, final Promise promise) {
|
|
58
|
+
mConnectivityReceiver.getCurrentState(requestedInterface, promise);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Override
|
|
62
|
+
public void onAmazonFireDeviceConnectivityChanged(boolean isConnected) {
|
|
63
|
+
mConnectivityReceiver.setIsInternetReachableOverride(isConnected);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@ReactMethod
|
|
67
|
+
public void addListener(String eventName) {
|
|
68
|
+
numberOfListeners++;
|
|
69
|
+
mConnectivityReceiver.hasListener = true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@ReactMethod
|
|
73
|
+
public void removeListeners(Integer count) {
|
|
74
|
+
numberOfListeners -= count;
|
|
75
|
+
if (numberOfListeners == 0) {
|
|
76
|
+
mConnectivityReceiver.hasListener = false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.Manifest;
|
|
10
|
+
import android.annotation.SuppressLint;
|
|
11
|
+
import android.content.BroadcastReceiver;
|
|
12
|
+
import android.content.Context;
|
|
13
|
+
import android.content.IntentFilter;
|
|
14
|
+
import android.content.pm.PackageManager;
|
|
15
|
+
import android.os.Build;
|
|
16
|
+
|
|
17
|
+
import androidx.core.content.ContextCompat;
|
|
18
|
+
|
|
19
|
+
public class NetInfoUtils {
|
|
20
|
+
public static void reverseByteArray(byte[] array) {
|
|
21
|
+
for (int i = 0; i < array.length / 2; i++) {
|
|
22
|
+
byte temp = array[i];
|
|
23
|
+
array[i] = array[array.length - i - 1];
|
|
24
|
+
array[array.length - i - 1] = temp;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static boolean isAccessWifiStatePermissionGranted(Context context) {
|
|
29
|
+
return ContextCompat.checkSelfPermission(context,
|
|
30
|
+
Manifest.permission.ACCESS_WIFI_STATE) == PackageManager.PERMISSION_GRANTED;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Starting with Android 14, apps and services that target Android 14 and use context-registered
|
|
36
|
+
* receivers are required to specify a flag to indicate whether or not the receiver should be
|
|
37
|
+
* exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED
|
|
38
|
+
* <a href="https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported"/>
|
|
39
|
+
*/
|
|
40
|
+
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
|
41
|
+
public static void compatRegisterReceiver(
|
|
42
|
+
Context context, BroadcastReceiver receiver, IntentFilter filter, boolean exported) {
|
|
43
|
+
if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) {
|
|
44
|
+
context.registerReceiver(
|
|
45
|
+
receiver, filter, exported ? Context.RECEIVER_EXPORTED : Context.RECEIVER_NOT_EXPORTED);
|
|
46
|
+
} else {
|
|
47
|
+
context.registerReceiver(receiver, filter);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
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.annotation.TargetApi;
|
|
11
|
+
import android.net.ConnectivityManager;
|
|
12
|
+
import android.net.LinkProperties;
|
|
13
|
+
import android.net.Network;
|
|
14
|
+
import android.net.NetworkCapabilities;
|
|
15
|
+
import android.net.NetworkInfo;
|
|
16
|
+
import android.os.Build;
|
|
17
|
+
import android.os.Handler;
|
|
18
|
+
import android.os.Looper;
|
|
19
|
+
|
|
20
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
21
|
+
import com.shakebug.types.CellularGeneration;
|
|
22
|
+
import com.shakebug.types.ConnectionType;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This gets the connectivity status using a NetworkCallback on the system default network. This
|
|
26
|
+
* method was added into Android from API level 24 (N) and we use it for all devices which support
|
|
27
|
+
* it.
|
|
28
|
+
*/
|
|
29
|
+
@TargetApi(Build.VERSION_CODES.N)
|
|
30
|
+
public class NetworkCallbackConnectivityReceiver extends ConnectivityReceiver {
|
|
31
|
+
private static final int DELAY_MS = 250;
|
|
32
|
+
private final ConnectivityNetworkCallback mNetworkCallback;
|
|
33
|
+
|
|
34
|
+
// from the docs:
|
|
35
|
+
// "Do NOT call ConnectivityManager.getNetworkCapabilities(android.net.Network)
|
|
36
|
+
// or ConnectivityManager.getLinkProperties(android.net.Network) or other
|
|
37
|
+
// synchronous ConnectivityManager methods in this callback as this is
|
|
38
|
+
// prone to race conditions ; calling these methods while in a callback
|
|
39
|
+
// may return an outdated or even a null object."
|
|
40
|
+
// https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback
|
|
41
|
+
// For this reason, we will fetch these values when not provided by the callback
|
|
42
|
+
// on an asynchronous thread.
|
|
43
|
+
private Network mNetwork = null;
|
|
44
|
+
private NetworkCapabilities mCapabilities = null;
|
|
45
|
+
|
|
46
|
+
public NetworkCallbackConnectivityReceiver(ReactApplicationContext reactContext) {
|
|
47
|
+
super(reactContext);
|
|
48
|
+
mNetworkCallback = new ConnectivityNetworkCallback();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
@SuppressLint("MissingPermission")
|
|
53
|
+
public void register() {
|
|
54
|
+
try {
|
|
55
|
+
// Similar to BroadcastReceiver implementation, we need to force
|
|
56
|
+
// an initial callback call in order to get the current network state,
|
|
57
|
+
// otherwise, an app started without any network connection will
|
|
58
|
+
// always be reported as "unknown".
|
|
59
|
+
mNetwork = getConnectivityManager().getActiveNetwork();
|
|
60
|
+
asyncUpdateAndSend(0);
|
|
61
|
+
|
|
62
|
+
getConnectivityManager().registerDefaultNetworkCallback(mNetworkCallback);
|
|
63
|
+
} catch (SecurityException e) {
|
|
64
|
+
// TODO: Display a yellow box about this
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Override
|
|
69
|
+
public void unregister() {
|
|
70
|
+
try {
|
|
71
|
+
getConnectivityManager().unregisterNetworkCallback(mNetworkCallback);
|
|
72
|
+
} catch (SecurityException e) {
|
|
73
|
+
// TODO: Display a yellow box about this
|
|
74
|
+
} catch (IllegalArgumentException e) {
|
|
75
|
+
// ignore this, it is expected when the callback was not registered successfully
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@SuppressLint("MissingPermission")
|
|
80
|
+
void updateAndSend() {
|
|
81
|
+
ConnectionType connectionType = ConnectionType.UNKNOWN;
|
|
82
|
+
CellularGeneration cellularGeneration = null;
|
|
83
|
+
NetworkInfo networkInfo = null;
|
|
84
|
+
boolean isInternetReachable = false;
|
|
85
|
+
boolean isInternetSuspended = false;
|
|
86
|
+
|
|
87
|
+
final Network network = mNetwork;
|
|
88
|
+
final NetworkCapabilities capabilities = mCapabilities;
|
|
89
|
+
|
|
90
|
+
if (capabilities != null) {
|
|
91
|
+
// Get the connection type
|
|
92
|
+
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)) {
|
|
93
|
+
connectionType = ConnectionType.BLUETOOTH;
|
|
94
|
+
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
|
|
95
|
+
connectionType = ConnectionType.CELLULAR;
|
|
96
|
+
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
|
|
97
|
+
connectionType = ConnectionType.ETHERNET;
|
|
98
|
+
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
|
99
|
+
connectionType = ConnectionType.WIFI;
|
|
100
|
+
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) {
|
|
101
|
+
connectionType = ConnectionType.VPN;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (network != null) {
|
|
105
|
+
// This may return null per API docs, and is deprecated, but for older APIs (< VERSION_CODES.P)
|
|
106
|
+
// we need it to test for suspended internet
|
|
107
|
+
try {
|
|
108
|
+
networkInfo = getConnectivityManager().getNetworkInfo(network);
|
|
109
|
+
} catch (SecurityException e) {
|
|
110
|
+
// Android 11 may throw a 'package does not belong' security exception here.
|
|
111
|
+
// Google fixed Android 14, 13 and 12 with the issue where Chaland Jean patched those versions.
|
|
112
|
+
// Android 11 is too old, so that's why we have to catch this exception here to be safe.
|
|
113
|
+
// https://android.googlesource.com/platform/frameworks/base/+/249be21013e389837f5b2beb7d36890b25ecfaaf%5E%21/
|
|
114
|
+
networkInfo = null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Check to see if the network is temporarily unavailable or if airplane mode is toggled on
|
|
119
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
120
|
+
isInternetSuspended = !capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED);
|
|
121
|
+
} else {
|
|
122
|
+
if (network != null && networkInfo != null) {
|
|
123
|
+
NetworkInfo.DetailedState detailedConnectionState = networkInfo.getDetailedState();
|
|
124
|
+
if (!detailedConnectionState.equals(NetworkInfo.DetailedState.CONNECTED)) {
|
|
125
|
+
isInternetSuspended = true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
isInternetReachable =
|
|
131
|
+
capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
|
132
|
+
&& capabilities.hasCapability(
|
|
133
|
+
NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
|
134
|
+
&& !isInternetSuspended;
|
|
135
|
+
|
|
136
|
+
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) {
|
|
137
|
+
isInternetReachable = isInternetReachable && capabilities.getLinkDownstreamBandwidthKbps() != 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Get the cellular network type
|
|
141
|
+
if (network != null && connectionType == ConnectionType.CELLULAR && isInternetReachable) {
|
|
142
|
+
cellularGeneration = CellularGeneration.fromNetworkInfo(networkInfo);
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
connectionType = ConnectionType.NONE;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
updateConnectivity(connectionType, cellularGeneration, isInternetReachable);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private void asyncUpdateAndSend(int delay) {
|
|
152
|
+
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
|
153
|
+
try {
|
|
154
|
+
mCapabilities = getConnectivityManager().getNetworkCapabilities(mNetwork);
|
|
155
|
+
updateAndSend();
|
|
156
|
+
} catch (SecurityException e) {
|
|
157
|
+
// Android 11 may throw a 'package does not belong' security exception here.
|
|
158
|
+
// Google fixed Android 14, 13 and 12 with the issue where Chaland Jean patched those versions.
|
|
159
|
+
// Android 11 is too old, so that's why we have to catch this exception here to be safe.
|
|
160
|
+
// https://android.googlesource.com/platform/frameworks/base/+/249be21013e389837f5b2beb7d36890b25ecfaaf%5E%21/
|
|
161
|
+
// We need to catch this to prevent app crash.
|
|
162
|
+
}
|
|
163
|
+
}, delay);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private class ConnectivityNetworkCallback extends ConnectivityManager.NetworkCallback {
|
|
167
|
+
@Override
|
|
168
|
+
public void onAvailable(Network network) {
|
|
169
|
+
mNetwork = network;
|
|
170
|
+
asyncUpdateAndSend(DELAY_MS);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@Override
|
|
174
|
+
public void onLosing(Network network, int maxMsToLive) {
|
|
175
|
+
mNetwork = network;
|
|
176
|
+
updateAndSend();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
@Override
|
|
180
|
+
public void onLost(Network network) {
|
|
181
|
+
mNetwork = null;
|
|
182
|
+
mCapabilities = null;
|
|
183
|
+
updateAndSend();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@Override
|
|
187
|
+
public void onUnavailable() {
|
|
188
|
+
mNetwork = null;
|
|
189
|
+
mCapabilities = null;
|
|
190
|
+
updateAndSend();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@Override
|
|
194
|
+
public void onCapabilitiesChanged(
|
|
195
|
+
Network network, NetworkCapabilities networkCapabilities) {
|
|
196
|
+
mNetwork = network;
|
|
197
|
+
mCapabilities = networkCapabilities;
|
|
198
|
+
updateAndSend();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@Override
|
|
202
|
+
public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
|
|
203
|
+
if (mNetwork != null) {
|
|
204
|
+
mNetwork = network;
|
|
205
|
+
}
|
|
206
|
+
asyncUpdateAndSend(DELAY_MS);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
4
|
+
|
|
5
|
+
import android.text.TextUtils;
|
|
6
|
+
|
|
7
|
+
public class Options {
|
|
8
|
+
int selectionLimit;
|
|
9
|
+
Boolean includeBase64;
|
|
10
|
+
Boolean includeExtra;
|
|
11
|
+
int videoQuality = 1;
|
|
12
|
+
int quality;
|
|
13
|
+
int maxWidth;
|
|
14
|
+
int maxHeight;
|
|
15
|
+
Boolean saveToPhotos;
|
|
16
|
+
int durationLimit;
|
|
17
|
+
Boolean useFrontCamera = false;
|
|
18
|
+
String mediaType;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Options(ReadableMap options) {
|
|
22
|
+
mediaType = options.getString("mediaType");
|
|
23
|
+
selectionLimit = options.getInt("selectionLimit");
|
|
24
|
+
includeBase64 = options.getBoolean("includeBase64");
|
|
25
|
+
includeExtra = options.getBoolean("includeExtra");
|
|
26
|
+
|
|
27
|
+
String videoQualityString = options.getString("videoQuality");
|
|
28
|
+
if (!TextUtils.isEmpty(videoQualityString) && !videoQualityString.toLowerCase().equals("high")) {
|
|
29
|
+
videoQuality = 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (options.getString("cameraType").equals("front")) {
|
|
33
|
+
useFrontCamera = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
quality = (int) (options.getDouble("quality") * 100);
|
|
37
|
+
maxHeight = options.getInt("maxHeight");
|
|
38
|
+
maxWidth = options.getInt("maxWidth");
|
|
39
|
+
saveToPhotos = options.getBoolean("saveToPhotos");
|
|
40
|
+
durationLimit = options.getInt("durationLimit");
|
|
41
|
+
}
|
|
42
|
+
}
|