Skip to content

Instantly share code, notes, and snippets.

@r-plus
Last active December 16, 2015 01:19
Show Gist options
  • Save r-plus/5354222 to your computer and use it in GitHub Desktop.
Save r-plus/5354222 to your computer and use it in GitHub Desktop.
OpenSource version of CloudTabs+. Licensed under the GPLv3.
#import <UIKit/UIKit.h>
static BOOL isActivatingFromLongPress;
%hook BrowserToolbar
- (void)_installGestureRecognizers
{
%orig;
id bookmarkButton = MSHookIvar<id>(self, "_bookmarksItem");
UILongPressGestureRecognizer *longGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressBookmarkButton:)];
[[bookmarkButton view] addGestureRecognizer:longGesture];
[longGesture release];
}
%new(v@:@)
- (void)longPressBookmarkButton:(UIGestureRecognizer *)gesture
{
if (gesture.state == UIGestureRecognizerStateBegan) {
isActivatingFromLongPress = YES;
[BC toggleCloudTabsFromButtonBar];
}
}
%end
%hook CloudTabViewController
- (void)_done
{
if (isActivatingFromLongPress) {
isActivatingFromLongPress = NO;
return [self dismissViewControllerAnimated:YES completion:^{}];
}
%orig;
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment