-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,255 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
SensorsAnalyticsSDK/Core/AutoTrack/ElementInfo/SAViewElementInfo.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// SAViewElementInfo.h | ||
// SensorsAnalyticsSDK | ||
// | ||
// Created by yuqiang on 2021/2/18. | ||
// Copyright © 2021 Sensors Data Co., Ltd. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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 "SAAutoTrackProperty.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface SAViewElementInfo : NSObject | ||
|
||
@property (nonatomic, weak) UIView *view; | ||
|
||
- (instancetype)initWithView:(UIView *)view; | ||
|
||
- (NSString *)elementType; | ||
|
||
- (BOOL)isSupportElementPosition; | ||
|
||
- (BOOL)isVisualView; | ||
|
||
@end | ||
|
||
@interface SAAlertElementInfo : SAViewElementInfo | ||
@end | ||
|
||
@interface SAMenuElementInfo : SAViewElementInfo | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
114 changes: 114 additions & 0 deletions
114
SensorsAnalyticsSDK/Core/AutoTrack/ElementInfo/SAViewElementInfo.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// | ||
// SAViewElementInfo.m | ||
// SensorsAnalyticsSDK | ||
// | ||
// Created by yuqiang on 2021/2/18. | ||
// Copyright © 2021 Sensors Data Co., Ltd. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
|
||
#if ! __has_feature(objc_arc) | ||
#error This file must be compiled with ARC. Either turn on ARC for the project or use -fobjc-arc flag on this file. | ||
#endif | ||
|
||
#import "SAViewElementInfo.h" | ||
#import "SAModuleManager.h" | ||
|
||
#pragma mark - View Element Type | ||
@implementation SAViewElementInfo | ||
|
||
- (instancetype)initWithView:(UIView *)view { | ||
if (self = [super init]) { | ||
self.view = view; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSString *)elementType { | ||
return NSStringFromClass(self.view.class); | ||
} | ||
|
||
- (BOOL)isSupportElementPosition { | ||
return YES; | ||
} | ||
|
||
- (BOOL)isVisualView { | ||
if (!self.view.userInteractionEnabled || self.view.alpha <= 0.01 || self.view.isHidden) { | ||
return NO; | ||
} | ||
return [SAModuleManager.sharedInstance isGestureVisualView:self.view]; | ||
} | ||
|
||
@end | ||
|
||
#pragma mark - Alert Element Type | ||
@implementation SAAlertElementInfo | ||
|
||
- (NSString *)elementType { | ||
#ifndef SENSORS_ANALYTICS_DISABLE_PRIVATE_APIS | ||
UIWindow *window = self.view.window; | ||
if ([NSStringFromClass(window.class) isEqualToString:@"_UIAlertControllerShimPresenterWindow"]) { | ||
CGFloat actionHeight = self.view.bounds.size.height; | ||
if (actionHeight > 50) { | ||
return NSStringFromClass(UIActionSheet.class); | ||
} else { | ||
return NSStringFromClass(UIAlertView.class); | ||
} | ||
} else { | ||
return NSStringFromClass(UIAlertController.class); | ||
} | ||
#else | ||
return NSStringFromClass(UIAlertController.class); | ||
#endif | ||
} | ||
|
||
- (BOOL)isSupportElementPosition { | ||
return NO; | ||
} | ||
|
||
- (BOOL)isVisualView { | ||
if (SAModuleManager.sharedInstance.gestureManager) { | ||
return YES; | ||
} | ||
return [super isVisualView]; | ||
} | ||
|
||
@end | ||
|
||
#pragma mark - Menu Element Type | ||
@implementation SAMenuElementInfo | ||
|
||
- (NSString *)elementType { | ||
if (@available(iOS 13.0, *)) { | ||
return NSStringFromClass(UIMenu.class); | ||
} | ||
return nil; | ||
} | ||
|
||
- (BOOL)isSupportElementPosition { | ||
return NO; | ||
} | ||
|
||
- (BOOL)isVisualView { | ||
// 在 iOS 14 中, 应当圈选 UICollectionViewCell | ||
if ([self.view.superview isKindOfClass:UICollectionViewCell.class]) { | ||
return NO; | ||
} | ||
if (SAModuleManager.sharedInstance.gestureManager) { | ||
return YES; | ||
} | ||
return [super isVisualView]; | ||
} | ||
|
||
@end |
32 changes: 32 additions & 0 deletions
32
SensorsAnalyticsSDK/Core/AutoTrack/ElementInfo/SAViewElementInfoFactory.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// SAViewElementInfoFactory.h | ||
// SensorsAnalyticsSDK | ||
// | ||
// Created by yuqiang on 2021/2/18. | ||
// Copyright © 2021 Sensors Data Co., Ltd. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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 "SAViewElementInfo.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface SAViewElementInfoFactory : NSObject | ||
|
||
+ (SAViewElementInfo *)elementInfoWithView:(UIView *)view; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
42 changes: 42 additions & 0 deletions
42
SensorsAnalyticsSDK/Core/AutoTrack/ElementInfo/SAViewElementInfoFactory.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// SAViewElementInfoFactory.m | ||
// SensorsAnalyticsSDK | ||
// | ||
// Created by yuqiang on 2021/2/18. | ||
// Copyright © 2021 Sensors Data Co., Ltd. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
|
||
#if ! __has_feature(objc_arc) | ||
#error This file must be compiled with ARC. Either turn on ARC for the project or use -fobjc-arc flag on this file. | ||
#endif | ||
|
||
#import "SAViewElementInfoFactory.h" | ||
|
||
@implementation SAViewElementInfoFactory | ||
|
||
+ (SAViewElementInfo *)elementInfoWithView:(UIView *)view { | ||
NSString *viewType = NSStringFromClass(view.class); | ||
if ([viewType isEqualToString:@"_UIInterfaceActionCustomViewRepresentationView"] || | ||
[viewType isEqualToString:@"_UIAlertControllerCollectionViewCell"]) { | ||
return [[SAAlertElementInfo alloc] initWithView:view]; | ||
} | ||
if ([viewType isEqualToString:@"_UIContextMenuActionView"] || | ||
[viewType isEqualToString:@"_UIContextMenuActionsListCell"]) { | ||
return [[SAMenuElementInfo alloc] initWithView:view]; | ||
} | ||
return [[SAViewElementInfo alloc] initWithView:view]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.