Browse Source

refactored the wificell and architecture around it

Carola Nitz 9 years ago
parent
commit
ae70674534

+ 0 - 73
Resources/VLCWiFiUploadTableViewCell.xib

@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8164.2" systemVersion="15A226f" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
-    <dependencies>
-        <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8135.1"/>
-        <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
-    </dependencies>
-    <objects>
-        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
-        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="WiFiMenuCell" rowHeight="46" id="3" customClass="VLCWiFiUploadTableViewCell">
-            <rect key="frame" x="0.0" y="0.0" width="260" height="50"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-            <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="3" id="qYq-WE-nye">
-                <rect key="frame" x="0.0" y="0.0" width="260" height="49.5"/>
-                <autoresizingMask key="autoresizingMask"/>
-                <subviews>
-                    <label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="HTTP Upload" textAlignment="justified" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="28">
-                        <rect key="frame" x="50" y="5" width="97.5" height="19.5"/>
-                        <animations/>
-                        <color key="backgroundColor" white="0.17000000000000001" alpha="1" colorSpace="calibratedWhite"/>
-                        <fontDescription key="fontDescription" type="system" pointSize="16"/>
-                        <color key="textColor" red="0.76862745099999996" green="0.80000000000000004" blue="0.85490196080000003" alpha="1" colorSpace="calibratedRGB"/>
-                        <nil key="highlightedColor"/>
-                    </label>
-                    <label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Inactive Server" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="YES" id="30">
-                        <rect key="frame" x="50" y="24" width="97.5" height="24"/>
-                        <animations/>
-                        <color key="backgroundColor" white="0.17000000000000001" alpha="1" colorSpace="calibratedWhite"/>
-                        <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                        <color key="textColor" red="0.76862745099999996" green="0.80000000000000004" blue="0.85490196080000003" alpha="1" colorSpace="calibratedRGB"/>
-                        <nil key="highlightedColor"/>
-                    </label>
-                    <button opaque="NO" contentMode="center" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="34">
-                        <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
-                        <animations/>
-                        <constraints>
-                            <constraint firstAttribute="width" constant="50" id="9hp-CX-VG6"/>
-                            <constraint firstAttribute="height" constant="50" id="FWj-TR-Jvt"/>
-                        </constraints>
-                        <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
-                        <state key="normal" image="WifiUp.png">
-                            <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" 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>
-                    </button>
-                </subviews>
-                <animations/>
-                <constraints>
-                    <constraint firstAttribute="bottomMargin" secondItem="30" secondAttribute="bottom" constant="-3.5" id="2Fr-vF-HgI"/>
-                    <constraint firstItem="34" firstAttribute="top" secondItem="qYq-WE-nye" secondAttribute="topMargin" constant="-8" id="3uj-4T-hgH"/>
-                    <constraint firstItem="28" firstAttribute="leading" secondItem="34" secondAttribute="trailing" id="Tbz-RD-inH"/>
-                    <constraint firstItem="30" firstAttribute="leading" secondItem="34" secondAttribute="trailing" id="mxE-0S-cjg"/>
-                    <constraint firstItem="34" firstAttribute="leading" secondItem="qYq-WE-nye" secondAttribute="leadingMargin" constant="-8" id="u4g-A3-Smq"/>
-                    <constraint firstItem="28" firstAttribute="top" secondItem="qYq-WE-nye" secondAttribute="topMargin" constant="-3" id="xgV-vT-ruF"/>
-                </constraints>
-            </tableViewCellContentView>
-            <animations/>
-            <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
-            <connections>
-                <outlet property="serverOnButton" destination="34" id="36"/>
-                <outlet property="titleLabel" destination="28" id="32"/>
-                <outlet property="uploadAddressLabel" destination="30" id="33"/>
-            </connections>
-        </tableViewCell>
-    </objects>
-    <resources>
-        <image name="WifiUp.png" width="16" height="29"/>
-    </resources>
-</document>

+ 2 - 5
Sources/VLCHTTPUploaderController.h

