Skip to content

Commit 8cd5f78

Browse files
authored
Merge pull request #73 from HDB-Li/1.3.3-b
1.3.3
2 parents 0aa56c3 + ba1d557 commit 8cd5f78

File tree

70 files changed

+1855
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1855
-159
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [1.3.3](https://github.com/HDB-Li/LLDebugTool/releases/tag/1.3.3) (10/18/2019)
2+
3+
### Add `Html` function.
4+
5+
You can debug HTML pages through `WKWebView`, `UIWebView` or your customized `ViewController` in your app at any time.
6+
7+
#### Add
8+
9+
* Now `LLURLProtocol` can correctly observe `WKWebView`.
10+
111
## [1.3.2](https://github.com/HDB-Li/LLDebugTool/releases/tag/1.3.2) (09/29/2019)
212

313
### Add `Ruler`, `Widget Border` function.

LLDebugTool.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "LLDebugTool"
3-
s.version = "1.3.2"
3+
s.version = "1.3.3"
44
s.summary = "LLDebugTool is a debugging tool for developers and testers that can help you analyze and manipulate data in non-xcode situations."
55
s.homepage = "https://github.com/HDB-Li/LLDebugTool"
66
s.license = "MIT"

LLDebugTool/Core/Component/Crash/UserInterface/LLCrashViewController.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
112112
}
113113
}
114114

