Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f041002e73 | |||
| 0da49c1eb6 | |||
| a3a84b0cd7 | |||
| 33be034e2b | |||
| f590263d9f | |||
| a1c378a9d5 |
@@ -173,7 +173,7 @@ NSString *const kFLEXNetworkRecorderResponseCacheLimitDefaultsKey = @"com.flex.r
|
||||
}
|
||||
|
||||
NSString *mimeType = transaction.response.MIMEType;
|
||||
if ([mimeType hasPrefix:@"image/"]) {
|
||||
if ([mimeType hasPrefix:@"image/"] && [responseBody length] > 0) {
|
||||
// Thumbnail image previews on a separate background queue
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
NSInteger maxPixelDimension = [[UIScreen mainScreen] scale] * 32.0;
|
||||
|
||||
@@ -53,6 +53,7 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
if (self) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleTransactionUpdatedNotification:) name:kFLEXNetworkRecorderTransactionUpdatedNotification object:nil];
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Copy" style:UIBarButtonItemStylePlain target:self action:@selector(copyButtonPressed:)];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -117,6 +118,30 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)copyButtonPressed:(id)sender
|
||||
{
|
||||
NSMutableString *requestDetailString = [NSMutableString string];
|
||||
|
||||
for (FLEXNetworkDetailSection *section in self.sections) {
|
||||
if ([section.rows count] > 0) {
|
||||
if ([section.title length] > 0) {
|
||||
[requestDetailString appendString:section.title];
|
||||
[requestDetailString appendString:@"\n\n"];
|
||||
}
|
||||
for (FLEXNetworkDetailRow *row in section.rows) {
|
||||
NSString *rowDescription = [[[self class] attributedTextForRow:row] string];
|
||||
if ([rowDescription length] > 0) {
|
||||
[requestDetailString appendString:rowDescription];
|
||||
[requestDetailString appendString:@"\n"];
|
||||
}
|
||||
}
|
||||
[requestDetailString appendString:@"\n\n"];
|
||||
}
|
||||
}
|
||||
|
||||
[[UIPasteboard generalPasteboard] setString:requestDetailString];
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
@@ -179,6 +204,26 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
|
||||
return [sectionModel.rows objectAtIndex:indexPath.row];
|
||||
}
|
||||
|
||||
#pragma mark - Cell Copying
|
||||
|
||||
- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
|
||||
{
|
||||
return action == @selector(copy:);
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
|
||||
{
|
||||
if (action == @selector(copy:)) {
|
||||
FLEXNetworkDetailRow *row = [self rowModelAtIndexPath:indexPath];
|
||||
[[UIPasteboard generalPasteboard] setString:row.detailText];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - View Configuration
|
||||
|
||||
+ (NSAttributedString *)attributedTextForRow:(FLEXNetworkDetailRow *)row
|
||||
@@ -400,7 +445,7 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
|
||||
{
|
||||
// FIXME (RKO): Don't rely on UTF8 string encoding
|
||||
UIViewController *detailViewController = nil;
|
||||
if ([mimeType isEqual:@"application/json"] || [mimeType isEqual:@"application/javascript"] || [mimeType isEqual:@"text/javascript"]) {
|
||||
if ([FLEXUtility isValidJSONData:data]) {
|
||||
NSString *prettyJSON = [FLEXUtility prettyJSONStringFromData:data];
|
||||
if ([prettyJSON length] > 0) {
|
||||
detailViewController = [[FLEXWebViewController alloc] initWithText:prettyJSON];
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
+ (NSString *)statusCodeStringFromURLResponse:(NSURLResponse *)response;
|
||||
+ (NSDictionary *)dictionaryFromQuery:(NSString *)query;
|
||||
+ (NSString *)prettyJSONStringFromData:(NSData *)data;
|
||||
+ (BOOL)isValidJSONData:(NSData *)data;
|
||||
+ (NSData *)inflatedDataFromCompressedData:(NSData *)compressedData;
|
||||
|
||||
@end
|
||||
|
||||
@@ -278,10 +278,15 @@
|
||||
} else {
|
||||
prettyString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
|
||||
return prettyString;
|
||||
}
|
||||
|
||||
+ (BOOL)isValidJSONData:(NSData *)data
|
||||
{
|
||||
return [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL] ? YES : NO;
|
||||
}
|
||||
|
||||
// Thanks to the following links for help with this method
|
||||
// http://www.cocoanetics.com/2012/02/decompressing-files-into-memory/
|
||||
// https://github.com/nicklockwood/GZIP
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = "FLEX"
|
||||
spec.version = "2.0.1"
|
||||
spec.version = "2.0.2"
|
||||
spec.summary = "A set of in-app debugging and exploration tools for iOS"
|
||||
spec.description = <<-DESC
|
||||
- Inspect and modify views in the hierarchy.
|
||||
|
||||
Reference in New Issue
Block a user