调试功能

chiyanzhen_branch
CYZ 2 years ago
parent e32124e9b3
commit e5a791765b

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\zqy04\.android\avd\Pixel_XL_API_31.avd" />
<type value="SERIAL_NUMBER" />
<value value="W3VBB21918206146" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-06-25T00:54:24.006491100Z" />
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-06-28T03:24:01.996639400Z" />
</component>
</project>

@ -1,5 +0,0 @@
C
java:S1604"(Make this anonymous inner class a lambda(ìäÔéùÿÿÿÿ
P
java:S1161":Add the "@Override" annotation above this method signature(¼²Á÷

@ -1,5 +0,0 @@
>
java:S1604"(Make this anonymous inner class a lambda(ʆ<C38A>õ
P
java:S1161":Add the "@Override" annotation above this method signature(¼²Á÷

@ -9,11 +9,7 @@ A
gradle.properties,2\a\2afbb999f001938c88fa43fc2ef52abf0f8213e4
k
;app/src/test/java/com/example/sixaunyi/ExampleUnitTest.java,8\9\892f839083a73d776402535dde27e522288853c9
i
9app/src/main/java/com/example/sixaunyi/FirstFragment.java,0\3\0336633037f72ee431c162e8d6cbc29d1cd6fa5d
?
settings.gradle,0\5\05efc8b1657769a27696d478ded1e95f38737233
j
:app/src/main/java/com/example/sixaunyi/SecondFragment.java,1\2\12963d86ac5c2888cc2a9ae459de5665bc06b01f
j
:app/src/main/java/com/example/sixaunyi/MapApplication.java,7\7\776a4b5f215e52628a4164ac15ef90fa338360ce
@
app/build.gradle,f\4\f4a01d6a4fcb971362ec00a83903fd3902f52164

@ -18,9 +18,9 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:icon="@drawable/app"
android:label="哨兵"
android:roundIcon="@drawable/app"
android:supportsRtl="true"
android:theme="@style/Theme.Sixaunyi.NoActionBar"
tools:targetApi="31">