@@ -14,16 +14,13 @@
 
 #import <UIKit/UIKit.h>
 
-@class HTTPServer;
-
 @interface VLCHTTPUploaderController : NSObject
 
 + (instancetype)sharedInstance;
 
-@property (nonatomic, readonly) HTTPServer *httpServer;
-
 - (BOOL)changeHTTPServerState:(BOOL)state;
-- (NSString *)currentIPAddress;
+- (NSString *)httpStatus;
+- (BOOL)isServerRunning;
 - (NSString *)hostname;
 
 - (void)moveFileFrom:(NSString *)filepath;

+ 43 - 0
Sources/VLCHTTPUploaderController.m

@@ -18,13 +18,21 @@
 #import "VLCActivityManager.h"
 #import "VLCMediaFileDiscoverer.h"
 #import "HTTPServer.h"
+#import "Reachability.h"
 
 #import <ifaddrs.h>
 #import <arpa/inet.h>
 
+@interface VLCHTTPUploaderController()
+
+@property(nonatomic, strong) HTTPServer *httpServer;
+
+@end
+
 @implementation VLCHTTPUploaderController
 {
     UIBackgroundTaskIdentifier _backgroundTaskIdentifier;
+    Reachability *_reachability;
 }
 
 + (instancetype)sharedInstance
@@ -47,11 +55,21 @@
             name:UIApplicationDidBecomeActiveNotification object:nil];
         [center addObserver:self selector:@selector(applicationDidEnterBackground:)
             name:UIApplicationDidEnterBackgroundNotification object:nil];
+        [center addObserver:self selector:@selector(netReachabilityChanged:) name:kReachabilityChangedNotification object:nil];
+        
+        BOOL isHTTPServerOn = [[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingSaveHTTPUploadServerStatus];
+        [self changeHTTPServerState:isHTTPServerOn];
+
     }
 
     return self;
 }
 
+- (void)dealloc
+{
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
 - (void)applicationDidBecomeActive: (NSNotification *)notification
 {
     if (!self.httpServer.isRunning)
@@ -81,6 +99,31 @@
     }
 }
 
+- (NSString *)httpStatus
+{
+    if (self.httpServer.isRunning) {
+        if (self.httpServer.listeningPort != 80) {
+            return [NSString stringWithFormat:@"http://%@:%i\nhttp://%@:%i", [self currentIPAddress], self.httpServer.listeningPort, [self hostname], self.httpServer.listeningPort];
+        } else {
+            return [NSString stringWithFormat:@"http://%@\nhttp://%@", [self currentIPAddress], [self hostname]];
+        }
+    } else {
+        return NSLocalizedString(@"HTTP_UPLOAD_SERVER_OFF", nil);
+    }
+}
+
+- (BOOL)isServerRunning
+{
+    return self.httpServer.isRunning;
+}
+
+- (void)netReachabilityChanged
+{
+    if (_reachability.currentReachabilityStatus != ReachableViaWiFi) {
+        [[VLCHTTPUploaderController sharedInstance] changeHTTPServerState:NO];
+    }
+}
+
 - (BOOL)changeHTTPServerState:(BOOL)state
 {
     if (!state) {

+ 9 - 85
Sources/VLCMenuTableViewController.m

@@ -17,12 +17,9 @@
 
 #import "VLCMenuTableViewController.h"
 #import "VLCSidebarViewCell.h"
-#import "Reachability.h"
 #import <QuartzCore/QuartzCore.h>
 #import "VLCWiFiUploadTableViewCell.h"
-#import "VLCHTTPUploaderController.h"
 #import "VLCAppDelegate.h"
-#import "HTTPServer.h"
 #import "IASKAppSettingsViewController.h"
 #import "VLCServerListViewController.h"
 #import "VLCOpenNetworkStreamViewController.h"
@@ -34,6 +31,10 @@
 #import "VLCNavigationController.h"
 #import "GHRevealViewController.h"
 
+#define ROW_HEIGHT 50
+static NSString *CellIdentifier = @"VLCMenuCell";
+static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
+
 @interface VLCMenuTableViewController () <UITableViewDataSource, UITableViewDelegate>
 {
     NSArray *_sectionHeaderTexts;
@@ -41,10 +42,7 @@
     NSArray *_menuItemsSectionTwo;
     NSArray *_menuItemsSectionThree;
     NSMutableSet *_hiddenSettingKeys;
-
-    UILabel *_uploadLocationLabel;
-    UIButton *_uploadButton;
-    Reachability *_reachability;
+    
 }
 
 @end
@@ -53,7 +51,6 @@
 
 - (void)dealloc
 {
-    [_reachability stopNotifier];
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
@@ -77,8 +74,9 @@
     _tableView.backgroundColor = [UIColor colorWithRed:(43.0f/255.0f) green:(43.0f/255.0f) blue:(43.0f/255.0f) alpha:1.0f];
     _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
     _tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
-    _tableView.rowHeight = [VLCWiFiUploadTableViewCell heightOfCell];
+    _tableView.rowHeight = ROW_HEIGHT;
     _tableView.scrollsToTop = NO;
+    [_tableView registerClass:[VLCWiFiUploadTableViewCell class] forCellReuseIdentifier:WiFiCellIdentifier];
 
     self.view = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds))];
     self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
