@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,287 @@
|
|
|
1
|
+
package com.zipfile;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2012 The Android Open Source Project
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
//To implement APEZProvider in your application, you'll want to change
|
|
20
|
+
//the AUTHORITY to match what you define in the manifest.
|
|
21
|
+
|
|
22
|
+
import com.zipfile.ZipResourceFile.ZipEntryRO;
|
|
23
|
+
|
|
24
|
+
import android.content.ContentProvider;
|
|
25
|
+
import android.content.ContentProviderOperation;
|
|
26
|
+
import android.content.ContentProviderResult;
|
|
27
|
+
import android.content.ContentValues;
|
|
28
|
+
import android.content.Context;
|
|
29
|
+
import android.content.OperationApplicationException;
|
|
30
|
+
import android.content.pm.PackageInfo;
|
|
31
|
+
import android.content.pm.PackageManager;
|
|
32
|
+
import android.content.pm.PackageManager.NameNotFoundException;
|
|
33
|
+
import android.content.pm.ProviderInfo;
|
|
34
|
+
import android.content.res.AssetFileDescriptor;
|
|
35
|
+
import android.database.Cursor;
|
|
36
|
+
import android.database.MatrixCursor;
|
|
37
|
+
import android.net.Uri;
|
|
38
|
+
import android.os.ParcelFileDescriptor;
|
|
39
|
+
import android.provider.BaseColumns;
|
|
40
|
+
|
|
41
|
+
import java.io.FileNotFoundException;
|
|
42
|
+
import java.io.IOException;
|
|
43
|
+
import java.util.ArrayList;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This content provider is an optional part of the library.
|
|
47
|
+
*
|
|
48
|
+
* <p>Most apps don't need to use this class. This defines a
|
|
49
|
+
* ContentProvider that marshalls the data from the ZIP files through a
|
|
50
|
+
* content provider Uri in order to provide file access for certain Android APIs
|
|
51
|
+
* that expect Uri access to media files.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
public abstract class APEZProvider extends ContentProvider {
|
|
55
|
+
|
|
56
|
+
private ZipResourceFile mAPKExtensionFile;
|
|
57
|
+
private boolean mInit;
|
|
58
|
+
|
|
59
|
+
public static final String FILEID = BaseColumns._ID;
|
|
60
|
+
public static final String FILENAME = "ZPFN";
|
|
61
|
+
public static final String ZIPFILE = "ZFIL";
|
|
62
|
+
public static final String MODIFICATION = "ZMOD";
|
|
63
|
+
public static final String CRC32 = "ZCRC";
|
|
64
|
+
public static final String COMPRESSEDLEN = "ZCOL";
|
|
65
|
+
public static final String UNCOMPRESSEDLEN = "ZUNL";
|
|
66
|
+
public static final String COMPRESSIONTYPE = "ZTYP";
|
|
67
|
+
|
|
68
|
+
public static final String[] ALL_FIELDS = {
|
|
69
|
+
FILEID,
|
|
70
|
+
FILENAME,
|
|
71
|
+
ZIPFILE,
|
|
72
|
+
MODIFICATION,
|
|
73
|
+
CRC32,
|
|
74
|
+
COMPRESSEDLEN,
|
|
75
|
+
UNCOMPRESSEDLEN,
|
|
76
|
+
COMPRESSIONTYPE
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
public static final int FILEID_IDX = 0;
|
|
80
|
+
public static final int FILENAME_IDX = 1;
|
|
81
|
+
public static final int ZIPFILE_IDX = 2;
|
|
82
|
+
public static final int MOD_IDX = 3;
|
|
83
|
+
public static final int CRC_IDX = 4;
|
|
84
|
+
public static final int COMPLEN_IDX = 5;
|
|
85
|
+
public static final int UNCOMPLEN_IDX = 6;
|
|
86
|
+
public static final int COMPTYPE_IDX = 7;
|
|
87
|
+
|
|
88
|
+
public static final int[] ALL_FIELDS_INT = {
|
|
89
|
+
FILEID_IDX,
|
|
90
|
+
FILENAME_IDX,
|
|
91
|
+
ZIPFILE_IDX,
|
|
92
|
+
MOD_IDX,
|
|
93
|
+
CRC_IDX,
|
|
94
|
+
COMPLEN_IDX,
|
|
95
|
+
UNCOMPLEN_IDX,
|
|
96
|
+
COMPTYPE_IDX
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* This needs to match the authority in your manifest
|
|
101
|
+
*/
|
|
102
|
+
public abstract String getAuthority();
|
|
103
|
+
|
|
104
|
+
@Override
|
|
105
|
+
public int delete(Uri arg0, String arg1, String[] arg2) {
|
|
106
|
+
// TODO Auto-generated method stub
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@Override
|
|
111
|
+
public String getType(Uri uri) {
|
|
112
|
+
return "vnd.android.cursor.item/asset";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@Override
|
|
116
|
+
public Uri insert(Uri uri, ContentValues values) {
|
|
117
|
+
// TODO Auto-generated method stub
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static private final String NO_FILE = "N";
|
|
122
|
+
|
|
123
|
+
private boolean initIfNecessary() {
|
|
124
|
+
if ( !mInit ) {
|
|
125
|
+
Context ctx = getContext();
|
|
126
|
+
PackageManager pm = ctx.getPackageManager();
|
|
127
|
+
ProviderInfo pi = pm.resolveContentProvider(getAuthority(), PackageManager.GET_META_DATA);
|
|
128
|
+
PackageInfo packInfo;
|
|
129
|
+
try {
|
|
130
|
+
packInfo = pm.getPackageInfo(ctx.getPackageName(), 0);
|
|
131
|
+
} catch (NameNotFoundException e1) {
|
|
132
|
+
e1.printStackTrace();
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
int patchFileVersion;
|
|
136
|
+
int mainFileVersion;
|
|
137
|
+
int appVersionCode = packInfo.versionCode;
|
|
138
|
+
String[] resourceFiles = null;
|
|
139
|
+
if ( null != pi.metaData ) {
|
|
140
|
+
mainFileVersion = pi.metaData.getInt("mainVersion", appVersionCode);
|
|
141
|
+
patchFileVersion = pi.metaData.getInt("patchVersion", appVersionCode);
|
|
142
|
+
String mainFileName = pi.metaData.getString("mainFilename", NO_FILE);
|
|
143
|
+
if ( NO_FILE != mainFileName ) {
|
|
144
|
+
String patchFileName = pi.metaData.getString("patchFilename", NO_FILE);
|
|
145
|
+
if ( NO_FILE != patchFileName ) {
|
|
146
|
+
resourceFiles = new String[] { mainFileName, patchFileName };
|
|
147
|
+
} else {
|
|
148
|
+
resourceFiles = new String[] { mainFileName };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
mainFileVersion = patchFileVersion = appVersionCode;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
if ( null == resourceFiles ) {
|
|
156
|
+
mAPKExtensionFile = APKExpansionSupport.getAPKExpansionZipFile(ctx, mainFileVersion, patchFileVersion);
|
|
157
|
+
} else {
|
|
158
|
+
mAPKExtensionFile = APKExpansionSupport.getResourceZipFile(resourceFiles);
|
|
159
|
+
}
|
|
160
|
+
mInit = true;
|
|
161
|
+
return true;
|
|
162
|
+
} catch (IOException e) {
|
|
163
|
+
e.printStackTrace();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@Override
|
|
170
|
+
public boolean onCreate() {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@Override
|
|
175
|
+
public AssetFileDescriptor openAssetFile(Uri uri, String mode)
|
|
176
|
+
throws FileNotFoundException {
|
|
177
|
+
initIfNecessary();
|
|
178
|
+
String path = uri.getEncodedPath();
|
|
179
|
+
if ( path.startsWith("/") ) {
|
|
180
|
+
path = path.substring(1);
|
|
181
|
+
}
|
|
182
|
+
return mAPKExtensionFile.getAssetFileDescriptor(path);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@Override
|
|
186
|
+
public ContentProviderResult[] applyBatch(
|
|
187
|
+
ArrayList<ContentProviderOperation> operations)
|
|
188
|
+
throws OperationApplicationException {
|
|
189
|
+
initIfNecessary();
|
|
190
|
+
return super.applyBatch(operations);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@Override
|
|
194
|
+
public ParcelFileDescriptor openFile(Uri uri, String mode)
|
|
195
|
+
throws FileNotFoundException {
|
|
196
|
+
initIfNecessary();
|
|
197
|
+
AssetFileDescriptor af = openAssetFile(uri, mode);
|
|
198
|
+
if ( null != af ) {
|
|
199
|
+
return af.getParcelFileDescriptor();
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@Override
|
|
205
|
+
public Cursor query(Uri uri, String[] projection, String selection,
|
|
206
|
+
String[] selectionArgs, String sortOrder) {
|
|
207
|
+
initIfNecessary();
|
|
208
|
+
// lists all of the items in the file that match
|
|
209
|
+
ZipEntryRO[] zipEntries;
|
|
210
|
+
if ( null == mAPKExtensionFile ) {
|
|
211
|
+
zipEntries = new ZipEntryRO[0];
|
|
212
|
+
} else {
|
|
213
|
+
zipEntries = mAPKExtensionFile.getAllEntries();
|
|
214
|
+
}
|
|
215
|
+
int[] intProjection;
|
|
216
|
+
if ( null == projection ) {
|
|
217
|
+
intProjection = ALL_FIELDS_INT;
|
|
218
|
+
projection = ALL_FIELDS;
|
|
219
|
+
} else {
|
|
220
|
+
int len = projection.length;
|
|
221
|
+
intProjection = new int[len];
|
|
222
|
+
for ( int i = 0; i < len; i++ ) {
|
|
223
|
+
if ( projection[i].equals(FILEID) ) {
|
|
224
|
+
intProjection[i] = FILEID_IDX;
|
|
225
|
+
} else if ( projection[i].equals(FILENAME) ) {
|
|
226
|
+
intProjection[i] = FILENAME_IDX;
|
|
227
|
+
} else if ( projection[i].equals(ZIPFILE) ) {
|
|
228
|
+
intProjection[i] = ZIPFILE_IDX;
|
|
229
|
+
} else if ( projection[i].equals(MODIFICATION) ) {
|
|
230
|
+
intProjection[i] = MOD_IDX;
|
|
231
|
+
} else if ( projection[i].equals(CRC32) ) {
|
|
232
|
+
intProjection[i] = CRC_IDX;
|
|
233
|
+
} else if ( projection[i].equals(COMPRESSEDLEN) ) {
|
|
234
|
+
intProjection[i] = COMPLEN_IDX;
|
|
235
|
+
} else if ( projection[i].equals(UNCOMPRESSEDLEN) ) {
|
|
236
|
+
intProjection[i] = UNCOMPLEN_IDX;
|
|
237
|
+
} else if ( projection[i].equals(COMPRESSIONTYPE) ) {
|
|
238
|
+
intProjection[i] = COMPTYPE_IDX;
|
|
239
|
+
} else {
|
|
240
|
+
throw new RuntimeException();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
MatrixCursor mc = new MatrixCursor(projection, zipEntries.length);
|
|
245
|
+
int len = intProjection.length;
|
|
246
|
+
for ( ZipEntryRO zer : zipEntries ) {
|
|
247
|
+
MatrixCursor.RowBuilder rb = mc.newRow();
|
|
248
|
+
for ( int i = 0; i < len; i++ ) {
|
|
249
|
+
switch (intProjection[i]) {
|
|
250
|
+
case FILEID_IDX:
|
|
251
|
+
rb.add(i);
|
|
252
|
+
break;
|
|
253
|
+
case FILENAME_IDX:
|
|
254
|
+
rb.add(zer.mFileName);
|
|
255
|
+
break;
|
|
256
|
+
case ZIPFILE_IDX:
|
|
257
|
+
rb.add(zer.getZipFileName());
|
|
258
|
+
break;
|
|
259
|
+
case MOD_IDX:
|
|
260
|
+
rb.add(zer.mWhenModified);
|
|
261
|
+
break;
|
|
262
|
+
case CRC_IDX:
|
|
263
|
+
rb.add(zer.mCRC32);
|
|
264
|
+
break;
|
|
265
|
+
case COMPLEN_IDX:
|
|
266
|
+
rb.add(zer.mCompressedLength);
|
|
267
|
+
break;
|
|
268
|
+
case UNCOMPLEN_IDX:
|
|
269
|
+
rb.add(zer.mUncompressedLength);
|
|
270
|
+
break;
|
|
271
|
+
case COMPTYPE_IDX:
|
|
272
|
+
rb.add(zer.mMethod);
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return mc;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@Override
|
|
281
|
+
public int update(Uri uri, ContentValues values, String selection,
|
|
282
|
+
String[] selectionArgs) {
|
|
283
|
+
// TODO Auto-generated method stub
|
|
284
|
+
return 0;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.zipfile;
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2012 The Android Open Source Project
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import java.io.File;
|
|
18
|
+
import java.io.FileFilter;
|
|
19
|
+
import java.io.IOException;
|
|
20
|
+
import java.util.Vector;
|
|
21
|
+
import java.util.regex.Matcher;
|
|
22
|
+
import java.util.regex.Pattern;
|
|
23
|
+
|
|
24
|
+
import android.content.Context;
|
|
25
|
+
import android.os.Environment;
|
|
26
|
+
import android.util.Log;
|
|
27
|
+
|
|
28
|
+
public class APKExpansionSupport {
|
|
29
|
+
// The shared path to all app expansion files
|
|
30
|
+
private final static String EXP_PATH = "/Android/obb/";
|
|
31
|
+
|
|
32
|
+
static String[] getAPKExpansionFiles(Context ctx, int mainVersion, int patchVersion) {
|
|
33
|
+
String packageName = ctx.getPackageName();
|
|
34
|
+
Vector<String> ret = new Vector<String>();
|
|
35
|
+
if (Environment.getExternalStorageState().equals(
|
|
36
|
+
Environment.MEDIA_MOUNTED)) {
|
|
37
|
+
// Build the full path to the app's expansion files
|
|
38
|
+
File root = Environment.getExternalStorageDirectory();
|
|
39
|
+
File expPath = new File(root.toString() + EXP_PATH + packageName);
|
|
40
|
+
|
|
41
|
+
// Check that expansion file path exists
|
|
42
|
+
if (expPath.exists()) {
|
|
43
|
+
if ( mainVersion > 0 ) {
|
|
44
|
+
String strMainPath = expPath + File.separator + "main." + mainVersion + "." + packageName + ".obb";
|
|
45
|
+
// Log.d("APKEXPANSION", strMainPath);
|
|
46
|
+
File main = new File(strMainPath);
|
|
47
|
+
if ( main.isFile() ) {
|
|
48
|
+
ret.add(strMainPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if ( patchVersion > 0 ) {
|
|
52
|
+
String strPatchPath = expPath + File.separator + "patch." + patchVersion + "." + packageName + ".obb";
|
|
53
|
+
File main = new File(strPatchPath);
|
|
54
|
+
if ( main.isFile() ) {
|
|
55
|
+
ret.add(strPatchPath);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
String[] retArray = new String[ret.size()];
|
|
61
|
+
ret.toArray(retArray);
|
|
62
|
+
return retArray;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static public ZipResourceFile getResourceZipFile(String[] expansionFiles) throws IOException {
|
|
66
|
+
ZipResourceFile apkExpansionFile = null;
|
|
67
|
+
for (String expansionFilePath : expansionFiles) {
|
|
68
|
+
if ( null == apkExpansionFile ) {
|
|
69
|
+
apkExpansionFile = new ZipResourceFile(expansionFilePath);
|
|
70
|
+
} else {
|
|
71
|
+
apkExpansionFile.addPatchFile(expansionFilePath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return apkExpansionFile;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static public ZipResourceFile getAPKExpansionZipFile(Context ctx, int mainVersion, int patchVersion) throws IOException{
|
|
78
|
+
String[] expansionFiles = getAPKExpansionFiles(ctx, mainVersion, patchVersion);
|
|
79
|
+
return getResourceZipFile(expansionFiles);
|
|
80
|
+
}
|
|
81
|
+
}
|