Procházet zdrojové kódy

improved toolbar appearance, fixed table view cell apperance for selection and also fixed hierarchy appearance as well

Kevin Bradley před 5 roky
rodič
revize
befaead484

+ 2 - 1
Classes/Core/Views/Cells/FLEXTableViewCell.m

@@ -37,8 +37,9 @@
     UIFont *cellFont = UIFont.flex_defaultTableCellFont;
     self.titleLabel.font = cellFont;
     self.subtitleLabel.font = cellFont;
+#if !TARGET_OS_TV
     self.subtitleLabel.textColor = FLEXColor.deemphasizedTextColor;
-    
+#endif
     self.titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
     self.subtitleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
     

+ 17 - 26
Classes/ExplorerInterface/FLEXExplorerViewController.m

@@ -86,6 +86,10 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 
 -(void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
     
+    if (self.currentMode != FLEXExplorerModeSelect){
+        [super pressesEnded:presses withEvent:event];
+        return;
+    }
     CGPoint point = [self.view convertPoint:cursorView.frame.origin toView:nil];
                NSLog(@"[FLEXInjected] clicked point: %@", NSStringFromCGPoint(point));
     [self updateOutlineViewsForSelectionPoint:point];
@@ -94,8 +98,6 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
         if (alertController) {
             [self.presentedViewController dismissViewControllerAnimated:true completion:nil];
         }
-        //go back?
-        //[self toggleSelectTool];
         
     }
     else if (presses.anyObject.type == UIPressTypeUpArrow) {
@@ -104,13 +106,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     }
     else if (presses.anyObject.type == UIPressTypeSelect)
     {
-        //if(self.currentMode == FLEXExplorerModeSelect){
-            //[self toggleMode];
-        //} else {
-            /* x. */
-            CGPoint point = [self.view convertPoint:cursorView.frame.origin toView:nil];
-            NSLog(@"[FLEXInjected] clicked point: %@", NSStringFromCGPoint(point));
-        //}
+    
     }
     
     else if (presses.anyObject.type == UIPressTypePlayPause)
@@ -119,8 +115,6 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
         if (alertController)
         {
             [self.presentedViewController dismissViewControllerAnimated:true completion:nil];
-        } else {
-            
         }
     }
 }
@@ -227,25 +221,22 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     longPress.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypePlayPause]];
     [self.view addGestureRecognizer:longPress];
     [self.view addSubview:cursorView];
+    
+    UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
+    doubleTap.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypePlayPause], [NSNumber numberWithInteger:UIPressTypeSelect]];
+    [self.view addGestureRecognizer:doubleTap];
 }
 
+- (void)doubleTap:(UITapGestureRecognizer *)gesture {
+    if (gesture.state == UIGestureRecognizerStateEnded) {
+        if (self.currentMode == FLEXExplorerModeSelect){
+            [self toggleViewsTool];
+        }
+    }
+}
 
 - (void)longPress:(UILongPressGestureRecognizer*)gesture {
-    if ( gesture.state == UIGestureRecognizerStateBegan) {
-        //[self toggleMode];
-        /*
-         //if ([_webview.scrollView zoomScale] != 1.0) {
-         if (![[_webview stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom;"]  isEqual: @"1.0"]) {
-         [_webview stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom = 1.0;"];
-         }
-         else {
-         [_webview stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom = 5.0;"];
-         }
-         */
-        
-    }
-    else if ( gesture.state == UIGestureRecognizerStateEnded) {
-        //[self toggleMode];
+    if ( gesture.state == UIGestureRecognizerStateEnded) {
         [self toggleSelectTool];
     }
 }

+ 1 - 1
Classes/Network/FLEXNetworkMITMViewController.m

@@ -66,8 +66,8 @@
     ];
 #if !TARGET_OS_TV
     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-    self.tableView.rowHeight = FLEXNetworkTransactionCell.preferredCellHeight;
 #endif
+    self.tableView.rowHeight = FLEXNetworkTransactionCell.preferredCellHeight;
     [self registerForNotifications];
     [self updateTransactions];
 }

+ 3 - 0
Classes/Network/FLEXNetworkTransactionCell.m

@@ -167,6 +167,9 @@ NSString *const kFLEXNetworkTransactionCellIdentifier = @"kFLEXNetworkTransactio
 }
 
 + (CGFloat)preferredCellHeight {
+#if TARGET_OS_TV
+    return 95.0;
+#endif
     return 65.0;
 }
 