@@ -96,32 +94,12 @@
 
     [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
 
-    _reachability = [Reachability reachabilityForLocalWiFi];
-    [_reachability startNotifier];
-
-    [self netReachabilityChanged:nil];
-
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachabilityChanged:) name:kReachabilityChangedNotification object:nil];
-
-    BOOL isHTTPServerOn = [[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingSaveHTTPUploadServerStatus];
-    [[VLCHTTPUploaderController sharedInstance] changeHTTPServerState:isHTTPServerOn];
-    [self updateHTTPServerAddress];
 }
 
 - (void)viewWillAppear:(BOOL)animated
 {
     [super viewWillAppear:animated];
     self.view.frame = CGRectMake(0.0f, 0.0f,kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds));
-    [self netReachabilityChanged:nil];
-}
-
-- (void)netReachabilityChanged:(NSNotification *)notification
-{
-    if (_reachability.currentReachabilityStatus == ReachableViaWiFi) {
-        _uploadButton.enabled = YES;
-        [self updateHTTPServerAddress];
-    } else
-        [self disableButtonHTTPServer];
 }
 
 - (BOOL)shouldAutorotate
@@ -156,8 +134,6 @@
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    static NSString *CellIdentifier = @"VLCMenuCell";
-    static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
 
     NSString *rawTitle;
     NSUInteger section = indexPath.section;
@@ -169,11 +145,8 @@
         rawTitle = _menuItemsSectionThree[indexPath.row];
 
     UITableViewCell *cell;
