#import <SpringBoard/SpringBoard.h>
MSClassHook(SpringBoard)
+
MSClassHook(SBAwayController)
MSClassHook(SBAwayView)
+MSClassHook(SBAwayViewController)
MSClassHook(SBAwayWindow)
#define _trace() \
- (void) enableCydget:(SBAwayController *)away {
if (NSString *plugin = [self objectForKey:@"CYPlugin"] ?: [self objectForKey:@"Plugin"]) {
+ ++online_;
UIKeyboardEnableAutomaticAppearance();
+
[[$UIPeripheralHost sharedInstance] createAutomaticKeyboardIfNeeded];
[[UITextEffectsWindow sharedTextEffectsWindow] setWindowLevel:1000];
[away enableLockScreenBundleWithName:plugin];
- ++online_;
}
}
- (void) disableCydget:(SBAwayController *)away {
if (NSString *plugin = [self objectForKey:@"CYPlugin"] ?: [self objectForKey:@"Plugin"]) {
- --online_;
[away disableLockScreenBundleWithName:plugin];
[$UIPeripheralHost _releaseSharedInstance];
+
UIKeyboardDisableAutomaticAppearance();
+ --online_;
}
}
@end
+// avoid rendering a keyboard onto the default SBAwayView while automatic keyboard is online
+MSInstanceMessageHook0(UIView *, SBAwayView, inputView) {
+ if (online_ == 0)
+ return MSOldCall();
+
+ return [[[UIView alloc] init] autorelease];
+}
+
+// by default, keyboard actions are redirected to SBAwayController and press menu button
MSInstanceMessageHook1(void, SpringBoard, handleKeyEvent, GSEventRef, event) {
- MSSuperCall(event);
+ if (online_ == 0)
+ return MSOldCall(event);
+
+ return MSSuperCall(event);
}
MSInstanceMessageHook0(BOOL, SBAwayController, handleMenuButtonTap) {
MSInstanceMessageHook0(void, SBAwayController, _undimScreen) {
menu_ = false;
- [[cydgets_ objectAtIndex:active_] enableCydget:[$SBAwayController sharedAwayController]];
- MSOldCall();
+ [[cydgets_ objectAtIndex:active_] enableCydget:self];
+ [[[self awayView] window] makeKeyWindow];
+ return MSOldCall();
}
static void Deactivate_(SBAwayController *self) {
}
MSInstanceMessageHook1(void, SBAwayView, addGestureRecognizer, id, recognizer) {
- // MSOldCall(recognizer);
+ if (online_ == 0)
+ return MSOldCall(recognizer);
}
MSInstanceMessageHook1(void, SBAwayWindow, sendGSEvent, GSEventRef, event) {
- if (online_ != 0)
- MSSuperCall(event);
- else
- MSOldCall(event);
+ NSLog(@"sendGSEvent");
+ if (online_ == 0)
+ return MSOldCall(event);
+
+ return MSSuperCall(event);
}
#define Cydgets_ @"/System/Library/LockCydgets"