shakebug-react-native 2.4.9 → 2.4.11

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.
Files changed (51) hide show
  1. package/README.md +0 -12
  2. package/VideoPlayer/PlayVideo.tsx +4 -46
  3. package/VideoPlayer/index.js +6 -43
  4. package/android/src/main/java/com/shakebug/BaseUtils.java +7 -19
  5. package/android/src/main/java/com/shakebug/DeviceUtil.java +34 -21
  6. package/android/src/main/java/com/shakebug/ShakebugPackage.java +3 -3
  7. package/android/src/main/java/com/shakebug/UnitConverter.java +8 -8
  8. package/android/src/main/java/com/shakebug/VideoPlayerModule.java +81 -0
  9. package/android/src/main/java/com/shakebug/VideoTrimModule.java +387 -0
  10. package/android/src/main/java/com/shakebug/VideoTrimUtil.java +133 -0
  11. package/android/src/main/java/com/shakebug/adapters/VideoTrimmerAdapter.java +53 -0
  12. package/android/src/main/java/com/shakebug/callback/SingleCallback.java +0 -6
  13. package/android/src/main/java/com/shakebug/thread/BackgroundExecutor.java +1 -93
  14. package/android/src/main/java/com/shakebug/thread/UiThreadExecutor.java +0 -37
  15. package/android/src/main/java/com/shakebug/utils/StorageUtil.java +135 -0
  16. package/android/src/main/java/com/shakebug/utils/VideoTrimmerUtil.java +70 -0
  17. package/android/src/main/java/com/shakebug/widgets/RangeSeekBarView.java +534 -0
  18. package/android/src/main/java/com/shakebug/widgets/SpacesItemDecoration2.java +1 -2
  19. package/android/src/main/java/com/shakebug/widgets/VideoPlayerView.java +317 -0
  20. package/android/src/main/java/com/shakebug/widgets/VideoTrimmerView.java +520 -0
  21. package/android/src/main/res/drawable/ic_volume_off.xml +10 -0
  22. package/android/src/main/res/drawable/ic_volume_on.xml +10 -0
  23. package/android/src/main/res/layout/{video_player_view.xml → shakebug_video_player_view.xml} +29 -9
  24. package/ios/TrimVideo/ShakebugSDKVideoTrim.swift +389 -0
  25. package/ios/TrimVideo/VideoTrim-Bridging-Header.h +10 -0
  26. package/ios/TrimVideo/VideoTrim.m +23 -0
  27. package/ios/TrimVideo/VideoTrimmer.swift +810 -0
  28. package/ios/TrimVideo/VideoTrimmerThumb.swift +119 -0
  29. package/ios/TrimVideo/VideoTrimmerViewController.swift +322 -0
  30. package/ios/VideoPlayer/VideoPlayerModule.m +23 -7
  31. package/package.json +1 -1
  32. package/src/APIs/AddIssue.js +7 -5
  33. package/src/APIs/AddReview.js +5 -2
  34. package/src/APIs/CustomUserId.js +5 -2
  35. package/src/APIs/EndSession.js +3 -2
  36. package/src/APIs/Event.js +5 -2
  37. package/src/APIs/FetchRemoteCodeAPI.js +5 -2
  38. package/src/APIs/MatchKey.js +3 -2
  39. package/src/APIs/StartSession.js +44 -23
  40. package/src/Componanats/LoadingModal.js +59 -0
  41. package/src/Componanats/ShakeFunction.js +32 -14
  42. package/src/Screens/AddDetailsScreen.js +28 -31
  43. package/src/Screens/FirstScreen.js +15 -18
  44. package/src/Screens/Shakebug.js +11 -6
  45. package/src/Screens/TrimVideoScreen.js +37 -22
  46. package/src/index.tsx +7 -6
  47. package/trimVideo/src/index.tsx +12 -48
  48. package/Volumes:.fileloc +0 -8
  49. package/shakebug-react-native-2.4.8.tgz +0 -0
  50. /package/android/src/main/res/layout/{video_thumb_item_layout.xml → shakebug_video_thumb_item_layout.xml} +0 -0
  51. /package/android/src/main/res/layout/{video_trimmer_view.xml → shakebug_video_trimmer_view.xml} +0 -0
