Prechádzať zdrojové kódy

more improvements to tvOS paradigms

Kevin Bradley 5 rokov pred
rodič
commit
4d91a42325

+ 63 - 10
Classes/ExplorerInterface/FLEXExplorerViewController.m

@@ -21,6 +21,7 @@
 #import "FLEXWindowManagerController.h"
 #import "FLEXViewControllersViewController.h"
 #import "NSUserDefaults+FLEX.h"
+#import "FLEXManager.h"
 
 typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     FLEXExplorerModeDefault,
@@ -84,21 +85,39 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 
 #pragma mark - Cursor Input
 
+#if TARGET_OS_TV
+
+- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
+{
+    for (UIPress *press in presses) {
+        if (press.type == UIPressTypeMenu) {
+            
+        } else {
+            [super pressesBegan:presses withEvent:event];
+        }
+    }
+}
+
 -(void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
     
-    if (self.currentMode != FLEXExplorerModeSelect){
+    if (self.currentMode != FLEXExplorerModeSelect && self.currentMode != FLEXExplorerModeMove){
         [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];
+    if (self.currentMode == FLEXExplorerModeSelect){
+        [self updateOutlineViewsForSelectionPoint:point];
+    }
     if (presses.anyObject.type == UIPressTypeMenu) {
-        UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
-        if (alertController) {
-            [self.presentedViewController dismissViewControllerAnimated:true completion:nil];
+        if (self.currentMode == FLEXExplorerModeMove || self.currentMode == FLEXExplorerModeSelect){
+            if (self.currentMode == FLEXExplorerModeMove || self.currentMode == FLEXExplorerModeSelect){
+                self.currentMode = FLEXExplorerModeDefault;
+                cursorView.hidden = true;
+                [self.explorerToolbar setUserInteractionEnabled:true];
+                [self updateFocusIfNeeded];
+            }
         }
-        
     }
     else if (presses.anyObject.type == UIPressTypeUpArrow) {
     }
@@ -157,6 +176,8 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     
 }
 
+#endif
+
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     if (self) {
@@ -209,13 +230,14 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     if (@available(iOS 10.0, *)) {
         _selectionFBG = [UISelectionFeedbackGenerator new];
     }
-    
+
+#if TARGET_OS_TV
     cursorView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];
     cursorView.center = CGPointMake(CGRectGetMidX([UIScreen mainScreen].bounds), CGRectGetMidY([UIScreen mainScreen].bounds));
     cursorView.image = [UIImage imageNamed:@"Cursor"];
     cursorView.backgroundColor = [UIColor clearColor];
     cursorView.hidden = YES;
-    
+
     
     UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
     longPress.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypePlayPause]];
@@ -225,16 +247,46 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
     doubleTap.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypePlayPause], [NSNumber numberWithInteger:UIPressTypeSelect]];
     [self.view addGestureRecognizer:doubleTap];
+    
+#endif
 }
 
 - (void)doubleTap:(UITapGestureRecognizer *)gesture {
     if (gesture.state == UIGestureRecognizerStateEnded) {
-        if (self.currentMode == FLEXExplorerModeSelect){
-            [self toggleViewsTool];
+        if (self.currentMode == FLEXExplorerModeSelect || self.currentMode == FLEXExplorerModeMove){
+            NSLog(@"[FLEXInjected] doubleTap: toggle views tool!");
+            [self showTVOSOptionsAlert];
+            
         }
     }
 }
 
+- (void)showTVOSOptionsAlert {
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"What would you like to do?" message:nil preferredStyle:UIAlertControllerStyleAlert];
+    UIAlertAction *showViews = [UIAlertAction actionWithTitle:@"Show Views" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        [self toggleViewsTool];
+        [[FLEXManager sharedManager] showExplorer];
+    }];
+    [alertController addAction:showViews];
+    UIAlertAction *details = [UIAlertAction actionWithTitle:@"Show Details" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        //i dont know yet
+        [[FLEXManager sharedManager] showExplorer];
+    }];
+    [alertController addAction:details];
+    UIAlertAction *movement = [UIAlertAction actionWithTitle:@"Move View" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        self.currentMode = FLEXExplorerModeMove;
+        [[FLEXManager sharedManager] showExplorer];
+    }];
+    [alertController addAction:movement];
+    
+    [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+        [[FLEXManager sharedManager] showExplorer];
+    }]];
+    
+    [self presentViewController:alertController animated:true completion:nil];
+    
+}
+
 - (void)longPress:(UILongPressGestureRecognizer*)gesture {
     if ( gesture.state == UIGestureRecognizerStateEnded) {
         [self toggleSelectTool];
@@ -1086,6 +1138,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 - (void)toggleViewsToolWithCompletion:(void(^)(void))completion {
     [self toggleToolWithViewControllerProvider:^UINavigationController *{
         if (self.selectedView) {
+            NSLog(@"[FLEXInjected] we have a selected view still: %@", self.selectedView);
             return [FLEXHierarchyViewController
                 delegate:self
                 viewsAtTap:self.viewsAtTapPoint

+ 1 - 0
Classes/Toolbar/FLEXExplorerToolbar.m

@@ -110,6 +110,7 @@
     CGFloat originY = CGRectGetMinY(safeArea);
     CGFloat height = kToolbarItemHeight;
     CGFloat width = FLEXFloor((CGRectGetWidth(safeArea) - CGRectGetWidth(self.dragHandle.frame)) / self.toolbarItems.count);
+    width = width - itemPadding;
     for (FLEXExplorerToolbarItem *toolbarItem in self.toolbarItems) {
         toolbarItem.currentItem.frame = CGRectMake(originX, originY, width, height);
         originX = CGRectGetMaxX(toolbarItem.currentItem.frame) + itemPadding;

+ 2 - 0
Classes/Toolbar/FLEXExplorerToolbarItem.m

@@ -122,7 +122,9 @@
     if (self.highlighted) {
         self.backgroundColor = self.class.highlightedBackgroundColor;
     } else if (self.selected) {
+#if !TARGET_OS_TV
         self.backgroundColor = self.class.selectedBackgroundColor;
+#endif
     } else {
         self.backgroundColor = self.class.defaultBackgroundColor;
     }

+ 1 - 1
postScript.sh

@@ -42,7 +42,7 @@ 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"
+ssh root@$ATV_DEVICE_IP "dpkg -i layout.deb ; killall -9 nitoTV ; lsdtrip launch com.nito.nitoTV4"
 
 exit 0