Compare commits
4 Commits
master
...
liufuluo_b
| Author | SHA1 | Date |
|---|---|---|
|
|
dc5bcc3441 | 3 years ago |
|
|
c46bec7579 | 3 years ago |
|
|
801ee9638f | 3 years ago |
|
|
dbc39e966b | 3 years ago |
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="E:\Program Files\anaconda3\envs\shaobing" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="shaobing" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="f3b53e87-e36a-4c95-acf0-d651a7921b93" name="更改" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectId" id="2RnD8aXMQVWHVYrLZZJBinH4ICo" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"git-widget-placeholder": "master",
|
||||
"last_opened_file_path": "F:/sbrg/Shaobing",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="默认任务">
|
||||
<changelist id="f3b53e87-e36a-4c95-acf0-d651a7921b93" name="更改" comment="" />
|
||||
<created>1687876792481</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1687876792481</updated>
|
||||
<workItem from="1687876793655" duration="764000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
Before Width: | Height: | Size: 4.2 MiB After Width: | Height: | Size: 1.9 MiB |
@ -1,31 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="img">
|
||||
<file>icon/button-off.png</file>
|
||||
<file>icon/button-on.png</file>
|
||||
<file>icon/暂停.png</file>
|
||||
<file>icon/笑脸.png</file>
|
||||
<file>icon/终止.png</file>
|
||||
<file>icon/下拉_白色.png</file>
|
||||
<file>icon/正方形.png</file>
|
||||
<file>icon/实时视频流解析.png</file>
|
||||
<file>icon/运行.png</file>
|
||||
<file>icon/conan.png</file>
|
||||
<file>icon/还原.png</file>
|
||||
<file>icon/doctor.png</file>
|
||||
<file>icon/圆.png</file>
|
||||
<file>icon/evil.png</file>
|
||||
<file>icon/关闭.png</file>
|
||||
<file>icon/箭头_列表收起.png</file>
|
||||
<file>icon/箭头_列表展开.png</file>
|
||||
<file>icon/最小化.png</file>
|
||||
<file>icon/background.jpg</file>
|
||||
<file>icon/背景.png</file>
|
||||
<file>icon/打开.png</file>
|
||||
<file>icon/摄像头关.png</file>
|
||||
<file>icon/摄像头开.png</file>
|
||||
<file>icon/数据探索.png</file>
|
||||
<file>icon/停止.png</file>
|
||||
<file>icon/图片1.png</file>
|
||||
<file>icon/赞停.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@ -1,8 +0,0 @@
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
"ip": "rtsp://admin:admin888@192.168.1.67:555"
|
||||
}
|
||||
=======
|
||||
"ip": "udp://@192.168.39.58:11111"
|
||||
}
|
||||
>>>>>>> develop
|
||||
|
Before Width: | Height: | Size: 366 KiB |
|
Before Width: | Height: | Size: 587 KiB |
|
Before Width: | Height: | Size: 986 KiB |
|
Before Width: | Height: | Size: 57 KiB |
@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QTableView" name="tableView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>130</y>
|
||||
<width>256</width>
|
||||
<height>192</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -1,2 +0,0 @@
|
||||
from .tello import Tello, TelloException, BackgroundFrameRead
|
||||
from .swarm import TelloSwarm
|
||||
@ -1,65 +0,0 @@
|
||||
"""
|
||||
This file is based on a StackOverflow post by @301_Moved_Permanently.
|
||||
See https://stackoverflow.com/a/50622643
|
||||
|
||||
The code was adapted to be able to wrap all methods of a class by simply
|
||||
adding the decorator to the class itself.
|
||||
"""
|
||||
|
||||
import inspect
|
||||
import typing
|
||||
from contextlib import suppress
|
||||
from functools import wraps
|
||||
|
||||
|
||||
def _is_unparameterized_special_typing(type_hint):
|
||||
# Check for typing.Any, typing.Union, typing.ClassVar (without parameters)
|
||||
if hasattr(typing, "_SpecialForm"):
|
||||
return isinstance(type_hint, typing._SpecialForm)
|
||||
elif hasattr(type_hint, "__origin__"):
|
||||
return type_hint.__origin__ is None
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def enforce_types(target):
|
||||
"""Class decorator adding type checks to all member functions
|
||||
"""
|
||||
def check_types(spec, *args, **kwargs):
|
||||
parameters = dict(zip(spec.args, args))
|
||||
parameters.update(kwargs)
|
||||
for name, value in parameters.items():
|
||||
with suppress(KeyError): # Assume un-annotated parameters can be any type
|
||||
type_hint = spec.annotations[name]
|
||||
if _is_unparameterized_special_typing(type_hint):
|
||||
continue
|
||||
|
||||
if hasattr(type_hint, "__origin__") and type_hint.__origin__ is not None:
|
||||
actual_type = type_hint.__origin__
|
||||
elif hasattr(type_hint, "__args__") and type_hint.__args__ is not None:
|
||||
actual_type = type_hint.__args__
|
||||
else:
|
||||
actual_type = type_hint
|
||||
|
||||
if not isinstance(value, actual_type):
|
||||
raise TypeError("Unexpected type for '{}' (expected {} but found {})"
|
||||
.format(name, type_hint, type(value)))
|
||||
|
||||
def decorate(func):
|
||||
spec = inspect.getfullargspec(func)
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
check_types(spec, *args, **kwargs)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
if inspect.isclass(target):
|
||||
members = inspect.getmembers(target, predicate=inspect.isfunction)
|
||||
for name, func in members:
|
||||
setattr(target, name, decorate(func))
|
||||
|
||||
return target
|
||||
else:
|
||||
return decorate(target)
|
||||
@ -1,159 +0,0 @@
|
||||
"""Library for controlling multiple DJI Ryze Tello drones.
|
||||
"""
|
||||
|
||||
from threading import Thread, Barrier
|
||||
from queue import Queue
|
||||
from typing import List, Callable
|
||||
|
||||
from .tello import Tello, TelloException
|
||||
from .enforce_types import enforce_types
|
||||
|
||||
|
||||
@enforce_types
|
||||
class TelloSwarm:
|
||||
"""Swarm library for controlling multiple Tellos simultaneously
|
||||
"""
|
||||
|
||||
tellos: List[Tello]
|
||||
barrier: Barrier
|
||||
funcBarier: Barrier
|
||||
funcQueues: List[Queue]
|
||||
threads: List[Thread]
|
||||
|
||||
@staticmethod
|
||||
def fromFile(path: str):
|
||||
"""Create TelloSwarm from file. The file should contain one IP address per line.
|
||||
|
||||
Arguments:
|
||||
path: path to the file
|
||||
"""
|
||||
with open(path, 'r') as fd:
|
||||
ips = fd.readlines()
|
||||
|
||||
return TelloSwarm.fromIps(ips)
|
||||
|
||||
@staticmethod
|
||||
def fromIps(ips: list):
|
||||
"""Create TelloSwarm from a list of IP addresses.
|
||||
|
||||
Arguments:
|
||||
ips: list of IP Addresses
|
||||
"""
|
||||
if not ips:
|
||||
raise TelloException("No ips provided")
|
||||
|
||||
tellos = []
|
||||
for ip in ips:
|
||||
tellos.append(Tello(ip.strip()))
|
||||
|
||||
return TelloSwarm(tellos)
|
||||
|
||||
def __init__(self, tellos: List[Tello]):
|
||||
"""Initialize a TelloSwarm instance
|
||||
|
||||
Arguments:
|
||||
tellos: list of [Tello][tello] instances
|
||||
"""
|
||||
self.tellos = tellos
|
||||
self.barrier = Barrier(len(tellos))
|
||||
self.funcBarrier = Barrier(len(tellos) + 1)
|
||||
self.funcQueues = [Queue() for tello in tellos]
|
||||
|
||||
def worker(i):
|
||||
queue = self.funcQueues[i]
|
||||
tello = self.tellos[i]
|
||||
|
||||
while True:
|
||||
func = queue.get()
|
||||
self.funcBarrier.wait()
|
||||
func(i, tello)
|
||||
self.funcBarrier.wait()
|
||||
|
||||
self.threads = []
|
||||
for i, _ in enumerate(tellos):
|
||||
thread = Thread(target=worker, daemon=True, args=(i,))
|
||||
thread.start()
|
||||
self.threads.append(thread)
|
||||
|
||||
def sequential(self, func: Callable[[int, Tello], None]):
|
||||
"""Call `func` for each tello sequentially. The function retrieves
|
||||
two arguments: The index `i` of the current drone and `tello` the
|
||||
current [Tello][tello] instance.
|
||||
|
||||
```python
|
||||
swarm.parallel(lambda i, tello: tello.land())
|
||||
```
|
||||
"""
|
||||
|
||||
for i, tello in enumerate(self.tellos):
|
||||
func(i, tello)
|
||||
|
||||
def parallel(self, func: Callable[[int, Tello], None]):
|
||||
"""Call `func` for each tello in parallel. The function retrieves
|
||||
two arguments: The index `i` of the current drone and `tello` the
|
||||
current [Tello][tello] instance.
|
||||
|
||||
You can use `swarm.sync()` for syncing between threads.
|
||||
|
||||
```python
|
||||
swarm.parallel(lambda i, tello: tello.move_up(50 + i * 10))
|
||||
```
|
||||
"""
|
||||
|
||||
for queue in self.funcQueues:
|
||||
queue.put(func)
|
||||
|
||||
self.funcBarrier.wait()
|
||||
self.funcBarrier.wait()
|
||||
|
||||
def sync(self, timeout: float = None):
|
||||
"""Sync parallel tello threads. The code continues when all threads
|
||||
have called `swarm.sync`.
|
||||
|
||||
```python
|
||||
def doStuff(i, tello):
|
||||
tello.move_up(50 + i * 10)
|
||||
swarm.sync()
|
||||
|
||||
if i == 2:
|
||||
tello.flip_back()
|
||||
# make all other drones wait for one to complete its flip
|
||||
swarm.sync()
|
||||
|
||||
swarm.parallel(doStuff)
|
||||
```
|
||||
"""
|
||||
return self.barrier.wait(timeout)
|
||||
|
||||
def __getattr__(self, attr):
|
||||
"""Call a standard tello function in parallel on all tellos.
|
||||
|
||||
```python
|
||||
swarm.command()
|
||||
swarm.takeoff()
|
||||
swarm.move_up(50)
|
||||
```
|
||||
"""
|
||||
def callAll(*args, **kwargs):
|
||||
self.parallel(lambda i, tello: getattr(tello, attr)(*args, **kwargs))
|
||||
|
||||
return callAll
|
||||
|
||||
def __iter__(self):
|
||||
"""Iterate over all drones in the swarm.
|
||||
|
||||
```python
|
||||
for tello in swarm:
|
||||
print(tello.get_battery())
|
||||
```
|
||||
"""
|
||||
return iter(self.tellos)
|
||||
|
||||
def __len__(self):
|
||||
"""Return the amount of tellos in the swarm
|
||||
|
||||
```python
|
||||
print("Tello count: {}".format(len(swarm)))
|
||||
```
|
||||
"""
|
||||
return len(self.tellos)
|
||||
@ -1,15 +0,0 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="SERIAL_NUMBER" />
|
||||
<value value="W3VBB21918206146" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-06-28T03:24:01.996639400Z" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/drawable/icon_favorite_red.xml" value="0.12" />
|
||||
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/activity_detect.xml" value="0.1" />
|
||||
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/activity_main.xml" value="0.1" />
|
||||
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/activity_map.xml" value="0.1125" />
|
||||
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/activity_video.xml" value="0.1" />
|
||||
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/content_detect.xml" value="0.1358695652173913" />
|
||||
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/fragment_first.xml" value="0.1358695652173913" />
|
||||
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/fragment_second.xml" value="0.1358695652173913" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1 +0,0 @@
|
||||
/build
|
||||
@ -1,58 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 32
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.sixaunyi"
|
||||
minSdk 22
|
||||
targetSdk 32
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.3.5'
|
||||
implementation 'androidx.navigation:navigation-ui:2.3.5'
|
||||
implementation 'com.google.android.gms:play-services-maps:17.0.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
//Google推荐的EasyPermission库
|
||||
implementation 'pub.devrel:easypermissions:3.0.0'
|
||||
//Material库
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.media:media:1.3.0'
|
||||
|
||||
|
||||
//定位功能
|
||||
/*implementation 'com.amap.api:location:latest.integration'
|
||||
//搜索功能
|
||||
implementation 'com.amap.api:search:latest.integration'*/
|
||||
|
||||
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@ -1,20 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.example.sixaunyi",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package com.example.sixaunyi;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.example.sixaunyi", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
package com.example.sixaunyi;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
import com.example.sixaunyi.databinding.FragmentFirstBinding;
|
||||
|
||||
public class FirstFragment extends Fragment {
|
||||
|
||||
private FragmentFirstBinding binding;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState
|
||||
) {
|
||||
|
||||
binding = FragmentFirstBinding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
binding.buttonFirst.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
NavHostFragment.findNavController(FirstFragment.this)
|
||||
.navigate(R.id.action_FirstFragment_to_SecondFragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,79 +0,0 @@
|
||||
package com.example.sixaunyi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private EditText mUsername;
|
||||
private EditText mPassword;
|
||||
private Button mLoginButton;
|
||||
private CheckBox Account_remember;
|
||||
private SharedPreferences sharedPreferences;
|
||||
private Map<String, String> mUsers = new HashMap<>();
|
||||
{
|
||||
mUsers.put("admin", "123456");
|
||||
mUsers.put("tiequan", "8731");
|
||||
mUsers.put("zhenghaoyuan", "6666");
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
// 获取输入框和按钮的实例
|
||||
mUsername = findViewById(R.id.username);
|
||||
mPassword = findViewById(R.id.password);
|
||||
mLoginButton = findViewById(R.id.login);
|
||||
Account_remember = findViewById(R.id.remember_check);
|
||||
sharedPreferences = getSharedPreferences("account", Context.MODE_PRIVATE);
|
||||
String username = sharedPreferences.getString("username", "");
|
||||
String password =sharedPreferences.getString("password", "");
|
||||
boolean isChecked = sharedPreferences.getBoolean("checkbox_state", false);
|
||||
mUsername.setText(username);
|
||||
mPassword.setText(password);
|
||||
Account_remember.setChecked(isChecked);
|
||||
// 设置登录按钮的点击事件
|
||||
mLoginButton.setOnClickListener(v -> {
|
||||
attemptLogin();
|
||||
});
|
||||
}
|
||||
private void attemptLogin() {
|
||||
String username = mUsername.getText().toString();
|
||||
String password = mPassword.getText().toString();
|
||||
boolean if_correct = verifyUser(username,password);
|
||||
if (if_correct) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("username", username);
|
||||
editor.putBoolean("checkbox_state", Account_remember.isChecked());
|
||||
editor.apply();
|
||||
if (Account_remember.isChecked()){
|
||||
editor.putString("password", password);
|
||||
}else{
|
||||
editor.putString("password", "");
|
||||
}
|
||||
editor.apply();
|
||||
Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Toast.makeText(this, "用户名或密码错误", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
private boolean verifyUser(String username, String password){
|
||||
if (mUsers.containsKey(username) && mUsers.get(username).equals(password)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package com.example.sixaunyi;
|
||||
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.location.AMapLocationClient;
|
||||
import com.amap.api.maps.MapsInitializer;
|
||||
import com.amap.api.services.core.ServiceSettings;
|
||||
|
||||
public class MapApplication extends Application {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Context context = this;
|
||||
//定位隐私政策同意
|
||||
AMapLocationClient.updatePrivacyShow(context,true,true);
|
||||
AMapLocationClient.updatePrivacyAgree(context,true);
|
||||
//地图隐私政策同意
|
||||
MapsInitializer.updatePrivacyShow(context,true,true);
|
||||
MapsInitializer.updatePrivacyAgree(context,true);
|
||||
//搜索隐私政策同意
|
||||
ServiceSettings.updatePrivacyShow(context,true,true);
|
||||
ServiceSettings.updatePrivacyAgree(context,true);
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
package com.example.sixaunyi;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
import com.example.sixaunyi.databinding.FragmentSecondBinding;
|
||||
|
||||
public class SecondFragment extends Fragment {
|
||||
|
||||
private FragmentSecondBinding binding;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState
|
||||
) {
|
||||
|
||||
binding = FragmentSecondBinding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
binding.buttonSecond.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
NavHostFragment.findNavController(SecondFragment.this)
|
||||
.navigate(R.id.action_SecondFragment_to_FirstFragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,194 +0,0 @@
|
||||
package com.example.sixaunyi;
|
||||
|
||||
import static androidx.constraintlayout.motion.utils.Oscillator.TAG;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class SettingActivity extends AppCompatActivity {
|
||||
|
||||
private final static String SEND_to_IP = "192.168.39.47";
|
||||
private SeekBar Speed_btn;
|
||||
private SeekBar Battery_btn;
|
||||
private ImageButton return_btn;
|
||||
private final static int SEND_PORT = 8888;
|
||||
private ExecutorService mThreadPool = Executors.newCachedThreadPool();
|
||||
private Switch photo_btn;
|
||||
private Context context;
|
||||
private SharedPreferences sharedPreferences;
|
||||
private TextView tvProgress;
|
||||
private TextView Battery_warning;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_setting);
|
||||
Speed_btn= findViewById(R.id.speed);
|
||||
return_btn=findViewById(R.id.returns);
|
||||
photo_btn = findViewById(R.id.photo);
|
||||
Battery_btn = findViewById(R.id.warning_num);
|
||||
tvProgress = findViewById(R.id.tvProgress);
|
||||
Battery_warning=findViewById(R.id.Battery_warning);
|
||||
sharedPreferences = getSharedPreferences("control_state", MODE_PRIVATE);
|
||||
boolean photo_btn_state= sharedPreferences.getBoolean("photo_btn_state", false);
|
||||
photo_btn.setChecked(photo_btn_state);
|
||||
// 恢复SeekBar状态
|
||||
int speedProgress = sharedPreferences.getInt("speed_progress", 0);
|
||||
Speed_btn.setProgress(speedProgress);
|
||||
tvProgress.setText(String.valueOf(speedProgress+10));
|
||||
int warning_num= sharedPreferences.getInt("battery_num", 0);
|
||||
Battery_btn.setProgress(warning_num);
|
||||
Battery_warning.setText(String.valueOf(warning_num));
|
||||
photo_btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
// 保存Switch状态
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean("photo_btn_state", isChecked);
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
Speed_btn.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
tvProgress.setText(String.valueOf(progress+10));
|
||||
int speed=progress+10;
|
||||
String s = "SPEED " + Integer.toString(speed);
|
||||
try {
|
||||
sendCommand(s);
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt("speed_progress", progress);
|
||||
editor.apply();
|
||||
}
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
});
|
||||
Battery_btn.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
Battery_warning.setText(String.valueOf(progress));
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt("battery_num", progress);
|
||||
editor.apply();
|
||||
}
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
});
|
||||
return_btn.setOnClickListener(new View.OnClickListener(){
|
||||
public void onClick(View v) {
|
||||
// 启动目标 Activity
|
||||
passingParameters();
|
||||
}
|
||||
});
|
||||
photo_btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (photo_btn.isChecked()) {
|
||||
try {
|
||||
sendCommand("PHOTO_HIGH");
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else
|
||||
{
|
||||
try {
|
||||
sendCommand("PHOTO_LOW");
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
* UDP数据发送线程
|
||||
* */
|
||||
class SendRunnable implements Runnable {
|
||||
byte[] mData;
|
||||
InetAddress mAddress;
|
||||
int mPort;
|
||||
public SendRunnable(byte[] data, InetAddress address, int port) {
|
||||
mData = data;
|
||||
mAddress = address;
|
||||
mPort = port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// 创建发送数据报文
|
||||
DatagramPacket packet = new DatagramPacket(mData, mData.length, mAddress, mPort);
|
||||
// 创建 DatagramSocket 对象并发送数据报文
|
||||
DatagramSocket socket = new DatagramSocket();
|
||||
socket.send(packet);
|
||||
|
||||
// 关闭 DatagramSocket 对象
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*封装函数*/
|
||||
private void sendCommand(String str) throws UnknownHostException {
|
||||
byte[] sendData = str.getBytes();
|
||||
InetAddress address = InetAddress.getByName(SEND_to_IP);
|
||||
SendRunnable sendRunnable1 = new SendRunnable(sendData, address, SEND_PORT);
|
||||
mThreadPool.execute(sendRunnable1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// 在这里处理返回事件的逻辑
|
||||
super.onBackPressed(); // 调用父类的方法,执行默认的返回操作
|
||||
passingParameters();
|
||||
}
|
||||
|
||||
private void passingParameters(){
|
||||
int warning_num= sharedPreferences.getInt("battery_num", 0);
|
||||
Log.i(TAG, "111111111111111111111"+String.valueOf(warning_num));
|
||||
Intent intent = new Intent(SettingActivity.this,VideoActivity.class);
|
||||
intent.putExtra("BATTERY_NUM", warning_num); // 设置要传递的参数
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |