-
Notifications
You must be signed in to change notification settings - Fork 15
AirSense Widget
Widget that displays an icon representing whether there are any aircraft nearby and how likely a collision is. The icon is shown in different colors representing the current AirSenseWarningLevel. The widget will be hidden on devices that do not have DJI AirSense installed. The icon is gray when no airplanes are nearby, and "N/A" is displayed when no product is connected.
When the warning level changes to DJIAirSenseWarningLevel.LEVEL_1 or above, a warning dialog will appear. This warning dialog contains a warning message, an option to never show the dialog again, and a link to an additional page with AirSense Terms and Conditions for the user to agree to.
When the warning level is at DJIAirSenseWarningLevel.LEVEL_2 or above, a toast will appear to suggest that the user should descend immediately. To react to all WarningMessages sent by all widgets including the AirSenseWidget, listen to UXSDK key with parameter DUXBetaWarningMessageParameterSendWarningMessage through DUXBetaSingleton.
Image | State | Description |
---|---|---|
DISCONNECTED |
There is no product connected. | |
NO_AIRPLANES_NEARBY |
A product that has DJI AirSense is connected and no airplanes are nearby. | |
WARNING_LEVEL_0 |
A product that has DJI AirSense is connected and the system detects an airplane but the DJI aircraft is either far away from the airplane or is in the opposite direction of the airplane's heading. | |
WARNING_LEVEL_1 |
A product that has DJI AirSense is connected and the system detects an airplane. The probability that it will pass through the location of the DJI aircraft is considered low. | |
WARNING_LEVEL_2 |
A product that has DJI AirSense is connected and the system detects an airplane. The probability that it will pass through the location of the DJI aircraft is considered medium. | |
WARNING_LEVEL_3 |
A product that has DJI AirSense is connected and the system detects an airplane. The probability that it will pass through the location of the DJI aircraft is considered high. | |
WARNING_LEVEL_4 |
A product that has DJI AirSense is connected and the system detects an airplane. The probability that it will pass through the location of the DJI aircraft is very high. |
If creating the AirSense widget through code it can be added using the convenience method:
- (void)installInViewController:(nullable UIViewController *)viewController
If creating the widget through storyboard use the object library to drag a container view controller into the desired view controller like so:
Following this make sure to change the class of the child view controller to be DUXBetaAirSenseWidget
. From here you can create the constraints on the container view using the AirSense Widget's widgetSizeHint
property.
The AirSense Widget supports customization of its icon as well as the dialog it presents.
An example of a customized AirSense widget showing there are no airplanes nearby could look something like this:
To get this effect we would use the following code:
airSenseWidget.airSenseImage = UIImage.init(named: "airSenseCustomIcon")!
airSenseWidget.setTintColor(UIColor.green, forWarning: DUXBetaAirSenseState_NoAirplanesNearby)
airSenseWidget.iconBackgroundColor = UIColor.black;
airSenseWidget.airSenseImage = [UIImage imageNamed:@"airSenseCustomIcon"];
[airSenseWidget setTintColor:[UIColor greenColor] forWarningState:DUXBetaAirSenseState_NoAirplanesNearby];
airSenseWidget.iconBackgroundColor = [UIColor blackColor];
An example of a customized AirSense dialog could look something like this:
To get this effect we would use the following code:
airSenseWidget.dialogTitleTextColor = UIColor.white
airSenseWidget.checkboxLabelTextColor = UIColor.white
airSenseWidget.dialogBackgroundColor = UIColor.black
airSenseWidget.emptyCheckboxImage = UIImage.init(named: "radioButtonOff")!
airSenseWidget.checkedCheckboxImage = UIImage.init(named: "radioButtonOn")!
airSenseWidget.dialogTitleTextColor = [UIColor whiteColor];
airSenseWidget.checkboxLabelTextColor = [UIColor whiteColor];
airSenseWidget.dialogBackgroundColor = [UIColor blackColor];
airSenseWidget.emptyCheckboxImage = [UIImage imageNamed:@"radioButtonOff"];
airSenseWidget.emptyCheckboxImage = [UIImage imageNamed:@"radioButtonOn"];
List of customization methods and properties
-
@property (nonatomic, strong) UIImage *airSenseImage;
The AirSense icon image. -
@property (nonatomic, strong) UIImage *disconnectedImage;
The AirSense icon when product is disconnected. -
@property (nonatomic, strong) UIColor *iconBackgroundColor;
The AirSense icon background color. -
@property (strong, nonatomic) NSString *dialogTitle;
The dialog title text (Another aircraft is nearby). -
@property (strong, nonatomic) UIColor *dialogTitleTextColor;
The dialog title text color. -
@property (strong, nonatomic) NSString *dialogMessage;
The dialog clickable message text (Please make sure you have read...). -
@property (strong, nonatomic) UIColor *dialogBackgroundColor;
The dialog's background color. -
@property (nonatomic, strong) UIImage *checkedCheckboxImage;
The image for the checkbox to the left of the "Don't show again" label when checked. -
@property (nonatomic, strong) UIImage *emptyCheckboxImage;
The image for the checkbox to the left of the "Don't show again" label when empty. -
@property (nonatomic, strong) UIColor *checkboxLabelTextColor;
The warning dialog checkbox label ("Don't show again") text color. -
@property (nonatomic, strong) UIFont *checkboxLabelTextFont;
The warning dialog checkbox label("Don't show again") text font. -
@property (nonatomic, strong) UIColor *dialogMessageTextColor;
The warning dialog message(clickable message: "make sure you have read and understood...") text color. -
@property (nonatomic, strong) UIFont *dialogMessageTextFont;
The warning dialog message(clickable message: "make sure you have read and understood...") text font. -
- (void)setTintColor:(UIColor *)color forWarningState:(DUXBetaAirSenseState)state;
Set tint color for given warning level. -
- (UIColor *)getTintColorForWarningState:(DUXBetaAirSenseState)state;
Get tint color for given warning level.
The widget provides hooks for users to add functionality based on state changes in the widget. The AirSense widget provides the following hooks
-
AirSenseModelState
- Provides hooks for events received by the widget from the widget model.
-
+ (instancetype)productConnected:(BOOL)isConnected;
- Event when product is connected or disconnected. -
+ (instancetype)airSenseWarningStateUpdate:(NSNumber *)warningState;
- Sends an NSNumber containing the AirSense warning state as an integer.
-
AirSenseUIState
- Provides hooks for events received by the widget from user interactions.
-
+ (instancetype)dialogDisplayed:(id)info;
- Sends the string identifier for a dialog being displayed (usually in response to a button tap or edit value update). -
+ (instancetype)dialogActionConfirmed:(id)info;
- Sends the string identifier for a dialog after the OK/Confirmation button was tapped in the displayed dialog. -
+ (instancetype)dialogActionDismissed:(id)info;
- Sends the string identifier for a dialog after the Cancel/Dismiss button was tapped in the displayed dialog. -
+ (instancetype)termsLinkTapped;
- Event when user taps the terms link. -
+ (instancetype)dontShowAgainCheckBoxTapped:(BOOL)isChecked;
- Event when user selects or deselects the don't show again checkbox.
DJI UX SDK Version 5 Beta 4.1