diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d9cd4ac --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +ARCHS = armv7 arm64 +VALID_ARCHS = armv7 armv7s arm64 + +include theos/makefiles/common.mk + +TWEAK_NAME = NotifyMusic +NotifyMusic_FILES = Tweak.xm +NotifyMusic_FRAMEWORKS = CoreTelephony AudioToolbox UIKit +NotifyMusic_LIBRARIES = bulletin + +include $(THEOS_MAKE_PATH)/tweak.mk + +after-install:: + install.exec "killall -9 SpringBoard" diff --git a/NotifyMusic.plist b/NotifyMusic.plist new file mode 100644 index 0000000..10dc654 --- /dev/null +++ b/NotifyMusic.plist @@ -0,0 +1 @@ +{ Filter = { Bundles = ( "com.apple.springboard" ); }; } diff --git a/Tweak.xm b/Tweak.xm new file mode 100644 index 0000000..85df270 --- /dev/null +++ b/Tweak.xm @@ -0,0 +1,52 @@ +#import +#import +#import + +@interface MPUNowPlayingMetadata +@property (nonatomic,readonly) NSString * title; +@property (nonatomic,readonly) NSString * artist; +@end + +@interface MPUNowPlayingController +@property bool isPlaying; +@property (nonatomic,readonly) NSString * nowPlayingAppDisplayID; +@property (nonatomic,readonly) MPUNowPlayingMetadata * currentNowPlayingMetadata; +@end + + +@interface JBBulletinManager : NSObject ++(id)sharedInstance; +-(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID; +-(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID soundPath:(NSString *)soundPath; +-(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID soundID:(int)inSoundID; +-(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overrideBundleImage:(UIImage *)overridBundleImage; +-(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overrideBundleImage:(UIImage *)overridBundleImage soundPath:(NSString *)soundPath; +-(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overridBundleImage:(UIImage *)overridBundleImage soundID:(int)inSoundID; +-(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID hasSound:(BOOL)hasSound soundID:(int)soundID vibrateMode:(int)vibrate soundPath:(NSString *)soundPath attachmentImage:(UIImage *)attachmentImage overrideBundleImage:(UIImage *)overrideBundleImage; +@end + + + +%hook MPUNowPlayingController +static NSString *cachedTitle; +-(void)_updateCurrentNowPlaying{ +%orig; + + +double delayInSeconds = 0.5; +dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); +dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + +if(self.isPlaying && ([self.nowPlayingAppDisplayID isEqualToString:@"com.apple.Music"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.spotify.client"]) && ![cachedTitle isEqualToString:self.currentNowPlayingMetadata.title]){ + +cachedTitle = [self.currentNowPlayingMetadata.title copy]; + + +[[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:self.currentNowPlayingMetadata.title message:self.currentNowPlayingMetadata.artist bundleID:self.nowPlayingAppDisplayID]; + + +} + +}); +} +%end diff --git a/com.gilshahar7.notifymusic_0.0.1-29_iphoneos-arm.deb b/com.gilshahar7.notifymusic_0.0.1-29_iphoneos-arm.deb new file mode 100644 index 0000000..e329d3f Binary files /dev/null and b/com.gilshahar7.notifymusic_0.0.1-29_iphoneos-arm.deb differ diff --git a/control b/control new file mode 100644 index 0000000..58a9e1f --- /dev/null +++ b/control @@ -0,0 +1,9 @@ +Package: com.gilshahar7.notifymusic +Name: NotifyMusic +Depends: mobilesubstrate, net.limneos.libbulletin +Version: 0.0.1 +Architecture: iphoneos-arm +Description: An awesome MobileSubstrate tweak! +Maintainer: gilshahar7 +Author: gilshahar7 +Section: Tweaks