Преглед на файлове

started added selection view support

Kevin Bradley преди 5 години
родител
ревизия
1a22e3f4c5
променени са 4 файла, в които са добавени 155 реда и са изтрити 13 реда
  1. 139 13
      Classes/ExplorerInterface/FLEXExplorerViewController.m
  2. BIN
      Cursor.png
  3. 4 0
      FLEX.xcodeproj/project.pbxproj
  4. 12 0
      layout/DEBIAN/control

+ 139 - 13
Classes/ExplorerInterface/FLEXExplorerViewController.m

@@ -28,7 +28,9 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     FLEXExplorerModeMove
 };
 
-@interface FLEXExplorerViewController () <FLEXHierarchyDelegate, UIAdaptivePresentationControllerDelegate>
+@interface FLEXExplorerViewController () <FLEXHierarchyDelegate, UIAdaptivePresentationControllerDelegate>{
+    UIImageView *cursorView;
+}
 
 /// Tracks the currently active tool/mode
 @property (nonatomic) FLEXExplorerMode currentMode;
@@ -73,10 +75,94 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 /// Used to preserve the target app's UIMenuController items.
 @property (nonatomic) NSArray<UIMenuItem *> *appMenuItems;
 #endif
+
+@property CGPoint lastTouchLocation;
+
 @end
 
 @implementation FLEXExplorerViewController
 
+#pragma mark - Cursor Input
+
+-(void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
+    
+    CGPoint point = [self.view convertPoint:cursorView.frame.origin toView:nil];
+               NSLog(@"[FLEXInjected] clicked point: %@", NSStringFromCGPoint(point));
+    [self updateOutlineViewsForSelectionPoint:point];
+    if (presses.anyObject.type == UIPressTypeMenu) {
+        UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
+        if (alertController) {
+            [self.presentedViewController dismissViewControllerAnimated:true completion:nil];
+        }
+        //go back?
+        //[self toggleSelectTool];
+        
+    }
+    else if (presses.anyObject.type == UIPressTypeUpArrow) {
+    }
+    else if (presses.anyObject.type == UIPressTypeDownArrow) {
+    }
+    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)
+    {
+        UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
+        if (alertController)
+        {
+            [self.presentedViewController dismissViewControllerAnimated:true completion:nil];
+        } else {
+            
+        }
+    }
+}
+
+- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
+{
+    self.lastTouchLocation = CGPointMake(-1, -1);
+}
+
+- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
+{
+    for (UITouch *touch in touches)
+    {
+        CGPoint location = [touch locationInView:self.view];
+        
+        if(self.lastTouchLocation.x == -1 && self.lastTouchLocation.y == -1)
+        {
+            // Prevent cursor from recentering
+            self.lastTouchLocation = location;
+        }
+        else
+        {
+            CGFloat xDiff = location.x - self.lastTouchLocation.x;
+            CGFloat yDiff = location.y - self.lastTouchLocation.y;
+            CGRect rect = cursorView.frame;
+            
+            if(rect.origin.x + xDiff >= 0 && rect.origin.x + xDiff <= 1920)
+                rect.origin.x += xDiff;//location.x - self.startPos.x;//+= xDiff; //location.x;
+            
+            if(rect.origin.y + yDiff >= 0 && rect.origin.y + yDiff <= 1080)
+                rect.origin.y += yDiff;//location.y - self.startPos.y;//+= yDiff; //location.y;
+            
+            cursorView.frame = rect;
+            self.lastTouchLocation = location;
+        }
+        
+        // We only use one touch, break the loop
+        break;
+    }
+    
+}
+
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     if (self) {
@@ -93,31 +179,31 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-
+    
     // Toolbar
     _explorerToolbar = [FLEXExplorerToolbar new];
-
+    
     // Start the toolbar off below any bars that may be at the top of the view.
     CGFloat toolbarOriginY = NSUserDefaults.standardUserDefaults.flex_toolbarTopMargin;
-
+    
     CGRect safeArea = [self viewSafeArea];
     CGSize toolbarSize = [self.explorerToolbar sizeThatFits:CGSizeMake(
-        CGRectGetWidth(self.view.bounds), CGRectGetHeight(safeArea)
-    )];
+                                                                       CGRectGetWidth(self.view.bounds), CGRectGetHeight(safeArea)
+                                                                       )];
     [self updateToolbarPositionWithUnconstrainedFrame:CGRectMake(
-        CGRectGetMinX(safeArea), toolbarOriginY, toolbarSize.width, toolbarSize.height
-    )];
+                                                                 CGRectGetMinX(safeArea), toolbarOriginY, toolbarSize.width, toolbarSize.height
+                                                                 )];
     self.explorerToolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth |
-                                            UIViewAutoresizingFlexibleBottomMargin |
-                                            UIViewAutoresizingFlexibleTopMargin;
+    UIViewAutoresizingFlexibleBottomMargin |
+    UIViewAutoresizingFlexibleTopMargin;
     [self.view addSubview:self.explorerToolbar];
     [self setupToolbarActions];
     [self setupToolbarGestures];
     
     // View selection
     UITapGestureRecognizer *selectionTapGR = [[UITapGestureRecognizer alloc]
-        initWithTarget:self action:@selector(handleSelectionTap:)
-    ];
+                                              initWithTarget:self action:@selector(handleSelectionTap:)
+                                              ];
     [self.view addGestureRecognizer:selectionTapGR];
     
     // View moving