+ 89 - 1
Classes/ObjectExplorers/FLEXObjectExplorerViewController.m

@@ -26,9 +26,12 @@
 #import "FLEXShortcutsSection.h"
 #import "NSUserDefaults+FLEX.h"
 #import <objc/runtime.h>
+#import <TargetConditionals.h>
 
 #pragma mark - Private properties
-@interface FLEXObjectExplorerViewController () <UIGestureRecognizerDelegate>
+@interface FLEXObjectExplorerViewController () <UIGestureRecognizerDelegate>{
+    BOOL _addedSwipeGestures;
+}
 @property (nonatomic, readonly) FLEXSingleRowSection *descriptionSection;
 @property (nonatomic, readonly) FLEXTableViewSection *customSection;
 @property (nonatomic) NSIndexSet *customSectionVisibleIndexes;
@@ -131,6 +134,89 @@
             object:nil
         ];
     }
+#if TARGET_OS_TV
+    [self addlongPressGestureRecognizer];
+    //[self addSwipeGestureRecognizers];
+#endif
+}
+
+- (void)addlongPressGestureRecognizer {
+    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
+    longPress.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypePlayPause],[NSNumber numberWithInteger:UIPressTypeSelect]];
+    [self.tableView addGestureRecognizer:longPress];
+    
+}
+
+- (void)swipedLeft {
+    NSLog(@"[FLEXInjected] swipedLeft!");
+    //go to previous carousel item if possible
+    NSInteger currentIndex = self.carousel.selectedIndex;
+    if (currentIndex == 0) return;
+    if (self.selectedScope > 0) {
+        self.selectedScope -= 1;
+    }
+    NSInteger newIndex = currentIndex - 1;
+    [self.carousel setSelectedIndex:newIndex];
+}
+
+- (void)swipedRight {
+    NSLog(@"[FLEXInjected] swipedRight!");
+    //go to next carousel item if possible
+       NSInteger currentIndex = self.carousel.selectedIndex;
+       NSInteger newIndex = currentIndex + 1;
+    if (newIndex <= self.carousel.items.count - 1){
+        if (self.selectedScope != self.explorer.classHierarchy.count - 1) {
+            self.selectedScope += 1;
+        }
+        NSLog(@"[FLEXInjected] count: %lu new index: %lu", self.carousel.items.count, currentIndex);
+       [self.carousel setSelectedIndex:newIndex];
+        }
+}
+
+- (void)swipeGestureRecognized:(UISwipeGestureRecognizer *)gestureRecognizer{
+    NSLog(@"[FLEXInjected] gesture recognized: %lu", gestureRecognizer.direction);
+    switch (gestureRecognizer.direction) {
+        case UISwipeGestureRecognizerDirectionLeft:
+            
+            [self swipedLeft];
+            break;
+            
+        case UISwipeGestureRecognizerDirectionRight:
+            
+            [self swipedRight];
+            break;
+                    
+        default:
+            break;
+    }
+    
+}
+
+- (void)addSwipeGestureRecognizers {
+    if (_addedSwipeGestures == YES) return;
+    UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGestureRecognized:)];
+    swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
+    [self.view addGestureRecognizer:swipeLeft];
+    self.view.userInteractionEnabled = YES;
+    swipeLeft.delegate = self;
+    
+    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGestureRecognized:)];
+    swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
+    [self.view addGestureRecognizer:swipeRight];
+    self.view.userInteractionEnabled = YES;
+    swipeRight.delegate = self;
+    _addedSwipeGestures = YES;
+}
+
+- (void)longPress:(UILongPressGestureRecognizer*)gesture {
+    if ( gesture.state == UIGestureRecognizerStateEnded) {
+        NSLog(@"do something different for long press!");
+        UITableView *tv = [self tableView];
+        //naughty naughty
+        NSIndexPath *focus = [tv valueForKey:@"_focusedCellIndexPath"];
+        NSLog(@"[FLEX] focusedIndexPath: %@", focus);
+        [self tableView:self.tableView accessoryButtonTappedForRowWithIndexPath:focus];
+    }
 }
 
 - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
@@ -254,11 +340,13 @@
             case UISwipeGestureRecognizerDirectionRight:
                 if (self.selectedScope > 0) {
                     self.selectedScope -= 1;
+                    [self.tableView reloadData];
                 }
                 break;
             case UISwipeGestureRecognizerDirectionLeft:
                 if (self.selectedScope != self.explorer.classHierarchy.count - 1) {
                     self.selectedScope += 1;
+                    [self.tableView reloadData];
                 }
                 break;
 

