From 79b42fd1b46eab09474ab4530e6959a52676b079 Mon Sep 17 00:00:00 2001 From: Grant Paul Date: Thu, 3 Feb 2011 15:40:19 -0800 Subject: Fix VoiceOver (at least on 4.x). Does not cause issues on other firmwares, since if the fix does not work it will just bail out (checks all methods, etc). --- MobileCydia.mm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'MobileCydia.mm') diff --git a/MobileCydia.mm b/MobileCydia.mm index 5a5afed..ee88c00 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -9089,6 +9089,33 @@ MSHook(void, UIHardware$_playSystemSound$, Class self, SEL _cmd, int sound) { } } +Class $UIApplication; + +MSHook(void, UIApplication$_updateApplicationAccessibility, UIApplication *self, SEL _cmd) { + static BOOL initialized = NO; + static BOOL started = NO; + + NSDictionary *dict([[[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.Accessibility.plist"] autorelease]); + BOOL enabled = [[dict objectForKey:@"VoiceOverTouchEnabled"] boolValue] || [[dict objectForKey:@"VoiceOverTouchEnabledByiTunes"] boolValue]; + + if ([self respondsToSelector:@selector(_accessibilityBundlePrincipalClass)]) { + id bundle = [self performSelector:@selector(_accessibilityBundlePrincipalClass)]; + if (![bundle respondsToSelector:@selector(_accessibilityStopServer)]) return; + if (![bundle respondsToSelector:@selector(_accessibilityStartServer)]) return; + + if (initialized && !enabled) { + initialized = NO; + [bundle performSelector:@selector(_accessibilityStopServer)]; + } else if (enabled) { + initialized = YES; + if (!started) { + started = YES; + [bundle performSelector:@selector(_accessibilityStartServer)]; + } + } + } +} + int main(int argc, char *argv[]) { _pooled _trace(); @@ -9116,6 +9143,13 @@ int main(int argc, char *argv[]) { _pooled _UIHardware$_playSystemSound$ = reinterpret_cast(method_getImplementation(UIHardware$_playSystemSound$)); method_setImplementation(UIHardware$_playSystemSound$, reinterpret_cast(&$UIHardware$_playSystemSound$)); } + + $UIApplication = objc_getClass("UIApplication"); + Method UIApplication$_updateApplicationAccessibility(class_getInstanceMethod($UIApplication, @selector(_updateApplicationAccessibility))); + if (UIApplication$_updateApplicationAccessibility != NULL) { + _UIApplication$_updateApplicationAccessibility = reinterpret_cast(method_getImplementation(UIApplication$_updateApplicationAccessibility)); + method_setImplementation(UIApplication$_updateApplicationAccessibility, reinterpret_cast(&$UIApplication$_updateApplicationAccessibility)); + } /* }}} */ /* Set Locale {{{ */ Locale_ = CFLocaleCopyCurrent(); -- cgit v1.2.3 From 003fc610c40f29f5e9195a890b198e48aad14c49 Mon Sep 17 00:00:00 2001 From: Grant Paul Date: Thu, 3 Feb 2011 15:59:51 -0800 Subject: Make PackageCell, SourceCell, and SectionCell have reasonable VoiceOver labels. --- MobileCydia.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'MobileCydia.mm') diff --git a/MobileCydia.mm b/MobileCydia.mm index ee88c00..cc00590 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -4993,6 +4993,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [self setNeedsDisplay]; } +- (NSString *) accessibilityLabel { + return [NSString stringWithFormat:UCLocalize("COLON_DELIMITED"), name_, description_]; +} + - (void) setPackage:(Package *)package { [self clearPackage]; [package parse]; @@ -5221,6 +5225,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [switch_ setFrame:CGRectMake(frame.size.width - 102, 9, rect.size.width, rect.size.height)]; } +- (NSString *) accessibilityLabel { + return name_; +} + - (void) drawContentRect:(CGRect)rect { bool highlighted(highlighted_ && !editing_); @@ -7447,6 +7455,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } return self; } +- (NSString *) accessibilityLabel { + return label_; +} + - (void) drawContentRect:(CGRect)rect { bool highlighted(highlighted_); float width(rect.size.width); -- cgit v1.2.3