forked from gilshahar7/NotifyMusic
		
	Version 1.3
added an option to disable the tweak while in the now playing app
This commit is contained in:
		
							
								
								
									
										16
									
								
								Tweak.xm
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								Tweak.xm
									
									
									
									
									
								
							@ -1,5 +1,14 @@
 | 
				
			|||||||
#import <UIKit/UIKit.h>
 | 
					#import <UIKit/UIKit.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface SpringBoard
 | 
				
			||||||
 | 
					-(id)_accessibilityFrontMostApplication;
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface UIApplication (myTweak)
 | 
				
			||||||
 | 
					+(id)sharedApplication;
 | 
				
			||||||
 | 
					- (id)bundleIdentifier;
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@interface SBLockScreenManager
 | 
					@interface SBLockScreenManager
 | 
				
			||||||
+(SBLockScreenManager *)sharedInstance;
 | 
					+(SBLockScreenManager *)sharedInstance;
 | 
				
			||||||
-(BOOL)isUILocked;
 | 
					-(BOOL)isUILocked;
 | 
				
			||||||
@ -28,12 +37,16 @@
 | 
				
			|||||||
		NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
 | 
							NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
 | 
				
			||||||
		BOOL enablewhilelocked = [[prefs objectForKey:@"enablewhilelocked"] boolValue];
 | 
							BOOL enablewhilelocked = [[prefs objectForKey:@"enablewhilelocked"] boolValue];
 | 
				
			||||||
		BOOL showalbumname = [[prefs objectForKey:@"showalbumname"] boolValue];
 | 
							BOOL showalbumname = [[prefs objectForKey:@"showalbumname"] boolValue];
 | 
				
			||||||
 | 
							BOOL enableinapp = [[prefs objectForKey:@"enableinapp"] boolValue];
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		double delayInSeconds = 0.5;
 | 
							double delayInSeconds = 0.5;
 | 
				
			||||||
		dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
 | 
							dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
 | 
				
			||||||
		dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
 | 
							dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
 | 
				
			||||||
			if(![cachedTitle isEqualToString:self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"]]){
 | 
								if(![cachedTitle isEqualToString:self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"]]){
 | 
				
			||||||
				cachedTitle = [self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"] copy];
 | 
									cachedTitle = [self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"] copy];
 | 
				
			||||||
				if((enablewhilelocked || (![[%c(SBLockScreenManager) sharedInstance] isUILocked])) && self.isPlaying && ([self.nowPlayingAppDisplayID isEqualToString:@"com.aspiro.TIDAL"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.ondalabs.doppi"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.coppertino.VoxMobile"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.soundcloud.TouchApp"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.Saavn.Saavn"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.apple.Music"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.spotify.client"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.pandora"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.rhapsody.iphone.Rhapsody3"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.google.PlayMusic"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.deezer.Deezer"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.michaelclay.Cesium"])){
 | 
									NSString *frontMost = [[(SpringBoard *)[UIApplication sharedApplication] _accessibilityFrontMostApplication] bundleIdentifier];
 | 
				
			||||||
 | 
									if((enablewhilelocked || (![[%c(SBLockScreenManager) sharedInstance] isUILocked])) && self.isPlaying){
 | 
				
			||||||
 | 
										if(enableinapp || (![self.nowPlayingAppDisplayID isEqualToString:frontMost])){
 | 
				
			||||||
						artist = [NSString stringWithFormat: @"\n%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoArtist"]];
 | 
											artist = [NSString stringWithFormat: @"\n%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoArtist"]];
 | 
				
			||||||
						
 | 
											
 | 
				
			||||||
						if([self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoAlbum"] length] > 1 && showalbumname){
 | 
											if([self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoAlbum"] length] > 1 && showalbumname){
 | 
				
			||||||
@ -48,6 +61,7 @@
 | 
				
			|||||||
						}
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
%end
 | 
					%end
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								control
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								control
									
									
									
									
									
								
							@ -1,7 +1,7 @@
 | 
				
			|||||||
Package: com.gilshahar7.notifymusic
 | 
					Package: com.gilshahar7.notifymusic
 | 
				
			||||||
Name: NotifyMusic
 | 
					Name: NotifyMusic
 | 
				
			||||||
Depends: mobilesubstrate, net.limneos.libbulletin
 | 
					Depends: mobilesubstrate, net.limneos.libbulletin
 | 
				
			||||||
Version: 1.2
 | 
					Version: 1.3
 | 
				
			||||||
Architecture: iphoneos-arm
 | 
					Architecture: iphoneos-arm
 | 
				
			||||||
Description: Creates a banner notification with song metadata when song is changed.
 | 
					Description: Creates a banner notification with song metadata when song is changed.
 | 
				
			||||||
Maintainer: gilshahar7
 | 
					Maintainer: gilshahar7
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,18 @@
 | 
				
			|||||||
			<string>enablewhilelocked</string>
 | 
								<string>enablewhilelocked</string>
 | 
				
			||||||
			<key>label</key>
 | 
								<key>label</key>
 | 
				
			||||||
			<string>Enable while locked</string>
 | 
								<string>Enable while locked</string>
 | 
				
			||||||
 | 
							</dict>
 | 
				
			||||||
 | 
								<dict>
 | 
				
			||||||
 | 
								<key>cell</key>
 | 
				
			||||||
 | 
								<string>PSSwitchCell</string>
 | 
				
			||||||
 | 
								<key>default</key>
 | 
				
			||||||
 | 
								<false/>
 | 
				
			||||||
 | 
								<key>defaults</key>
 | 
				
			||||||
 | 
								<string>com.gilshahar7.notifymusicprefs</string>
 | 
				
			||||||
 | 
								<key>key</key>
 | 
				
			||||||
 | 
								<string>enableinapp</string>
 | 
				
			||||||
 | 
								<key>label</key>
 | 
				
			||||||
 | 
								<string>Enable inside now playing app</string>
 | 
				
			||||||
		</dict>
 | 
							</dict>
 | 
				
			||||||
		<dict>
 | 
							<dict>
 | 
				
			||||||
			<key>cell</key>
 | 
								<key>cell</key>
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user