Skip to content

Commit a8766e3

Browse files
author
daniel.chen
committed
4.15 sample update
1 parent 241af9a commit a8766e3

File tree

574 files changed

+113451
-6838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

574 files changed

+113451
-6838
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ Declare dependency via Maven:
1212
<dependency>
1313
<groupId>com.dji</groupId>
1414
<artifactId>dji-sdk</artifactId>
15-
<version>4.14.1</version>
15+
<version>4.15</version>
1616
</dependency>
1717

1818
<dependency>
1919
<groupId>com.dji</groupId>
2020
<artifactId>dji-sdk-provided</artifactId>
21-
<version>4.14.1</version>
21+
<version>4.15</version>
2222
</dependency>
2323
~~~
2424

2525
or Gradle:
2626

2727
~~~groovy
28-
compile 'com.dji:dji-sdk:4.14.1'
29-
provided 'com.dji:dji-sdk-provided:4.14.1'
28+
compile 'com.dji:dji-sdk:4.15'
29+
provided 'com.dji:dji-sdk-provided:4.15'
3030
~~~
3131

3232
For further detail on how to integrate the DJI Android SDK into your Android Studio project, please check the [Integrate SDK into Application](http://developer.dji.com/mobile-sdk/documentation/application-development-workflow/workflow-integrate.html#import-maven-dependency) tutorial.

Sample Code/app/build.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ android {
7676
dependencies {
7777
implementation 'androidx.multidex:multidex:2.0.0'
7878
implementation 'com.squareup:otto:1.3.8'
79-
implementation('com.dji:dji-sdk:4.14.1', {
79+
implementation('com.dji:dji-sdk:4.15', {
8080
/**
8181
* Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
8282
* Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
@@ -86,7 +86,7 @@ dependencies {
8686
exclude module: 'library-anti-distortion'
8787
//exclude module: 'fly-safe-database'
8888
})
89-
compileOnly 'com.dji:dji-sdk-provided:4.14.1'
89+
compileOnly 'com.dji:dji-sdk-provided:4.15'
9090

9191
implementation 'androidx.appcompat:appcompat:1.0.0'
9292
implementation 'androidx.core:core:1.0.0'
@@ -101,4 +101,12 @@ dependencies {
101101
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
102102
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
103103
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
104+
105+
implementation 'androidx.lifecycle:lifecycle-common-java8:2.3.1'
106+
implementation 'androidx.lifecycle:lifecycle-runtime:2.3.1'
107+
implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
108+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
109+
110+
implementation 'com.google.guava:guava:29.0-android'
111+
implementation 'org.apache.commons:commons-math3:3.6.1'
104112
}

Sample Code/app/proguard-rules.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858

5959
-keep class org.greenrobot.eventbus.**{*;}
6060

61+
-keep class it.sauronsoftware.ftp4j.**{*;}
62+
6163
-keepclasseswithmembers,allowshrinking class * {
6264
native <methods>;
6365
}
@@ -112,6 +114,8 @@
112114
-keep class android.arch.** { *; }
113115
-dontwarn android.arch.**
114116

117+
-keep class org.apache.commons.** {*;}
118+
115119

116120
#<------------ utmiss config start------------>
117121
-keep class dji.sdk.utmiss.** { *; }

Sample Code/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
android:label="@string/sample_app_name"
3434
android:supportsRtl="true"
3535
android:theme="@style/AppTheme"
36+
android:extractNativeLibs="true"
3637
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
3738

3839
<uses-library android:name="org.apache.http.legacy" android:required="false" />
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package com.dji.sdk.sample.demo.camera;
2+
3+
4+
import android.app.Service;
5+
import android.content.Context;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.widget.Button;
9+
import android.widget.RelativeLayout;
10+
import android.widget.TextView;
11+
12+
import androidx.annotation.NonNull;
13+
14+
import com.dji.sdk.sample.R;
15+
import com.dji.sdk.sample.internal.controller.DJISampleApplication;
16+
import com.dji.sdk.sample.internal.utils.ToastUtils;
17+
import com.dji.sdk.sample.internal.view.PresentableView;
18+
19+
import dji.common.camera.DJICameraCalibrateResult;
20+
import dji.common.camera.DJICameraCalibrateState;
21+
import dji.common.error.DJIError;
22+
import dji.common.util.CommonCallbacks;
23+
import dji.sdk.camera.Camera;
24+
25+
public class CameraCalibration extends RelativeLayout implements View.OnClickListener, PresentableView {
26+
private Button startCalibrationBtn;
27+
private Button stopCalibrationBtn;
28+
private Button calibrationInfinityBtn;
29+
private TextView calibrationState;
30+
private TextView calibrationResult;
31+
private Camera camera;
32+
public CameraCalibration(Context context){
33+
super(context);
34+
initUI(context);
35+
}
36+
37+
private void initUI(Context context) {
38+
setClickable(true);
39+
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
40+
41+
layoutInflater.inflate(R.layout.view_camera_calibration, this);
42+
43+
startCalibrationBtn = (Button) findViewById(R.id.btn_start_calibration);
44+
stopCalibrationBtn = (Button) findViewById(R.id.btn_stop_calibration);
45+
calibrationInfinityBtn = (Button) findViewById(R.id.btn_calibration_infinity_focus);
46+
calibrationState = findViewById(R.id.tv_camera_calibration_state);
47+
calibrationResult = findViewById(R.id.tv_camera_calibration_result);
48+
49+
startCalibrationBtn.setOnClickListener(this);
50+
stopCalibrationBtn.setOnClickListener(this);
51+
calibrationInfinityBtn.setOnClickListener(this);
52+
}
53+
54+
private void initCallBack(){
55+
camera.setCalibrationCallback(new Camera.CalibrationCallback() {
56+
@Override
57+
public void OnStateUpdate(DJICameraCalibrateState state) {
58+
ToastUtils.setResultToToast("Calibration State Change to: "+state);
59+
}
60+
61+
@Override
62+
public void OnResultUpdate(DJICameraCalibrateResult result) {
63+
ToastUtils.setResultToToast("Calibration Result Change to: "+result);
64+
}
65+
});
66+
}
67+
68+
@Override
69+
protected void onAttachedToWindow() {
70+
super.onAttachedToWindow();
71+
camera = DJISampleApplication.getAircraftInstance().getCamera();
72+
initCallBack();
73+
}
74+
75+
@Override
76+
public void onClick(View v) {
77+
switch (v.getId()){
78+
case R.id.btn_start_calibration:
79+
camera.startCalibration(new CommonCallbacks.CompletionCallback() {
80+
@Override
81+
public void onResult(DJIError djiError) {
82+
ToastUtils.setResultToToast(djiError == null ? "Start Success!" : djiError.getDescription());
83+
}
84+
});
85+
break;
86+
case R.id.btn_stop_calibration:
87+
camera.stopCalibration(new CommonCallbacks.CompletionCallback() {
88+
@Override
89+
public void onResult(DJIError djiError) {
90+
ToastUtils.setResultToToast(djiError == null ? "Stop Success!" : djiError.getDescription());
91+
}
92+
});
93+
break;
94+
case R.id.btn_calibration_infinity_focus:
95+
camera.calibratedInfinityFocus(new CommonCallbacks.CompletionCallback() {
96+
@Override
97+
public void onResult(DJIError djiError) {
98+
ToastUtils.setResultToToast(djiError == null ? "Success!" : djiError.getDescription());
99+
}
100+
});
101+
break;
102+
default:
103+
break;
104+
}
105+
}
106+
107+
@Override
108+
public int getDescription() {
109+
return 0;
110+
}
111+
112+
@NonNull
113+
@Override
114+
public String getHint() {
115+
return null;
116+
}
117+
}

Sample Code/app/src/main/java/com/dji/sdk/sample/demo/camera/LiveStreamView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import android.widget.EditText;
1111
import android.widget.LinearLayout;
1212

13-
import androidx.annotation.NonNull;
14-
1513
import com.dji.sdk.sample.R;
1614
import com.dji.sdk.sample.internal.controller.DJISampleApplication;
1715
import com.dji.sdk.sample.internal.utils.Helper;
@@ -23,6 +21,7 @@
2321
import java.util.Date;
2422
import java.util.Locale;
2523

24+
import androidx.annotation.NonNull;
2625
import dji.sdk.base.BaseProduct;
2726
import dji.sdk.camera.VideoFeeder;
2827
import dji.sdk.sdkmanager.DJISDKManager;

Sample Code/app/src/main/java/com/dji/sdk/sample/demo/camera/MultipleLensCameraView.kt

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import com.dji.sdk.sample.R
1111
import com.dji.sdk.sample.internal.controller.DJISampleApplication
1212
import com.dji.sdk.sample.internal.controller.MainActivity.RequestEndFullScreenEvent
1313
import com.dji.sdk.sample.internal.controller.MainActivity.RequestStartFullScreenEvent
14-
import com.dji.sdk.sample.internal.utils.Helper
15-
import com.dji.sdk.sample.internal.utils.PopupUtils
16-
import com.dji.sdk.sample.internal.utils.ToastUtils
17-
import com.dji.sdk.sample.internal.utils.VideoFeedView
14+
import com.dji.sdk.sample.internal.utils.*
1815
import com.dji.sdk.sample.internal.view.PresentableView
1916
import dji.common.airlink.PhysicalSource
2017
import dji.common.camera.CameraVideoStreamSource
@@ -71,7 +68,7 @@ class MultipleLensCameraView(context: Context) : LinearLayout(context), View.OnC
7168
val assignResult = error?.let {
7269
"assignSourceToPrimaryChannel fail, reason: ${error.description}."
7370
} ?: "assignSourceToPrimaryChannel success."
74-
Helper.showToast(context as Activity?, assignResult)
71+
ViewHelper.showToast(context as Activity?, assignResult)
7572
}
7673
}
7774

@@ -118,9 +115,9 @@ class MultipleLensCameraView(context: Context) : LinearLayout(context), View.OnC
118115
}
119116
}
120117
if (streamSources.isNotEmpty()) {
121-
PopupUtils.initPopupNumberPicker(Helper.makeList(streamSources), runSetCameraStreamSource, this)
118+
PopupUtils.initPopupNumberPicker(ViewHelper.makeList(streamSources), runSetCameraStreamSource, this)
122119
} else {
123-
Helper.showToast(context as Activity?, "Cannot load camera video stream source range.")
120+
ViewHelper.showToast(context as Activity?, "Cannot load camera video stream source range.")
124121
}
125122
}
126123
R.id.btn_laser_enabled -> {
@@ -132,7 +129,7 @@ class MultipleLensCameraView(context: Context) : LinearLayout(context), View.OnC
132129
}
133130
}
134131
if (laserEnabledArray.isNotEmpty()) {
135-
PopupUtils.initPopupNumberPicker(Helper.makeList(laserEnabledArray), runSetLaserEnabled, this)
132+
PopupUtils.initPopupNumberPicker(ViewHelper.makeList(laserEnabledArray), runSetLaserEnabled, this)
136133
}
137134
}
138135
R.id.btn_flat_camera_mode -> {
@@ -146,9 +143,9 @@ class MultipleLensCameraView(context: Context) : LinearLayout(context), View.OnC
146143
}
147144
}
148145
if (flatCameraModes.isNotEmpty()) {
149-
PopupUtils.initPopupNumberPicker(Helper.makeList(flatCameraModes), runSetFlatCameraMode, this)
146+
PopupUtils.initPopupNumberPicker(ViewHelper.makeList(flatCameraModes), runSetFlatCameraMode, this)
150147
} else {
151-
Helper.showToast(context as Activity?, "Cannot load flat camera mode.")
148+
ViewHelper.showToast(context as Activity?, "Cannot load flat camera mode.")
152149
}
153150
}
154151
R.id.btn_hybrid_zoom_spec -> {
@@ -159,11 +156,11 @@ class MultipleLensCameraView(context: Context) : LinearLayout(context), View.OnC
159156
KeyManager.getInstance().getValue(CameraKey.createLensKey(CameraKey.HYBRID_ZOOM_SPEC, 0, lensIndex), object : GetCallback {
160157
override fun onSuccess(any: Any) {
161158
val hybridZoomSpec = any as SettingsDefinitions.HybridZoomSpec
162-
Helper.showToast(context as Activity?, "Get Hybrid Zoom Spec: $hybridZoomSpec")
159+
ViewHelper.showToast(context as Activity?, "Get Hybrid Zoom Spec: $hybridZoomSpec")
163160
}
164161

165162
override fun onFailure(error: DJIError) {
166-
Helper.showToast(context as Activity?, "Get Hybrid Zoom Spec failed: ${error?.description}")
163+
ViewHelper.showToast(context as Activity?, "Get Hybrid Zoom Spec failed: ${error?.description}")
167164
}
168165
})
169166
}
@@ -174,11 +171,11 @@ class MultipleLensCameraView(context: Context) : LinearLayout(context), View.OnC
174171
val lensIndex: Int = CommonUtil.getLensIndex(0, SettingsDefinitions.LensType.INFRARED_THERMAL)
175172
KeyManager.getInstance().performAction(CameraKey.createLensKey(CameraKey.INFRARED_THERMAL_CAMERA_SHUTTER_ENABLED, 0, lensIndex), object : ActionCallback {
176173
override fun onSuccess() {
177-
Helper.showToast(context as Activity?, "Set Infrared Thermal Camera Shutter Enabled Success!")
174+
ViewHelper.showToast(context as Activity?, "Set Infrared Thermal Camera Shutter Enabled Success!")
178175
}
179176

180177
override fun onFailure(error: DJIError) {
181-
Helper.showToast(context as Activity?, "Set Infrared Thermal Camera Shutter Enabled failed: ${error.description}")
178+
ViewHelper.showToast(context as Activity?, "Set Infrared Thermal Camera Shutter Enabled failed: ${error.description}")
182179
}
183180
})
184181
}
@@ -195,23 +192,23 @@ class MultipleLensCameraView(context: Context) : LinearLayout(context), View.OnC
195192
private fun setVideoStreamSource(videoStreamSource: CameraVideoStreamSource) {
196193
KeyManager.getInstance().setValue(CameraKey.create(CameraKey.CAMERA_VIDEO_STREAM_SOURCE, 0), videoStreamSource, object : SetCallback {
197194
override fun onSuccess() {
198-
Helper.showToast(context as Activity?, "Set Video Stream Source: $videoStreamSource Success!")
195+
ViewHelper.showToast(context as Activity?, "Set Video Stream Source: $videoStreamSource Success!")
199196
}
200197

201198
override fun onFailure(error: DJIError) {
202-
Helper.showToast(context as Activity?, "Set Video Stream Source failed: ${error.description}")
199+
ViewHelper.showToast(context as Activity?, "Set Video Stream Source failed: ${error.description}")
203200
}
204201
})
205202
}
206203

207204
private fun setLaserEnabled(enabled: Boolean) {
208205
KeyManager.getInstance().setValue(CameraKey.create(CameraKey.LASER_ENABLED, 0), enabled, object : SetCallback {
209206
override fun onSuccess() {
210-
Helper.showToast(context as Activity?, "Set Laser Enabled: $enabled Success!")
207+
ViewHelper.showToast(context as Activity?, "Set Laser Enabled: $enabled Success!")
211208
}
212209

213210
override fun onFailure(error: DJIError) {
214-
Helper.showToast(context as Activity?, "Set Laser Enabled failed: ${error.description}")
211+
ViewHelper.showToast(context as Activity?, "Set Laser Enabled failed: ${error.description}")
215212
}
216213
})
217214
}
@@ -226,11 +223,11 @@ class MultipleLensCameraView(context: Context) : LinearLayout(context), View.OnC
226223
private fun setFlatCameraMode(flatCameraMode: SettingsDefinitions.FlatCameraMode) {
227224
KeyManager.getInstance().setValue(CameraKey.create(CameraKey.FLAT_CAMERA_MODE, 0), flatCameraMode, object : SetCallback {
228225
override fun onSuccess() {
229-
Helper.showToast(context as Activity?, "Set Flat Camera Mode: $flatCameraMode Success!")
226+
ViewHelper.showToast(context as Activity?, "Set Flat Camera Mode: $flatCameraMode Success!")
230227
}
231228

232229
override fun onFailure(error: DJIError) {
233-
Helper.showToast(context as Activity?, "Set Flat Camera Mode failed: ${error.description}")
230+
ViewHelper.showToast(context as Activity?, "Set Flat Camera Mode failed: ${error.description}")
234231
}
235232
})
236233
}

0 commit comments

Comments
 (0)