@@ -129,6 +215,39 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     if (@available(iOS 10.0, *)) {
         _selectionFBG = [UISelectionFeedbackGenerator new];
     }
+    
+    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]];
+    [self.view addGestureRecognizer:longPress];
+    [self.view addSubview:cursorView];
+}
+
+
+- (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];
+        [self toggleSelectTool];
+    }
 }
 
 - (void)viewWillAppear:(BOOL)animated {
@@ -873,7 +992,8 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
         
         // If we now have a selected view and we didn't have one previously, go to "select" mode.
         if (self.currentMode == FLEXExplorerModeDefault && selectedView) {
-            self.currentMode = FLEXExplorerModeSelect;
+            //self.currentMode = FLEXExplorerModeSelect;
+            [self toggleSelectTool];
         }
         
         // The selected view setter will also update the selected view overlay appropriately.
@@ -949,8 +1069,14 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 - (void)toggleSelectTool {
     if (self.currentMode == FLEXExplorerModeSelect) {
         self.currentMode = FLEXExplorerModeDefault;
+        cursorView.hidden = true;
+        [self.explorerToolbar setUserInteractionEnabled:true];
     } else {
         self.currentMode = FLEXExplorerModeSelect;
+        cursorView.hidden = false;
+        [self.explorerToolbar setUserInteractionEnabled:false];
+        [self setNeedsFocusUpdate];
+        [self updateFocusIfNeeded];
     }
 }
 

BIN
Cursor.png


+ 4 - 0
FLEX.xcodeproj/project.pbxproj

@@ -17,6 +17,7 @@
 		224D49AB1C673AB5000EAB86 /* FLEXSQLiteDatabaseManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 224D49A71C673AB5000EAB86 /* FLEXSQLiteDatabaseManager.m */; };
 		2EF6B04D1D494BE50006BDA5 /* FLEXNetworkCurlLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EF6B04B1D494BE50006BDA5 /* FLEXNetworkCurlLogger.m */; };
 		2EF6B04E1D494BE50006BDA5 /* FLEXNetworkCurlLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EF6B04C1D494BE50006BDA5 /* FLEXNetworkCurlLogger.h */; };
+		325D7AAF2593AE4700CC6B10 /* Cursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 325D7AAE2593AE4700CC6B10 /* Cursor.png */; };
 		32D4E15B259273E60027F238 /* fakes.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D4E15A259273E60027F238 /* fakes.h */; };
 		32D4E15D2592749D0027F238 /* fakes.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D4E15C2592749D0027F238 /* fakes.m */; };
 		32D4E15E2592749D0027F238 /* fakes.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D4E15C2592749D0027F238 /* fakes.m */; };
@@ -375,6 +376,7 @@
 		224D49A71C673AB5000EAB86 /* FLEXSQLiteDatabaseManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXSQLiteDatabaseManager.m; sourceTree = "<group>"; };
 		2EF6B04B1D494BE50006BDA5 /* FLEXNetworkCurlLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXNetworkCurlLogger.m; sourceTree = "<group>"; };
 		2EF6B04C1D494BE50006BDA5 /* FLEXNetworkCurlLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXNetworkCurlLogger.h; sourceTree = "<group>"; };
+		325D7AAE2593AE4700CC6B10 /* Cursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Cursor.png; sourceTree = SOURCE_ROOT; };
 		32D4E15A259273E60027F238 /* fakes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = fakes.h; sourceTree = "<group>"; };
 		32D4E15C2592749D0027F238 /* fakes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = fakes.m; sourceTree = "<group>"; };
 		3A4C941F1B5B20570088C3F2 /* FLEX.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FLEX.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -795,6 +797,7 @@
 		3A4C94221B5B20570088C3F2 /* Supporting Files */ = {
 			isa = PBXGroup;
 			children = (
+				325D7AAE2593AE4700CC6B10 /* Cursor.png */,
 				3A4C94231B5B20570088C3F2 /* Info.plist */,
 			);
 			name = "Supporting Files";
@@ -1694,6 +1697,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				04F1CA191C137CF1000A52B0 /* LICENSE in Resources */,
+				325D7AAF2593AE4700CC6B10 /* Cursor.png in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 12 - 0
layout/DEBIAN/control

@@ -0,0 +1,12 @@
+Package: libflex
+Section: Development
+Maintainer: Kevin Bradley
+Architecture: appletvos-arm64
+Version: 4.1.1a-1
+Depends: firmware (>= 9.0), mobilesubstrate
+Description: A library for Flipboard Explorer on tvOS, alpha at best!!
+Name: libFLEX
+Author: Tanner Bennett <tannerbennett@me.com>
+dev: tannerbennett
+Homepage: http://moreinfo.thebigboss.org/moreinfo/depiction.php?file=libflexDp
+Tag: compatible::ios9, compatible::ios10, compatible::ios11, compatible::ios12, compatible::ios13