-
Notifications
You must be signed in to change notification settings - Fork 401
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
fix: make adjusting screenshot coordinate configurable - screenshotOrientation settings api #277
Changes from all commits
2ad9289
8e1d1a0
84bf3ff
8d033b2
0a3c626
e77a936
b78445a
9440004
963b3ab
7edcaaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
static NSString* const INCLUDE_NON_MODAL_ELEMENTS = @"includeNonModalElements"; | ||
static NSString* const ACCEPT_ALERT_BUTTON_SELECTOR = @"acceptAlertButtonSelector"; | ||
static NSString* const DISMISS_ALERT_BUTTON_SELECTOR = @"dismissAlertButtonSelector"; | ||
static NSString* const SCREENSHOT_ORIENTATION = @"screenshotOrientation"; | ||
|
||
|
||
@implementation FBSessionCommands | ||
|
@@ -258,6 +259,9 @@ + (NSArray *)routes | |
INCLUDE_NON_MODAL_ELEMENTS: @([FBConfiguration includeNonModalElements]), | ||
ACCEPT_ALERT_BUTTON_SELECTOR: FBConfiguration.acceptAlertButtonSelector, | ||
DISMISS_ALERT_BUTTON_SELECTOR: FBConfiguration.dismissAlertButtonSelector, | ||
#if !TARGET_OS_TV | ||
SCREENSHOT_ORIENTATION: [FBConfiguration humanReadableScreenshotOrientation], | ||
#endif | ||
} | ||
); | ||
} | ||
|
@@ -328,6 +332,18 @@ + (NSArray *)routes | |
[FBConfiguration setDismissAlertButtonSelector:(NSString *)[settings objectForKey:DISMISS_ALERT_BUTTON_SELECTOR]]; | ||
} | ||
|
||
#if !TARGET_OS_TV | ||
if (nil != [settings objectForKey:SCREENSHOT_ORIENTATION]) { | ||
NSError *error; | ||
if (![FBConfiguration setScreenshotOrientation:(NSString *)[settings objectForKey:SCREENSHOT_ORIENTATION] | ||
error:&error]) { | ||
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:error.description traceback:nil]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
} | ||
|
||
|
||
} | ||
#endif | ||
|
||
return [self handleGetSettings:request]; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,9 @@ | |
static NSString *FBSnapshotMaxDepthKey = @"maxDepth"; | ||
static NSMutableDictionary *FBSnapshotRequestParameters; | ||
|
||
#if !TARGET_OS_TV | ||
static UIInterfaceOrientation FBScreenshotOrientation = UIInterfaceOrientationUnknown; | ||
#endif | ||
|
||
@implementation FBConfiguration | ||
|
||
|
@@ -343,6 +346,52 @@ + (NSString *)dismissAlertButtonSelector | |
return FBDismissAlertButtonSelector; | ||
} | ||
|
||
#if !TARGET_OS_TV | ||
+ (BOOL)setScreenshotOrientation:(NSString *)orientation error:(NSError **)error | ||
{ | ||
// Only UIInterfaceOrientationUnknown is over iOS 8. Others are over iOS 2. | ||
// https://developer.apple.com/documentation/uikit/uiinterfaceorientation/uiinterfaceorientationunknown | ||
if ([orientation.lowercaseString isEqualToString:@"portrait"]) { | ||
FBScreenshotOrientation = UIInterfaceOrientationPortrait; | ||
} else if ([orientation.lowercaseString isEqualToString:@"portraitupsidedown"]) { | ||
FBScreenshotOrientation = UIInterfaceOrientationPortraitUpsideDown; | ||
} else if ([orientation.lowercaseString isEqualToString:@"landscaperight"]) { | ||
FBScreenshotOrientation = UIInterfaceOrientationLandscapeRight; | ||
} else if ([orientation.lowercaseString isEqualToString:@"landscapeleft"]) { | ||
FBScreenshotOrientation = UIInterfaceOrientationLandscapeLeft; | ||
} else if ([orientation.lowercaseString isEqualToString:@"auto"]) { | ||
FBScreenshotOrientation = UIInterfaceOrientationUnknown; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather throw an error if an unknown setting value is provided |
||
} else { | ||
return [[FBErrorBuilder.builder withDescriptionFormat: | ||
@"The orientation value '%@' is not known. Only the following orientation values are supported: " \ | ||
"'auto', 'portrate', 'portraitUpsideDown', 'landscapeRight' and 'landscapeLeft'", orientation] | ||
buildError:error]; | ||
} | ||
return YES; | ||
} | ||
|
||
+ (NSInteger)screenshotOrientation | ||
{ | ||
return FBScreenshotOrientation; | ||
mykola-mokhnach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
+ (NSString *)humanReadableScreenshotOrientation | ||
{ | ||
switch (FBScreenshotOrientation) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
case UIInterfaceOrientationPortrait: | ||
return @"portrait"; | ||
case UIInterfaceOrientationPortraitUpsideDown: | ||
return @"portraitUpsideDown"; | ||
case UIInterfaceOrientationLandscapeRight: | ||
return @"landscapeRight"; | ||
case UIInterfaceOrientationLandscapeLeft: | ||
return @"landscapeLeft"; | ||
case UIInterfaceOrientationUnknown: | ||
return @"auto"; | ||
} | ||
} | ||
#endif | ||
|
||
#pragma mark Private | ||
|
||
+ (BOOL)keyboardsPreference:(nonnull NSString *)key | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