Commit fb5a8ee8 authored by Felix Paul Kühne's avatar Felix Paul Kühne

library: implement multi-file deletion and file renaming for the Pad UI

parent 05a052cb
......@@ -25,6 +25,8 @@ Interface:
* Added option to disable file name display optimizations (#10050)
* TV Shows are sorted by Season number / Episode number and Music Albums
respectively by track number
* Added ability to rename any media item in the library view
* Added deletion of multiple media items in one step
* New translations to Czech, Malay, Persian, Spanish (Mexico)
Cloud interaction:
......
......@@ -24,21 +24,6 @@
<rect key="frame" x="0.0" y="0.0" width="341" height="190"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="37" userLabel="Delete button">
<rect key="frame" x="307" y="4" width="33" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" size="button"/>
<state key="normal" image="DeleteButton.png">
<color key="titleColor" red="0.1960784314" green="0.30980392159999998" blue="0.52156862749999999" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="removeMedia:" destination="2" eventType="touchUpInside" id="48"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Title" lineBreakMode="wordWrap" baselineAdjustment="none" minimumFontSize="9" adjustsLetterSpacingToFitWidth="YES" id="4XD-oC-pqG">
<rect key="frame" x="10" y="141" width="321" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
......@@ -55,6 +40,10 @@
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="shadowOffset" width="0.0" height="0.0"/>
</label>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="checkboxEmpty.png" id="pl6-iw-2ZI">
<rect key="frame" x="6" y="6" width="25" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Subtitle — Subtitle" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="jdp-lJ-hIF">
<rect key="frame" x="10" y="166" width="293" height="15"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
......@@ -68,8 +57,8 @@
</view>
<size key="customSize" width="298" height="167"/>
<connections>
<outlet property="isSelectedView" destination="pl6-iw-2ZI" id="1sX-gh-yiU"/>
<outlet property="mediaIsUnreadView" destination="ftR-Og-FOs" id="5aH-vE-E37"/>
<outlet property="removeMediaButton" destination="37" id="43"/>
<outlet property="subtitleLabel" destination="jdp-lJ-hIF" id="YUa-G7-CMl"/>
<outlet property="thumbnailView" destination="31" id="46"/>
<outlet property="titleLabel" destination="4XD-oC-pqG" id="Te1-JA-An0"/>
......@@ -77,7 +66,7 @@
</collectionViewCell>
</objects>
<resources>
<image name="DeleteButton.png" width="29" height="29"/>
<image name="checkboxEmpty.png" width="25" height="25"/>
<image name="gradient-cell-ios7-ipad.png" width="2" height="190"/>
</resources>
</document>
......@@ -56,21 +56,10 @@
<rect key="frame" x="16" y="9" width="266" height="154"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="37" userLabel="Delete button">
<rect key="frame" x="260" y="2" width="33" height="29"/>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="checkboxEmpty.png" id="0Jc-2h-HQ9">
<rect key="frame" x="8" y="1" width="25" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" size="button"/>
<state key="normal" image="DeleteButton.png">
<color key="titleColor" red="0.1960784314" green="0.30980392159999998" blue="0.52156862749999999" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="removeMedia:" destination="2" eventType="touchUpInside" id="48"/>
</connections>
</button>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="badgeUnread.png" id="38">
<rect key="frame" x="235" y="12" width="44" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
......@@ -79,9 +68,9 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="isSelectedView" destination="0Jc-2h-HQ9" id="I7k-1Q-y1G"/>
<outlet property="mediaIsUnreadView" destination="38" id="41"/>
<outlet property="progressView" destination="35" id="42"/>
<outlet property="removeMediaButton" destination="37" id="43"/>
<outlet property="seriesNameLabel" destination="34" id="44"/>
<outlet property="subtitleLabel" destination="33" id="45"/>
<outlet property="thumbnailView" destination="31" id="46"/>
......@@ -90,8 +79,8 @@
</collectionViewCell>
</objects>
<resources>
<image name="DeleteButton.png" width="29" height="29"/>
<image name="badgeUnread.png" width="44" height="44"/>
<image name="checkboxEmpty.png" width="25" height="25"/>
<image name="thumbOverlay.png" width="266" height="154"/>
</resources>
</document>
B"CHOOSE_AUDIO_TRACK"="Choose Audio Track";
......
......@@ -21,15 +21,16 @@
@property (nonatomic, strong) IBOutlet UILabel *subtitleLabel;
@property (nonatomic, strong) IBOutlet UIImageView *thumbnailView;
@property (nonatomic, strong) IBOutlet VLCLinearProgressIndicator *progressView;
@property (nonatomic, strong) IBOutlet UIButton *removeMediaButton;
@property (nonatomic, strong) IBOutlet UIView *mediaIsUnreadView;
@property (nonatomic, strong) IBOutlet UILabel *seriesNameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *isSelectedView;
@property (nonatomic, retain) MLFile *mediaObject;
@property (nonatomic, weak) UICollectionView *collectionView;
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;
- (void)selectionUpdate;
- (IBAction)removeMedia:(id)sender;
@end
......@@ -20,10 +20,18 @@
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
self.removeMediaButton.hidden = !editing;
self.isSelectedView.hidden = !editing;
[self _updatedDisplayedInformationForKeyPath:@"editing"];
}
- (void)selectionUpdate
{
if (self.selected)
self.isSelectedView.image = [UIImage imageNamed:@"checkbox"];
else
self.isSelectedView.image = [UIImage imageNamed:@"checkboxEmpty"];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
[self _updatedDisplayedInformationForKeyPath:keyPath];
......@@ -112,28 +120,6 @@
[self setNeedsDisplay];
}
- (IBAction)removeMedia:(id)sender
{
NSString *title;
id mediaObject = self.mediaObject;
if ([mediaObject isKindOfClass:[MLAlbum class]] || [mediaObject isKindOfClass:[MLShowEpisode class]] || [mediaObject isKindOfClass:[MLShow class]])
title = [mediaObject name];
else
title = [mediaObject title];
/* ask user if s/he really wants to delete the media file */
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DELETE_FILE", @"") message:[NSString stringWithFormat:NSLocalizedString(@"DELETE_FILE_LONG", @""), title] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_DELETE", @""), nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
VLCPlaylistViewController *delegate = (VLCPlaylistViewController*)self.collectionView.delegate;
[delegate removeMediaObject:self.mediaObject updateDatabase:YES];
}
}
#pragma mark - presentation
- (void)_configureForShow:(MLShow *)show
......
......@@ -496,10 +496,20 @@
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (self.editing) {
[(VLCPlaylistCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath] selectionUpdate];
return;
}
NSManagedObject *selectedObject = _foundMedia[indexPath.row];
[self openMediaObject:selectedObject];
}
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
{
[(VLCPlaylistCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath] selectionUpdate];
}
#pragma mark - UI implementation
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
......@@ -526,12 +536,23 @@
[aCell setEditing:editing animated:animated];
}];
self.collectionView.allowsMultipleSelection = editing;
/* UIKit doesn't clear the selection automagically if we leave the editing mode
* so we need to do so manually */
if (!editing) {
NSArray *selectedItems = [self.collectionView indexPathsForSelectedItems];
NSUInteger count = selectedItems.count;
for (NSUInteger x = 0; x < count; x++)
[self.collectionView deselectItemAtIndexPath:selectedItems[x] animated:NO];
}
} else {
self.navigationController.toolbarHidden = !editing;
self.tableView.allowsMultipleSelectionDuringEditing = editing;
[self.tableView setEditing:editing animated:YES];
[self.editButtonItem setTitle:editing ? NSLocalizedString(@"BUTTON_CANCEL",@"") : NSLocalizedString(@"BUTTON_EDIT", @"")];
}
self.navigationController.toolbarHidden = !editing;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
......@@ -563,7 +584,11 @@
- (void)deleteSelection
{
NSArray *indexPaths = [self.tableView indexPathsForSelectedRows];
NSArray *indexPaths;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
indexPaths = [self.collectionView indexPathsForSelectedItems];
else
indexPaths = [self.tableView indexPathsForSelectedRows];
NSUInteger count = indexPaths.count;
NSMutableArray *objects = [[NSMutableArray alloc] initWithCapacity:count];
......@@ -578,14 +603,22 @@
- (void)renameSelection
{
NSArray *indexPaths = [self.tableView indexPathsForSelectedRows];
NSArray *indexPaths;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
indexPaths = [self.collectionView indexPathsForSelectedItems];
else
indexPaths = [self.tableView indexPathsForSelectedRows];
if (indexPaths.count < 1) {
[self _endEditing];
return;
}
NSString *itemName = [(VLCPlaylistTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPaths[0]] titleLabel].text;
NSString *itemName;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
itemName = [(VLCPlaylistCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPaths[0]] titleLabel].text;
else
itemName = [(VLCPlaylistTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPaths[0]] titleLabel].text;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"RENAME_MEDIA_TO", @""), itemName] message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_RENAME", @""), nil];
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
[[alert textFieldAtIndex:0] setText:itemName];
......@@ -594,7 +627,11 @@
- (void)renameMediaObjectTo:(NSString*)newName
{
NSArray *indexPaths = [self.tableView indexPathsForSelectedRows];
NSArray *indexPaths;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
indexPaths = [self.collectionView indexPathsForSelectedItems];
else
indexPaths = [self.tableView indexPathsForSelectedRows];
id mediaObject = _foundMedia[[indexPaths[0] row]];
if ([mediaObject isKindOfClass:[MLAlbum class]] || [mediaObject isKindOfClass:[MLShowEpisode class]] || [mediaObject isKindOfClass:[MLShow class]])
......@@ -602,7 +639,10 @@
else
[mediaObject setTitle:newName];
[self.tableView deselectRowAtIndexPath:indexPaths[0] animated:YES];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
[self.collectionView deselectItemAtIndexPath:indexPaths[0] animated:YES];
else
[self.tableView deselectRowAtIndexPath:indexPaths[0] animated:YES];
if (indexPaths.count > 1)
[self renameSelection];
......
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