Skip to content

Commit 6389a7e

Browse files
authored
Merge pull request #9 from HDB-Li/screenShot
Screen Shot function.
2 parents 4b60ac9 + d9cc83b commit 6389a7e

File tree

98 files changed

+2593
-192
lines changed

Some content is hidden

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

98 files changed

+2593
-192
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ xcuserdata/
3434
# you should judge for yourself, the pros and cons are mentioned at:
3535
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
3636
#
37-
# Pods/
37+
Pods/
38+
Podfile.lock
3839

3940
# Carthage
4041
#

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
## [1.1.0](https://github.com/HDB-Li/LLDebugTool/releases/tag/1.1.0) (06/07/2018)
2+
3+
### Add screenshot function.
4+
5+
Increases the need to the permissions of the album, but it is not necessary, if the project has the authority, save will be synchronized to photo album, if the project doesn't have the permission, is saved into the sandbox alone, LLDebugTool will not actively apply for album permissions.
6+
7+
<div align="left">
8+
<img src="https://raw.githubusercontent.com/HDB-Li/HDBImageRepository/master/LLDebugTool/ScreenGif-Screenshot.gif" width="20%"></img>
9+
</div>
10+
11+
#### Add
12+
13+
* Add `LLScreenshotHelper` in `Helper` folder, used to control screenshot.
14+
* Add `LLScreenshotView` folder in `UserInterface/Others` folder, used to show and draw screenshot.
15+
* Add `LLDebugToolMacros.h`, used to manage public macros.
16+
17+
#### Update
18+
19+
* Update `LLBaseNavigationController` and `LLBaseViewController` to repair toolbar's frame is wrong when hiding tabbar.
20+
* Update `LLAppHelper` to fix iPhone X getting network status error.
21+
* Remove `LLog` macros in `LLDebugTool.h` and moved to `LLDebugToolMacros.h`
22+
23+
#### Additional Changes
24+
25+
* Update demo for saving screenshots to photo albums when screenshots are taken.
26+
127
## [1.0.3](https://github.com/HDB-Li/LLDebugTool/releases/tag/1.0.3) (05/31/2018)
228

329
Fix some leaks.

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.0.3"
3+
s.version = "1.1.0"
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/DebugTool/LLDebugTool.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@
2626

2727
#ifndef LLSharedDebugTool
2828
#define LLSharedDebugTool [LLDebugTool sharedTool]
29-
#define LLog(fmt, ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelDefault onEvent:nil message:(fmt, ##__VA_ARGS__)]
30-
#define LLog_Event(event , fmt , ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelDefault onEvent:event message:(fmt, ##__VA_ARGS__)]
31-
#define LLog_Alert(fmt, ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelAlert onEvent:nil message:(fmt, ##__VA_ARGS__)]
32-
#define LLog_Alert_Event(event, fmt , ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelAlert onEvent:event message:(fmt, ##__VA_ARGS__)]
33-
#define LLog_Warning(fmt, ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelWarning onEvent:nil message:(fmt, ##__VA_ARGS__)]
34-
#define LLog_Warning_Event(event, fmt , ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelWarning onEvent:event message:(fmt, ##__VA_ARGS__)]
35-
#define LLog_Error(fmt, ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelError onEvent:nil message:(fmt, ##__VA_ARGS__)]
36-
#define LLog_Error_Event(event, fmt , ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelError onEvent:event message:(fmt, ##__VA_ARGS__)]
3729
#endif
3830

3931
@class LLWindow;

LLDebugTool/DebugTool/LLDebugTool.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@
2222
// SOFTWARE.
2323

2424
#import "LLDebugTool.h"
25+
#import "LLScreenshotHelper.h"
2526
#import "LLStorageManager.h"
2627
#import "LLNetworkHelper.h"
2728
#import "LLCrashHelper.h"
29+
#import "LLLogHelper.h"
2830
#import "LLAppHelper.h"
2931
#import "LLWindow.h"
30-
#import "LLLogHelper.h"
31-
32-
3332

3433
static LLDebugTool *_instance = nil;
3534