-
     if ([rawTitle isEqualToString:@"WEBINTF_TITLE"]) {
         cell = (VLCWiFiUploadTableViewCell *)[tableView dequeueReusableCellWithIdentifier:WiFiCellIdentifier];
-        if (cell == nil)
-            cell = [VLCWiFiUploadTableViewCell cellWithReuseIdentifier:WiFiCellIdentifier];
     } else {
         cell = (VLCSidebarViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
         if (cell == nil)
@@ -194,12 +167,7 @@
             cell.imageView.image = [UIImage imageNamed:@"OpenNetStream"];
         else if ([rawTitle isEqualToString:@"DOWNLOAD_FROM_HTTP"])
             cell.imageView.image = [UIImage imageNamed:@"Downloads"];
-        else if ([rawTitle isEqualToString:@"WEBINTF_TITLE"]) {
-            _uploadLocationLabel = [(VLCWiFiUploadTableViewCell*)cell uploadAddressLabel];
-            _uploadButton = [(VLCWiFiUploadTableViewCell*)cell serverOnButton];
-            [_uploadButton addTarget:self action:@selector(toggleHTTPServer:) forControlEvents:UIControlEventTouchUpInside];
-            [self updateHTTPServerAddress];
-        } else if ([rawTitle isEqualToString:@"CLOUD_SERVICES"])
+        else if ([rawTitle isEqualToString:@"CLOUD_SERVICES"])
             cell.imageView.image = [UIImage imageNamed:@"iCloudIcon"];
     } else if (section == 2) {
         if ([rawTitle isEqualToString:@"Settings"])
@@ -252,50 +220,6 @@
 
 #pragma mark - menu implementation
 
-- (void)updateHTTPServerAddress
-{
-    if (_reachability.currentReachabilityStatus == !ReachableViaWiFi)
-        [self disableButtonHTTPServer];
-    else {
-        VLCHTTPUploaderController *uploadController = [VLCHTTPUploaderController sharedInstance];
-        HTTPServer *server = uploadController.httpServer;
-        _uploadButton.enabled = YES;
-        if (server.isRunning) {
-            _uploadLocationLabel.numberOfLines = 0;
-            if (server.listeningPort != 80)
-                _uploadLocationLabel.text = [NSString stringWithFormat:@"http://%@:%i\nhttp://%@:%i", [uploadController currentIPAddress], server.listeningPort, [uploadController hostname], server.listeningPort];
-            else
-                _uploadLocationLabel.text = [NSString stringWithFormat:@"http://%@\nhttp://%@", [uploadController currentIPAddress], [uploadController hostname]];
-            [_uploadButton setImage:[UIImage imageNamed:@"WifiUpOn"] forState:UIControlStateNormal];
-        } else {
-            _uploadLocationLabel.text = NSLocalizedString(@"HTTP_UPLOAD_SERVER_OFF", nil);
-            [_uploadButton setImage:[UIImage imageNamed:@"WifiUp"] forState:UIControlStateNormal];
-        }
-    }
-}
-
-- (IBAction)toggleHTTPServer:(UIButton *)sender
-{
-    if (_uploadButton.enabled) {
-        VLCHTTPUploaderController *uploadController = [VLCHTTPUploaderController sharedInstance];
-        BOOL futureHTTPServerState = !uploadController.httpServer.isRunning;
-
-        [[NSUserDefaults standardUserDefaults] setBool:futureHTTPServerState forKey:kVLCSettingSaveHTTPUploadServerStatus];
-        [uploadController changeHTTPServerState:futureHTTPServerState];
-        [self updateHTTPServerAddress];
-        [[NSUserDefaults standardUserDefaults] synchronize];
-    }
-}
-
-- (void)disableButtonHTTPServer
-{
-    [_uploadButton setImage:[UIImage imageNamed:@"WifiUp"] forState:UIControlStateNormal];
-    _uploadButton.enabled = NO;
-    [_uploadButton setImage:[UIImage imageNamed:@"WiFiUp"] forState:UIControlStateDisabled];
-    _uploadLocationLabel.text = NSLocalizedString(@"HTTP_UPLOAD_NO_CONNECTIVITY", nil);
-    [[VLCHTTPUploaderController sharedInstance] changeHTTPServerState:NO];
-}
-
 - (void)_revealItem:(NSUInteger)itemIndex inSection:(NSUInteger)sectionNumber
 {
     UIViewController *viewController;
@@ -308,7 +232,7 @@
         } else if (itemIndex == 2)
             viewController = [VLCDownloadViewController sharedInstance];
         else if (itemIndex == 3)
-            [self toggleHTTPServer:nil];
+            [((VLCWiFiUploadTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:itemIndex inSection:sectionNumber]]) toggleHTTPServer];
         else if (itemIndex == 4)
             viewController = [[VLCCloudServicesTableViewController alloc] initWithNibName:@"VLCCloudServicesTableViewController" bundle:nil];
     } else if (sectionNumber == 2) {

+ 1 - 6
Sources/VLCWiFiUploadTableViewCell.h

@@ -14,11 +14,6 @@
 
 @interface VLCWiFiUploadTableViewCell : UITableViewCell
 
-@property (nonatomic, strong) IBOutlet UILabel *titleLabel;
-@property (nonatomic, strong) IBOutlet UILabel *uploadAddressLabel;
-@property (nonatomic, strong) IBOutlet UIButton *serverOnButton;
-
-+ (VLCWiFiUploadTableViewCell *)cellWithReuseIdentifier:(NSString *)ident;
-+ (CGFloat)heightOfCell;
+- (void)toggleHTTPServer;
 
 @end

+ 86 - 12
Sources/VLCWiFiUploadTableViewCell.m

@@ -11,47 +11,121 @@
  *****************************************************************************/
 
 #import "VLCWiFiUploadTableViewCell.h"
+#import "Reachability.h"
+#import "VLCHTTPUploaderController.h"
+
+@interface VLCWiFiUploadTableViewCell()
+
+@property (nonatomic, strong) UILabel *titleLabel;
+@property (nonatomic, strong) UILabel *uploadAddressLabel;
+@property (nonatomic, strong) UIButton *serverOnButton;
+@property (nonatomic, strong) Reachability *reachability;
+
+@end
 
 @implementation VLCWiFiUploadTableViewCell
 
-+ (VLCWiFiUploadTableViewCell *)cellWithReuseIdentifier:(NSString *)ident
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
 {
-    NSArray *nibContentArray = [[NSBundle mainBundle] loadNibNamed:@"VLCWiFiUploadTableViewCell" owner:nil options:nil];
-    NSAssert([nibContentArray count] == 1, @"meh");
-    NSAssert([[nibContentArray lastObject] isKindOfClass:[VLCWiFiUploadTableViewCell class]], @"meh meh");
-    VLCWiFiUploadTableViewCell *cell = (VLCWiFiUploadTableViewCell *)[nibContentArray lastObject];
+    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+    if (self) {
+        [self setupCell];
+        [self setupConstraints];
+        [self updateHTTPServerAddress];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachabilityChanged:) name:kReachabilityChangedNotification object:nil];
+    }
+    return self;
+}
 