115-
#pragma mark - UISearchController
116-
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
117-
[super searchBar:searchBar textDidChange:searchText];
118-
if (searchText.length == 0) {
115+
#pragma mark - UITextFieldDelegate
116+
- (void)textFieldDidChange:(NSString *)text {
117+
[super textFieldDidChange:text];
118+
if (text.length == 0) {
119119
[self.searchDataArray removeAllObjects];
120120
[self.searchDataArray addObjectsFromArray:self.oriDataArray];
121121
[self.tableView reloadData];
122122
} else {
123123
[self.searchDataArray removeAllObjects];
124124
for (LLCrashModel *model in self.oriDataArray) {
125-
if ([model.name.lowercaseString containsString:searchText.lowercaseString] || [model.reason.lowercaseString containsString:searchText.lowercaseString]) {
125+
if ([model.name.lowercaseString containsString:text.lowercaseString] || [model.reason.lowercaseString containsString:text.lowercaseString]) {
126126
[self.searchDataArray addObject:model];
127127
}
128128
}

LLDebugTool/Core/Component/Function/UserInterface/LLFunctionItemModel.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#import "LLMagnifierComponent.h"
3636
#import "LLRulerComponent.h"
3737
#import "LLWidgetBorderComponent.h"
38+
#import "LLHtmlComponent.h"
3839
#import "LLSettingComponent.h"
3940
#import "LLImageNameConfig.h"
4041

@@ -78,6 +79,8 @@ - (LLComponent *)componentFromAction:(LLDebugToolAction)action {
7879
return [[LLRulerComponent alloc] init];
7980
case LLDebugToolActionWidgetBorder:
8081
return [[LLWidgetBorderComponent alloc] init];
82+
case LLDebugToolActionHtml:
83+
return [[LLHtmlComponent alloc] init];
8184
}
8285
}
8386

@@ -109,6 +112,8 @@ - (NSString *)titleFromAction:(LLDebugToolAction)action {
109112
return @"Ruler";
110113
case LLDebugToolActionWidgetBorder:
111114
return @"Widget Border";
115+
case LLDebugToolActionHtml:
116+
return @"Html5";
112117
}
113118
}
114119

@@ -138,6 +143,8 @@ - (NSString *)imageNameFromAction:(LLDebugToolAction)action {
138143
return kRulerImageName;
139144
case LLDebugToolActionWidgetBorder:
140145
return kWidgetBorderImageName;
146+
case LLDebugToolActionHtml:
147+
return kHtml5ImageName;
141148
}
142149
}
143150

LLDebugTool/Core/Component/Function/UserInterface/LLFunctionViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ - (void)loadData {
106106
[items addObject:[[LLFunctionItemModel alloc] initWithAction:LLDebugToolActionMagnifier]];
107107
[items addObject:[[LLFunctionItemModel alloc] initWithAction:LLDebugToolActionRuler]];
108108
[items addObject:[[LLFunctionItemModel alloc] initWithAction:LLDebugToolActionWidgetBorder]];
109-
109+
[items addObject:[[LLFunctionItemModel alloc] initWithAction:LLDebugToolActionHtml]];
110110

111111
self.shortCutContainerView.dataArray = [items copy];
112112
self.shortCutContainerView.title = @"Short Cut";
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// LLHtmlComponent.h
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
#import "LLComponent.h"
23+
24+
NS_ASSUME_NONNULL_BEGIN
25+
26+
@interface LLHtmlComponent : LLComponent
27+
28+
@end
29+
30+
NS_ASSUME_NONNULL_END
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// LLHtmlComponent.m
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
#import "LLHtmlComponent.h"
23+
#import "LLWindowManager.h"
24+
#import "LLNavigationController.h"
25+
26+
@implementation LLHtmlComponent
27+
28+
- (void)componentDidLoad:(NSDictionary<NSString *,id> *)data {
29+
LLHtmlWindow *window = [LLWindowManager htmlWindow];
30+
if (data[kLLComponentWindowRootViewControllerKey]) {
31+
Class rootViewControllerClass = NSClassFromString(data[kLLComponentWindowRootViewControllerKey]);
32+
if (rootViewControllerClass != nil) {
33+
UIViewController *viewController = [[rootViewControllerClass alloc] init];
34+
NSDictionary *properties = data[kLLComponentWindowRootViewControllerPropertiesKey];
35+
for (NSString *key in properties) {
36+
id value = properties[key];
37+
[viewController setValue:value forKey:key];
38+
}
39+
LLNavigationController *nav = [[LLNavigationController alloc] initWithRootViewController:viewController];
40+
window.rootViewController = nav;
41+
}
42+
}
43+
[[LLWindowManager shared] showWindow:window animated:YES];
44+
}
45+
46+
@end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// LLHtmlConfigViewController.h
3+
// LLDebugToolDemo
4+
//
5+
// Created by admin10000 on 2019/10/11.
6+
// Copyright © 2019 li. All rights reserved.
7+
//
8+
9+
#import "LLTitleViewController.h"
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface LLHtmlConfigViewController : LLTitleViewController
14+
15+
@end
16+
17+
NS_ASSUME_NONNULL_END
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
//
2+
// LLHtmlConfigViewController.m
3+
// LLDebugToolDemo
4+
//
5+
// Created by admin10000 on 2019/10/11.
6+
// Copyright © 2019 li. All rights reserved.
7+
//
8+
9+
#import "LLHtmlConfigViewController.h"
10+
#import "LLTitleCellCategoryModel.h"
11+
#import "LLSettingManager.h"
12+
#import "LLFactory.h"
13+
#import "LLMacros.h"
14+
#import "LLConst.h"
15+
#import "UIView+LL_Utils.h"
16+
#import "LLThemeManager.h"
17+
#import "LLToastUtils.h"
18+
#import "LLHtmlViewController.h"
19+
#import "LLHtmlUIWebViewController.h"
20+
#import "LLHtmlWkWebViewController.h"
21+
#import "LLConfig.h"
22+
#import <WebKit/WebKit.h>
23+
24+
@interface LLHtmlConfigViewController () <UITextFieldDelegate>
25+
26+
@property (nonatomic, copy) NSString *webViewClass;
27+
28+
@property (nonatomic, strong) UIView *headerView;
29+
30+
@property (nonatomic, strong) UITextField *headerTextField;
31+
32+
@end
33+
34+
@implementation LLHtmlConfigViewController
35+
36+
#pragma mark - Life cycle
37+
- (void)viewDidLoad {
38+
[super viewDidLoad];
39+
[self setUpUI];
40+
[self loadData];
41+
}
42+
43+
- (void)viewWillDisappear:(BOOL)animated {
44+
if ([self.headerTextField isFirstResponder]) {
45+
[self.headerTextField resignFirstResponder];
46+
}
47+
}
48+
49+
#pragma mark - Over write
50+
- (void)rightItemClick:(UIButton *)sender {
51+
NSString *urlString = [self currentUrlString];
52+
if (!urlString) {
53+
[[LLToastUtils shared] toastMessage:@"Empty URL"];
54+
return;
55+
}
56+
if (![urlString.lowercaseString hasPrefix:@"https://"] && ![urlString.lowercaseString hasPrefix:@"http://"]) {
57+
[[LLToastUtils shared] toastMessage:@"URL must has prefix with https:// or http://"];
58+
return;
59+
}
60+
Class cls = NSClassFromString(self.webViewClass);
61+
#pragma clang diagnostic push
62+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
63+
if (cls != [UIWebView class] && cls != [WKWebView class]) {
64+
#pragma clang diagnostic pop
65+
[[LLToastUtils shared] toastMessage:@"Invalid webView class"];
66+
return;
67+
}
68+
69+
[LLSettingManager shared].lastWebViewUrl = urlString;
70+
71+
LLHtmlViewController *vc = nil;
72+
#pragma clang diagnostic push
73+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
74+
if (cls == [UIWebView class]) {
75+
#pragma clang diagnostic pop
76+
vc = [[LLHtmlUIWebViewController alloc] init];
77+
} else {
78+
vc = [[LLHtmlWkWebViewController alloc] init];
79+
}
80+
vc.webViewClass = self.webViewClass;
81+
vc.urlString = [self currentUrlString];
82+
[self.navigationController pushViewController:vc animated:YES];
83+
}
84+
85+
#pragma mark - UITextFieldDelegate
86+
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
87+
[textField resignFirstResponder];
88+
return YES;
89+
}
90+
91+
#pragma mark - Primary
92+
- (void)setUpUI {
93+
self.title = @"WebView Config";
94+
[self initNavigationItemWithTitle:@"Go" imageName:nil isLeft:NO];
95+
96+
self.webViewClass = [LLSettingManager shared].webViewClass ?: NSStringFromClass([WKWebView class]);
97+
98+
self.tableView.tableHeaderView = self.headerView;
99+
}
100+
101+
- (void)loadData {
102+
NSMutableArray *settings = [[NSMutableArray alloc] init];
103+
104+
// Short Cut
105+
[settings addObject:[self getWebViewStyleModel]];
106+
LLTitleCellCategoryModel *category0 = [[LLTitleCellCategoryModel alloc] initWithTitle:nil items:settings];
107+
[settings removeAllObjects];
108+
109+
[self.dataArray removeAllObjects];
110+
[self.dataArray addObjectsFromArray:@[category0]];
111+
[self.tableView reloadData];
112+
}
113+
114+
- (LLTitleCellModel *)getWebViewStyleModel {
115+
LLTitleCellModel *model = [[LLTitleCellModel alloc] initWithTitle:@"Style" detailTitleSelector:self.webViewClass];
116+
__weak typeof(self) weakSelf = self;
117+
model.block = ^{
118+
[weakSelf showWebViewClassAlert];
119+
};
120+
return model;
121+
}
122+
123+
- (void)showWebViewClassAlert {
124+
__block NSMutableArray *actions = [[NSMutableArray alloc] init];
125+
[actions addObject:NSStringFromClass([WKWebView class])];
126+
#pragma clang diagnostic push
127+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
128+
[actions addObject:NSStringFromClass([UIWebView class])];
129+
#pragma clang diagnostic pop
130+
__weak typeof(self) weakSelf = self;
131+
[self showActionSheetWithTitle:@"Web View Style" actions:actions currentAction:self.webViewClass completion:^(NSInteger index) {
132+
[weakSelf setNewWebViewClass:actions[index]];
133+
}];
134+
}
135+
136+
- (void)setNewWebViewClass:(NSString *)aClass {
137+
self.webViewClass = aClass;
138+
[LLSettingManager shared].webViewClass = aClass;
139+
[self loadData];
140+
}
141+
142+
- (NSString *)currentUrlString {
143+
NSString *text = self.headerTextField.text;
144+
text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
145+
if (!text || text.length == 0) {
146+
return nil;
147+
}
148+
return text;
149+
}
150+
151+
#pragma mark - Getters and setters
152+
- (UIView *)headerView {
153+
if (!_headerView) {
154+
_headerView = [LLFactory getView];
155+
_headerView.frame = CGRectMake(0, 0, LL_SCREEN_WIDTH, 60);
156+
[_headerView addSubview:self.headerTextField];
157+
self.headerTextField.frame = CGRectMake(kLLGeneralMargin, kLLGeneralMargin, _headerView.LL_width - kLLGeneralMargin * 2, _headerView.LL_height - kLLGeneralMargin * 2);
158+
}
159+
return _headerView;
160+
}
161+
162+
- (UITextField *)headerTextField {
163+
if (!_headerTextField) {
164+
_headerTextField = [LLFactory getTextField];
165+
_headerTextField.tintColor = [LLThemeManager shared].primaryColor;
166+
_headerTextField.backgroundColor = [LLThemeManager shared].backgroundColor;
167+
[_headerTextField LL_setBorderColor:[LLThemeManager shared].primaryColor borderWidth:1];
168+
[_headerTextField LL_setCornerRadius:5];
169+
_headerTextField.font = [UIFont systemFontOfSize:14];
170+
_headerTextField.textColor = [LLThemeManager shared].primaryColor;
171+
_headerTextField.delegate = self;
172+
_headerTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
173+
_headerTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Pleace input url" attributes:@{NSForegroundColorAttributeName : [LLThemeManager shared].placeHolderColor}];
174+
_headerTextField.text = [LLSettingManager shared].lastWebViewUrl ?: ([LLConfig shared].defaultHtmlUrl ?: @"https://");
175+
UIView *leftView = [LLFactory getView];
176+
leftView.frame = CGRectMake(0, 0, 10, 1);
177+
_headerTextField.leftView = leftView;
178+
_headerTextField.leftViewMode = UITextFieldViewModeAlways;
179+
}
180+
return _headerTextField;
181+
}
182+
183+
@end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// LLHtmlUIWebViewController.h
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
#import "LLHtmlViewController.h"
23+
24+
NS_ASSUME_NONNULL_BEGIN
25+
26+
@interface LLHtmlUIWebViewController : LLHtmlViewController
27+
28+
@end
29+
30+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)