Skip to content

Commit

Permalink
Improve support for tvOS.
Browse files Browse the repository at this point in the history
Several Nimbus APIs rely on APIs that are unavailable on tvOS. To better support Nimbus being built for tvOS apps, these APIs have been annotated as also unavailable on tvOS.

PiperOrigin-RevId: 349350231
  • Loading branch information
Jeff Verkoeyen authored and material-automation committed Dec 29, 2020
1 parent 5387ace commit f44a5a1
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 19 deletions.
27 changes: 18 additions & 9 deletions src/core/src/NICommonMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ extern "C" {
*
* Value: 44
*/
CGFloat NIMinimumTapDimension(void);
CGFloat NIMinimumTapDimension(void)
API_UNAVAILABLE(tvos, watchos);

/**
* Fetch the height of a toolbar in a given orientation.
Expand All @@ -79,7 +80,8 @@ CGFloat NIMinimumTapDimension(void);
*
* On the iPad: always 44
*/
CGFloat NIToolbarHeightForOrientation(UIInterfaceOrientation orientation);
CGFloat NIToolbarHeightForOrientation(UIInterfaceOrientation orientation)
API_UNAVAILABLE(tvos, watchos);

/**
* The animation curve used when changing the status bar's visibility.
Expand All @@ -89,7 +91,8 @@ CGFloat NIToolbarHeightForOrientation(UIInterfaceOrientation orientation);
*
* Value: UIViewAnimationCurveEaseIn
*/
UIViewAnimationCurve NIStatusBarAnimationCurve(void);
UIViewAnimationCurve NIStatusBarAnimationCurve(void)
API_UNAVAILABLE(tvos, watchos);

/**
* The animation duration used when changing the status bar's visibility.
Expand All @@ -99,23 +102,26 @@ UIViewAnimationCurve NIStatusBarAnimationCurve(void);
*
* Value: 0.3 seconds
*/
NSTimeInterval NIStatusBarAnimationDuration(void);
NSTimeInterval NIStatusBarAnimationDuration(void)
API_UNAVAILABLE(tvos, watchos);

/**
* The animation curve used when the status bar's bounds change (when a call is received,
* for example).
*
* Value: UIViewAnimationCurveEaseInOut
*/
UIViewAnimationCurve NIStatusBarBoundsChangeAnimationCurve(void);
UIViewAnimationCurve NIStatusBarBoundsChangeAnimationCurve(void)
API_UNAVAILABLE(tvos, watchos);

/**
* The animation duration used when the status bar's bounds change (when a call is received,
* for example).
*
* Value: 0.35 seconds
*/
NSTimeInterval NIStatusBarBoundsChangeAnimationDuration(void);
NSTimeInterval NIStatusBarBoundsChangeAnimationDuration(void)
API_UNAVAILABLE(tvos, watchos);

/**
* Get the status bar's current height.
Expand All @@ -124,7 +130,8 @@ NSTimeInterval NIStatusBarBoundsChangeAnimationDuration(void);
*
* This is generally 20 when the status bar is its normal height.
*/
CGFloat NIStatusBarHeight(void) NI_EXTENSION_UNAVAILABLE_IOS("");
CGFloat NIStatusBarHeight(void) NI_EXTENSION_UNAVAILABLE_IOS("")
API_UNAVAILABLE(tvos, watchos);

/**
* The animation duration when the device is rotating to a new orientation.
Expand All @@ -134,14 +141,16 @@ CGFloat NIStatusBarHeight(void) NI_EXTENSION_UNAVAILABLE_IOS("");
*
* @param isFlippingUpsideDown YES if the device is being flipped upside down.
*/
NSTimeInterval NIDeviceRotationDuration(BOOL isFlippingUpsideDown);
NSTimeInterval NIDeviceRotationDuration(BOOL isFlippingUpsideDown)
API_UNAVAILABLE(tvos, watchos);

/**
* The padding around a standard cell in a table view.
*
* Value: 10 pixels on all sides.
*/
UIEdgeInsets NICellContentPadding(void);
UIEdgeInsets NICellContentPadding(void)
API_UNAVAILABLE(tvos, watchos);

#if defined __cplusplus
}
Expand Down
12 changes: 8 additions & 4 deletions src/core/src/NIDeviceOrientation.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ extern "C" {
*
* Always returns YES.
*/
BOOL NIIsSupportedOrientation(UIInterfaceOrientation orientation);
BOOL NIIsSupportedOrientation(UIInterfaceOrientation orientation)
API_UNAVAILABLE(tvos, watchos);

/**
* Returns the application's current interface orientation.
Expand All @@ -64,7 +65,8 @@ BOOL NIIsSupportedOrientation(UIInterfaceOrientation orientation);
*
* @returns The current interface orientation.
*/
UIInterfaceOrientation NIInterfaceOrientation(void) NI_EXTENSION_UNAVAILABLE_IOS("");
UIInterfaceOrientation NIInterfaceOrientation(void) NI_EXTENSION_UNAVAILABLE_IOS("")
API_UNAVAILABLE(tvos, watchos);

/**
* Returns YES if the device is a phone and the orientation is landscape.
Expand All @@ -74,15 +76,17 @@ UIInterfaceOrientation NIInterfaceOrientation(void) NI_EXTENSION_UNAVAILABLE_IOS
*
* @returns YES if the device is a phone and orientation is landscape.
*/
BOOL NIIsLandscapePhoneOrientation(UIInterfaceOrientation orientation);
BOOL NIIsLandscapePhoneOrientation(UIInterfaceOrientation orientation)
API_UNAVAILABLE(tvos, watchos);

/**
* Creates an affine transform for the given device orientation.
*
* This is useful for creating a transformation matrix for a view that has been added
* directly to the window and doesn't automatically have its transformation modified.
*/
CGAffineTransform NIRotateTransformForOrientation(UIInterfaceOrientation orientation);
CGAffineTransform NIRotateTransformForOrientation(UIInterfaceOrientation orientation)
API_UNAVAILABLE(tvos, watchos);

#if defined __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/src/NIFoundationMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ CGRect NIFrameOfCenteredViewWithinView(UIView* viewToCenter, UIView* containerVi
/**
* Returns the size of the string with given UILabel properties.
*/
CGSize NISizeOfStringWithLabelProperties(NSString *string, CGSize constrainedToSize, UIFont *font, NSLineBreakMode lineBreakMode, NSInteger numberOfLines);
CGSize NISizeOfStringWithLabelProperties(NSString *string, CGSize constrainedToSize, UIFont *font, NSLineBreakMode lineBreakMode, NSInteger numberOfLines)
API_UNAVAILABLE(tvos, watchos);

/**@}*/

Expand Down
3 changes: 2 additions & 1 deletion src/core/src/NIImageUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ extern "C" {
* stretching images that have gradients. For example, an image with a vertical gradient
* can be stretched horizontally, but will look odd if stretched vertically.
*/
UIImage* NIStretchableImageFromImage(UIImage* image);
UIImage* NIStretchableImageFromImage(UIImage* image)
API_UNAVAILABLE(tvos, watchos);

/**@}*/// End of Image Utilities //////////////////////////////////////////////////////////////////

Expand Down
9 changes: 5 additions & 4 deletions src/core/src/NINetworkActivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ extern "C" {
*
* This method is threadsafe.
*/
void NINetworkActivityTaskDidStart(void) NI_EXTENSION_UNAVAILABLE_IOS("");
void NINetworkActivityTaskDidStart(void) NI_EXTENSION_UNAVAILABLE_IOS("")
API_UNAVAILABLE(tvos, watchos);

/**
* Decrement the number of active network tasks.
Expand All @@ -52,7 +53,7 @@ void NINetworkActivityTaskDidStart(void) NI_EXTENSION_UNAVAILABLE_IOS("");
*
* This method is threadsafe.
*/
void NINetworkActivityTaskDidFinish(void);
void NINetworkActivityTaskDidFinish(void) API_UNAVAILABLE(tvos, watchos);

/**
* @name For Debugging Only
Expand All @@ -78,7 +79,7 @@ void NINetworkActivityTaskDidFinish(void);
*
* If debugging was previously enabled, this does nothing.
*/
void NIEnableNetworkActivityDebugging(void);
void NIEnableNetworkActivityDebugging(void) API_UNAVAILABLE(tvos, watchos);

/**
* Disable network activity debugging.
Expand All @@ -90,7 +91,7 @@ void NIEnableNetworkActivityDebugging(void);
*
* If debugging wasn't previously enabled, this does nothing.
*/
void NIDisableNetworkActivityDebugging(void);
void NIDisableNetworkActivityDebugging(void) API_UNAVAILABLE(tvos, watchos);

/**@}*/// End of For Debugging Only

Expand Down
1 change: 1 addition & 0 deletions src/core/src/NINetworkActivity.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
static const NSTimeInterval kDelayBeforeDisablingActivity = 0.1;
static NSTimer* gScheduledDelayTimer = nil;

API_UNAVAILABLE(tvos, watchos)
@interface NINetworkActivity : NSObject
@end

Expand Down
3 changes: 3 additions & 0 deletions src/core/src/NISnapshotRotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* You must call this object's rotation methods from your controller in order for the rotation
* object to implement the rotation animations correctly.
*/
API_UNAVAILABLE(tvos, watchos)
@interface NISnapshotRotation : NSObject

// Designated initializer.
Expand Down Expand Up @@ -71,13 +72,15 @@
* The assigned delegate only needs to implement containerViewForSnapshotRotation: and
* rotatingViewForSnapshotRotation:.
*/
API_UNAVAILABLE(tvos, watchos)
@interface NITableViewSnapshotRotation : NISnapshotRotation
@end

/**
* The methods declared by the NISnapshotRotation protocol allow the adopting delegate to respond to
* messages from the NISnapshotRotation class and thus implement snapshot rotations.
*/
API_UNAVAILABLE(tvos, watchos)
@protocol NISnapshotRotationDelegate <NSObject>
@required

Expand Down

0 comments on commit f44a5a1

Please sign in to comment.