Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions preferences/Resources/PriorityHub.plist
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ items = (
PostNotification = com.thomasfinch.priorityhub-prefschanged;
label = "Enable Pull To Clear";
},
{
cell = PSSwitchCell;
default = 0;
defaults = "com.thomasfinch.priorityhub";
key = externalPullToClear;
PostNotification = com.thomasfinch.priorityhub-prefschanged;
label = "External Pull To Clear";
},
{
cell = PSSwitchCell;
default = 0;
Expand Down
20 changes: 16 additions & 4 deletions source/Tweak.xm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <UIKit/UIKit.h>
#include <Foundation/NSDistributedNotificationCenter.h>
#import "Headers.h"
#import "PHContainerView.h"
#import "substrate.h"
Expand Down Expand Up @@ -84,6 +85,7 @@ void showTestNotification() {
@"showSeparators": @NO,
@"collapseOnLock": @YES,
@"enablePullToClear": @YES,
@"externalPullToClear": @NO,
@"privacyMode": @NO,
@"iconLocation": [NSNumber numberWithInt:0],
@"iconSize": (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? [NSNumber numberWithInt:1] : [NSNumber numberWithInt:0],
Expand Down Expand Up @@ -127,7 +129,7 @@ void showTestNotification() {
}

//Add pull to clear view if the option is on
if ([defaults boolForKey:@"enablePullToClear"]) {
if ([defaults boolForKey:@"enablePullToClear"] || [defaults boolForKey:@"externalPullToClear"]) {
if (pullToClearView)
[pullToClearView removeFromSuperview];
pullToClearView = [[PHPullToClearView alloc] initWithFrame:CGRectZero];
Expand Down Expand Up @@ -203,7 +205,7 @@ void showTestNotification() {

//All scroll view methods are used for pull to clear control
- (void)scrollViewDidScroll:(UIScrollView*)scrollView {
if ([defaults boolForKey:@"enabled"] && [defaults boolForKey:@"enablePullToClear"]) {
if ([defaults boolForKey:@"enabled"] && ([defaults boolForKey:@"enablePullToClear"] || [defaults boolForKey:@"externalPullToClear"])) {
if (scrollView.contentOffset.y <= 0)
[pullToClearView setXVisible:(scrollView.contentOffset.y <= pullToClearThreshold)];
}
Expand All @@ -213,8 +215,18 @@ void showTestNotification() {

//All scroll view methods are used for pull to clear control
- (void)scrollViewDidEndDragging:(UIScrollView*)scrollView willDecelerate:(_Bool)arg2 {
if ([defaults boolForKey:@"enabled"] && [defaults boolForKey:@"enablePullToClear"] && phContainerView.selectedAppID != nil && scrollView.contentOffset.y <= pullToClearThreshold && (scrollView.dragging || scrollView.tracking)) {
BOOL enablePullToClear = [defaults boolForKey:@"enablePullToClear"];
BOOL externalPullToClear = [defaults boolForKey:@"externalPullToClear"];

if ([defaults boolForKey:@"enabled"] && (enablePullToClear || externalPullToClear) && phContainerView.selectedAppID != nil && scrollView.contentOffset.y <= pullToClearThreshold && (scrollView.dragging || scrollView.tracking)) {
if (externalPullToClear) {
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.thomasfinch.priorityhub-pulltoclearsection" object:nil userInfo:@{@"sectionID":phContainerView.selectedAppID}];
}

if (enablePullToClear) {
[bulletinObserver clearSection:phContainerView.selectedAppID];
}

notificationsTableView.alpha = 0;
[pullToClearView setXVisible:NO];
}
Expand Down Expand Up @@ -279,7 +291,7 @@ void showTestNotification() {
%orig;

PHLog(@"TWEAK XM SET SCREEN IN OFF MODE");

if(off && [defaults boolForKey:@"enabled"] && [defaults boolForKey:@"collapseOnLock"] && phContainerView && phContainerView.selectedAppID)
[phContainerView selectAppID:phContainerView.selectedAppID newNotification:NO];
}
Expand Down