-    return cell;
+- (void)dealloc
+{
+    [self.reachability stopNotifier];
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
-- (void)awakeFromNib
+- (void)setupCell
 {
+    self.reachability = [Reachability reachabilityForLocalWiFi];
+    [self.reachability startNotifier];
+    
+    self.titleLabel = [UILabel new];
+    self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
+    [self.contentView addSubview:self.titleLabel];
     self.titleLabel.text = NSLocalizedString(@"WEBINTF_TITLE", nil);
     self.titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
     self.titleLabel.shadowColor = [UIColor VLCDarkTextShadowColor];
     self.titleLabel.textColor = [UIColor whiteColor];
+    self.titleLabel.font = [UIFont systemFontOfSize:16.0];
+    self.titleLabel.superview.backgroundColor = [UIColor colorWithRed:(43.0f/255.0f) green:(43.0f/255.0f) blue:(43.0f/255.0f) alpha:1.0f];
+    [self.titleLabel sizeToFit];
 
     self.clipsToBounds = YES;
     self.backgroundColor = [UIColor clearColor];
-    self.titleLabel.superview.backgroundColor = [UIColor colorWithRed:(43.0f/255.0f) green:(43.0f/255.0f) blue:(43.0f/255.0f) alpha:1.0f];
+    self.selectionStyle =  UITableViewCellSelectionStyleNone;
 
+    self.uploadAddressLabel = [UILabel new];
+    self.uploadAddressLabel.translatesAutoresizingMaskIntoConstraints = NO;
+    self.uploadAddressLabel.numberOfLines = 0;
+    [self.contentView addSubview:self.uploadAddressLabel];
     self.uploadAddressLabel.text = NSLocalizedString(@"HTTP_UPLOAD_SERVER_OFF", nil);
     self.uploadAddressLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
     self.uploadAddressLabel.shadowColor = [UIColor VLCDarkTextShadowColor];
     self.uploadAddressLabel.textColor = [UIColor whiteColor];
+    self.uploadAddressLabel.font = [UIFont systemFontOfSize:12.0];
+    [self.uploadAddressLabel sizeToFit];
 
+    self.serverOnButton = [UIButton buttonWithType:UIButtonTypeCustom];
+    self.serverOnButton.translatesAutoresizingMaskIntoConstraints = NO;
+    [self.serverOnButton addTarget:self action:@selector(toggleHTTPServer) forControlEvents:UIControlEventTouchUpInside];
+    [self.serverOnButton setImage:[UIImage imageNamed:@"WiFiUp"] forState:UIControlStateDisabled];
+    [self.contentView addSubview:self.serverOnButton];
+    
     UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
     topLine.backgroundColor = [UIColor colorWithRed:(16.0f/255.0f) green:(16.0f/255.0f) blue:(16.0f/255.0f) alpha:1.0f];
-    [self.titleLabel.superview addSubview:topLine];
+    [self.contentView addSubview:topLine];
 
     UIView *bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 50.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
     bottomLine.backgroundColor = [UIColor colorWithRed:(23.0f/255.0f) green:(23.0f/255.0f) blue:(23.0f/255.0f) alpha:1.0f];
-    [self.titleLabel.superview addSubview:bottomLine];
+    [self.contentView addSubview:bottomLine];
+}
+
+- (void)setupConstraints
+{
+    NSDictionary *dict = NSDictionaryOfVariableBindings(_titleLabel, _uploadAddressLabel, _serverOnButton);
+    
+    [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_serverOnButton(50)][_titleLabel]" options:0 metrics:0 views:dict]];
+    [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_serverOnButton(50)][_uploadAddressLabel]" options:0 metrics:0 views:dict]];
+    [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_serverOnButton(50)]|" options:0 metrics:0 views:dict]];
+    
+    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]];
+    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_uploadAddressLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_titleLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]];
+}
+
+- (void)netReachabilityChanged
+{
+    [self updateHTTPServerAddress];
+}
+
+- (void)updateHTTPServerAddress
+{
+    [self.serverOnButton setImage:[UIImage imageNamed:@"WifiUp"] forState:UIControlStateNormal];
+    
+    BOOL connectedViaWifi = self.reachability.currentReachabilityStatus == ReachableViaWiFi;
+    self.serverOnButton.enabled = connectedViaWifi;
+    NSString *uploadText = connectedViaWifi ? [[VLCHTTPUploaderController sharedInstance] httpStatus] : NSLocalizedString(@"HTTP_UPLOAD_NO_CONNECTIVITY", nil);
+    self.uploadAddressLabel.text = uploadText;
+    if (connectedViaWifi && [VLCHTTPUploaderController sharedInstance].isServerRunning) {
+        [self.serverOnButton setImage:[UIImage imageNamed:@"WifiUpOn"] forState:UIControlStateNormal];
+    }
 }
 
