Commit 06c877d0 authored by Carola's avatar Carola Committed by Felix Paul Kühne

push a tableviewcontroller for groupitems and a detailviewcontroller otherwise

parent 86374098
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="3737"/> <plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="3737"/>
</dependencies> </dependencies>
<scenes> <scenes>
<!--Interface Controller--> <!--tableViewController-->
<scene sceneID="aou-V4-d1y"> <scene sceneID="aou-V4-d1y">
<objects> <objects>
<controller id="AgC-eL-Hgc" customClass="InterfaceController"> <controller identifier="tableViewController" id="AgC-eL-Hgc" customClass="InterfaceController">
<items> <items>
<button width="1" alignment="left" title="︿" id="fUJ-qB-19l"> <button width="1" alignment="left" title="︿" id="fUJ-qB-19l">
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<table alignment="left" id="lC4-Vd-sgP"> <table alignment="left" id="lC4-Vd-sgP">
<items> <items>
<tableRow identifier="mediaRow" id="QhF-se-FCS" customClass="VLCRowController"> <tableRow identifier="mediaRow" id="QhF-se-FCS" customClass="VLCRowController">
<group key="rootItem" width="1" height="60" alignment="left" contentMode="scaleAspectFill" layout="vertical" radius="10" id="IQK-uE-8Jr"> <group key="rootItem" width="1" height="60" alignment="left" contentMode="scaleAspectFill" layout="vertical" radius="5" id="IQK-uE-8Jr">
<items> <items>
<label alignment="left" verticalAlignment="bottom" text="title" numberOfLines="0" minimumScaleFactor="0.90000000000000002" id="bUB-PE-2P0"/> <label alignment="left" verticalAlignment="bottom" text="title" numberOfLines="0" minimumScaleFactor="0.90000000000000002" id="bUB-PE-2P0"/>
</items> </items>
......
...@@ -28,13 +28,16 @@ static NSString *const VLCDBUpdateNotificationRemote = @"org.videolan.ios-app.db ...@@ -28,13 +28,16 @@ static NSString *const VLCDBUpdateNotificationRemote = @"org.videolan.ios-app.db
typedef enum { typedef enum {
VLCLibraryModeAllFiles = 0, VLCLibraryModeAllFiles = 0,
VLCLibraryModeAllAlbums = 1, VLCLibraryModeAllAlbums = 1,
VLCLibraryModeAllSeries = 2 VLCLibraryModeAllSeries = 2,
VLCLibraryModeInGroup = 3
} VLCLibraryMode; } VLCLibraryMode;
@interface InterfaceController() @interface InterfaceController()
@property (nonatomic, strong) VLCWatchTableController *tableController; @property (nonatomic, strong) VLCWatchTableController *tableController;
@property (nonatomic) VLCLibraryMode libraryMode; @property (nonatomic) VLCLibraryMode libraryMode;
@property (nonatomic) BOOL needsUpdate; @property (nonatomic) BOOL needsUpdate;
@property (nonatomic) id groupObject;
@end @end
@implementation InterfaceController @implementation InterfaceController
...@@ -44,20 +47,32 @@ typedef enum { ...@@ -44,20 +47,32 @@ typedef enum {
NSLog(@"%s",__PRETTY_FUNCTION__); NSLog(@"%s",__PRETTY_FUNCTION__);
NSURL *groupURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.org.videolan.vlc-ios"]; NSURL *groupURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.org.videolan.vlc-ios"];
[self setupMenuButtons];
self.libraryMode = VLCLibraryModeAllFiles;
MLMediaLibrary *mediaLibrary = [MLMediaLibrary sharedMediaLibrary]; MLMediaLibrary *mediaLibrary = [MLMediaLibrary sharedMediaLibrary];
mediaLibrary.libraryBasePath = groupURL.path; mediaLibrary.libraryBasePath = groupURL.path;
mediaLibrary.additionalPersitentStoreOptions = @{NSReadOnlyPersistentStoreOption : @YES}; mediaLibrary.additionalPersitentStoreOptions = @{NSReadOnlyPersistentStoreOption : @YES};
self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", nil); if (context == nil) {
self.libraryMode = VLCLibraryModeAllFiles;
self.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", nil); [self setupMenuButtons];
self.emptyLibraryLabelLong.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", nil); self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", nil);
self.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", nil);
self.emptyLibraryLabelLong.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", nil);
} else {
self.groupObject = context;
self.title = [self.groupObject name];
self.libraryMode = VLCLibraryModeInGroup;
}
[[VLCNotificationRelay sharedRelay] addRelayRemoteName:VLCDBUpdateNotificationRemote toLocalName:VLCDBUpdateNotification]; [[VLCNotificationRelay sharedRelay] addRelayRemoteName:VLCDBUpdateNotificationRemote toLocalName:VLCDBUpdateNotification];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateData) name:VLCDBUpdateNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateData) name:VLCDBUpdateNotification object:nil];
[self setupTableController];
[self updateData];
}
- (void)setupTableController {
VLCWatchTableController *tableController = [[VLCWatchTableController alloc] init]; VLCWatchTableController *tableController = [[VLCWatchTableController alloc] init];
tableController.table = self.table; tableController.table = self.table;
tableController.previousPageButton = self.previousButton; tableController.previousPageButton = self.previousButton;
...@@ -71,8 +86,6 @@ typedef enum { ...@@ -71,8 +86,6 @@ typedef enum {
[weakSelf configureTableRowController:controller withObject:object]; [weakSelf configureTableRowController:controller withObject:object];
}; };
self.tableController = tableController; self.tableController = tableController;
[self updateData];
} }
- (void) dealloc { - (void) dealloc {
...@@ -90,7 +103,9 @@ typedef enum { ...@@ -90,7 +103,9 @@ typedef enum {
- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex { - (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {
id object = self.tableController.displayedObjects[rowIndex]; id object = self.tableController.displayedObjects[rowIndex];
if ([object isKindOfClass:[MLFile class]]) { if ([object isKindOfClass:[MLAlbum class]] || [object isKindOfClass:[MLLabel class]] || [object isKindOfClass:[MLShow class]]) {
[self pushControllerWithName:@"tableViewController" context:object];
} else {
[self pushControllerWithName:@"detailInfo" context:object]; [self pushControllerWithName:@"detailInfo" context:object];
} }
} }
...@@ -142,6 +157,7 @@ typedef enum { ...@@ -142,6 +157,7 @@ typedef enum {
} }
- (void)configureTableRowController:(id)rowController withObject:(id)storageObject { - (void)configureTableRowController:(id)rowController withObject:(id)storageObject {
VLCRowController *row = rowController; VLCRowController *row = rowController;
UIImage *backgroundImage; UIImage *backgroundImage;
...@@ -173,9 +189,10 @@ typedef enum { ...@@ -173,9 +189,10 @@ typedef enum {
backgroundImage = nil; backgroundImage = nil;
*/ */
[row.group setBackgroundImage:[self generateBackgroundiImageWithGradient:backgroundImage]]; [row.group setBackgroundImage:[self generateBackgroundImageWithGradient:backgroundImage]];
} }
- (UIImage *)generateBackgroundiImageWithGradient:(UIImage *)backgroundImage {
- (UIImage *)generateBackgroundImageWithGradient:(UIImage *)backgroundImage {
UIImage *gradient = [UIImage imageNamed:@"gradient-cell-ios7"]; UIImage *gradient = [UIImage imageNamed:@"gradient-cell-ios7"];
...@@ -195,6 +212,21 @@ typedef enum { ...@@ -195,6 +212,21 @@ typedef enum {
//TODO: this code could use refactoring to be more readable //TODO: this code could use refactoring to be more readable
- (NSMutableArray *)mediaArray { - (NSMutableArray *)mediaArray {
if (_libraryMode == VLCLibraryModeInGroup) {
id groupObject = self.groupObject;
if([groupObject isKindOfClass:[MLLabel class]]) {
return [NSMutableArray arrayWithArray:[(MLLabel *)groupObject sortedFolderItems]];
} else if ([groupObject isKindOfClass:[MLAlbum class]]) {
return [NSMutableArray arrayWithArray:[(MLAlbum *)groupObject sortedTracks]];
} else if ([groupObject isKindOfClass:[MLShow class]]){
return [NSMutableArray arrayWithArray:[(MLShow *)groupObject sortedEpisodes]];
} else {
NSAssert(NO, @"this shouldn't have happened check the grouObjects type");
}
}
NSMutableArray *objects = [NSMutableArray array]; NSMutableArray *objects = [NSMutableArray array];
/* add all albums */ /* add all albums */
......
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