what's new
* 动态启动图
* 动态聊天背景
* 支持8.0.1
* 更新越狱包8.0.1
* 更新已注入助手的8.0.1未签名包
* 更新越狱源安装包
This commit is contained in:
DKJone
2021-01-29 16:35:34 +08:00
parent 25a3f7f760
commit 888af8954e
125 changed files with 10144 additions and 40 deletions
@@ -0,0 +1,22 @@
// NSArray+VAPUtil.h
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
@interface NSArray (VAPUtil)
- (CGRect)hwd_rectValue;
@end
@@ -0,0 +1,37 @@
// NSArray+VAPUtil.m
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import "NSArray+VAPUtil.h"
@implementation NSArray (VAPUtil)
- (CGRect)hwd_rectValue {
if (self.count < 4) {
return CGRectZero;
}
for (int i = 0; i < self.count; i++) {
id value = self[i];
if (i >= 4) {
break ;
}
if (![value isKindOfClass:[NSString class]] && ![value isKindOfClass:[NSNumber class]]) {
return CGRectZero;
}
}
return CGRectMake([self[0] floatValue], [self[1] floatValue], [self[2] floatValue], [self[3] floatValue]);
}
@end
@@ -0,0 +1,28 @@
// NSDictionary+VAPUtil.h
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
@interface NSDictionary (VAPUtil)
- (CGFloat)hwd_floatValue:(NSString *)key;
- (NSInteger)hwd_integerValue:(NSString *)key;
- (NSString *)hwd_stringValue:(NSString *)key;
- (NSDictionary *)hwd_dicValue:(NSString *)key;
- (NSArray *)hwd_arrValue:(NSString *)key;
@end
@@ -0,0 +1,71 @@
// NSDictionary+VAPUtil.m
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import "NSDictionary+VAPUtil.h"
#define HWD_RETURN_VALUE(_type_, _default_) \
if (!key) return _default_; \
id value = self[key]; \
if (!value || value == [NSNull null]) return _default_; \
if ([value isKindOfClass:[NSNumber class]]) return ((NSNumber *)value)._type_; \
if ([value isKindOfClass:[NSString class]]) return ((NSString *)value)._type_; \
return _default_;
@implementation NSDictionary (VAPUtil)
- (CGFloat)hwd_floatValue:(NSString *)key {
HWD_RETURN_VALUE(floatValue, 0.0);
}
- (NSInteger)hwd_integerValue:(NSString *)key {
HWD_RETURN_VALUE(integerValue, 0);
}
- (NSString *)hwd_stringValue:(NSString *)key {
NSString *defaultValue = @"";
if (!key) return defaultValue;
id value = self[key];
if (!value || value == [NSNull null]) return defaultValue;
if ([value isKindOfClass:[NSString class]]) return value;
if ([value isKindOfClass:[NSNumber class]]) return ((NSNumber *)value).description;
return defaultValue;
}
- (NSDictionary *)hwd_dicValue:(NSString *)key {
if (!key) {
return nil;
}
id value = self[key];
if (![value isKindOfClass:[NSDictionary class]]) {
return nil;
}
return value;
}
- (NSArray *)hwd_arrValue:(NSString *)key {
if (!key) {
return nil;
}
id value = self[key];
if (![value isKindOfClass:[NSArray class]]) {
return nil;
}
return value;
}
@end
@@ -0,0 +1,54 @@
// NSNotificationCenter+VAPThreadSafe.h
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import <Foundation/Foundation.h>
@interface NSNotificationCenter (VAPThreadSafe)
/**
该方法能够保证通知的执行和移除是线程安全的
不需要手动移除通知
(iOS9以下系统方法addObserver:selector:name:object:通常用法是不安全的。
@note 该方法适用于代替原来需要在dealloc内移除通知的场景
@param observer Object registering as an observer. This value must not be nil.
@param aSelector Selector that specifies the message the receiver sends observer to notify it of the notification posting. The method specified by aSelector must have one and only one argument (an instance of NSNotification).
@param aName The name of the notification for which to register the observer; that is, only notifications with this name are delivered to the observer.
If you pass nil, the notification center doesnt use a notifications name to decide whether to deliver it to the observer.
@param anObject The object whose notifications the observer wants to receive; that is, only notifications sent by this sender are delivered to the observer.
If you pass nil, the notification center doesnt use a notifications sender to decide whether to deliver it to the observer.
*/
- (void)hwd_addSafeObserver:(id)observer selector:(SEL)aSelector name:(NSNotificationName)aName object:(id)anObject;
- (void)hwd_addWeakObserver:( id)weakObserver name:(NSNotificationName)aName usingBlock:(void (^)(NSNotification *note,id observer))block;
/**
1.设置接收通知的queue
2.调用- (void)addSafeObserver:(id)observer selector:(SEL)aSelector name:(NSNotificationName)aName object:(id)anObject
@param observer Object registering as an observer. This value must not be nil.
@param aSelector Selector that specifies the message the receiver sends observer to notify it of the notification posting. The method specified by aSelector must have one and only one argument (an instance of NSNotification).
@param aName The name of the notification for which to register the observer; that is, only notifications with this name are delivered to the observer.
If you pass nil, the notification center doesnt use a notifications name to decide whether to deliver it to the observer.
@param anObject The object whose notifications the observer wants to receive; that is, only notifications sent by this sender are delivered to the observer.
If you pass nil, the notification center doesnt use a notifications sender to decide whether to deliver it to the observer.
@param queue The operation queue to which callbackoperation should be added.
If you pass nil, the block is run asynchronously on queue which hold by this notification.
*/
- (void)hwd_addSafeObserver:(id)observer selector:(SEL)aSelector name:(NSNotificationName)aName object:(id)anObject queue:(NSOperationQueue *)queue;
@end
@@ -0,0 +1,89 @@
// NSNotificationCenter+ThreadSafe.m
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import "NSNotificationCenter+VAPThreadSafe.h"
#import "QGVAPSafeMutableDictionary.h"
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
@interface NSObject (SafeNotification)
@property (nonatomic, strong) NSOperationQueue *notificationOperationQueue;
@end
@implementation NSObject (SafeNotification)
- (NSOperationQueue *)notificationOperationQueue {
@synchronized (self) {
NSOperationQueue *queue = objc_getAssociatedObject(self, @"notificationOperationQueue");
if (!queue) {
queue = [[NSOperationQueue alloc] init];
queue.maxConcurrentOperationCount = 1;
self.notificationOperationQueue = queue;
}
return queue;
}
}
- (void)setNotificationOperationQueue:(NSOperationQueue *)notificationOperationQueue {
@synchronized (self) {
objc_setAssociatedObject(self, @"notificationOperationQueue", notificationOperationQueue, OBJC_ASSOCIATION_RETAIN);
}
}
@end
@implementation NSNotificationCenter (VAPThreadSafe)
- (void)hwd_addSafeObserver:(id)observer selector:(SEL)aSelector name:(NSNotificationName)aName object:(id)anObject {
double sysVersion = [[[UIDevice currentDevice] systemVersion] doubleValue];;
if (sysVersion >= 9.0) {
return [self addObserver:observer selector:aSelector name:aName object:anObject];
}
__weak typeof(observer) weakObserver = observer;
__block NSObject *blockObserver = [self addObserverForName:aName object:anObject queue:aName.notificationOperationQueue usingBlock:^(NSNotification * _Nonnull note) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
__strong __typeof__(weakObserver) strongObserver = weakObserver;
[strongObserver performSelector:aSelector withObject:note];
#pragma clang diagnostic pop
if (!weakObserver) {
[[NSNotificationCenter defaultCenter] removeObserver:blockObserver];
blockObserver = nil;
}
}];
}
- (void)hwd_addWeakObserver:( id)Observer name:(NSNotificationName)aName usingBlock:(void (^)(NSNotification *note,id observer))block{
__weak id weakObserver=Observer;
__block NSObject *blockObserver = [self addObserverForName:aName object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
__strong id strongObserver = weakObserver;
if(!weakObserver ){
[[NSNotificationCenter defaultCenter] removeObserver:blockObserver];
blockObserver = nil;
}else{
block(note,strongObserver);
}
}];
}
- (void)hwd_addSafeObserver:(id)observer selector:(SEL)aSelector name:(NSNotificationName)aName object:(id)anObject queue:(NSOperationQueue *)queue {
aName.notificationOperationQueue = queue;
[self hwd_addSafeObserver:observer selector:aSelector name:aName object:anObject];
}
@end
@@ -0,0 +1,26 @@
// UIColor+VAPUtil.h
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIColor (VAPUtil)
+ (instancetype)hwd_colorWithHexString:(NSString *)hexStr;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,66 @@
// UIColor+VAPUtil.m
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import "UIColor+VAPUtil.h"
@implementation UIColor (VAPUtil)
static inline NSUInteger hwd_hexStrToInt(NSString *str) {
uint32_t result = 0;
sscanf([str UTF8String], "%X", &result);
return result;
}
static BOOL hwd_hexStrToRGBA(NSString *str,
CGFloat *r, CGFloat *g, CGFloat *b, CGFloat *a) {
NSCharacterSet *cset = [NSCharacterSet whitespaceAndNewlineCharacterSet];
str = [[str stringByTrimmingCharactersInSet:cset] uppercaseString];
if ([str hasPrefix:@"#"]) {
str = [str substringFromIndex:1];
} else if ([str hasPrefix:@"0X"]) {
str = [str substringFromIndex:2];
}
NSUInteger length = [str length];
//RGB||RGBA||RRGGBB||RRGGBBAA
if (length != 3 && length != 4 && length != 6 && length != 8) {
return NO;
}
if (length < 5) {
*r = hwd_hexStrToInt([str substringWithRange:NSMakeRange(0, 1)]) / 255.0f;
*g = hwd_hexStrToInt([str substringWithRange:NSMakeRange(1, 1)]) / 255.0f;
*b = hwd_hexStrToInt([str substringWithRange:NSMakeRange(2, 1)]) / 255.0f;
if (length == 4) *a = hwd_hexStrToInt([str substringWithRange:NSMakeRange(3, 1)]) / 255.0f;
else *a = 1;
} else {
*r = hwd_hexStrToInt([str substringWithRange:NSMakeRange(0, 2)]) / 255.0f;
*g = hwd_hexStrToInt([str substringWithRange:NSMakeRange(2, 2)]) / 255.0f;
*b = hwd_hexStrToInt([str substringWithRange:NSMakeRange(4, 2)]) / 255.0f;
if (length == 8) *a = hwd_hexStrToInt([str substringWithRange:NSMakeRange(6, 2)]) / 255.0f;
else *a = 1;
}
return YES;
}
+ (instancetype)hwd_colorWithHexString:(NSString *)hexStr {
CGFloat r, g, b, a;
if (hwd_hexStrToRGBA(hexStr, &r, &g, &b, &a)) {
return [UIColor colorWithRed:r green:g blue:b alpha:a];
}
return nil;
}
@end
@@ -0,0 +1,45 @@
// UIDevice+VAPUtil.h
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
#import <Metal/Metal.h>
#ifndef kHWDSystemVersion
#define kHWDSystemVersion [UIDevice systemVersionNum]
#endif
#ifndef kHWDiOS9Later
#define kHWDiOS9Later (kHWDSystemVersion >= 9)
#endif
#define kDefaultMTLResourceOption getDefaultMTLResourceOption()
#ifdef __cplusplus
extern "C" {
#endif
MTLResourceOptions getDefaultMTLResourceOption(void);
#ifdef __cplusplus
}
#endif
NS_ASSUME_NONNULL_BEGIN
@interface UIDevice (VAPUtil)
+ (double)systemVersionNum;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,38 @@
// UIDevice+VAPUtil.m
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import "UIDevice+VAPUtil.h"
MTLResourceOptions getDefaultMTLResourceOption() {
if (@available(iOS 9.0, *)) {
return MTLResourceStorageModeShared;
} else {
return MTLResourceCPUCacheModeDefaultCache;
}
}
@implementation UIDevice (VAPUtil)
+ (double)systemVersionNum {
static double version;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
version = [UIDevice currentDevice].systemVersion.doubleValue;
});
return version;
}
@end
@@ -0,0 +1,26 @@
// UIGestureRecognizer+VAPUtil.h
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
@interface UIGestureRecognizer (VAPUtil)
- (instancetype)initWithVapActionBlock:(void (^)(id sender))block;
- (void)addVapActionBlock:(void (^)(id sender))block;
- (void)removeAllVapActionBlocks;
@end
@@ -0,0 +1,84 @@
// UIGestureRecognizer+VAPUtil.m
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import "UIGestureRecognizer+VAPUtil.h"
#import <objc/runtime.h>
#import "QGVAPSafeMutableArray.h"
static const int vap_block_key;
@interface _VAPUIGestureRecognizerBlockTarget : NSObject
@property (nonatomic, copy) void (^block)(id sender);
- (id)initWithBlock:(void (^)(id sender))block;
- (void)invoke:(id)sender;
@end
@implementation _VAPUIGestureRecognizerBlockTarget
- (id)initWithBlock:(void (^)(id sender))block{
if (self = [super init]) {
_block = [block copy];
}
return self;
}
- (void)invoke:(id)sender {
if (_block) _block(sender);
}
@end
@implementation UIGestureRecognizer (VAPUtil)
- (instancetype)initWithVapActionBlock:(void (^)(id sender))block {
if (self = [self init]) {
[self addVapActionBlock:block];
}
return self;
}
- (void)addVapActionBlock:(void (^)(id sender))block {
_VAPUIGestureRecognizerBlockTarget *target = [[_VAPUIGestureRecognizerBlockTarget alloc] initWithBlock:block];
[self addTarget:target action:@selector(invoke:)];
NSMutableArray *targets = [self _vap_allUIGestureRecognizerBlockTargets];
[targets addObject:target];
}
- (NSMutableArray *)_vap_allUIGestureRecognizerBlockTargets {
NSMutableArray *targets = objc_getAssociatedObject(self, &vap_block_key);
if (!targets) {
targets = [QGVAPSafeMutableArray new];
objc_setAssociatedObject(self, &vap_block_key, targets, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return targets;
}
- (void)removeAllVapActionBlocks {
NSMutableArray *targets = [self _vap_allUIGestureRecognizerBlockTargets];
[targets enumerateObjectsUsingBlock:^(id target, NSUInteger idx, BOOL *stop) {
[self removeTarget:target action:@selector(invoke:)];
}];
[targets removeAllObjects];
}
@end
@@ -0,0 +1,25 @@
// UIView+MP4HWDecode.h
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
#import "UIView+VAP.h"
NS_ASSUME_NONNULL_BEGIN
@interface UIView (MP4HWDecode)
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,20 @@
// UIView+MP4HWDecode.m
// Tencent is pleased to support the open source community by making vap available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
#import "UIView+MP4HWDecode.h"
@implementation UIView (MP4HWDecode)
@end