-+ (CGFloat)heightOfCell
+- (void)toggleHTTPServer
 {
-    return 50.;
+    BOOL futureHTTPServerState = ![VLCHTTPUploaderController sharedInstance].isServerRunning ;
+    [[NSUserDefaults standardUserDefaults] setBool:futureHTTPServerState forKey:kVLCSettingSaveHTTPUploadServerStatus];
+    [[VLCHTTPUploaderController sharedInstance] changeHTTPServerState:futureHTTPServerState];
+    [self updateHTTPServerAddress];
+    [[NSUserDefaults standardUserDefaults] synchronize];
 }
 
 @end

+ 0 - 4
VLC for iOS.xcodeproj/project.pbxproj

@@ -175,7 +175,6 @@
 		7DBBF1A4183AB4300009A339 /* VLCNetworkListCell~iphone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DBBF18F183AB4300009A339 /* VLCNetworkListCell~iphone.xib */; };
 		7DBBF1A5183AB4300009A339 /* VLCMovieViewController~ipad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DBBF190183AB4300009A339 /* VLCMovieViewController~ipad.xib */; };
 		7DBBF1A6183AB4300009A339 /* VLCMovieViewController~iphone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DBBF191183AB4300009A339 /* VLCMovieViewController~iphone.xib */; };
