Browse Source

Updated for Version 1.2

-Added iOS 9 support
-Added preference pane to disable the tweak on the lockscreen and displaying album name as the title of the banner
-Added support to the folowing apps: SoundCloud, Saavn, VOX, Doppi and Tidal.
master
Gil Shahar 7 years ago
parent
commit
c24879880b
10 changed files with 158 additions and 14 deletions
  1. +4
    -2
      Makefile
  2. +35
    -11
      Tweak.xm
  3. +1
    -1
      control
  4. +14
    -0
      notifymusicprefs/Makefile
  5. +24
    -0
      notifymusicprefs/Resources/Info.plist
  6. BIN
      notifymusicprefs/Resources/NotifyMusic@2x.png
  7. +41
    -0
      notifymusicprefs/Resources/Root.plist
  8. +21
    -0
      notifymusicprefs/entry.plist
  9. +5
    -0
      notifymusicprefs/nmpRootListController.h
  10. +13
    -0
      notifymusicprefs/nmpRootListController.m

+ 4
- 2
Makefile View File

@@ -1,14 +1,16 @@
ARCHS = armv7 arm64
VALID_ARCHS = armv7 armv7s arm64

include theos/makefiles/common.mk
include $(THEOS)/makefiles/common.mk

TWEAK_NAME = NotifyMusic
NotifyMusic_FILES = Tweak.xm
NotifyMusic_FRAMEWORKS = UIKit
NotifyMusic_FRAMEWORKS = UIKit MediaPlayer
NotifyMusic_LIBRARIES = bulletin

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
install.exec "killall -9 SpringBoard"
SUBPROJECTS += notifymusicprefs
include $(THEOS_MAKE_PATH)/aggregate.mk

+ 35
- 11
Tweak.xm View File

@@ -1,8 +1,22 @@
#import <UIKit/UIKit.h>

@interface SBApplication
@end

@interface SpringBoard
+(SpringBoard *)sharedApplication;
-(SBApplication *)_accessibilityFrontMostApplication;
@end

@interface SBLockScreenManager
+(SBLockScreenManager *)sharedInstance;
-(BOOL)isUILocked;
@end

@interface MPUNowPlayingMetadata
@property (nonatomic,readonly) NSString * title;
@property (nonatomic,readonly) NSString * artist;
@property (nonatomic,readonly) NSString * album;
@end

@interface MPUNowPlayingController
@@ -10,6 +24,7 @@
@property (nonatomic,readonly) NSString * nowPlayingAppDisplayID;
@property (nonatomic,readonly) MPUNowPlayingMetadata * currentNowPlayingMetadata;
@property (nonatomic,readonly) UIImage * currentNowPlayingArtwork;
@property (nonatomic,readonly) NSDictionary * currentNowPlayingInfo;
@end

@interface JBBulletinManager : NSObject
@@ -26,22 +41,31 @@
%hook MPUNowPlayingController
static NSString *cachedTitle;
static NSString *artist;
static NSString *album;
-(void)_updateCurrentNowPlaying{
%orig;
NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.notifymusicprefs.plist";
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
BOOL enablewhilelocked = [[prefs objectForKey:@"enablewhilelocked"] boolValue];
BOOL showalbumname = [[prefs objectForKey:@"showalbumname"] boolValue];
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];
if([self.currentNowPlayingMetadata.artist length] > 1){
artist = [NSString stringWithFormat: @"\nBy: %@", self.currentNowPlayingMetadata.artist];
}else{
artist = @"";
}
if(self.currentNowPlayingArtwork != nil){
[[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:@"Now Playing" message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingMetadata.title, artist] bundleID:self.nowPlayingAppDisplayID hasSound:false soundID:0 vibrateMode:0 soundPath:@"" attachmentImage:self.currentNowPlayingArtwork overrideBundleImage:nil];
}else{
[[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:@"Now Playing" message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingMetadata.title, artist] bundleID:self.nowPlayingAppDisplayID];
if(![cachedTitle isEqualToString:self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"]]){
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"])){
artist = [NSString stringWithFormat: @"\n%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoArtist"]];
if([self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoAlbum"] length] > 1 && showalbumname){
album = self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoAlbum"];
}else{
album = @"Now Playing";
}
if(self.currentNowPlayingArtwork != nil){
[[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:album message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"], artist] bundleID:self.nowPlayingAppDisplayID hasSound:false soundID:0 vibrateMode:0 soundPath:@"" attachmentImage:self.currentNowPlayingArtwork overrideBundleImage:nil];
}else{
[[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:album message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"], artist] bundleID:self.nowPlayingAppDisplayID];
}
}
}
});

+ 1
- 1
control View File

@@ -1,7 +1,7 @@
Package: com.gilshahar7.notifymusic
Name: NotifyMusic
Depends: mobilesubstrate, net.limneos.libbulletin
Version: 1.0
Version: 1.2
Architecture: iphoneos-arm
Description: Creates a banner notification with song metadata when song is changed.
Maintainer: gilshahar7

+ 14
- 0
notifymusicprefs/Makefile View File

@@ -0,0 +1,14 @@
ARCHS = armv7 arm64
include $(THEOS)/makefiles/common.mk

BUNDLE_NAME = notifymusicprefs
notifymusicprefs_FILES = nmpRootListController.m
notifymusicprefs_INSTALL_PATH = /Library/PreferenceBundles
notifymusicprefs_FRAMEWORKS = UIKit
notifymusicprefs_PRIVATE_FRAMEWORKS = Preferences

include $(THEOS_MAKE_PATH)/bundle.mk

internal-stage::
$(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END)
$(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/notifymusicprefs.plist$(ECHO_END)

+ 24
- 0
notifymusicprefs/Resources/Info.plist View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>notifymusicprefs</string>
<key>CFBundleIdentifier</key>
<string>com.gilshahar7.notifymusicprefs</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string>nmpRootListController</string>
</dict>
</plist>

BIN
notifymusicprefs/Resources/NotifyMusic@2x.png View File

Before After
Width: 58  |  Height: 58  |  Size: 5.3KB

+ 41
- 0
notifymusicprefs/Resources/Root.plist View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>NotifyMusic</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>enablewhilelocked</string>
<key>label</key>
<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>showalbumname</string>
<key>label</key>
<string>Show album name in title</string>
</dict>
</array>
<key>title</key>
<string>NotifyMusic</string>
</dict>
</plist>

+ 21
- 0
notifymusicprefs/entry.plist View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>entry</key>
<dict>
<key>bundle</key>
<string>notifymusicprefs</string>
<key>cell</key>
<string>PSLinkCell</string>
<key>detail</key>
<string>nmpRootListController</string>
<key>icon</key>
<string>NotifyMusic.png</string>
<key>isController</key>
<true/>
<key>label</key>
<string>NotifyMusic</string>
</dict>
</dict>
</plist>

+ 5
- 0
notifymusicprefs/nmpRootListController.h View File

@@ -0,0 +1,5 @@
#import <Preferences/PSListController.h>

@interface nmpRootListController : PSListController

@end

+ 13
- 0
notifymusicprefs/nmpRootListController.m View File

@@ -0,0 +1,13 @@
#include "nmpRootListController.h"

@implementation nmpRootListController

- (NSArray *)specifiers {
if (!_specifiers) {
_specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
}

return _specifiers;
}

@end

Loading…
Cancel
Save