Skip to content

Commit

Permalink
Merge pull request #73 from HDB-Li/1.3.3-b
Browse files Browse the repository at this point in the history
1.3.3
  • Loading branch information
HDB-Li authored Oct 18, 2019
2 parents 0aa56c3 + ba1d557 commit 8cd5f78
Show file tree
Hide file tree
Showing 70 changed files with 1,855 additions and 159 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [1.3.3](https://github.com/HDB-Li/LLDebugTool/releases/tag/1.3.3) (10/18/2019)

### Add `Html` function.

You can debug HTML pages through `WKWebView`, `UIWebView` or your customized `ViewController` in your app at any time.

#### Add

* Now `LLURLProtocol` can correctly observe `WKWebView`.

## [1.3.2](https://github.com/HDB-Li/LLDebugTool/releases/tag/1.3.2) (09/29/2019)

### Add `Ruler`, `Widget Border` function.
Expand Down
2 changes: 1 addition & 1 deletion LLDebugTool.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LLDebugTool"
s.version = "1.3.2"
s.version = "1.3.3"
s.summary = "LLDebugTool is a debugging tool for developers and testers that can help you analyze and manipulate data in non-xcode situations."
s.homepage = "https://github.com/HDB-Li/LLDebugTool"
s.license = "MIT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}

#pragma mark - UISearchController
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
[super searchBar:searchBar textDidChange:searchText];
if (searchText.length == 0) {
#pragma mark - UITextFieldDelegate
- (void)textFieldDidChange:(NSString *)text {
[super textFieldDidChange:text];
if (text.length == 0) {
[self.searchDataArray removeAllObjects];
[self.searchDataArray addObjectsFromArray:self.oriDataArray];
[self.tableView reloadData];
} else {
[self.searchDataArray removeAllObjects];
for (LLCrashModel *model in self.oriDataArray) {
if ([model.name.lowercaseString containsString:searchText.lowercaseString] || [model.reason.lowercaseString containsString:searchText.lowercaseString]) {
if ([model.name.lowercaseString containsString:text.lowercaseString] || [model.reason.lowercaseString containsString:text.lowercaseString]) {
[self.searchDataArray addObject:model];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#import "LLMagnifierComponent.h"
#import "LLRulerComponent.h"
#import "LLWidgetBorderComponent.h"
#import "LLHtmlComponent.h"
#import "LLSettingComponent.h"
#import "LLImageNameConfig.h"

Expand Down Expand Up @@ -78,6 +79,8 @@ - (LLComponent *)componentFromAction:(LLDebugToolAction)action {
return [[LLRulerComponent alloc] init];
case LLDebugToolActionWidgetBorder:
return [[LLWidgetBorderComponent alloc] init];
case LLDebugToolActionHtml:
return [[LLHtmlComponent alloc] init];
}
}

Expand Down Expand Up @@ -109,6 +112,8 @@ - (NSString *)titleFromAction:(LLDebugToolAction)action {
return @"Ruler";
case LLDebugToolActionWidgetBorder:
return @"Widget Border";
case LLDebugToolActionHtml:
return @"Html5";
}
}

Expand Down Expand Up @@ -138,6 +143,8 @@ - (NSString *)imageNameFromAction:(LLDebugToolAction)action {
return kRulerImageName;
case LLDebugToolActionWidgetBorder:
return kWidgetBorderImageName;
case LLDebugToolActionHtml:
return kHtml5ImageName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (void)loadData {
[items addObject:[[LLFunctionItemModel alloc] initWithAction:LLDebugToolActionMagnifier]];
[items addObject:[[LLFunctionItemModel alloc] initWithAction:LLDebugToolActionRuler]];
[items addObject:[[LLFunctionItemModel alloc] initWithAction:LLDebugToolActionWidgetBorder]];

[items addObject:[[LLFunctionItemModel alloc] initWithAction:LLDebugToolActionHtml]];

self.shortCutContainerView.dataArray = [items copy];
self.shortCutContainerView.title = @"Short Cut";
Expand Down
30 changes: 30 additions & 0 deletions LLDebugTool/Core/Component/Html/LLHtmlComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// LLHtmlComponent.h
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#import "LLComponent.h"

NS_ASSUME_NONNULL_BEGIN

@interface LLHtmlComponent : LLComponent

@end

NS_ASSUME_NONNULL_END
46 changes: 46 additions & 0 deletions LLDebugTool/Core/Component/Html/LLHtmlComponent.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// LLHtmlComponent.m
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#import "LLHtmlComponent.h"
#import "LLWindowManager.h"
#import "LLNavigationController.h"

@implementation LLHtmlComponent

- (void)componentDidLoad:(NSDictionary<NSString *,id> *)data {
LLHtmlWindow *window = [LLWindowManager htmlWindow];
if (data[kLLComponentWindowRootViewControllerKey]) {
Class rootViewControllerClass = NSClassFromString(data[kLLComponentWindowRootViewControllerKey]);
if (rootViewControllerClass != nil) {
UIViewController *viewController = [[rootViewControllerClass alloc] init];
NSDictionary *properties = data[kLLComponentWindowRootViewControllerPropertiesKey];
for (NSString *key in properties) {
id value = properties[key];
[viewController setValue:value forKey:key];
}
LLNavigationController *nav = [[LLNavigationController alloc] initWithRootViewController:viewController];
window.rootViewController = nav;
}
}
[[LLWindowManager shared] showWindow:window animated:YES];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// LLHtmlConfigViewController.h
// LLDebugToolDemo
//
// Created by admin10000 on 2019/10/11.
// Copyright © 2019 li. All rights reserved.
//

#import "LLTitleViewController.h"

NS_ASSUME_NONNULL_BEGIN

@interface LLHtmlConfigViewController : LLTitleViewController

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
//
// LLHtmlConfigViewController.m
// LLDebugToolDemo
//
// Created by admin10000 on 2019/10/11.
// Copyright © 2019 li. All rights reserved.
//

#import "LLHtmlConfigViewController.h"
#import "LLTitleCellCategoryModel.h"
#import "LLSettingManager.h"
#import "LLFactory.h"
#import "LLMacros.h"
#import "LLConst.h"
#import "UIView+LL_Utils.h"
#import "LLThemeManager.h"
#import "LLToastUtils.h"
#import "LLHtmlViewController.h"
#import "LLHtmlUIWebViewController.h"
#import "LLHtmlWkWebViewController.h"
#import "LLConfig.h"
#import <WebKit/WebKit.h>

@interface LLHtmlConfigViewController () <UITextFieldDelegate>

@property (nonatomic, copy) NSString *webViewClass;

@property (nonatomic, strong) UIView *headerView;

@property (nonatomic, strong) UITextField *headerTextField;

@end

@implementation LLHtmlConfigViewController

#pragma mark - Life cycle
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpUI];
[self loadData];
}

- (void)viewWillDisappear:(BOOL)animated {
if ([self.headerTextField isFirstResponder]) {
[self.headerTextField resignFirstResponder];
}
}

#pragma mark - Over write
- (void)rightItemClick:(UIButton *)sender {
NSString *urlString = [self currentUrlString];
if (!urlString) {
[[LLToastUtils shared] toastMessage:@"Empty URL"];
return;
}
if (![urlString.lowercaseString hasPrefix:@"https://"] && ![urlString.lowercaseString hasPrefix:@"http://"]) {
[[LLToastUtils shared] toastMessage:@"URL must has prefix with https:// or http://"];
return;
}
Class cls = NSClassFromString(self.webViewClass);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (cls != [UIWebView class] && cls != [WKWebView class]) {
#pragma clang diagnostic pop
[[LLToastUtils shared] toastMessage:@"Invalid webView class"];
return;
}

[LLSettingManager shared].lastWebViewUrl = urlString;

LLHtmlViewController *vc = nil;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (cls == [UIWebView class]) {
#pragma clang diagnostic pop
vc = [[LLHtmlUIWebViewController alloc] init];
} else {
vc = [[LLHtmlWkWebViewController alloc] init];
}
vc.webViewClass = self.webViewClass;
vc.urlString = [self currentUrlString];
[self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}

#pragma mark - Primary
- (void)setUpUI {
self.title = @"WebView Config";
[self initNavigationItemWithTitle:@"Go" imageName:nil isLeft:NO];

self.webViewClass = [LLSettingManager shared].webViewClass ?: NSStringFromClass([WKWebView class]);

self.tableView.tableHeaderView = self.headerView;
}

- (void)loadData {
NSMutableArray *settings = [[NSMutableArray alloc] init];

// Short Cut
[settings addObject:[self getWebViewStyleModel]];
LLTitleCellCategoryModel *category0 = [[LLTitleCellCategoryModel alloc] initWithTitle:nil items:settings];
[settings removeAllObjects];

[self.dataArray removeAllObjects];
[self.dataArray addObjectsFromArray:@[category0]];
[self.tableView reloadData];
}

- (LLTitleCellModel *)getWebViewStyleModel {
LLTitleCellModel *model = [[LLTitleCellModel alloc] initWithTitle:@"Style" detailTitleSelector:self.webViewClass];
__weak typeof(self) weakSelf = self;
model.block = ^{
[weakSelf showWebViewClassAlert];
};
return model;
}

- (void)showWebViewClassAlert {
__block NSMutableArray *actions = [[NSMutableArray alloc] init];
[actions addObject:NSStringFromClass([WKWebView class])];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[actions addObject:NSStringFromClass([UIWebView class])];
#pragma clang diagnostic pop
__weak typeof(self) weakSelf = self;
[self showActionSheetWithTitle:@"Web View Style" actions:actions currentAction:self.webViewClass completion:^(NSInteger index) {
[weakSelf setNewWebViewClass:actions[index]];
}];
}

- (void)setNewWebViewClass:(NSString *)aClass {
self.webViewClass = aClass;
[LLSettingManager shared].webViewClass = aClass;
[self loadData];
}

- (NSString *)currentUrlString {
NSString *text = self.headerTextField.text;
text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (!text || text.length == 0) {
return nil;
}
return text;
}

#pragma mark - Getters and setters
- (UIView *)headerView {
if (!_headerView) {
_headerView = [LLFactory getView];
_headerView.frame = CGRectMake(0, 0, LL_SCREEN_WIDTH, 60);
[_headerView addSubview:self.headerTextField];
self.headerTextField.frame = CGRectMake(kLLGeneralMargin, kLLGeneralMargin, _headerView.LL_width - kLLGeneralMargin * 2, _headerView.LL_height - kLLGeneralMargin * 2);
}
return _headerView;
}

- (UITextField *)headerTextField {
if (!_headerTextField) {
_headerTextField = [LLFactory getTextField];
_headerTextField.tintColor = [LLThemeManager shared].primaryColor;
_headerTextField.backgroundColor = [LLThemeManager shared].backgroundColor;
[_headerTextField LL_setBorderColor:[LLThemeManager shared].primaryColor borderWidth:1];
[_headerTextField LL_setCornerRadius:5];
_headerTextField.font = [UIFont systemFontOfSize:14];
_headerTextField.textColor = [LLThemeManager shared].primaryColor;
_headerTextField.delegate = self;
_headerTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
_headerTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Pleace input url" attributes:@{NSForegroundColorAttributeName : [LLThemeManager shared].placeHolderColor}];
_headerTextField.text = [LLSettingManager shared].lastWebViewUrl ?: ([LLConfig shared].defaultHtmlUrl ?: @"https://");
UIView *leftView = [LLFactory getView];
leftView.frame = CGRectMake(0, 0, 10, 1);
_headerTextField.leftView = leftView;
_headerTextField.leftViewMode = UITextFieldViewModeAlways;
}
return _headerTextField;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// LLHtmlUIWebViewController.h
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#import "LLHtmlViewController.h"

NS_ASSUME_NONNULL_BEGIN

@interface LLHtmlUIWebViewController : LLHtmlViewController

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 8cd5f78

Please sign in to comment.