-Added Songtexte.com Lyrics Hoster
-Repositioned the load more results button into the outline view -Improved the replacing of html escape characters -Lyrics Hosters can now be dragged into a preferred order in the preference window -Changed results outline's column ordering method -Some code changes -Replaced the Buttons in the lyrics pane with an action button -Preferred order of lyrics hosters will now be saved -Translation Improvements
This commit is contained in:
78
iLyrics/iLyrics.m
Normal file
78
iLyrics/iLyrics.m
Normal file
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// iLyrics.m
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 19.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "iLyrics.h"
|
||||
|
||||
@implementation iLyrics
|
||||
|
||||
iLyrics *ilyrics;
|
||||
|
||||
@synthesize lyricsHosters;
|
||||
@synthesize magistrix;
|
||||
@synthesize songtexte;
|
||||
@synthesize mp3Lyrics;
|
||||
@synthesize iTunes;
|
||||
@synthesize spotify;
|
||||
|
||||
+(iLyrics *)sharediLyrics {
|
||||
if (ilyrics == nil) {
|
||||
ilyrics = [[iLyrics alloc] init];
|
||||
}
|
||||
return ilyrics;
|
||||
}
|
||||
|
||||
-(id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
|
||||
spotify = [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
|
||||
magistrix = [[Magistrix alloc] init];
|
||||
songtexte = [[Songtexte alloc] init];
|
||||
//mp3Lyrics = [[MP3Lyrics alloc] init];
|
||||
lyricsHosters = [NSMutableArray arrayWithObjects:magistrix, songtexte, /*mp3Lyrics,*/ nil];
|
||||
[self loadFromDefaults:[NSUserDefaults standardUserDefaults]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)loadFromDefaults:(NSUserDefaults *)defaults {
|
||||
NSArray *hosterNames = [defaults objectForKey:@"Lyrics Hosters"];
|
||||
NSMutableArray *reorderedHosters = [[NSMutableArray alloc] init];
|
||||
for (NSString *name in hosterNames) {
|
||||
id<LyricsHoster> hoster = [self hosterWithName:name];
|
||||
if (hoster) {
|
||||
[reorderedHosters addObject:hoster];
|
||||
}
|
||||
}
|
||||
if ([reorderedHosters count] == [lyricsHosters count]) {
|
||||
lyricsHosters = reorderedHosters;
|
||||
}
|
||||
}
|
||||
|
||||
-(id<LyricsHoster>)preferredHoster {
|
||||
return [lyricsHosters objectAtIndex:0];
|
||||
}
|
||||
|
||||
-(id<LyricsHoster>)hosterWithName:(NSString *)name {
|
||||
for (id<LyricsHoster> hoster in lyricsHosters) {
|
||||
if ([name isEqualToString:[hoster name]]) {
|
||||
return hoster;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void)saveToDefaults:(NSUserDefaults *)defaults {
|
||||
NSMutableArray *hosterNames = [[NSMutableArray alloc] init];
|
||||
for (id<LyricsHoster> hoster in lyricsHosters) {
|
||||
[hosterNames addObject:[hoster name]];
|
||||
}
|
||||
[defaults setObject:hosterNames forKey:@"Lyrics Hosters"];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user