@cometchat/chat-uikit-react-native 4.2.2 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -67
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +2 -1
- package/android/src/main/java/com/reactnativecometchatuikit/ReactVideoView.java +796 -0
- package/android/src/main/java/com/reactnativecometchatuikit/ReactVideoViewManager.java +172 -0
- package/android/src/main/java/com/scalablevideoview/BuildConfig.java +10 -0
- package/android/src/main/java/com/scalablevideoview/PivotPoint.java +13 -0
- package/android/src/main/java/com/scalablevideoview/ScalableType.java +34 -0
- package/android/src/main/java/com/scalablevideoview/ScalableVideoView.java +255 -0
- package/android/src/main/java/com/scalablevideoview/ScaleManager.java +188 -0
- package/android/src/main/java/com/scalablevideoview/Size.java +20 -0
- package/android/src/main/java/com/zipfile/APEZProvider.java +287 -0
- package/android/src/main/java/com/zipfile/APKExpansionSupport.java +81 -0
- package/android/src/main/java/com/zipfile/ZipResourceFile.java +428 -0
- package/android/src/main/res/values/attrs.xml +37 -0
- package/ios/FileManager.m +75 -5
- package/ios/Video/CCRCTVideo.h +67 -0
- package/ios/Video/CCRCTVideo.m +2031 -0
- package/ios/Video/CCRCTVideoManager.h +6 -0
- package/ios/Video/CCRCTVideoManager.m +133 -0
- package/ios/Video/CCRCTVideoPlayerViewController.h +20 -0
- package/ios/Video/CCRCTVideoPlayerViewController.m +43 -0
- package/ios/Video/CCRCTVideoPlayerViewControllerDelegate.h +7 -0
- package/ios/Video/UIView+FindUIViewController.h +15 -0
- package/ios/Video/UIView+FindUIViewController.m +21 -0
- package/ios/VideoCaching/RCTVideoCache.h +38 -0
- package/ios/VideoCaching/RCTVideoCache.m +174 -0
- package/ios/VideoPickerModule.h +7 -0
- package/ios/VideoPickerModule.mm +95 -0
- package/package.json +3 -4
- package/react-native-cometchat-ui-kit.podspec +24 -10
- package/src/CometChatContacts/CometChatContacts.tsx +12 -9
- package/src/CometChatConversations/CometChatConversations.tsx +84 -64
- package/src/CometChatDetails/CometChatDetails.tsx +14 -12
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +8 -4
- package/src/CometChatGroupMembers/resources/check.png +0 -0
- package/src/CometChatGroupMembers/resources/index.ts +2 -0
- package/src/CometChatGroups/CometChatGroups.tsx +4 -4
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +57 -15
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +9 -2
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +596 -181
- package/src/CometChatMessageList/MessageListConfiguration.ts +55 -4
- package/src/CometChatMessageList/resources/index.ts +5 -1
- package/src/CometChatMessageList/resources/leftarrowcurve.png +0 -0
- package/src/CometChatMessageList/resources/rightarrowcurve.png +0 -0
- package/src/CometChatMessages/CometChatMessages.tsx +1 -1
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +4 -12
- package/src/CometChatThreadedMessages/style.ts +3 -1
- package/src/CometChatUsers/CometChatUsers.tsx +1 -1
- package/src/calls/CallUtils.ts +4 -8
- package/src/calls/CallingExtentionDecorator.tsx +5 -2
- package/src/calls/CometChatCallBubble/styles.ts +2 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +14 -3
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +9 -9
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +80 -73
- package/src/extensions/CollaborativeBubble/styles.ts +2 -0
- package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +11 -0
- package/src/extensions/index.ts +0 -4
- package/src/index.ts +53 -8
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +14 -2
- package/src/shared/constants/UIKitConstants.ts +1 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +6 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +8 -0
- package/src/shared/events/ListenerInitializer.ts +6 -0
- package/src/shared/events/messages.ts +2 -0
- package/src/shared/framework/MessageDataSource.tsx +29 -25
- package/src/shared/index.ts +49 -1
- package/src/shared/libs/VideoPlayer/DRMType.js +6 -0
- package/src/shared/libs/VideoPlayer/FilterType.js +18 -0
- package/src/shared/libs/VideoPlayer/TextTrackType.js +5 -0
- package/src/shared/libs/VideoPlayer/Video.js +519 -0
- package/src/shared/libs/VideoPlayer/VideoResizeMode.js +5 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/PlatformSupport.tsx +43 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/TVOSSupport.tsx +16 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/index.tsx +1 -0
- package/src/shared/libs/VideoPlayerControls/VideoPlayer.tsx +511 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +28 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/BottomControls.tsx +142 -0
- package/src/shared/libs/VideoPlayerControls/components/Control.tsx +45 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/Error.tsx +22 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/styles.ts +21 -0
- package/src/shared/libs/VideoPlayerControls/components/Fullscreen.tsx +36 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/Loader.tsx +15 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/styles.ts +16 -0
- package/src/shared/libs/VideoPlayerControls/components/NullControl.tsx +7 -0
- package/src/shared/libs/VideoPlayerControls/components/Overlay.tsx +23 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx +109 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/styles.ts +21 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/Seekbar.tsx +47 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/styles.ts +37 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/Timer.tsx +28 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/styles.ts +12 -0
- package/src/shared/libs/VideoPlayerControls/components/Title.tsx +35 -0
- package/src/shared/libs/VideoPlayerControls/components/TopControls.tsx +110 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/Volume.tsx +37 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/styles.ts +31 -0
- package/src/shared/libs/VideoPlayerControls/components/index.ts +14 -0
- package/src/shared/libs/VideoPlayerControls/components/styles.ts +30 -0
- package/src/shared/libs/VideoPlayerControls/hooks/index.ts +3 -0
- package/src/shared/libs/VideoPlayerControls/hooks/useAnimations.ts +68 -0
- package/src/shared/libs/VideoPlayerControls/hooks/useControlTimeout.tsx +67 -0
- package/src/shared/libs/VideoPlayerControls/hooks/usePanResponders.tsx +96 -0
- package/src/shared/libs/VideoPlayerControls/index.ts +4 -0
- package/src/shared/libs/VideoPlayerControls/styles.ts +19 -0
- package/src/shared/libs/VideoPlayerControls/types.ts +290 -0
- package/src/shared/libs/VideoPlayerControls/utils.ts +76 -0
- package/src/shared/modals/CometChatMessageTemplate.ts +113 -9
- package/src/shared/modals/InteractiveData/InteractiveMessage/SchedulerMessage.ts +23 -21
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +6 -3
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -1
- package/src/shared/resources/CometChatTheme/Palette.ts +79 -45
- package/src/shared/resources/CometChatTheme/Typography.ts +18 -0
- package/src/shared/utils/CommonUtils.ts +71 -0
- package/src/shared/utils/PermissionUtilIOS.ts +104 -0
- package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +3 -1
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +6 -6
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +28 -5
- package/src/shared/views/CometChatAudioBubble/style.ts +4 -2
- package/src/shared/views/CometChatAvatar/AvatarStyle.ts +1 -1
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +4 -3
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +47 -31
- package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardConfiguration.ts +5 -5
- package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardStyle.ts +12 -13
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +52 -5
- package/src/shared/views/CometChatFileBubble/style.ts +4 -2
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +25 -2
- package/src/shared/views/CometChatList/CometChatList.tsx +2 -1
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +51 -2
- package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +76 -0
- package/src/shared/views/CometChatQuickReactions/QuickReactionsConfiguration.tsx +12 -0
- package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +35 -0
- package/src/shared/views/CometChatQuickReactions/index.ts +12 -0
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +166 -0
- package/src/shared/views/CometChatReactions/ReactionsConfiguration.tsx +12 -0
- package/src/shared/views/CometChatReactions/ReactionsStyle.tsx +43 -0
- package/src/shared/views/CometChatReactions/index.ts +12 -0
- package/src/{extensions/Reactions/CometChatMessageReactions → shared/views/CometChatReactions}/style.ts +7 -7
- package/src/shared/views/CometChatReactionsList/CometChatReactionsList.tsx +335 -0
- package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +14 -0
- package/src/shared/views/CometChatReactionsList/ReactionsListStyle.tsx +67 -0
- package/src/shared/views/CometChatReactionsList/index.ts +12 -0
- package/src/shared/views/CometChatReactionsList/resources/Spineer.png +0 -0
- package/src/shared/views/CometChatReactionsList/resources/index.ts +5 -0
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +21 -4
- package/src/shared/views/CometChatReceipt/MessageConfiguration.ts +12 -0
- package/src/shared/views/CometChatReceipt/resources/error.png +0 -0
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +1 -1
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +78 -12
- package/src/shared/views/CometChatVideoBubble/VideoBubbleStyle.ts +52 -2
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +134 -0
- package/src/shared/views/CometChatVideoPlayer/index.tsx +1 -0
- package/src/shared/views/index.ts +30 -0
- package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4.2/gc.properties +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.idea/gradle.xml +0 -13
- package/android/.idea/misc.xml +0 -8
- package/android/.idea/modules/android.iml +0 -18
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/src/extensions/Reactions/CometChatMessageReactions/CometChatMessageReactions.tsx +0 -249
- package/src/extensions/Reactions/CometChatMessageReactions/index.ts +0 -3
- package/src/extensions/Reactions/ReactionsDecorator.tsx +0 -164
- package/src/extensions/Reactions/ReactionsExtension.tsx +0 -48
- package/src/extensions/Reactions/index.ts +0 -4
- /package/src/{extensions/Reactions → shared/views/CometChatQuickReactions}/resources/AddReactions.png +0 -0
- /package/src/{extensions/Reactions → shared/views/CometChatQuickReactions}/resources/index.ts +0 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
|
|
2
|
+
package com.zipfile;
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2012 The Android Open Source Project
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import android.content.res.AssetFileDescriptor;
|
|
20
|
+
import android.os.ParcelFileDescriptor;
|
|
21
|
+
import android.util.Log;
|
|
22
|
+
|
|
23
|
+
import java.io.EOFException;
|
|
24
|
+
import java.io.File;
|
|
25
|
+
import java.io.FileNotFoundException;
|
|
26
|
+
import java.io.IOException;
|
|
27
|
+
import java.io.InputStream;
|
|
28
|
+
import java.io.RandomAccessFile;
|
|
29
|
+
import java.nio.ByteBuffer;
|
|
30
|
+
import java.nio.ByteOrder;
|
|
31
|
+
import java.nio.MappedByteBuffer;
|
|
32
|
+
import java.nio.channels.FileChannel;
|
|
33
|
+
import java.util.Collection;
|
|
34
|
+
import java.util.HashMap;
|
|
35
|
+
import java.util.Vector;
|
|
36
|
+
import java.util.zip.ZipEntry;
|
|
37
|
+
import java.util.zip.ZipFile;
|
|
38
|
+
|
|
39
|
+
public class ZipResourceFile {
|
|
40
|
+
|
|
41
|
+
//
|
|
42
|
+
// Read-only access to Zip archives, with minimal heap allocation.
|
|
43
|
+
//
|
|
44
|
+
static final String LOG_TAG = "zipro";
|
|
45
|
+
static final boolean LOGV = false;
|
|
46
|
+
|
|
47
|
+
// 4-byte number
|
|
48
|
+
static private int swapEndian(int i)
|
|
49
|
+
{
|
|
50
|
+
return ((i & 0xff) << 24) + ((i & 0xff00) << 8) + ((i & 0xff0000) >>> 8)
|
|
51
|
+
+ ((i >>> 24) & 0xff);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 2-byte number
|
|
55
|
+
static private int swapEndian(short i)
|
|
56
|
+
{
|
|
57
|
+
return ((i & 0x00FF) << 8 | (i & 0xFF00) >>> 8);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
* Zip file constants.
|
|
62
|
+
*/
|
|
63
|
+
static final int kEOCDSignature = 0x06054b50;
|
|
64
|
+
static final int kEOCDLen = 22;
|
|
65
|
+
static final int kEOCDNumEntries = 8; // offset to #of entries in file
|
|
66
|
+
static final int kEOCDSize = 12; // size of the central directory
|
|
67
|
+
static final int kEOCDFileOffset = 16; // offset to central directory
|
|
68
|
+
|
|
69
|
+
static final int kMaxCommentLen = 65535; // longest possible in ushort
|
|
70
|
+
static final int kMaxEOCDSearch = (kMaxCommentLen + kEOCDLen);
|
|
71
|
+
|
|
72
|
+
static final int kLFHSignature = 0x04034b50;
|
|
73
|
+
static final int kLFHLen = 30; // excluding variable-len fields
|
|
74
|
+
static final int kLFHNameLen = 26; // offset to filename length
|
|
75
|
+
static final int kLFHExtraLen = 28; // offset to extra length
|
|
76
|
+
|
|
77
|
+
static final int kCDESignature = 0x02014b50;
|
|
78
|
+
static final int kCDELen = 46; // excluding variable-len fields
|
|
79
|
+
static final int kCDEMethod = 10; // offset to compression method
|
|
80
|
+
static final int kCDEModWhen = 12; // offset to modification timestamp
|
|
81
|
+
static final int kCDECRC = 16; // offset to entry CRC
|
|
82
|
+
static final int kCDECompLen = 20; // offset to compressed length
|
|
83
|
+
static final int kCDEUncompLen = 24; // offset to uncompressed length
|
|
84
|
+
static final int kCDENameLen = 28; // offset to filename length
|
|
85
|
+
static final int kCDEExtraLen = 30; // offset to extra length
|
|
86
|
+
static final int kCDECommentLen = 32; // offset to comment length
|
|
87
|
+
static final int kCDELocalOffset = 42; // offset to local hdr
|
|
88
|
+
|
|
89
|
+
static final int kCompressStored = 0; // no compression
|
|
90
|
+
static final int kCompressDeflated = 8; // standard deflate
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
* The values we return for ZipEntryRO use 0 as an invalid value, so we want
|
|
94
|
+
* to adjust the hash table index by a fixed amount. Using a large value
|
|
95
|
+
* helps insure that people don't mix & match arguments, e.g. to
|
|
96
|
+
* findEntryByIndex().
|
|
97
|
+
*/
|
|
98
|
+
static final int kZipEntryAdj = 10000;
|
|
99
|
+
|
|
100
|
+
static public final class ZipEntryRO {
|
|
101
|
+
public ZipEntryRO(final String zipFileName, final File file, final String fileName) {
|
|
102
|
+
mFileName = fileName;
|
|
103
|
+
mZipFileName = zipFileName;
|
|
104
|
+
mFile = file;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public final File mFile;
|
|
108
|
+
public final String mFileName;
|
|
109
|
+
public final String mZipFileName;
|
|
110
|
+
public long mLocalHdrOffset; // offset of local file header
|
|
111
|
+
|
|
112
|
+
/* useful stuff from the directory entry */
|
|
113
|
+
public int mMethod;
|
|
114
|
+
public long mWhenModified;
|
|
115
|
+
public long mCRC32;
|
|
116
|
+
public long mCompressedLength;
|
|
117
|
+
public long mUncompressedLength;
|
|
118
|
+
|
|
119
|
+
public long mOffset = -1;
|
|
120
|
+
|
|
121
|
+
public void setOffsetFromFile(RandomAccessFile f, ByteBuffer buf) throws IOException {
|
|
122
|
+
long localHdrOffset = mLocalHdrOffset;
|
|
123
|
+
try {
|
|
124
|
+
f.seek(localHdrOffset);
|
|
125
|
+
f.readFully(buf.array());
|
|
126
|
+
if (buf.getInt(0) != kLFHSignature) {
|
|
127
|
+
Log.w(LOG_TAG, "didn't find signature at start of lfh");
|
|
128
|
+
throw new IOException();
|
|
129
|
+
}
|
|
130
|
+
int nameLen = buf.getShort(kLFHNameLen) & 0xFFFF;
|
|
131
|
+
int extraLen = buf.getShort(kLFHExtraLen) & 0xFFFF;
|
|
132
|
+
mOffset = localHdrOffset + kLFHLen + nameLen + extraLen;
|
|
133
|
+
} catch (FileNotFoundException e) {
|
|
134
|
+
e.printStackTrace();
|
|
135
|
+
} catch (IOException ioe) {
|
|
136
|
+
ioe.printStackTrace();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Calculates the offset of the start of the Zip file entry within the
|
|
142
|
+
* Zip file.
|
|
143
|
+
*
|
|
144
|
+
* @return the offset, in bytes from the start of the file of the entry
|
|
145
|
+
*/
|
|
146
|
+
public long getOffset() {
|
|
147
|
+
return mOffset;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* isUncompressed
|
|
152
|
+
*
|
|
153
|
+
* @return true if the file is stored in uncompressed form
|
|
154
|
+
*/
|
|
155
|
+
public boolean isUncompressed() {
|
|
156
|
+
return mMethod == kCompressStored;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public AssetFileDescriptor getAssetFileDescriptor() {
|
|
160
|
+
if (mMethod == kCompressStored) {
|
|
161
|
+
ParcelFileDescriptor pfd;
|
|
162
|
+
try {
|
|
163
|
+
pfd = ParcelFileDescriptor.open(mFile, ParcelFileDescriptor.MODE_READ_ONLY);
|
|
164
|
+
return new AssetFileDescriptor(pfd, getOffset(), mUncompressedLength);
|
|
165
|
+
} catch (FileNotFoundException e) {
|
|
166
|
+
// TODO Auto-generated catch block
|
|
167
|
+
e.printStackTrace();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public String getZipFileName() {
|
|
174
|
+
return mZipFileName;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public File getZipFile() {
|
|
178
|
+
return mFile;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private HashMap<String, ZipEntryRO> mHashMap = new HashMap<String, ZipEntryRO>();
|
|
184
|
+
|
|
185
|
+
/* for reading compressed files */
|
|
186
|
+
public HashMap<File, ZipFile> mZipFiles = new HashMap<File, ZipFile>();
|
|
187
|
+
|
|
188
|
+
public ZipResourceFile(String zipFileName) throws IOException {
|
|
189
|
+
addPatchFile(zipFileName);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
ZipEntryRO[] getEntriesAt(String path) {
|
|
193
|
+
Vector<ZipEntryRO> zev = new Vector<ZipEntryRO>();
|
|
194
|
+
Collection<ZipEntryRO> values = mHashMap.values();
|
|
195
|
+
if (null == path)
|
|
196
|
+
path = "";
|
|
197
|
+
int length = path.length();
|
|
198
|
+
for (ZipEntryRO ze : values) {
|
|
199
|
+
if (ze.mFileName.startsWith(path)) {
|
|
200
|
+
if (-1 == ze.mFileName.indexOf('/', length)) {
|
|
201
|
+
zev.add(ze);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
ZipEntryRO[] entries = new ZipEntryRO[zev.size()];
|
|
206
|
+
return zev.toArray(entries);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
public ZipEntryRO[] getAllEntries() {
|
|
210
|
+
Collection<ZipEntryRO> values = mHashMap.values();
|
|
211
|
+
return values.toArray(new ZipEntryRO[values.size()]);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* getAssetFileDescriptor allows for ZipResourceFile to directly feed
|
|
216
|
+
* Android API's that want an fd, offset, and length such as the
|
|
217
|
+
* MediaPlayer. It also allows for the class to be used in a content
|
|
218
|
+
* provider that can feed video players. The file must be stored
|
|
219
|
+
* (non-compressed) in the Zip file for this to work.
|
|
220
|
+
*
|
|
221
|
+
* @param assetPath
|
|
222
|
+
* @return the asset file descriptor for the file, or null if the file isn't
|
|
223
|
+
* present or is stored compressed
|
|
224
|
+
*/
|
|
225
|
+
public AssetFileDescriptor getAssetFileDescriptor(String assetPath) {
|
|
226
|
+
ZipEntryRO entry = mHashMap.get(assetPath);
|
|
227
|
+
if (null != entry) {
|
|
228
|
+
return entry.getAssetFileDescriptor();
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* getInputStream returns an AssetFileDescriptor.AutoCloseInputStream
|
|
235
|
+
* associated with the asset that is contained in the Zip file, or a
|
|
236
|
+
* standard ZipInputStream if necessary to uncompress the file
|
|
237
|
+
*
|
|
238
|
+
* @param assetPath
|
|
239
|
+
* @return an input stream for the named asset path, or null if not found
|
|
240
|
+
* @throws IOException
|
|
241
|
+
*/
|
|
242
|
+
public InputStream getInputStream(String assetPath) throws IOException {
|
|
243
|
+
ZipEntryRO entry = mHashMap.get(assetPath);
|
|
244
|
+
if (null != entry) {
|
|
245
|
+
if (entry.isUncompressed()) {
|
|
246
|
+
return entry.getAssetFileDescriptor().createInputStream();
|
|
247
|
+
} else {
|
|
248
|
+
ZipFile zf = mZipFiles.get(entry.getZipFile());
|
|
249
|
+
/** read compressed files **/
|
|
250
|
+
if (null == zf) {
|
|
251
|
+
zf = new ZipFile(entry.getZipFile(), ZipFile.OPEN_READ);
|
|
252
|
+
mZipFiles.put(entry.getZipFile(), zf);
|
|
253
|
+
}
|
|
254
|
+
ZipEntry zi = zf.getEntry(assetPath);
|
|
255
|
+
if (null != zi)
|
|
256
|
+
return zf.getInputStream(zi);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
ByteBuffer mLEByteBuffer = ByteBuffer.allocate(4);
|
|
263
|
+
|
|
264
|
+
static private int read4LE(RandomAccessFile f) throws EOFException, IOException {
|
|
265
|
+
return swapEndian(f.readInt());
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/*
|
|
269
|
+
* Opens the specified file read-only. We memory-map the entire thing and
|
|
270
|
+
* close the file before returning.
|
|
271
|
+
*/
|
|
272
|
+
void addPatchFile(String zipFileName) throws IOException
|
|
273
|
+
{
|
|
274
|
+
File file = new File(zipFileName);
|
|
275
|
+
RandomAccessFile f = new RandomAccessFile(file, "r");
|
|
276
|
+
long fileLength = f.length();
|
|
277
|
+
|
|
278
|
+
if (fileLength < kEOCDLen) {
|
|
279
|
+
throw new java.io.IOException();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
long readAmount = kMaxEOCDSearch;
|
|
283
|
+
if (readAmount > fileLength)
|
|
284
|
+
readAmount = fileLength;
|
|
285
|
+
|
|
286
|
+
/*
|
|
287
|
+
* Make sure this is a Zip archive.
|
|
288
|
+
*/
|
|
289
|
+
f.seek(0);
|
|
290
|
+
|
|
291
|
+
int header = read4LE(f);
|
|
292
|
+
if (header == kEOCDSignature) {
|
|
293
|
+
Log.i(LOG_TAG, "Found Zip archive, but it looks empty");
|
|
294
|
+
throw new IOException();
|
|
295
|
+
} else if (header != kLFHSignature) {
|
|
296
|
+
Log.v(LOG_TAG, "Not a Zip archive");
|
|
297
|
+
throw new IOException();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/*
|
|
301
|
+
* Perform the traditional EOCD snipe hunt. We're searching for the End
|
|
302
|
+
* of Central Directory magic number, which appears at the start of the
|
|
303
|
+
* EOCD block. It's followed by 18 bytes of EOCD stuff and up to 64KB of
|
|
304
|
+
* archive comment. We need to read the last part of the file into a
|
|
305
|
+
* buffer, dig through it to find the magic number, parse some values
|
|
306
|
+
* out, and use those to determine the extent of the CD. We start by
|
|
307
|
+
* pulling in the last part of the file.
|
|
308
|
+
*/
|
|
309
|
+
long searchStart = fileLength - readAmount;
|
|
310
|
+
|
|
311
|
+
f.seek(searchStart);
|
|
312
|
+
ByteBuffer bbuf = ByteBuffer.allocate((int) readAmount);
|
|
313
|
+
byte[] buffer = bbuf.array();
|
|
314
|
+
f.readFully(buffer);
|
|
315
|
+
bbuf.order(ByteOrder.LITTLE_ENDIAN);
|
|
316
|
+
|
|
317
|
+
/*
|
|
318
|
+
* Scan backward for the EOCD magic. In an archive without a trailing
|
|
319
|
+
* comment, we'll find it on the first try. (We may want to consider
|
|
320
|
+
* doing an initial minimal read; if we don't find it, retry with a
|
|
321
|
+
* second read as above.)
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
// EOCD == 0x50, 0x4b, 0x05, 0x06
|
|
325
|
+
int eocdIdx;
|
|
326
|
+
for (eocdIdx = buffer.length - kEOCDLen; eocdIdx >= 0; eocdIdx--) {
|
|
327
|
+
if (buffer[eocdIdx] == 0x50 && bbuf.getInt(eocdIdx) == kEOCDSignature)
|
|
328
|
+
{
|
|
329
|
+
if (LOGV) {
|
|
330
|
+
Log.v(LOG_TAG, "+++ Found EOCD at index: " + eocdIdx);
|
|
331
|
+
}
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (eocdIdx < 0) {
|
|
337
|
+
Log.d(LOG_TAG, "Zip: EOCD not found, " + zipFileName + " is not zip");
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/*
|
|
341
|
+
* Grab the CD offset and size, and the number of entries in the
|
|
342
|
+
* archive. After that, we can release our EOCD hunt buffer.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
int numEntries = bbuf.getShort(eocdIdx + kEOCDNumEntries);
|
|
346
|
+
long dirSize = bbuf.getInt(eocdIdx + kEOCDSize) & 0xffffffffL;
|
|
347
|
+
long dirOffset = bbuf.getInt(eocdIdx + kEOCDFileOffset) & 0xffffffffL;
|
|
348
|
+
|
|
349
|
+
// Verify that they look reasonable.
|
|
350
|
+
if (dirOffset + dirSize > fileLength) {
|
|
351
|
+
Log.w(LOG_TAG, "bad offsets (dir " + dirOffset + ", size " + dirSize + ", eocd "
|
|
352
|
+
+ eocdIdx + ")");
|
|
353
|
+
throw new IOException();
|
|
354
|
+
}
|
|
355
|
+
if (numEntries == 0) {
|
|
356
|
+
Log.w(LOG_TAG, "empty archive?");
|
|
357
|
+
throw new IOException();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (LOGV) {
|
|
361
|
+
Log.v(LOG_TAG, "+++ numEntries=" + numEntries + " dirSize=" + dirSize + " dirOffset="
|
|
362
|
+
+ dirOffset);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
MappedByteBuffer directoryMap = f.getChannel()
|
|
366
|
+
.map(FileChannel.MapMode.READ_ONLY, dirOffset, dirSize);
|
|
367
|
+
directoryMap.order(ByteOrder.LITTLE_ENDIAN);
|
|
368
|
+
|
|
369
|
+
byte[] tempBuf = new byte[0xffff];
|
|
370
|
+
|
|
371
|
+
/*
|
|
372
|
+
* Walk through the central directory, adding entries to the hash table.
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
int currentOffset = 0;
|
|
376
|
+
|
|
377
|
+
/*
|
|
378
|
+
* Allocate the local directory information
|
|
379
|
+
*/
|
|
380
|
+
ByteBuffer buf = ByteBuffer.allocate(kLFHLen);
|
|
381
|
+
buf.order(ByteOrder.LITTLE_ENDIAN);
|
|
382
|
+
|
|
383
|
+
for (int i = 0; i < numEntries; i++) {
|
|
384
|
+
if (directoryMap.getInt(currentOffset) != kCDESignature) {
|
|
385
|
+
Log.w(LOG_TAG, "Missed a central dir sig (at " + currentOffset + ")");
|
|
386
|
+
throw new IOException();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/* useful stuff from the directory entry */
|
|
390
|
+
int fileNameLen = directoryMap.getShort(currentOffset + kCDENameLen) & 0xffff;
|
|
391
|
+
int extraLen = directoryMap.getShort(currentOffset + kCDEExtraLen) & 0xffff;
|
|
392
|
+
int commentLen = directoryMap.getShort(currentOffset + kCDECommentLen) & 0xffff;
|
|
393
|
+
|
|
394
|
+
/* get the CDE filename */
|
|
395
|
+
|
|
396
|
+
directoryMap.position(currentOffset + kCDELen);
|
|
397
|
+
directoryMap.get(tempBuf, 0, fileNameLen);
|
|
398
|
+
directoryMap.position(0);
|
|
399
|
+
|
|
400
|
+
/* UTF-8 on Android */
|
|
401
|
+
String str = new String(tempBuf, 0, fileNameLen);
|
|
402
|
+
if (LOGV) {
|
|
403
|
+
Log.v(LOG_TAG, "Filename: " + str);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
ZipEntryRO ze = new ZipEntryRO(zipFileName, file, str);
|
|
407
|
+
ze.mMethod = directoryMap.getShort(currentOffset + kCDEMethod) & 0xffff;
|
|
408
|
+
ze.mWhenModified = directoryMap.getInt(currentOffset + kCDEModWhen) & 0xffffffffL;
|
|
409
|
+
ze.mCRC32 = directoryMap.getLong(currentOffset + kCDECRC) & 0xffffffffL;
|
|
410
|
+
ze.mCompressedLength = directoryMap.getLong(currentOffset + kCDECompLen) & 0xffffffffL;
|
|
411
|
+
ze.mUncompressedLength = directoryMap.getLong(currentOffset + kCDEUncompLen) & 0xffffffffL;
|
|
412
|
+
ze.mLocalHdrOffset = directoryMap.getInt(currentOffset + kCDELocalOffset) & 0xffffffffL;
|
|
413
|
+
|
|
414
|
+
// set the offsets
|
|
415
|
+
buf.clear();
|
|
416
|
+
ze.setOffsetFromFile(f, buf);
|
|
417
|
+
|
|
418
|
+
// put file into hash
|
|
419
|
+
mHashMap.put(str, ze);
|
|
420
|
+
|
|
421
|
+
// go to next directory entry
|
|
422
|
+
currentOffset += kCDELen + fileNameLen + extraLen + commentLen;
|
|
423
|
+
}
|
|
424
|
+
if (LOGV) {
|
|
425
|
+
Log.v(LOG_TAG, "+++ zip good scan " + numEntries + " entries");
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<declare-styleable name="scaleStyle">
|
|
4
|
+
<attr name="scalableType">
|
|
5
|
+
<enum name="none" value="0"/>
|
|
6
|
+
|
|
7
|
+
<enum name="fitXY" value="1"/>
|
|
8
|
+
<enum name="fitStart" value="2"/>
|
|
9
|
+
<enum name="fitCenter" value="3"/>
|
|
10
|
+
<enum name="fitEnd" value="4"/>
|
|
11
|
+
|
|
12
|
+
<enum name="leftTop" value="5"/>
|
|
13
|
+
<enum name="leftCenter" value="6"/>
|
|
14
|
+
<enum name="leftBottom" value="7"/>
|
|
15
|
+
<enum name="centerTop" value="8"/>
|
|
16
|
+
<enum name="center" value="9"/>
|
|
17
|
+
<enum name="centerBottom" value="10"/>
|
|
18
|
+
<enum name="rightTop" value="11"/>
|
|
19
|
+
<enum name="rightCenter" value="12"/>
|
|
20
|
+
<enum name="rightBottom" value="13"/>
|
|
21
|
+
|
|
22
|
+
<enum name="leftTopCrop" value="14"/>
|
|
23
|
+
<enum name="leftCenterCrop" value="15"/>
|
|
24
|
+
<enum name="leftBottomCrop" value="16"/>
|
|
25
|
+
<enum name="centerTopCrop" value="17"/>
|
|
26
|
+
<enum name="centerCrop" value="18"/>
|
|
27
|
+
<enum name="centerBottomCrop" value="19"/>
|
|
28
|
+
<enum name="rightTopCrop" value="20"/>
|
|
29
|
+
<enum name="rightCenterCrop" value="21"/>
|
|
30
|
+
<enum name="rightBottomCrop" value="22"/>
|
|
31
|
+
|
|
32
|
+
<enum name="startInside" value="23"/>
|
|
33
|
+
<enum name="centerInside" value="24"/>
|
|
34
|
+
<enum name="endInside" value="25"/>
|
|
35
|
+
</attr>
|
|
36
|
+
</declare-styleable>
|
|
37
|
+
</resources>
|
package/ios/FileManager.m
CHANGED
|
@@ -133,15 +133,85 @@ RCT_EXPORT_METHOD(openFile:(NSString *) url name:(NSString *) fileName myCallbac
|
|
|
133
133
|
return YES;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
RCT_EXPORT_METHOD(requestResourcesPermission:(NSArray *)resourceTypes resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
137
|
+
{
|
|
138
|
+
__block NSUInteger permissionsToCheckCount = resourceTypes.count;
|
|
139
|
+
NSMutableDictionary *permDict = [NSMutableDictionary new];
|
|
140
|
+
for (NSString *resourceType in resourceTypes) {
|
|
141
|
+
NSString *mediaType;
|
|
142
|
+
if ([resourceType isEqualToString:@"camera"]) {
|
|
143
|
+
mediaType = AVMediaTypeVideo;
|
|
144
|
+
} else if ([resourceType isEqualToString:@"mic"]) {
|
|
145
|
+
mediaType = AVMediaTypeAudio;
|
|
146
|
+
} else {
|
|
147
|
+
reject(@"INVALID_RESOURCE_TYPE", @"Invalid resource type requested", nil);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
|
|
151
|
+
NSNumber *authStatusObj = granted ? @(AVAuthorizationStatusAuthorized) : @(AVAuthorizationStatusDenied);
|
|
152
|
+
permDict[resourceType] = authStatusObj;
|
|
153
|
+
|
|
154
|
+
permissionsToCheckCount--;
|
|
155
|
+
if (permissionsToCheckCount == 0) {
|
|
156
|
+
resolve(permDict);
|
|
157
|
+
}
|
|
158
|
+
}];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
RCT_EXPORT_METHOD(checkResourcesPermission:(NSArray *)resourceTypes resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
163
|
+
{
|
|
164
|
+
NSMutableDictionary *permDict = [NSMutableDictionary new];
|
|
165
|
+
|
|
166
|
+
for (NSString *resourceType in resourceTypes) {
|
|
167
|
+
NSString *mediaType = AVMediaTypeVideo;
|
|
168
|
+
if ([resourceType isEqualToString:@"camera"]) {
|
|
169
|
+
mediaType = AVMediaTypeVideo;
|
|
170
|
+
} else if ([resourceType isEqualToString:@"mic"]) {
|
|
171
|
+
mediaType = AVMediaTypeAudio;
|
|
172
|
+
} else {
|
|
173
|
+
reject(@"INVALID_RESOURCE_TYPE", @"Invalid resource type requested", nil);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
AVAuthorizationStatus authStatusCamera = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
|
|
178
|
+
|
|
179
|
+
NSNumber *authStatusCameraObj = @(authStatusCamera);
|
|
180
|
+
|
|
181
|
+
permDict[resourceType] = authStatusCameraObj;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
resolve(permDict);
|
|
185
|
+
}
|
|
186
|
+
|
|
136
187
|
RCT_EXPORT_METHOD(openCamera: (NSString *) type callback:(RCTResponseSenderBlock) call) {
|
|
137
188
|
callback = call;
|
|
138
189
|
UIViewController *presentedViewController = RCTPresentedViewController();
|
|
139
190
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
191
|
+
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
|
|
192
|
+
UIImagePickerController *imageController = [[UIImagePickerController alloc] init];
|
|
193
|
+
imageController.delegate = self;
|
|
194
|
+
imageController.title = @"Select an image";
|
|
195
|
+
imageController.sourceType = UIImagePickerControllerSourceTypeCamera;
|
|
196
|
+
[presentedViewController presentViewController:imageController animated:YES completion:nil];
|
|
197
|
+
} else {
|
|
198
|
+
NSMutableString *myMutableString = [NSMutableString stringWithString:@"Camera not available"];
|
|
199
|
+
if (TARGET_IPHONE_SIMULATOR) {
|
|
200
|
+
[myMutableString setString:@"Camera not available in simulator"];
|
|
201
|
+
}
|
|
202
|
+
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"Error"
|
|
203
|
+
message:myMutableString
|
|
204
|
+
preferredStyle:UIAlertControllerStyleAlert];
|
|
205
|
+
|
|
206
|
+
UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
|
|
207
|
+
handler:^(UIAlertAction * action) {
|
|
208
|
+
// Action when OK button is pressed
|
|
209
|
+
}];
|
|
210
|
+
|
|
211
|
+
[alertController addAction:okAction];
|
|
212
|
+
|
|
213
|
+
[presentedViewController presentViewController:alertController animated:YES completion:nil];
|
|
214
|
+
}
|
|
145
215
|
});
|
|
146
216
|
}
|
|
147
217
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#import <AVFoundation/AVFoundation.h>
|
|
2
|
+
#import "AVKit/AVKit.h"
|
|
3
|
+
#import "UIView+FindUIViewController.h"
|
|
4
|
+
#import "CCRCTVideoPlayerViewController.h"
|
|
5
|
+
#import "CCRCTVideoPlayerViewControllerDelegate.h"
|
|
6
|
+
#import <React/RCTComponent.h>
|
|
7
|
+
#import <React/RCTBridgeModule.h>
|
|
8
|
+
|
|
9
|
+
#if __has_include(<react-native-cometchat-ui-kit/RCTVideoCache.h>)
|
|
10
|
+
#import <RCTVideoCache.h>
|
|
11
|
+
#import <DVAssetLoaderDelegate/DVURLAsset.h>
|
|
12
|
+
#import <DVAssetLoaderDelegate/DVAssetLoaderDelegate.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
@class RCTEventDispatcher;
|
|
16
|
+
#if __has_include(<react-native-cometchat-ui-kit/RCTVideoCache.h>)
|
|
17
|
+
@interface CCRCTVideo : UIView <CCRCTVideoPlayerViewControllerDelegate, DVAssetLoaderDelegatesDelegate, AVAssetResourceLoaderDelegate>
|
|
18
|
+
#elif TARGET_OS_TV
|
|
19
|
+
@interface CCRCTVideo : UIView <CCRCTVideoPlayerViewControllerDelegate, AVAssetResourceLoaderDelegate>
|
|
20
|
+
#else
|
|
21
|
+
@interface CCRCTVideo : UIView <CCRCTVideoPlayerViewControllerDelegate, AVPictureInPictureControllerDelegate, AVAssetResourceLoaderDelegate>
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoLoadStart;
|
|
25
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoLoad;
|
|
26
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoBuffer;
|
|
27
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoError;
|
|
28
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoProgress;
|
|
29
|
+
@property (nonatomic, copy) RCTDirectEventBlock onBandwidthUpdate;
|
|
30
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoSeek;
|
|
31
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoEnd;
|
|
32
|
+
@property (nonatomic, copy) RCTDirectEventBlock onTimedMetadata;
|
|
33
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoAudioBecomingNoisy;
|
|
34
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoFullscreenPlayerWillPresent;
|
|
35
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoFullscreenPlayerDidPresent;
|
|
36
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoFullscreenPlayerWillDismiss;
|
|
37
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoFullscreenPlayerDidDismiss;
|
|
38
|
+
@property (nonatomic, copy) RCTDirectEventBlock onReadyForDisplay;
|
|
39
|
+
@property (nonatomic, copy) RCTDirectEventBlock onPlaybackStalled;
|
|
40
|
+
@property (nonatomic, copy) RCTDirectEventBlock onPlaybackResume;
|
|
41
|
+
@property (nonatomic, copy) RCTDirectEventBlock onPlaybackRateChange;
|
|
42
|
+
@property (nonatomic, copy) RCTDirectEventBlock onVideoExternalPlaybackChange;
|
|
43
|
+
@property (nonatomic, copy) RCTDirectEventBlock onPictureInPictureStatusChanged;
|
|
44
|
+
@property (nonatomic, copy) RCTDirectEventBlock onRestoreUserInterfaceForPictureInPictureStop;
|
|
45
|
+
@property (nonatomic, copy) RCTDirectEventBlock onGetLicense;
|
|
46
|
+
|
|
47
|
+
typedef NS_ENUM(NSInteger, RCTVideoError) {
|
|
48
|
+
RCTVideoErrorFromJSPart,
|
|
49
|
+
RCTVideoErrorLicenseRequestNotOk,
|
|
50
|
+
RCTVideoErrorNoDataFromLicenseRequest,
|
|
51
|
+
RCTVideoErrorNoSPC,
|
|
52
|
+
RCTVideoErrorNoDataRequest,
|
|
53
|
+
RCTVideoErrorNoCertificateData,
|
|
54
|
+
RCTVideoErrorNoCertificateURL,
|
|
55
|
+
RCTVideoErrorNoFairplayDRM,
|
|
56
|
+
RCTVideoErrorNoDRMData
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
|
|
60
|
+
|
|
61
|
+
- (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem;
|
|
62
|
+
|
|
63
|
+
- (void)save:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
|
64
|
+
- (void)setLicenseResult:(NSString * )license;
|
|
65
|
+
- (BOOL)setLicenseResultError:(NSString * )error;
|
|
66
|
+
|
|
67
|
+
@end
|