+ 11 - 2
Classes/Toolbar/FLEXExplorerToolbar.m

@@ -99,6 +99,11 @@
     dragHandleImageFrame.origin.y = FLEXFloor((self.dragHandle.frame.size.height - dragHandleImageFrame.size.height) / 2.0);
     self.dragHandleImageView.frame = dragHandleImageFrame;
     
+    CGFloat itemPadding = 0;
+
+#if TARGET_OS_TV
+    itemPadding = 40;
+#endif
     
     // Toolbar Items
     CGFloat originX = CGRectGetMaxX(self.dragHandle.frame);
@@ -107,7 +112,7 @@
     CGFloat width = FLEXFloor((CGRectGetWidth(safeArea) - CGRectGetWidth(self.dragHandle.frame)) / self.toolbarItems.count);
     for (FLEXExplorerToolbarItem *toolbarItem in self.toolbarItems) {
         toolbarItem.currentItem.frame = CGRectMake(originX, originY, width, height);
-        originX = CGRectGetMaxX(toolbarItem.currentItem.frame);
+        originX = CGRectGetMaxX(toolbarItem.currentItem.frame) + itemPadding;
     }
     
     // Make sure the last toolbar item goes to the edge to account for any accumulated rounding effects.
@@ -145,8 +150,9 @@
     selectedViewColorFrame.origin.x = kHorizontalPadding;
     selectedViewColorFrame.origin.y = FLEXFloor((kDescriptionContainerHeight - kSelectedViewColorDiameter) / 2.0);
     self.selectedViewColorIndicator.frame = selectedViewColorFrame;
+#if !TARGET_OS_TV
     self.selectedViewColorIndicator.layer.cornerRadius = ceil(selectedViewColorFrame.size.height / 2.0);
-    
+#endif
     // Selected View Description
     CGRect descriptionLabelFrame = CGRectZero;
     CGFloat descriptionOriginX = CGRectGetMaxX(selectedViewColorFrame) + kHorizontalPadding;
@@ -210,6 +216,9 @@
 }
 
 + (CGFloat)toolbarItemHeight {
+#if TARGET_OS_TV
+    return 68.0;
+#endif
     return 44.0;
 }
 

+ 16 - 3
Classes/Toolbar/FLEXExplorerToolbarItem.m

@@ -44,7 +44,9 @@
     toolbarItem.titleLabel.font = [UIFont systemFontOfSize:12.0];
     [toolbarItem setTitle:title forState:UIControlStateNormal];
     [toolbarItem setImage:image forState:UIControlStateNormal];
+#if !TARGET_OS_TV
     [toolbarItem setTitleColor:FLEXColor.primaryTextColor forState:UIControlStateNormal];
+#endif
     [toolbarItem setTitleColor:FLEXColor.deemphasizedTextColor forState:UIControlStateDisabled];
     return toolbarItem;
 }
@@ -77,7 +79,7 @@
 }
 
 + (CGFloat)topMargin {
-    return 2.0;
+    return 20.0;
 }
 
 
@@ -130,6 +132,13 @@
 #pragma mark - UIButton Layout Overrides
 
 - (CGRect)titleRectForContentRect:(CGRect)contentRect {
+    
+    CGFloat padding = 0;
+    CGFloat titleBottomPadding = 0;
+#if TARGET_OS_TV
+    padding = 30;
+    titleBottomPadding = 5;
+#endif
     NSDictionary *attrs = [[self class] titleAttributes];
     // Bottom aligned and centered.
     CGRect titleRect = CGRectZero;
@@ -139,11 +148,13 @@
                                                 context:nil].size;
     titleSize = CGSizeMake(ceil(titleSize.width), ceil(titleSize.height));
     titleRect.size = titleSize;
-    titleRect.origin.y = contentRect.origin.y + CGRectGetMaxY(contentRect) - titleSize.height;
-    titleRect.origin.x = contentRect.origin.x + FLEXFloor((contentRect.size.width - titleSize.width) / 2.0);
+    titleRect.origin.y = contentRect.origin.y + CGRectGetMaxY(contentRect) - titleSize.height - titleBottomPadding;
+    titleRect.origin.x = contentRect.origin.x + FLEXFloor((contentRect.size.width-padding - titleSize.width) / 2.0);
     return titleRect;
 }
 
