Commit 27ebba3c authored by Felix Paul Kühne's avatar Felix Paul Kühne

library: unify string representation of albums (& tracks) and shows (&...

library: unify string representation of albums (& tracks) and shows (& episodes) on iOS 6 and 7 (close #10190)

Fix a rendering issue where fetched and available artwork may disappear over time
parent 3762ebe5
......@@ -15,24 +15,6 @@
<rect key="frame" x="0.0" y="0.0" width="298" height="220"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" text="Artist Name" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="12" adjustsLetterSpacingToFitWidth="YES" id="29">
<rect key="frame" x="19" y="76" width="257" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<color key="backgroundColor" red="0.1215686275" green="0.1215686275" blue="0.1215686275" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
<color key="shadowColor" cocoaTouchSystemColor="darkTextColor"/>
</label>
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Album Name" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" adjustsLetterSpacingToFitWidth="YES" id="30">
<rect key="frame" x="20" y="96" width="258" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<color key="backgroundColor" red="0.1215686275" green="0.1215686275" blue="0.1215686275" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="0.71999999999999997" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
<color key="shadowColor" cocoaTouchSystemColor="darkTextColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" id="31">
<rect key="frame" x="21" y="14" width="256" height="144"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
......@@ -97,8 +79,6 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="albumNameLabel" destination="30" id="39"/>
<outlet property="artistNameLabel" destination="29" id="40"/>
<outlet property="mediaIsUnreadView" destination="38" id="41"/>
<outlet property="progressView" destination="35" id="42"/>
<outlet property="removeMediaButton" destination="37" id="43"/>
......
......@@ -20,13 +20,6 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Album Name" textAlignment="center" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" minimumFontSize="10" adjustsLetterSpacingToFitWidth="YES" id="30">
<rect key="frame" x="6" y="44" width="122" height="15"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" white="0.71999999999999997" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="none" minimumFontSize="9" adjustsLetterSpacingToFitWidth="YES" id="6">
<rect key="frame" x="137" y="5" width="178" height="42"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
......@@ -36,13 +29,6 @@ Title 2</string>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Artist Name" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="none" minimumFontSize="9" adjustsLetterSpacingToFitWidth="YES" id="35">
<rect key="frame" x="6" y="5" width="122" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="thumbOverlayPhone.png" id="22">
<rect key="frame" x="3" y="2" width="129" height="75"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
......@@ -67,8 +53,6 @@ Title 2</string>
</tableViewCellContentView>
<color key="backgroundColor" white="0.12" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="albumNameLabel" destination="30" id="31"/>
<outlet property="artistNameLabel" destination="35" id="36"/>
<outlet property="mediaIsUnreadView" destination="20" id="21"/>
<outlet property="progressIndicator" destination="27" id="28"/>
<outlet property="subtitleLabel" destination="7" id="8"/>
......
......@@ -24,8 +24,6 @@
@property (nonatomic, strong) IBOutlet UIButton *removeMediaButton;
@property (nonatomic, strong) IBOutlet UIView *mediaIsUnreadView;
@property (nonatomic, strong) IBOutlet UILabel *seriesNameLabel;
@property (nonatomic, strong) IBOutlet UILabel *artistNameLabel;
@property (nonatomic, strong) IBOutlet UILabel *albumNameLabel;
@property (nonatomic, retain) MLFile *mediaObject;
......
......@@ -69,15 +69,12 @@
- (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
{
self.albumNameLabel.text = self.artistNameLabel.text = self.seriesNameLabel.text = @"";
if ([self.mediaObject isKindOfClass:[MLFile class]]) {
MLFile *mediaObject = self.mediaObject;
[self _configureForMLFile:mediaObject];
if (([keyPath isEqualToString:@"computedThumbnail"] || !keyPath) || (!self.thumbnailView.image && [keyPath isEqualToString:@"editing"])) {
if (([keyPath isEqualToString:@"computedThumbnail"] || !keyPath) || (!self.thumbnailView.image && [keyPath isEqualToString:@"editing"]))
self.thumbnailView.image = [VLCThumbnailsCache thumbnailForMediaFile:mediaObject];
}
} else if ([self.mediaObject isKindOfClass:[MLAlbum class]]) {
MLAlbum *mediaObject = (MLAlbum *)self.mediaObject;
[self _configureForAlbum:mediaObject];
......@@ -136,16 +133,10 @@
{
self.titleLabel.text = show.name;
NSUInteger count = show.episodes.count;
if (SYSTEM_RUNS_IOS7_OR_LATER) {
NSString *string = @"";
if (show.releaseYear)
string = [NSString stringWithFormat:@"%@ — ", show.releaseYear];
self.subtitleLabel.text = [string stringByAppendingString:[NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_EPISODES", @"") : NSLocalizedString(@"LIBRARY_SINGLE_EPISODE", @""), count, show.unreadEpisodes.count]];
} else {
self.artistNameLabel.text = @"";
self.albumNameLabel.text = show.releaseYear;
self.subtitleLabel.text = [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_EPISODES", @"") : NSLocalizedString(@"LIBRARY_SINGLE_EPISODE", @""), count, show.unreadEpisodes.count];
}
NSString *string = @"";
if (show.releaseYear)
string = [NSString stringWithFormat:@"%@ — ", show.releaseYear];
self.subtitleLabel.text = [string stringByAppendingString:[NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_EPISODES", @"") : NSLocalizedString(@"LIBRARY_SINGLE_EPISODE", @""), count, show.unreadEpisodes.count]];
self.mediaIsUnreadView.hidden = YES;
self.progressView.hidden = YES;
}
......@@ -154,15 +145,8 @@
{
MLFile *anyFileFromTrack = albumTrack.files.anyObject;
if (SYSTEM_RUNS_IOS7_OR_LATER)
self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@ — %@", albumTrack.artist, [NSString stringWithFormat:NSLocalizedString(@"LIBRARY_TRACK_N", @""), albumTrack.trackNumber.intValue], [VLCTime timeWithNumber:[anyFileFromTrack duration]]];
else {
self.artistNameLabel.text = albumTrack.artist;
self.albumNameLabel.text = [NSString stringWithFormat:NSLocalizedString(@"LIBRARY_TRACK_N", @""), albumTrack.trackNumber.intValue];
self.subtitleLabel.text = [NSString stringWithFormat:@"%@", [VLCTime timeWithNumber:[anyFileFromTrack duration]]];
}
self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@ — %@", albumTrack.artist, [NSString stringWithFormat:NSLocalizedString(@"LIBRARY_TRACK_N", @""), albumTrack.trackNumber.intValue], [VLCTime timeWithNumber:[anyFileFromTrack duration]]];
self.titleLabel.text = albumTrack.title;
self.thumbnailView.image = nil;
[self _showPositionOfItem:anyFileFromTrack];
}
......@@ -186,20 +170,13 @@
self.titleLabel.text = album.name;
MLAlbumTrack *anyTrack = [album.tracks anyObject];
NSUInteger count = album.tracks.count;
if (SYSTEM_RUNS_IOS7_OR_LATER) {
NSMutableString *string = [[NSMutableString alloc] init];
if (anyTrack) {
[string appendString:anyTrack.artist];
[string appendString:@" — "];
}
[string appendFormat:@"%@ — %@", [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_TRACKS", @"") : NSLocalizedString(@"LIBRARY_SINGLE_TRACK", @""), count], album.releaseYear];
self.subtitleLabel.text = string;
} else {
self.artistNameLabel.text = anyTrack? anyTrack.artist: @"";
self.albumNameLabel.text = album.releaseYear;
self.subtitleLabel.text = [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_TRACKS", @"") : NSLocalizedString(@"LIBRARY_SINGLE_TRACK", @""), count];
NSMutableString *string = [[NSMutableString alloc] init];
if (anyTrack) {
[string appendString:anyTrack.artist];
[string appendString:@" — "];
}
self.thumbnailView.image = nil;
[string appendFormat:@"%@ — %@", [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_TRACKS", @"") : NSLocalizedString(@"LIBRARY_SINGLE_TRACK", @""), count], album.releaseYear];
self.subtitleLabel.text = string;
self.mediaIsUnreadView.hidden = YES;
self.progressView.hidden = YES;
}
......@@ -207,19 +184,12 @@
- (void)_configureForMLFile:(MLFile *)mediaFile
{
if (mediaFile.isAlbumTrack) {
if (SYSTEM_RUNS_IOS7_OR_LATER) {
NSString *string = @"";
if (mediaFile.albumTrack.artist)
string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
else if (mediaFile.albumTrack.album.name)
string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
self.titleLabel.text = [string stringByAppendingString:(mediaFile.albumTrack.title.length > 1) ? mediaFile.albumTrack.title : mediaFile.title];
} else {
self.artistNameLabel.text = mediaFile.albumTrack.artist;
self.albumNameLabel.text = mediaFile.albumTrack.album.name;
self.titleLabel.text = (mediaFile.albumTrack.title.length > 1) ? mediaFile.albumTrack.title : mediaFile.title;
}
self.thumbnailView.image = nil;
NSString *string = @"";
if (mediaFile.albumTrack.artist)
string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
else if (mediaFile.albumTrack.album.name)
string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
self.titleLabel.text = [string stringByAppendingString:(mediaFile.albumTrack.title.length > 1) ? mediaFile.albumTrack.title : mediaFile.title];
} else
self.titleLabel.text = mediaFile.title;
......
......@@ -21,8 +21,6 @@
@property (nonatomic, strong) IBOutlet UIImageView *thumbnailView;
@property (nonatomic, strong) IBOutlet VLCLinearProgressIndicator *progressIndicator;
@property (nonatomic, strong) IBOutlet UIView *mediaIsUnreadView;
@property (nonatomic, strong) IBOutlet UILabel *artistNameLabel;
@property (nonatomic, strong) IBOutlet UILabel *albumNameLabel;
@property (nonatomic, strong) NSManagedObject *mediaObject;
......
......@@ -83,15 +83,12 @@
- (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
{
self.albumNameLabel.text = self.artistNameLabel.text = @"";
if ([self.mediaObject isKindOfClass:[MLFile class]]) {
MLFile *mediaObject = (MLFile*)self.mediaObject;
[self _configureForMLFile:mediaObject];
if (([keyPath isEqualToString:@"computedThumbnail"] || !keyPath || (!self.thumbnailView.image && [keyPath isEqualToString:@"editing"])))
self.thumbnailView.image = [VLCThumbnailsCache thumbnailForMediaFile:mediaObject];
} else if ([self.mediaObject isKindOfClass:[MLAlbum class]]) {
MLAlbum *mediaObject = (MLAlbum *)self.mediaObject;
[self _configureForAlbum:mediaObject];
......@@ -143,16 +140,10 @@
{
self.titleLabel.text = show.name;
NSUInteger count = show.episodes.count;
if (SYSTEM_RUNS_IOS7_OR_LATER) {
NSString *string = @"";
if (show.releaseYear)
string = [NSString stringWithFormat:@"%@ — ", show.releaseYear];
self.subtitleLabel.text = [string stringByAppendingString:[NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_EPISODES", @"") : NSLocalizedString(@"LIBRARY_SINGLE_EPISODE", @""), count, show.unreadEpisodes.count]];
} else {
self.artistNameLabel.text = @"";
self.albumNameLabel.text = show.releaseYear;
self.subtitleLabel.text = [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_EPISODES", @"") : NSLocalizedString(@"LIBRARY_SINGLE_EPISODE", @""), count, show.unreadEpisodes.count];
}
NSString *string = @"";
if (show.releaseYear)
string = [NSString stringWithFormat:@"%@ — ", show.releaseYear];
self.subtitleLabel.text = [string stringByAppendingString:[NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_EPISODES", @"") : NSLocalizedString(@"LIBRARY_SINGLE_EPISODE", @""), count, show.unreadEpisodes.count]];
self.mediaIsUnreadView.hidden = YES;
self.progressIndicator.hidden = YES;
}
......@@ -160,16 +151,8 @@
- (void)_configureForAlbumTrack:(MLAlbumTrack *)albumTrack
{
MLFile *anyFileFromTrack = albumTrack.files.anyObject;
if (SYSTEM_RUNS_IOS7_OR_LATER)
self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@ — %@", albumTrack.artist, [NSString stringWithFormat:NSLocalizedString(@"LIBRARY_TRACK_N", @""), albumTrack.trackNumber.intValue], [VLCTime timeWithNumber:[anyFileFromTrack duration]]];
else {
self.artistNameLabel.text = albumTrack.artist;
self.albumNameLabel.text = [NSString stringWithFormat:NSLocalizedString(@"LIBRARY_TRACK_N", @""), albumTrack.trackNumber.intValue];
self.subtitleLabel.text = [NSString stringWithFormat:@"%@", [VLCTime timeWithNumber:[anyFileFromTrack duration]]];
}
self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@ — %@", albumTrack.artist, [NSString stringWithFormat:NSLocalizedString(@"LIBRARY_TRACK_N", @""), albumTrack.trackNumber.intValue], [VLCTime timeWithNumber:[anyFileFromTrack duration]]];
self.titleLabel.text = albumTrack.title;
self.thumbnailView.image = nil;
[self _showPositionOfItem:anyFileFromTrack];
}
......@@ -193,20 +176,13 @@
self.titleLabel.text = album.name;
MLAlbumTrack *anyTrack = [album.tracks anyObject];
NSUInteger count = album.tracks.count;
if (SYSTEM_RUNS_IOS7_OR_LATER) {
NSMutableString *string = [[NSMutableString alloc] init];
if (anyTrack) {
[string appendString:anyTrack.artist];
[string appendString:@" — "];
}
[string appendFormat:@"%@ — %@", [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_TRACKS", @"") : NSLocalizedString(@"LIBRARY_SINGLE_TRACK", @""), count], album.releaseYear];
self.subtitleLabel.text = string;
} else {
self.artistNameLabel.text = anyTrack? anyTrack.artist: @"";
self.albumNameLabel.text = album.releaseYear;
self.subtitleLabel.text = [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_TRACKS", @"") : NSLocalizedString(@"LIBRARY_SINGLE_TRACK", @""), count];
NSMutableString *string = [[NSMutableString alloc] init];
if (anyTrack) {
[string appendString:anyTrack.artist];
[string appendString:@" — "];
}
self.thumbnailView.image = nil;
[string appendFormat:@"%@ — %@", [NSString stringWithFormat:(count > 1) ? NSLocalizedString(@"LIBRARY_TRACKS", @"") : NSLocalizedString(@"LIBRARY_SINGLE_TRACK", @""), count], album.releaseYear];
self.subtitleLabel.text = string;
self.mediaIsUnreadView.hidden = YES;
self.progressIndicator.hidden = YES;
}
......@@ -214,19 +190,12 @@
- (void)_configureForMLFile:(MLFile *)mediaFile
{
if (mediaFile.isAlbumTrack) {
if (SYSTEM_RUNS_IOS7_OR_LATER) {
NSString *string = @"";
if (mediaFile.albumTrack.artist)
string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
else if (mediaFile.albumTrack.album.name)
string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
self.titleLabel.text = [string stringByAppendingString:(mediaFile.albumTrack.title.length > 1) ? mediaFile.albumTrack.title : mediaFile.title];
} else {
self.artistNameLabel.text = mediaFile.albumTrack.artist;
self.albumNameLabel.text = mediaFile.albumTrack.album.name;
self.titleLabel.text = (mediaFile.albumTrack.title.length > 1) ? mediaFile.albumTrack.title : mediaFile.title;
}
self.thumbnailView.image = nil;
NSString *string = @"";
if (mediaFile.albumTrack.artist)
string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
else if (mediaFile.albumTrack.album.name)
string = [NSString stringWithFormat:@"%@ — ", mediaFile.albumTrack.artist];
self.titleLabel.text = [string stringByAppendingString:(mediaFile.albumTrack.title.length > 1) ? mediaFile.albumTrack.title : mediaFile.title];
} else
self.titleLabel.text = mediaFile.title;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment