Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tvOS: NetworkStream UI: Add sorting button new to old #451

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Apple-TV/Assets.xcassets/sortingImage.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "tv",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Apple-TV/VLCOpenNetworkStreamTVViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
@property (readwrite, nonatomic, weak) IBOutlet UIImageView *nothingFoundConeImageView;

@property (readwrite, nonatomic, weak) IBOutlet UIButton *emptyListButton;
@property (readwrite, nonatomic, weak) IBOutlet UIButton *reverseListSortingButton;

- (IBAction)URLEnteredInField:(id)sender;
- (IBAction)emptyListAction:(id)sender;
- (IBAction)reverseListSortingAction:(id)sender;

@end
27 changes: 23 additions & 4 deletions Apple-TV/VLCOpenNetworkStreamTVViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ @interface VLCOpenNetworkStreamTVViewController ()
{
NSMutableArray *_recentURLs;
NSMutableDictionary *_recentURLTitles;
BOOL _newestFirst;
}
@property (nonatomic) NSIndexPath *currentlyFocusedIndexPath;
@end
Expand Down Expand Up @@ -50,6 +51,9 @@ - (void)viewDidLoad {
self.playURLField.textContentType = UITextContentTypeURL;
}
self.emptyListButton.accessibilityLabel = NSLocalizedString(@"BUTTON_RESET", nil);
self.reverseListSortingButton.accessibilityLabel = NSLocalizedString(@"BUTTON_REVERSE", nil);

_newestFirst = false;

self.previouslyPlayedStreamsTableView.backgroundColor = [UIColor clearColor];
self.previouslyPlayedStreamsTableView.rowHeight = UITableViewAutomaticDimension;
Expand Down Expand Up @@ -108,8 +112,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"RecentlyPlayedURLsTableViewCell"];
}

NSString *content = [_recentURLs[indexPath.row] stringByRemovingPercentEncoding];
NSString *possibleTitle = _recentURLTitles[[@(indexPath.row) stringValue]];
NSInteger index = _newestFirst ? _recentURLs.count - 1 - indexPath.row : indexPath.row;
NSString *content = [_recentURLs[index] stringByRemovingPercentEncoding];
NSString *possibleTitle = _recentURLTitles[[@(index) stringValue]];

cell.detailTextLabel.text = content;
cell.textLabel.text = (possibleTitle != nil) ? possibleTitle : [content lastPathComponent];
Expand All @@ -120,7 +125,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.previouslyPlayedStreamsTableView deselectRowAtIndexPath:indexPath animated:NO];
[self _openURLStringAndDismiss:_recentURLs[indexPath.row]];
NSInteger index = _newestFirst ? _recentURLs.count - 1 - indexPath.row : indexPath.row;
[self _openURLStringAndDismiss:_recentURLs[index]];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
Expand All @@ -129,6 +135,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
if (count > 0) {
self.nothingFoundView.hidden = YES;
self.emptyListButton.hidden = NO;
self.reverseListSortingButton.hidden = NO;
}
return count;
}
Expand Down Expand Up @@ -204,6 +211,18 @@ - (void)emptyListAction:(id)sender
[self presentViewController:alertController animated:YES completion:nil];
}

- (IBAction)reverseListSortingAction:(id)sender
{
_newestFirst = !_newestFirst;
if (_newestFirst) {
self.reverseListSortingButton.transform = CGAffineTransformMakeRotation( M_PI );
} else {
self.reverseListSortingButton.transform = CGAffineTransformIdentity;
}

[self.previouslyPlayedStreamsTableView reloadData];
}

#pragma mark - editing

- (NSIndexPath *)indexPathToDelete
Expand All @@ -221,7 +240,7 @@ - (NSString *)itemToDelete

