Skip to content

Commit

Permalink
Remap, blacklist,
Browse files Browse the repository at this point in the history
  • Loading branch information
midnightchip committed Mar 2, 2019
1 parent 2a38f97 commit b5b5b33
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 224 deletions.
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: com.vitataf.homegesture
Name: HomeGesture
Pre-Depends: com.spark.libsparkapplist
Depends: firmware (>= 11.0), mobilesubstrate, preferenceloader, com.creaturecoding.libcspreferences, com.creaturesurvive.libcscolorpicker, org.thebigboss.libcolorpicker
Version: 2.1.1
Version: 2.1.2
Architecture: iphoneos-arm
Description: Enable iPhone X home gesture on other devices.
Maintainer: MidnightChips/PINPAL
Expand Down
5 changes: 5 additions & 0 deletions preferences/HGPPreferenceController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ -(void)selectBlackList{
[self.navigationController pushViewController:s animated:YES];
self.navigationItem.hidesBackButton = FALSE;
}
-(void)selectStatusBlacklist{
SparkAppListTableViewController* s = [[SparkAppListTableViewController alloc] initWithIdentifier:@"com.midnight.homegesture.plist" andKey:@"statusBlack"];
[self.navigationController pushViewController:s animated:YES];
self.navigationItem.hidesBackButton = FALSE;
}
@end

@implementation HGPPreferenceController
Expand Down
2 changes: 2 additions & 0 deletions preferences/Resources/base.lproj/statusBar.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
"Show_Centre" = "Show the status bar in Control Centre";
"iPad_STYLE" = "iPad Style Status Bar";
"Mimic_iPad" = "Mimics iPad Status Bar, adds date (iOS 12+)";
"Disable_IPX_IN_APPS" = "Disable the iPhone X Status bar in incompatible apps (iOS 12)";
"Turn_ON_iPad_FallBack"= "You can also enable the iPad status bar for those apps as a fallback";
}
2 changes: 2 additions & 0 deletions preferences/Resources/en-GB.lproj/statusBar.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
"Show_Centre" = "Show the status bar in Control Centre";
"iPad_STYLE" = "iPad Style Status Bar";
"Mimic_iPad" = "Mimics iPad Status Bar, adds date (iOS 12)";
"Disable_IPX_IN_APPS" = "Disable the iPhone X Status bar in incompatible apps (iOS 12)";
"Turn_ON_iPad_FallBack"= "You can also enable the iPad status bar for those apps as a fallback";
}
2 changes: 2 additions & 0 deletions preferences/Resources/en.lproj/statusBar.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
"Show_Centre" = "Show the status bar in Control Center";
"iPad_STYLE" = "iPad Style Status Bar";
"Mimic_iPad" = "Mimics iPad Status Bar, adds date (iOS 12)";
"Disable_IPX_IN_APPS" = "Disable the iPhone X Status bar in incompatible apps (iOS 12)";
"Turn_ON_iPad_FallBack"= "You can also enable the iPad status bar for those apps as a fallback";
}
11 changes: 11 additions & 0 deletions preferences/Resources/statusBar.plist
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
<string>/Library/PreferenceBundles/HomeGesture.bundle</string>
</dict>

<dict>
<key>cell</key>
<string>PSButtonCell</string>
<key>label</key>
<string>Disable_IPX_IN_APPS</string>
<key>sublabel</key>
<string>Turn_ON_iPad_FallBack</string>
<key>action</key>
<string>selectStatusBlacklist</string>
</dict>

<dict>
<key>cell</key>
<string>PSSwitchCell</string>
Expand Down
226 changes: 11 additions & 215 deletions source/HGBlacklist+Remap.xm
Original file line number Diff line number Diff line change
@@ -1,245 +1,41 @@
#import "HomeGesture.h"


