From 0a51fcb19809e59c108883462fda6739164db4c9 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Thu, 30 Dec 2021 14:14:31 -0500 Subject: Fixes requested by Chariz --- .../QuickActionsPrefs/QASAppSelectorController.h | 1 + .../QuickActionsPrefs/QASAppSelectorController.m | 20 ++++++++++- .../QuickActionsPrefs/Resources/Root.plist | 16 ++++----- QuickActions/Tweak.x | 39 ++++++++++++++-------- 4 files changed, 54 insertions(+), 22 deletions(-) (limited to 'QuickActions') diff --git a/QuickActions/QuickActionsPrefs/QASAppSelectorController.h b/QuickActions/QuickActionsPrefs/QASAppSelectorController.h index f439fcb..0a3937e 100644 --- a/QuickActions/QuickActionsPrefs/QASAppSelectorController.h +++ b/QuickActions/QuickActionsPrefs/QASAppSelectorController.h @@ -17,6 +17,7 @@ typedef enum { UISearchResultsUpdating, UISearchBarDelegate> { UISearchController *_searchController; NSString *_searchKey; + UISelectionFeedbackGenerator *_feedback; } @property (nonatomic) UITableView *tableView; @property (nonatomic) NSMutableArray *enabled; diff --git a/QuickActions/QuickActionsPrefs/QASAppSelectorController.m b/QuickActions/QuickActionsPrefs/QASAppSelectorController.m index cadca5c..fb3aba4 100644 --- a/QuickActions/QuickActionsPrefs/QASAppSelectorController.m +++ b/QuickActions/QuickActionsPrefs/QASAppSelectorController.m @@ -1,6 +1,7 @@ #import #import #import +#import #import "QASAppSelectorController.h" #import "LSApplicationProxy+AltList.h" @@ -40,7 +41,8 @@ ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]]]; - _searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; + if (_searchController == nil) + _searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; _searchController.searchResultsUpdater = self; _searchController.obscuresBackgroundDuringPresentation = NO; _searchController.searchBar.delegate = self; @@ -49,6 +51,11 @@ self.navigationItem.hidesSearchBarWhenScrolling = NO; self.definesPresentationContext = YES; + + + if (_feedback == nil) + _feedback = [[UISelectionFeedbackGenerator alloc] init]; + [_feedback prepare]; } -(void)updateSearchResultsForSearchController:(UISearchController *)searchController { @@ -233,6 +240,17 @@ } else if (editingStyle == UITableViewCellEditingStyleInsert) { [self.enabled insertObject:item atIndex:self.enabled.count]; [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:([self.enabled count] - 1) inSection:0]] withRowAnimation:UITableViewRowAnimationFade]; + + switch ([(NSNumber *)[[UIDevice currentDevice] valueForKey:@"_feedbackSupportLevel"] intValue]) { + case 2: + [_feedback selectionChanged]; + break; + case 1: + AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); + break; + default: + break; + } } [tableView endUpdates]; diff --git a/QuickActions/QuickActionsPrefs/Resources/Root.plist b/QuickActions/QuickActionsPrefs/Resources/Root.plist index 1eb8853..60f36c2 100644 --- a/QuickActions/QuickActionsPrefs/Resources/Root.plist +++ b/QuickActions/QuickActionsPrefs/Resources/Root.plist @@ -31,8 +31,8 @@ LeftOffsetX defaults com.cameronkatri.quickactions - isDecimalPad - + keyboard + numbers placeholder 0 @@ -45,8 +45,8 @@ LeftOffsetY defaults com.cameronkatri.quickactions - isDecimalPad - + keyboard + numbers placeholder 0 @@ -77,8 +77,8 @@ RightOffsetX defaults com.cameronkatri.quickactions - isDecimalPad - + keyboard + numbers placeholder 0 @@ -91,8 +91,8 @@ RightOffsetY defaults com.cameronkatri.quickactions - isDecimalPad - + keyboard + numbers placeholder 0 diff --git a/QuickActions/Tweak.x b/QuickActions/Tweak.x index 02871ee..79a3195 100644 --- a/QuickActions/Tweak.x +++ b/QuickActions/Tweak.x @@ -110,14 +110,32 @@ void openApplication(NSString *bundleID) } } - // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDND:) name:@"SBQuietModeStatusChangedNotification" object:nil]; - // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDND:) name:@"QuickActionsUpdateDND" object:nil]; self.stateService = (DNDStateService *)[objc_getClass("DNDStateService") serviceForClientIdentifier:@"com.apple.donotdisturb.control-center.module"]; [self.stateService addStateUpdateListener:self withCompletionHandler:nil]; return o; } +-(void)refreshFlashlightAvailability +{ + %orig; + + if (self.leftOpen) { + self.leftOpen = !self.leftOpen; + for (CSQuickActionsButton *button in [self leftButtons]) { + button.frame = [self leftFrameForButton:button]; + [button setHidden:!self.leftOpen]; + } + } + if (self.rightOpen) { + self.rightOpen = !self.rightOpen; + for (CSQuickActionsButton *button in [self rightButtons]) { + button.frame = [self rightFrameForButton:button]; + [button setHidden:!self.rightOpen]; + } + } +} + %new -(CGRect)rightFrameForButton:(CSQuickActionsButton*)button { @@ -161,6 +179,11 @@ void openApplication(NSString *bundleID) if (SBFEffectiveHomeButtonType() != 2) { CGRect bounds = [[UIScreen mainScreen] _referenceBounds]; + // Detect if we are on an iPhone SE and adjust the insets + // accordingly to not overlap with the text + if ([[UIScreen mainScreen] nativeBounds].size.height == 1136) + insets.bottom += 10; + CGFloat buttonWidth = 50 + insets.right + insets.left; CGFloat buttonHeight = 50 + insets.top + insets.bottom; @@ -203,7 +226,7 @@ void openApplication(NSString *bundleID) for (CSQuickActionsButton *button in [self leftButtons]) { [button setEdgeInsets:insets]; button.frame = [self leftFrameForButton:button]; - [button setHidden:!self.rightOpen]; + [button setHidden:!self.leftOpen]; } for (CSQuickActionsButton *button in [self rightButtons]) { [button setEdgeInsets:insets]; @@ -410,14 +433,4 @@ void openApplication(NSString *bundleID) %end -// %hook DNDNotificationsService - -// -(void)stateService:(id)arg1 didReceiveDoNotDisturbStateUpdate:(id)arg2{ -// %orig; - -// [[NSNotificationCenter defaultCenter] postNotificationName:@"QuickActionsUpdateDND" object:nil]; -// } - -// %end - // vim: filetype=logos -- cgit v1.2.3-56-ge451