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,199 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
|
|
4
|
+
|
|
5
|
+
import android.app.Activity;
|
|
6
|
+
import android.media.MediaMetadataRetriever;
|
|
7
|
+
import android.net.Uri;
|
|
8
|
+
import android.widget.ProgressBar;
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.NonNull;
|
|
11
|
+
import androidx.annotation.Nullable;
|
|
12
|
+
import androidx.appcompat.app.AlertDialog;
|
|
13
|
+
|
|
14
|
+
import com.facebook.react.bridge.Arguments;
|
|
15
|
+
import com.facebook.react.bridge.LifecycleEventListener;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContext;
|
|
19
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
20
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
21
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
22
|
+
import com.facebook.react.bridge.WritableMap;
|
|
23
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
24
|
+
import com.shakebug.interfaces.VideoPlayerListner;
|
|
25
|
+
import com.shakebug.widgets.VideoPlayerView;
|
|
26
|
+
|
|
27
|
+
public class VideoPlayerModule extends ReactContextBaseJavaModule implements VideoPlayerListner, LifecycleEventListener {
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
private static final String MODULE_NAME = "ShakebugSDKVideoPlayerModule";
|
|
31
|
+
private static Boolean isInit = false;
|
|
32
|
+
private VideoPlayerView trimmerView;
|
|
33
|
+
private AlertDialog alertDialog;
|
|
34
|
+
private AlertDialog mProgressDialog;
|
|
35
|
+
private ProgressBar mProgressBar;
|
|
36
|
+
private int listenerCount = 0;
|
|
37
|
+
|
|
38
|
+
private Promise showEditorPromise;
|
|
39
|
+
|
|
40
|
+
private boolean enableCancelDialog = true;
|
|
41
|
+
private String cancelDialogTitle = "Warning!";
|
|
42
|
+
private String cancelDialogMessage = "Are you sure want to cancel?";
|
|
43
|
+
private String cancelDialogCancelText = "Close";
|
|
44
|
+
private String cancelDialogConfirmText = "Proceed";
|
|
45
|
+
// Activity activity = getReactApplicationContext().getCurrentActivity();
|
|
46
|
+
|
|
47
|
+
public VideoPlayerModule(ReactApplicationContext reactContext) {
|
|
48
|
+
super(reactContext);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
@NonNull
|
|
53
|
+
public String getName() {
|
|
54
|
+
return MODULE_NAME;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// From Trimmer
|
|
62
|
+
|
|
63
|
+
@ReactMethod
|
|
64
|
+
public void showEditor(String videoPath, ReadableMap config) {
|
|
65
|
+
// if (trimmerView != null || alertDialog != null) {
|
|
66
|
+
// return;
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if (!isValidVideo(videoPath)) {
|
|
71
|
+
WritableMap map = Arguments.createMap();
|
|
72
|
+
map.putString("message", "File is not a valid video");
|
|
73
|
+
sendEvent(getReactApplicationContext(), "onError", map);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
enableCancelDialog = config.hasKey("enableCancelDialog") ? config.getBoolean("enableCancelDialog") : true;
|
|
78
|
+
cancelDialogTitle = config.hasKey("cancelDialogTitle") ? config.getString("cancelDialogTitle") : "Warning!";
|
|
79
|
+
cancelDialogMessage = config.hasKey("cancelDialogMessage") ? config.getString("cancelDialogMessage") : "Are you sure want to cancel?";
|
|
80
|
+
cancelDialogCancelText = config.hasKey("cancelDialogCancelText") ? config.getString("cancelDialogCancelText") : "Close";
|
|
81
|
+
cancelDialogConfirmText = config.hasKey("cancelDialogConfirmText") ? config.getString("cancelDialogConfirmText") : "Proceed";
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
Activity activity = getReactApplicationContext().getCurrentActivity();
|
|
85
|
+
|
|
86
|
+
if (!isInit) {
|
|
87
|
+
init(activity);
|
|
88
|
+
isInit = true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// here is NOT main thread, we need to create VideoTrimmerView on UI thread, so that later we can update it using same thread
|
|
92
|
+
|
|
93
|
+
runOnUiThread(() -> {
|
|
94
|
+
trimmerView = new VideoPlayerView(getReactApplicationContext(), config, null);
|
|
95
|
+
trimmerView.setOnTrimVideoListener(this);
|
|
96
|
+
trimmerView.initVideoByURI(Uri.parse(videoPath));
|
|
97
|
+
|
|
98
|
+
AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
|
99
|
+
builder.setCancelable(false);
|
|
100
|
+
alertDialog = builder.create();
|
|
101
|
+
alertDialog.setView(trimmerView);
|
|
102
|
+
alertDialog.show();
|
|
103
|
+
|
|
104
|
+
// this is to ensure to release resource if dialog is dismissed in unexpected way (Eg. open control/notification center by dragging from top of screen)
|
|
105
|
+
alertDialog.setOnDismissListener(dialog -> {
|
|
106
|
+
// This is called in same thread as the trimmer view -> UI thread
|
|
107
|
+
if (trimmerView != null) {
|
|
108
|
+
trimmerView.onDestroy();
|
|
109
|
+
trimmerView = null;
|
|
110
|
+
}
|
|
111
|
+
sendEvent(getReactApplicationContext(), "onHide", null);
|
|
112
|
+
});
|
|
113
|
+
sendEvent(getReactApplicationContext(), "onShow", null);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private void init(Activity activity) {
|
|
118
|
+
isInit = true;
|
|
119
|
+
// we have to init this before create videoTrimmerView
|
|
120
|
+
BaseUtils.init(getReactApplicationContext());
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@Override
|
|
124
|
+
public void onHostResume() {
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@Override
|
|
129
|
+
public void onHostPause() {
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@Override
|
|
134
|
+
public void onHostDestroy() {
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@Override public void onCancel() {
|
|
140
|
+
if (!enableCancelDialog) {
|
|
141
|
+
alertDialog.dismiss(); // Dismiss the alertDialog when the close button is clicked
|
|
142
|
+
trimmerView.onDestroy(); // Clean up the trimmerView
|
|
143
|
+
trimmerView = null;
|
|
144
|
+
sendEvent(getReactApplicationContext(), "onCancelPlayer", null);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
AlertDialog.Builder builder = new AlertDialog.Builder(getReactApplicationContext().getCurrentActivity());
|
|
149
|
+
builder.setMessage(cancelDialogMessage);
|
|
150
|
+
builder.setTitle(cancelDialogTitle);
|
|
151
|
+
builder.setCancelable(false);
|
|
152
|
+
builder.setPositiveButton(cancelDialogConfirmText, (dialog, which) -> {
|
|
153
|
+
dialog.cancel();
|
|
154
|
+
sendEvent(getReactApplicationContext(), "onCancelPlayer", null);
|
|
155
|
+
});
|
|
156
|
+
builder.setNegativeButton(cancelDialogCancelText, (dialog, which) -> {
|
|
157
|
+
dialog.cancel();
|
|
158
|
+
});
|
|
159
|
+
AlertDialog alertDialog = builder.create();
|
|
160
|
+
alertDialog.show();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@ReactMethod
|
|
164
|
+
public void addListener(String eventName) {
|
|
165
|
+
// This method is required by React
|
|
166
|
+
listenerCount += 1;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@ReactMethod
|
|
170
|
+
public void removeListeners(Integer count) {
|
|
171
|
+
// This method is required by React
|
|
172
|
+
listenerCount -= count;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
|
|
176
|
+
if (listenerCount > 0) {
|
|
177
|
+
WritableMap map = params != null ? params : Arguments.createMap();
|
|
178
|
+
map.putString("name", eventName);
|
|
179
|
+
reactContext
|
|
180
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
181
|
+
.emit("ShakebugSDKVideoPlayer", map);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
public boolean isValidVideo(String filePath) {
|
|
187
|
+
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
|
188
|
+
|
|
189
|
+
try {
|
|
190
|
+
retriever.setDataSource(getReactApplicationContext(), Uri.parse(filePath));
|
|
191
|
+
} catch (Exception e){
|
|
192
|
+
e.printStackTrace();
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
String hasVideo = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_VIDEO);
|
|
197
|
+
return "yes".equals(hasVideo);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Bitmap;
|
|
5
|
+
import android.graphics.BitmapFactory;
|
|
6
|
+
import android.media.MediaMetadataRetriever;
|
|
7
|
+
import android.net.Uri;
|
|
8
|
+
import android.os.Build.VERSION;
|
|
9
|
+
import android.text.TextUtils;
|
|
10
|
+
import android.webkit.URLUtil;
|
|
11
|
+
|
|
12
|
+
import com.facebook.react.bridge.Arguments;
|
|
13
|
+
import com.facebook.react.bridge.GuardedResultAsyncTask;
|
|
14
|
+
import com.facebook.react.bridge.Promise;
|
|
15
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
16
|
+
import com.facebook.react.bridge.ReactContext;
|
|
17
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
18
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
19
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
20
|
+
import com.facebook.react.bridge.WritableMap;
|
|
21
|
+
|
|
22
|
+
import org.apache.commons.io.comparator.LastModifiedFileComparator;
|
|
23
|
+
|
|
24
|
+
import java.io.File;
|
|
25
|
+
import java.io.FileOutputStream;
|
|
26
|
+
import java.io.IOException;
|
|
27
|
+
import java.io.OutputStream;
|
|
28
|
+
import java.io.UnsupportedEncodingException;
|
|
29
|
+
import java.net.URLDecoder;
|
|
30
|
+
import java.lang.ref.WeakReference;
|
|
31
|
+
import java.util.Arrays;
|
|
32
|
+
import java.util.HashMap;
|
|
33
|
+
import java.util.Map;
|
|
34
|
+
import java.util.UUID;
|
|
35
|
+
|
|
36
|
+
public class VideoThumbnailModule extends ReactContextBaseJavaModule {
|
|
37
|
+
|
|
38
|
+
private final ReactApplicationContext reactContext;
|
|
39
|
+
|
|
40
|
+
public VideoThumbnailModule(ReactApplicationContext reactContext) {
|
|
41
|
+
super(reactContext);
|
|
42
|
+
this.reactContext = reactContext;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Override
|
|
46
|
+
public String getName() {
|
|
47
|
+
return "ShakebugSDKCreateThumbnail";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@ReactMethod
|
|
51
|
+
public void create(ReadableMap options, Promise promise) {
|
|
52
|
+
new ProcessDataTask(reactContext, promise, options).execute();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private static class ProcessDataTask extends GuardedResultAsyncTask<ReadableMap> {
|
|
56
|
+
private final WeakReference<Context> weakContext;
|
|
57
|
+
private final Promise promise;
|
|
58
|
+
private final ReadableMap options;
|
|
59
|
+
|
|
60
|
+
protected ProcessDataTask(ReactContext reactContext, Promise promise, ReadableMap options) {
|
|
61
|
+
super(reactContext.getExceptionHandler());
|
|
62
|
+
this.weakContext = new WeakReference<>(reactContext.getApplicationContext());
|
|
63
|
+
this.promise = promise;
|
|
64
|
+
this.options = options;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Override
|
|
68
|
+
protected ReadableMap doInBackgroundGuarded() {
|
|
69
|
+
String format = options.hasKey("format") ? options.getString("format") : "jpeg";
|
|
70
|
+
String cacheName = options.hasKey("cacheName") ? options.getString("cacheName") : "";
|
|
71
|
+
|
|
72
|
+
String thumbnailDir = weakContext.get().getApplicationContext().getCacheDir().getAbsolutePath() + "/thumbnails";
|
|
73
|
+
File cacheDir = createDirIfNotExists(thumbnailDir);
|
|
74
|
+
if (!TextUtils.isEmpty(cacheName)) {
|
|
75
|
+
File file = new File(thumbnailDir, cacheName + "." + format);
|
|
76
|
+
if (file.exists()) {
|
|
77
|
+
WritableMap map = Arguments.createMap();
|
|
78
|
+
map.putString("path", "file://" + file.getAbsolutePath());
|
|
79
|
+
Bitmap image = BitmapFactory.decodeFile(file.getAbsolutePath());
|
|
80
|
+
map.putDouble("size", image.getByteCount());
|
|
81
|
+
map.putString("mime", "image/" + format);
|
|
82
|
+
map.putDouble("width", image.getWidth());
|
|
83
|
+
map.putDouble("height", image.getHeight());
|
|
84
|
+
return map;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
String filePath = options.hasKey("url") ? options.getString("url") : "";
|
|
89
|
+
int dirSize = options.hasKey("dirSize") ? options.getInt("dirSize") : 100;
|
|
90
|
+
int timeStamp = options.hasKey("timeStamp") ? options.getInt("timeStamp") : 0;
|
|
91
|
+
HashMap headers = options.hasKey("headers") ? options.getMap("headers").toHashMap() : new HashMap<String, String>();
|
|
92
|
+
String fileName = TextUtils.isEmpty(cacheName) ? ("thumb-" + UUID.randomUUID().toString()) : cacheName + "." + format;
|
|
93
|
+
OutputStream fOut = null;
|
|
94
|
+
try {
|
|
95
|
+
File file = new File(cacheDir, fileName);
|
|
96
|
+
Context context = weakContext.get();
|
|
97
|
+
Bitmap image = getBitmapAtTime(context, filePath, timeStamp, headers);
|
|
98
|
+
file.createNewFile();
|
|
99
|
+
fOut = new FileOutputStream(file);
|
|
100
|
+
|
|
101
|
+
// 100 means no compression, the lower you go, the stronger the compression
|
|
102
|
+
if (format.equals("png")) {
|
|
103
|
+
image.compress(Bitmap.CompressFormat.PNG, 100, fOut);
|
|
104
|
+
} else {
|
|
105
|
+
image.compress(Bitmap.CompressFormat.JPEG, 90, fOut);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fOut.flush();
|
|
109
|
+
fOut.close();
|
|
110
|
+
|
|
111
|
+
long cacheDirSize = (long) dirSize * 1024 * 1024;
|
|
112
|
+
long newSize = image.getByteCount() + getDirSize(cacheDir);
|
|
113
|
+
// free up some cached data if size of cache dir exceeds CACHE_DIR_MAX_SIZE
|
|
114
|
+
if (newSize > cacheDirSize) {
|
|
115
|
+
cleanDir(cacheDir, cacheDirSize / 2);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
WritableMap map = Arguments.createMap();
|
|
119
|
+
map.putString("path", "file://" + file.getAbsolutePath());
|
|
120
|
+
map.putDouble("size", image.getByteCount());
|
|
121
|
+
map.putString("mime", "image/" + format);
|
|
122
|
+
map.putDouble("width", image.getWidth());
|
|
123
|
+
map.putDouble("height", image.getHeight());
|
|
124
|
+
return map;
|
|
125
|
+
} catch (Exception e) {
|
|
126
|
+
promise.reject("CreateThumbnail_ERROR", e);
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@Override
|
|
132
|
+
protected void onPostExecuteGuarded(ReadableMap readableArray) {
|
|
133
|
+
promise.resolve(readableArray);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// delete previously added files one by one untill requred space is available
|
|
138
|
+
private static void cleanDir(File dir, long bytes) {
|
|
139
|
+
long bytesDeleted = 0;
|
|
140
|
+
File[] files = dir.listFiles();
|
|
141
|
+
Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);
|
|
142
|
+
|
|
143
|
+
for (File file : files) {
|
|
144
|
+
bytesDeleted += file.length();
|
|
145
|
+
file.delete();
|
|
146
|
+
|
|
147
|
+
if (bytesDeleted >= bytes) {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private static File createDirIfNotExists(String path) {
|
|
154
|
+
File dir = new File(path);
|
|
155
|
+
if (dir.exists()) {
|
|
156
|
+
return dir;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
dir.mkdirs();
|
|
161
|
+
// Add .nomedia to hide the thumbnail directory from gallery
|
|
162
|
+
File noMedia = new File(path, ".nomedia");
|
|
163
|
+
noMedia.createNewFile();
|
|
164
|
+
} catch (IOException e) {
|
|
165
|
+
e.printStackTrace();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return dir;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private static Bitmap getBitmapAtTime(Context context, String filePath, int time, Map headers) {
|
|
172
|
+
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
|
173
|
+
if (URLUtil.isFileUrl(filePath)) {
|
|
174
|
+
String decodedPath;
|
|
175
|
+
try {
|
|
176
|
+
decodedPath = URLDecoder.decode(filePath, "UTF-8");
|
|
177
|
+
} catch (UnsupportedEncodingException e) {
|
|
178
|
+
decodedPath = filePath;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
retriever.setDataSource(decodedPath.replace("file://", ""));
|
|
182
|
+
} else if (filePath.contains("content://")) {
|
|
183
|
+
retriever.setDataSource(context, Uri.parse(filePath));
|
|
184
|
+
} else {
|
|
185
|
+
if (VERSION.SDK_INT < 14) {
|
|
186
|
+
throw new IllegalStateException("Remote videos aren't supported on sdk_version < 14");
|
|
187
|
+
}
|
|
188
|
+
retriever.setDataSource(filePath, headers);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
Bitmap image = retriever.getFrameAtTime(time * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
|
|
192
|
+
try {
|
|
193
|
+
retriever.release();
|
|
194
|
+
} catch(IOException e) {
|
|
195
|
+
e.printStackTrace();
|
|
196
|
+
}
|
|
197
|
+
if (image == null) {
|
|
198
|
+
throw new IllegalStateException("File doesn't exist or not supported");
|
|
199
|
+
}
|
|
200
|
+
return image;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private static long getDirSize(File dir) {
|
|
204
|
+
long size = 0;
|
|
205
|
+
File[] files = dir.listFiles();
|
|
206
|
+
|
|
207
|
+
for (File file : files) {
|
|
208
|
+
if (file.isFile()) {
|
|
209
|
+
size += file.length();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return size;
|
|
214
|
+
}
|
|
215
|
+
}
|