/*int applicationDidFinishLaunching;
%group loadMe
static BOOL homeEnable = YES;
static BOOL rotateDisable = YES;
// Disable Gestures Switch
%hook SBHomeGestureSettings
-(BOOL)isHomeGestureEnabled{
if(![prefs boolForKey:@"disableGestures"]){
NSString *currentApp;
SpringBoard *springBoard = (SpringBoard *)[UIApplication sharedApplication];
SBApplication *frontApp = (SBApplication *)[springBoard _accessibilityFrontMostApplication];
currentApp = [frontApp valueForKey:@"_bundleIdentifier"];
if(homeEnable && rotateDisable && ![SparkAppList doesIdentifier:@"com.midnight.homegesture.plist" andKey:@"blackList" containBundleIdentifier:currentApp]){
return YES;
}else{
return NO;
}
}else{
return NO;
}
}
%end
// Disable Gestures (SpringBoard applicationDidFinishLaunching also used in Screenshot Remap!)
static NSString *currentApp;
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
applicationDidFinishLaunching = 2;
%orig;
// Disable Gestures When Keyboard is Visible
if([prefs boolForKey:@"stopKeyboard"]){
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification
object:nil];
}
// Disable Gestures in Blacklisted Apps
if ([prefs boolForKey:@"enableBlacklist"]){
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(yourMethod:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
}
}
%new
-(void)keyboardDidShow:(NSNotification *)sender
{
homeEnable = NO;
}
%new
-(void)keyboardDidHide:(NSNotification *)sender
{
homeEnable = YES;
}
%new
-(void)yourMethod:(NSNotification *)sender {
UIDevice *currentDevice = sender.object;
if(currentDevice.orientation == UIDeviceOrientationPortrait) {
rotateDisable = YES;
}
if(currentDevice.orientation == UIDeviceOrientationLandscapeLeft) {
SpringBoard *springBoard = (SpringBoard *)[UIApplication sharedApplication];
SBApplication *frontApp = (SBApplication *)[springBoard _accessibilityFrontMostApplication];
currentApp = [frontApp valueForKey:@"_bundleIdentifier"];
if([SparkAppList doesIdentifier:@"com.midnight.homegesture.plist" andKey:@"excludedApps" containBundleIdentifier:currentApp]){
rotateDisable = NO;
}
}
if(currentDevice.orientation == UIDeviceOrientationLandscapeRight) {
SpringBoard *springBoard = (SpringBoard *)[UIApplication sharedApplication];
SBApplication *frontApp = (SBApplication *)[springBoard _accessibilityFrontMostApplication];
currentApp = [frontApp valueForKey:@"_bundleIdentifier"];
if([SparkAppList doesIdentifier:@"com.midnight.homegesture.plist" andKey:@"excludedApps" containBundleIdentifier:currentApp]){
rotateDisable = NO;
}
}
if(currentDevice.orientation == UIDeviceOrientationPortraitUpsideDown) {
rotateDisable = YES;
}
}
%end
//Remap
// Screenshot Remap
%hook SBPressGestureRecognizer
- (void)setAllowedPressTypes:(NSArray *)arg1 {
NSArray * lockHome = @[@104, @101];
NSArray * lockVol = @[@104, @102, @103];
if ([arg1 isEqual:lockVol] && applicationDidFinishLaunching == 2 && [prefs boolForKey:@"remapScreen"]) {
%orig(lockHome);
applicationDidFinishLaunching--;
return;
}
%orig;
}
%end
%hook SBClickGestureRecognizer
- (void)addShortcutWithPressTypes:(id)arg1 {
if (applicationDidFinishLaunching == 1 && [prefs boolForKey:@"remapScreen"]) {
applicationDidFinishLaunching--;
return;
}
%orig;
}
%end
%end
%group kickStart
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
%orig;
%init(loadMe)
}
%end
%end
%ctor {
//NSString *bundleIdentifier = [NSBundle mainBundle].bundleIdentifier;
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:@"/var/mobile/Library/Preferences/HomeGesture/setup"]){
%init(kickStart);
}
}*/
/*static BOOL enableGesture(){
NSLog(@"")
if([SparkAppList doesIdentifier:@"com.midnight.homegesture.plist" andKey:@"blackList" containBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]]){
return NO;
}else{
return YES;
}
}*/
/*@interface PTSettings : NSObject
@end
@interface _UISettings : PTSettings
@end
@interface SBUISettings : _UISettings
@end
@interface SBHomeGestureSettings : SBUISettings
-(void)setHomeGestureEnabled:(BOOL)arg1 ;
@end
%hook SBHomeGestureSettings
-(BOOL)isHomeGestureEnabled{
//return enableGesture();
NSLog(@"HOMEGESTURE SETTINGNOTIFS");
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification
object:nil];
return %orig;
}
%new
-(void)keyboardDidShow:(NSNotification *)sender{
NSLog(@"KEYBOARD UP");
[self setHomeGestureEnabled:FALSE];
}
%new
-(void)keyboardDidHide:(NSNotification *)sender{
NSLog(@"KEYBOARD DOWN");
[self setHomeGestureEnabled:TRUE];
}
%end */
/*-(void)setHomeGestureEnabled:(BOOL)arg1{
%orig(NO);
}*/

//%end
%group remap
int applicationDidFinishLaunching;
long _homeButtonTypeRemap = 1;

%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
applicationDidFinishLaunching = 2;
%orig;
}
%end

%hook SBPressGestureRecognizer
- (void)setAllowedPressTypes:(NSArray *)arg1 {
NSArray * lockHome = @[@104, @101];
NSArray * lockVol = @[@104, @102, @103];
if ([arg1 isEqual:lockVol] && applicationDidFinishLaunching == 2) {
if ([arg1 isEqual:lockVol] && applicationDidFinishLaunching == 2 && [prefs boolForKey:@"remapScreen"]) {
%orig(lockHome);
applicationDidFinishLaunching--;
return;
}
}
%orig;
}
%end

%hook SBClickGestureRecognizer
- (void)addShortcutWithPressTypes:(id)arg1 {
if (applicationDidFinishLaunching == 1) {
if (applicationDidFinishLaunching == 1 && [prefs boolForKey:@"remapScreen"]) {
applicationDidFinishLaunching--;
return;
}
%orig;
}
%end

%hook SBHomeHardwareButton
- (id)initWithScreenshotGestureRecognizer:(id)arg1 homeButtonType:(long long)arg2 buttonActions:(id)arg3 gestureRecognizerConfiguration:(id)arg4 {
return %orig(arg1, _homeButtonTypeRemap, arg3, arg4);
if ([prefs boolForKey:@"remapScreen"]) {
return %orig(arg1, _homeButtonTypeRemap, arg3, arg4);
}
return %orig;
}
- (id)initWithScreenshotGestureRecognizer:(id)arg1 homeButtonType:(long long)arg2 {
return %orig(arg1, _homeButtonTypeRemap);
}
%end
%end

%ctor{
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"12.0")){
%init(remap)
if ([prefs boolForKey:@"remapScreen"]) {
return %orig(arg1, _homeButtonTypeRemap);
}
return %orig;
}
//NSString *bundleID = [NSBundle mainBundle].bundleIdentifier;
/*if([SparkAppList doesIdentifier:@"com.midnight.homegesture.plist" andKey:@"blackList" containBundleIdentifier:bundleID]){
%init(stopGesture);
}*/
//}

//}
%end
Loading

0 comments on commit b5b5b33

Please sign in to comment.