+#if !TARGET_OS_TV
+
 - (CGRect)imageRectForContentRect:(CGRect)contentRect {
     CGSize imageSize = self.image.size;
     CGRect titleRect = [self titleRectForContentRect:contentRect];
@@ -154,4 +165,6 @@
     return imageRect;
 }
 
+#endif
+
 @end

+ 4 - 5
Classes/Utility/FLEXResources.m

@@ -8692,20 +8692,19 @@ static const u_int8_t FLEXHierarchyIndentPattern3x[] = {
 
 @implementation FLEXResources
 
+#define FLEXRetinaOnlyImage(base) ([self imageWithBytesNoCopy:(void *)(base) length:sizeof(base) scale:2.0])
+
 #define FLEXImage(base) ( \
     (UIScreen.mainScreen.scale > 1.5) ? \
         ( (UIScreen.mainScreen.scale > 2.5) ? \
             [self imageWithBytesNoCopy:(void *)base##3x length:sizeof(base##3x) scale:3.0] : \
             [self imageWithBytesNoCopy:(void *)base##2x length:sizeof(base##2x) scale:2.0] \
         ) : \
-        nil \
+        [self imageWithBytesNoCopy:(void *)base##2x length:sizeof(base##2x) scale:2.0] \
 )
 
 #define FLEXImageTemplate(base) ([FLEXImage(base) imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate])
 
-#define FLEXRetinaOnlyImage(base) ([self imageWithBytesNoCopy:(void *)(base) length:sizeof(base) scale:2.0])
-
-
 #pragma mark - FLEX Toolbar Icons
 
 + (UIImage *)closeIcon {
@@ -8843,7 +8842,7 @@ static const u_int8_t FLEXHierarchyIndentPattern3x[] = {
 }
 
 + (UIImage *)hierarchyIndentPattern {
-    return FLEXRetinaOnlyImage(FLEXHierarchyIndentPattern);
+    return FLEXImageTemplate(FLEXHierarchyIndentPattern);
 }
 
 

+ 4 - 5
Classes/ViewHierarchy/TreeExplorer/FLEXHierarchyTableViewController.m

@@ -63,19 +63,16 @@ typedef NS_ENUM(NSUInteger, FLEXHierarchyScope) {
 }
 
 - (void)longPress:(UILongPressGestureRecognizer*)gesture {
-    if ( gesture.state == UIGestureRecognizerStateBegan) {
-        
-    }
-    else if ( gesture.state == UIGestureRecognizerStateEnded) {
+    if ( gesture.state == UIGestureRecognizerStateEnded) {
         NSLog(@"do something different for long press!");
         UITableView *tv = [self tableView];
         //naughty naughty
         NSIndexPath *focus = [tv valueForKey:@"_focusedCellIndexPath"];
         NSLog(@"[FLEX] focusedIndexPath: %@", focus);
         [self tableView:self.tableView accessoryButtonTappedForRowWithIndexPath:focus];
-        
     }
 }
+
 - (void)addlongPressGestureRecognizer {
     UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
     longPress.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypePlayPause],[NSNumber numberWithInteger:UIPressTypeSelect]];
@@ -255,8 +252,10 @@ typedef NS_ENUM(NSUInteger, FLEXHierarchyScope) {
         cell.textLabel.textColor = FLEXColor.deemphasizedTextColor;
         cell.detailTextLabel.textColor = FLEXColor.deemphasizedTextColor;
     } else {
+#if !TARGET_OS_TV
         cell.textLabel.textColor = FLEXColor.primaryTextColor;
         cell.detailTextLabel.textColor = FLEXColor.primaryTextColor;
+#endif
     }
     
     return cell;

+ 3 - 3
postScript.sh

@@ -40,9 +40,9 @@ EXE_PATH=$FINAL_FW_PATH/$EXECUTABLE_NAME
 
 ldid -S $EXE_PATH
 rm -rf $FINAL_FW_PATH/_CodeSignature
-#/usr/local/bin/fakeroot dpkg-deb -b layout
-#scp layout.deb root@$ATV_DEVICE_IP:~
-#ssh root@$ATV_DEVICE_IP "dpkg -i layout.deb ; killall -9 PineBoard"
+/usr/local/bin/fakeroot dpkg-deb -b layout
+scp layout.deb root@$ATV_DEVICE_IP:~
+ssh root@$ATV_DEVICE_IP "dpkg -i layout.deb ; killall -9 PineBoard"
 
 exit 0