@@ -8,7 +8,7 @@ | |||
<option name="distributionType" value="DEFAULT_WRAPPED" /> | |||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | |||
<option name="gradleHome" value="$PROJECT_DIR$/../../../gradle-8.0.2-all/gradle-8.0.2" /> | |||
<option name="gradleJvm" value="JDK" /> | |||
<option name="gradleJvm" value="corretto-11" /> | |||
<option name="modules"> | |||
<set> | |||
<option value="$PROJECT_DIR$" /> | |||
@@ -1,7 +1,7 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ExternalStorageConfigurationManager" enabled="true" /> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK"> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK"> | |||
<output url="file://$PROJECT_DIR$/build/classes" /> | |||
</component> | |||
<component name="ProjectType"> | |||
@@ -55,6 +55,8 @@ dependencies { | |||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | |||
implementation 'androidx.recyclerview:recyclerview:1.2.1' | |||
implementation 'com.google.android.libraries.places:places:2.5.0' | |||
implementation 'androidx.navigation:navigation-fragment:2.4.1' | |||
implementation 'androidx.navigation:navigation-ui:2.4.1' | |||
// implementation files('libs\\org.eclipse.paho.android.service-1.1.1.jar') | |||
// implementation files('libs\\org.eclipse.paho.client.mqttv3-1.2.5.jar') | |||
testImplementation 'junit:junit:4.13.2' | |||
@@ -65,6 +67,7 @@ dependencies { | |||
// implementation files('libs\\gson-2.2.2.jar') | |||
implementation files('libs\\sdkapi.jar') | |||
compileOnly files('libs/sdkapi.jar') | |||
compileOnly files('libs/PC_RFID.jar') | |||
implementation files('libs/modbus4Android-1.2.jar') | |||
implementation 'com.contrarywind:Android-PickerView:3.2.6' | |||
implementation 'com.github.Ccapton:Android-ColorfulProgressBar:1.0.5' | |||
@@ -79,4 +82,6 @@ dependencies { | |||
implementation 'com.github.zcweng:switch-button:0.0.3@aar' | |||
// easyPermissions权限管理 | |||
implementation 'pub.devrel:easypermissions:2.0.1' | |||
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1' | |||
//implementation fileTree(dir: "libs", include: ["*.jar"]) | |||
} |
@@ -13,11 +13,14 @@ | |||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- MQTT权限 唤醒,访问网络信息,访问电话权限 --> | |||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | |||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |||
<uses-permission android:name="android.permission.INTERNET" /> | |||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | |||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | |||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | |||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |||
<uses-permission android:name="android.permission.USB_PERMISSION" /> | |||
<uses-feature android:name="android.hardware.usb.host" /> | |||
<application | |||
android:name=".app.ICSApp" | |||
@@ -32,99 +35,13 @@ | |||
tools:replace="android:icon" | |||
tools:targetApi="31"> | |||
<activity | |||
android:name=".view.from.dzcjy_new_activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.pflb_activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.clsfbc_activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.wdgl_new_Activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.sdkz_new_Activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.fragment.SsjkFragment" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.wdgl_activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.sdkz_activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.fragment.setting.ovarparameter" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.fragment.setting.mqttparameter" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.ddgl_activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.RunLog" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.fragment.setting.systemparameter" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.add_pf_activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.wlgl_activity" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> | |||
<activity | |||
android:name=".view.from.yfpf_activity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.from.ygczrz_activity" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> | |||
<activity | |||
android:name=".view.from.ddyjrz_activity" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> | |||
<activity | |||
android:name=".view.from.yfcl_activity" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> | |||
<activity | |||
android:name=".view.from.zdqx_activity" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> | |||
<activity | |||
android:name=".view.from.lsjy_activity" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> | |||
<activity | |||
android:name=".view.from.dzcjy_activity" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> | |||
<activity | |||
android:name=".view.from.lcsz_activity" | |||
android:name=".PlateActivity" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> | |||
<activity | |||
android:name=".view.fragment.SystemCapabilitiesFragment" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.fragment.HeplerFragment" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.fragment.SystemSetFragment" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".view.fragment.HomeFragment" | |||
android:exported="false" /> | |||
android:label="@string/title_activity_plate" | |||
android:theme="@style/AppTheme.NoActionBar" /> | |||
<activity | |||
android:name=".view.fragment.CloudFragment" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".LoginActivity" | |||
android:name=".view.PlateActivity" | |||
android:configChanges="orientation|screenSize|keyboard|keyboardHidden|navigation" | |||
android:exported="true" | |||
android:windowSoftInputMode="adjustPan|stateHidden"> | |||
<intent-filter> | |||
@@ -133,12 +50,6 @@ | |||
<category android:name="android.intent.category.LAUNCHER" /> | |||
</intent-filter> | |||
</activity> | |||
<activity | |||
android:name=".MainActivity" | |||
android:configChanges="orientation|screenSize|keyboard|keyboardHidden|navigation" | |||
android:exported="false" | |||
android:windowSoftInputMode="adjustPan|stateHidden" /> <!-- Mqtt Service --> | |||
<service android:name="org.eclipse.paho.android.service.MqttService" /> | |||
<receiver | |||
android:name=".app.BootReceiver" | |||
@@ -0,0 +1,103 @@ | |||
package com.example.bpa.helper; | |||
import android.content.Context; | |||
import android.hardware.usb.UsbDevice; | |||
import android.hardware.usb.UsbDeviceConnection; | |||
import android.hardware.usb.UsbManager; | |||
import com.hoho.android.usbserial.driver.CdcAcmSerialDriver; | |||
import com.hoho.android.usbserial.driver.ProbeTable; | |||
import com.hoho.android.usbserial.driver.UsbSerialDriver; | |||
import com.hoho.android.usbserial.driver.UsbSerialPort; | |||
import com.hoho.android.usbserial.driver.UsbSerialProber; | |||
import java.io.IOException; | |||
import java.util.List; | |||
public class USBSerialHelper { | |||
private UsbManager usbManager; | |||
private UsbSerialPort usbSerialPort; | |||
private UsbDeviceConnection connection; | |||
private OnDataReceivedListener onDataReceivedListener; | |||
private ReadThread readThread; | |||
public interface OnDataReceivedListener { | |||
void onDataReceived(byte[] data); | |||
} | |||
public USBSerialHelper(Context context, OnDataReceivedListener listener) { | |||
usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE); | |||
onDataReceivedListener = listener; | |||
} | |||
public void openDevice() throws IOException { | |||
ProbeTable customTable = new ProbeTable(); | |||
customTable.addProduct(0x2341, 0x0043, CdcAcmSerialDriver.class); | |||
UsbSerialProber prober = new UsbSerialProber(customTable); | |||
List<UsbSerialDriver> availableDrivers = prober.findAllDrivers(usbManager); | |||
if (!availableDrivers.isEmpty()) { | |||
UsbSerialDriver driver = availableDrivers.get(0); | |||
UsbDevice device = driver.getDevice(); | |||
connection = usbManager.openDevice(device); | |||
usbSerialPort = driver.getPorts().get(0); | |||
usbSerialPort.open(connection); | |||
usbSerialPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE); | |||
readThread = new ReadThread(); | |||
readThread.start(); | |||
} else { | |||
throw new IOException("No USB serial device found"); | |||
} | |||
} | |||
public void closeDevice() { | |||
if (readThread != null) { | |||
readThread.interrupt(); | |||
readThread = null; | |||
} | |||
if (usbSerialPort != null) { | |||
try { | |||
usbSerialPort.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
usbSerialPort = null; | |||
} | |||
if (connection != null) { | |||
connection.close(); | |||
connection = null; | |||
} | |||
} | |||
public void sendData(byte[] data) throws IOException { | |||
if (usbSerialPort != null) { | |||
usbSerialPort.write(data, 1000); | |||
} | |||
} | |||
private class ReadThread extends Thread { | |||
@Override | |||
public void run() { | |||
byte[] buffer = new byte[1024]; | |||
int numBytes; | |||
while (!isInterrupted()) { | |||
try { | |||
numBytes = usbSerialPort.read(buffer, 1000); | |||
if (numBytes > 0) { | |||
byte[] data = new byte[numBytes]; | |||
System.arraycopy(buffer, 0, data, 0, numBytes); | |||
onDataReceivedListener.onDataReceived(data); | |||
} | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
break; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,47 @@ | |||
package com.example.bpa.view; | |||
import android.os.Bundle; | |||
import com.google.android.material.snackbar.Snackbar; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import android.view.View; | |||
import androidx.navigation.NavController; | |||
import androidx.navigation.Navigation; | |||
import androidx.navigation.ui.AppBarConfiguration; | |||
import androidx.navigation.ui.NavigationUI; | |||
import com.example.bpa.R; | |||
import com.pc_rfid.api.PC_API; | |||
import com.pc_rfid.api.RFdata; | |||
public class PlateActivity extends AppCompatActivity { | |||
private AppBarConfiguration appBarConfiguration; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.plate_main); | |||
RFdata data=new RFdata(); | |||
PC_API.USB_init(getApplicationContext()); | |||
boolean b; | |||
if (!PC_API.PC_GetDeviceInfoVersion(data)) { | |||
b = false; | |||
} else { | |||
b = true; | |||
} | |||
} | |||
@Override | |||
public boolean onSupportNavigateUp() { | |||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_plate); | |||
return NavigationUI.navigateUp(navController, appBarConfiguration) | |||
|| super.onSupportNavigateUp(); | |||
} | |||
} |
@@ -0,0 +1,100 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
tools:context=".view.PlateActivity"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:textAlignment="center" | |||
android:orientation="horizontal"> | |||
<TextView | |||
android:layout_gravity="center" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="端口"></TextView> | |||
<Spinner | |||
android:layout_marginLeft="20dp" | |||
android:layout_gravity="center" | |||
android:id="@+id/sp_port" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:spinnerMode="dialog"></Spinner> | |||
<Button | |||
android:layout_marginLeft="20dp" | |||
android:id="@+id/btn_open" | |||
android:layout_gravity="center" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:text="打开端口"></Button> | |||
<TextView | |||
android:id="@+id/txt_status" | |||
android:layout_marginLeft="20dp" | |||
android:layout_gravity="center" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="当前状态:未连接"></TextView> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_marginTop="50dp" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
<GridLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:columnCount="4"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="当前标签UID:"></TextView> | |||
<TextView | |||
android:layout_marginLeft="5dp" | |||
android:id="@+id/txt_cardUid" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
></TextView> | |||
<TextView | |||
android:layout_marginLeft="20dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="当前标签数据内容:"></TextView> | |||
<TextView | |||
android:layout_marginLeft="5dp" | |||
android:id="@+id/txt_cardContent" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
></TextView> | |||
</GridLayout> | |||
<GridLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:columnCount="4"> | |||
<TextView | |||
android:layout_gravity="center" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="写入新数据:"></TextView> | |||
<TextView | |||
android:layout_gravity="center" | |||
android:layout_marginLeft="5dp" | |||
android:id="@+id/txt_cardContentNew" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
></TextView> | |||
<Button | |||
android:layout_marginLeft="20dp" | |||
android:id="@+id/btn_write" | |||
android:layout_gravity="center" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:text="写入数据"></Button> | |||
</GridLayout> | |||
</LinearLayout> | |||
</LinearLayout> |
@@ -0,0 +1,19 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
app:layout_behavior="@string/appbar_scrolling_view_behavior"> | |||
<fragment | |||
android:id="@+id/nav_host_fragment_content_plate" | |||
android:name="androidx.navigation.fragment.NavHostFragment" | |||
android:layout_width="0dp" | |||
android:layout_height="0dp" | |||
app:defaultNavHost="true" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
app:navGraph="@navigation/nav_graph" /> | |||
</androidx.constraintlayout.widget.ConstraintLayout> |
@@ -0,0 +1,28 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".FirstFragment"> | |||
<TextView | |||
android:id="@+id/textview_first" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="@string/hello_first_fragment" | |||
app:layout_constraintBottom_toTopOf="@id/button_first" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<Button | |||
android:id="@+id/button_first" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="@string/next" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toBottomOf="@id/textview_first" /> | |||
</androidx.constraintlayout.widget.ConstraintLayout> |
@@ -0,0 +1,27 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".SecondFragment"> | |||
<TextView | |||
android:id="@+id/textview_second" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
app:layout_constraintBottom_toTopOf="@id/button_second" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<Button | |||
android:id="@+id/button_second" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="@string/previous" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toBottomOf="@id/textview_second" /> | |||
</androidx.constraintlayout.widget.ConstraintLayout> |
@@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
</LinearLayout> |
@@ -0,0 +1,28 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<navigation xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:id="@+id/nav_graph" | |||
app:startDestination="@id/FirstFragment"> | |||
<fragment | |||
android:id="@+id/FirstFragment" | |||
android:name="com.example.bpa.view.FirstFragment" | |||
android:label="@string/first_fragment_label" | |||
tools:layout="@layout/fragment_first"> | |||
<action | |||
android:id="@+id/action_FirstFragment_to_SecondFragment" | |||
app:destination="@id/SecondFragment" /> | |||
</fragment> | |||
<fragment | |||
android:id="@+id/SecondFragment" | |||
android:name="com.example.bpa.view.SecondFragment" | |||
android:label="@string/second_fragment_label" | |||
tools:layout="@layout/fragment_second"> | |||
<action | |||
android:id="@+id/action_SecondFragment_to_FirstFragment" | |||
app:destination="@id/FirstFragment" /> | |||
</fragment> | |||
</navigation> |
@@ -0,0 +1,3 @@ | |||
<resources> | |||
<dimen name="fab_margin">48dp</dimen> | |||
</resources> |
@@ -0,0 +1,3 @@ | |||
<resources> | |||
<dimen name="fab_margin">200dp</dimen> | |||
</resources> |
@@ -0,0 +1,3 @@ | |||
<resources> | |||
<dimen name="fab_margin">48dp</dimen> | |||
</resources> |
@@ -0,0 +1,3 @@ | |||
<resources> | |||
<dimen name="fab_margin">16dp</dimen> | |||
</resources> |
@@ -1,4 +1,13 @@ | |||
<resources> | |||
<!-- TODO: Remove or change this placeholder text --> | |||
<string name="hello_blank_fragment">Hello blank fragment</string> | |||
<string name="title_activity_plate">PlateActivity</string> | |||
<!-- Strings used for fragments for navigation --> | |||
<string name="first_fragment_label">First Fragment</string> | |||
<string name="second_fragment_label">Second Fragment</string> | |||
<string name="next">Next</string> | |||
<string name="previous">Previous</string> | |||
<string name="hello_first_fragment">Hello first fragment</string> | |||
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string> | |||
</resources> |
@@ -0,0 +1,11 @@ | |||
<resources> | |||
<style name="AppTheme.NoActionBar"> | |||
<item name="windowActionBar">false</item> | |||
<item name="windowNoTitle">true</item> | |||
</style> | |||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> | |||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> | |||
</resources> |