diff --git a/.travis.yml b/.travis.yml
index 5f3545ca..b9e1da97 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -38,8 +38,8 @@ before_script:
- chmod +x gradlew
script:
- - ./gradlew clean build
- - ./gradlew test
+ - travis_wait 30 ./gradlew clean build
+ - travis_wait 30 ./gradlew test
after_success:
- bash <(curl -s https://codecov.io/bash)
diff --git a/README.md b/README.md
index e8dc13a2..ba818665 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ You can also post questions, keep up to date on DJI developer news and contribut
## Future Plans
-We are eager to give you a sneak peek, and are very interested in receiving your feedback and suggestions. Please refer to the wiki or the release notes for the full list of elements that the Beta 4 version makes available.
+We are eager to give you a sneak peek, and are very interested in receiving your feedback and suggestions. Please refer to the wiki or the release notes for the full list of elements that the Beta 5 version makes available.
Our long-term plan is for this framework to reach feature parity with the current UX SDK 4.x release. The core team is currently working on porting the remaining widgets and other APIs to the new architecture and we will open source them in additional future Beta releases as they are completed. We welcome your feedback on the architecture and your ideas for additional widgets, including those not included in prior UX SDK releases, as well as your contributions and PRs for any ***currently open-sourced features***.
diff --git a/android-uxsdk-beta-hardwareaccessory/build.gradle b/android-uxsdk-beta-accessory/build.gradle
similarity index 96%
rename from android-uxsdk-beta-hardwareaccessory/build.gradle
rename to android-uxsdk-beta-accessory/build.gradle
index 6c2455af..4d40f66f 100644
--- a/android-uxsdk-beta-hardwareaccessory/build.gradle
+++ b/android-uxsdk-beta-accessory/build.gradle
@@ -69,7 +69,7 @@ android {
dependencies {
api project(path: ':android-uxsdk-beta-core')
- implementation ('com.dji:dji-sdk:4.13.1', {
+ implementation ('com.dji:dji-sdk:4.14-trial1', {
/**
* Comment the "library-anti-distortion" if your app needs Anti Distortion for Mavic 2 Pro
* and Mavic 2 Zoom.
@@ -81,7 +81,7 @@ dependencies {
exclude module: 'library-anti-distortion'
exclude module: 'fly-safe-database'
})
- compileOnly ('com.dji:dji-sdk-provided:4.13.1')
+ compileOnly ('com.dji:dji-sdk-provided:4.14-trial1')
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
diff --git a/android-uxsdk-beta-hardwareaccessory/proguard-rules.pro b/android-uxsdk-beta-accessory/proguard-rules.pro
similarity index 100%
rename from android-uxsdk-beta-hardwareaccessory/proguard-rules.pro
rename to android-uxsdk-beta-accessory/proguard-rules.pro
diff --git a/android-uxsdk-beta-hardwareaccessory/proguard-test-rules.pro b/android-uxsdk-beta-accessory/proguard-test-rules.pro
similarity index 100%
rename from android-uxsdk-beta-hardwareaccessory/proguard-test-rules.pro
rename to android-uxsdk-beta-accessory/proguard-test-rules.pro
diff --git a/android-uxsdk-beta-intelligentflight/src/main/AndroidManifest.xml b/android-uxsdk-beta-accessory/src/main/AndroidManifest.xml
similarity index 95%
rename from android-uxsdk-beta-intelligentflight/src/main/AndroidManifest.xml
rename to android-uxsdk-beta-accessory/src/main/AndroidManifest.xml
index 17cb7967..719fb363 100644
--- a/android-uxsdk-beta-intelligentflight/src/main/AndroidManifest.xml
+++ b/android-uxsdk-beta-accessory/src/main/AndroidManifest.xml
@@ -21,4 +21,4 @@
~
-->
-
+
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKEnabledWidget.kt b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKEnabledWidget.kt
similarity index 84%
rename from android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKEnabledWidget.kt
rename to android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKEnabledWidget.kt
index 8c4e18b7..20dcf579 100644
--- a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKEnabledWidget.kt
+++ b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKEnabledWidget.kt
@@ -18,10 +18,10 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
- *
+ *
*/
-package dji.ux.beta.hardwareaccessory.widget.rtk
+package dji.ux.beta.accessory.widget.rtk
import android.annotation.SuppressLint
import android.content.Context
@@ -39,17 +39,17 @@ import dji.thirdparty.io.reactivex.Flowable
import dji.thirdparty.io.reactivex.disposables.Disposable
import dji.thirdparty.io.reactivex.functions.Consumer
import dji.thirdparty.io.reactivex.processors.PublishProcessor
-import dji.ux.beta.core.base.ConstraintLayoutWidget
+import dji.ux.beta.accessory.R
+import dji.ux.beta.accessory.widget.rtk.RTKEnabledWidget.ModelState
+import dji.ux.beta.accessory.widget.rtk.RTKEnabledWidget.ModelState.ProductConnected
+import dji.ux.beta.accessory.widget.rtk.RTKEnabledWidget.ModelState.RTKEnabledUpdated
+import dji.ux.beta.accessory.widget.rtk.RTKEnabledWidget.UIState.SwitchChanged
import dji.ux.beta.core.base.DJISDKModel
import dji.ux.beta.core.base.SchedulerProvider
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore
+import dji.ux.beta.core.base.widget.ConstraintLayoutWidget
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore
import dji.ux.beta.core.extension.*
import dji.ux.beta.core.util.DisplayUtil
-import dji.ux.beta.hardwareaccessory.R
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKEnabledWidget.RTKEnabledWidgetState
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKEnabledWidget.RTKEnabledWidgetState.ProductConnected
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKEnabledWidget.RTKEnabledWidgetState.RTKEnabledUpdate
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKEnabledWidget.RTKEnabledWidgetUIState.RTKEnabledSwitchCheckChanged
private const val TAG = "RTKEnabledWidget"
@@ -60,19 +60,18 @@ open class RTKEnabledWidget @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : ConstraintLayoutWidget(context, attrs, defStyleAttr), CompoundButton.OnCheckedChangeListener {
+) : ConstraintLayoutWidget(context, attrs, defStyleAttr), CompoundButton.OnCheckedChangeListener {
//region Fields
private val rtkTitleTextView: TextView = findViewById(R.id.textview_rtk_title)
private val rtkEnabledSwitch: Switch = findViewById(R.id.switch_rtk_enabled)
private val rtkEnabledDescriptionTextView: TextView = findViewById(R.id.textview_rtk_enabled_description)
- private val uiUpdateStateProcessor: PublishProcessor = PublishProcessor.create()
+ private val uiUpdateStateProcessor: PublishProcessor = PublishProcessor.create()
private val widgetModel by lazy {
RTKEnabledWidgetModel(
DJISDKModel.getInstance(),
- ObservableInMemoryKeyedStore.getInstance(),
- SchedulerProvider.getInstance())
+ ObservableInMemoryKeyedStore.getInstance())
}
/**
@@ -169,7 +168,7 @@ open class RTKEnabledWidget @JvmOverloads constructor(
}
//endregion
- //region Constructors
+ //region Constructor
override fun initView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) {
inflate(context, R.layout.uxsdk_widget_rtk_enabled, this)
}
@@ -197,7 +196,7 @@ open class RTKEnabledWidget @JvmOverloads constructor(
override fun onCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) {
addDisposable(widgetModel.canEnableRTK.firstOrError()
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(Consumer { canEnableRTK: Boolean ->
if (!canEnableRTK) {
setRTKSwitch(!isChecked)
@@ -206,15 +205,15 @@ open class RTKEnabledWidget @JvmOverloads constructor(
setRTKEnabled(isChecked)
}
}, logErrorConsumer(TAG, "canEnableRTK: ")))
- uiUpdateStateProcessor.onNext(RTKEnabledSwitchCheckChanged(isChecked))
+ uiUpdateStateProcessor.onNext(SwitchChanged(isChecked))
}
override fun reactToModelChanges() {
addReaction(widgetModel.rtkEnabled
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { updateUIForRTKEnabled(it) })
addReaction(widgetModel.productConnection
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { widgetStateDataProcessor.onNext(ProductConnected(it)) })
}
//endregion
@@ -222,13 +221,13 @@ open class RTKEnabledWidget @JvmOverloads constructor(
//region Reaction helpers
private fun updateUIForRTKEnabled(rtkEnabled: Boolean) {
setRTKSwitch(rtkEnabled)
- widgetStateDataProcessor.onNext(RTKEnabledUpdate(rtkEnabled))
+ widgetStateDataProcessor.onNext(RTKEnabledUpdated(rtkEnabled))
}
private fun setRTKEnabled(enabled: Boolean) {
addDisposable(widgetModel.rtkEnabled
.firstOrError()
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(Consumer { rtkEnabled: Boolean ->
if (rtkEnabled != enabled) {
addDisposable(toggleRTK(enabled))
@@ -238,7 +237,7 @@ open class RTKEnabledWidget @JvmOverloads constructor(
private fun toggleRTK(enabled: Boolean): Disposable {
return widgetModel.setRTKEnabled(enabled)
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe({}
) { throwable: Throwable ->
setRTKSwitch(!enabled)
@@ -333,42 +332,43 @@ open class RTKEnabledWidget @JvmOverloads constructor(
//region Hooks
/**
- * Get the [RTKEnabledWidgetUIState] updates
+ * Get the [UIState] updates
*/
- fun getUIStateUpdates(): Flowable {
- return uiUpdateStateProcessor
+ fun getUIStateUpdates(): Flowable {
+ return uiUpdateStateProcessor.onBackpressureBuffer()
}
/**
* Widget UI update State
*/
- sealed class RTKEnabledWidgetUIState {
+ sealed class UIState {
/**
* RTK enabled switch check changed update
*/
- data class RTKEnabledSwitchCheckChanged(val isChecked: Boolean) : RTKEnabledWidgetUIState()
+ data class SwitchChanged(val isChecked: Boolean) : UIState()
}
/**
- * Get the [RTKEnabledWidgetState] updates
+ * Get the [ModelState] updates
*/
- override fun getWidgetStateUpdate(): Flowable {
+ @SuppressWarnings
+ override fun getWidgetStateUpdate(): Flowable {
return super.getWidgetStateUpdate()
}
/**
* Class defines the widget state updates
*/
- sealed class RTKEnabledWidgetState {
+ sealed class ModelState {
/**
* Product connection update
*/
- data class ProductConnected(val isConnected: Boolean) : RTKEnabledWidgetState()
+ data class ProductConnected(val isConnected: Boolean) : ModelState()
/**
* RTK enabled update
*/
- data class RTKEnabledUpdate(val isRTKEnabled: Boolean) : RTKEnabledWidgetState()
+ data class RTKEnabledUpdated(val isRTKEnabled: Boolean) : ModelState()
}
//endregion
}
\ No newline at end of file
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKEnabledWidgetModel.kt b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKEnabledWidgetModel.kt
similarity index 86%
rename from android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKEnabledWidgetModel.kt
rename to android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKEnabledWidgetModel.kt
index 12dea042..3beff70d 100644
--- a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKEnabledWidgetModel.kt
+++ b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKEnabledWidgetModel.kt
@@ -18,28 +18,27 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
- *
+ *
*/
-package dji.ux.beta.hardwareaccessory.widget.rtk
+package dji.ux.beta.accessory.widget.rtk
import dji.keysdk.DJIKey
import dji.keysdk.FlightControllerKey
import dji.thirdparty.io.reactivex.Completable
import dji.thirdparty.io.reactivex.Flowable
import dji.ux.beta.core.base.DJISDKModel
-import dji.ux.beta.core.base.SchedulerProviderInterface
import dji.ux.beta.core.base.WidgetModel
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore
import dji.ux.beta.core.util.DataProcessor
/**
* Widget Model for the [RTKEnabledWidget] used to define
* the underlying logic and communication
*/
-class RTKEnabledWidgetModel(djiSdkModel: DJISDKModel,
- keyedStore: ObservableInMemoryKeyedStore,
- private val schedulerProvider: SchedulerProviderInterface
+class RTKEnabledWidgetModel(
+ djiSdkModel: DJISDKModel,
+ keyedStore: ObservableInMemoryKeyedStore
) : WidgetModel(djiSdkModel, keyedStore) {
//region Fields
@@ -90,7 +89,7 @@ class RTKEnabledWidgetModel(djiSdkModel: DJISDKModel,
//region User interaction
fun setRTKEnabled(enabled: Boolean): Completable {
- return djiSdkModel.setValue(isRTKEnabledKey, enabled).subscribeOn(schedulerProvider.io())
+ return djiSdkModel.setValue(isRTKEnabledKey, enabled)
}
//endregion
}
@@ -123,15 +122,12 @@ enum class HomePointDataSourceType(@get:JvmName("value") val value: Int) {
UNKNOWN(255);
companion object {
+ @JvmStatic
+ val values = values()
+
@JvmStatic
fun find(value: Int): HomePointDataSourceType {
- val values = values()
- for (item in values) {
- if (item.value == value) {
- return item
- }
- }
- return UNKNOWN
+ return values.find { it.value == value } ?: UNKNOWN
}
}
}
\ No newline at end of file
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKSatelliteStatusWidget.kt b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKSatelliteStatusWidget.kt
similarity index 90%
rename from android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKSatelliteStatusWidget.kt
rename to android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKSatelliteStatusWidget.kt
index 88977fc1..b4ed79e3 100644
--- a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKSatelliteStatusWidget.kt
+++ b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKSatelliteStatusWidget.kt
@@ -18,10 +18,10 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
- *
+ *
*/
-package dji.ux.beta.hardwareaccessory.widget.rtk
+package dji.ux.beta.accessory.widget.rtk
import android.annotation.SuppressLint
import android.content.Context
@@ -45,18 +45,18 @@ import dji.common.flightcontroller.rtk.NetworkServiceChannelState
import dji.common.product.Model
import dji.thirdparty.io.reactivex.Flowable
import dji.thirdparty.io.reactivex.functions.Consumer
-import dji.ux.beta.core.base.ConstraintLayoutWidget
+import dji.ux.beta.accessory.R
+import dji.ux.beta.accessory.widget.rtk.RTKSatelliteStatusWidget.ModelState
+import dji.ux.beta.accessory.widget.rtk.RTKSatelliteStatusWidget.ModelState.*
+import dji.ux.beta.accessory.widget.rtk.RTKSatelliteStatusWidgetModel.*
import dji.ux.beta.core.base.DJISDKModel
-import dji.ux.beta.core.base.GlobalPreferencesManager
import dji.ux.beta.core.base.SchedulerProvider
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore
+import dji.ux.beta.core.base.widget.ConstraintLayoutWidget
+import dji.ux.beta.core.communication.GlobalPreferencesManager
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore
import dji.ux.beta.core.extension.*
import dji.ux.beta.core.util.DisplayUtil
import dji.ux.beta.core.util.UnitConversionUtil
-import dji.ux.beta.hardwareaccessory.R
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKSatelliteStatusWidget.RTKSatelliteStatusWidgetState
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKSatelliteStatusWidget.RTKSatelliteStatusWidgetState.*
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKSatelliteStatusWidgetModel.*
import java.util.*
private const val TAG = "RTKStatusWidget"
@@ -64,13 +64,13 @@ private const val TAG = "RTKStatusWidget"
/**
* This widget shows all the information related to RTK. This includes coordinates and altitude
* of the aircraft and base station, course angle, GLONASS, Beidou, Galileo, and GPS satellite
- * counts for both antennas and the base station, and overall status of the RTK system.
+ * counts for both antennas and the base station, and overall state of the RTK system.
*/
open class RTKSatelliteStatusWidget @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : ConstraintLayoutWidget(context, attrs, defStyleAttr) {
+) : ConstraintLayoutWidget(context, attrs, defStyleAttr) {
//region Fields
private val rtkStatusTitleTextView: TextView = findViewById(R.id.textview_rtk_status_title)
private val rtkStatusTextView: TextView = findViewById(R.id.textview_rtk_status)
@@ -118,11 +118,11 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
private val rtkOrientationPositioningSeparator: View = findViewById(R.id.rtk_orientation_positioning_separator)
private val rtkLocationSeparator: View = findViewById(R.id.rtk_location_separator)
private val rtkSatelliteCountSeparator: View = findViewById(R.id.rtk_satellite_count_separator)
- private val connectionStatusTextColorMap: MutableMap =
+ private val connectionStateTextColorMap: MutableMap =
mutableMapOf(
- RTKBaseStationStatus.CONNECTED_IN_USE to getColor(R.color.uxsdk_rtk_status_connected_in_use),
- RTKBaseStationStatus.CONNECTED_NOT_IN_USE to getColor(R.color.uxsdk_rtk_status_connected_not_in_use),
- RTKBaseStationStatus.DISCONNECTED to getColor(R.color.uxsdk_rtk_status_disconnected)
+ RTKBaseStationState.CONNECTED_IN_USE to getColor(R.color.uxsdk_rtk_status_connected_in_use),
+ RTKBaseStationState.CONNECTED_NOT_IN_USE to getColor(R.color.uxsdk_rtk_status_connected_not_in_use),
+ RTKBaseStationState.DISCONNECTED to getColor(R.color.uxsdk_rtk_status_disconnected)
)
private val widgetModel by lazy {
@@ -132,7 +132,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * The text size of the RTK connection status title.
+ * The text size of the RTK connection state title.
*/
var rtkConnectionStatusTitleTextSize: Float
@JvmName("getRTKConnectionStatusTitleTextSize")
@@ -144,7 +144,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * The text color of the RTK connection status title.
+ * The text color of the RTK connection state title.
*/
var rtkConnectionStatusTitleTextColor: Int
@JvmName("getRTKConnectionStatusTitleTextColor")
@@ -156,7 +156,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * The background of the RTK connection status title.
+ * The background of the RTK connection state title.
*/
var rtkConnectionStatusTitleTextBackground: Drawable?
@JvmName("getRTKConnectionStatusTitleTextBackground")
@@ -167,7 +167,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * The text size of the RTK connection status.
+ * The text size of the RTK connection state.
*/
var rtkConnectionStatusTextSize: Float
@JvmName("getRTKConnectionStatusTextSize")
@@ -179,7 +179,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * The background of the RTK connection status.
+ * The background of the RTK connection state.
*/
var rtkConnectionStatusTextBackground: Drawable?
@JvmName("getRTKConnectionStatusTextBackground")
@@ -521,7 +521,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * The image displayed behind the satellite status table.
+ * The image displayed behind the satellite state table.
*/
var tableBackground: Drawable?
get() = tableBackgroundImageView.imageDrawable
@@ -530,7 +530,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
//endregion
- //region Constructors
+ //region Constructor
override fun initView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) {
inflate(context, R.layout.uxsdk_widget_rtk_satellite_status, this)
}
@@ -558,28 +558,28 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
override fun reactToModelChanges() {
addReaction(widgetModel.isRTKConnected
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { updateUIForIsRTKConnected(it) })
addReaction(widgetModel.rtkState
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { updateRTKStateUI(it) })
addReaction(widgetModel.model
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { updateModel(it) })
addReaction(widgetModel.rtkSignal
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { updateBaseStationTitle(it) })
- addReaction(widgetModel.rtkBaseStationStatus
- .observeOn(SchedulerProvider.getInstance().ui())
+ addReaction(widgetModel.rtkBaseStationState
+ .observeOn(SchedulerProvider.ui())
.subscribe { updateBaseStationStatus(it) })
- addReaction(widgetModel.rtkNetworkServiceStatus
- .observeOn(SchedulerProvider.getInstance().ui())
+ addReaction(widgetModel.rtkNetworkServiceState
+ .observeOn(SchedulerProvider.ui())
.subscribe { updateNetworkServiceStatus(it) })
addReaction(widgetModel.standardDeviation
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { updateStandardDeviation(it) })
addReaction(widgetModel.productConnection
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { widgetStateDataProcessor.onNext(ProductConnected(it)) })
}
@@ -613,14 +613,14 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
updateBeidouSatelliteDisplay(rtkState)
updateGLONASSSatelliteDisplay(rtkState)
updateGalileoSatelliteDisplay(rtkState)
- widgetStateDataProcessor.onNext(RTKStateUpdate(rtkState))
+ widgetStateDataProcessor.onNext(RTKStateUpdated(rtkState))
}
private fun updateUIForIsRTKConnected(isRTKConnected: Boolean) {
if (!isRTKConnected) {
initItemValues()
}
- widgetStateDataProcessor.onNext(RTKConnectedUpdate(isRTKConnected))
+ widgetStateDataProcessor.onNext(RTKConnectionUpdated(isRTKConnected))
}
private fun updateModel(model: Model) {
@@ -640,7 +640,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
beiDouAntenna2TextView.visibility = if (!isPhantom4RTK(model) && isBeiDouSatelliteInfoVisible) View.VISIBLE else View.GONE
glonassAntenna2TextView.visibility = if (!isPhantom4RTK(model) && isGLONASSSatelliteInfoVisible) View.VISIBLE else View.GONE
galileoAntenna2TextView.visibility = if (!isPhantom4RTK(model) && isGalileoSatelliteInfoVisible) View.VISIBLE else View.GONE
- widgetStateDataProcessor.onNext(ModelUpdate(model))
+ widgetStateDataProcessor.onNext(ModelUpdated(model))
}
private fun isPhantom4RTK(model: Model): Boolean {
@@ -718,7 +718,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
+ resources.getString(resourceString, String.format(Locale.US, "%s", standardDeviation.longitude)) + "\n"
+ resources.getString(resourceString, String.format(Locale.US, "%s", standardDeviation.altitude)))
standardDeviationTextView.text = standardDeviationStr
- widgetStateDataProcessor.onNext(StandardDeviationUpdate(standardDeviation))
+ widgetStateDataProcessor.onNext(StandardDeviationUpdated(standardDeviation))
}
private fun updateBeidouSatelliteDisplay(rtkState: RTKState) {
@@ -772,16 +772,16 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
}
- private fun updateNetworkServiceStatus(networkServiceStatus: RTKNetworkServiceStatus) {
+ private fun updateNetworkServiceStatus(networkServiceState: RTKNetworkServiceState) {
val rtkStatusStr: String
- var rtkStatusColor: Int = getRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.DISCONNECTED)
- when (networkServiceStatus.state) {
+ var rtkStatusColor: Int = getRTKConnectionStatusLabelTextColor(RTKBaseStationState.DISCONNECTED)
+ when (networkServiceState.state) {
NetworkServiceChannelState.TRANSMITTING ->
- if (networkServiceStatus.isRTKBeingUsed) {
- rtkStatusColor = getRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.CONNECTED_IN_USE)
+ if (networkServiceState.isRTKBeingUsed) {
+ rtkStatusColor = getRTKConnectionStatusLabelTextColor(RTKBaseStationState.CONNECTED_IN_USE)
rtkStatusStr = getString(R.string.uxsdk_rtk_state_connect)
} else {
- rtkStatusColor = getRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.CONNECTED_NOT_IN_USE)
+ rtkStatusColor = getRTKConnectionStatusLabelTextColor(RTKBaseStationState.CONNECTED_NOT_IN_USE)
rtkStatusStr = getString(R.string.uxsdk_rtk_state_connect_not_healthy)
}
NetworkServiceChannelState.SERVICE_SUSPENSION -> rtkStatusStr = getString(R.string.uxsdk_rtk_state_pause)
@@ -789,8 +789,8 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
NetworkServiceChannelState.NETWORK_NOT_REACHABLE -> rtkStatusStr = getString(R.string.uxsdk_rtk_state_network_err)
NetworkServiceChannelState.LOGIN_FAILURE -> rtkStatusStr = getString(R.string.uxsdk_rtk_state_auth_failed)
NetworkServiceChannelState.UNKNOWN -> rtkStatusStr =
- if (networkServiceStatus.isNetworkServiceOpen) {
- resources.getString(R.string.uxsdk_rtk_nrtk_state_inner_error, getRTKTypeName(networkServiceStatus.rtkSignal))
+ if (networkServiceState.isNetworkServiceOpen) {
+ resources.getString(R.string.uxsdk_rtk_nrtk_state_inner_error, getRTKTypeName(networkServiceState.rtkSignal))
} else {
getString(R.string.uxsdk_rtk_nrtk_state_unknown)
}
@@ -802,32 +802,32 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
rtkStatusTextView.text = rtkStatusStr
rtkStatusTextView.setTextColor(rtkStatusColor)
- widgetStateDataProcessor.onNext(RTKNetworkServiceStatusUpdate(networkServiceStatus))
+ widgetStateDataProcessor.onNext(RTKNetworkServiceStateUpdated(networkServiceState))
}
- private fun updateBaseStationStatus(connectionState: RTKBaseStationStatus) {
+ private fun updateBaseStationStatus(connectionState: RTKBaseStationState) {
when (connectionState) {
- RTKBaseStationStatus.CONNECTED_IN_USE -> {
+ RTKBaseStationState.CONNECTED_IN_USE -> {
rtkStatusTextView.setText(R.string.uxsdk_rtk_state_connect)
- rtkStatusTextView.setTextColor(getRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.CONNECTED_IN_USE))
+ rtkStatusTextView.setTextColor(getRTKConnectionStatusLabelTextColor(RTKBaseStationState.CONNECTED_IN_USE))
}
- RTKBaseStationStatus.CONNECTED_NOT_IN_USE -> {
+ RTKBaseStationState.CONNECTED_NOT_IN_USE -> {
rtkStatusTextView.setText(R.string.uxsdk_rtk_state_connect_not_healthy)
- rtkStatusTextView.setTextColor(getRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.CONNECTED_NOT_IN_USE))
+ rtkStatusTextView.setTextColor(getRTKConnectionStatusLabelTextColor(RTKBaseStationState.CONNECTED_NOT_IN_USE))
}
- RTKBaseStationStatus.DISCONNECTED -> {
+ RTKBaseStationState.DISCONNECTED -> {
rtkStatusTextView.setText(R.string.uxsdk_rtk_state_disconnect)
- rtkStatusTextView.textColor = getRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.DISCONNECTED)
+ rtkStatusTextView.textColor = getRTKConnectionStatusLabelTextColor(RTKBaseStationState.DISCONNECTED)
}
}
- widgetStateDataProcessor.onNext(RTKBaseStationStatusUpdate(connectionState))
+ widgetStateDataProcessor.onNext(RTKBaseStationStateUpdated(connectionState))
}
private fun updateBaseStationTitle(rtkSignal: RTKSignal) {
val name = getRTKTypeName(rtkSignal)
baseStationCoordinatesTitleTextView.text = name
rtkStatusTitleTextView.text = resources.getString(R.string.uxsdk_rtk_status_desc, name)
- widgetStateDataProcessor.onNext(RTKSignalUpdate(rtkSignal))
+ widgetStateDataProcessor.onNext(RTKSignalUpdated(rtkSignal))
}
private fun getRTKTypeName(rtkSignal: RTKSignal): String {
@@ -865,7 +865,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
if (!isInEditMode) {
addDisposable(widgetModel.rtkState
.firstOrError()
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(Consumer { updateOrientationStatus(it.isHeadingValid, it.headingSolution) },
logErrorConsumer(TAG, "updateOrientation")))
}
@@ -875,7 +875,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
if (!isInEditMode) {
addDisposable(widgetModel.model
.firstOrError()
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(Consumer { updateModel(it) },
logErrorConsumer(TAG, "updateModel")))
}
@@ -889,7 +889,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * Set the text appearance of the RTK connection status title.
+ * Set the text appearance of the RTK connection state title.
*
* @param textAppearance Style resource for text appearance
*/
@@ -898,7 +898,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * Set the text appearance of the RTK connection status.
+ * Set the text appearance of the RTK connection state.
*
* @param textAppearance Style resource for text appearance
*/
@@ -907,27 +907,27 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * Set the text color of the RTK connection status when the RTKBaseStationStatus is the given
+ * Set the text color of the RTK connection state when the RTKBaseStationState is the given
* value.
*
- * @param status The status for which to set the text color.
+ * @param state The state for which to set the text color.
* @param color The color of the text
*/
- fun setRTKConnectionStatusLabelTextColor(status: RTKBaseStationStatus, @ColorInt color: Int) {
- connectionStatusTextColorMap[status] = color
- widgetModel.updateRTKConnectionStatus()
+ fun setRTKConnectionStatusLabelTextColor(state: RTKBaseStationState, @ColorInt color: Int) {
+ connectionStateTextColorMap[state] = color
+ widgetModel.updateRTKConnectionState()
}
/**
- * Get the text color of the RTK connection status when the RTKBaseStationStatus is the given
+ * Get the text color of the RTK connection state when the RTKBaseStationState is the given
* value.
*
- * @param status The status for which to get the text color.
+ * @param state The state for which to get the text color.
* @return The color of the text
*/
@ColorInt
- fun getRTKConnectionStatusLabelTextColor(status: RTKBaseStationStatus): Int {
- return (connectionStatusTextColorMap[status]?.let { it }
+ fun getRTKConnectionStatusLabelTextColor(state: RTKBaseStationState): Int {
+ return (connectionStateTextColorMap[state]?.let { it }
?: getColor(R.color.uxsdk_rtk_status_disconnected))
}
@@ -994,7 +994,7 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
}
/**
- * Set the image displayed behind the satellite status table.
+ * Set the image displayed behind the satellite state table.
*
* @param resourceId Integer ID of the drawable resource
*/
@@ -1025,13 +1025,13 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
rtkConnectionStatusTextSize = DisplayUtil.pxToSp(context, it)
}
typedArray.getColorAndUse(R.styleable.RTKSatelliteStatusWidget_uxsdk_rtkConnectionStatusConnectedInUseTextColor) {
- setRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.CONNECTED_IN_USE, it)
+ setRTKConnectionStatusLabelTextColor(RTKBaseStationState.CONNECTED_IN_USE, it)
}
typedArray.getColorAndUse(R.styleable.RTKSatelliteStatusWidget_uxsdk_rtkConnectionStatusConnectedNotInUseTextColor) {
- setRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.CONNECTED_NOT_IN_USE, it)
+ setRTKConnectionStatusLabelTextColor(RTKBaseStationState.CONNECTED_NOT_IN_USE, it)
}
typedArray.getColorAndUse(R.styleable.RTKSatelliteStatusWidget_uxsdk_rtkConnectionStatusDisconnectedTextColor) {
- setRTKConnectionStatusLabelTextColor(RTKBaseStationStatus.DISCONNECTED, it)
+ setRTKConnectionStatusLabelTextColor(RTKBaseStationState.DISCONNECTED, it)
}
typedArray.getDrawableAndUse(R.styleable.RTKSatelliteStatusWidget_uxsdk_rtkConnectionStatusBackgroundDrawable) {
rtkConnectionStatusTextBackground = it
@@ -1083,56 +1083,58 @@ open class RTKSatelliteStatusWidget @JvmOverloads constructor(
//endregion
//region Hooks
+
/**
- * Get the [RTKSatelliteStatusWidgetState] updates
+ * Get the [ModelState] updates
*/
- override fun getWidgetStateUpdate(): Flowable {
+ @SuppressWarnings
+ override fun getWidgetStateUpdate(): Flowable {
return super.getWidgetStateUpdate()
}
/**
* Class defines the widget state updates
*/
- sealed class RTKSatelliteStatusWidgetState {
+ sealed class ModelState {
/**
* Product connection update
*/
- data class ProductConnected(val isConnected: Boolean) : RTKSatelliteStatusWidgetState()
+ data class ProductConnected(val isConnected: Boolean) : ModelState()
/**
* RTK connection update
*/
- data class RTKConnectedUpdate(val isConnected: Boolean) : RTKSatelliteStatusWidgetState()
+ data class RTKConnectionUpdated(val isConnected: Boolean) : ModelState()
/**
* RTK state update
*/
- data class RTKStateUpdate(val rtkState: RTKState) : RTKSatelliteStatusWidgetState()
+ data class RTKStateUpdated(val rtkState: RTKState) : ModelState()
/**
* Model update
*/
- data class ModelUpdate(val model: Model) : RTKSatelliteStatusWidgetState()
+ data class ModelUpdated(val model: Model) : ModelState()
/**
* RTK signal update
*/
- data class RTKSignalUpdate(val source: RTKSignal) : RTKSatelliteStatusWidgetState()
+ data class RTKSignalUpdated(val source: RTKSignal) : ModelState()
/**
* Standard deviation update
*/
- data class StandardDeviationUpdate(val standardDeviation: StandardDeviation) : RTKSatelliteStatusWidgetState()
+ data class StandardDeviationUpdated(val standardDeviation: StandardDeviation) : ModelState()
/**
- * RTK base station status update
+ * RTK base station state update
*/
- data class RTKBaseStationStatusUpdate(val status: RTKBaseStationStatus) : RTKSatelliteStatusWidgetState()
+ data class RTKBaseStationStateUpdated(val state: RTKBaseStationState) : ModelState()
/**
- * RTK network service status update
+ * RTK network service state update
*/
- data class RTKNetworkServiceStatusUpdate(val status: RTKNetworkServiceStatus) : RTKSatelliteStatusWidgetState()
+ data class RTKNetworkServiceStateUpdated(val state: RTKNetworkServiceState) : ModelState()
}
//endregion
}
\ No newline at end of file
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKSatelliteStatusWidgetModel.kt b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKSatelliteStatusWidgetModel.kt
similarity index 81%
rename from android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKSatelliteStatusWidgetModel.kt
rename to android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKSatelliteStatusWidgetModel.kt
index 058575ef..7108c488 100644
--- a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKSatelliteStatusWidgetModel.kt
+++ b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKSatelliteStatusWidgetModel.kt
@@ -18,10 +18,10 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
- *
+ *
*/
-package dji.ux.beta.hardwareaccessory.widget.rtk
+package dji.ux.beta.accessory.widget.rtk
import dji.common.flightcontroller.RTKState
import dji.common.flightcontroller.rtk.NetworkServiceChannelState
@@ -35,11 +35,11 @@ import dji.sdk.network.RTKNetworkServiceProvider
import dji.thirdparty.io.reactivex.Flowable
import dji.thirdparty.io.reactivex.functions.BiFunction
import dji.ux.beta.core.base.DJISDKModel
-import dji.ux.beta.core.base.GlobalPreferencesInterface
import dji.ux.beta.core.base.WidgetModel
-import dji.ux.beta.core.base.uxsdkkeys.GlobalPreferenceKeys
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore
-import dji.ux.beta.core.base.uxsdkkeys.UXKeys
+import dji.ux.beta.core.communication.GlobalPreferenceKeys
+import dji.ux.beta.core.communication.GlobalPreferencesInterface
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore
+import dji.ux.beta.core.communication.UXKeys
import dji.ux.beta.core.util.DataProcessor
import dji.ux.beta.core.util.UnitConversionUtil
@@ -62,9 +62,9 @@ class RTKSatelliteStatusWidgetModel(djiSdkModel: DJISDKModel,
private val unitTypeProcessor: DataProcessor = DataProcessor.create(UnitConversionUtil.UnitType.METRIC)
private val networkServiceStateProcessor: DataProcessor = DataProcessor.create(NetworkServiceChannelState.UNKNOWN)
- private val rtkBaseStationStatusProcessor: DataProcessor = DataProcessor.create(RTKBaseStationStatus.DISCONNECTED)
- private val rtkNetworkServiceStatusProcessor: DataProcessor = DataProcessor.create(
- RTKNetworkServiceStatus(NetworkServiceChannelState.UNKNOWN,
+ private val rtkBaseStationStateProcessor: DataProcessor = DataProcessor.create(RTKBaseStationState.DISCONNECTED)
+ private val rtkNetworkServiceStateProcessor: DataProcessor = DataProcessor.create(
+ RTKNetworkServiceState(NetworkServiceChannelState.UNKNOWN,
isRTKBeingUsed = false,
isNetworkServiceOpen = false,
rtkSignal = RTKSignal.BASE_STATION))
@@ -111,27 +111,27 @@ class RTKSatelliteStatusWidgetModel(djiSdkModel: DJISDKModel,
get() = standardDeviationProcessor.toFlowable()
/**
- * Get the status of the RTK base station.
+ * Get the state of the RTK base station.
*/
- @get:JvmName("getRTKBaseStationStatus")
- val rtkBaseStationStatus: Flowable
- get() = rtkBaseStationStatusProcessor.toFlowable()
+ @get:JvmName("getRTKBaseStationState")
+ val rtkBaseStationState: Flowable
+ get() = rtkBaseStationStateProcessor.toFlowable()
/**
- * Get the status of the network service.
+ * Get the state of the network service.
*/
- @get:JvmName("getRTKNetworkServiceStatus")
- val rtkNetworkServiceStatus: Flowable
- get() = rtkNetworkServiceStatusProcessor.toFlowable()
+ @get:JvmName("getRTKNetworkServiceState")
+ val rtkNetworkServiceState: Flowable
+ get() = rtkNetworkServiceStateProcessor.toFlowable()
/**
- * Sends the latest network service status or base station status to the corresponding flowable.
+ * Sends the latest network service state or base station state to the corresponding flowable.
*/
- fun updateRTKConnectionStatus() {
+ fun updateRTKConnectionState() {
if (isNetworkServiceOpen(referenceStationSourceProcessor.value)) {
- updateNetworkServiceStatus()
+ updateNetworkServiceState()
} else {
- updateBaseStationStatus()
+ updateBaseStationState()
}
}
//endregion
@@ -182,7 +182,7 @@ class RTKSatelliteStatusWidgetModel(djiSdkModel: DJISDKModel,
}
override fun updateStates() {
- updateRTKConnectionStatus()
+ updateRTKConnectionState()
var stdLatitude = 0f
var stdLongitude = 0f
@@ -209,29 +209,29 @@ class RTKSatelliteStatusWidgetModel(djiSdkModel: DJISDKModel,
override fun onNetworkServiceStateUpdate(networkServiceState: NetworkServiceState?) {
if (networkServiceState != null && networkServiceStateProcessor.value != networkServiceState.channelState) {
networkServiceStateProcessor.onNext(networkServiceState.channelState)
- updateNetworkServiceStatus()
+ updateNetworkServiceState()
}
}
//endregion
//region Helper methods
- private fun updateNetworkServiceStatus() {
- rtkNetworkServiceStatusProcessor.onNext(RTKNetworkServiceStatus(networkServiceStateProcessor.value,
+ private fun updateNetworkServiceState() {
+ rtkNetworkServiceStateProcessor.onNext(RTKNetworkServiceState(networkServiceStateProcessor.value,
rtkStateProcessor.value.isRTKBeingUsed,
isNetworkServiceOpen(referenceStationSourceProcessor.value),
rtkSignalProcessor.value))
}
- private fun updateBaseStationStatus() {
+ private fun updateBaseStationState() {
if (isRTKConnectedProcessor.value && productConnectionProcessor.value) {
if (rtkStateProcessor.value.isRTKBeingUsed) {
- rtkBaseStationStatusProcessor.onNext(RTKBaseStationStatus.CONNECTED_IN_USE)
+ rtkBaseStationStateProcessor.onNext(RTKBaseStationState.CONNECTED_IN_USE)
} else {
- rtkBaseStationStatusProcessor.onNext(RTKBaseStationStatus.CONNECTED_NOT_IN_USE)
+ rtkBaseStationStateProcessor.onNext(RTKBaseStationState.CONNECTED_NOT_IN_USE)
}
} else {
- rtkBaseStationStatusProcessor.onNext(RTKBaseStationStatus.DISCONNECTED)
+ rtkBaseStationStateProcessor.onNext(RTKBaseStationState.DISCONNECTED)
}
}
@@ -245,9 +245,9 @@ class RTKSatelliteStatusWidgetModel(djiSdkModel: DJISDKModel,
//region Classes
/**
- * The status of the RTK base station
+ * The state of the RTK base station
*/
- enum class RTKBaseStationStatus {
+ enum class RTKBaseStationState {
/**
* The RTK base station is connected and in use.
*/
@@ -265,12 +265,12 @@ class RTKSatelliteStatusWidgetModel(djiSdkModel: DJISDKModel,
}
/**
- * The status of the network service.
+ * The state of the network service.
*/
- data class RTKNetworkServiceStatus(val state: NetworkServiceChannelState,
- val isRTKBeingUsed: Boolean,
- val isNetworkServiceOpen: Boolean,
- @get:JvmName("getRTKSignal")
+ data class RTKNetworkServiceState(val state: NetworkServiceChannelState,
+ val isRTKBeingUsed: Boolean,
+ val isNetworkServiceOpen: Boolean,
+ @get:JvmName("getRTKSignal")
val rtkSignal: RTKSignal)
/**
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKWidget.kt b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKWidget.kt
similarity index 86%
rename from android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKWidget.kt
rename to android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKWidget.kt
index 29463492..38da7b70 100644
--- a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKWidget.kt
+++ b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKWidget.kt
@@ -18,10 +18,10 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
- *
+ *
*/
-package dji.ux.beta.hardwareaccessory.widget.rtk
+package dji.ux.beta.accessory.widget.rtk
import android.annotation.SuppressLint
import android.content.Context
@@ -37,17 +37,19 @@ import androidx.core.content.res.use
import dji.thirdparty.io.reactivex.Flowable
import dji.thirdparty.io.reactivex.functions.Consumer
import dji.thirdparty.io.reactivex.processors.PublishProcessor
-import dji.ux.beta.core.base.ConstraintLayoutWidget
+import dji.ux.beta.accessory.R
+import dji.ux.beta.accessory.widget.rtk.RTKWidget.ModelState
+import dji.ux.beta.accessory.widget.rtk.RTKWidget.ModelState.ProductConnected
+import dji.ux.beta.accessory.widget.rtk.RTKWidget.ModelState.RTKEnabledUpdated
+import dji.ux.beta.accessory.widget.rtk.RTKWidget.UIState.DialogActionDismissed
+import dji.ux.beta.accessory.widget.rtk.RTKWidget.UIState.VisibilityUpdated
import dji.ux.beta.core.base.DJISDKModel
-import dji.ux.beta.core.base.OnStateChangeCallback
import dji.ux.beta.core.base.SchedulerProvider
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore
+import dji.ux.beta.core.base.widget.ConstraintLayoutWidget
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore
+import dji.ux.beta.core.communication.OnStateChangeCallback
import dji.ux.beta.core.extension.*
import dji.ux.beta.core.util.DisplayUtil
-import dji.ux.beta.hardwareaccessory.R
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKWidget.RTKWidgetState
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKWidget.RTKWidgetState.*
-import dji.ux.beta.hardwareaccessory.widget.rtk.RTKWidget.RTKWidgetUIState.DialogOKTap
private const val TAG = "RTKWidget"
@@ -58,19 +60,18 @@ open class RTKWidget @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : ConstraintLayoutWidget(context, attrs, defStyleAttr), View.OnClickListener,
+) : ConstraintLayoutWidget(context, attrs, defStyleAttr), View.OnClickListener,
OnStateChangeCallback {
//region Fields
private val dialogOkTextView: TextView = findViewById(R.id.textview_ok)
private val rtkDescriptionTextView: TextView = findViewById(R.id.textview_rtk_description)
private val rtkDialogSeparator: View = findViewById(R.id.rtk_dialog_separator)
- private val uiUpdateStateProcessor: PublishProcessor = PublishProcessor.create()
+ private val uiUpdateStateProcessor: PublishProcessor = PublishProcessor.create()
private val widgetModel by lazy {
RTKWidgetModel(
DJISDKModel.getInstance(),
- ObservableInMemoryKeyedStore.getInstance(),
- SchedulerProvider.getInstance())
+ ObservableInMemoryKeyedStore.getInstance())
}
/**
@@ -211,7 +212,7 @@ open class RTKWidget @JvmOverloads constructor(
override fun onClick(v: View) {
if (v.id == R.id.textview_ok) {
visibility = View.GONE
- uiUpdateStateProcessor.onNext(DialogOKTap)
+ uiUpdateStateProcessor.onNext(DialogActionDismissed)
}
}
@@ -221,10 +222,10 @@ open class RTKWidget @JvmOverloads constructor(
override fun reactToModelChanges() {
addReaction(widgetModel.rtkEnabled
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { rtkEnabled: Boolean -> updateUIForRTKEnabled(rtkEnabled) })
addReaction(widgetModel.productConnection
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe { widgetStateDataProcessor.onNext(ProductConnected(it)) })
}
//endregion
@@ -238,7 +239,7 @@ open class RTKWidget @JvmOverloads constructor(
rtkSatelliteStatusWidget.visibility = View.GONE
rtkDescriptionTextView.visibility = View.VISIBLE
}
- widgetStateDataProcessor.onNext(RTKEnabledUpdate(rtkEnabled))
+ widgetStateDataProcessor.onNext(RTKEnabledUpdated(rtkEnabled))
}
//endregion
@@ -246,7 +247,7 @@ open class RTKWidget @JvmOverloads constructor(
private fun toggleVisibility() {
addDisposable(widgetModel.rtkSupported
.firstOrError()
- .observeOn(SchedulerProvider.getInstance().ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(Consumer { rtkSupported: Boolean ->
if (rtkSupported) {
visibility = if (visibility == View.VISIBLE) {
@@ -254,7 +255,7 @@ open class RTKWidget @JvmOverloads constructor(
} else {
View.VISIBLE
}
- widgetStateDataProcessor.onNext(VisibilityUpdate(visibility == View.VISIBLE))
+ uiUpdateStateProcessor.onNext(VisibilityUpdated(visibility == View.VISIBLE))
}
}, logErrorConsumer(TAG, "getRTKSupported: ")))
}
@@ -338,47 +339,49 @@ open class RTKWidget @JvmOverloads constructor(
//region Hooks
/**
- * Get the [RTKWidgetUIState] updates
+ * Get the [UIState] updates
+ */
+ fun getUIStateUpdates(): Flowable {
+ return uiUpdateStateProcessor.onBackpressureBuffer()
+ }
+
+ /**
+ * Get the [ModelState] updates
*/
- fun getUIStateUpdates(): Flowable {
- return uiUpdateStateProcessor
+ @SuppressWarnings
+ override fun getWidgetStateUpdate(): Flowable {
+ return super.getWidgetStateUpdate()
}
/**
* Widget UI update State
*/
- sealed class RTKWidgetUIState {
+ sealed class UIState {
/**
* OK button tapped
*/
- object DialogOKTap : RTKWidgetUIState()
- }
+ object DialogActionDismissed : UIState()
- /**
- * Get the [RTKWidgetState] updates
- */
- override fun getWidgetStateUpdate(): Flowable {
- return super.getWidgetStateUpdate()
+ /**
+ * Widget visibility update
+ */
+ data class VisibilityUpdated(val isVisible: Boolean) : UIState()
}
/**
* Class defines the widget state updates
*/
- sealed class RTKWidgetState {
+ sealed class ModelState {
/**
* Product connection update
*/
- data class ProductConnected(val isConnected: Boolean) : RTKWidgetState()
+ data class ProductConnected(val isConnected: Boolean) : ModelState()
/**
* RTK enabled update
*/
- data class RTKEnabledUpdate(val isRTKEnabled: Boolean) : RTKWidgetState()
+ data class RTKEnabledUpdated(val isRTKEnabled: Boolean) : ModelState()
- /**
- * Widget visibility update
- */
- data class VisibilityUpdate(val isVisible: Boolean) : RTKWidgetState()
}
//endregion
}
\ No newline at end of file
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKWidgetModel.kt b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKWidgetModel.kt
similarity index 89%
rename from android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKWidgetModel.kt
rename to android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKWidgetModel.kt
index c4742578..80a72ccc 100644
--- a/android-uxsdk-beta-hardwareaccessory/src/main/java/dji/ux/beta/hardwareaccessory/widget/rtk/RTKWidgetModel.kt
+++ b/android-uxsdk-beta-accessory/src/main/java/dji/ux/beta/accessory/widget/rtk/RTKWidgetModel.kt
@@ -18,19 +18,19 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
- *
+ *
*/
-package dji.ux.beta.hardwareaccessory.widget.rtk
+package dji.ux.beta.accessory.widget.rtk
import dji.keysdk.DJIKey
import dji.keysdk.FlightControllerKey
import dji.thirdparty.io.reactivex.Flowable
import dji.thirdparty.io.reactivex.functions.Consumer
import dji.ux.beta.core.base.DJISDKModel
-import dji.ux.beta.core.base.SchedulerProviderInterface
+import dji.ux.beta.core.base.SchedulerProvider
import dji.ux.beta.core.base.WidgetModel
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore
import dji.ux.beta.core.util.DataProcessor
private const val TAG = "RTKWidgetModel"
@@ -40,8 +40,7 @@ private const val TAG = "RTKWidgetModel"
* the underlying logic and communication
*/
class RTKWidgetModel(djiSdkModel: DJISDKModel,
- uxKeyManager: ObservableInMemoryKeyedStore,
- private val schedulerProvider: SchedulerProviderInterface
+ uxKeyManager: ObservableInMemoryKeyedStore
) : WidgetModel(djiSdkModel, uxKeyManager) {
//region Fields
@@ -75,7 +74,7 @@ class RTKWidgetModel(djiSdkModel: DJISDKModel,
val isRTKConnectedKey: DJIKey = FlightControllerKey.createRTKKey(FlightControllerKey.IS_RTK_CONNECTED)
bindDataProcessor(isRTKConnectedKey, isRTKConnectedProcessor) {
addDisposable(djiSdkModel.getValue(rtkEnabledKey)
- .observeOn(schedulerProvider.io())
+ .observeOn(SchedulerProvider.io())
.subscribe(Consumer { }, logErrorConsumer(TAG, "isRTKEnabled: ")))
}
}
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/res/drawable/uxsdk_ic_rtk_status.xml b/android-uxsdk-beta-accessory/src/main/res/drawable/uxsdk_ic_rtk_status.xml
similarity index 100%
rename from android-uxsdk-beta-hardwareaccessory/src/main/res/drawable/uxsdk_ic_rtk_status.xml
rename to android-uxsdk-beta-accessory/src/main/res/drawable/uxsdk_ic_rtk_status.xml
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/res/drawable/uxsdk_rtk_status_bg.xml b/android-uxsdk-beta-accessory/src/main/res/drawable/uxsdk_rtk_status_bg.xml
similarity index 100%
rename from android-uxsdk-beta-hardwareaccessory/src/main/res/drawable/uxsdk_rtk_status_bg.xml
rename to android-uxsdk-beta-accessory/src/main/res/drawable/uxsdk_rtk_status_bg.xml
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/res/layout/uxsdk_widget_rtk.xml b/android-uxsdk-beta-accessory/src/main/res/layout/uxsdk_widget_rtk.xml
similarity index 95%
rename from android-uxsdk-beta-hardwareaccessory/src/main/res/layout/uxsdk_widget_rtk.xml
rename to android-uxsdk-beta-accessory/src/main/res/layout/uxsdk_widget_rtk.xml
index b9f7f23e..bfe42389 100644
--- a/android-uxsdk-beta-hardwareaccessory/src/main/res/layout/uxsdk_widget_rtk.xml
+++ b/android-uxsdk-beta-accessory/src/main/res/layout/uxsdk_widget_rtk.xml
@@ -27,7 +27,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:parentTag="dji.ux.beta.hardwareaccessory.widget.rtk.RTKWidget">
+ tools:parentTag="dji.ux.beta.accessory.widget.rtk.RTKWidget">
-
-
+ tools:parentTag="dji.ux.beta.accessory.widget.rtk.RTKEnabledWidget">
+ tools:parentTag="dji.ux.beta.accessory.widget.rtk.RTKSatelliteStatusWidget">
+
Antenna 1
Antenna 2
+ Base Station
+ Satellites#
GPS:
BeiDou:
GLONASS:
@@ -56,14 +59,15 @@
RTK connected. RTK data in use
RTK connected. RTK data not in use
Not connected
- Suspending account...
+ Suspending account…
Time verification failed
Network unavailable
Verification failed
+ Unknown error
%sInternal error
Unknown error
Account error
- Connecting to server...
+ Connecting to server…
Request rejected by server
Connecting to server failed
Network RTK
@@ -71,4 +75,5 @@
Base Station
Custom Network RTK
%1$s Status:
+
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/res/values/strings_dimension_ratios.xml b/android-uxsdk-beta-accessory/src/main/res/values/strings_dimension_ratios.xml
similarity index 100%
rename from android-uxsdk-beta-hardwareaccessory/src/main/res/values/strings_dimension_ratios.xml
rename to android-uxsdk-beta-accessory/src/main/res/values/strings_dimension_ratios.xml
diff --git a/android-uxsdk-beta-hardwareaccessory/src/main/res/values/styles.xml b/android-uxsdk-beta-accessory/src/main/res/values/styles.xml
similarity index 100%
rename from android-uxsdk-beta-hardwareaccessory/src/main/res/values/styles.xml
rename to android-uxsdk-beta-accessory/src/main/res/values/styles.xml
diff --git a/android-uxsdk-beta-cameracore/build.gradle b/android-uxsdk-beta-cameracore/build.gradle
index 8b1e9dd9..6befbc9c 100644
--- a/android-uxsdk-beta-cameracore/build.gradle
+++ b/android-uxsdk-beta-cameracore/build.gradle
@@ -69,7 +69,7 @@ android {
dependencies {
api project(path: ':android-uxsdk-beta-core')
- implementation ('com.dji:dji-sdk:4.13.1', {
+ implementation ('com.dji:dji-sdk:4.14-trial1', {
/**
* Comment the "library-anti-distortion" if your app needs Anti Distortion for Mavic 2 Pro
* and Mavic 2 Zoom.
@@ -81,7 +81,7 @@ dependencies {
exclude module: 'library-anti-distortion'
exclude module: 'fly-safe-database'
})
- compileOnly ('com.dji:dji-sdk-provided:4.13.1')
+ compileOnly ('com.dji:dji-sdk-provided:4.14-trial1')
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/ui/ProgressRingView.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/ui/ProgressRingView.java
index b68523b2..7c05e3f9 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/ui/ProgressRingView.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/ui/ProgressRingView.java
@@ -39,6 +39,10 @@
import dji.ux.beta.cameracore.R;
+/**
+ * Ring progress bar.
+ * The view shows circular animation to indicate progress.
+ */
public class ProgressRingView extends View {
private RectF boundaries;
@@ -125,6 +129,11 @@ protected void onDraw(Canvas canvas) {
canvas.drawArc(boundaries, 0, 360, false, paint);
}
+ /**
+ * Set the color of the progress ring.
+ *
+ * @param color integer value
+ */
public void setRingColor(@ColorInt int color) {
ringColor = color;
paint.setColor(color);
@@ -132,10 +141,22 @@ public void setRingColor(@ColorInt int color) {
invalidate();
}
+ /**
+ * Check if the ring is currently animating.
+ *
+ * @return boolean value
+ */
public boolean isIndeterminate() {
return indeterminate;
}
+ /**
+ * Start/Stop the ring animation.
+ *
+ * @param indeterminate boolean value
+ * true - to start animation
+ * false - to stop animation
+ */
public void setIndeterminate(boolean indeterminate) {
if (indeterminate == this.indeterminate) return;
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/util/CameraActionSound.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/util/CameraActionSound.java
index b5a253f4..0b8ce6d2 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/util/CameraActionSound.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/util/CameraActionSound.java
@@ -29,7 +29,6 @@
import dji.thirdparty.io.reactivex.disposables.Disposable;
import dji.ux.beta.cameracore.R;
-import dji.ux.beta.core.base.SchedulerProvider;
import dji.ux.beta.core.util.AudioUtil;
/**
@@ -48,27 +47,27 @@ private int shutterCountSound(ShutterSoundCount value) {
int soundId;
switch (value) {
case ONE:
- soundId = R.raw.shutter_1;
+ soundId = R.raw.uxsdk_shutter_1;
break;
case THREE:
- soundId = R.raw.shutter_3;
+ soundId = R.raw.uxsdk_shutter_3;
break;
case FIVE:
- soundId = R.raw.shutter_5;
+ soundId = R.raw.uxsdk_shutter_5;
break;
case SEVEN:
- soundId = R.raw.shutter_7;
+ soundId = R.raw.uxsdk_shutter_7;
break;
case TEN:
- soundId = R.raw.shutter_10;
+ soundId = R.raw.uxsdk_shutter_10;
break;
case FOURTEEN:
- soundId = R.raw.shutter_14;
+ soundId = R.raw.uxsdk_shutter_14;
break;
case UNKNOWN:
default:
- soundId = R.raw.shutter_3;
+ soundId = R.raw.uxsdk_shutter_3;
break;
}
return soundId;
@@ -86,35 +85,32 @@ public void setShutterCount(@NonNull ShutterSoundCount count) {
/**
* Play sound for Capture Photo
*
- * @param schedulerProvider instance of scheduler
* @return Disposable
*/
@NonNull
- public Disposable playCapturePhoto(@NonNull SchedulerProvider schedulerProvider) {
- return AudioUtil.playSoundInBackground(schedulerProvider, context, shutterCountSound(shutterCount));
+ public Disposable playCapturePhoto() {
+ return AudioUtil.playSoundInBackground(context, shutterCountSound(shutterCount));
}
/**
* Play sound for start record video
*
- * @param schedulerProvider instance of scheduler
* @return Disposable
*/
@NonNull
- public Disposable playStartRecordVideo(@NonNull SchedulerProvider schedulerProvider) {
- return AudioUtil.playSoundInBackground(schedulerProvider, context, R.raw.video_voice);
+ public Disposable playStartRecordVideo() {
+ return AudioUtil.playSoundInBackground(context, R.raw.uxsdk_video_voice);
}
/**
* Play sound for stop record video
*
- * @param schedulerProvider instance of scheduler
* @return Disposable
*/
@NonNull
- public Disposable playStopRecordVideo(@NonNull SchedulerProvider schedulerProvider) {
- return AudioUtil.playSoundInBackground(schedulerProvider, context, R.raw.end_video_record);
+ public Disposable playStopRecordVideo() {
+ return AudioUtil.playSoundInBackground(context, R.raw.uxsdk_end_video_record);
}
/**
@@ -164,9 +160,9 @@ public enum ShutterSoundCount {
*/
public static ShutterSoundCount find(int value) {
ShutterSoundCount result = UNKNOWN;
- for (int i = 0; i < values().length; i++) {
- if (values()[i]._equals(value)) {
- result = values()[i];
+ for (int i = 0; i < getValues().length; i++) {
+ if (getValues()[i]._equals(value)) {
+ result = getValues()[i];
break;
}
}
@@ -192,6 +188,15 @@ private boolean _equals(int b) {
return value == b;
}
+ private static ShutterSoundCount[] values;
+
+ public static ShutterSoundCount[] getValues() {
+ if (values == null) {
+ values = values();
+ }
+ return values;
+ }
+
}
}
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/autoexposurelock/AutoExposureLockWidget.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/autoexposurelock/AutoExposureLockWidget.java
index 45b78b4f..eeb41bc5 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/autoexposurelock/AutoExposureLockWidget.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/autoexposurelock/AutoExposureLockWidget.java
@@ -39,12 +39,12 @@
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
-import dji.thirdparty.io.reactivex.android.schedulers.AndroidSchedulers;
+import dji.common.camera.SettingsDefinitions;
import dji.ux.beta.cameracore.R;
-import dji.ux.beta.core.base.ConstraintLayoutWidget;
import dji.ux.beta.core.base.DJISDKModel;
import dji.ux.beta.core.base.SchedulerProvider;
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.base.widget.ConstraintLayoutWidget;
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore;
import dji.ux.beta.core.util.SettingDefinitions.CameraIndex;
import dji.ux.beta.core.util.ViewUtil;
@@ -63,12 +63,11 @@ public class AutoExposureLockWidget extends ConstraintLayoutWidget implements Vi
private AutoExposureLockWidgetModel widgetModel;
private Drawable autoExposureLockDrawable;
private Drawable autoExposureUnlockDrawable;
- private SchedulerProvider schedulerProvider;
private ColorStateList lockDrawableTint;
private ColorStateList unlockDrawableTint;
//endregion
- //region lifecycle
+ //region Lifecycle
public AutoExposureLockWidget(@NonNull Context context) {
super(context);
}
@@ -87,14 +86,12 @@ protected void initView(@NonNull Context context, @Nullable AttributeSet attrs,
if (getBackground() == null) {
setBackgroundResource(R.drawable.uxsdk_background_black_rectangle);
}
- schedulerProvider = SchedulerProvider.getInstance();
foregroundImageView = findViewById(R.id.auto_exposure_lock_widget_foreground_image_view);
titleTextView = findViewById(R.id.auto_exposure_lock_widget_title_text_view);
if (!isInEditMode()) {
widgetModel =
new AutoExposureLockWidgetModel(DJISDKModel.getInstance(),
- ObservableInMemoryKeyedStore.getInstance(),
- schedulerProvider);
+ ObservableInMemoryKeyedStore.getInstance());
}
initDefaults();
if (attrs != null) {
@@ -106,7 +103,7 @@ protected void initView(@NonNull Context context, @Nullable AttributeSet attrs,
@Override
protected void reactToModelChanges() {
- addReaction(widgetModel.isAutoExposureLockOn().observeOn(AndroidSchedulers.mainThread()).subscribe(this::onAELockChange));
+ addReaction(widgetModel.isAutoExposureLockOn().observeOn(SchedulerProvider.ui()).subscribe(this::onAELockChange));
}
@Override
@@ -149,7 +146,7 @@ private void onAELockChange(boolean isLocked) {
private void setAutoExposureLock() {
addDisposable(widgetModel.toggleAutoExposureLock()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(() -> {
// Do nothing
}, logErrorConsumer(TAG, "set auto exposure lock: ")));
@@ -158,7 +155,7 @@ private void setAutoExposureLock() {
private void checkAndUpdateAELock() {
if (!isInEditMode()) {
addDisposable(widgetModel.isAutoExposureLockOn().firstOrError()
- .observeOn(AndroidSchedulers.mainThread())
+ .observeOn(SchedulerProvider.ui())
.subscribe(this::onAELockChange, logErrorConsumer(TAG, "Update AE Lock ")));
}
}
@@ -173,6 +170,7 @@ private void initDefaults() {
private void initAttributes(@NonNull Context context, @NonNull AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AutoExposureLockWidget);
setCameraIndex(CameraIndex.find(typedArray.getInt(R.styleable.AutoExposureLockWidget_uxsdk_cameraIndex, 0)));
+ setLensType(SettingsDefinitions.LensType.find(typedArray.getInt(R.styleable.AutoExposureLockWidget_uxsdk_lensType, 0)));
ColorStateList colorStateList = typedArray.getColorStateList(R.styleable.AutoExposureLockWidget_uxsdk_widgetTitleTextColor);
if (colorStateList != null) {
setTitleTextColor(colorStateList);
@@ -244,6 +242,27 @@ public void setCameraIndex(@NonNull CameraIndex cameraIndex) {
}
}
+ /**
+ * Get the current type of the lens the widget is reacting to
+ *
+ * @return current lens type
+ */
+ @NonNull
+ public SettingsDefinitions.LensType getLensType() {
+ return widgetModel.getLensType();
+ }
+
+ /**
+ * Set the type of the lens for which the widget should react
+ *
+ * @param lensType lens type
+ */
+ public void setLensType(@NonNull SettingsDefinitions.LensType lensType) {
+ if (!isInEditMode()) {
+ widgetModel.setLensType(lensType);
+ }
+ }
+
/**
* Set drawable for auto exposure lock in locked state
*
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/autoexposurelock/AutoExposureLockWidgetModel.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/autoexposurelock/AutoExposureLockWidgetModel.java
index 9173995d..d8f61123 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/autoexposurelock/AutoExposureLockWidgetModel.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/autoexposurelock/AutoExposureLockWidgetModel.java
@@ -25,14 +25,14 @@
import androidx.annotation.NonNull;
+import dji.common.camera.SettingsDefinitions;
import dji.keysdk.CameraKey;
import dji.keysdk.DJIKey;
import dji.thirdparty.io.reactivex.Completable;
import dji.thirdparty.io.reactivex.Flowable;
import dji.ux.beta.core.base.DJISDKModel;
-import dji.ux.beta.core.base.SchedulerProviderInterface;
import dji.ux.beta.core.base.WidgetModel;
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore;
import dji.ux.beta.core.util.DataProcessor;
import dji.ux.beta.core.util.SettingDefinitions.CameraIndex;
@@ -47,15 +47,13 @@ public class AutoExposureLockWidgetModel extends WidgetModel {
private final DataProcessor autoExposureLockBooleanProcessor;
private DJIKey autoExposureLockKey;
private int cameraIndex = CameraIndex.CAMERA_INDEX_0.getIndex();
- private SchedulerProviderInterface schedulerProvider;
+ private SettingsDefinitions.LensType lensType = SettingsDefinitions.LensType.ZOOM;
//endregion
public AutoExposureLockWidgetModel(@NonNull DJISDKModel djiSdkModel,
- @NonNull ObservableInMemoryKeyedStore uxKeyManager,
- @NonNull SchedulerProviderInterface schedulerProvider) {
+ @NonNull ObservableInMemoryKeyedStore uxKeyManager) {
super(djiSdkModel, uxKeyManager);
autoExposureLockBooleanProcessor = DataProcessor.create(false);
- this.schedulerProvider = schedulerProvider;
}
//region Data
@@ -93,21 +91,40 @@ public void setCameraIndex(@NonNull CameraIndex cameraIndex) {
restart();
}
+ /**
+ * Get the current type of the lens the widget model is reacting to
+ *
+ * @return current lens type
+ */
+ @NonNull
+ public SettingsDefinitions.LensType getLensType() {
+ return lensType;
+ }
+
+ /**
+ * Set the type of the lens for which the widget model should react
+ *
+ * @param lensType lens type
+ */
+ public void setLensType(@NonNull SettingsDefinitions.LensType lensType) {
+ this.lensType = lensType;
+ restart();
+ }
+
/**
* Set auto exposure lock the opposite of its current state
*
* @return Completable representing success and failure of action
*/
public Completable toggleAutoExposureLock() {
- return djiSdkModel.setValue(autoExposureLockKey, !autoExposureLockBooleanProcessor.getValue())
- .subscribeOn(schedulerProvider.io());
+ return djiSdkModel.setValue(autoExposureLockKey, !autoExposureLockBooleanProcessor.getValue());
}
//endregion
- //region lifecycle
+ //region Lifecycle
@Override
protected void inSetup() {
- autoExposureLockKey = CameraKey.create(CameraKey.AE_LOCK, cameraIndex);
+ autoExposureLockKey = djiSdkModel.createLensKey(CameraKey.AE_LOCK, cameraIndex, lensType.value());
bindDataProcessor(autoExposureLockKey, autoExposureLockBooleanProcessor);
}
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/CameraCaptureWidget.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/CameraCaptureWidget.java
index 558b5e67..d6a12ec3 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/CameraCaptureWidget.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/CameraCaptureWidget.java
@@ -37,13 +37,13 @@
import java.util.Map;
import dji.common.camera.SettingsDefinitions.CameraMode;
-import dji.thirdparty.io.reactivex.android.schedulers.AndroidSchedulers;
import dji.ux.beta.cameracore.R;
import dji.ux.beta.cameracore.widget.cameracapture.recordvideo.RecordVideoWidget;
import dji.ux.beta.cameracore.widget.cameracapture.shootphoto.ShootPhotoWidget;
-import dji.ux.beta.core.base.ConstraintLayoutWidget;
import dji.ux.beta.core.base.DJISDKModel;
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.base.SchedulerProvider;
+import dji.ux.beta.core.base.widget.ConstraintLayoutWidget;
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore;
/**
* Camera Capture Widget
@@ -53,13 +53,13 @@
*/
public class CameraCaptureWidget extends ConstraintLayoutWidget {
- //region fields
+ //region Fields
private static final String TAG = "CameraCaptureWidget";
private CameraCaptureWidgetModel widgetModel;
private Map widgetMap;
//endregion
- //region lifecycle
+ //region Lifecycle
public CameraCaptureWidget(Context context) {
super(context);
}
@@ -104,7 +104,7 @@ protected void onDetachedFromWindow() {
protected void reactToModelChanges() {
addReaction(
widgetModel.getCameraMode()
- .observeOn(AndroidSchedulers.mainThread())
+ .observeOn(SchedulerProvider.ui())
.subscribe(
this::onCameraModeChange,
logErrorConsumer(TAG, "Camera Mode Change: ")));
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/CameraCaptureWidgetModel.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/CameraCaptureWidgetModel.java
index 9563ced1..6932aaec 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/CameraCaptureWidgetModel.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/CameraCaptureWidgetModel.java
@@ -26,13 +26,11 @@
import androidx.annotation.NonNull;
import dji.common.camera.SettingsDefinitions.CameraMode;
-import dji.keysdk.CameraKey;
-import dji.keysdk.DJIKey;
import dji.thirdparty.io.reactivex.Flowable;
import dji.ux.beta.core.base.DJISDKModel;
import dji.ux.beta.core.base.WidgetModel;
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore;
-import dji.ux.beta.core.util.DataProcessor;
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.module.FlatCameraModule;
/**
* Camera Capture Widget Model
@@ -42,26 +40,26 @@
*/
public class CameraCaptureWidgetModel extends WidgetModel {
- //region fields
- private final DataProcessor cameraModeDataProcessor;
+ //region Fields
+ private FlatCameraModule flatCameraModule;
//endregion
- //region lifecycle
+ //region Lifecycle
public CameraCaptureWidgetModel(@NonNull DJISDKModel djiSdkModel,
@NonNull ObservableInMemoryKeyedStore keyedStore) {
super(djiSdkModel, keyedStore);
- cameraModeDataProcessor = DataProcessor.create(CameraMode.UNKNOWN);
+ flatCameraModule = new FlatCameraModule();
+ addModule(flatCameraModule);
}
@Override
protected void inSetup() {
- DJIKey cameraModeKey = CameraKey.create(CameraKey.MODE);
- bindDataProcessor(cameraModeKey, cameraModeDataProcessor);
+ // do nothing
}
@Override
protected void inCleanup() {
- // Empty function
+ // do nothing
}
@Override
@@ -78,7 +76,7 @@ protected void updateStates() {
* @return Flowable with {@link CameraMode} instance
*/
public Flowable getCameraMode() {
- return cameraModeDataProcessor.toFlowable();
+ return flatCameraModule.getCameraModeDataProcessor().toFlowable();
}
//endregion
}
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/recordvideo/RecordVideoWidget.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/recordvideo/RecordVideoWidget.java
index 8f1c7b5b..ccd96f05 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/recordvideo/RecordVideoWidget.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/recordvideo/RecordVideoWidget.java
@@ -50,10 +50,10 @@
import dji.ux.beta.cameracore.R;
import dji.ux.beta.cameracore.util.CameraActionSound;
import dji.ux.beta.cameracore.widget.cameracapture.recordvideo.RecordVideoWidgetModel.RecordingState;
-import dji.ux.beta.core.base.ConstraintLayoutWidget;
import dji.ux.beta.core.base.DJISDKModel;
import dji.ux.beta.core.base.SchedulerProvider;
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.base.widget.ConstraintLayoutWidget;
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore;
import dji.ux.beta.core.util.CameraUtil;
import dji.ux.beta.core.util.ProductUtil;
import dji.ux.beta.core.util.SettingDefinitions.CameraIndex;
@@ -66,7 +66,7 @@
*/
public class RecordVideoWidget extends ConstraintLayoutWidget implements OnClickListener {
- //region fields
+ //region Fields
private static final String TAG = "RecordVideoWidget";
private RecordVideoWidgetModel widgetModel;
private ImageView centerImageView;
@@ -79,11 +79,10 @@ public class RecordVideoWidget extends ConstraintLayoutWidget implements OnClick
private Drawable recordVideoStopDrawable;
private Drawable recordVideoStartHasselbladDrawable;
private Drawable recordVideoStopHasselbladDrawable;
- private SchedulerProvider schedulerProvider;
private CameraActionSound cameraActionSound;
//endregion
- //region lifecycle
+ //region Lifecycle
public RecordVideoWidget(Context context) {
super(context);
}
@@ -107,12 +106,10 @@ protected void initView(@NonNull Context context, @Nullable AttributeSet attrs,
storageSDCardIconMap = new HashMap<>();
centerImageView.setOnClickListener(this);
cameraActionSound = new CameraActionSound(context);
- schedulerProvider = SchedulerProvider.getInstance();
if (!isInEditMode()) {
widgetModel =
new RecordVideoWidgetModel(DJISDKModel.getInstance(),
- ObservableInMemoryKeyedStore.getInstance(),
- schedulerProvider);
+ ObservableInMemoryKeyedStore.getInstance());
}
initDefaults();
if (attrs != null) {
@@ -140,19 +137,19 @@ protected void onDetachedFromWindow() {
protected void reactToModelChanges() {
addReaction(
widgetModel.getRecordingTimeInSeconds()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(
this::updateRecordingTime,
logErrorConsumer(TAG, "record time: ")));
addReaction(
widgetModel.getRecordingState()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(
recordingState -> onIsRecordingVideoChange(recordingState, true),
logErrorConsumer(TAG, "is recording: ")));
addReaction(
widgetModel.getCameraVideoStorageState()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(
this::updateCameraForegroundResource,
logErrorConsumer(TAG, "camera storage update: ")));
@@ -175,7 +172,7 @@ public void onClick(View v) {
} else {
return Completable.complete();
}
- }).observeOn(schedulerProvider.ui()).subscribe(() -> {
+ }).observeOn(SchedulerProvider.ui()).subscribe(() -> {
}, logErrorConsumer(TAG, "START STOP VIDEO")));
}
}
@@ -202,6 +199,7 @@ private void initDefaults() {
private void initAttributes(@NonNull Context context, @NonNull AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RecordVideoWidget);
setCameraIndex(CameraIndex.find(typedArray.getInt(R.styleable.RecordVideoWidget_uxsdk_cameraIndex, 0)));
+ setLensType(SettingsDefinitions.LensType.find(typedArray.getInt(R.styleable.RecordVideoWidget_uxsdk_lensType, 0)));
int textAppearance = typedArray.getResourceId(R.styleable.RecordVideoWidget_uxsdk_timerTextAppearance, INVALID_RESOURCE);
if (textAppearance != INVALID_RESOURCE) {
@@ -312,9 +310,9 @@ private void onIsRecordingVideoChange(RecordingState recordingState, boolean pla
storageStatusOverlayImageView.setVisibility(isRecordingVideo ? View.GONE : View.VISIBLE);
if (playSound) {
if (recordingState == RecordingState.RECORDING_IN_PROGRESS) {
- addDisposable(cameraActionSound.playStartRecordVideo(schedulerProvider));
+ addDisposable(cameraActionSound.playStartRecordVideo());
} else if (recordingState == RecordingState.RECORDING_STOPPED) {
- addDisposable(cameraActionSound.playStopRecordVideo(schedulerProvider));
+ addDisposable(cameraActionSound.playStopRecordVideo());
}
}
}
@@ -322,7 +320,7 @@ private void onIsRecordingVideoChange(RecordingState recordingState, boolean pla
private void checkAndUpdateCameraForegroundResource() {
if (!isInEditMode()) {
addDisposable(widgetModel.getCameraVideoStorageState().firstOrError()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(this::updateCameraForegroundResource,
logErrorConsumer(TAG, "check and update camera foreground resource: ")));
}
@@ -331,7 +329,7 @@ private void checkAndUpdateCameraForegroundResource() {
private void checkAndUpdateCenterImageView() {
if (!isInEditMode()) {
addDisposable(widgetModel.getRecordingState().firstOrError()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(recordingState -> onIsRecordingVideoChange(recordingState, false),
logErrorConsumer(TAG, "check and update camera foreground resource: ")));
}
@@ -361,6 +359,27 @@ public void setCameraIndex(@NonNull CameraIndex cameraIndex) {
}
}
+ /**
+ * Get the current type of the lens the widget is reacting to
+ *
+ * @return current lens type
+ */
+ @NonNull
+ public SettingsDefinitions.LensType getLensType() {
+ return widgetModel.getLensType();
+ }
+
+ /**
+ * Set the type of the lens for which the widget should react
+ *
+ * @param lensType lens type
+ */
+ public void setLensType(@NonNull SettingsDefinitions.LensType lensType) {
+ if (!isInEditMode()) {
+ widgetModel.setLensType(lensType);
+ }
+ }
+
/**
* Get the current start recording video icon
*
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/recordvideo/RecordVideoWidgetModel.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/recordvideo/RecordVideoWidgetModel.java
index 834ff8de..6ad43f69 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/recordvideo/RecordVideoWidgetModel.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/recordvideo/RecordVideoWidgetModel.java
@@ -34,9 +34,8 @@
import dji.thirdparty.io.reactivex.Completable;
import dji.thirdparty.io.reactivex.Flowable;
import dji.ux.beta.core.base.DJISDKModel;
-import dji.ux.beta.core.base.SchedulerProviderInterface;
import dji.ux.beta.core.base.WidgetModel;
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore;
import dji.ux.beta.core.util.DataProcessor;
import dji.ux.beta.core.util.SettingDefinitions;
@@ -75,18 +74,16 @@ public class RecordVideoWidgetModel extends WidgetModel {
private final DataProcessor ssdRecordingTime;
private final DataProcessor recordingStateProcessor;
private int cameraIndex;
+ private SettingsDefinitions.LensType lensType = SettingsDefinitions.LensType.ZOOM;
private DJIKey stopVideoRecordingKey;
private DJIKey startVideoRecordingKey;
- private SchedulerProviderInterface schedulerProvider;
//endregion
//region Constructor
public RecordVideoWidgetModel(@NonNull DJISDKModel djiSdkModel,
- @NonNull ObservableInMemoryKeyedStore uxKeyManager,
- @NonNull SchedulerProviderInterface schedulerProvider) {
+ @NonNull ObservableInMemoryKeyedStore uxKeyManager) {
super(djiSdkModel, uxKeyManager);
this.cameraIndex = SettingDefinitions.CameraIndex.CAMERA_INDEX_0.getIndex();
- this.schedulerProvider = schedulerProvider;
CameraSDVideoStorageState cameraSDVideoStorageState = new CameraSDVideoStorageState(
SettingsDefinitions.StorageLocation.SDCARD,
0,
@@ -150,7 +147,7 @@ protected void inSetup() {
bindDataProcessor(ssdRecordingTimeKey, ssdRecordingTime);
bindDataProcessor(ssdVideoLicenseKey, cameraSSDVideoLicenseDataProcessor);
// Resolution and Frame Rates
- DJIKey nonSSDRecordedVideoParametersKey = CameraKey.create(CameraKey.RESOLUTION_FRAME_RATE, cameraIndex);
+ DJIKey nonSSDRecordedVideoParametersKey = djiSdkModel.createLensKey(CameraKey.RESOLUTION_FRAME_RATE, cameraIndex, lensType.value());
DJIKey ssdRecordedVideoParametersKey = CameraKey.create(CameraKey.SSD_VIDEO_RESOLUTION_AND_FRAME_RATE, cameraIndex);
bindDataProcessor(nonSSDRecordedVideoParametersKey, nonSSDRecordedVideoParameters);
bindDataProcessor(ssdRecordedVideoParametersKey, ssdRecordedVideoParameters);
@@ -237,6 +234,26 @@ public void setCameraIndex(@NonNull SettingDefinitions.CameraIndex cameraIndex)
this.cameraIndex = cameraIndex.getIndex();
restart();
}
+
+ /**
+ * Get the current type of the lens the widget model is reacting to
+ *
+ * @return current lens type
+ */
+ @NonNull
+ public SettingsDefinitions.LensType getLensType() {
+ return lensType;
+ }
+
+ /**
+ * Set the type of the lens for which the widget model should react
+ *
+ * @param lensType lens type
+ */
+ public void setLensType(@NonNull SettingsDefinitions.LensType lensType) {
+ this.lensType = lensType;
+ restart();
+ }
//endregion
//region Actions
@@ -251,8 +268,7 @@ public Completable startRecordVideo() {
return Completable.complete();
}
- return djiSdkModel.performAction(startVideoRecordingKey)
- .subscribeOn(schedulerProvider.io());
+ return djiSdkModel.performAction(startVideoRecordingKey);
}
/**
@@ -265,8 +281,7 @@ public Completable stopRecordVideo() {
return Completable.complete();
}
- return djiSdkModel.performAction(stopVideoRecordingKey)
- .subscribeOn(schedulerProvider.io());
+ return djiSdkModel.performAction(stopVideoRecordingKey);
}
//endregion
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/shootphoto/ShootPhotoWidget.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/shootphoto/ShootPhotoWidget.java
index 5ac94915..034d71da 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/shootphoto/ShootPhotoWidget.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/shootphoto/ShootPhotoWidget.java
@@ -53,10 +53,10 @@
import dji.ux.beta.cameracore.ui.ProgressRingView;
import dji.ux.beta.cameracore.util.CameraActionSound;
import dji.ux.beta.cameracore.util.CameraResource;
-import dji.ux.beta.core.base.ConstraintLayoutWidget;
import dji.ux.beta.core.base.DJISDKModel;
import dji.ux.beta.core.base.SchedulerProvider;
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.base.widget.ConstraintLayoutWidget;
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore;
import dji.ux.beta.core.util.ProductUtil;
import static dji.ux.beta.core.util.SettingDefinitions.CameraIndex;
@@ -68,7 +68,7 @@
* displays the storage state and errors associated with it.
*/
public class ShootPhotoWidget extends ConstraintLayoutWidget implements View.OnClickListener {
- //region fields
+ //region Fields
private static final String TAG = "ShootPhotoWidget";
private ShootPhotoWidgetModel widgetModel;
private ProgressRingView borderProgressRingView;
@@ -85,11 +85,10 @@ public class ShootPhotoWidget extends ConstraintLayoutWidget implements View.OnC
private Map storageInternalIconMap;
private Map storageSSDIconMap;
private Map storageSDCardIconMap;
- private SchedulerProvider schedulerProvider;
private CameraActionSound cameraActionSound;
//endregion
- //region lifecycle
+ //region Lifecycle
public ShootPhotoWidget(Context context) {
super(context);
}
@@ -111,14 +110,12 @@ protected void initView(@NonNull Context context, @Nullable AttributeSet attrs,
storageInternalIconMap = new HashMap<>();
storageSSDIconMap = new HashMap<>();
storageSDCardIconMap = new HashMap<>();
- schedulerProvider = SchedulerProvider.getInstance();
cameraActionSound = new CameraActionSound(context);
if (!isInEditMode()) {
centerImageView.setOnClickListener(this);
widgetModel =
new ShootPhotoWidgetModel(DJISDKModel.getInstance(),
- ObservableInMemoryKeyedStore.getInstance(),
- schedulerProvider);
+ ObservableInMemoryKeyedStore.getInstance());
}
initDefaults();
if (attrs != null) {
@@ -146,7 +143,7 @@ protected void onDetachedFromWindow() {
protected void reactToModelChanges() {
addReaction(
widgetModel.isShootingPhoto()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(
this::onIsShootingPhotoChange,
logErrorConsumer(TAG, "isShootingPhoto: ")));
@@ -175,7 +172,7 @@ public void onClick(View v) {
return widgetModel.startShootPhoto();
}
return Completable.complete();
- }).observeOn(schedulerProvider.ui())
+ }).observeOn(SchedulerProvider.ui())
.subscribe(
() -> {
}, logErrorConsumer(TAG, "Start Stop Shoot Photo")));
@@ -252,7 +249,7 @@ private void onIsShootingPhotoChange(boolean isShootingPhoto) {
DJILog.d(TAG, "onIsShootingPhotoChange " + isShootingPhoto);
borderProgressRingView.setIndeterminate(isShootingPhoto);
if (isShootingPhoto) {
- addDisposable(cameraActionSound.playCapturePhoto(schedulerProvider));
+ addDisposable(cameraActionSound.playCapturePhoto());
}
}
@@ -260,7 +257,7 @@ private Disposable reactToPhotoStateAndPhotoStorageState() {
return Flowable.combineLatest(widgetModel.getCameraPhotoState(),
widgetModel.getCameraStorageState(),
Pair::new)
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(values -> updateCameraForegroundResource(values.first, values.second),
logErrorConsumer(TAG, "reactToPhotoStateAndPhotoStorageState "));
}
@@ -270,7 +267,7 @@ private Disposable reactToCanStartOrStopShootingPhoto() {
widgetModel.canStartShootingPhoto(),
widgetModel.canStopShootingPhoto(),
Pair::new)
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(values -> updateImages(values.first, values.second),
logErrorConsumer(TAG, "reactToCanStartOrStopShootingPhoto: "));
}
@@ -281,7 +278,7 @@ private void checkAndUpdatePhotoStateAndPhotoStorageState() {
widgetModel.getCameraStorageState(),
Pair::new)
.firstOrError()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(values -> updateCameraForegroundResource(values.first, values.second),
logErrorConsumer(TAG, "checkAndUpdatePhotoStateAndPhotoStorageState ")));
}
@@ -294,7 +291,7 @@ private void checkAndUpdateCanStartOrStopShootingPhoto() {
widgetModel.canStopShootingPhoto(),
Pair::new)
.firstOrError()
- .observeOn(schedulerProvider.ui())
+ .observeOn(SchedulerProvider.ui())
.subscribe(values -> updateImages(values.first, values.second),
logErrorConsumer(TAG, "checkAndUpdateCanStartOrStopShootingPhoto: ")));
}
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/shootphoto/ShootPhotoWidgetModel.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/shootphoto/ShootPhotoWidgetModel.java
index 155978b5..0149b639 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/shootphoto/ShootPhotoWidgetModel.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracapture/shootphoto/ShootPhotoWidgetModel.java
@@ -32,9 +32,9 @@
import dji.thirdparty.io.reactivex.Completable;
import dji.thirdparty.io.reactivex.Flowable;
import dji.ux.beta.core.base.DJISDKModel;
-import dji.ux.beta.core.base.SchedulerProviderInterface;
import dji.ux.beta.core.base.WidgetModel;
-import dji.ux.beta.core.base.uxsdkkeys.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.communication.ObservableInMemoryKeyedStore;
+import dji.ux.beta.core.module.FlatCameraModule;
import dji.ux.beta.core.util.DataProcessor;
import dji.ux.beta.core.util.SettingDefinitions;
@@ -59,13 +59,11 @@ public class ShootPhotoWidgetModel extends WidgetModel {
private final DataProcessor canStartShootingPhoto;
private final DataProcessor canStopShootingPhoto;
private final DataProcessor cameraDisplayName;
- private int cameraIndex;
+ private final DataProcessor isShootingInterval;
//endregion
//region Internal data
- private final DataProcessor isShootingInterval;
private final DataProcessor isShootingPanorama;
- private final DataProcessor shootPhotoMode;
private final DataProcessor aebCount;
private final DataProcessor burstCount;
private final DataProcessor rawBurstCount;
@@ -80,22 +78,21 @@ public class ShootPhotoWidgetModel extends WidgetModel {
private final DataProcessor innerStorageAvailableCaptureCount;
private final DataProcessor ssdAvailableCaptureCount;
private final DataProcessor isProductConnected;
- private SchedulerProviderInterface schedulerProvider;
//endregion
//region Other fields
private final SettingsDefinitions.PhotoTimeIntervalSettings defaultIntervalSettings;
+ private int cameraIndex;
private DJIKey stopShootPhotoKey;
private DJIKey startShootPhotoKey;
+ private FlatCameraModule flatCameraModule;
//endregion
//region Constructor
public ShootPhotoWidgetModel(@NonNull DJISDKModel djiSdkModel,
- @NonNull ObservableInMemoryKeyedStore keyedStore,
- @NonNull SchedulerProviderInterface schedulerProvider) {
+ @NonNull ObservableInMemoryKeyedStore keyedStore) {
super(djiSdkModel, keyedStore);
this.cameraIndex = SettingDefinitions.CameraIndex.CAMERA_INDEX_0.getIndex();
- this.schedulerProvider = schedulerProvider;
defaultIntervalSettings = new SettingsDefinitions.PhotoTimeIntervalSettings(0, 0);
CameraPhotoState cameraPhotoState = new CameraPhotoState(SettingsDefinitions.ShootPhotoMode.UNKNOWN);
@@ -105,7 +102,6 @@ public ShootPhotoWidgetModel(@NonNull DJISDKModel djiSdkModel,
0,
SettingsDefinitions.SDCardOperationState.NOT_INSERTED);
cameraStorageState = DataProcessor.create(cameraSDStorageState);
- shootPhotoMode = DataProcessor.create(cameraPhotoState.getShootPhotoMode());
canStartShootingPhoto = DataProcessor.create(false);
canStopShootingPhoto = DataProcessor.create(false);
cameraDisplayName = DataProcessor.create("");
@@ -127,6 +123,8 @@ public ShootPhotoWidgetModel(@NonNull DJISDKModel djiSdkModel,
innerStorageAvailableCaptureCount = DataProcessor.create(INVALID_AVAILABLE_CAPTURE_COUNT_LONG);
ssdAvailableCaptureCount = DataProcessor.create(INVALID_AVAILABLE_CAPTURE_COUNT);
isProductConnected = DataProcessor.create(false);
+ flatCameraModule = new FlatCameraModule();
+ addModule(flatCameraModule);
}
//endregion
@@ -191,22 +189,23 @@ public Flowable canStopShootingPhoto() {
}
/**
- * Set the index of the camera for which the widget model should react
+ * Get the current index of the camera the widget model is reacting to
*
- * @param cameraIndex camera index
+ * @return current camera index
*/
- public void setCameraIndex(@NonNull SettingDefinitions.CameraIndex cameraIndex) {
- this.cameraIndex = cameraIndex.getIndex();
- restart();
+ public SettingDefinitions.CameraIndex getCameraIndex() {
+ return SettingDefinitions.CameraIndex.find(cameraIndex);
}
/**
- * Get the current index of the camera the widget model is reacting to
+ * Set the index of the camera for which the widget model should react
*
- * @return current camera index
+ * @param cameraIndex camera index
*/
- public SettingDefinitions.CameraIndex getCameraIndex() {
- return SettingDefinitions.CameraIndex.find(cameraIndex);
+ public void setCameraIndex(@NonNull SettingDefinitions.CameraIndex cameraIndex) {
+ this.cameraIndex = cameraIndex.getIndex();
+ flatCameraModule.setCameraIndex(cameraIndex);
+ restart();
}
/**
@@ -230,9 +229,7 @@ public Completable startShootPhoto() {
if (!canStartShootingPhoto.getValue() || !djiSdkModel.isAvailable()) {
return Completable.complete();
}
-
- return djiSdkModel.performAction(startShootPhotoKey)
- .subscribeOn(schedulerProvider.io());
+ return djiSdkModel.performAction(startShootPhotoKey);
}
/**
@@ -244,8 +241,7 @@ public Completable stopShootPhoto() {
if (!canStopShootingPhoto.getValue() || !djiSdkModel.isAvailable()) {
return Completable.complete();
}
- return djiSdkModel.performAction(stopShootPhotoKey)
- .subscribeOn(schedulerProvider.io());
+ return djiSdkModel.performAction(stopShootPhotoKey);
}
//endregion
@@ -259,13 +255,11 @@ protected void inSetup() {
DJIKey cameraConnectionKey = CameraKey.create(CameraKey.CONNECTION, cameraIndex);
bindDataProcessor(cameraConnectionKey, isProductConnected, newValue -> onCameraConnected((boolean) newValue));
// Photo mode
- DJIKey shootPhotoModeKey = CameraKey.create(CameraKey.SHOOT_PHOTO_MODE, cameraIndex);
DJIKey photoAEBParamKey = CameraKey.create(CameraKey.PHOTO_AEB_COUNT, cameraIndex);
DJIKey photoBurstCountKey = CameraKey.create(CameraKey.PHOTO_BURST_COUNT, cameraIndex);
DJIKey photoIntervalParamKey = CameraKey.create(CameraKey.PHOTO_TIME_INTERVAL_SETTINGS, cameraIndex);
DJIKey rawBurstCountKey = CameraKey.create(CameraKey.PHOTO_RAW_BURST_COUNT, cameraIndex);
DJIKey panoramaModeKey = CameraKey.create(CameraKey.PHOTO_PANORAMA_MODE, cameraIndex);
- bindDataProcessor(shootPhotoModeKey, shootPhotoMode);
bindDataProcessor(photoAEBParamKey, aebCount);
bindDataProcessor(photoBurstCountKey, burstCount);
bindDataProcessor(rawBurstCountKey, rawBurstCount);
@@ -311,7 +305,7 @@ protected void inSetup() {
@Override
protected void inCleanup() {
- //Nothing to clean
+ // do nothing
}
@Override
@@ -324,7 +318,7 @@ protected void updateStates() {
//region Helpers
private void updateCameraPhotoState() {
CameraPhotoState cameraPhotoState = null;
- SettingsDefinitions.ShootPhotoMode shootPhotoMode = this.shootPhotoMode.getValue();
+ SettingsDefinitions.ShootPhotoMode shootPhotoMode = flatCameraModule.getShootPhotoModeProcessor().getValue();
switch (shootPhotoMode) {
case SINGLE:
case HDR:
@@ -389,7 +383,7 @@ private void updateCameraStorageState() {
return;
}
- SettingsDefinitions.ShootPhotoMode currentShootPhotoMode = shootPhotoMode.getValue();
+ SettingsDefinitions.ShootPhotoMode currentShootPhotoMode = flatCameraModule.getShootPhotoModeProcessor().getValue();
long availableCaptureCount = getAvailableCaptureCount(currentStorageLocation, currentShootPhotoMode);
if (availableCaptureCount == INVALID_AVAILABLE_CAPTURE_COUNT) {
return;
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracontrols/CameraControlsWidget.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracontrols/CameraControlsWidget.java
index f35a4b60..364092ea 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracontrols/CameraControlsWidget.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracontrols/CameraControlsWidget.java
@@ -34,7 +34,7 @@
import dji.ux.beta.cameracore.widget.cameracontrols.camerasettingsindicator.CameraSettingsMenuIndicatorWidget;
import dji.ux.beta.cameracore.widget.cameracontrols.exposuresettingsindicator.ExposureSettingsIndicatorWidget;
import dji.ux.beta.cameracore.widget.cameracontrols.photovideoswitch.PhotoVideoSwitchWidget;
-import dji.ux.beta.core.base.ConstraintLayoutWidget;
+import dji.ux.beta.core.base.widget.ConstraintLayoutWidget;
/**
* Compound widget which combines the state and interaction related to camera.
@@ -45,14 +45,14 @@
*/
public class CameraControlsWidget extends ConstraintLayoutWidget {
- //region fields
+ //region Fields
private CameraSettingsMenuIndicatorWidget cameraSettingsMenuIndicatorWidget;
private PhotoVideoSwitchWidget photoVideoSwitchWidget;
private CameraCaptureWidget cameraCaptureWidget;
private ExposureSettingsIndicatorWidget exposureSettingsIndicatorWidget;
//endregion
- //region lifecycle
+ //region Lifecycle
public CameraControlsWidget(@NonNull Context context) {
super(context);
}
diff --git a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracontrols/camerasettingsindicator/CameraSettingsMenuIndicatorWidget.java b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracontrols/camerasettingsindicator/CameraSettingsMenuIndicatorWidget.java
index 3f583deb..f24674c9 100644
--- a/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracontrols/camerasettingsindicator/CameraSettingsMenuIndicatorWidget.java
+++ b/android-uxsdk-beta-cameracore/src/main/java/dji/ux/beta/cameracore/widget/cameracontrols/camerasettingsindicator/CameraSettingsMenuIndicatorWidget.java
@@ -39,8 +39,8 @@
import dji.ux.beta.cameracore.R;
import dji.ux.beta.cameracore.widget.cameracontrols.CameraControlsWidget;
-import dji.ux.beta.core.base.FrameLayoutWidget;
-import dji.ux.beta.core.base.OnStateChangeCallback;
+import dji.ux.beta.core.base.widget.FrameLayoutWidget;
+import dji.ux.beta.core.communication.OnStateChangeCallback;
/**
* Camera Settings Menu Indicator Widget
@@ -50,13 +50,13 @@
*/
public class CameraSettingsMenuIndicatorWidget extends FrameLayoutWidget implements View.OnClickListener {
- //region fields
+ //region Fields
private TextView foregroundTextView;
private OnStateChangeCallback