Skip to content

Commit

Permalink
Merge pull request #779 from dji-sdk/sdk_releases/4.14
Browse files Browse the repository at this point in the history
update for 4.14
  • Loading branch information
dji-dev committed Feb 23, 2021
2 parents 37ffe51 + 224431f commit 10e5a05
Show file tree
Hide file tree
Showing 515 changed files with 7,379 additions and 1,265 deletions.
6 changes: 2 additions & 4 deletions Sample Code/app/build.gradle
Expand Up @@ -76,19 +76,17 @@ android {
dependencies {
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.squareup:otto:1.3.8'
implementation('com.dji:dji-sdk:4.14-trial1', {
implementation('com.dji:dji-sdk:4.14', {
/**
* Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
* Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
* is called.
* Both will greatly reducing the size of the APK.
*/
exclude module: 'library-anti-distortion'
exclude module: 'utmiss'
//exclude module: 'fly-safe-database'
})
implementation 'com.dji:utmiss:1.0.8'
compileOnly 'com.dji:dji-sdk-provided:4.14-trial1'
compileOnly 'com.dji:dji-sdk-provided:4.14'

implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.core:core:1.0.0'
Expand Down
Expand Up @@ -13,8 +13,6 @@
import java.util.concurrent.TimeUnit;

import dji.common.camera.SettingsDefinitions;
import dji.common.error.DJIError;
import dji.common.util.CommonCallbacks;

/**
* Created by dji on 16/1/6.
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -147,15 +147,15 @@ public void onResult(DJIError djiError) {
flightController.setMaxFlightHeight(MAX_HEIGHT, new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError djiError) {
ToastUtils.setResultToToast(djiError == null ? "Max Flight Height is set to 500m!" : djiError.getDescription());
ToastUtils.setResultToToast(djiError == null ? "The maximum height is set to 500m!" : djiError.getDescription());
}
});
break;
case R.id.btn_set_maximum_radius:
flightController.setMaxFlightRadius(MAX_RADIUS, new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError djiError) {
ToastUtils.setResultToToast(djiError == null ? "Max Flight Radius is set to 500m!" : djiError.getDescription());
ToastUtils.setResultToToast(djiError == null ? "The maximum radius is set to 500m!" : djiError.getDescription());
}
});
break;
Expand Down
Expand Up @@ -6,20 +6,21 @@ import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import butterknife.OnClick
import com.dji.sdk.sample.R
import com.dji.sdk.sample.internal.utils.ToastUtils
import com.dji.sdk.sample.internal.view.PresentableView
import dji.common.error.DJIError
import dji.common.util.CommonCallbacks.CompletionCallbackWith
import dji.sdk.sdkmanager.DJISDKManager
import dji.sdk.sdkmanager.LDMManager.LDMCallback
import dji.sdk.sdkmanager.LDMModule
import dji.sdk.sdkmanager.LDMModuleType

class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.OnClickListener {

private lateinit var ldmInfoText: TextView
private var isLDMEnable: Boolean = false
private var isLDMSupport: Boolean = false
private var isLDMSupported: Boolean = false
private var isLDMEnabled: Boolean = false

init {
initUI(context)
Expand All @@ -36,19 +37,20 @@ class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.
findViewById<View>(R.id.btn_disable_ldm).setOnClickListener(this)
findViewById<View>(R.id.btn_enable_rtk_network).setOnClickListener(this)
findViewById<View>(R.id.btn_disable_rtk_network).setOnClickListener(this)
findViewById<View>(R.id.btn_is_rtk_network_enabled).setOnClickListener(this)
findViewById<View>(R.id.btn_is_enable_user_account).setOnClickListener(this)
findViewById<View>(R.id.btn_is_disable_user_account).setOnClickListener(this)
findViewById<View>(R.id.btn_get_ldm_license).setOnClickListener(this)
}

private fun initListener() {
DJISDKManager.getInstance().ldmManager.setCallback(object : LDMCallback {
override fun onLDMEnabledChange(isEnabled: Boolean) {
isLDMEnable = isEnabled;
isLDMEnabled = isEnabled;
handler.post { updateLdmInfo() }
}

override fun onLDMSupportedChange(isSupported: Boolean) {
isLDMSupport = isSupported;
isLDMSupported = isSupported;
handler.post { updateLdmInfo() }
}
})
Expand All @@ -68,18 +70,40 @@ class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.
}
}

fun enableRTKNetwork() {
val error = DJISDKManager.getInstance().ldmManager.setRTKNetworkServiceEnabled(true)
ToastUtils.setResultToToast("enableRTKNetwork " + if (error == null) "success" else "error=" + error.description)
fun setRTKEnabled() {
var error = DJISDKManager.getInstance().ldmManager.setModuleNetworkServiceEnabled(LDMModule.Builder()
.enabled(true)
.moduleType(LDMModuleType.RTK)
.build())
ToastUtils.setResultToToast("setRTKEnabled " + if (error == null) "success" else "error=" + error.description)
updateLdmInfo()
}

fun disableRTKNetwork() {
val error = DJISDKManager.getInstance().ldmManager.setRTKNetworkServiceEnabled(false)
ToastUtils.setResultToToast("disableRTKNetwork " + if (error == null) "success" else "error=" + error.description)
fun setRTKDisabled() {
var error = DJISDKManager.getInstance().ldmManager.setModuleNetworkServiceEnabled(LDMModule.Builder()
.enabled(false)
.moduleType(LDMModuleType.RTK)
.build())
ToastUtils.setResultToToast("setRTKDisabled " + if (error == null) "success" else "error=" + error.description)
updateLdmInfo()
}

fun isRTKNetworkEnabled() {
ToastUtils.setResultToToast("isRTKNetworkServiceEnabled: " + DJISDKManager.getInstance().ldmManager.isRTKNetworkServiceEnabled)
fun setUserAccountEnabled() {
var error = DJISDKManager.getInstance().ldmManager.setModuleNetworkServiceEnabled(LDMModule.Builder()
.enabled(true)
.moduleType(LDMModuleType.USER_ACCOUNT)
.build())
ToastUtils.setResultToToast("setUserAccountEnabled " + if (error == null) "success" else "error=" + error.description)
updateLdmInfo()
}

fun setUserAccountDisabled() {
var error = DJISDKManager.getInstance().ldmManager.setModuleNetworkServiceEnabled(LDMModule.Builder()
.enabled(false)
.moduleType(LDMModuleType.USER_ACCOUNT)
.build())
ToastUtils.setResultToToast("setUserAccountDisabled " + if (error == null) "success" else "error=" + error.description)
updateLdmInfo()
}

fun getLdmLicense() {
Expand All @@ -92,10 +116,18 @@ class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.
ToastUtils.setResultToToast("getLdmLicense error=" + error.description)
}
})
updateLdmInfo()
}

private fun updateLdmInfo() {
ldmInfoText.text = "LDM enabled:$isLDMEnable,LDM supported:$isLDMSupport"
isLDMEnabled = DJISDKManager.getInstance().ldmManager.isLDMEnabled
var isRTKEnabled = DJISDKManager.getInstance().ldmManager.isModuleNetworkServiceEnabled(LDMModuleType.RTK)
var isUserAccountEnabled = DJISDKManager.getInstance().ldmManager.isModuleNetworkServiceEnabled(LDMModuleType.USER_ACCOUNT)

ldmInfoText.text = "LDM enabled: $isLDMEnabled\n" +
"LDM supported: $isLDMSupported\n" +
"isRTKEnabled: $isRTKEnabled\n" +
"isUserAccountEnabled: $isUserAccountEnabled\n"
}

override fun getDescription(): Int = R.string.component_listview_ldm
Expand All @@ -106,9 +138,10 @@ class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.
when (v?.id) {
R.id.btn_enable_ldm -> enableLDM()
R.id.btn_disable_ldm -> disableLDM()
R.id.btn_enable_rtk_network -> enableRTKNetwork()
R.id.btn_disable_rtk_network -> disableRTKNetwork()
R.id.btn_is_rtk_network_enabled -> isRTKNetworkEnabled()
R.id.btn_enable_rtk_network -> setRTKEnabled()
R.id.btn_disable_rtk_network -> setRTKDisabled()
R.id.btn_is_enable_user_account -> setUserAccountEnabled()
R.id.btn_is_disable_user_account -> setUserAccountDisabled()
R.id.btn_get_ldm_license -> getLdmLicense()
}
}
Expand Down
Expand Up @@ -7,12 +7,13 @@
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.dji.sdk.sample.R;

import java.io.File;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
Expand Down

0 comments on commit 10e5a05

Please sign in to comment.