@ -13,6 +13,7 @@ import android.content.Context;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.nfc.Tag;
@ -108,10 +109,11 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
//private ActivityResultLauncher<Intent> launcher;
////////////////////////////可修改部分/////////////////////////////
private final LatLng Monitorlatlng = new LatLng(28.258348849051746,113.04552182879037);
private final LatLng Monitorlatlng = new LatLng(28.257553,113.0417);
private final static String Recieve_IP = "192.168.39.46";
private final static int RECEIVE_PORT = 9987;
private final static String SEND_to_IP = "192.168.39.47";
private final static int RECEIVE_PORT = 9975;
private final static String SEND_to_IP = "192.168.39.195";
private final static int SEND_PORT = 8888;
/////////////////////////////////////////////////////////////////
private InetAddress serverAddr;
@ -126,6 +128,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState != null) {
// 从保存的状态数据中恢复状态
value = savedInstanceState.getString("key");
@ -145,9 +148,10 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
//检查安卓版本
checkingAndroidVersion();
udpReceiveThread = new UdpReceiveThread();
udpReceiveThread.startListening();
addSensorMarker(Monitorlatlng);
}
/**
* Android
@ -248,7 +252,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
// 设置为true表示显示定位层并可触发定位false表示隐藏定位层并不可触发定位默认是false
aMap.setMyLocationEnabled(true);
//设置最小缩放等级为16 ,缩放级别范围为[3, 20]
aMap.setMinZoomLevel(18);
aMap.setMinZoomLevel(14);
//设置地图标志点击事件
aMap.setOnMarkerClickListener(this);
//设置地图标志拖拽事件
@ -302,7 +306,10 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
city = aMapLocation.getCity();
//当前位置经纬度坐标
Current_latlng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
MonitorDistance = AMapUtils.calculateLineDistance(Current_latlng,Monitorlatlng);
Log.i(TAG, String.valueOf(Current_latlng.longitude));
Log.i(TAG, String.valueOf(Current_latlng.latitude));
//
//获取纬度
double latitude = aMapLocation.getLatitude();
//获取经度
@ -310,6 +317,8 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
Log.d("MainActivity", aMapLocation.getCity());
showMsg(address);
udpReceiveThread = new UdpReceiveThread();
udpReceiveThread.startListening();
//停止定位后,本地定位服务并不会被销毁
mLocationClient.stopLocation();
if (mListener != null) {
@ -391,7 +400,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
.draggable(true)
//标点图标
.icon(BitmapDescriptorFactory.
fromBitmap(BitmapFactory.decodeResource(getResources(),R.drawable.img)))
fromBitmap(BitmapFactory.decodeResource(getResources(),R.drawable.weizhi)))
//备注
.title("路径点")
.snippet("距离:")
@ -435,7 +444,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.drone)))
// 备注
.title("无人机")
.snippet("距离:")
);
droneMarker.showInfoWindow();
}
@ -631,14 +640,32 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
}
class ReceiveHandler extends Handler{
@Override
public void handleMessage(Message msg) {
if (msg.what == 1) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Context context = MainActivity.this;
showAlert(context,"传感器报警");
addDroneMarker();
moveDrone();
}
});
}
}
}
public class UdpReceiveThread extends Thread {
private static final String TAG = "UdpReceiveThread";
private static final int mRECEIVE_PORT = RECEIVE_PORT;
private boolean mRunning;
private boolean mRunning = true;
private String mReceiveIp = Recieve_IP;
private String mExpectedData = "Motion detected!";
private float udpMonitorDistance = MonitorDistance;
private String udpMonitorAngle = MonitorAngle;
private Handler receiveHandler = new ReceiveHandler();
@Override
public void run() {
@ -654,11 +681,9 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
Log.d(TAG, "Received data: " + receivedString);
if (receivedString.equals(mExpectedData)) {
Log.i(TAG, "run: 222222222222222222222222222");
receiveHandler.sendEmptyMessage(1);
sendCommand("WARNING "+String.valueOf(udpMonitorDistance)+" "+udpMonitorAngle);
Context context = MainActivity.this;
showAlert(context,"传感器报警");
addDroneMarker();
moveDrone();
mRunning = false;
@ -672,6 +697,16 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
e.printStackTrace();
}
}
public void startListening() {
mRunning = true;
start();
}
public void stopListening() {
mRunning = false;
}
}
public void showAlert(Context context, String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("警告");
@ -683,16 +718,6 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
dialog.show();
}
public void startListening() {
mRunning = true;
start();
}
public void stopListening() {
mRunning = false;
}
}
//以北为0度
public static String calcAngle(Double centerLat, Double centerLon, Double anotherLat, Double anotherLon) {
//差值

@ -37,13 +37,15 @@ public class SettingActivity extends AppCompatActivity {
private final static String SEND_to_IP = "192.168.39.47";
private SeekBar Speed_btn;
private Switch Battery_btn;
private SeekBar Battery_btn;
private ImageButton return_btn;
private final static int SEND_PORT = 8888;
private ExecutorService mThreadPool = Executors.newCachedThreadPool();
private Switch photo_btn;
private Context context;
private SharedPreferences sharedPreferences;
private TextView tvProgress;
private TextView Battery_warning;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -51,8 +53,9 @@ public class SettingActivity extends AppCompatActivity {
Speed_btn= findViewById(R.id.speed);
return_btn=findViewById(R.id.returns);
photo_btn = findViewById(R.id.photo);
Battery_btn = findViewById(R.id.Battery_warning);
TextView tvProgress = (TextView) findViewById(R.id.tvProgress);
Battery_btn = findViewById(R.id.warning_num);
tvProgress = findViewById(R.id.tvProgress);
Battery_warning=findViewById(R.id.Battery_warning);
sharedPreferences = getSharedPreferences("control_state", MODE_PRIVATE);
boolean photo_btn_state= sharedPreferences.getBoolean("photo_btn_state", false);
photo_btn.setChecked(photo_btn_state);
@ -60,6 +63,9 @@ public class SettingActivity extends AppCompatActivity {
int speedProgress = sharedPreferences.getInt("speed_progress", 0);
Speed_btn.setProgress(speedProgress);
tvProgress.setText(String.valueOf(speedProgress+10));
int warning_num= sharedPreferences.getInt("battery_num", 0);
Battery_btn.setProgress(warning_num);
Battery_warning.setText(String.valueOf(warning_num));
photo_btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -80,11 +86,9 @@ public class SettingActivity extends AppCompatActivity {
} catch (UnknownHostException e) {
e.printStackTrace();
}
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt("speed_progress", progress);
editor.apply();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@ -93,30 +97,25 @@ public class SettingActivity extends AppCompatActivity {
public void onStopTrackingTouch(SeekBar seekBar) {}
});
Battery_btn.setOnClickListener(new View.OnClickListener() {
Battery_btn.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onClick(View v) {
if (Battery_btn.isChecked()) {
try {
sendCommand("battery_warning");
} catch (UnknownHostException e) {
e.printStackTrace();
}
}else
{
try {
sendCommand("warning_cancel");
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
Battery_warning.setText(String.valueOf(progress));
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt("battery_num", progress);
editor.apply();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
return_btn.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Intent intent = new Intent(SettingActivity.this, VideoActivity.class);
// 启动目标 Activity
finish();
passingParameters();
}
});
photo_btn.setOnClickListener(new View.OnClickListener() {
@ -124,14 +123,14 @@ public class SettingActivity extends AppCompatActivity {
public void onClick(View v) {
if (photo_btn.isChecked()) {
try {
sendCommand("photo_high");
sendCommand("PHOTO_HIGH");
} catch (UnknownHostException e) {
e.printStackTrace();
}
}else
{
try {
sendCommand("photo_low");
sendCommand("PHOTO_LOW");
} catch (UnknownHostException e) {
e.printStackTrace();
}
@ -177,5 +176,19 @@ public class SettingActivity extends AppCompatActivity {
mThreadPool.execute(sendRunnable1);
}
@Override
public void onBackPressed() {
// 在这里处理返回事件的逻辑
super.onBackPressed(); // 调用父类的方法,执行默认的返回操作
passingParameters();
}
private void passingParameters(){
int warning_num= sharedPreferences.getInt("battery_num", 0);
Log.i(TAG, "111111111111111111111"+String.valueOf(warning_num));
Intent intent = new Intent(SettingActivity.this,VideoActivity.class);
intent.putExtra("BATTERY_NUM", warning_num); // 设置要传递的参数
setResult(RESULT_OK, intent);
finish();
}
}

@ -64,8 +64,8 @@ import android.widget.ToggleButton;
public class VideoActivity extends AppCompatActivity {
private final static String SEND_to_IP = "192.168.39.47"; //填写接收方IP
private final static String Recieve_IP = "192.168.39.47";//填服务器IP与send_to_IP为同一个
private final static String SEND_to_IP = "192.168.39.195"; //填写接收方IP
private final static String Recieve_IP = "192.168.39.195";//填服务器IP与send_to_IP为同一个
private final static int SEND_PORT = 8888; //发送端口号
private final static int RECEIVE_PORT = 9999; //接收端口号
private static boolean listenStatus = true; //接收线程的循环标识

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -26,14 +26,37 @@
android:scaleType="centerInside"
app:srcCompat="@drawable/returns" />
<Switch
android:id="@+id/Battery_warning"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:background="@drawable/txt_radiuborder">
<TextView
android:layout_width="150dp"
android:layout_height="50dp"
android:text="电量预警"
android:textColor="@color/white"
android:textSize="28dp"
android:background="@drawable/txt_radiuborder"/>
android:textSize="28dp" />
<SeekBar
android:id="@+id/warning_num"
android:layout_width="180dp"
android:layout_height="50dp"
android:max="100"
android:progress="0"
android:thumbTint='@color/teal_200' />
<TextView
android:id="@+id/Battery_warning"
android:layout_width="77dp"
android:layout_height="30dp"
android:text="0"
android:textColor="@color/white"
android:textSize="18dp" />
</LinearLayout>
<Switch
android:id="@+id/photo"

Loading…
Cancel
Save