Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
39 lines (30 sloc) 1.182 kb
#import <FSSwitchDataSource.h>
#import <FSSwitchPanel.h>
@interface SBMediaController
+ (id)sharedInstance;
- (BOOL)isRingerMuted;
- (void)setRingerMuted:(BOOL)muted;
@end
@interface RingerSwitch : NSObject <FSSwitchDataSource>
@end
@implementation RingerSwitch
static void RingerSettingsChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
[[FSSwitchPanel sharedPanel] stateDidChangeForSwitchIdentifier:[NSBundle bundleForClass:[RingerSwitch class]].bundleIdentifier];
}
+ (void)load
{
CFNotificationCenterRef center = CFNotificationCenterGetDarwinNotifyCenter();
CFNotificationCenterAddObserver(center, NULL, RingerSettingsChanged, CFSTR("com.apple.springboard.ringerstate"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}
- (FSSwitchState)stateForSwitchIdentifier:(NSString *)switchIdentifier
{
return ![[%c(SBMediaController) sharedInstance] isRingerMuted];
}
- (void)applyState:(FSSwitchState)newState forSwitchIdentifier:(NSString *)switchIdentifier
{
if (newState == FSSwitchStateIndeterminate)
return;
[[%c(SBMediaController) sharedInstance] setRingerMuted:!newState];
}
@end
Jump to Line
Something went wrong with that request. Please try again.