Skip to content

Camera Config Color Widget

Siddharth Utgikar edited this page Feb 26, 2021 · 1 revision

(Updated widget in develop branch)

Camera Config Color Widget is created using Base Camera Config Widget and shows the camera's current color profile. The widget will be hidden when camera color is UNKNOWN or NONE.

Usage

<dji.ux.beta.visualcamera.widget.cameraconfig.color.CameraConfigColorWidget
        android:id="@+id/widget_camera_config_color"
        android:layout_width="wrap_content"
        android:layout_height="35dp" />

Customizations

The widget can be customized by the user to serve their purpose and theme. It supports all the customizations that its parent Base Camera Config Widget does. The customizations can be done using attributes in XML or programmatically using the APIs.

XML Example

<dji.ux.beta.visualcamera.widget.cameraconfig.color.CameraConfigColorWidget
        android:id="@+id/widget_camera_config_color"
        android:layout_width="wrap_content"
        android:layout_height="35dp"
        android:background="@color/white"
        app:uxsdk_value_normal_color="@color/red"
        app:uxsdk_label_text_color="@color/black" />

Attributes

List of the customizable XML attributes
  • uxsdk_cameraIndex - The camera index to which the widget should react.

Kotlin Example

val cameraConfigColorWidget = findViewById<CameraConfigColorWidget>(R.id.widget_camera_config_color)
cameraConfigColorWidget.setBackgroundColor(resources.getColor(R.color.white))
cameraConfigColorWidget.labelTextColor = resources.getColor(R.color.black)
cameraConfigColorWidget.normalValueColor = resources.getColor(R.color.red)

Java Example

CameraConfigColorWidget cameraConfigColorWidget = findViewById(R.id.widget_camera_config_color);
cameraConfigColorWidget.setBackgroundColor(getResources().getColor(R.color.white));
cameraConfigColorWidget.setLabelTextColor(getResources().getColor(R.color.black));
cameraConfigColorWidget.setNormalValueColor(getResources().getColor(R.color.red));

APIs

List of the customization APIs
  • var cameraIndex: CameraIndex - The camera index for which the widget should react.

Hooks

The widget provides hooks for users to add functionality based on state changes in the widget. The Camera Config Color widget provides the following hooks

  1. ModelState - Provides hooks for events received by the widget from the widget model.
    • data class ProductConnected(val isConnected: Boolean) : ModelState() - Event when product is connected or disconnected.
    • data class ColorStateUpdated(val colorState: CameraConfigColorState) : ModelState() - Event when camera color state is updated.

The user can subscribe to this using public override fun getWidgetStateUpdate(): Flowable<ModelState>.

Clone this wiki locally