package/README.md CHANGED
@@ -23,18 +23,6 @@ Or if you prefer to use Yarn instead of npm:
23
23
  yarn add shakebug-react-native
24
24
  ```
25
25
 
26
- Make sure to install Required Libraries also
27
-
28
- ```bash
29
- npm i react-native-video react-native-video-trim@3.0.9
30
- ```
31
- Or if you prefer to use Yarn instead of npm:
32
-
33
- ```bash
34
- yarn add react-native-video react-native-video-trim@3.0.9
35
- ```
36
-
37
-
38
26
  ### iOS
39
27
 
40
28
  1. You need to provide permissions inside `ios/YourProjectName/info.plist`:
@@ -1,51 +1,9 @@
1
- // videoUtils.js
2
-
3
- import { Platform } from 'react-native';
4
1
  import { NativeModules } from 'react-native';
5
- const { ShakebugSDKVideoPlayerModule } = NativeModules;
6
2
 
7
- export interface EditorConfig {
8
- saveToPhoto?: boolean;
9
- removeAfterSavedToPhoto?: boolean;
10
- maxDuration?: number;
11
- cancelButtonText?: string;
12
- saveButtonText?: string;
13
- enableCancelDialog?: boolean;
14
- cancelDialogTitle?: string;
15
- cancelDialogMessage?: string;
16
- cancelDialogCancelText?: string;
17
- cancelDialogConfirmText?: string;
18
- enableSaveDialog?: boolean;
19
- saveDialogTitle?: string;
20
- saveDialogMessage?: string;
21
- saveDialogCancelText?: string;
22
- saveDialogConfirmText?: string;
23
- trimmingText?: string;
24
- }
3
+ const VideoPlayerModule = NativeModules.ShakebugSDKVideoPlayerModule || NativeModules.ShakebugSDKVideoPlayer;
25
4
 
26
5
  export const PlayVideo = (videoUri: string) => {
27
-
28
- const config: EditorConfig = {
29
- saveToPhoto: false,
30
- removeAfterSavedToPhoto: false,
31
- maxDuration: 120,
32
- cancelButtonText: "Cancel",
33
- saveButtonText: "Save",
34
- enableCancelDialog: false,
35
- cancelDialogTitle: "Cancel Editing",
36
- cancelDialogMessage: "Are you sure you want to cancel editing?",
37
- cancelDialogCancelText: "No",
38
- cancelDialogConfirmText: "Yes",
39
- enableSaveDialog: false,
40
- saveDialogTitle: "Save Video",
41
- saveDialogMessage: "Do you want to save this video?",
42
- saveDialogCancelText: "No",
43
- saveDialogConfirmText: "Yes",
44
- trimmingText: "Trimming Video"
45
- };
46
- if(Platform.OS == 'android')
47
- ShakebugSDKVideoPlayerModule.showEditor(videoUri, config);
48
- else
49
- ShakebugSDKVideoPlayerModule.playVideo(videoUri);
6
+ if (VideoPlayerModule && VideoPlayerModule.playVideo) {
7
+ VideoPlayerModule.playVideo(videoUri);
8
+ }
50
9
  };
51
-
@@ -1,38 +1,13 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { NativeModules, Image, TouchableOpacity, ImageBackground, NativeEventEmitter, Platform, StatusBar } from 'react-native';
1
+ import React from 'react';
2
+ import { Image, TouchableOpacity, ImageBackground } from 'react-native';
3
3
  import { PlayVideo } from './PlayVideo';
4
- import Video from 'react-native-video';
5
4
 
6
5
  const VideoPlayer = ({ videoUri, img, goToScreenAtIndex, UpdateStatusBar }) => {
7
- // useEffect(() => {
8
- // if (Platform.OS == 'android') {
9
- // const eventEmitter = new NativeEventEmitter(NativeModules.VideoPlayerModule);
10
- // const subscription = eventEmitter.addListener('ShakebugSDKVideoPlayer', (event) => {
11
- // switch (event.name) {
12
- // case 'onCancelPlayer': {
13
- // UpdateStatusBar()
14
- // goToScreenAtIndex(3)
15
- // break;
16
- // }
17
- // default:
18
- // break;
19
- // }
20
- // });
21
-
22
- // return () => {
23
- // subscription.remove();
24
- // };
25
- // }
26
- // }, []);
27
-
28
- const [isPlayVideo, setIsPlayVideo] = useState(false);
29
-
30
- const playVideo = () => {
31
- setIsPlayVideo(true)
32
- }
6
+ const handlePlayVideo = () => {
7
+ PlayVideo(videoUri);
8
+ };
33
9
 
34
10
  return (
35
- !isPlayVideo ? (
36
11
  <ImageBackground
37
12
  source={{ uri: img }}
38
13
  style={{
@@ -51,9 +26,8 @@ const VideoPlayer = ({ videoUri, img, goToScreenAtIndex, UpdateStatusBar }) => {
51
26
  paddingVertical: 8,
52
27
  paddingHorizontal: 15,
53
28
  alignItems: 'center',
54
-
55
29
  }}
56
- onPress={playVideo}
30
+ onPress={handlePlayVideo}
57
31
  >
58
32
  <Image
59
33
  source={require('../src/Assets/images/play.png')}
@@ -66,17 +40,6 @@ const VideoPlayer = ({ videoUri, img, goToScreenAtIndex, UpdateStatusBar }) => {
66
40
  />
67
41
  </TouchableOpacity>
68
42
  </ImageBackground>
69
- )
70
- : (<Video
71
- source={{ uri: videoUri }}
72
- style={{
73
- width: "90%",
74
- marginLeft: '5%',
75
- height: "100%"
76
- }}
77
- controls={true}
78
- fullscreen={Platform.OS == 'ios' && true}
79
- />)
80
43
  );
81
44
  };
82
45
 
@@ -1,33 +1,21 @@
1
1
  package com.shakebug;
2
2
 
3
3
  import android.content.Context;
4
-
5
4
  import java.lang.ref.WeakReference;
6
5
 
7
- /**
8
- * Author:J.Chou
9
- * Date: 2016.07.21 11:45.
10
- * Email: who_know_me@163.com
11
- * Describe:
12
- */
13
6
  public class BaseUtils {
14
-
15
- private static final String ERROR_INIT = "Initialize BaseUtils with invoke init()";
16
-
17
7
  private static WeakReference<Context> mWeakReferenceContext;
18
8
 
19
- /**
20
- * init in Application
21
- */
22
- public static void init(Context ctx){
23
- mWeakReferenceContext = new WeakReference<>(ctx);
24
- //something to do...
9
+ public static void init(Context ctx) {
10
+ if (ctx != null) {
11
+ mWeakReferenceContext = new WeakReference<>(ctx.getApplicationContext());
12
+ }
25
13
  }
26
14
 
27
15
  public static Context getContext() {
28
- if (mWeakReferenceContext == null) {
29
- throw new IllegalArgumentException(ERROR_INIT);
16
+ if (mWeakReferenceContext != null && mWeakReferenceContext.get() != null) {
17
+ return mWeakReferenceContext.get();
30
18
  }
31
- return mWeakReferenceContext.get().getApplicationContext();
19
+ return null;
32
20
  }
33
21
  }
@@ -3,44 +3,57 @@ package com.shakebug;
3
3
  import android.app.ActivityManager;
4
4
  import android.content.Context;
5
5
  import android.content.pm.PackageManager;
6
-
6
+ import android.content.res.Resources;
7
7
  import java.util.List;
8
8
 
9
- /**
10
- * Author:J.Chou
11
- * Date: 2016.07.19 11:40.
12
- * Email: who_know_me@163.com
13
- * Describe:
14
- */
15
9
  public final class DeviceUtil {
16
10
 
17
11
  public static int getDeviceWidth() {
18
- return BaseUtils.getContext().getResources().getDisplayMetrics().widthPixels;
12
+ try {
13
+ if (BaseUtils.getContext() != null) {
14
+ return BaseUtils.getContext().getResources().getDisplayMetrics().widthPixels;
15
+ }
16
+ } catch (Exception ignored) {}
17
+ return Resources.getSystem().getDisplayMetrics().widthPixels;
19
18
  }
20
19
 
21
- public static int getDeviceHeight(){
22
- return BaseUtils.getContext().getResources().getDisplayMetrics().heightPixels;
20
+ public static int getDeviceHeight() {
21
+ try {
22
+ if (BaseUtils.getContext() != null) {
23
+ return BaseUtils.getContext().getResources().getDisplayMetrics().heightPixels;
24
+ }
25
+ } catch (Exception ignored) {}
26
+ return Resources.getSystem().getDisplayMetrics().heightPixels;
23
27
  }
24
28
 
25
29
  public static boolean hasAppInstalled(String pkgName) {
26
30
  try {
27
- BaseUtils.getContext().getPackageManager().getPackageInfo(pkgName, PackageManager.PERMISSION_GRANTED);
28
- return true;
29
- } catch (PackageManager.NameNotFoundException e) {
31
+ if (BaseUtils.getContext() != null) {
32
+ BaseUtils.getContext().getPackageManager().getPackageInfo(pkgName, PackageManager.PERMISSION_GRANTED);
33
+ return true;
34
+ }
35
+ } catch (Exception e) {
30
36
  return false;
31
37
  }
38
+ return false;
32
39
  }
33
40
 
34
41
  public static boolean isAppRunInBackground() {
35
- ActivityManager activityManager = (ActivityManager) BaseUtils.getContext().getSystemService(Context.ACTIVITY_SERVICE);
36
- List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
37
- for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
38
- if (appProcess.processName.equals(BaseUtils.getContext().getPackageName())) {
39
- // return true -> Run in background
40
- // return false - > Run in foreground
41
- return appProcess.importance != ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
42
+ try {
43
+ if (BaseUtils.getContext() != null) {
44
+ ActivityManager activityManager = (ActivityManager) BaseUtils.getContext().getSystemService(Context.ACTIVITY_SERVICE);
45
+ if (activityManager != null) {
46
+ List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
47
+ if (appProcesses != null) {
48
+ for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
49
+ if (appProcess.processName.equals(BaseUtils.getContext().getPackageName())) {
50
+ return appProcess.importance != ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
51
+ }
52
+ }
53
+ }
54
+ }
42
55
  }
43
- }
56
+ } catch (Exception ignored) {}
44
57
  return false;
45
58
  }
46
59
  }
@@ -20,7 +20,7 @@ import java.util.Map;
20
20
  public class ShakebugPackage implements ReactPackage {
21
21
 
22
22
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
23
-
23
+ BaseUtils.init(reactContext);
24
24
  return Arrays.<NativeModule>asList(
25
25
  new ShakebugSensors(reactContext, "ShakebugSDKRNSensorsGyroscope", Sensor.TYPE_GYROSCOPE),
26
26
  new ShakebugSensors(reactContext, "ShakebugSDKRNSensorsAccelerometer", Sensor.TYPE_ACCELEROMETER),
@@ -38,9 +38,9 @@ public class ShakebugPackage implements ReactPackage {
38
38
  new RNLocalizeModule(reactContext),
39
39
  new SharedPreferencesModule(reactContext),
40
40
  new ShakebugSDKRNViewShotModule(reactContext),
41
- // new VideoPlayerModule(reactContext),
41
+ new VideoPlayerModule(reactContext),
42
42
  new CreateThumbnailModule(reactContext),
43
- // new VideoTrimModule(reactContext),
43
+ new VideoTrimModule(reactContext),
44
44
  new ScreenshotDetectorModule(reactContext)
45
45
  );
46
46
  }
@@ -1,17 +1,17 @@
1
1
  package com.shakebug;
2
2
 
3
+ import android.content.res.Resources;
3
4
  import android.util.DisplayMetrics;
4
5
 
5
- /**
6
- * Created by choujason on 7/31/16.
7
- */
8
-
9
6
  public class UnitConverter {
10
7
 
11
-
12
- public static DisplayMetrics getDisplayMetrics(){
13
-
14
- return BaseUtils.getContext().getResources().getDisplayMetrics();
8
+ public static DisplayMetrics getDisplayMetrics() {
9
+ try {
10
+ if (BaseUtils.getContext() != null) {
11
+ return BaseUtils.getContext().getResources().getDisplayMetrics();
12
+ }
13
+ } catch (Exception ignored) {}
14
+ return Resources.getSystem().getDisplayMetrics();
15
15
  }
16
16
 
17
17
  public static float dpToPx(float dp) {
@@ -0,0 +1,81 @@
1
+ package com.shakebug;
2
+
3
+ import android.app.Activity;
4
+ import android.net.Uri;
5
+ import android.os.Handler;
6
+ import android.os.Looper;
7
+
8
+ import androidx.appcompat.app.AlertDialog;
9
+
10
+ import com.facebook.react.bridge.ReactApplicationContext;
11
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
+ import com.facebook.react.bridge.ReactMethod;
13
+ import com.shakebug.interfaces.VideoPlayerListner;
14
+ import com.shakebug.widgets.VideoPlayerView;
15
+
16
+ import java.io.File;
17
+
18
+ public class VideoPlayerModule extends ReactContextBaseJavaModule {
19
+ private final ReactApplicationContext reactContext;
20
+ private AlertDialog alertDialog;
21
+ private VideoPlayerView videoPlayerView;
22
+
23
+ public VideoPlayerModule(ReactApplicationContext reactContext) {
24
+ super(reactContext);
25
+ this.reactContext = reactContext;
26
+ }
27
+
28
+ @Override
29
+ public String getName() {
30
+ return "ShakebugSDKVideoPlayerModule";
31
+ }
32
+
33
+ @ReactMethod
34
+ public void playVideo(final String videoUri) {
35
+ final Activity currentActivity = getCurrentActivity();
36
+ if (currentActivity == null || currentActivity.isFinishing() || videoUri == null || videoUri.isEmpty()) {
37
+ return;
38
+ }
39
+
40
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
41
+ @Override
42
+ public void run() {
43
+ try {
44
+ Activity act = getCurrentActivity();
45
+ if (act == null || act.isFinishing()) return;
46
+
47
+ videoPlayerView = new VideoPlayerView(act);
48
+ videoPlayerView.setOnTrimVideoListener(new VideoPlayerListner() {
49
+ @Override
50
+ public void onCancel() {
51
+ try {
52
+ if (alertDialog != null && alertDialog.isShowing()) {
53
+ alertDialog.dismiss();
54
+ }
55
+ } catch (Exception ignored) {}
56
+ }
57
+ });
58
+
59
+ String cleanPath = videoUri.replace("file://", "");
60
+ Uri uri = cleanPath.startsWith("/") ? Uri.fromFile(new File(cleanPath)) : Uri.parse(videoUri);
61
+ videoPlayerView.initVideoByURI(uri);
62
+
63
+ AlertDialog.Builder builder = new AlertDialog.Builder(act, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
64
+ builder.setCancelable(true);
65
+ alertDialog = builder.create();
66
+ alertDialog.setView(videoPlayerView);
67
+ alertDialog.show();
68
+
69
+ alertDialog.setOnDismissListener(dialog -> {
70
+ if (videoPlayerView != null) {
71
+ videoPlayerView.onDestroy();
72
+ videoPlayerView = null;
73
+ }
74
+ });
75
+ } catch (Exception e) {
76
+ e.printStackTrace();
77
+ }
78
+ }
79
+ });
80
+ }
81
+ }