diff --git a/app/src/main/java/com/example/longyi_groundstation/Login/Activity/LoginActivity.java b/app/src/main/java/com/example/longyi_groundstation/Login/Activity/LoginActivity.java index b7edad5..1b2ae02 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Login/Activity/LoginActivity.java +++ b/app/src/main/java/com/example/longyi_groundstation/Login/Activity/LoginActivity.java @@ -41,7 +41,6 @@ public class LoginActivity extends AppCompatActivity { // Log.d("myReceiver_HEARTBEAT", Tool.getDecToFirstBin("128")); // Log.d("myReceiver_HEARTBEAT", Tool.getDecToBinFull("128")); - initData(); initView(); initOnClick(); @@ -64,9 +63,6 @@ public class LoginActivity extends AppCompatActivity { private void initView() { //所有组件 allView = new AllView(this); - - - } /** diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Activity/MainActivity.java b/app/src/main/java/com/example/longyi_groundstation/Main/Activity/MainActivity.java index d3ea43f..26b8022 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Activity/MainActivity.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Activity/MainActivity.java @@ -25,6 +25,8 @@ import android.graphics.Outline; import android.os.Build; import android.os.Bundle; import android.os.IBinder; +import android.text.Editable; +import android.text.TextWatcher; import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -74,6 +76,8 @@ import com.example.longyi_groundstation.Main.View.DpadView; import com.example.longyi_groundstation.Main.View.ErrorLogDialog; import com.example.longyi_groundstation.Main.View.FPV_Void; import com.example.longyi_groundstation.Main.View.LandDialog; +import com.example.longyi_groundstation.Main.View.PointFlyDialog; +import com.example.longyi_groundstation.Main.View.SaveLinkNameDialog; import com.example.longyi_groundstation.Main.View.SlideToUnlockView; import com.example.longyi_groundstation.Main.View.StartExecuteDialog; import com.example.longyi_groundstation.Main.View.TakeOffDialog; @@ -129,7 +133,8 @@ public class MainActivity extends AppCompatActivity { //广播接收器 private MyReceiver myReceiver_ATTITUDE, myReceiver_GPS_RAW_INT, myReceiver_GLOBAL_POSITION_INT, myReceiver_POWER_STATUS, myReceiver_SYS_STATUS, myReceiver_STATUSTEXT, - myReceiver_HEARTBEAT, myReceiver_VFR_HUD,myReceiver_MISSION_REQUEST,myReceiver_MISSION_ACK; + myReceiver_HEARTBEAT, myReceiver_VFR_HUD, myReceiver_MISSION_REQUEST, myReceiver_MISSION_ACK, + myReceiver_MISSION_CURRENT; //所有组件 private AllView allView; private ArrayList typeList = new ArrayList<>(); @@ -138,15 +143,15 @@ public class MainActivity extends AppCompatActivity { private TurnBackDialog turnBackDialog;//返航弹窗 private LandDialog landDialog;//降落弹窗 private BombingDialog bombingDialog;//投弹弹窗 + private PointFlyDialog pointFlyDialog;//指点飞行弹窗 public static StartExecuteDialog startExecuteDialog;//开始执行弹窗 - + private SaveLinkNameDialog saveLinkNameDialog;//二次确认路线名称弹窗 private ArrayList LogItemList = new ArrayList<>(); private LogAdapter adapter; private FPV_Void fpvVoid = new FPV_Void(); private int mainDisplay = 1;//1:Map 2:FPV private Intent intent; private Marker mainMarker; - private Marker flyMarker; private FlyVoid flyVoid = new FlyVoid(); private boolean islocation = true;//是否第一次定位 private LatLng homeLatLng = null; @@ -161,8 +166,14 @@ public class MainActivity extends AppCompatActivity { // 在成员变量部分添加 private CreateLinkAdapter createLinkAdapter; private List createLinkList = new ArrayList<>(); - private ArrayList selectedLinkList = null;//当前选择的航线 - public boolean isUnlock = false;//是否解锁 + private ArrayList selectedLinkList = new ArrayList<>();//当前选择的航线 + private ArrayList uploadLinkList = new ArrayList<>();//当前上传的航线 + public static boolean isUnlock = false;//是否解锁 + public boolean isAdviseFly = true;//是否可以使用指点飞行 + // 创建航线列表适配器 + private AllLinkAdapter allLinkAdapter; + private SQLClass sqlClass; + private List linkListInfoList; @Override @@ -180,6 +191,8 @@ public class MainActivity extends AppCompatActivity { initView(); initReceiver(); initOnClick(); + mapVoid.startFlightTracking(); + } /** @@ -290,6 +303,16 @@ public class MainActivity extends AppCompatActivity { registerReceiver(myReceiver_MISSION_ACK, filter10); } + //目标航点 + myReceiver_MISSION_CURRENT = new MyReceiver(); + IntentFilter filter11 = new IntentFilter("Broadcast_MISSION_CURRENT"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + registerReceiver(myReceiver_MISSION_CURRENT, filter11, Context.RECEIVER_EXPORTED); + } else { + registerReceiver(myReceiver_MISSION_CURRENT, filter11); + } + + // 初始化数据源 typeList = new ArrayList<>(); typeList.add(new Msg("relative_alt", "0", true)); @@ -320,16 +343,10 @@ public class MainActivity extends AppCompatActivity { allView = new AllView(this); //地图全局方法类 mapVoid = new MapVoid(MainActivity.this); - mainMarker = mapVoid.aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f) // 设置锚点为图片中心 - .title("飞机").snippet("型号")); - // 更换 Marker 图标 - mainMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_fly)); + mainMarker = mapVoid.aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)); // 设置锚点为图片中心 - - flyMarker = mapVoid.aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f) // 设置锚点为图片中心 - .title("飞机").snippet("型号")); // 更换 Marker 图标 - flyMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_fly)); + mainMarker.setIcon(BitmapDescriptorFactory.fromResource(R.mipmap.icon_fly)); Intent intents = new Intent(this, MyBoundService.class); intents.putExtra("type", intent.getIntExtra("type", 0)); @@ -361,13 +378,18 @@ public class MainActivity extends AppCompatActivity { bombingDialog = new BombingDialog(MainActivity.this); //开始执行弹窗 startExecuteDialog = new StartExecuteDialog(this, "10"); + //指点飞行弹窗 + pointFlyDialog = new PointFlyDialog(this); + //保存航线弹窗 + saveLinkNameDialog = new SaveLinkNameDialog(this); + allView.rv_error_list.setLayoutManager(new LinearLayoutManager(this)); adapter = new LogAdapter(); allView.rv_error_list.setAdapter(adapter); - // 初始化路线适配器 - createLinkAdapter = new CreateLinkAdapter(); + // 初始化航线适配器 + createLinkAdapter = new CreateLinkAdapter(this); allView.rv_create_link_list.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); allView.rv_create_link_list.setAdapter(createLinkAdapter); @@ -390,14 +412,6 @@ public class MainActivity extends AppCompatActivity { //拿到数据库里所有的航线 setupAllLinkList(); - //设置滑动解锁的view属性 - allView.unlockView.setText("滑动解锁"); - // 设置背景圆角弧度为10dp - allView.unlockView.setCornerRadius(4); - // 设置滑块圆角弧度为5dp - allView.unlockView.setThumbCornerRadius(4); - // 设置组件半透明(50%透明度) - allView.unlockView.setComponentAlpha(128); } /** @@ -411,17 +425,17 @@ public class MainActivity extends AppCompatActivity { //广播接收-ATTITUDE myReceiver_ATTITUDE.setATTITUDEListener(data -> { // 这里可以更新 UI 或刷新数据 -// Log.d(TAG, "收到新数据ATTITUDE:" + data.toString()); + Log.d(TAG, "收到新数据ATTITUDE:" +MyReceiver.ATTITUDE_json.optDouble("yaw")); // allView.tv_connect.setText("已连接"); // 示例:更新 typeList 数据并刷新 RecyclerView if (data != null) { - flyVoid.setAttitude(getApplicationContext(), allView, MyReceiver.ATTITUDE_json.optDouble("roll"), MyReceiver.ATTITUDE_json.optDouble("pitch"), MyReceiver.ATTITUDE_json.optDouble("yaw")); + flyVoid.setAttitude(getApplicationContext(), allView, MyReceiver.ATTITUDE_json.optDouble("roll"), MyReceiver.ATTITUDE_json.optDouble("pitch"),(int) Math.round(MyReceiver.ATTITUDE_json.optDouble("yaw") * 57.3)); } //地图上飞机的朝向 - mainMarker.setRotateAngle((int) Math.toDegrees(MyReceiver.ATTITUDE_json.optDouble("yaw"))); + mainMarker.setRotateAngle( (int) Math.round(MyReceiver.ATTITUDE_json.optDouble("yaw")* 57.3) * -1); - allView.tv_yaw.setText((int) Math.toDegrees(MyReceiver.ATTITUDE_json.optDouble("yaw")) + "°"); + allView.tv_yaw.setText((int) Math.round(MyReceiver.ATTITUDE_json.optDouble("yaw") * 57.3) + "°"); mainMarker.setVisible(true); }); @@ -445,6 +459,7 @@ public class MainActivity extends AppCompatActivity { (MyReceiver.GLOBAL_POSITION_INT_json.optDouble("lon", 0) / 10000000), (MyReceiver.GLOBAL_POSITION_INT_json.optDouble("lat", 0) / 10000000)); + if (doubles[1] != 0) { //获取到位置后移动视角到当前位置 if (islocation) { @@ -475,6 +490,7 @@ public class MainActivity extends AppCompatActivity { typeAdapter.notifyDataSetChanged(); if (FlyVoid.parseSerialData != null) { // allView.tv_height.setText(Math.round((MyReceiver.GLOBAL_POSITION_INT_json.optDouble("relative_alt") / 100) / 10.0) + "m"); +// Toast.makeText(this, flyVoid.parseSerialData[0]+"", Toast.LENGTH_SHORT).show(); allView.tv_height.setText(flyVoid.parseSerialData[0] + "m"); } } @@ -534,20 +550,20 @@ public class MainActivity extends AppCompatActivity { isUnlock = Tool.getDecToFirstBin(MyReceiver.HEARTBEAT_json.optString("base_mode")).equals("1"); - if (allView.ll_link_start.getVisibility() == VISIBLE){ + if (allView.ll_link_start.getVisibility() == VISIBLE) { Log.d(TAG, "myReceiver_HEARTBEAT: " + data.toString()); //判断飞控是否解锁 - if (Tool.getDecToFirstBin(MyReceiver.HEARTBEAT_json.optString("base_mode")).equals("1")){ + if (Tool.getDecToFirstBin(MyReceiver.HEARTBEAT_json.optString("base_mode")).equals("1")) { //已解锁 - allView.rl_unlock.setVisibility(View.GONE); - allView.ll_link_start_fun2.setVisibility(VISIBLE); - }else { - if (allView.rl_unlock.getVisibility() == View.GONE){ - //未解锁 - allView.rl_unlock.setVisibility(View.VISIBLE); - allView.unlockView.resetToInitialState("滑动解锁"); - allView.ll_link_start_fun2.setVisibility(GONE); - } +// allView.rl_unlock.setVisibility(View.GONE); +// allView.ll_link_start_fun2.setVisibility(VISIBLE); + } else { + //未解锁 +// if (allView.rl_unlock.getVisibility() == View.GONE){ +// allView.rl_unlock.setVisibility(View.VISIBLE); +// allView.unlockView.resetToInitialState("滑动解锁"); +// allView.ll_link_start_fun2.setVisibility(GONE); +// } } } @@ -607,16 +623,16 @@ public class MainActivity extends AppCompatActivity { // data.optDouble("throttle")/100, // 1 // ))); - if (data.optDouble("throttle") > 0){ - typeList.set(2, new Msg("throttle", String.format("%.1f", MyTool.getThrottle( + if (data.optDouble("throttle") > 0) { + typeList.set(2, new Msg("throttle", String.format("%.1f", MyTool.getThrottle( Double.parseDouble(FlyVoid.paramList.get("MOT_SPIN_MIN").getParam_value()), Double.parseDouble(FlyVoid.paramList.get("MOT_SPIN_MAX").getParam_value()), Double.parseDouble(FlyVoid.paramList.get("MOT_THST_EXPO").getParam_value()), - data.optDouble("throttle")/100, + data.optDouble("throttle") / 100, 1 - )*100) + "%", true)); - }else { - typeList.set(2, new Msg("throttle","0%", true)); + ) * 100) + "%", true)); + } else { + typeList.set(2, new Msg("throttle", "0%", true)); } }); @@ -627,9 +643,16 @@ public class MainActivity extends AppCompatActivity { //广播接收-setMissionAcklistener myReceiver_MISSION_ACK.setMissionAcklistener(data -> { - Log.d(TAG, "myReceiver_MISSION_ACK: "+data.toString()); + Log.d(TAG, "myReceiver_MISSION_ACK: " + data.toString()); }); + //广播接收-setMissionAcklistener + myReceiver_MISSION_CURRENT.setMissionCurrentlistener(data -> { + Log.d(TAG, "myReceiver_MISSION_CURRENT: " + data.toString()); + allView.tv_test1.setText(data.optInt("seq") + ""); + }); + + } /** @@ -680,7 +703,6 @@ public class MainActivity extends AppCompatActivity { } }); - //点击异常窗口 allView.iv_error.setOnClickListener(v -> { @@ -692,7 +714,7 @@ public class MainActivity extends AppCompatActivity { }); //点击定位到当前位置按钮 - allView.iv_location_me.setOnClickListener(v -> { + allView.ll_location_me.setOnClickListener(v -> { if (MyReceiver.GLOBAL_POSITION_INT_json.optDouble("lat", 0) / 10000000 != 0) { // 移动视图到Marker点 mapVoid.aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(MyReceiver.GLOBAL_POSITION_INT_json.optDouble("lat", 0) / 10000000, MyReceiver.GLOBAL_POSITION_INT_json.optDouble("lon", 0) / 10000000), 15)); // 15是缩放级别 @@ -722,37 +744,27 @@ public class MainActivity extends AppCompatActivity { startActivity(intent); }); - //路线执行 - allView.ll_line_fly_layout.setOnClickListener(v -> { - - //清空所有线路,并且退出执行页面 - refreshLinkList(); - allView.v_mainDisplay.setVisibility(GONE); - allView.ll_open_layout.setVisibility(GONE); - allView.ll_text.setVisibility(GONE); - allView.ll_link_start.setVisibility(VISIBLE); - allView.ll_all_link_layout.setVisibility(VISIBLE); - allView.fpvWidget.setVisibility(GONE); - }); - - //路线执行-上传航线 + //航线执行-上传航线 allView.ll_link_start_fun1.setOnClickListener(v -> { // 添加航线发送功能 - if (selectedLinkList != null) { + if (selectedLinkList.size() > 0) { // 调用FlyVoid中的方法发送航线到飞控 flyVoid.sendMissionToFlightController(this, selectedLinkList, allView.et_start_execute_height.getText().toString()); - + // 清除当前地图上的所有航点和航线 +// clearWaypoints(); + allView.v_mainDisplay.setVisibility(VISIBLE); + allView.ll_open_layout.setVisibility(VISIBLE); + allView.ll_text.setVisibility(VISIBLE); + allView.ll_link_start.setVisibility(GONE); + allView.ll_all_link_layout.setVisibility(GONE); + allView.fpvWidget.setVisibility(VISIBLE); + uploadLinkList.addAll(selectedLinkList); + allView.ll_assistance_layout.setVisibility(VISIBLE); + } else { + Toast.makeText(this, "请选择航线", Toast.LENGTH_SHORT).show(); } -// // 清除当前地图上的所有航点和航线 -// clearWaypoints(); -// allView.v_mainDisplay.setVisibility(VISIBLE); -// allView.ll_open_layout.setVisibility(VISIBLE); -// allView.ll_text.setVisibility(VISIBLE); -// allView.ll_link_start.setVisibility(GONE); -// allView.ll_all_link_layout.setVisibility(GONE); -// allView.fpvWidget.setVisibility(VISIBLE); }); //开始执行 allView.ll_link_start_fun2.setOnClickListener(v -> { @@ -760,29 +772,35 @@ public class MainActivity extends AppCompatActivity { if (selectedLinkList != null) { // 调用FlyVoid中的方法发送航线到飞控 //flyVoid.requestMissionStart(0,0); - if (isUnlock){ + if (isUnlock) { startExecuteDialog.show(); - }else { + } else { Toast.makeText(this, "请先解锁", Toast.LENGTH_SHORT).show(); } - }else { + } else { Toast.makeText(this, "请先选择航线", Toast.LENGTH_SHORT).show(); } }); - //路线执行-退出 + //航线执行-退出 allView.ll_link_start_back.setOnClickListener(v -> { - // 清除当前地图上的所有航点和航线 - clearWaypoints(); + //判断是否选择了航线 + if (uploadLinkList != null) { + // 清除当前地图上的所有航点和航线 + clearWaypoints(); + // 在地图上显示航线-之前上传的航线 + displayRouteOnMap(uploadLinkList); + } allView.v_mainDisplay.setVisibility(VISIBLE); allView.ll_open_layout.setVisibility(VISIBLE); allView.ll_text.setVisibility(VISIBLE); allView.ll_link_start.setVisibility(GONE); allView.ll_all_link_layout.setVisibility(GONE); allView.fpvWidget.setVisibility(VISIBLE); - allView.rl_unlock.setVisibility(View.GONE); + allView.ll_assistance_layout.setVisibility(VISIBLE); + isAdviseFly = true; }); allView.ll_left_open.setOnClickListener(v -> { @@ -793,16 +811,23 @@ public class MainActivity extends AppCompatActivity { } }); + //清除所有航线的方法 allView.ll_clear.setOnClickListener(v -> { - Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); + uploadLinkList.clear(); + // 清除所有航点和航线 + clearWaypoints(); + // 在地图上显示航线-清除选中点在更新地图 + displayRouteOnMap(uploadLinkList); + Toast.makeText(this, "已清除", Toast.LENGTH_SHORT).show(); }); - allView.ll_antenna.setOnClickListener(v -> { - Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); - }); - //路线规划 - allView.ll_map.setOnClickListener(v -> { -// Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); + + //添加航线跳转 + allView.tv_add_link.setOnClickListener(v -> { + // 清除所有航点和航线 + clearWaypoints(); isSetLink = true; + allView.ll_all_link_layout.setVisibility(GONE); + allView.ll_link_start.setVisibility(GONE); allView.v_mainDisplay.setVisibility(GONE); allView.ll_open_layout.setVisibility(GONE); allView.ll_text.setVisibility(GONE); @@ -810,34 +835,33 @@ public class MainActivity extends AppCompatActivity { allView.ll_create_link_layout.setVisibility(VISIBLE); allView.fpvWidget.setVisibility(GONE); }); - //路线规划功能-保存 - allView.ll_link_save.setOnClickListener(v -> { - // 初始化数据库 - SQLClass sqlClass = new SQLClass(this); - // 添加一个CreateLink列表 - ArrayList createLinkLists = new ArrayList<>(); - createLinkLists.addAll(createLinkList); - // 添加CreateLink对象到列表中 - boolean success = sqlClass.addCreateLinkList("路线-"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), createLinkLists); - if (success){ - // 清除所有航点和航线 - clearWaypoints(); - isSetLink = false; - allView.v_mainDisplay.setVisibility(VISIBLE); - allView.ll_open_layout.setVisibility(VISIBLE); - allView.ll_text.setVisibility(VISIBLE); - allView.ll_link.setVisibility(GONE); - allView.ll_create_link_layout.setVisibility(GONE); - allView.fpvWidget.setVisibility(VISIBLE); - // 获取列表数量 - int count = sqlClass.getLinkListCount(); - Toast.makeText(this, "保存成功-"+count, Toast.LENGTH_SHORT).show(); + //航线规划 + allView.ll_map.setOnClickListener(v -> { + // 清除所有航点和航线 + clearWaypoints(); + isAdviseFly = false; + allView.ll_all_link_layout.setVisibility(VISIBLE); + allView.ll_link_start.setVisibility(VISIBLE); + allView.v_mainDisplay.setVisibility(GONE); + allView.ll_open_layout.setVisibility(GONE); + allView.ll_text.setVisibility(GONE); + allView.ll_link.setVisibility(GONE); + allView.ll_create_link_layout.setVisibility(GONE); + allView.fpvWidget.setVisibility(GONE); + allView.ll_assistance_layout.setVisibility(GONE); + }); + //航线规划功能-保存 + allView.ll_link_save.setOnClickListener(v -> { + if (allView.et_link_name.getText().toString().length() != 0){ + saveLink(null); + }else { + saveLinkNameDialog.show(); } }); - // 路线规划功能-1:反转航点顺序 - allView.ll_link_fun1.setOnClickListener(v -> { + // 航线规划功能-1:反转航点顺序 + allView.tv_link_fun1.setOnClickListener(v -> { // 创建确认对话框 AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("反转航点顺序"); @@ -850,6 +874,9 @@ public class MainActivity extends AppCompatActivity { // 反转航点标记列表 java.util.Collections.reverse(waypointMarkers); + // 反转createLinkList列表 + java.util.Collections.reverse(createLinkList); + // 重新编号航点标记 renumberWaypoints(); @@ -866,8 +893,8 @@ public class MainActivity extends AppCompatActivity { AlertDialog dialog = builder.create(); dialog.show(); }); - // 路线规划功能-2:清除所有线路 - allView.ll_link_fun2.setOnClickListener(v -> { + // 航线规划功能-2:清除所有线航 + allView.tv_link_fun2.setOnClickListener(v -> { // 创建确认对话框 AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("清除所有航点"); @@ -886,46 +913,56 @@ public class MainActivity extends AppCompatActivity { AlertDialog dialog = builder.create(); dialog.show(); }); - //路线规划功能-退出 + //航线规划功能-退出 allView.ll_link_back.setOnClickListener(v -> { - // 创建确认对话框 - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("退出"); - builder.setMessage("确定要退出嘛?退出前的航线不会保存"); + if (createLinkList.size() > 0) { + // 创建确认对话框 + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("退出"); + builder.setMessage("确定要退出嘛?退出前的航线不会保存"); - builder.setPositiveButton("确定", (dialog, which) -> { + builder.setPositiveButton("确定", (dialog, which) -> { + // 清除所有航点和航线 + clearWaypoints(); + isSetLink = false; + allView.ll_all_link_layout.setVisibility(VISIBLE); + allView.ll_link_start.setVisibility(VISIBLE); + allView.v_mainDisplay.setVisibility(GONE); + allView.ll_open_layout.setVisibility(GONE); + allView.ll_text.setVisibility(GONE); + allView.ll_link.setVisibility(GONE); + allView.ll_create_link_layout.setVisibility(GONE); + allView.fpvWidget.setVisibility(GONE); + displayRouteOnMap(selectedLinkList); + dialog.dismiss(); + // 在地图上显示航线-之前上传的航线 + displayRouteOnMap(selectedLinkList); + + }); + + builder.setNegativeButton("取消", (dialog, which) -> { + dialog.dismiss(); + }); + + AlertDialog dialog = builder.create(); + dialog.show(); + } else { // 清除所有航点和航线 clearWaypoints(); isSetLink = false; - allView.v_mainDisplay.setVisibility(VISIBLE); - allView.ll_open_layout.setVisibility(VISIBLE); - allView.ll_text.setVisibility(VISIBLE); + allView.ll_all_link_layout.setVisibility(VISIBLE); + allView.ll_link_start.setVisibility(VISIBLE); + allView.v_mainDisplay.setVisibility(GONE); + allView.ll_open_layout.setVisibility(GONE); + allView.ll_text.setVisibility(GONE); allView.ll_link.setVisibility(GONE); allView.ll_create_link_layout.setVisibility(GONE); - allView.fpvWidget.setVisibility(VISIBLE); - dialog.dismiss(); - }); - - builder.setNegativeButton("取消", (dialog, which) -> { - dialog.dismiss(); - }); - - AlertDialog dialog = builder.create(); - dialog.show(); - + allView.fpvWidget.setVisibility(GONE); + } }); - allView.ll_one_word.setOnClickListener(v -> { - Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); - }); allView.ll_execute_line.setOnClickListener(v -> { - Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); - }); - allView.ll_joystick.setOnClickListener(v -> { - Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); - }); - allView.ll_fire.setOnClickListener(v -> { - Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); + startExecuteDialog.show(); }); allView.ll_bombing.setOnClickListener(v -> { bombingDialog.show(); @@ -934,18 +971,12 @@ public class MainActivity extends AppCompatActivity { allView.ll_shout.setOnClickListener(v -> { Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); }); - allView.ll_thoroughfare.setOnClickListener(v -> { - Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); - }); allView.ll_hook.setOnClickListener(v -> { Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); }); allView.ll_searchlight.setOnClickListener(v -> { Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); }); - allView.ll_mode_select.setOnClickListener(v -> { - Toast.makeText(this, "正在研发..", Toast.LENGTH_SHORT).show(); - }); //初始化FPV手势处理 fpvGestureHandler = new FpvGestureHandler(allView.fpvWidget); fpvGestureHandler.setOnFpvGestureListener(new FpvGestureHandler.OnFpvGestureListener() { @@ -1257,6 +1288,7 @@ public class MainActivity extends AppCompatActivity { byte[] testData = new byte[]{(byte) 0xFF, 0x01, 0x13, 0x03, 0x00, 0x00, 0x17}; tcpClient.sendBytes(testData); }); + //一键向下 allView.ll_PTZ_one_bottom.setOnClickListener(v -> { // 发送左转数据 @@ -1327,9 +1359,19 @@ public class MainActivity extends AppCompatActivity { // 设置地图点击监听器以添加航点 allView.map.getMap().setOnMapClickListener(latLng -> { if (isSetLink) { +// Log.d("setOnMapClickListener", latLng.toString()+"++"+isSetLink); addWaypoint(latLng); } }); + + //地图长按 + allView.map.getMap().setOnMapLongClickListener(latLng -> { + if (isAdviseFly) { + pointFlyDialog.setLatLng(latLng); + pointFlyDialog.show(); + } + }); + // 设置标记点击监听器以删除航点 allView.map.getMap().setOnMarkerClickListener(marker -> { if (isSetLink) { @@ -1365,16 +1407,120 @@ public class MainActivity extends AppCompatActivity { } }); - allView.unlockView.setOnUnlockListener(new SlideToUnlockView.OnUnlockListener() { + //根据输入的文字模糊查询(名字)搜索框 + allView.et_link_search.addTextChangedListener(new TextWatcher() { @Override - public void onUnlock() { - // 解锁飞机 - flyVoid.requestArm(); - allView.rl_unlock.setVisibility(View.GONE); + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + // 不需要实现 + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + // 实时查询 + filterLinkList(s.toString()); + } + + @Override + public void afterTextChanged(Editable s) { + // 不需要实现 } }); + //清除飞行轨迹 + allView.ll_clear_fly_line.setOnClickListener(v -> { + if (mapVoid.isTracking){ + mapVoid.isTracking = false; + mapVoid.clearFlightTrack(); + mapVoid.stopFlightTracking(); + }else { + mapVoid.startFlightTracking(); + } + }); + + //开启|关闭航线点位 + allView.iv_open_link_list.setOnClickListener(v -> { + if (allView.ll_create_link_item_layout.getVisibility() == View.GONE){ + allView.ll_create_link_item_layout.setVisibility(View.VISIBLE); + }else { + allView.ll_create_link_item_layout.setVisibility(View.GONE); + } + }); + + } + + /** + * 方法:保存航线 + * + * @cuijingzhou + */ + public void saveLink( String linkName) { + // 初始化数据库 + SQLClass sqlClass = new SQLClass(this); + // 添加一个CreateLink列表 + ArrayList createLinkLists = new ArrayList<>(); + if (createLinkList.size() > 0) { + createLinkLists.addAll(createLinkList); + boolean success; + if (linkName == null){ + // 添加CreateLink对象到列表中 + if (allView.et_link_name.getText().toString().length() != 0) { + success = sqlClass.addCreateLinkList(allView.et_link_name.getText().toString(), createLinkLists); + } else { + success = sqlClass.addCreateLinkList("航线-" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), createLinkLists); + } + }else { + success = sqlClass.addCreateLinkList(linkName, createLinkLists); + } + + if (success) { + // 清除所有航点和航线 + clearWaypoints(); + isSetLink = false; + allView.ll_all_link_layout.setVisibility(VISIBLE); + allView.ll_link_start.setVisibility(VISIBLE); + allView.v_mainDisplay.setVisibility(GONE); + allView.ll_open_layout.setVisibility(GONE); + allView.ll_text.setVisibility(GONE); + allView.ll_link.setVisibility(GONE); + allView.ll_create_link_layout.setVisibility(GONE); + allView.fpvWidget.setVisibility(GONE); + allView.et_link_name.setText(""); + // 在地图上显示航线-之前选中的航线 + displayRouteOnMap(selectedLinkList); + refreshLinkList();//刷新航线列表 + Toast.makeText(this, "航线保存成功", Toast.LENGTH_SHORT).show(); + } + } else { + Toast.makeText(this, "请先添加航点", Toast.LENGTH_SHORT).show(); + } + + + + } + + // 添加过滤方法 + private void filterLinkList(String query) { + if (sqlClass != null && allLinkAdapter != null) { + if (query.isEmpty()) { + // 如果查询为空,显示所有数据 + List allList = sqlClass.getAllLinkListInfo(); + allLinkAdapter.updateDataList(allList); + } else { + // 根据输入文字模糊查询 + List filteredList = new ArrayList<>(); + List fullList = sqlClass.getAllLinkListInfo(); + + for (SQLClass.LinkListInfo item : fullList) { + // 模糊匹配航线名称 + if (item.getListName().toLowerCase().contains(query.toLowerCase())) { + filteredList.add(item); + } + } + + allLinkAdapter.updateDataList(filteredList); + } + } } /** @@ -1387,7 +1533,7 @@ public class MainActivity extends AppCompatActivity { // 创建自定义对话框 AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("删除航点"); - builder.setMessage("确定要删除点位" +(index+1) + "吗?"); + builder.setMessage("确定要删除航点" + (index + 1) + "吗?"); builder.setPositiveButton("确定", (dialog, which) -> { // 删除航点时同时删除对应的列表项 @@ -1409,7 +1555,7 @@ public class MainActivity extends AppCompatActivity { // 创建自定义标记视图 View markerView = getLayoutInflater().inflate(R.layout.custom_marker_layout, null); @SuppressLint({"MissingInflatedId", "LocalSuppress"}) TextView markerText = markerView.findViewById(R.id.marker_text); - markerText.setText("点位" + (waypointMarkers.size() + 1)); + markerText.setText( "" + (waypointMarkers.size() + 1)); // 将视图转换为Bitmap markerView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); @@ -1430,7 +1576,15 @@ public class MainActivity extends AppCompatActivity { waypointPositions.add(latLng); // 添加到列表 - CreateLink createLink = new CreateLink("点位" + waypointMarkers.size(), 30, 10, waypointMarkers.size() - 1, latLng); + CreateLink createLink = new CreateLink( + waypointMarkers.size()+"", + 30, + 10, + waypointMarkers.size() - 1, + latLng, + true, + true + ); createLinkList.add(createLink); createLinkAdapter.setCreateLinkList(createLinkList); @@ -1462,20 +1616,22 @@ public class MainActivity extends AppCompatActivity { private void renumberWaypoints() { for (int i = 0; i < waypointMarkers.size(); i++) { // 创建新的自定义标记Bitmap - Bitmap markerBitmap = createCustomMarkerBitmap("点位" + (i + 1)); + Bitmap markerBitmap = createCustomMarkerBitmap( (i + 1)+""); // 更新标记图标 waypointMarkers.get(i).setIcon(BitmapDescriptorFactory.fromBitmap(markerBitmap)); // 更新列表项名称 if (i < createLinkList.size()) { - createLinkList.get(i).setName("点位" + (i + 1)); + createLinkList.get(i).setName( (i + 1)+""); } } + createLinkAdapter.setCreateLinkList(createLinkList); } /** * 创建自定义标记Bitmap + * * @param text 标记文字 * @return Bitmap */ @@ -1502,6 +1658,7 @@ public class MainActivity extends AppCompatActivity { waypointMarkers.clear(); waypointPositions.clear(); createLinkList.clear(); + selectedLinkList.clear(); createLinkAdapter.setCreateLinkList(createLinkList); // 移除航线 @@ -1523,7 +1680,6 @@ public class MainActivity extends AppCompatActivity { } - /** * 更新航线显示 */ @@ -1538,8 +1694,8 @@ public class MainActivity extends AppCompatActivity { if (waypointPositions.size() > 1) { flightPathPolyline = allView.map.getMap().addPolyline(new PolylineOptions() .addAll(waypointPositions) - .width(8) - .color(Color.BLACK)); + .width(6) + .color(Color.parseColor("#FFEB3B"))); } } @@ -1553,10 +1709,6 @@ public class MainActivity extends AppCompatActivity { } - // 创建航线列表适配器 - private AllLinkAdapter allLinkAdapter; - private SQLClass sqlClass; - private List linkListInfoList; private void setupAllLinkList() { // 初始化数据库 sqlClass = new SQLClass(this); @@ -1573,14 +1725,13 @@ public class MainActivity extends AppCompatActivity { allLinkAdapter.setOnItemClickListener(new AllLinkAdapter.OnItemClickListener() { @Override public void onItemClick(int listId, int position) { - // 清除当前地图上的所有航点和航线 + // 清除所有航点和航线 clearWaypoints(); - selectedLinkList = null; // 从数据库中获取选中的航线数据 selectedLinkList = sqlClass.getCreateLinkList(listId); - if (selectedLinkList != null) { - Toast.makeText(MainActivity.this, "已加载航线: " + linkListInfoList.get(position).getListName(), - Toast.LENGTH_SHORT).show(); + if (selectedLinkList.size() > 0) { +// Toast.makeText(MainActivity.this, "已加载航线: " + linkListInfoList.get(position).getListName(), +// Toast.LENGTH_SHORT).show(); // 在地图上显示航线 displayRouteOnMap(selectedLinkList); } else { @@ -1601,11 +1752,10 @@ public class MainActivity extends AppCompatActivity { /** * 在地图上显示航线 + * * @param createLinkList 航线数据列表 */ private void displayRouteOnMap(ArrayList createLinkList) { - // 清除现有的航点和航线 - clearWaypoints(); // 遍历航线数据并在地图上显示 for (int i = 0; i < createLinkList.size(); i++) { @@ -1645,7 +1795,9 @@ public class MainActivity extends AppCompatActivity { createLink.getHeight(), createLink.getSpeed(), createLink.getWaypointIndex(), - latLng + latLng, + createLink.isBom1_show(), + createLink.isBom2_show() ); this.createLinkList.add(newCreateLink); } @@ -1663,8 +1815,6 @@ public class MainActivity extends AppCompatActivity { } } - - @Override protected void onDestroy() { super.onDestroy(); @@ -1726,9 +1876,10 @@ public class MainActivity extends AppCompatActivity { } fpvVoid.Fstop(allView.fpvWidget); + //关闭航线 + mapVoid.stopFlightTracking(); } - @Override protected void onResume() { super.onResume(); diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Adapter/AllLinkAdapter.java b/app/src/main/java/com/example/longyi_groundstation/Main/Adapter/AllLinkAdapter.java index db88742..dcb805d 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Adapter/AllLinkAdapter.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Adapter/AllLinkAdapter.java @@ -6,6 +6,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -46,7 +47,13 @@ public class AllLinkAdapter extends RecyclerView.Adapter { if (onItemClickListener != null) { + setSelects(position); onItemClickListener.onItemClick(linkListInfo.getListId(), position); } }); } + /** + * 方法:选择其中一个航线列表 + * + * @cuijingzhou + */ + public void setSelects(int position){ + for (int i = 0; i < linkListInfoList.size(); i++){ + if (i != position){ + linkListInfoList.get(i).setSelect(false); + } else { + linkListInfoList.get(i).setSelect(true); + } + } + notifyDataSetChanged(); + } + @Override public int getItemCount() { return linkListInfoList != null ? linkListInfoList.size() : 0; @@ -127,6 +151,7 @@ public class AllLinkAdapter extends RecyclerView.Adapter { private List createLinkList; private OnItemClickListener onItemClickListener; + private Activity content; + public static ArrayList isExpand = new ArrayList<>();//当前两个弹舱是否可以使用 0=弹舱1 1=弹舱2 public interface OnItemClickListener { void onDeleteClick(int position); } - public CreateLinkAdapter() { + public CreateLinkAdapter(Activity content) { this.createLinkList = new ArrayList<>(); + this.content = content; + isExpand.add(true); + isExpand.add(true); } public void setOnItemClickListener(OnItemClickListener listener) { @@ -60,22 +74,111 @@ public class CreateLinkAdapter extends RecyclerView.Adapter linkAdapter = new ArrayAdapter<>(content, + android.R.layout.simple_spinner_item, linkOptions); + linkAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + sp_turn.setAdapter(linkAdapter); + + + + //投弹是否显示 + if (createLink.isBom1_show()){ + ll_bom_layout1.setVisibility(View.VISIBLE); + }else { + ll_bom_layout1.setVisibility(View.GONE); + } + if (createLink.isBom2_show()){ + ll_bom_layout2.setVisibility(View.VISIBLE); + }else { + ll_bom_layout2.setVisibility(View.GONE); + } + + //投弹高度 + et_bom1.setText(createLink.getBom1_height() + ""); + et_bom2.setText(createLink.getBom2_height() + ""); + + if (!createLink.isBom1_show() && !createLink.isBom2_show()){ + tv_null_data.setVisibility(View.VISIBLE); + }else { + tv_null_data.setVisibility(View.GONE); + } + + + if (createLink.isBom1_select()) { + tv_bom_text1.setBackgroundResource(R.drawable.ff029a45_2round_1stroke_bg); + iv_bom1.setImageResource(R.mipmap.icon_select_link_yes); +// ll_bom_height_layout1.setVisibility(View.VISIBLE); + } else { + tv_bom_text1.setBackgroundResource(R.drawable.b2101010_4round_1stroke_bg); + iv_bom1.setImageResource(R.mipmap.icon_select_link_no); +// ll_bom_height_layout1.setVisibility(View.INVISIBLE); + } + + if (createLink.isBom2_select()) { + tv_bom_text2.setBackgroundResource(R.drawable.ff029a45_2round_1stroke_bg); + iv_bom2.setImageResource(R.mipmap.icon_select_link_yes); +// ll_bom_height_layout2.setVisibility(View.VISIBLE); + } else { + tv_bom_text2.setBackgroundResource(R.drawable.b2101010_4round_1stroke_bg); + iv_bom2.setImageResource(R.mipmap.icon_select_link_no); +// ll_bom_height_layout2.setVisibility(View.INVISIBLE); + } + tvDel.setOnClickListener(v -> { if (onItemClickListener != null) { @@ -94,15 +197,147 @@ public class CreateLinkAdapter extends RecyclerView.Adapter { - if (!hasFocus) { - try { - createLink.setSpeed(Double.parseDouble(etSpeed.getText().toString())); - } catch (NumberFormatException e) { - etSpeed.setText(String.valueOf((int) createLink.getSpeed())); - } + // 为Spinner设置选择监听器 + sp_turn.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + tv_turn.setText(parent.getItemAtPosition(position).toString()); + + } + + @Override + public void onNothingSelected(AdapterView parent) { + // 什么都不做 } }); + + rl_turn.setOnClickListener(v -> { + showCustomDropdown(rl_turn, tv_turn,ll_turn); + }); + + //长按弹出窗口 + tv_expand.setOnClickListener(v -> { + if (ll_expand.getVisibility() == View.VISIBLE) { + ll_expand.setVisibility(View.GONE); + tv_expand.setText("展开"); + } else { + ll_expand.setVisibility(View.VISIBLE); + tv_expand.setText("收起"); + } + }); + + //投弹选中1 + ll_bom_layout1.setOnClickListener(v -> { + if (createLink.isBom1_select()) { + // 取消选中状态 + tv_bom_text1.setBackgroundResource(R.drawable.b2101010_4round_1stroke_bg); + iv_bom1.setImageResource(R.mipmap.icon_select_link_no); + } else { + // 设置当前项为选中状态 + tv_bom_text1.setBackgroundResource(R.drawable.ff029a45_2round_1stroke_bg); + iv_bom1.setImageResource(R.mipmap.icon_select_link_yes); + } + // 选中状态 - 先取消其他所有项的选中状态 + clearAllSelectionsExcept(position, 1); // 1表示bom1 + }); + + //投弹选中2 + ll_bom_layout2.setOnClickListener(v -> { + if (createLink.isBom2_select()) { + // 取消选中状态 + tv_bom_text2.setBackgroundResource(R.drawable.b2101010_4round_1stroke_bg); + iv_bom2.setImageResource(R.mipmap.icon_select_link_no); + + } else { + // 设置当前项为选中状态 + tv_bom_text2.setBackgroundResource(R.drawable.ff029a45_2round_1stroke_bg); + iv_bom2.setImageResource(R.mipmap.icon_select_link_yes); + } + // 选中状态 - 先取消其他所有项的选中状态 + clearAllSelectionsExcept(position, 2); // 2表示bom2 + }); + + } + + /** + * 清除除指定位置和类型外的所有显示状态 + * @param currentPosition 当前项的位置 + * @param type 1表示bom1,2表示bom2 + */ + private void clearAllSelectionsExcept(int currentPosition, int type) { + // bom1 + if (type == 1){ + //如果当前项是选中状态,则取消所有bom1的选中状态并显示出来 + if (createLinkList.get(currentPosition).isBom1_select()){ + for (int i = 0; i < createLinkList.size(); i++) { + CreateLink link = createLinkList.get(i); + link.setBom1_show(true); + link.setBom1_select(false); + } + isExpand.set(0,true); + } + //如果当前项不是选中状态,则取消除了当前项其它所有bom1的选中状态并隐藏 + else { + for (int i = 0; i < createLinkList.size(); i++) { + CreateLink link = createLinkList.get(i); + if (i == currentPosition){ + link.setBom1_show(true); + link.setBom1_select(true); + }else { + link.setBom1_show(false); + link.setBom1_select(false); + } + } + isExpand.set(0,false); + } + + } + //bom2 + else { + if (createLinkList.get(currentPosition).isBom2_select()){ + for (int i = 0; i < createLinkList.size(); i++) { + CreateLink link = createLinkList.get(i); + link.setBom2_show(true); + link.setBom2_select(false); + } + isExpand.set(1,true); + } + //如果当前项不是选中状态,则取消除了当前项其它所有bom2的选中状态并隐藏 + else { + for ( int i = 0; i < createLinkList.size(); i++) { + CreateLink link = createLinkList.get(i); + if (i == currentPosition){ + link.setBom2_show(true); + link.setBom2_select(true); + }else { + link.setBom2_show(false); + link.setBom2_select(false); + } + } + isExpand.set(1,false); + } + } + + notifyDataSetChanged(); } } + + //转弯方式选择弹窗 + private void showCustomDropdown(RelativeLayout anchor, TextView tv_turn,LinearLayout ll_turn) { + String[] options = {"协调转弯", "到点转弯"}; + AlertDialog.Builder builder = new AlertDialog.Builder(content); + builder.setItems(options, (dialog, which) -> { + tv_turn.setText(options[which]); + if (which == 1){ + ll_turn.setVisibility(View.VISIBLE); + }else { + ll_turn.setVisibility(View.GONE); + } + // 更新选中状态 + }); + builder.show(); + } + + + } diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Adapter/TypeAdapter.java b/app/src/main/java/com/example/longyi_groundstation/Main/Adapter/TypeAdapter.java index 5697a37..84266be 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Adapter/TypeAdapter.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Adapter/TypeAdapter.java @@ -82,7 +82,7 @@ public class TypeAdapter extends RecyclerView.Adapter { + // 移除参数更新检查的回调 + if (uiHandler != null) { + uiHandler.removeCallbacks(paramUpdateChecker); + } + // 返回主页 + finish(); + }); paramLoadingDialog.show(); } + @Override protected void onResume() { super.onResume(); diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Setting/Adapter/MultiSelectAdapter.java b/app/src/main/java/com/example/longyi_groundstation/Main/Setting/Adapter/MultiSelectAdapter.java index 1358796..49be845 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Setting/Adapter/MultiSelectAdapter.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Setting/Adapter/MultiSelectAdapter.java @@ -5,7 +5,6 @@ import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; import android.widget.TextView; import androidx.annotation.NonNull; @@ -41,7 +40,7 @@ public class MultiSelectAdapter extends RecyclerView.Adapter { -// switch (position) { -// case 0: -// tab.setText("机型设置"); -// break; -// case 1: -// tab.setText("安装设置"); -// break; -// case 2: -// tab.setText("加速度计"); -// break; -// case 3: -// tab.setText("磁力计"); -// break; -// } -// } -// ); -// tabLayoutMediator.attach(); -// -// // 为Tab之间添加间距 -// for (int i = 0; i < tabLayout.getTabCount(); i++) { -// View tab = (((ViewGroup) tabLayout.getChildAt(0)).getChildAt(i)); -// ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) tab.getLayoutParams(); -// layoutParams.setMargins(6, 0, 6, 0); // 左右各16dp的间距 -// tab.setLayoutParams(layoutParams); -// } -// -// -// } + rl_low_end = view.findViewById(R.id.rl_low_end); + rl_mid_range = view.findViewById(R.id.rl_mid_range); + rl_high_end = view.findViewById(R.id.rl_high_end); + sp_low_end = view.findViewById(R.id.sp_low_end); + sp_mid_range = view.findViewById(R.id.sp_mid_range); + sp_high_end = view.findViewById(R.id.sp_high_end); + tv_low_end_text = view.findViewById(R.id.tv_low_end_text); + tv_mid_range_text = view.findViewById(R.id.tv_mid_range_text); + tv_high_end_text = view.findViewById(R.id.tv_high_end_text); + tv_save = view.findViewById(R.id.tv_save); + initSpinnerData(); + initText(); } /** @@ -99,30 +86,181 @@ public class FoundationFragment extends Fragment { * @cuijingzhou */ private void initOnClick() { + rl_low_end.setOnClickListener(v -> { + // 点击TextView后打开对应的Spinner + sp_low_end.performClick(); + }); + rl_mid_range.setOnClickListener(v -> { + // 点击TextView后打开对应的Spinner + sp_mid_range.performClick(); + }); + rl_high_end.setOnClickListener(v -> { + // 点击TextView后打开对应的Spinner + sp_high_end.performClick(); + }); + // 修改所有的Spinner监听器 + sp_low_end.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @SuppressLint("SetTextI18n") + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + Log.d("无事发生", "onItemSelected: sp_m7"); + tv_low_end_text.setText( parent.getSelectedItem().toString()); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + Log.d("无事发生", "onNothingSelected: sp_m7"); + } + }); + + // 修改所有的Spinner监听器 + sp_mid_range.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @SuppressLint("SetTextI18n") + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + Log.d("无事发生", "onItemSelected: sp_m7"); + tv_mid_range_text.setText( parent.getSelectedItem().toString()); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + Log.d("无事发生", "onNothingSelected: sp_m7"); + } + }); + + // 修改所有的Spinner监听器 + sp_high_end.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @SuppressLint("SetTextI18n") + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + Log.d("无事发生", "onItemSelected: sp_m7"); + tv_high_end_text.setText( parent.getSelectedItem().toString()); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + Log.d("无事发生", "onNothingSelected: sp_m7"); + } + }); + + //保存 + tv_save.setOnClickListener(v -> { + save(); + }); + + + } + + /** + * 方法:保存 + * + * @cuijingzhou + */ + private void save() { + try { + flyVoid.requestParamSet("FLTMODE1", + getSelectedChannelValue(sp_low_end) + "", + FlyVoid.paramList.get("FLTMODE1").getParam_type()); + flyVoid.requestParamSet("FLTMODE2", + getSelectedChannelValue(sp_low_end) + ""); + + Thread.sleep(100); + + flyVoid.requestParamSet("FLTMODE3", + getSelectedChannelValue(sp_mid_range) + "", + FlyVoid.paramList.get("FLTMODE3").getParam_type()); + flyVoid.requestParamSet("FLTMODE4", + getSelectedChannelValue(sp_mid_range) + ""); + + Thread.sleep(100); + + flyVoid.requestParamSet("FLTMODE5", + getSelectedChannelValue(sp_high_end) + "", + FlyVoid.paramList.get("FLTMODE5").getParam_type()); + flyVoid.requestParamSet("FLTMODE6", + getSelectedChannelValue(sp_high_end) + ""); + + Toast.makeText(requireContext(), "保存成功", Toast.LENGTH_SHORT).show(); + }catch (Exception e){ + Log.d("FLTMODE-save", e.toString()); + } + } + + /** + * 方法:初始化文字 + * + * @cuijingzhou + */ + private void initText() { + setSelectedChannel(sp_low_end, Integer.parseInt(FlyVoid.paramList.get("FLTMODE1").getParam_value())); + setSelectedChannel(sp_mid_range, Integer.parseInt(FlyVoid.paramList.get("FLTMODE3").getParam_value())); + setSelectedChannel(sp_high_end, Integer.parseInt(FlyVoid.paramList.get("FLTMODE5").getParam_value())); + } + + /** + * 方法:初始化Spinner数据 + * + * @cuijingzhou + */ + private void initSpinnerData() { + // 创建通道数据列表 + List channelList = new ArrayList<>(); + channelList.add(new ModeItem("姿态", 0)); + channelList.add(new ModeItem("定高", 2)); + channelList.add(new ModeItem("航线", 3)); + channelList.add(new ModeItem("定点", 5)); + channelList.add(new ModeItem("返航", 6)); + channelList.add(new ModeItem("降落", 9)); + + // 创建适配器 + ArrayAdapter adapter = new ArrayAdapter<>(requireContext(), + android.R.layout.simple_spinner_item, channelList); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + + // 为所有Spinner设置适配器 + Spinner[] spinners = {sp_low_end, sp_mid_range, sp_high_end}; + for (Spinner spinner : spinners) { + if (spinner != null) { + spinner.setAdapter(adapter); + } + } + } + + // 示例:设置Spinner选中项 + private void setSelectedChannel(Spinner spinner, int value) { + ArrayAdapter adapter = (ArrayAdapter) spinner.getAdapter(); + for (int i = 0; i < adapter.getCount(); i++) { + ModeItem item = adapter.getItem(i); + if (item != null && item.getValue() == value) { + spinner.setSelection(i); + break; + } + } + } + + // 示例:获取选中的值 + private int getSelectedChannelValue(Spinner spinner) { + if (spinner.getSelectedItem() instanceof ModeItem) { + ModeItem item = (ModeItem) spinner.getSelectedItem(); + return item.getValue(); + } + return 0; // 默认值 } @Override public void onResume() { super.onResume(); -// // 使用post方法将initData()推迟到下一个UI循环执行,避免FragmentManager冲突 -// getView().post(new Runnable() { -// @Override -// public void run() { -// initData(); -// initView(); -// initOnClick(); -// } -// }); + // 使用post方法将initData()推迟到下一个UI循环执行,避免FragmentManager冲突 + } @Override public void onDestroyView() { super.onDestroyView(); - // 清理TabLayoutMediator资源 - if (tabLayoutMediator != null) { - tabLayoutMediator.detach(); - tabLayoutMediator = null; - } + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Setting/Fragment/LoadFragment.java b/app/src/main/java/com/example/longyi_groundstation/Main/Setting/Fragment/LoadFragment.java index 7f248b4..4fd66b7 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Setting/Fragment/LoadFragment.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Setting/Fragment/LoadFragment.java @@ -423,7 +423,7 @@ public class LoadFragment extends Fragment { et_off_m13.setText("1900"); } }); -// 修改所有的Spinner监听器,以sp_m7为例: + // 修改所有的Spinner监听器,以sp_m7为例: sp_m7.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @SuppressLint("SetTextI18n") @Override diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/View/PointFlyDialog.java b/app/src/main/java/com/example/longyi_groundstation/Main/View/PointFlyDialog.java new file mode 100644 index 0000000..57e9097 --- /dev/null +++ b/app/src/main/java/com/example/longyi_groundstation/Main/View/PointFlyDialog.java @@ -0,0 +1,115 @@ +package com.example.longyi_groundstation.Main.View; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.widget.TextView; +import android.widget.Toast; + +import com.amap.api.maps.model.LatLng; +import com.example.longyi_groundstation.Main.Void.FlyVoid; +import com.example.longyi_groundstation.Main.Void.MyTool; +import com.example.longyi_groundstation.R; + +public class PointFlyDialog { + + private final Activity context; + private String title; + private String message; + private String positiveButtonText; + private LatLng latLng; + + private FlyVoid flyVoid = new FlyVoid(); + + + public PointFlyDialog(Activity context) { + this.context = context; + this.title = "错误日志"; + this.message = ""; + this.positiveButtonText = "确定"; + this.latLng = latLng; + + } + + // 设置弹窗标题 + public PointFlyDialog setLatLng(LatLng latLng) { + this.latLng = latLng; + return this; + } + + // 设置弹窗标题 + public PointFlyDialog setTitle(String title) { + this.title = title; + return this; + } + + // 设置弹窗内容 + public PointFlyDialog setMessage(String message) { + this.message = message; + return this; + } + + // 设置确认按钮文字 + public PointFlyDialog setPositiveButtonText(String text) { + this.positiveButtonText = text; + return this; + } + + // 显示弹窗 + public void show() { + MyTool.hideBottomNavigationBar( context); + AlertDialog.Builder builder = new AlertDialog.Builder(context); + + // 使用自定义布局 + View view = LayoutInflater.from(context).inflate(R.layout.dialog_point_fly, null); + @SuppressLint({"MissingInflatedId", "LocalSuppress"}) TextView tvMessage = view.findViewById(R.id.tv_message); + // 滑动模块 + @SuppressLint({"MissingInflatedId", "LocalSuppress"}) SlideToUnlockView unlockView = view.findViewById(R.id.unlockView); + + if (latLng != null){ + tvMessage.setText("经度:" + latLng.latitude + "\n纬度:" + latLng.latitude); + } + + // 添加日志 + builder.setView(view); + + AlertDialog dialog = builder.create(); + dialog.show(); + + // 设置宽高 + Window window = dialog.getWindow(); + if (window != null) { + WindowManager.LayoutParams layoutParams = window.getAttributes(); + layoutParams.width = MyTool.dpToPx(context, 300); // 或具体像素值 + layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; // 或具体像素值 + window.setAttributes(layoutParams); + window.setBackgroundDrawableResource(R.drawable.ffffffff_4round_bg); + } + + unlockView.setText("滑动执行"); + unlockView.setOnUnlockListener(new SlideToUnlockView.OnUnlockListener() { + @Override + public void onUnlock() { +// // 发送命令 + + MyTool.hideBottomNavigationBar( context); + dialog.dismiss(); + // 滑动到阈值后触发(如关闭对话框或执行操作) + Toast.makeText(context, "操作已确认", Toast.LENGTH_SHORT).show(); + } + }); + + //取消按钮 + tvMessage.setOnClickListener(v -> { + dialog.dismiss(); + MyTool.hideBottomNavigationBar(context); + + }); + } + +} diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/View/SaveLinkNameDialog.java b/app/src/main/java/com/example/longyi_groundstation/Main/View/SaveLinkNameDialog.java new file mode 100644 index 0000000..6d918bf --- /dev/null +++ b/app/src/main/java/com/example/longyi_groundstation/Main/View/SaveLinkNameDialog.java @@ -0,0 +1,113 @@ +package com.example.longyi_groundstation.Main.View; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.example.longyi_groundstation.Main.Activity.MainActivity; +import com.example.longyi_groundstation.Main.Void.FlyVoid; +import com.example.longyi_groundstation.Main.Void.MyTool; +import com.example.longyi_groundstation.R; + +public class SaveLinkNameDialog { + + private final MainActivity context; + private String title; + private String message; + private String positiveButtonText; + + private FlyVoid flyVoid = new FlyVoid(); + + + public SaveLinkNameDialog(MainActivity context) { + this.context = context; + this.title = "错误日志"; + this.message = ""; + this.positiveButtonText = "确定"; + } + + // 设置弹窗标题 + public SaveLinkNameDialog setTitle(String title) { + this.title = title; + return this; + } + + // 设置弹窗内容 + public SaveLinkNameDialog setMessage(String message) { + this.message = message; + return this; + } + + // 设置确认按钮文字 + public SaveLinkNameDialog setPositiveButtonText(String text) { + this.positiveButtonText = text; + return this; + } + + // 显示弹窗 + public void show() { + MyTool.hideBottomNavigationBar( context); + AlertDialog.Builder builder = new AlertDialog.Builder(context); + + // 使用自定义布局 + View view = LayoutInflater.from(context).inflate(R.layout.dialog_link_name, null); + @SuppressLint({"MissingInflatedId", "LocalSuppress"}) TextView tvMessage = view.findViewById(R.id.tv_message); + // 滑动模块 + @SuppressLint({"MissingInflatedId", "LocalSuppress"}) SlideToUnlockView unlockView = view.findViewById(R.id.unlockView); + // 高度输入 + @SuppressLint({"MissingInflatedId", "LocalSuppress"}) EditText et_name = view.findViewById(R.id.et_name); + + + // 添加日志 + builder.setView(view); + + AlertDialog dialog = builder.create(); + dialog.show(); + + // 设置宽高 + Window window = dialog.getWindow(); + if (window != null) { + WindowManager.LayoutParams layoutParams = window.getAttributes(); + layoutParams.width = MyTool.dpToPx(context, 300); // 或具体像素值 + layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; // 或具体像素值 + window.setAttributes(layoutParams); + window.setBackgroundDrawableResource(R.drawable.ffffffff_4round_bg); + } + + unlockView.setText("滑动确认"); + unlockView.setOnUnlockListener(new SlideToUnlockView.OnUnlockListener() { + @Override + public void onUnlock() { + + if (et_name.getText().toString().length() > 0){ + context.saveLink(et_name.getText().toString()); + }else { + context.saveLink(null); + } + + + MyTool.hideBottomNavigationBar( context); + dialog.dismiss(); + // 滑动到阈值后触发(如关闭对话框或执行操作) + Toast.makeText(context, "操作已确认", Toast.LENGTH_SHORT).show(); + MyTool.hideBottomNavigationBar(context); + } + }); + + ; + //取消按钮 + tvMessage.setOnClickListener(v -> { + dialog.dismiss(); + MyTool.hideBottomNavigationBar(context); + }); + } + +} diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/View/SlideToUnlockView.java b/app/src/main/java/com/example/longyi_groundstation/Main/View/SlideToUnlockView.java index d2b278a..e6a6d9a 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/View/SlideToUnlockView.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/View/SlideToUnlockView.java @@ -8,7 +8,7 @@ import android.view.*; import android.view.animation.OvershootInterpolator; public class SlideToUnlockView extends View { - private static String DEFAULT_TEXT = "滑动执行"; + private String defaultText = "滑动执行"; // private float progress = 0f; private Paint paint; private Paint textPaint; @@ -23,7 +23,7 @@ public class SlideToUnlockView extends View { private float cornerRadius; // 背景圆角弧度 private float thumbCornerRadius; // 滑块圆角弧度 private int componentAlpha = 255; // 组件透明度,默认为完全不透明 - + public boolean isSlide = true;//是否可以滑动 public interface OnUnlockListener { void onUnlock(); @@ -94,8 +94,7 @@ public class SlideToUnlockView extends View { canvas.drawRoundRect(thumbRect, thumbCornerRadius, thumbCornerRadius, paint); // 3. 绘制文本(始终可见) - textPaint.setAlpha(componentAlpha); // 固定不透明度 - canvas.drawText(DEFAULT_TEXT, + canvas.drawText(defaultText, getWidth()/2f, getHeight()/2f + textPaint.getTextSize()/3, textPaint); @@ -109,38 +108,45 @@ public class SlideToUnlockView extends View { @Override public boolean onTouchEvent(MotionEvent event) { - float eventX = event.getX(); - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - // 检查是否点击在滑块上 - return thumbRect.contains(eventX, event.getY()); - case MotionEvent.ACTION_MOVE: - // 计算进度(限制在0-1) - progress = Math.max(0f, Math.min(1f, (eventX - minX) / (maxX - minX))); - invalidate(); - return true; - case MotionEvent.ACTION_UP: - if (progress > 0.7f) { - reboundAnimator.start(); - if (listener != null) listener.onUnlock(); - } else { - resetProgress(); - } - return true; + if (isSlide){ + float eventX = event.getX(); + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + // 检查是否点击在滑块上 + return thumbRect.contains(eventX, event.getY()); + case MotionEvent.ACTION_MOVE: + // 计算进度(限制在0-1) + progress = Math.max(0f, Math.min(1f, (eventX - minX) / (maxX - minX))); + invalidate(); + return true; + case MotionEvent.ACTION_UP: + if (progress > 0.7f) { +// reboundAnimator.start(); + isSlide = false; + if (listener != null) listener.onUnlock(); + } else { + resetProgress(); + } + return true; + } + return super.onTouchEvent(event); + }else { + return true; } - return super.onTouchEvent(event); + } - // 其他方法保持不变... - private void setProgress(float progress) { + // 设置进度 + public void setProgress(float progress) { this.progress = progress; invalidate(); } public void setText(String s) { - DEFAULT_TEXT = s; + this.defaultText = s; } + public void resetProgress() { ValueAnimator animator = ValueAnimator.ofFloat(progress, 0); animator.setDuration(300); @@ -169,18 +175,17 @@ public class SlideToUnlockView extends View { /** * 恢复到初始化状态 */ - public void resetToInitialState(String text) { + public void resetToInitialState(String text) { // 重置进度为0 progress = 0f; if (text != null){ setText(text); - }else { + } else { // 重置默认文本 - DEFAULT_TEXT = "滑动执行"; + this.defaultText = "滑动执行"; } - // 重置颜色为默认值 bgColor = Color.parseColor("#cfcfcf"); activeColor = Color.parseColor("#029A45"); diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/View/StartExecuteDialog.java b/app/src/main/java/com/example/longyi_groundstation/Main/View/StartExecuteDialog.java index 0635359..ba44397 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/View/StartExecuteDialog.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/View/StartExecuteDialog.java @@ -3,6 +3,7 @@ package com.example.longyi_groundstation.Main.View; import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; +import android.os.CountDownTimer; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -15,6 +16,7 @@ import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; +import com.example.longyi_groundstation.Main.Activity.MainActivity; import com.example.longyi_groundstation.Main.Void.FlyVoid; import com.example.longyi_groundstation.Main.Void.MyTool; import com.example.longyi_groundstation.R; @@ -26,9 +28,11 @@ public class StartExecuteDialog { private String message; private String positiveButtonText; private String height = "10"; - private FlyVoid flyVoid = new FlyVoid(); - + private CountDownTimer countDownTimer; + private AlertDialog dialog; + private TextView tvStartCountdown; + private TextView tvStartCancel; public StartExecuteDialog(Activity context, String height) { this.context = context; @@ -57,13 +61,16 @@ public class StartExecuteDialog { } // 显示弹窗 + @SuppressLint("MissingInflatedId") public void show() { - MyTool.hideBottomNavigationBar( context); + MyTool.hideBottomNavigationBar(context); AlertDialog.Builder builder = new AlertDialog.Builder(context); // 使用自定义布局 View view = LayoutInflater.from(context).inflate(R.layout.dialog_start_execute, null); @SuppressLint({"MissingInflatedId", "LocalSuppress"}) TextView tvMessage = view.findViewById(R.id.tv_message); + // 滑动模块-解锁 + @SuppressLint({"MissingInflatedId", "LocalSuppress"}) SlideToUnlockView unlockView_unlock = view.findViewById(R.id.unlockView_unlock); // 滑动模块 @SuppressLint({"MissingInflatedId", "LocalSuppress"}) SlideToUnlockView unlockView = view.findViewById(R.id.unlockView); // 高度 @@ -72,6 +79,10 @@ public class StartExecuteDialog { @SuppressLint({"MissingInflatedId", "LocalSuppress"}) Spinner sp_protect = view.findViewById(R.id.sp_protect); // 完成文字 @SuppressLint({"MissingInflatedId", "LocalSuppress"}) TextView tv_protect = view.findViewById(R.id.tv_protect); + // 取消执行 + tvStartCancel = view.findViewById(R.id.tv_start_cancel); + // 倒计时文字 + tvStartCountdown = view.findViewById(R.id.tv_start_countdown); //初始化下拉 String[] onePowerOptions = {"返航", "降落", "继续飞行"}; @@ -98,7 +109,7 @@ public class StartExecuteDialog { builder.setView(view); - AlertDialog dialog = builder.create(); + dialog = builder.create(); dialog.show(); // 设置宽高 @@ -111,27 +122,120 @@ public class StartExecuteDialog { window.setBackgroundDrawableResource(R.drawable.ffffffff_4round_bg); } + //判断是否解锁 + if (MainActivity.isUnlock){ + unlockView_unlock.setProgress(1f); + unlockView_unlock.isSlide = false; + } + unlockView_unlock.setText("滑动解锁"); + unlockView_unlock.setOnUnlockListener(new SlideToUnlockView.OnUnlockListener() { + @Override + public void onUnlock() { + //解锁飞机 + flyVoid.requestArm(); + new Thread(() -> { + for (int i = 0; i < 6; i++) { + try { + Thread.sleep(490); + if (i == 5){ + context.runOnUiThread(() -> { + unlockView_unlock.setProgress(0f); + unlockView_unlock.resetProgress(); + Toast.makeText(context, "解锁失败", Toast.LENGTH_SHORT).show(); + }); + break; + } + + if (MainActivity.isUnlock){ + // 滑动到阈值后触发(如关闭对话框或执行操作) + context.runOnUiThread(() -> { + Toast.makeText(context, "解锁成功", Toast.LENGTH_SHORT).show(); + unlockView_unlock.setProgress(1f); + unlockView_unlock.isSlide = false; + }); + break; + } + + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }).start(); + } + }); unlockView.setText("滑动执行"); unlockView.setOnUnlockListener(new SlideToUnlockView.OnUnlockListener() { @Override public void onUnlock() { -// // 发送命令 - // 调用FlyVoid中的方法发送航线到飞控 - flyVoid.requestMissionStart(0,0); - MyTool.hideBottomNavigationBar( context); - dialog.dismiss(); - // 滑动到阈值后触发(如关闭对话框或执行操作) - Toast.makeText(context, "开始执行航线", Toast.LENGTH_SHORT).show(); + if (MainActivity.isUnlock){ + // 开始5秒倒计时 + startCountdown(); + }else { + Toast.makeText(context, "请先解锁", Toast.LENGTH_SHORT).show(); + unlockView.isSlide = true; + unlockView.resetProgress(); + } } }); - ; //取消按钮 tvMessage.setOnClickListener(v -> { + cancelCountdown(); dialog.dismiss(); MyTool.hideBottomNavigationBar(context); }); + + // 取消执行按钮 + tvStartCancel.setOnClickListener(v -> { + cancelCountdown(); + // 隐藏倒计时和取消按钮 + tvStartCountdown.setVisibility(View.GONE); + tvStartCancel.setVisibility(View.GONE); + // 重置滑动条 + unlockView.isSlide = true; + unlockView.resetProgress(); + }); + } + + // 开始5秒倒计时 + private void startCountdown() { + // 显示倒计时和取消按钮 + tvStartCountdown.setVisibility(View.VISIBLE); + tvStartCancel.setVisibility(View.VISIBLE); + tvStartCountdown.setText("执行倒计时 5"); + + // 创建倒计时器 + countDownTimer = new CountDownTimer(3000, 1000) { + @Override + public void onTick(long millisUntilFinished) { + int seconds = (int) (millisUntilFinished / 1000); + tvStartCountdown.setText("执行倒计时 " + seconds); + } + + @Override + public void onFinish() { + // 倒计时结束,执行任务 + if (dialog != null && dialog.isShowing()) { + dialog.dismiss(); + } + MyTool.hideBottomNavigationBar(context); + flyVoid.requestMissionStart(0, 0); + Toast.makeText(context, "开始执行航线", Toast.LENGTH_SHORT).show(); + + // 隐藏倒计时和取消按钮 + tvStartCountdown.setVisibility(View.GONE); + tvStartCancel.setVisibility(View.GONE); + } + }.start(); + } + + // 取消倒计时 + private void cancelCountdown() { + if (countDownTimer != null) { + countDownTimer.cancel(); + countDownTimer = null; + } } private void initSpinners() { diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Void/AllView.java b/app/src/main/java/com/example/longyi_groundstation/Main/Void/AllView.java index e00dbef..dea08f1 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Void/AllView.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Void/AllView.java @@ -35,19 +35,15 @@ public class AllView { public TextView tv_power; public TextView tv_connect; public ImageView iv_error; - public LinearLayout ll_line_fly_layout; public LinearLayout ll_pitch; public CircularLinearLayout cll_layout; public ImageView iv_yaw; public View v_welkin; public TextView tv_yaw; public View v_mainDisplay; - public ImageView iv_location_me; -// public ImageView iv_line_fly; public LinearLayout ll_turn_back; public LinearLayout ll_lift_off; public LinearLayout ll_icon_land; - public LinearLayout ll_mode_select; public RecyclerView rv_error_list; public LinearLayout ll_left_error_layout; public LinearLayout ll_setting; @@ -56,16 +52,11 @@ public class AllView { public LinearLayout ll_left_open; public LinearLayout ll_function_layout; public LinearLayout ll_clear; - public LinearLayout ll_antenna; public LinearLayout ll_map; - public LinearLayout ll_one_word; public LinearLayout ll_execute_line; - public LinearLayout ll_joystick; - public LinearLayout ll_fire; public LinearLayout ll_bombing; public LinearLayout ll_shout; public LinearLayout ll_searchlight; - public LinearLayout ll_thoroughfare; public LinearLayout ll_hook; public ImageView iv_ptz_top; public ImageView iv_ptz_left; @@ -83,8 +74,8 @@ public class AllView { public LinearLayout ll_text; public LinearLayout ll_link; public LinearLayout ll_link_save; - public LinearLayout ll_link_fun1; - public LinearLayout ll_link_fun2; + public TextView tv_link_fun1; + public TextView tv_link_fun2; public LinearLayout ll_link_back; public LinearLayout ll_create_link_layout; public RecyclerView rv_create_link_list; @@ -94,9 +85,19 @@ public class AllView { public LinearLayout ll_link_start_fun1; public LinearLayout ll_link_start_fun2; public LinearLayout ll_link_start_back; + public TextView tv_add_link; + public LinearLayout ll_assistance_layout; + public EditText et_link_name; + public LinearLayout ll_location_me; + public EditText et_link_search; + public TextView tv_test1; + public ImageView iv_open_link_list; + public LinearLayout ll_clear_fly_line; + public LinearLayout ll_create_link_item_layout; - public SlideToUnlockView unlockView; - public RelativeLayout rl_unlock; + +// public SlideToUnlockView unlockView; +// public RelativeLayout rl_unlock; public EditText et_start_execute_height; @@ -119,18 +120,15 @@ public class AllView { tv_power = activity.findViewById(R.id.tv_power); tv_connect = activity.findViewById(R.id.tv_connect); iv_error = activity.findViewById(R.id.iv_error); - ll_line_fly_layout = activity.findViewById(R.id.ll_line_fly_layout); ll_pitch = activity.findViewById(R.id.ll_pitch); cll_layout = activity.findViewById(R.id.cll_layout); iv_yaw = activity.findViewById(R.id.iv_yaw); v_welkin = activity.findViewById(R.id.v_welkin); tv_yaw = activity.findViewById(R.id.tv_yaw); v_mainDisplay = activity.findViewById(R.id.v_mainDisplay); - iv_location_me = activity.findViewById(R.id.iv_location_me); ll_turn_back = activity.findViewById(R.id.ll_turn_back); ll_lift_off = activity.findViewById(R.id.ll_lift_off); ll_icon_land = activity.findViewById(R.id.ll_icon_land); - ll_mode_select = activity.findViewById(R.id.ll_mode_select); rv_error_list = activity.findViewById(R.id.rv_error_list); ll_left_error_layout = activity.findViewById(R.id.ll_left_error_layout); ll_setting = activity.findViewById(R.id.ll_setting); @@ -139,16 +137,11 @@ public class AllView { ll_left_open = activity.findViewById(R.id.ll_left_open); ll_function_layout = activity.findViewById(R.id.ll_function_layout); ll_clear = activity.findViewById(R.id.ll_clear); - ll_antenna = activity.findViewById(R.id.ll_antenna); ll_map = activity.findViewById(R.id.ll_map); - ll_one_word = activity.findViewById(R.id.ll_one_word); ll_execute_line = activity.findViewById(R.id.ll_execute_line); - ll_joystick = activity.findViewById(R.id.ll_joystick); - ll_fire = activity.findViewById(R.id.ll_fire); ll_bombing = activity.findViewById(R.id.ll_bombing); ll_shout = activity.findViewById(R.id.ll_shout); ll_searchlight = activity.findViewById(R.id.ll_searchlight); - ll_thoroughfare = activity.findViewById(R.id.ll_thoroughfare); ll_hook = activity.findViewById(R.id.ll_hook); iv_ptz_top = activity.findViewById(R.id.iv_ptz_top); iv_ptz_left = activity.findViewById(R.id.iv_ptz_left); @@ -166,8 +159,8 @@ public class AllView { ll_text= activity.findViewById(R.id.ll_text); ll_link = activity.findViewById(R.id.ll_link); ll_link_save = activity.findViewById(R.id.ll_link_save); - ll_link_fun1 = activity.findViewById(R.id.ll_link_fun1); - ll_link_fun2 = activity.findViewById(R.id.ll_link_fun2); + tv_link_fun1 = activity.findViewById(R.id.tv_link_fun1); + tv_link_fun2 = activity.findViewById(R.id.tv_link_fun2); ll_link_back = activity.findViewById(R.id.ll_link_back); ll_create_link_layout = activity.findViewById(R.id.ll_create_link_layout); rv_create_link_list = activity.findViewById(R.id.rv_create_link_list); @@ -177,9 +170,18 @@ public class AllView { ll_link_start_fun1 = activity.findViewById(R.id.ll_link_start_fun1); ll_link_start_fun2 = activity.findViewById(R.id.ll_link_start_fun2); ll_link_start_back = activity.findViewById(R.id.ll_link_start_back); - unlockView = activity.findViewById(R.id.unlockView); - rl_unlock = activity.findViewById(R.id.rl_unlock); +// unlockView = activity.findViewById(R.id.unlockView); +// rl_unlock = activity.findViewById(R.id.rl_unlock); + ll_location_me = activity.findViewById(R.id.ll_location_me); et_start_execute_height = activity.findViewById(R.id.et_start_execute_height); + tv_add_link = activity.findViewById(R.id.tv_add_link); + ll_assistance_layout = activity.findViewById(R.id.ll_assistance_layout); + et_link_name = activity.findViewById(R.id.et_link_name); + et_link_search = activity.findViewById(R.id.et_link_search); + tv_test1 = activity.findViewById(R.id.tv_test1); + ll_clear_fly_line = activity.findViewById(R.id.ll_clear_fly_line); + ll_create_link_item_layout = activity.findViewById(R.id.ll_create_link_item_layout); + iv_open_link_list = activity.findViewById(R.id.iv_open_link_list); } } diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Void/FlyVoid.java b/app/src/main/java/com/example/longyi_groundstation/Main/Void/FlyVoid.java index 5bcf2c0..4a873ac 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Void/FlyVoid.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Void/FlyVoid.java @@ -80,10 +80,10 @@ public class FlyVoid { isParamUpdateComplete = isComplete; } - public void setAttitude(Context content, AllView allView, double roll, double pitch, double yaw) { + public void setAttitude(Context content, AllView allView, double roll, double pitch, int yaw) { //设置偏航 // allView.iv_yaw.setRotation((int) Math.round(yaw * 57.2)); - allView.iv_yaw.setRotation((int) Math.toDegrees(yaw * -1)); + allView.iv_yaw.setRotation((yaw + 360) * -1); //设置翻滚 allView.cll_layout.setPivotX((float) allView.cll_layout.getWidth() / 2); @@ -375,7 +375,7 @@ public class FlyVoid { // 创建 ProgressDialog android.app.ProgressDialog progressDialog = new android.app.ProgressDialog(context); - progressDialog.setTitle("任务执行中"); + progressDialog.setTitle("任务上传中"); progressDialog.setMessage("正在发送航线到飞控..."); progressDialog.setProgressStyle(android.app.ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(false); // 设置不可手动关闭 @@ -419,7 +419,7 @@ public class FlyVoid { sentWaypoints = seq + 1; // 更新发送进度 - final int progress = (int) ((sentWaypoints / (float) totalWaypoints) * 50); // 发送占50%进度 + final int progress = (int) ((sentWaypoints / (float) totalWaypoints) * 92); // 发送占50%进度 context.runOnUiThread(() -> { progressDialog.setProgress(progress); }); @@ -455,8 +455,7 @@ public class FlyVoid { progressDialog.dismiss(); if (verifyResult) { - Toast.makeText(context, "航线已发送到飞控并校验通过", Toast.LENGTH_SHORT).show(); - startExecuteDialog.show(); + Toast.makeText(context, "航线上传成功", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, "航线发送完成但校验失败", Toast.LENGTH_SHORT).show(); } @@ -475,6 +474,60 @@ public class FlyVoid { } + /** + * 方法:整理收到的点位,并且转换成mavlink可以识别的格式 + * + * @cuijingzhou + * */ + private void creatDataList (ArrayList createLinkList, String height) { + ArrayList dataList = new ArrayList<>(); + //home点,默认第一个为home点 + msg_mission_item_int waypoint = new msg_mission_item_int(); + waypoint.target_system = 1; // 无人机系统ID + waypoint.target_component = 1; // 无人机组件ID + waypoint.seq = 0; // 航点序号 + waypoint.frame = MAV_FRAME.MAV_FRAME_GLOBAL_RELATIVE_ALT; // 坐标系 + waypoint.command = MAV_CMD.MAV_CMD_NAV_WAYPOINT; // 航点指令 + waypoint.current = 1 ; // 第一个航点设为当前航点 + waypoint.autocontinue = 1; // 自动继续到下一个航点 + waypoint.param1 = 0; // 停留时间(秒) + waypoint.param2 = 0; // 接受半径(m) + waypoint.param3 = 0; // 通过半径(m) + waypoint.param4 = 0; // 航向角 + waypoint.x = 0; + waypoint.y = 0; + waypoint.z = 0; // 高度(相对) + dataList.add(waypoint); + //起飞,将飞机拉起来 + msg_mission_item_int waypoint1 = new msg_mission_item_int(); + waypoint1.target_system = 1; // 无人机系统ID + waypoint1.target_component = 1; // 无人机组件ID + waypoint1.seq = 1; // 航点序号 + waypoint1.frame = MAV_FRAME.MAV_FRAME_GLOBAL_RELATIVE_ALT; // 坐标系 + waypoint1.command = MAV_CMD.MAV_CMD_NAV_TAKEOFF; // 航点指令 + waypoint1.current = 0; // 第一个航点设为当前航点 + waypoint1.autocontinue = 1; // 自动继续到下一个航点 + waypoint1.param1 = 0; // 停留时间(秒) + waypoint1.param2 = 0; // 接受半径(m) + waypoint1.param3 = 0; // 通过半径(m) + waypoint1.param4 = 0; // 航向角 + waypoint1.x = 0; + waypoint1.y = 0; + waypoint1.z = Float.parseFloat(height); // 高度(相对) + waypoint1.mission_type = MAV_MISSION_TYPE.MAV_MISSION_TYPE_MISSION; + +// //添加航点 +// for (int i = 0; i < createLinkList.size(); i++) { +// if (){ +// +// } +// } + + + } + + + /** * 方法:给飞控发送点位 * @@ -763,6 +816,4 @@ public class FlyVoid { } - - } diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Void/MapVoid.java b/app/src/main/java/com/example/longyi_groundstation/Main/Void/MapVoid.java index 42ba12b..50152d4 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Void/MapVoid.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Void/MapVoid.java @@ -8,6 +8,8 @@ import android.graphics.Paint; import android.graphics.Rect; import android.location.Location; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.util.Log; import android.view.View; import android.widget.TextView; @@ -118,6 +120,115 @@ public class MapVoid { + // 在成员变量部分添加 + public List flightTrackPoints = new ArrayList<>(); // 飞行轨迹点 + public Polyline flightTrackPolyline = null; // 飞行轨迹线 + public Handler flightTrackHandler = new Handler(Looper.getMainLooper()); // 轨迹更新Handler + public Runnable flightTrackRunnable; // 轨迹更新任务 + public boolean isTracking = false; // 是否正在追踪 + /** + * 开始飞行轨迹跟踪 + */ + public void startFlightTracking() { + if (isTracking) return; + + isTracking = true; + flightTrackPoints.clear(); + + flightTrackRunnable = new Runnable() { + @Override + public void run() { + try { + if (isTracking) { + // 获取当前飞机位置 + double lat = MyReceiver.GLOBAL_POSITION_INT_json.optDouble("lat", 0) / 10000000; + double lon = MyReceiver.GLOBAL_POSITION_INT_json.optDouble("lon", 0) / 10000000; + + // 检查坐标有效性 + if (lat != 0 && lon != 0) { + // 转换坐标 + double[] convertedCoords = CoordinateConverter.wgs84ToGcj02(lon, lat); + if (convertedCoords != null && convertedCoords.length >= 2) { + LatLng currentPos = new LatLng(convertedCoords[1], convertedCoords[0]); + + // 添加到轨迹点列表 + flightTrackPoints.add(currentPos); + + // 更新轨迹线 + updateFlightTrack(); + } + } + // 0.3秒后再次执行 + flightTrackHandler.postDelayed(this, 600); + } + } catch (Exception e) { +// e.printStackTrace(); + Log.d(TAG, "error: "+e); + // 2秒后再次执行 + flightTrackHandler.postDelayed(this, 600); + } + + } + }; + + // 立即开始第一次执行 + flightTrackHandler.post(flightTrackRunnable); + } + + /** + * 停止飞行轨迹跟踪 + */ + public void stopFlightTracking() { + isTracking = false; + if (flightTrackRunnable != null) { + flightTrackHandler.removeCallbacks(flightTrackRunnable); + } + } + + /** + * 更新飞行轨迹线 + */ + public void updateFlightTrack() { + // 移除旧的轨迹线 + if (flightTrackPolyline != null) { + flightTrackPolyline.remove(); + } + + // 控制轨迹点数量不超过20个 + if (flightTrackPoints.size() > 2048) { + flightTrackPoints.remove(0); // 删除最后一个点 + } + + List sparsePoints = new ArrayList<>(); + // 每5个点取1个点,减少点密度 + for (int i = 0; i < flightTrackPoints.size(); i += 5) { + sparsePoints.add(flightTrackPoints.get(i)); + } + + flightTrackPolyline = allView.map.getMap().addPolyline(new PolylineOptions() + .addAll(sparsePoints) + .width(12) + .color(Color.RED) + .setDottedLine(true) + .setDottedLineType(PolylineOptions.DOTTEDLINE_TYPE_CIRCLE)); + + } + + /** + * 清除飞行轨迹 + */ + public void clearFlightTrack() { + stopFlightTracking(); + + // 移除轨迹线 + if (flightTrackPolyline != null) { + flightTrackPolyline.remove(); + flightTrackPolyline = null; + } + + // 清空轨迹点 + flightTrackPoints.clear(); + } diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Void/MyReceiver.java b/app/src/main/java/com/example/longyi_groundstation/Main/Void/MyReceiver.java index 483b97c..53c3c49 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Void/MyReceiver.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Void/MyReceiver.java @@ -20,8 +20,10 @@ public class MyReceiver extends BroadcastReceiver { public static JSONObject PARAM_VALUE_json = null;//飞机基础飞行模式 public static JSONObject RC_CHANNELS_json = null;//RC通道监控 public static JSONObject VFR_HUD_json = null;//油门量 - public static JSONObject MISSION_REQUEST_json = null;//路线上传报错回调 + public static JSONObject MISSION_REQUEST_json = null;//航线上传报错回调 public static JSONObject MISSION_ACK_json = null;//路线上传穿插回调 + public static JSONObject MISSION_CURRENT_json = null;//路线上传穿插回调 + //ATTITUDE @@ -93,7 +95,10 @@ public class MyReceiver extends BroadcastReceiver { } private OnMissionAckListener MissionAcklistener; - + public interface OnMissionCurrentListener { + void onMissionCurrent(JSONObject data); + } + private OnMissionCurrentListener MissionCurrentlistener; public void setATTITUDEListener(OnATTITUDEListener listener) { @@ -136,7 +141,9 @@ public class MyReceiver extends BroadcastReceiver { public void setMissionAcklistener(OnMissionAckListener listener) { this.MissionAcklistener = listener; } - + public void setMissionCurrentlistener(OnMissionCurrentListener listener) { + this.MissionCurrentlistener = listener; + } @Override public void onReceive(Context context, Intent intent) { @@ -360,5 +367,25 @@ public class MyReceiver extends BroadcastReceiver { Log.e("cuijingzhou-e Broadcast_MISSION_ACK", e.toString()); } } + + if ("Broadcast_MISSION_CURRENT".equals(intent.getAction())) { + try { + String receivedData = intent.getStringExtra("data"); + if (receivedData != null) { + MISSION_CURRENT_json = new JSONObject(receivedData); + MISSION_CURRENT_json.optString("jsonObject"); +// Log.d("cuijingzhou", "onReceive: " + receivedData); + // 触发回调 + if (MissionCurrentlistener != null) { + MissionCurrentlistener.onMissionCurrent(MISSION_CURRENT_json); + } + } + + } catch (Exception e) { + Log.e("cuijingzhou-e Broadcast_MISSION_CURRENT", e.toString()); + } + } + + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/longyi_groundstation/Main/Void/SQLClass.java b/app/src/main/java/com/example/longyi_groundstation/Main/Void/SQLClass.java index a3d0968..fbee95f 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Main/Void/SQLClass.java +++ b/app/src/main/java/com/example/longyi_groundstation/Main/Void/SQLClass.java @@ -22,7 +22,7 @@ import java.util.List; * // 添加一个CreateLink列表 * ArrayList createLinkList = new ArrayList<>(); * // ... 添加CreateLink对象到列表中 - * boolean success = sqlClass.addCreateLinkList("路线1", createLinkList); + * boolean success = sqlClass.addCreateLinkList("航线1", createLinkList); * * // 获取所有列表信息 * List listInfos = sqlClass.getAllLinkListInfo(); @@ -31,7 +31,7 @@ import java.util.List; * ArrayList retrievedList = sqlClass.getCreateLinkList(1); * * // 更新列表 - * sqlClass.updateCreateLinkList(1, "新路线名称", updatedCreateLinkList); + * sqlClass.updateCreateLinkList(1, "新航线名称", updatedCreateLinkList); * * // 删除列表 * sqlClass.deleteCreateLinkList(1); @@ -65,6 +65,10 @@ public class SQLClass extends SQLiteOpenHelper { private static final String COLUMN_WAYPOINT_INDEX = "waypoint_index"; private static final String COLUMN_LATITUDE = "latitude"; private static final String COLUMN_LONGITUDE = "longitude"; + private static final String COLUMN_BOM1_SELECT = "bom1_select"; + private static final String COLUMN_BOM2_SELECT = "bom2_select"; + + private static final String COLUMN_ITEM_ORDER = "item_order"; // 项在列表中的顺序 // 创建主表的SQL语句 @@ -120,8 +124,8 @@ public class SQLClass extends SQLiteOpenHelper { */ public boolean addCreateLinkList(String listName, ArrayList createLinkList) { // 检查是否已达到最大数量限制 - if (getLinkListCount() >= 10) { - Log.w(TAG, "已达到最大存储数量限制(10个列表),无法添加新列表"); + if (getLinkListCount() >= 10000) { + Log.w(TAG, "已达到最大存储数量限制(10000个列表),无法添加新列表"); return false; } @@ -235,6 +239,8 @@ public class SQLClass extends SQLiteOpenHelper { int waypointIndex = cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_WAYPOINT_INDEX)); double latitude = cursor.getDouble(cursor.getColumnIndexOrThrow(COLUMN_LATITUDE)); double longitude = cursor.getDouble(cursor.getColumnIndexOrThrow(COLUMN_LONGITUDE)); +// boolean bom1_select = cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_BOM1_SELECT)) == 1; +// boolean bom2_select = cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_BOM2_SELECT)) == 1; LatLng latLng = new LatLng(latitude, longitude); CreateLink createLink = new CreateLink(name, height, speed, waypointIndex, latLng); @@ -419,6 +425,14 @@ public class SQLClass extends SQLiteOpenHelper { private int listId; private String listName; private long createdTime; + private boolean isSelect; + + public LinkListInfo(int listId, String listName, long createdTime, boolean isSelect) { + this.listId = listId; + this.listName = listName; + this.createdTime = createdTime; + this.isSelect = isSelect; + } public LinkListInfo(int listId, String listName, long createdTime) { this.listId = listId; @@ -430,12 +444,32 @@ public class SQLClass extends SQLiteOpenHelper { return listId; } + public void setListId(int listId) { + this.listId = listId; + } + public String getListName() { return listName; } + public void setListName(String listName) { + this.listName = listName; + } + public long getCreatedTime() { return createdTime; } + + public void setCreatedTime(long createdTime) { + this.createdTime = createdTime; + } + + public boolean isSelect() { + return isSelect; + } + + public void setSelect(boolean select) { + isSelect = select; + } } } diff --git a/app/src/main/java/com/example/longyi_groundstation/Util/BroadcastUtil.java b/app/src/main/java/com/example/longyi_groundstation/Util/BroadcastUtil.java index c3c2159..d6d366a 100644 --- a/app/src/main/java/com/example/longyi_groundstation/Util/BroadcastUtil.java +++ b/app/src/main/java/com/example/longyi_groundstation/Util/BroadcastUtil.java @@ -172,6 +172,18 @@ public class BroadcastUtil { intent.clone(); } + /** + * MAVLINK_MSG_ID_MISSION_CURRENT + * + * @param context 上下文 + * @param data 数据-json + */ + public static void Broadcast_MISSION_CURRENT(Context context, String data) { + Intent intent = new Intent("Broadcast_MISSION_CURRENT"); + intent.putExtra("data", data); + context.sendBroadcast(intent); + intent.clone(); + } } diff --git a/app/src/main/java/com/example/longyi_groundstation/Util/Url.java b/app/src/main/java/com/example/longyi_groundstation/Util/Url.java new file mode 100644 index 0000000..7c49cb6 --- /dev/null +++ b/app/src/main/java/com/example/longyi_groundstation/Util/Url.java @@ -0,0 +1,18 @@ +package com.example.longyi_groundstation.Util; + +public class Url { + + public static String getBaseUrl() { + return "https://api.longyi-uav-cloud.com"; + } + + /** + * 方法:登录接口 + * + * @cuijingzhou + */ + public static String LoginUrl() { + return getBaseUrl() + "/admin-api/system/auth/login"; + } + +} diff --git a/app/src/main/res/drawable/custom_seekbar_progress.xml b/app/src/main/res/drawable/custom_seekbar_progress.xml new file mode 100644 index 0000000..2d79d89 --- /dev/null +++ b/app/src/main/res/drawable/custom_seekbar_progress.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/custom_seekbar_thumb.xml b/app/src/main/res/drawable/custom_seekbar_thumb.xml new file mode 100644 index 0000000..96f8971 --- /dev/null +++ b/app/src/main/res/drawable/custom_seekbar_thumb.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/ff60b964_4round_1stroke_bg.xml b/app/src/main/res/drawable/ff029a45_2round_1stroke_bg.xml similarity index 86% rename from app/src/main/res/drawable/ff60b964_4round_1stroke_bg.xml rename to app/src/main/res/drawable/ff029a45_2round_1stroke_bg.xml index 81dbea6..1653cb7 100644 --- a/app/src/main/res/drawable/ff60b964_4round_1stroke_bg.xml +++ b/app/src/main/res/drawable/ff029a45_2round_1stroke_bg.xml @@ -3,10 +3,10 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ff62a7f0_2round_1stroke_bg.xml b/app/src/main/res/drawable/ff029a45_4round_1stroke_bg.xml similarity index 86% rename from app/src/main/res/drawable/ff62a7f0_2round_1stroke_bg.xml rename to app/src/main/res/drawable/ff029a45_4round_1stroke_bg.xml index df44ab5..09097ab 100644 --- a/app/src/main/res/drawable/ff62a7f0_2round_1stroke_bg.xml +++ b/app/src/main/res/drawable/ff029a45_4round_1stroke_bg.xml @@ -3,10 +3,10 @@ + + - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ff33b138_1round_1stroke.xml b/app/src/main/res/drawable/ff33b138_1round_1stroke.xml new file mode 100644 index 0000000..d60c5c0 --- /dev/null +++ b/app/src/main/res/drawable/ff33b138_1round_1stroke.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ffdd635a_4round_1stroke_bg.xml b/app/src/main/res/drawable/ffdf4b40_4round_1stroke_bg.xml similarity index 86% rename from app/src/main/res/drawable/ffdd635a_4round_1stroke_bg.xml rename to app/src/main/res/drawable/ffdf4b40_4round_1stroke_bg.xml index f974f40..40ea10f 100644 --- a/app/src/main/res/drawable/ffdd635a_4round_1stroke_bg.xml +++ b/app/src/main/res/drawable/ffdf4b40_4round_1stroke_bg.xml @@ -3,7 +3,7 @@ - + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ffffffff_4round_bg.xml b/app/src/main/res/drawable/ffffffff_4round_bg.xml index c288fbf..d5b53b6 100644 --- a/app/src/main/res/drawable/ffffffff_4round_bg.xml +++ b/app/src/main/res/drawable/ffffffff_4round_bg.xml @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/app/src/main/res/drawable/icon_fly.png b/app/src/main/res/drawable/icon_fly.png deleted file mode 100644 index 7af97cf..0000000 Binary files a/app/src/main/res/drawable/icon_fly.png and /dev/null differ diff --git a/app/src/main/res/drawable/x80000000_4round_1stroke_bg.xml b/app/src/main/res/drawable/x80000000_4round_1stroke_bg.xml new file mode 100644 index 0000000..b5fbd1d --- /dev/null +++ b/app/src/main/res/drawable/x80000000_4round_1stroke_bg.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index dc278a9..6461afe 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -57,34 +57,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ca9d871..58ad39b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -499,6 +499,7 @@ android:padding="5dp"> - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_height="match_parent" + android:layout_marginTop="3dp" /> @@ -1029,32 +1275,29 @@ + android:padding="5dp"> + android:src="@mipmap/icon_one_word" /> - @@ -1066,9 +1309,9 @@ + android:visibility="visible"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1282,32 +1384,6 @@ - - - - - - - - @@ -1318,37 +1394,11 @@ android:orientation="horizontal" android:visibility="visible"> - - - - - - - - - - - - - - - - - + + android:src="@mipmap/icon_shout" /> - + - - - - - - + @@ -1503,7 +1508,7 @@ - + @@ -1538,45 +1543,6 @@ - - - - - - - - - - - - - - + + android:orientation="horizontal" + android:padding="2dp"> + android:textSize="7sp" /> + android:textSize="9sp" /> @@ -1650,11 +1616,10 @@ android:layout_width="65dp" android:layout_height="28dp" android:layout_marginTop="4dp" - android:background="@drawable/ff60b964_4round_1stroke_bg" + android:background="@drawable/ff029a45_4round_1stroke_bg" android:gravity="center" android:orientation="horizontal"> - - + android:orientation="horizontal" + android:visibility="gone"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_play_back.xml b/app/src/main/res/layout/activity_play_back.xml index 5b762e7..5e6bd62 100644 --- a/app/src/main/res/layout/activity_play_back.xml +++ b/app/src/main/res/layout/activity_play_back.xml @@ -225,7 +225,7 @@ android:layout_weight="1" android:layout_margin="5dp" /> - + @@ -55,7 +55,7 @@ + + - - - - - - - - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/adapter_control_data_item.xml b/app/src/main/res/layout/adapter_control_data_item.xml index 66d8e8e..d7fda06 100644 --- a/app/src/main/res/layout/adapter_control_data_item.xml +++ b/app/src/main/res/layout/adapter_control_data_item.xml @@ -56,7 +56,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:background="#62a7f0" /> + android:background="#029a45" /> - + + android:textSize="8sp" + android:text="1" + android:layout_width="20dp" + android:layout_height="match_parent"/> - + + + android:background="@drawable/ff33b138_1round_1stroke" + android:gravity="center" + android:text="1" + android:textSize="7sp" + android:id="@+id/et_speed" + android:layout_width="40dp" + android:layout_height="match_parent"/> - + + + + - + android:gravity="center" + android:background="@drawable/ff33b138_1round_1stroke" + android:layout_width="99.5dp" + android:layout_height="match_parent"> - - + android:text="删除" + android:layout_width="42dp" + android:layout_height="18dp"/> + android:text="展开" + android:layout_width="42dp" + android:layout_height="18dp"/> - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/adapter_secure_item.xml b/app/src/main/res/layout/adapter_secure_item.xml index 4868851..11d6fd5 100644 --- a/app/src/main/res/layout/adapter_secure_item.xml +++ b/app/src/main/res/layout/adapter_secure_item.xml @@ -33,7 +33,7 @@ android:layout_height="22dp" android:layout_marginLeft="5dp" android:layout_weight="1" - android:background="@drawable/ff62a7f0_2round_1stroke_bg" + android:background="@drawable/ff029a45_2round_1stroke_bg" android:orientation="vertical"> @@ -9,20 +9,22 @@ + diff --git a/app/src/main/res/layout/dialog_link_name.xml b/app/src/main/res/layout/dialog_link_name.xml new file mode 100644 index 0000000..43526e0 --- /dev/null +++ b/app/src/main/res/layout/dialog_link_name.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/dialog_point_fly.xml b/app/src/main/res/layout/dialog_point_fly.xml new file mode 100644 index 0000000..dc50d07 --- /dev/null +++ b/app/src/main/res/layout/dialog_point_fly.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/dialog_start_execute.xml b/app/src/main/res/layout/dialog_start_execute.xml index a17dbc2..682a56a 100644 --- a/app/src/main/res/layout/dialog_start_execute.xml +++ b/app/src/main/res/layout/dialog_start_execute.xml @@ -30,7 +30,7 @@ @@ -116,7 +116,7 @@ - + + + + + + @@ -11,7 +11,7 @@ android:textSize="10sp" android:layout_alignParentRight="true" android:layout_margin="6dp" - android:background="@drawable/ff62a7f0_2round_1stroke_bg" + android:background="@drawable/ff029a45_2round_1stroke_bg" android:textColor="#ffffff" android:id="@+id/tv_calibration" android:gravity="center" @@ -21,7 +21,7 @@ android:layout_height="wrap_content"/> @@ -32,7 +32,7 @@ android:layout_marginRight="20dp" android:gravity="center" android:textColor="#ffffff" - android:background="@drawable/ff62a7f0_2round_1stroke_bg" + android:background="@drawable/ff029a45_2round_1stroke_bg" android:textSize="10sp" android:text="恢复默认" android:paddingLeft="20dp" @@ -45,7 +45,7 @@ android:id="@+id/tv_save" android:gravity="center" android:textColor="#ffffff" - android:background="@drawable/ff60b964_4round_1stroke_bg" + android:background="@drawable/ff029a45_2round_1stroke_bg" android:textSize="10sp" android:text="保存" android:layout_width="42dp" @@ -80,7 +80,7 @@ android:text="-" android:textColor="#ffffff" android:textSize="10sp" - android:background="@drawable/ff62a7f0_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> - /> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:thumb="@drawable/custom_seekbar_thumb" /> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:thumb="@drawable/custom_seekbar_thumb" /> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:thumb="@drawable/custom_seekbar_thumb" /> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:thumb="@drawable/custom_seekbar_thumb" /> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> - + + + + + + - + android:layout_height="wrap_content"> - + + + + + + + + + android:layout_height="wrap_content"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_load.xml b/app/src/main/res/layout/fragment_load.xml index 6d0a106..b6473cf 100644 --- a/app/src/main/res/layout/fragment_load.xml +++ b/app/src/main/res/layout/fragment_load.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#ff112446" + android:background="#101010" android:orientation="vertical" tools:context=".Main.Setting.Fragment.LoadFragment"> @@ -33,7 +33,7 @@ android:textSize="10sp" android:id="@+id/tv_save" android:textColor="#ffffff" - android:background="@drawable/ff60b964_4round_1stroke_bg" + android:background="@drawable/ff029a45_4round_1stroke_bg" android:padding="5dp" android:gravity="center" android:text="保存" @@ -134,7 +134,7 @@ android:layout_height="22dp" android:layout_marginLeft="5dp" android:layout_weight="1" - android:background="@drawable/ff62a7f0_2round_1stroke_bg" + android:background="@drawable/ff029a45_2round_1stroke_bg" android:orientation="vertical"> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> @@ -44,7 +44,7 @@ android:id="@+id/tv_add" android:gravity="center" android:textColor="#ffffff" - android:background="@drawable/ff60b964_4round_1stroke_bg" + android:background="@drawable/ff029a45_4round_1stroke_bg" android:textSize="10sp" android:text="+ 增加" android:layout_width="42dp" @@ -56,7 +56,7 @@ android:layout_marginLeft="10dp" android:gravity="center" android:textColor="#ffffff" - android:background="@drawable/ffdd635a_4round_1stroke_bg" + android:background="@drawable/ffdf4b40_4round_1stroke_bg" android:textSize="10sp" android:text="- 删除" android:layout_width="42dp" diff --git a/app/src/main/res/layout/fragment_secure.xml b/app/src/main/res/layout/fragment_secure.xml index 394a39c..f0c6951 100644 --- a/app/src/main/res/layout/fragment_secure.xml +++ b/app/src/main/res/layout/fragment_secure.xml @@ -5,7 +5,7 @@ android:layout_height="match_parent" android:orientation="vertical" android:padding="6dp" - android:background="#112446" + android:background="#101010" tools:context=".Main.Setting.Fragment.SecureFragment"> @@ -26,7 +26,7 @@ android:layout_height="1.5dp"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> + android:background="@drawable/ff029a45_2round_1stroke_bg"/> diff --git a/app/src/main/res/mipmap-xhdpi/icon_expand.png b/app/src/main/res/mipmap-xhdpi/icon_expand.png new file mode 100644 index 0000000..ec163b3 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_expand.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_fly.png b/app/src/main/res/mipmap-xhdpi/icon_fly.png index 7af97cf..7ca6528 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_fly.png and b/app/src/main/res/mipmap-xhdpi/icon_fly.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_marker.png b/app/src/main/res/mipmap-xhdpi/icon_marker.png index 68a7426..5ce856f 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_marker.png and b/app/src/main/res/mipmap-xhdpi/icon_marker.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_select_link_no.png b/app/src/main/res/mipmap-xhdpi/icon_select_link_no.png new file mode 100644 index 0000000..ba78399 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_select_link_no.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_select_link_yes.png b/app/src/main/res/mipmap-xhdpi/icon_select_link_yes.png new file mode 100644 index 0000000..3d85040 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_select_link_yes.png differ