NSString *ret = nil;
@synchronized(_recentURLs) {
NSInteger index = indexPathToDelete.item;
NSInteger index = _newestFirst ? _recentURLs.count - 1 - indexPathToDelete.item : indexPathToDelete.item;
if (index < _recentURLs.count) {
ret = _recentURLs[index];
}
Expand Down
20 changes: 17 additions & 3 deletions Apple-TV/VLCOpenNetworkStreamTVViewController.xib
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="20037" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="19529" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="appleTV" appearance="light"/>
<dependencies>
<deployment identifier="tvOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCOpenNetworkStreamTVViewController">
<connections>
<outlet property="deleteHintView" destination="Wa3-IS-ztU" id="ipW-Hx-fMJ"/>
<outlet property="emptyListButton" destination="OXZ-Zx-045" id="kJS-RB-MGp"/>
<outlet property="emptyListButton" destination="OXZ-Zx-045" id="amt-Xy-VhT"/>
<outlet property="nothingFoundConeImageView" destination="aAb-aY-bkT" id="Abp-Yt-oQb"/>
<outlet property="nothingFoundLabel" destination="sdc-e1-PSc" id="dvi-jc-vaR"/>
<outlet property="nothingFoundView" destination="dvt-CP-ALF" id="lg3-aJ-oHg"/>
<outlet property="playURLField" destination="dWa-3n-YCa" id="Eoe-vT-AuM"/>
<outlet property="preferredFocusedView" destination="dWa-3n-YCa" id="0Ez-4Z-KFF"/>
<outlet property="previouslyPlayedStreamsTableView" destination="v0o-s0-Xaz" id="I1r-ie-lFf"/>
<outlet property="reverseListSortingButton" destination="S9C-So-1TT" id="Wys-kF-xwY"/>
<outlet property="view" destination="iN0-l3-epB" id="Eym-vH-oyN"/>
</connections>
</placeholder>
Expand Down Expand Up @@ -83,17 +84,29 @@
<action selector="emptyListAction:" destination="-1" eventType="primaryActionTriggered" id="Pp6-st-y2N"/>
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" ambiguous="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="S9C-So-1TT">
<rect key="frame" x="1439" y="190" width="128" height="88"/>
<inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="delete"/>
<buttonConfiguration key="configuration" style="gray" image="sortingImage"/>
<connections>
<action selector="reverseListSortingAction:" destination="-1" eventType="primaryActionTriggered" id="pFj-w5-Hp2"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="Wa3-IS-ztU" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="0ms-Lt-g1Q"/>
<constraint firstItem="dWa-3n-YCa" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="193" id="6FP-0U-Znd"/>
<constraint firstItem="S9C-So-1TT" firstAttribute="centerY" secondItem="dWa-3n-YCa" secondAttribute="centerY" id="D1b-zy-Rwv"/>
<constraint firstItem="dvt-CP-ALF" firstAttribute="centerY" secondItem="v0o-s0-Xaz" secondAttribute="centerY" id="GIx-LR-UOF"/>
<constraint firstItem="dvt-CP-ALF" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="961" id="GfH-Fp-I0L"/>
<constraint firstItem="OXZ-Zx-045" firstAttribute="trailing" secondItem="v0o-s0-Xaz" secondAttribute="trailing" id="HGJ-W8-lfl"/>
<constraint firstItem="OXZ-Zx-045" firstAttribute="centerY" secondItem="dWa-3n-YCa" secondAttribute="centerY" id="O9J-Zz-Pur"/>
<constraint firstAttribute="bottom" secondItem="Wa3-IS-ztU" secondAttribute="bottom" constant="50" id="ZDa-1f-46j"/>
<constraint firstItem="v0o-s0-Xaz" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="elq-bO-Tb3"/>
<constraint firstItem="v0o-s0-Xaz" firstAttribute="top" secondItem="dWa-3n-YCa" secondAttribute="bottom" constant="70" id="jCe-Gz-82c"/>
<constraint firstItem="OXZ-Zx-045" firstAttribute="leading" secondItem="S9C-So-1TT" secondAttribute="trailing" constant="42.5" id="jlD-FU-9bO"/>
<constraint firstItem="dWa-3n-YCa" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="oFS-xp-QJo"/>
<constraint firstItem="dvt-CP-ALF" firstAttribute="centerX" secondItem="v0o-s0-Xaz" secondAttribute="centerX" id="uSF-XP-xr0"/>
<constraint firstAttribute="bottom" secondItem="v0o-s0-Xaz" secondAttribute="bottom" constant="70" id="ydf-eT-5UK"/>
Expand All @@ -105,5 +118,6 @@
<image name="cone" width="143" height="158"/>
<image name="delete" width="24" height="24"/>
<image name="deleteImage" width="48" height="48"/>
<image name="sortingImage" width="48" height="48"/>
</resources>
</document>
1 change: 1 addition & 0 deletions Resources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"BUTTON_CONTINUE" = "Fortsetzen";
"BUTTON_SET" = "Einstellen";
"BUTTON_RESET" = "Zurücksetzen";
"BUTTON_REVERSE" = "Sortierung umkehren";
"BUTTON_RESCAN" = "Erneut durchsuchen";
"PRIVATE_PLAYBACK_TOGGLE" = "Private Wiedergabe";
"SCAN_SUBTITLE_TOGGLE" = "Untertitelsuche (nur HTTP)";
Expand Down
1 change: 1 addition & 0 deletions Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"BUTTON_CONTINUE" = "Continue";
"BUTTON_SET" = "Set";
"BUTTON_RESET" = "Reset";
"BUTTON_REVERSE" = "Reverse sorting order";
"BUTTON_RESCAN" = "Rescan";
"PRIVATE_PLAYBACK_TOGGLE" = "Private Playback";
"SCAN_SUBTITLE_TOGGLE" = "Scan for Subtitles (http-only)";
Expand Down