@@ -65,6 +64,8 @@ - (void)startWorking{
6564
[[LLNetworkHelper sharedHelper] setEnable:YES];
6665
// Open app monitoring
6766
[[LLAppHelper sharedHelper] startMonitoring];
67+
// Open screenshot
68+
[[LLScreenshotHelper sharedHelper] setEnable:YES];
6869
// show window
6970
[self.window showWindow];
7071
}
@@ -75,6 +76,8 @@ - (void)stopWorking {
7576
_isWorking = NO;
7677
// Close app monitoring
7778
[[LLAppHelper sharedHelper] stopMonitoring];
79+
// Close screenshot
80+
[[LLScreenshotHelper sharedHelper] setEnable:NO];
7881
// Close network monitoring
7982
[[LLNetworkHelper sharedHelper] setEnable:NO];
8083
// Close log helper
@@ -87,7 +90,7 @@ - (void)stopWorking {
8790
}
8891

8992
- (NSString *)version {
90-
return @"1.0.3";
93+
return @"1.1.0";
9194
}
9295

9396
- (void)showDebugViewControllerWithIndex:(NSInteger)index {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// LLDebugToolMacros.h
3+
//
4+
// Copyright (c) 2018 LLDebugTool Software Foundation (https://github.com/HDB-Li/LLDebugTool)
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
24+
#ifndef LLDebugToolMacros_h
25+
#define LLDebugToolMacros_h
26+
27+
#define LLog(fmt, ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelDefault onEvent:nil message:(fmt, ##__VA_ARGS__)]
28+
#define LLog_Event(event , fmt , ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelDefault onEvent:event message:(fmt, ##__VA_ARGS__)]
29+
#define LLog_Alert(fmt, ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelAlert onEvent:nil message:(fmt, ##__VA_ARGS__)]
30+
#define LLog_Alert_Event(event, fmt , ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelAlert onEvent:event message:(fmt, ##__VA_ARGS__)]
31+
#define LLog_Warning(fmt, ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelWarning onEvent:nil message:(fmt, ##__VA_ARGS__)]
32+
#define LLog_Warning_Event(event, fmt , ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelWarning onEvent:event message:(fmt, ##__VA_ARGS__)]
33+
#define LLog_Error(fmt, ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelError onEvent:nil message:(fmt, ##__VA_ARGS__)]
34+
#define LLog_Error_Event(event, fmt , ...) [LLSharedDebugTool logInFile:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] function:NSStringFromSelector(_cmd) lineNo:__LINE__ level:LLConfigLogLevelError onEvent:event message:(fmt, ##__VA_ARGS__)]
35+
36+
/*
37+
// If you only use LLDebugTool in Debug environment, you can copy the following part to your PCH file to resolve most Release environment errors.
38+
39+
#ifndef DEBUG
40+
#define LLog(fmt, ...) NSLog(fmt)
41+
#define LLog_Event(event , fmt , ...) NSLog(fmt)
42+
#define LLog_Alert(fmt, ...) NSLog(fmt)
43+
#define LLog_Alert_Event(event, fmt , ...) NSLog(fmt)
44+
#define LLog_Warning(fmt, ...) NSLog(fmt)
45+
#define LLog_Warning_Event(event, fmt , ...) NSLog(fmt)
46+
#define LLog_Error(fmt, ...) NSLog(fmt)
47+
#define LLog_Error_Event(event, fmt , ...) NSLog(fmt)
48+
#endif
49+
50+
*/
51+
52+
#endif /* LLDebugToolMacros_h */

LLDebugTool/Helper/AppHelper/LLAppHelper.m

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -332,54 +332,59 @@ - (NSString *)currentWifiSSID
332332
}
333333

334334
- (NSString *)networkingStatesFromStatebar {
335+
NSString *stateString = @"Unknown";
335336
UIApplication *app = [UIApplication sharedApplication];
336337

337-
NSArray *children;
338338
if ([[app valueForKeyPath:@"_statusBar"] isKindOfClass:NSClassFromString(@"UIStatusBar_Modern")]) {
339-
children = [[[[app valueForKeyPath:@"_statusBar"] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
339+
// For iPhoneX
340+
NSArray *children = [[[[app valueForKeyPath:@"_statusBar"] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
341+
for (UIView *view in children) {
342+
for (id child in view.subviews) {
343+
if ([child isKindOfClass:NSClassFromString(@"_UIStatusBarWifiSignalView")]) {
344+
stateString = @"WIFI";
345+
break;
346+
}
347+
if ([child isKindOfClass:NSClassFromString(@"_UIStatusBarStringView")]) {
348+
if ([[child valueForKey:@"_originalText"] containsString:@"G"]) {
349+
stateString = [child valueForKey:@"_originalText"];
350+
break;
351+
}
352+
}
353+
}
354+
}
340355
} else {
341-
children = [[[app valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
342-
}
343-
344-
int type = 0;
345-
for (id child in children) {
346-
if ([child isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
347-
type = [[child valueForKeyPath:@"dataNetworkType"] intValue];
356+
// For others iPhone
357+
NSArray *children = [[[app valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
358+
int type = -1;
359+
for (id child in children) {
360+
if ([child isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
361+
type = [[child valueForKeyPath:@"dataNetworkType"] intValue];
362+
}
363+
}
364+
switch (type) {
365+
case 0:
366+
stateString = @"Not Reachable";
367+
break;
368+
case 1:
369+
stateString = @"2G";
370+
break;
371+
case 2:
372+
stateString = @"3G";
373+
break;
374+
case 3:
375+
stateString = @"4G";
376+
break;
377+
case 4:
378+
stateString = @"LTE";
379+
break;
380+
case 5:
381+
stateString = @"WIFI";
382+
break;
383+
default:
384+
stateString = @"Unknown";
385+
break;
348386
}
349387
}
350-
351-
NSString *stateString = @"wifi";
352-
353-
switch (type) {
354-
case 0:
355-
stateString = @"notReachable";
356-
break;
357-
358-
case 1:
359-
stateString = @"2G";
360-
break;
361-
362-
case 2:
363-
stateString = @"3G";
364-
break;
365-
366-
case 3:
367-
stateString = @"4G";
368-
break;
369-
370-
case 4:
371-
stateString = @"LTE";
372-
break;
373-
374-
case 5:
375-
stateString = @"wifi";
376-
break;
377-
378-
default:
379-
stateString = @"unknown";
380-
break;
381-
}
382-
383388
return stateString;
384389
}
385390

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// LLScreenshotHelper.h
3+
//
4+
// Copyright (c) 2018 LLDebugTool Software Foundation (https://github.com/HDB-Li/LLDebugTool)
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
24+
#import <Foundation/Foundation.h>
25+
26+
@interface LLScreenshotHelper : NSObject
27+
28+
/**
29+
Singleton to control screenshot.
30+
31+
@return Singleton
32+
*/
33+
+ (instancetype)sharedHelper;
34+
35+
/**
36+
Set enable to screenshot.
37+
*/
38+
@property (nonatomic , assign) BOOL enable;
39+
40+
/**
41+
Simulate user screenshot.
42+
*/
43+
- (void)simulateTakeScreenshot;
44+
45+
@end

0 commit comments

Comments
 (0)