+3
-1
@@ -88,7 +88,7 @@ android {
|
||||
|
||||
// We need to be restrict as we get error on newer versions...
|
||||
buildToolsVersion '30.0.2'
|
||||
ndkVersion '20.1.5948944'
|
||||
ndkVersion '22.0.7026061'
|
||||
|
||||
}
|
||||
dependencies {
|
||||
@@ -133,6 +133,8 @@ dependencies {
|
||||
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
|
||||
implementation 'com.google.android.gms:play-services-location:17.1.0'
|
||||
|
||||
implementation 'com.google.maps:google-maps-services:0.15.0'
|
||||
|
||||
implementation 'com.jakewharton:butterknife:10.2.3'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
|
||||
@@ -72,7 +72,6 @@
|
||||
|
||||
<activity android:name="sq.rogue.rosettadrone.MainActivity">
|
||||
<intent-filter>
|
||||
<!-- <action android:name="android.intent.action.MAIN" /> -->
|
||||
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
@@ -116,7 +115,7 @@
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="AIzaSyAO1eIAc6cCYdO74LBd8fmMNzs7sabxW5E" />
|
||||
android:value="@string/google_key" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
|
||||
@@ -3,22 +3,18 @@ package sq.rogue.rosettadrone;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -35,22 +31,13 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import dji.common.error.DJIError;
|
||||
import dji.common.error.DJISDKError;
|
||||
import dji.common.useraccount.UserAccountState;
|
||||
import dji.common.util.CommonCallbacks;
|
||||
import dji.keysdk.DJIKey;
|
||||
import dji.keysdk.KeyManager;
|
||||
import dji.keysdk.ProductKey;
|
||||
import dji.keysdk.callback.KeyListener;
|
||||
import dji.log.DJILog;
|
||||
import dji.sdk.base.BaseComponent;
|
||||
import dji.sdk.base.BaseProduct;
|
||||
import dji.sdk.products.Aircraft;
|
||||
import dji.sdk.sdkmanager.DJISDKInitEvent;
|
||||
import dji.sdk.sdkmanager.DJISDKManager;
|
||||
import dji.sdk.useraccount.UserAccountManager;
|
||||
import sq.rogue.rosettadrone.video.VideoService;
|
||||
|
||||
public class ConnectionActivity extends Activity implements View.OnClickListener {
|
||||
|
||||
@@ -156,113 +143,7 @@ public class ConnectionActivity extends Activity implements View.OnClickListener
|
||||
Toast.makeText(getApplicationContext(), "Missing permissions!!!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void startSDKRegistration() {
|
||||
Log.d(TAG, "startSDKRegistration");
|
||||
if (isRegistrationInProgress.compareAndSet(false, true)) {
|
||||
Log.d(TAG, "startSDKRegistration started");
|
||||
AsyncTask.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DJISDKManager.getInstance().registerApp(ConnectionActivity.this.getApplicationContext(), new DJISDKManager.SDKManagerCallback() {
|
||||
@Override
|
||||
public void onRegister(DJIError djiError) {
|
||||
if (djiError == DJISDKError.REGISTRATION_SUCCESS) {
|
||||
DJILog.v("App registration", DJISDKError.REGISTRATION_SUCCESS.getDescription());
|
||||
DJISDKManager.getInstance().startConnectionToProduct();
|
||||
showToast("Register SDK Success");
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loginDJIUserAccount();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showToast("Register sdk fails, check network is available");
|
||||
}
|
||||
Log.v(TAG, djiError.getDescription());
|
||||
isRegistrationInProgress.set(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProductDisconnect() {
|
||||
showToast("Product Disconnected");
|
||||
notifyStatusChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProductConnect(BaseProduct baseProduct) {
|
||||
Log.e(TAG, "Product Connected");
|
||||
|
||||
notifyStatusChange();
|
||||
isRegistrationInProgress.set(false);
|
||||
updateVersion();
|
||||
if (baseProduct != null) {
|
||||
// RDApplication.updateProduct(baseProduct);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProductChanged(BaseProduct baseProduct) {
|
||||
Log.e(TAG, "Product Changed");
|
||||
|
||||
notifyStatusChange();
|
||||
isRegistrationInProgress.set(false);
|
||||
updateVersion();
|
||||
if (baseProduct != null) {
|
||||
// RDApplication.updateProduct(baseProduct);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComponentChange(BaseProduct.ComponentKey componentKey,
|
||||
BaseComponent oldComponent,
|
||||
BaseComponent newComponent) {
|
||||
if (newComponent != null && oldComponent == null) {
|
||||
Log.v(TAG, componentKey.name() + " Component Found index:" + newComponent.getIndex());
|
||||
}
|
||||
if (newComponent != null) {
|
||||
newComponent.setComponentListener(new BaseComponent.ComponentListener() {
|
||||
@Override
|
||||
public void onConnectivityChange(boolean b) {
|
||||
Log.v(TAG, " Component " + (b ? "connected" : "disconnected"));
|
||||
notifyStatusChange();
|
||||
}
|
||||
});
|
||||
}
|
||||
notifyStatusChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitProcess(DJISDKInitEvent djisdkInitEvent, int i) {
|
||||
//notify the init progress
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseDownloadProgress(long l, long l1) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void loginDJIUserAccount() {
|
||||
|
||||
UserAccountManager.getInstance().logIntoDJIUserAccount(this,
|
||||
new CommonCallbacks.CompletionCallbackWith<UserAccountState>() {
|
||||
@Override
|
||||
public void onSuccess(final UserAccountState userAccountState) {
|
||||
showToast("login success! Account state is:" + userAccountState.name());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(DJIError error) {
|
||||
showToast(error.getDescription());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void notifyStatusChange() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,6 @@ import android.content.res.AssetManager;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.media.MediaFormat;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
@@ -45,13 +44,15 @@ import android.widget.Toast;
|
||||
import com.MAVLink.MAVLinkPacket;
|
||||
import com.MAVLink.Messages.MAVLinkMessage;
|
||||
import com.MAVLink.Parser;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.MapView;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
@@ -70,7 +71,6 @@ import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
@@ -106,10 +106,8 @@ import sq.rogue.rosettadrone.video.VideoService;
|
||||
import static com.google.android.material.snackbar.Snackbar.LENGTH_LONG;
|
||||
import static sq.rogue.rosettadrone.util.safeSleep;
|
||||
|
||||
// import sq.rogue.rosettadrone.settings.Waypoint1Activity;
|
||||
// import sq.rogue.rosettadrone.settings.Waypoint2Activity;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
//public class MainActivity extends AppCompatActivity implements OnMapReadyCallback, GoogleMap.OnMapClickListener {
|
||||
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
|
||||
// public static final String FLAG_CONNECTION_CHANGE = "dji_sdk_connection_change";
|
||||
private final static int RESULT_SETTINGS = 1001;
|
||||
@@ -129,13 +127,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
public static boolean FLAG_DRONE_LANDING_PROTECTION_CHANGED = false;
|
||||
public static boolean FLAG_DRONE_FLIGHT_PATH_MODE_CHANGED = false;
|
||||
public static boolean FLAG_DRONE_MAX_HEIGHT_CHANGED = false;
|
||||
public static boolean FLAG_APP_NAME_CHANGED = false;
|
||||
public static boolean FLAG_MAPS_CHANGED = false;
|
||||
|
||||
// private com.google.android.gms.maps.SupportMapFragment mapView;
|
||||
private MapView mapView;
|
||||
private AMap aMap;
|
||||
private GoogleMap aMap;
|
||||
private double droneLocationLat, droneLocationLng;
|
||||
private Marker droneMarker = null;
|
||||
// private FlightController mFlightController;
|
||||
|
||||
private static BaseProduct mProduct;
|
||||
private Model mProductModel;
|
||||
@@ -171,6 +168,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private VideoService mService = null;
|
||||
private boolean mIsBound;
|
||||
private int m_videoMode = 1;
|
||||
private int mMaptype = GoogleMap.MAP_TYPE_HYBRID;
|
||||
|
||||
private VideoFeeder.VideoFeed standardVideoFeeder;
|
||||
protected VideoFeeder.VideoDataListener mReceivedVideoDataListener;
|
||||
@@ -195,7 +193,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (!gui_enabled) {
|
||||
try {
|
||||
if (!mNewDJI.equals("")) {
|
||||
@@ -206,7 +203,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (!mNewOutbound.equals("")) {
|
||||
// ((LogFragment) logPagerAdapter.getItem(1)).appendLogText(mNewOutbound);
|
||||
logOutbound.appendLogText(mNewOutbound);
|
||||
|
||||
mNewOutbound = "";
|
||||
}
|
||||
if (!mNewInbound.equals("")) {
|
||||
@@ -214,7 +210,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
logInbound.appendLogText(mNewInbound);
|
||||
mNewInbound = "";
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "exception", e);
|
||||
}
|
||||
@@ -226,7 +221,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private void initPacketizer() {
|
||||
Log.e(TAG, "initPacketizer");
|
||||
|
||||
String address = "127.0.0.1";
|
||||
|
||||
sharedPreferences = android.preference.PreferenceManager.getDefaultSharedPreferences(this);
|
||||
@@ -239,19 +233,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
} else if (sharedPreferences.getBoolean("pref_separate_gcs", false)) {
|
||||
address = sharedPreferences.getString("pref_video_ip", "127.0.0.1");
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
mvideoIPString = address;
|
||||
|
||||
// address.replace("/","");
|
||||
Log.e(TAG, "Ip Address: " + mvideoIPString);
|
||||
//------------------------------------------------------------
|
||||
|
||||
videoPort = Integer.parseInt(Objects.requireNonNull(sharedPreferences.getString("pref_video_port", "5600")));
|
||||
mVideoBitrate = Integer.parseInt(Objects.requireNonNull(sharedPreferences.getString("pref_video_bitrate", "2")));
|
||||
mEncodeSpeed = Integer.parseInt(Objects.requireNonNull(sharedPreferences.getString("pref_encode_speed", "2")));
|
||||
|
||||
//------------------------------------------------------------
|
||||
mMaptype = Integer.parseInt(Objects.requireNonNull(prefs.getString("pref_maptype_mode", "2")));
|
||||
logMessageDJI("Mapmode: " + mMaptype);
|
||||
//------------------------------------------------------------
|
||||
|
||||
Intent intent = new Intent(this, VideoService.class);
|
||||
@@ -323,6 +314,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Log.e(TAG, "onResume()");
|
||||
super.onResume();
|
||||
|
||||
setDroneParameters();
|
||||
/*
|
||||
if (mDroneDetails != null) {
|
||||
String droneID = prefs.getString("pref_drone_id", "1");
|
||||
@@ -337,7 +329,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
// String text = "ID:" + "\t" + droneID + System.getProperty("line.separator") + "RTL:" + "\t" + rtlAlt;
|
||||
mDroneDetails.setText(text);
|
||||
}
|
||||
|
||||
*/
|
||||
if (prefs.getBoolean("pref_enable_video", true)) {
|
||||
mExternalVideoOut = true;
|
||||
@@ -345,6 +336,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
mExternalVideoOut = false;
|
||||
}
|
||||
|
||||
// Wew should rather use multicast...
|
||||
if (mService != null) {
|
||||
if (prefs.getBoolean("pref_enable_dualvideo", true)) {
|
||||
mService.setDualVideo(true);
|
||||
@@ -450,35 +442,68 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
//Intent intent = getIntent();
|
||||
finish();
|
||||
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
|
||||
private void initMapView() {
|
||||
Log.d(TAG, "onMapReady()");
|
||||
|
||||
if (aMap == null) {
|
||||
aMap = mapView.getMap();
|
||||
//aMap.setOnMapClickListener(this);// add the listener for click for amap object
|
||||
aMap = googleMap;
|
||||
LinearLayout map_layout = findViewById(R.id.map_view);
|
||||
map_layout.setClickable(true);
|
||||
map_layout.setOnClickListener((map) -> {
|
||||
ViewGroup.LayoutParams map_para = map_layout.getLayoutParams();
|
||||
map_layout.setZ(0.f);
|
||||
map_para.height = LayoutParams.WRAP_CONTENT;
|
||||
map_para.width = LayoutParams.WRAP_CONTENT;
|
||||
map_layout.setLayoutParams(map_para);
|
||||
});
|
||||
}
|
||||
|
||||
// We initialize the default map location to the same as the default SIM location...
|
||||
LatLng coordinate;
|
||||
|
||||
if (checkGpsCoordination(droneLocationLat, droneLocationLng)) {
|
||||
coordinate = new LatLng(droneLocationLat, droneLocationLng);
|
||||
}
|
||||
else{
|
||||
LocationCoordinate2D pos = mModel.getSimPos2D();
|
||||
coordinate = new LatLng(pos.getLatitude(), pos.getLongitude());
|
||||
}
|
||||
// aMap.addMarker(new MarkerOptions().position(coordinate).title("Marker in Shenzhen"));
|
||||
aMap.addMarker(new MarkerOptions().position(coordinate));
|
||||
|
||||
|
||||
aMap.getUiSettings().setZoomControlsEnabled(false);
|
||||
aMap.moveCamera(CameraUpdateFactory.newLatLng(coordinate));
|
||||
aMap.setMapType(mMaptype);
|
||||
|
||||
updateDroneLocation();
|
||||
}
|
||||
|
||||
// Update the drone location based on states from MCU.
|
||||
private void updateDroneLocation() {
|
||||
|
||||
if (aMap != null) {
|
||||
|
||||
// We initialize the default map location to the same as the default SIM location...
|
||||
LatLng pos;
|
||||
|
||||
if (checkGpsCoordination(droneLocationLat, droneLocationLng)) {
|
||||
pos = new LatLng(droneLocationLat, droneLocationLng);
|
||||
} else {
|
||||
LocationCoordinate2D loc = mModel.getSimPos2D();
|
||||
if(checkGpsCoordination(loc.getLongitude(),loc.getLongitude())) {
|
||||
pos = new LatLng(loc.getLatitude(), loc.getLongitude());
|
||||
}
|
||||
else{
|
||||
pos = new LatLng(62,12);
|
||||
}
|
||||
}
|
||||
|
||||
//Create MarkerOptions object
|
||||
final MarkerOptions markerOptions = new MarkerOptions();
|
||||
markerOptions.position(pos);
|
||||
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.aircraft));
|
||||
|
||||
runOnUiThread(() -> {
|
||||
if (droneMarker != null) {
|
||||
droneMarker.remove();
|
||||
}
|
||||
|
||||
if (checkGpsCoordination(pos.latitude, pos.longitude)) {
|
||||
droneMarker = aMap.addMarker(markerOptions);
|
||||
aMap.moveCamera(CameraUpdateFactory.newLatLng(pos));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void initFlightController() {
|
||||
@@ -498,28 +523,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
return (latitude > -90 && latitude < 90 && longitude > -180 && longitude < 180) && (latitude != 0f && longitude != 0f);
|
||||
}
|
||||
|
||||
private void updateDroneLocation() {
|
||||
|
||||
LatLng pos = new LatLng(droneLocationLat, droneLocationLng);
|
||||
|
||||
//Create MarkerOptions object
|
||||
final MarkerOptions markerOptions = new MarkerOptions();
|
||||
markerOptions.position(pos);
|
||||
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.aircraft));
|
||||
|
||||
runOnUiThread(() -> {
|
||||
if (droneMarker != null) {
|
||||
droneMarker.remove();
|
||||
}
|
||||
|
||||
// setResultToToast(droneLocationLat+"----"+droneLocationLng);
|
||||
if (checkGpsCoordination(droneLocationLat, droneLocationLng)) {
|
||||
// setResultToToast("小飞机标识");
|
||||
droneMarker = aMap.addMarker(markerOptions);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.e(TAG, "onCreate()");
|
||||
@@ -587,10 +590,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
initLogs();
|
||||
initPacketizer();
|
||||
|
||||
mapView = (MapView) findViewById(R.id.map);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(this);
|
||||
|
||||
initMapView();
|
||||
initFlightController();
|
||||
|
||||
DJISDKManager.getInstance().registerApp(this, mDJISDKManagerCallback);
|
||||
@@ -789,8 +792,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
* Init a fake texture view to for the codec manager, so that the video raw data can be received
|
||||
* by the camera needed to get video to the UDP handler...
|
||||
*/
|
||||
// private void initPreviewerTextureView() {
|
||||
// Log.e(TAG, "initPreviewerTextureView");
|
||||
|
||||
private TextureView.SurfaceTextureListener mSurfaceTextureListener = new TextureView.SurfaceTextureListener() {
|
||||
@Override
|
||||
@@ -901,7 +902,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
notifyStatusChange();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onComponentChange(BaseProduct.ComponentKey componentKey, BaseComponent oldComponent, BaseComponent newComponent) {
|
||||
if (newComponent != null) {
|
||||
@@ -1239,6 +1239,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
// Hmm is this ever called...
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
// AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
@@ -1295,7 +1296,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onClickClearLogs() {
|
||||
logDJI.clearLogText();
|
||||
logOutbound.clearLogText();
|
||||
@@ -1425,18 +1425,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
mNewDJI += "\n" + msg;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void sendRestartVideoService() {
|
||||
String videoIP = getVideoIP();
|
||||
int videoPort = Integer.parseInt(Objects.requireNonNull(prefs.getString("pref_video_port", "5600")));
|
||||
logMessageDJI("Restarting Video link to " + videoIP + ":" + videoPort);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void sendDroneConnected() {
|
||||
String videoIP = getVideoIP();
|
||||
|
||||
@@ -1462,9 +1456,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void sendDroneDisconnected() {
|
||||
|
||||
}
|
||||
@@ -1539,6 +1530,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
FLAG_DRONE_LANDING_PROTECTION_CHANGED = false;
|
||||
}
|
||||
|
||||
if(FLAG_MAPS_CHANGED){
|
||||
mMaptype = Integer.parseInt(Objects.requireNonNull(prefs.getString("pref_maptype_mode", "0")));
|
||||
aMap.setMapType(mMaptype);
|
||||
FLAG_MAPS_CHANGED = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
@@ -1560,6 +1557,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Log.e(TAG, "onPointerCaptureChanged");
|
||||
}
|
||||
|
||||
|
||||
//region GCS Timer Task
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1578,7 +1576,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class GCSCommunicatorAsyncTask extends AsyncTask<Integer, Integer, Integer> {
|
||||
|
||||
private static final String TAG = GCSSenderTimerTask.class.getSimpleName();
|
||||
|
||||
@@ -190,17 +190,9 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
||||
findPreference("pref_app_name").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
try {
|
||||
if (Integer.parseInt((String) newValue) >= 1 && Integer.parseInt((String) newValue) <= 65535) {
|
||||
MainActivity.FLAG_PREFS_CHANGED = true;
|
||||
MainActivity.FLAG_VIDEO_ADDRESS_CHANGED = true;
|
||||
return true;
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
NotificationHandler.notifyAlert(SettingsFragment.this.getActivity(), TYPE_APP_NAME,
|
||||
null, null);
|
||||
return false;
|
||||
MainActivity.FLAG_PREFS_CHANGED = true;
|
||||
MainActivity.FLAG_APP_NAME_CHANGED = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -579,8 +579,8 @@ public class Waypoint1Activity extends FragmentActivity implements View.OnClickL
|
||||
setUpMap();
|
||||
}
|
||||
|
||||
LatLng shenzhen = new LatLng(22.5362, 113.9454);
|
||||
gMap.addMarker(new MarkerOptions().position(shenzhen).title("Marker in Shenzhen"));
|
||||
LatLng shenzhen = new LatLng(62.5362, 12.9454);
|
||||
gMap.addMarker(new MarkerOptions().position(shenzhen).title("Marker in Norway"));
|
||||
gMap.moveCamera(CameraUpdateFactory.newLatLng(shenzhen));
|
||||
}
|
||||
|
||||
|
||||
@@ -786,7 +786,9 @@ public class Waypoint2Activity extends FragmentActivity implements View.OnClickL
|
||||
initMapView();
|
||||
}
|
||||
|
||||
// gMap.addMarker(new MarkerOptions().position(shenzhen).title("Marker in Shenzhen"));
|
||||
// gMap.moveCamera(CameraUpdateFactory.newLatLng(shenzhen));
|
||||
LatLng shenzhen = new LatLng(62.5362, 12.9454);
|
||||
gMap.addMarker(new MarkerOptions().position(shenzhen).title("Marker in Norway"));
|
||||
gMap.moveCamera(CameraUpdateFactory.newLatLng(shenzhen));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package sq.rogue.rosettadrone.settings.drone;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -196,7 +197,14 @@ public class DroneSettingsFragment extends PreferenceFragmentCompat implements S
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
findPreference("pref_maptype_mode").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
MainActivity.FLAG_PREFS_CHANGED = true;
|
||||
MainActivity.FLAG_MAPS_CHANGED = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
findPreference("pref_drone_collision_avoidance").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
|
||||
@@ -45,11 +45,14 @@ public class RtpSocket implements Runnable {
|
||||
* Use this to use UDP for the transport protocol.
|
||||
*/
|
||||
public final static int TRANSPORT_UDP = 0x00;
|
||||
|
||||
/**
|
||||
* Use this to use TCP for the transport protocol.
|
||||
*/
|
||||
public final static int TRANSPORT_TCP = 0x01;
|
||||
/**
|
||||
* Use this to use UDP MULTICAST for the transport protocol.
|
||||
*/
|
||||
public final static int TRANSPORT_MULTICAST = 0x02;
|
||||
|
||||
public static final int RTP_HEADER_LENGTH = 12;
|
||||
public static final int MTU = 1300;
|
||||
@@ -199,7 +202,11 @@ public class RtpSocket implements Runnable {
|
||||
*/
|
||||
public void setDestination(InetAddress dest, int dport, int rtcpPort) {
|
||||
if (dport != 0 && rtcpPort != 0) {
|
||||
mTransport = TRANSPORT_UDP;
|
||||
if(dest.isMulticastAddress()) {
|
||||
mTransport = TRANSPORT_MULTICAST;
|
||||
}else {
|
||||
mTransport = TRANSPORT_UDP;
|
||||
}
|
||||
mPort = dport;
|
||||
Log.d(TAG, "setDestination: " + dest + ":" + dport);
|
||||
for (int i = 0; i < mBufferCount; i++) {
|
||||
@@ -230,10 +237,9 @@ public class RtpSocket implements Runnable {
|
||||
|
||||
public int[] getLocalPorts() {
|
||||
return new int[]{
|
||||
mSocket.getLocalPort(),
|
||||
mSocketUDP.getLocalPort(),
|
||||
mSocketUDP2.getLocalPort(),
|
||||
// mSocket.getLocalPort(),
|
||||
//mReport.getLocalPort()
|
||||
};
|
||||
|
||||
}
|
||||
@@ -357,7 +363,10 @@ public class RtpSocket implements Runnable {
|
||||
} else {
|
||||
mSocketUDP.send(mPackets[mBufferOut]);
|
||||
}
|
||||
} else {
|
||||
} else if (mTransport == TRANSPORT_MULTICAST) {
|
||||
mSocket.send(mPackets[mBufferOut]);
|
||||
}
|
||||
else {
|
||||
sendTCP();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,18 +68,27 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
|
||||
<com.amap.api.maps.MapView
|
||||
<fragment
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
class="com.google.android.gms.maps.SupportMapFragment" />
|
||||
|
||||
<!--
|
||||
<com.google.android.gms.maps.MapView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
-->
|
||||
<!--
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
-->
|
||||
</LinearLayout>
|
||||
<!--
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/compass_container"
|
||||
android:layout_width="510dp"
|
||||
@@ -101,7 +110,7 @@
|
||||
tools:ignore="RtlHardcoded" />
|
||||
</FrameLayout>
|
||||
|
||||
<!--
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/tab_map_video"
|
||||
android:layout_width="164dp"
|
||||
@@ -116,7 +125,7 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
</FrameLayout>
|
||||
-->
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@@ -32,6 +32,26 @@
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Map Types -->
|
||||
<string name="pref_maptype_mode">Select map type</string>
|
||||
<string name="pref_maptype">Maps</string>
|
||||
|
||||
<string-array name="maptype_array">
|
||||
<item>Normal</item>
|
||||
<item>Hybrid</item>
|
||||
<item>Satellite</item>
|
||||
<item>Terrain</item>
|
||||
<item>None</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="maptypet_values_array">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Drone Safety -->
|
||||
<string name="pref_drone_safety_cat">Safety</string>
|
||||
<string name="pref_drone_multi_mode">Enable multiple flight modes</string>
|
||||
|
||||
@@ -30,6 +30,28 @@
|
||||
android:defaultValue="true" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="drone_maptype_prefs"
|
||||
android:title="@string/pref_maptype_mode">
|
||||
|
||||
<androidx.preference.ListPreference
|
||||
android:key="pref_maptype_mode"
|
||||
android:title="@string/pref_maptype"
|
||||
android:entries="@array/maptype_array"
|
||||
android:entryValues="@array/maptypet_values_array"
|
||||
android:defaultValue="2" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="drone_name_prefs"
|
||||
android:title="App Name">
|
||||
|
||||
<androidx.preference.EditTextPreference
|
||||
android:defaultValue="RosettaDrone 2"
|
||||
android:key="pref_app_name"
|
||||
android:title="@string/pref_app" />
|
||||
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="drone_heading_prefs"
|
||||
android:title="@string/pref_drone_heading_cat">
|
||||
@@ -42,17 +64,6 @@
|
||||
android:defaultValue="0"
|
||||
android:enabled="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="drone_name_prefs"
|
||||
android:title="App Name">
|
||||
|
||||
<androidx.preference.EditTextPreference
|
||||
android:defaultValue=" "
|
||||
android:key="pref_app_name"
|
||||
android:title="@string/pref_app" />
|
||||
|
||||
</PreferenceCategory>
|
||||
v
|
||||
<PreferenceCategory
|
||||
android:key="sim_pos_prefs"
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário