Quellcode durchsuchen

UIDevice: move category to properties with a 3 character prefix

(cherry picked from commit 687284a30565f446fd4dbaa56e8524de36282582)
Felix Paul Kühne vor 9 Jahren
Ursprung
Commit
67a712e397

+ 1 - 1
SharedSources/ServerBrowsing/Plex/VLCPlexWebAPI.m

@@ -201,7 +201,7 @@
 
     NSData *receivedSub = [NSData dataWithContentsOfURL:url];
 
-    if (receivedSub.length < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (receivedSub.length < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         NSArray *searchPaths =  nil;
         if (modeStream)
             searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

+ 2 - 2
SharedSources/ServerBrowsing/VLCServerBrowsingController.m

@@ -135,7 +135,7 @@
     NSString *FileSubtitlePath = nil;
     NSData *receivedSub = [NSData dataWithContentsOfURL:subtitleURL]; // TODO: fix synchronous load
 
-    if (receivedSub.length < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (receivedSub.length < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
         NSString *directoryPath = searchPaths[0];
         FileSubtitlePath = [directoryPath stringByAppendingPathComponent:[subtitleURL lastPathComponent]];
@@ -242,7 +242,7 @@
         return NO;
     }
 
-    if (item.fileSizeBytes.longLongValue  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (item.fileSizeBytes.longLongValue  < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         [self _downloadItem:item];
         return YES;
     } else {

+ 3 - 3
Sources/UIDevice+VLC.h

@@ -14,8 +14,8 @@
 
 @interface UIDevice (VLC)
 
-- (int)speedCategory;
-- (NSNumber *)freeDiskspace;
-- (BOOL)hasExternalDisplay;
+@property (readonly) int VLCSpeedCategory;
+@property (readonly) NSNumber *VLCFreeDiskSpace;
+@property (readonly) BOOL VLCHasExternalDisplay;
 
 @end

+ 3 - 3
Sources/UIDevice+VLC.m

@@ -15,7 +15,7 @@
 
 @implementation UIDevice (VLC)
 
-- (int)speedCategory
+- (int)VLCSpeedCategory
 {
     size_t size;
     sysctlbyname("hw.machine", NULL, &size, NULL, 0);
@@ -45,7 +45,7 @@
     }
 }
 
-- (NSNumber *)freeDiskspace
+- (NSNumber *)VLCFreeDiskSpace
 {
     NSNumber *totalSpace;
     NSNumber *totalFreeSpace;
@@ -65,7 +65,7 @@
     return totalFreeSpace;
 }
 
-- (BOOL)hasExternalDisplay
+- (BOOL)VLCHasExternalDisplay
 {
     return ([[UIScreen screens] count] > 1);
 }

+ 1 - 1
Sources/VLCAppDelegate.m

@@ -55,7 +55,7 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
     NSNumber *skipLoopFilterDefaultValue;
-    int deviceSpeedCategory = [[UIDevice currentDevice] speedCategory];
+    int deviceSpeedCategory = [[UIDevice currentDevice] VLCSpeedCategory];
     if (deviceSpeedCategory < 3)
         skipLoopFilterDefaultValue = kVLCSettingSkipLoopFilterNonKey;
     else

+ 1 - 1
Sources/VLCBoxTableViewController.m

@@ -232,7 +232,7 @@
 {
     _selectedFile = _listOfFiles[[self.tableView indexPathForCell:cell].row];
 
-    if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         /* selected item is a proper file, ask the user if s/he wants to download it */
         VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil) message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) otherButtonTitles:NSLocalizedString(@"BUTTON_DOWNLOAD", nil), nil];
         [alert show];

+ 1 - 1
Sources/VLCDropboxTableViewController.m

@@ -171,7 +171,7 @@
 {
     _selectedFile = _mediaList[[self.tableView indexPathForCell:cell].row];
 
-    if (_selectedFile.totalBytes < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (_selectedFile.totalBytes < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         /* selected item is a proper file, ask the user if s/he wants to download it */
         VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
                                                           message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.filename, [[UIDevice currentDevice] model]]

+ 1 - 1
Sources/VLCEqualizerView.m

@@ -260,7 +260,7 @@
     _tableView.sectionHeaderHeight = 28.;
     [_tableView registerClass:[VLCTrackSelectorHeaderView class] forHeaderFooterViewReuseIdentifier:PROFILE_SELECTOR_TABLEVIEW_SECTIONHEADER];
     [_tableView registerClass:[VLCTrackSelectorTableViewCell class] forCellReuseIdentifier:PROFILE_SELECTOR_TABLEVIEW_CELL];
-    if ([[UIDevice currentDevice] speedCategory] >= 3) {
+    if ([[UIDevice currentDevice] VLCSpeedCategory] >= 3) {
         _tableView.opaque = NO;
         _tableView.backgroundColor = [UIColor clearColor];
     } else

+ 1 - 1
Sources/VLCGoogleDriveTableViewController.m

@@ -150,7 +150,7 @@
 {
     _selectedFile = _googleDriveController.currentListFiles[[self.tableView indexPathForCell:cell].row];
 
-    if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         /* selected item is a proper file, ask the user if s/he wants to download it */
         VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
                                                           message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]

+ 2 - 2
Sources/VLCHTTPConnection.m

@@ -136,7 +136,7 @@
 
             /* devices category 3 and faster include HW accelerated JPEG encoding
              * so we can make our transfers faster by using waaay smaller images */
-            if ([[UIDevice currentDevice] speedCategory] < 3) {
+            if ([[UIDevice currentDevice] VLCSpeedCategory] < 3) {
                 theData = UIImagePNGRepresentation([VLCThumbnailsCache thumbnailForManagedObject:mo]);
                 contentType = @"image/png";
             } else {
@@ -685,7 +685,7 @@
 
     _filepath = [uploadDirPath stringByAppendingPathComponent: filename];
 
-    NSNumber *freeSpace = [[UIDevice currentDevice] freeDiskspace];
+    NSNumber *freeSpace = [[UIDevice currentDevice] VLCFreeDiskSpace];
     if (_contentLength >= freeSpace.longLongValue) {
         /* avoid deadlock since we are on a background thread */
         [self performSelectorOnMainThread:@selector(notifyUserAboutEndOfFreeStorage:) withObject:filename waitUntilDone:NO];

+ 1 - 1
Sources/VLCHTTPFileDownloader.m

@@ -105,7 +105,7 @@
     if (_statusCode == 200) {
         _expectedDownloadSize = [response expectedContentLength];
         APLog(@"expected download size: %lli", _expectedDownloadSize);
-        if (_expectedDownloadSize  < [[UIDevice currentDevice] freeDiskspace].longLongValue)
+        if (_expectedDownloadSize  < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue)
             [self.delegate downloadStarted];
         else {
             [_urlConnection cancel];

+ 8 - 8
Sources/VLCMovieViewController.m

@@ -149,6 +149,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     [super viewDidLoad];
     CGRect rect;
 
+    int deviceSpeedCategory = [[UIDevice currentDevice] VLCSpeedCategory];
+
     self.extendedLayoutIncludesOpaqueBars = YES;
     self.edgesForExtendedLayout = UIRectEdgeAll;
 
@@ -214,7 +216,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
 
     _playingExternallyTitle.text = NSLocalizedString(@"PLAYING_EXTERNALLY_TITLE", nil);
     _playingExternallyDescription.text = NSLocalizedString(@"PLAYING_EXTERNALLY_DESC", nil);
-    if ([[UIDevice currentDevice] hasExternalDisplay])
+    if ([[UIDevice currentDevice] VLCHasExternalDisplay])
         [self showOnExternalDisplay];
 
     self.trackNameLabel.text = self.artistNameLabel.text = self.albumNameLabel.text = @"";
@@ -224,8 +226,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     _tapOnVideoRecognizer.delegate = self;
     [self.view addGestureRecognizer:_tapOnVideoRecognizer];
 
-
-
     _pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
     _pinchRecognizer.delegate = self;
     [self.view addGestureRecognizer:_pinchRecognizer];
@@ -312,7 +312,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     _trackSelectorContainer.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight;
     _trackSelectorContainer.hidden = YES;
 
-    if ([[UIDevice currentDevice] speedCategory] >= 3) {
+    if (deviceSpeedCategory >= 3) {
         _trackSelectorTableView.opaque = NO;
         _trackSelectorTableView.backgroundColor = [UIColor clearColor];
     } else
@@ -334,7 +334,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     _sleepTimerContainer.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
 
     _sleepTimeDatePicker = [[UIDatePicker alloc] init];
-    if ([[UIDevice currentDevice] speedCategory] >= 3) {
+    if (deviceSpeedCategory >= 3) {
         _sleepTimeDatePicker.opaque = NO;
         _sleepTimeDatePicker.backgroundColor = [UIColor clearColor];
     } else
@@ -807,7 +807,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     self.timeNavigationTitleView.positionSlider.value = 0.;
     [self.timeNavigationTitleView.timeDisplayButton setTitle:@"" forState:UIControlStateNormal];
     self.timeNavigationTitleView.timeDisplayButton.accessibilityLabel = @"";
-    if (![[UIDevice currentDevice] hasExternalDisplay])
+    if (![[UIDevice currentDevice] VLCHasExternalDisplay])
         self.brightnessSlider.value = [UIScreen mainScreen].brightness * 2.;
     [_equalizerView reloadData];
 
@@ -1487,7 +1487,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
     else if (sender == self.contrastSlider)
         mediaPlayer.contrast = self.contrastSlider.value;
     else if (sender == self.brightnessSlider) {
-        if ([[UIDevice currentDevice] hasExternalDisplay])
+        if ([[UIDevice currentDevice] VLCHasExternalDisplay])
             mediaPlayer.brightness = self.brightnessSlider.value;
         else
             [[UIScreen mainScreen] setBrightness:(self.brightnessSlider.value / 2.)];
@@ -1511,7 +1511,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 {
     if (notification)
         self.brightnessSlider.value = [(UIScreen *)notification.object brightness] * 2.;
-    else if (![[UIDevice currentDevice] hasExternalDisplay])
+    else if (![[UIDevice currentDevice] VLCHasExternalDisplay])
         self.brightnessSlider.value = [(UIScreen *)[[UIScreen screens] firstObject] brightness] * 2.;
 }
 

+ 2 - 2
Sources/VLCOneDriveTableViewController.m

@@ -180,7 +180,7 @@
     NSString *FileSubtitlePath = nil;
     NSData *receivedSub = [NSData dataWithContentsOfURL:subtitleURL]; // TODO: fix synchronous load
 
-    if (receivedSub.length < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (receivedSub.length < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
         NSString *directoryPath = searchPaths[0];
         FileSubtitlePath = [directoryPath stringByAppendingPathComponent:[subtitleURL lastPathComponent]];
@@ -255,7 +255,7 @@
     NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
     _selectedFile = _oneDriveController.currentFolder.items[indexPath.row];
 
-    if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         /* selected item is a proper file, ask the user if s/he wants to download it */
         VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
                                                           message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]

+ 1 - 1
Sources/VLCOpenNetworkStreamViewController.m

@@ -395,7 +395,7 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
     NSString *fileName = [[url path] lastPathComponent];
     NSData *receivedSub = [NSData dataWithContentsOfURL:url];
 
-    if (receivedSub.length < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+    if (receivedSub.length < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
         NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
         NSString *directoryPath = [searchPaths objectAtIndex:0];
         fileSubtitlePath = [directoryPath stringByAppendingPathComponent:fileName];

+ 2 - 2
Sources/VLCPlaybackController.m

@@ -134,7 +134,7 @@ NSString *const VLCPlaybackControllerPlaybackPositionUpdated = @"VLCPlaybackCont
 
     NSUInteger totalNumberOfPixels = width * height;
 
-    NSInteger speedCategory = [[UIDevice currentDevice] speedCategory];
+    NSInteger speedCategory = [[UIDevice currentDevice] VLCSpeedCategory];
 
     if (speedCategory == 1) {
         // iPhone 3GS, iPhone 4, first gen. iPad, 3rd and 4th generation iPod touch
@@ -708,7 +708,7 @@ NSString *const VLCPlaybackControllerPlaybackPositionUpdated = @"VLCPlaybackCont
 
         if ([_aspectRatios[_currentAspectRatioMask] isEqualToString:@"FILL_TO_SCREEN"]) {
             UIScreen *screen;
-            if (![[UIDevice currentDevice] hasExternalDisplay])
+            if (![[UIDevice currentDevice] VLCHasExternalDisplay])
                 screen = [UIScreen mainScreen];
             else
                 screen = [UIScreen screens][1];

+ 1 - 1
Sources/VLCSidebarController.m

@@ -58,7 +58,7 @@
     }
     _sideMenuViewController.backgroundImage = [UIImage imageNamed:@"menu-background"];
 
-    if ([[UIDevice currentDevice] speedCategory] <= 2) {
+    if ([[UIDevice currentDevice] VLCSpeedCategory] <= 2) {
         _sideMenuViewController.animationDuration = 0.1f;
         _sideMenuViewController.parallaxEnabled = NO;
         _sideMenuViewController.contentViewShadowEnabled = NO;

+ 1 - 1
Sources/VLCTrackSelectorHeaderView.m

@@ -25,7 +25,7 @@
     self.contentView.backgroundColor = [UIColor VLCDarkBackgroundColor];
     self.textLabel.textColor = [UIColor whiteColor];
 
-    if ([[UIDevice currentDevice] speedCategory] >= 3) {
+    if ([[UIDevice currentDevice] VLCSpeedCategory] >= 3) {
         self.opaque = NO;
         self.alpha = .8;
     }