-		7DBBF1AC183AB4300009A339 /* VLCWiFiUploadTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DBBF197183AB4300009A339 /* VLCWiFiUploadTableViewCell.xib */; };
 		7DBC85631A50B8860098D388 /* LiveAuthDialog_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DBC85611A50B8860098D388 /* LiveAuthDialog_iPad.xib */; };
 		7DBC85641A50B8860098D388 /* LiveAuthDialog_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DBC85621A50B8860098D388 /* LiveAuthDialog_iPhone.xib */; };
 		7DC0C0551A4D78A4000EE359 /* DropboxSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DC0C0541A4D78A4000EE359 /* DropboxSDK.framework */; };
@@ -635,7 +634,6 @@
 		7DBBF18F183AB4300009A339 /* VLCNetworkListCell~iphone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = "VLCNetworkListCell~iphone.xib"; path = "Resources/VLCNetworkListCell~iphone.xib"; sourceTree = SOURCE_ROOT; };
 		7DBBF190183AB4300009A339 /* VLCMovieViewController~ipad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = "VLCMovieViewController~ipad.xib"; path = "Resources/VLCMovieViewController~ipad.xib"; sourceTree = SOURCE_ROOT; };
 		7DBBF191183AB4300009A339 /* VLCMovieViewController~iphone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = "VLCMovieViewController~iphone.xib"; path = "Resources/VLCMovieViewController~iphone.xib"; sourceTree = SOURCE_ROOT; };
-		7DBBF197183AB4300009A339 /* VLCWiFiUploadTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = VLCWiFiUploadTableViewCell.xib; path = Resources/VLCWiFiUploadTableViewCell.xib; sourceTree = SOURCE_ROOT; };
 		7DBC85611A50B8860098D388 /* LiveAuthDialog_iPad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = LiveAuthDialog_iPad.xib; path = ImportedSources/OneDrive/src/LiveSDK/Library/Internal/LiveAuthDialog_iPad.xib; sourceTree = SOURCE_ROOT; };
 		7DBC85621A50B8860098D388 /* LiveAuthDialog_iPhone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = LiveAuthDialog_iPhone.xib; path = ImportedSources/OneDrive/src/LiveSDK/Library/Internal/LiveAuthDialog_iPhone.xib; sourceTree = SOURCE_ROOT; };
 		7DC0C0541A4D78A4000EE359 /* DropboxSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DropboxSDK.framework; path = ImportedSources/Dropbox/DropboxSDK.framework; sourceTree = "<group>"; };
@@ -1347,7 +1345,6 @@
 				7D6BEF1E19E027BE00DF3972 /* Library */,
 				7DBBF190183AB4300009A339 /* VLCMovieViewController~ipad.xib */,
 				7DBBF191183AB4300009A339 /* VLCMovieViewController~iphone.xib */,
-				7DBBF197183AB4300009A339 /* VLCWiFiUploadTableViewCell.xib */,
 				7D27EB9319DEE11900EF0370 /* Launch Screen.xib */,
 			);
 			name = XIBs;
@@ -1864,7 +1861,6 @@
 				266DB8EB1B447E5000EA415E /* VLCPlexMediaInformationViewController.xib in Resources */,
 				7D9870651A3E03D5009CF27D /* papasscode_background@2x.png in Resources */,
 				7DBBF1A1183AB4300009A339 /* VLCPlaylistTableViewCell.xib in Resources */,
-				7DBBF1AC183AB4300009A339 /* VLCWiFiUploadTableViewCell.xib in Resources */,
 				7D63C19718774F1000BD5256 /* VLCFirstStepsFourthPageViewController~ipad.xib in Resources */,
 				7DBC85631A50B8860098D388 /* LiveAuthDialog_iPad.xib in Resources */,
 				7DBBF1A3183AB4300009A339 /* VLCNetworkListCell~ipad.xib in Resources */,