Pārlūkot izejas kodu

First submission

master
陈福行 pirms 5 gadiem
revīzija
dc60aee9b0
74 mainītis faili ar 3208 papildinājumiem un 0 dzēšanām
  1. 13
    0
      .gitignore
  2. 224
    0
      .idea/codeStyles/Project.xml
  3. 5
    0
      .idea/codeStyles/codeStyleConfig.xml
  4. 6
    0
      .idea/compiler.xml
  5. 3
    0
      .idea/dictionaries/xing.xml
  6. 6
    0
      .idea/encodings.xml
  7. 19
    0
      .idea/gradle.xml
  8. 14
    0
      .idea/misc.xml
  9. 12
    0
      .idea/runConfigurations.xml
  10. 6
    0
      .idea/vcs.xml
  11. 194
    0
      README.md
  12. 194
    0
      README_CN.md
  13. 1
    0
      app/.gitignore
  14. 36
    0
      app/build.gradle
  15. 21
    0
      app/proguard-rules.pro
  16. 27
    0
      app/src/androidTest/java/aicare/net/cn/sdk/tmpsrepositoryandroid/ExampleInstrumentedTest.java
  17. 25
    0
      app/src/main/AndroidManifest.xml
  18. 384
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/MainActivity.java
  19. 12
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/OnIdSetListener.java
  20. 67
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/adapter/DeviceIdAdapter.java
  21. 41
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/bean/DeviceId.java
  22. 71
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/Config.java
  23. 12
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/Configs.java
  24. 81
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/L.java
  25. 204
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/ParseData.java
  26. 173
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/SPUtils.java
  27. 114
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/T.java
  28. 99
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/views/MyTextView.java
  29. 158
    0
      app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/views/SetIdDialog.java
  30. 34
    0
      app/src/main/res/drawable-v24/ic_launcher_foreground.xml
  31. 7
    0
      app/src/main/res/drawable/bg.xml
  32. 11
    0
      app/src/main/res/drawable/hw_bluetooth_scan_tv.xml
  33. 171
    0
      app/src/main/res/drawable/ic_launcher_background.xml
  34. 87
    0
      app/src/main/res/layout/activity_main.xml
  35. 24
    0
      app/src/main/res/layout/device_id_item.xml
  36. 18
    0
      app/src/main/res/layout/dialog_get_id.xml
  37. 71
    0
      app/src/main/res/layout/dialog_set_id.xml
  38. 5
    0
      app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  39. 5
    0
      app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  40. Binārs
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  41. Binārs
      app/src/main/res/mipmap-hdpi/ic_launcher_round.png
  42. Binārs
      app/src/main/res/mipmap-mdpi/ic_launcher.png
  43. Binārs
      app/src/main/res/mipmap-mdpi/ic_launcher_round.png
  44. Binārs
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  45. Binārs
      app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  46. Binārs
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  47. Binārs
      app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  48. Binārs
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  49. Binārs
      app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  50. 10
    0
      app/src/main/res/values/attrs.xml
  51. 8
    0
      app/src/main/res/values/colors.xml
  52. 5
    0
      app/src/main/res/values/dimens.xml
  53. 23
    0
      app/src/main/res/values/strings.xml
  54. 68
    0
      app/src/main/res/values/styles.xml
  55. 17
    0
      app/src/test/java/aicare/net/cn/sdk/tmpsrepositoryandroid/ExampleUnitTest.java
  56. 27
    0
      build.gradle
  57. 20
    0
      gradle.properties
  58. Binārs
      gradle/wrapper/gradle-wrapper.jar
  59. 6
    0
      gradle/wrapper/gradle-wrapper.properties
  60. 172
    0
      gradlew
  61. 84
    0
      gradlew.bat
  62. 1
    0
      settings.gradle
  63. 1
    0
      tpmslibrary/.gitignore
  64. 41
    0
      tpmslibrary/build.gradle
  65. Binārs
      tpmslibrary/libs/arm64-v8a/libtpms-lib.so
  66. Binārs
      tpmslibrary/libs/armeabi-v7a/libtpms-lib.so
  67. Binārs
      tpmslibrary/libs/tpmslib.jar
  68. Binārs
      tpmslibrary/libs/x86/libtpms-lib.so
  69. Binārs
      tpmslibrary/libs/x86_64/libtpms-lib.so
  70. 21
    0
      tpmslibrary/proguard-rules.pro
  71. 27
    0
      tpmslibrary/src/androidTest/java/aicare/net/cn/sdk/tpmslibrary/ExampleInstrumentedTest.java
  72. 2
    0
      tpmslibrary/src/main/AndroidManifest.xml
  73. 3
    0
      tpmslibrary/src/main/res/values/strings.xml
  74. 17
    0
      tpmslibrary/src/test/java/aicare/net/cn/sdk/tpmslibrary/ExampleUnitTest.java

+ 13
- 0
.gitignore Parādīt failu

@@ -0,0 +1,13 @@
*.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

+ 224
- 0
.idea/codeStyles/Project.xml Parādīt failu

@@ -0,0 +1,224 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="android" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
<emptyLine />
<package name="junit" withSubpackages="true" static="false" />
<emptyLine />
<package name="net" withSubpackages="true" static="false" />
<emptyLine />
<package name="org" withSubpackages="true" static="false" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
</value>
</option>
<option name="RIGHT_MARGIN" value="100" />
<AndroidXmlCodeStyleSettings>
<option name="USE_CUSTOM_SETTINGS" value="true" />
</AndroidXmlCodeStyleSettings>
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="android" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
<emptyLine />
<package name="junit" withSubpackages="true" static="false" />
<emptyLine />
<package name="net" withSubpackages="true" static="false" />
<emptyLine />
<package name="org" withSubpackages="true" static="false" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
</value>
</option>
</JavaCodeStyleSettings>
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_NAMESPACE>Namespace:</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_NAMESPACE>Namespace:</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_width</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_height</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:width</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:height</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

+ 5
- 0
.idea/codeStyles/codeStyleConfig.xml Parādīt failu

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
</state>
</component>

+ 6
- 0
.idea/compiler.xml Parādīt failu

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="9" />
</component>
</project>

+ 3
- 0
.idea/dictionaries/xing.xml Parādīt failu

@@ -0,0 +1,3 @@
<component name="ProjectDictionaryState">
<dictionary name="xing" />
</component>

+ 6
- 0
.idea/encodings.xml Parādīt failu

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8" addBOMForNewFiles="with NO BOM">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

+ 19
- 0
.idea/gradle.xml Parādīt failu

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<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" />
<option value="$PROJECT_DIR$/tpmslibrary" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

+ 14
- 0
.idea/misc.xml Parādīt failu

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

+ 12
- 0
.idea/runConfigurations.xml Parādīt failu

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

+ 6
- 0
.idea/vcs.xml Parādīt failu

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

+ 194
- 0
README.md Parādīt failu

@@ -0,0 +1,194 @@
# TPMS SDK instructions-Android

[![](https://jitpack.io/v/elinkthings/TmpsSDKRepositoryAndroid.svg)](https://jitpack.io/#elinkthings/TmpsSDKRepositoryAndroid)

[aar package download address](https://github.com/elinkthings/TmpsSDKRepositoryAndroid/releases)

[key registered address](http://sdk.aicare.net.cn)

[中文文档](README_CN.md)

This document is to guide Android developers to integrate TPMS-SDK-Android in Android 4.4 and above systems.
## 1. Conditions of use:
1. Android SDK minimum version android4.4 (API 19).
2. The Bluetooth version used by the device requires 4.0 or above.
3. Configure java1.8
4. The project depends on the androidx library

## Second, import the SDK


```
repositories {
    flatDir {
        dirs 'libs'
    }
}


1. Add the JitPack repository to your build file
Add it to the root build.gradle at the end of the repository:
allprojects {
repositories {
...
maven {url 'https://jitpack.io'}
}
}

2. Add dependencies
dependencies {
implementation 'com.github.elinkthings: TmpsSDKRepositoryAndroid: 1.2.2' // Bluetooth library

}

3. Configure java1.8 in gradle
    android {
        ...
        compileOptions {
            sourceCompatibility 1.8
            targetCompatibility 1.8
        }
    }

You can also use the aar package dependency, please download it yourself and put it in the project's libs, the download address is at the top of the document



```

## Second, permission settings

```
<!-In most cases, you need to ensure that the device supports BLE .-->
<uses-feature
    android: name = "android.hardware.bluetooth_le"
    android: required = "true" />

<uses-permission android: name = "android.permission.BLUETOOTH" />
<uses-permission android: name = "android.permission.BLUETOOTH_ADMIN" />

<!-Android 6.0 and above. Bluetooth scanning requires one of the following two permissions. You need to apply at run time .-->
<uses-permission android: name = "android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android: name = "android.permission.ACCESS_FINE_LOCATION" />

<!-Optional. If your app need dfu function .-->
<uses-permission android: name = "android.permission.INTERNET" />
```

> 6.0 and above systems must locate permissions and need to manually obtain permissions

## Three, start integration



### 1, Initialization, [key registered address](http://sdk.aicare.net.cn)
```
TpmsSDK.init(this, key, secret);
```

### 2, Implement the TpmsScan.TpmsScanListener method
```
TpmsScan mTpmsScan = new TpmsScan (new TpmsScan.TpmsScanListener () {
            @Override
            public void onGetData (String mac, String deviceId, int rssi, float pressure, float battery, int temp, int status, float mcuVersion, int year, int month, int day, float bleVersion) {
                
            }
        });
```
### 3, search for TpmsScan.startScan (String [] deviceIdS);
```
    / **
     * Search device, search all devices by default and return through TpmsScanListener interface
     * /
     TpmsScan.startScan ()

   / **
     * Search for devices, search for devices in the incoming device id array and return through the TpmsScanListener interface
     *
     * /
     TpmsScan.startScan (String [] deviceIdS)

The found devices will be returned in onGetData (...) in the TpmsScan.TpmsScanListener interface
```
### 4, Data analysis returned by the TpmsScan.TpmsScanListener interface
```
public void onGetData (String mac, String deviceId, int rssi, float pressure, float battery, int temp, int status, float mcuVersion, int year, int month, int day, float bleVersion);

mac: device mac address
deviceId: device id
rssi: signal value
pressure: air pressure
battery: voltage
temp: temperature
status: status
    / **
     * device status
     * /
    public enum DeviceState {
        / **
         * Normal
         * /
        NORMAL,
        / **
         * Leakage
         * /
        LEAK,
        / **
         * Inflatable
         * /
        INFLATE,
        / **
         * start up
         * /
        START,
        / **
         * Power-on
         * /
        POWER_ON,
        / **
         * Wake up
         * /
        WEAK_UP,
        / **
         * Abnormal temperature
         * /
        TEMP_ERROR,
        / **
         * Abnormal battery
         * /
        BATTERY_ERROR,
        / **
         * Unknown
         * /
        UNKNOWN
    }
    
mcuVersion: mcu version number
year, month, day: date
bleVersion: Bluetooth version number


    / **
     * Equipment installation location
     * /
    public enum DevicePosition {
        / **
         * Front left
         * /
        LEFT_FRONT,
        / **
         * Rear left
         * /
        LEFT_REAR,
        / **
         * Front right
         * /
        RIGHT_FRONT,
        / **
         * right back
         * /
        RIGHT_REAR
    }

```
### 5, stop searching TpmsScan.stopScan ();

+ 194
- 0
README_CN.md Parādīt failu

@@ -0,0 +1,194 @@

# TPMS SDK使用说明 - Android
[![](https://jitpack.io/v/elinkthings/TmpsSDKRepositoryAndroid.svg)](https://jitpack.io/#elinkthings/TmpsSDKRepositoryAndroid)

[aar包下载地址](https://github.com/elinkthings/TmpsSDKRepositoryAndroid/releases)

[key注册地址](http://sdk.aicare.net.cn)

[English documentation](README.md)

该文档为指导Android开发人员在Android 4.4及以上系统中集成TPMS-SDK-Android,主要为一些关键的使用示例
## 一、使用条件:
1.Android SDK最低版本android4.4(API 19)。
2.设备所使用蓝牙版本需要4.0及以上。
3.配置java1.8
4.项目依赖androidx库

## 二、导入SDK


```
repositories {
flatDir {
dirs 'libs'
}
}


1.将JitPack存储库添加到您的构建文件中
将其添加到存储库末尾的root build.gradle中:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

2.添加依赖项
dependencies {
implementation 'com.github.elinkthings:TmpsSDKRepositoryAndroid:1.2.2'//蓝牙库

}

3.在gradle中配置java1.8
android {
...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

也可以使用aar包依赖,请自行下载放到项目的libs中,下载地址在文档顶部



```

## 二、权限设置

```
<!--In most cases, you need to ensure that the device supports BLE.-->
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true"/>

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

<!--Android 6.0 and above. Bluetooth scanning requires one of the following two permissions. You need to apply at run time.-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<!--Optional. If your app need dfu function.-->
<uses-permission android:name="android.permission.INTERNET"/>
```

> 6.0及以上系统必须要定位权限,且需要手动获取权限

## 三、开始集成



### 1,初始化,[key注册地址](http://sdk.aicare.net.cn)
```
booTpmsSDK.init(this,key,secret);
```

### 2,实现TpmsScan.TpmsScanListener方法
```
TpmsScan mTpmsScan = new TpmsScan(new TpmsScan.TpmsScanListener() {
@Override
public void onGetData(String mac, String deviceId, int rssi, float pressure, float battery,int temp, int status, float mcuVersion, int year, int month, int day,float bleVersion){

}
});
```
### 3,搜索 TpmsScan.startScan(String[] deviceIdS);
```
/**
* 搜索设备,默认搜索所有的设备并通过TpmsScanListener接口返回
*/
TpmsScan.startScan()

/**
* 搜索设备,搜索传入的设备id数组的设备并通过TpmsScanListener接口返回
*
*/
TpmsScan.startScan(String[] deviceIdS)

搜索到的设备会在TpmsScan.TpmsScanListener接口中的onGetData(...)返回
```
### 4,TpmsScan.TpmsScanListener接口返回的数据解析
```
public void onGetData(String mac, String deviceId, int rssi, float pressure, float battery,int temp, int status, float mcuVersion, int year, int month, int day,float bleVersion);

mac:设备mac地址
deviceId:设备id
rssi:信号值
pressure:气压
battery:电压
temp:温度
status:状态
/**
* 设备状态
*/
public enum DeviceState {
/**
* 正常
*/
NORMAL,
/**
* 漏气
*/
LEAK,
/**
* 充气
*/
INFLATE,
/**
* 启动
*/
START,
/**
* 上电
*/
POWER_ON,
/**
* 唤醒
*/
WEAK_UP,
/**
* 温度异常
*/
TEMP_ERROR,
/**
* 电量异常
*/
BATTERY_ERROR,
/**
* 未知
*/
UNKNOWN
}

mcuVersion:mcu版本号
year,month,day :日期
bleVersion:蓝牙版本号


/**
* 设备安装位置
*/
public enum DevicePosition {
/**
* 左前
*/
LEFT_FRONT,
/**
* 左后
*/
LEFT_REAR,
/**
* 右前
*/
RIGHT_FRONT,
/**
* 右后
*/
RIGHT_REAR
}

```
### 5,停止搜索TpmsScan.stopScan();

+ 1
- 0
app/.gitignore Parādīt failu

@@ -0,0 +1 @@
/build

+ 36
- 0
app/build.gradle Parādīt failu

@@ -0,0 +1,36 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "aicare.net.cn.sdk.tmpsrepositoryandroid"
minSdkVersion 19
targetSdkVersion 29
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 '1.8'
targetCompatibility '1.8'
}


}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(path: ':tpmslibrary')
}

+ 21
- 0
app/proguard-rules.pro Parādīt failu

@@ -0,0 +1,21 @@
# 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

+ 27
- 0
app/src/androidTest/java/aicare/net/cn/sdk/tmpsrepositoryandroid/ExampleInstrumentedTest.java Parādīt failu

@@ -0,0 +1,27 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid;

import android.content.Context;

import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import static org.junit.Assert.assertEquals;

/**
* 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.getTargetContext();

assertEquals("aicare.net.cn.sdk.tmpsrepositoryandroid", appContext.getPackageName());
}
}

+ 25
- 0
app/src/main/AndroidManifest.xml Parādīt failu

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="aicare.net.cn.sdk.tmpsrepositoryandroid"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>

+ 384
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/MainActivity.java Parādīt failu

@@ -0,0 +1,384 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid;

import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.pingwang.tpmslibrary.TpmsSDK;
import com.pingwang.tpmslibrary.TpmsScan;

import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Set;

import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.Config;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.Configs;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.L;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.ParseData;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.SPUtils;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.T;
import aicare.net.cn.sdk.tmpsrepositoryandroid.views.SetIdDialog;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener,
TpmsScan.TpmsScanListener, OnIdSetListener {

private Button btn_get_info, btn_clear_log, btn_stop_scan;
private TextView tv_left_front, tv_right_front, tv_left_rear, tv_right_rear;
private ListView lv_show_log;
private LinearLayout ll_set_id;
private String leftFront, rightFront, leftRear, rightRear;

private List<String> infoList;
private ArrayAdapter listAdapter;
private TpmsScan mTpmsScan;
private EnumMap<Config.DevicePosition, String> deviceIdMap;
private String[] mDeviceIdS;



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TpmsSDK.init(this, "f36120b9dc0c042e", "00bb9f124ea3de327ed54cfa3e");
L.isDebug = true;
initData();
initViews();
initEvents();
}

@Override
protected void onResume() {
super.onResume();
if (mTpmsScan != null) {
if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) {
showBLEDialog();
}
}
}


private void initData() {
infoList = new ArrayList<>();
deviceIdMap = new EnumMap<>(Config.DevicePosition.class);
setDeviceIdMap();

mTpmsScan = new TpmsScan(MainActivity.this);
}

private void setDeviceIdMap() {
leftFront = (String) SPUtils.get(this, Configs.LEFT_FRONT, "");
leftRear = (String) SPUtils.get(this, Configs.LEFT_REAR, "");
rightFront = (String) SPUtils.get(this, Configs.RIGHT_FRONT, "");
rightRear = (String) SPUtils.get(this, Configs.RIGHT_REAR, "");
deviceIdMap.put(Config.DevicePosition.LEFT_FRONT, leftFront);
deviceIdMap.put(Config.DevicePosition.LEFT_REAR, leftRear);
deviceIdMap.put(Config.DevicePosition.RIGHT_FRONT, rightFront);
deviceIdMap.put(Config.DevicePosition.RIGHT_REAR, rightRear);
}

private void initViews() {
btn_stop_scan = (Button) findViewById(R.id.btn_stop_scan);
btn_get_info = (Button) findViewById(R.id.btn_get_info);
btn_clear_log = (Button) findViewById(R.id.btn_clear_log);

tv_left_front = (TextView) findViewById(R.id.tv_left_front);
tv_right_front = (TextView) findViewById(R.id.tv_right_front);
tv_left_rear = (TextView) findViewById(R.id.tv_left_rear);
tv_right_rear = (TextView) findViewById(R.id.tv_right_rear);
setTyreId();

ll_set_id = (LinearLayout) findViewById(R.id.ll_set_id);

lv_show_log = (ListView) findViewById(R.id.lv_show_log);
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, infoList);
lv_show_log.setAdapter(listAdapter);
}

private void setTyreId() {
if (TextUtils.isEmpty(leftFront)) {
tv_left_front.setText(R.string.please_set_id);
} else {
tv_left_front.setText(String
.format(getResources().getString(R.string.left_front_id), leftFront));
}
if (TextUtils.isEmpty(rightFront)) {
tv_right_front.setText(R.string.please_set_id);
} else {
tv_right_front.setText(String
.format(getResources().getString(R.string.right_front_id), rightFront));
}
if (TextUtils.isEmpty(leftRear)) {
tv_left_rear.setText(R.string.please_set_id);
} else {
tv_left_rear.setText(String
.format(getResources().getString(R.string.left_rear_id), leftRear));
}
if (TextUtils.isEmpty(rightRear)) {
tv_right_rear.setText(R.string.please_set_id);
} else {
tv_right_rear.setText(String
.format(getResources().getString(R.string.right_rear_id), rightRear));
}
}

private void initEvents() {
btn_stop_scan.setOnClickListener(this);
btn_get_info.setOnClickListener(this);
btn_clear_log.setOnClickListener(this);
ll_set_id.setOnClickListener(this);
}


private static final int REQUEST_ENABLE_BT = 2;

private void showBLEDialog() {
final Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
}

@Override
protected void onDestroy() {
super.onDestroy();
if (mTpmsScan != null) {
mTpmsScan.stopScan();
}
}




@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_stop_scan:
if (mTpmsScan != null) {
mTpmsScan.stopScan();
}
break;
case R.id.btn_get_info:
if (deviceIdMap.isEmpty() || noId()) {
T.showLong(this, R.string.please_set_id);
} else {
if (mTpmsScan != null && deviceIdMap != null) {
mDeviceIdS = null;
if (getUuidStrings()) {
mTpmsScan.startScan(mDeviceIdS);
}
}
}
break;

case R.id.btn_clear_log:
infoList.clear();
listAdapter.notifyDataSetChanged();
break;
case R.id.ll_set_id:
new SetIdDialog(this, deviceIdMap, this).show();
break;
}
}


@Override
public void onGetData(String mac, String deviceId, int rssi, float pressure, float battery,
int temp, int status, float mcuVersion, int year, int month, int day,
float bleVersion) {

if (deviceIdMap != null) {
for (Config.DevicePosition devicePosition : deviceIdMap.keySet()) {
if (TextUtils.equals(deviceId, deviceIdMap.get(devicePosition))) {
Config.DeviceState deviceState = Config.DeviceState.NORMAL;
switch (status) {
case 1:
deviceState = Config.DeviceState.LEAK;
break;
case 2:
deviceState = Config.DeviceState.INFLATE;
break;
case 3:
deviceState = Config.DeviceState.START;
break;
case 4:
deviceState = Config.DeviceState.POWER_ON;
break;
case 5:
deviceState = Config.DeviceState.WEAK_UP;
break;
}

StringBuffer buffer = new StringBuffer();
buffer.append("设备位置:");
buffer.append(getPosition(devicePosition));
buffer.append(", 设备id:");
buffer.append(deviceId);
buffer.append(", 电压:");
buffer.append(battery);
buffer.append(", 气压:");
buffer.append(pressure);
buffer.append(", 温度:");
buffer.append(temp);
buffer.append(", 状态:");
buffer.append(getState(deviceState));
buffer.append(", 时间:");
buffer.append(ParseData.getTime());
sendMsg(buffer.toString());
return;
}
}
}

}


public void onStopScan() {
sendMsg("停止扫描");
}

public void onBluetoothStateOn() {
T.showLong(this, "蓝牙已开启!");
}

public void onBluetoothStateOff() {
T.showLong(this, "蓝牙已关闭!");
}

public void onBluetoothTurningOn() {
T.showLong(this, "蓝牙开启中!");
}

public void onBluetoothTurningOff() {
T.showLong(this, "蓝牙关闭中!");
}

private String getPosition(Config.DevicePosition devicePosition) {
switch (devicePosition) {
case LEFT_FRONT:
return "左前";
case RIGHT_FRONT:
return "右前";
case LEFT_REAR:
return "左后";
case RIGHT_REAR:
return "右后";
default:
return "";
}
}


private String getState(Config.DeviceState deviceState) {
switch (deviceState) {
case NORMAL:
return "正常";
case LEAK:
return "漏气";
case INFLATE:
return "充气";
case START:
return "启动";
case POWER_ON:
return "上电";
case WEAK_UP:
return "唤醒";
case TEMP_ERROR:
return "温度异常";
case BATTERY_ERROR:
return "电量异常";
case UNKNOWN:
return "未知";
default:
return "";
}
}

@Override
public void onIdSet() {
setDeviceIdMap();
if (noId()) {
if (mTpmsScan != null) {
mTpmsScan.stopScan();
}
}
setTyreId();
}

@Override
public void cancel() {
if (mTpmsScan != null) {
mTpmsScan.stopScan();
}
}

/**
* 没有设置ID重新扫描
*/
private boolean noId() {
if (deviceIdMap != null && !deviceIdMap.isEmpty()) {
if (TextUtils.isEmpty(deviceIdMap.get(Config.DevicePosition.LEFT_FRONT)) && TextUtils
.isEmpty(deviceIdMap.get(Config.DevicePosition.LEFT_REAR)) && TextUtils
.isEmpty(deviceIdMap.get(Config.DevicePosition.RIGHT_FRONT)) && TextUtils
.isEmpty(deviceIdMap.get(Config.DevicePosition.RIGHT_REAR))) {//当所有ID都为空时,停止扫描
return true;
}
}
return false;
}

private void showInfo(String str) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(infoList.size() + 1);
stringBuilder.append(".\n");
stringBuilder.append(str);
infoList.add(stringBuilder.toString());
listAdapter.notifyDataSetChanged();
lv_show_log.setSelection(infoList.size() - 1);
}

private Handler handler = new android.os.Handler() {
@Override
public void handleMessage(Message msg) {
String result = msg.getData().getString(RESULT);
if (!TextUtils.isEmpty(result)) {
showInfo(result);
}
}
};

private final static String RESULT = "RESULT";

private void sendMsg(String str) {
Message msg = new Message();
Bundle bundle = new Bundle();
bundle.putString(RESULT, str);
msg.setData(bundle);
handler.sendMessage(msg);
}


private boolean getUuidStrings() {
if (deviceIdMap != null) {
Set<Config.DevicePosition> devicePositions = deviceIdMap.keySet();
mDeviceIdS = new String[devicePositions.size()];
int i = 0;
for (Config.DevicePosition devicePosition : devicePositions) {
mDeviceIdS[i] = deviceIdMap.get(devicePosition);
i++;
}
return true;
}
return false;
}

}

+ 12
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/OnIdSetListener.java Parādīt failu

@@ -0,0 +1,12 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid;

/**
* xing<br>
* 2019/10/8<br>
* java类作用描述
*/
public interface OnIdSetListener {

void onIdSet();
void cancel();
}

+ 67
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/adapter/DeviceIdAdapter.java Parādīt failu

@@ -0,0 +1,67 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import aicare.net.cn.sdk.tmpsrepositoryandroid.R;
import aicare.net.cn.sdk.tmpsrepositoryandroid.bean.DeviceId;

/**
* Created by Suzy on 2016/8/30.
*/
public class DeviceIdAdapter extends BaseAdapter {

private List<DeviceId> deviceIds;
private Context context;

public DeviceIdAdapter(Context context, List<DeviceId> deviceIds) {
this.context = context;
this.deviceIds = deviceIds;
}

@Override
public int getCount() {
return deviceIds.size();
}

@Override
public Object getItem(int position) {
return deviceIds.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(R.layout.device_id_item, null);
viewHolder.tv_device_id = (TextView) convertView.findViewById(R.id.tv_device_id);
viewHolder.tv_count = (TextView) convertView.findViewById(R.id.tv_count);
convertView.setTag(viewHolder);
}
viewHolder = (ViewHolder) convertView.getTag();
setValues(viewHolder, position);
return convertView;
}

private void setValues(ViewHolder viewHolder, int position) {
viewHolder.tv_device_id.setText("设备ID:" + deviceIds.get(position).getDeviceId());
viewHolder.tv_count.setText("次数:" + deviceIds.get(position).getCount());
}

private class ViewHolder {
private TextView tv_device_id;
private TextView tv_count;
}
}

+ 41
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/bean/DeviceId.java Parādīt failu

@@ -0,0 +1,41 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.bean;

/**
* Created by Suzy on 2016/8/30.
*/
public class DeviceId {
private String deviceId;
private int count;

public DeviceId(String deviceId, int count) {
this.deviceId = deviceId;
this.count = count;
}

public DeviceId() {
}

public String getDeviceId() {
return deviceId;
}

public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}

public int getCount() {
return count;
}

public void setCount(int count) {
this.count = count;
}

@Override
public String toString() {
return "DeviceId{" +
"deviceId='" + deviceId + '\'' +
", count=" + count +
'}';
}
}

+ 71
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/Config.java Parādīt failu

@@ -0,0 +1,71 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.utils;

/**
* Created by Suzy on 2016/2/22.
*/
public class Config {

/**
* 设备安装位置
*/
public enum DevicePosition {
/**
* 左前
*/
LEFT_FRONT,
/**
* 左后
*/
LEFT_REAR,
/**
* 右前
*/
RIGHT_FRONT,
/**
* 右后
*/
RIGHT_REAR
}

/**
* 设备状态
*/
public enum DeviceState {
/**
* 正常
*/
NORMAL,
/**
* 漏气
*/
LEAK,
/**
* 充气
*/
INFLATE,
/**
* 启动
*/
START,
/**
* 上电
*/
POWER_ON,
/**
* 唤醒
*/
WEAK_UP,
/**
* 温度异常
*/
TEMP_ERROR,
/**
* 电量异常
*/
BATTERY_ERROR,
/**
* 未知
*/
UNKNOWN
}
}

+ 12
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/Configs.java Parādīt failu

@@ -0,0 +1,12 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.utils;

/**
* Created by Suzy on 2016/7/23.
*/
public class Configs {

public final static String LEFT_FRONT = "LEFT_FRONT";
public final static String LEFT_REAR = "LEFT_REAR";
public final static String RIGHT_FRONT = "RIGHT_FRONT";
public final static String RIGHT_REAR = "RIGHT_REAR";
}

+ 81
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/L.java Parādīt failu

@@ -0,0 +1,81 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.utils;

import android.util.Log;

/**
* Log统一管理类
*
* @author way
*/
public class L {
public static boolean isDebug = false;// 是否需要打印bug,可以在application的onCreate函数里面初始化
private static final String TAG = "iTpmsServices";

// 下面四个是默认tag的函数
public static void i(String msg) {
if (isDebug)
Log.i(TAG, msg);
}

public static void iAndTag(String tag, String msg) {
if (isDebug)
Log.i(tag, msg);
}

public static void d(String msg) {
if (isDebug)
Log.d(TAG, msg);
}

public static void e(String msg) {
if (isDebug)
Log.e(TAG, msg);
}

public static void v(String msg) {
if (isDebug)
Log.v(TAG, msg);
}

//下面是传入类名打印log
public static void i(Class<?> _class, String msg) {
if (isDebug)
Log.i(_class.getName(), msg);
}

public static void d(Class<?> _class, String msg) {
if (isDebug)
Log.d(_class.getName(), msg);
}

public static void e(Class<?> _class, String msg) {
if (isDebug)
Log.e(_class.getName(), msg);
}

public static void v(Class<?> _class, String msg) {
if (isDebug)
Log.v(_class.getName(), msg);
}

// 下面是传入自定义tag的函数
public static void i(String tag, String msg) {
if (isDebug)
Log.i(tag, msg);
}

public static void d(String tag, String msg) {
if (isDebug)
Log.d(tag, msg);
}

public static void e(String tag, String msg) {
if (isDebug)
Log.e(tag, msg);
}

public static void v(String tag, String msg) {
if (isDebug)
Log.v(tag, msg);
}
}

+ 204
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/ParseData.java Parādīt failu

@@ -0,0 +1,204 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.utils;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ParseData {

private final static String TAG = ParseData.class.getSimpleName();

/**
* byte转16进制
*
* @param b
* @return
*/
public static String binaryToHex(byte b) {
String str = byteToBit(b);
String hexStr = Integer.toHexString(Integer.parseInt(str, 2));
return hexStr.toUpperCase();
}

/**
* Byte转Bit
*/
public static String byteToBit(byte b) {
return "" + (byte) ((b >> 7) & 0x1) + (byte) ((b >> 6) & 0x1)
+ (byte) ((b >> 5) & 0x1) + (byte) ((b >> 4) & 0x1)
+ (byte) ((b >> 3) & 0x1) + (byte) ((b >> 2) & 0x1)
+ (byte) ((b >> 1) & 0x1) + (byte) ((b >> 0) & 0x1);
}

/**
* byte转十进制
*
* @param b
* @return
*/
public static int binaryToDecimal(byte b) {
String str = byteToBit(b);
return Integer.parseInt(str, 2);
}

/**
* 字符串长度等于1的话,补0
*
* @param str
* @return
*/
public static String addZero(String str) {
StringBuffer sBuffer = new StringBuffer();
if (str.length() == 1) {
sBuffer.append("0");
sBuffer.append(str);
return sBuffer.toString();
} else {
return str;
}
}

/**
* Bit转Byte
*/
public static byte bitToByte(String byteStr) {
int re, len;
if (null == byteStr) {
return 0;
}
len = byteStr.length();
if (len != 4 && len != 8) {
return 0;
}
if (len == 8) {// 8 bit处理
if (byteStr.charAt(0) == '0') {// 正数
re = Integer.parseInt(byteStr, 2);
} else {// 负数
re = Integer.parseInt(byteStr, 2) - 256;
}
} else {//4 bit处理
re = Integer.parseInt(byteStr, 2);
}
return (byte) re;
}

// 获取系统时间
public static String getTime() {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date curDate = new Date(System.currentTimeMillis());
String str = formatter.format(curDate);
return str;
}

/**
* 从一个byte[]数组中截取一部分
* @param src
* @param begin
* @param count
* @return
*/
public static byte[] subBytes(byte[] src, int begin, int count) {
byte[] bs = new byte[count];
for (int i=begin; i<begin+count; i++) bs[i-begin] = src[i];
return bs;
}

/**
* 解析数据
*
* @param b1
* @param b2
* @return
*/
public static int getData(byte b1, byte b2) {
int data = ((b1 & 0xFF)) + (b2 & 0xFF);
return data;
}

/**
* 保留小数点后count位
* @param d
* @param count
* @return
*/
public static double keepDecimal(double d, int count) {
BigDecimal decimal = new BigDecimal(d);
return decimal.setScale(count, BigDecimal.ROUND_HALF_UP).doubleValue();
}

/**
* 判断是不是正确的设备ID
* @param str
* @return
*/
public static boolean isDeviceId(String str) {
String upperCaseStr = str.toUpperCase();
switch (upperCaseStr.length()) {
case 5:
if (is0or1(upperCaseStr.substring(0, 1))) {
if (isHex(upperCaseStr.substring(1, upperCaseStr.length()))) {
return true;
}
}
break;
case 6:
if (isHex(upperCaseStr)) {
return true;
}
}
return false;
}

/**
* 验证是否为16进制数
*
* @param hex
* @return
*/
private static boolean isHex(String hex) {
String str = "^[A-Fa-f0-9]+$";
Pattern p = Pattern.compile(str);
Matcher m = p.matcher(hex);
return m.matches();
}

/**
* 验证是否是0或1
*
* @param numStr
* @return
*/
private static boolean is0or1(String numStr) {
String str = "^[0-1]*$";
Pattern p = Pattern.compile(str);
Matcher m = p.matcher(numStr);
return m.matches();
}

/**
* byte数组转string
*
* @param b
* @return
*/
public static String arr2Str(byte[] b) {
if (b == null) {
return null;
}
if (b.length == 0) {
return "[]";
}
StringBuffer buffer = new StringBuffer();
buffer.append("[");
for (int i = 0; i < b.length; i++) {
buffer.append(binaryToHex(b[i]));
if (i != b.length - 1) {
buffer.append(", ");
}
}
buffer.append("]");
return buffer.toString();
}
}

+ 173
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/SPUtils.java Parādīt failu

@@ -0,0 +1,173 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.utils;

import android.content.Context;
import android.content.SharedPreferences;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;

public class SPUtils {
public SPUtils() {
/* cannot be instantiated */
throw new UnsupportedOperationException("cannot be instantiated");
}

/**
* 保存在手机里面的文件名
*/
public static final String FILE_NAME = "share_data";

/**
* 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法
*
* @param context
* @param key
* @param object
*/
public static void put(Context context, String key, Object object) {

SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();

if (object instanceof String) {
editor.putString(key, (String) object);
} else if (object instanceof Integer) {
editor.putInt(key, (Integer) object);
} else if (object instanceof Boolean) {
editor.putBoolean(key, (Boolean) object);
} else if (object instanceof Float) {
editor.putFloat(key, (Float) object);
} else if (object instanceof Long) {
editor.putLong(key, (Long) object);
} else {
editor.putString(key, object.toString());
}

SharedPreferencesCompat.apply(editor);
}

/**
* 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值
*
* @param context
* @param key
* @param defaultObject
* @return
*/
public static Object get(Context context, String key, Object defaultObject) {
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);

if (defaultObject instanceof String) {
return sp.getString(key, (String) defaultObject);
} else if (defaultObject instanceof Integer) {
return sp.getInt(key, (Integer) defaultObject);
} else if (defaultObject instanceof Boolean) {
return sp.getBoolean(key, (Boolean) defaultObject);
} else if (defaultObject instanceof Float) {
return sp.getFloat(key, (Float) defaultObject);
} else if (defaultObject instanceof Long) {
return sp.getLong(key, (Long) defaultObject);
}

return null;
}

/**
* 移除某个key值已经对应的值
*
* @param context
* @param key
*/
public static void remove(Context context, String key) {
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.remove(key);
SharedPreferencesCompat.apply(editor);
}

/**
* 清除所有数据
*
* @param context
*/
public static void clear(Context context) {
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.clear();
SharedPreferencesCompat.apply(editor);
}

/**
* 查询某个key是否已经存在
*
* @param context
* @param key
* @return
*/
public static boolean contains(Context context, String key) {
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
return sp.contains(key);
}

/**
* 返回所有的键值对
*
* @param context
* @return
*/
public static Map<String, ?> getAll(Context context) {
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
return sp.getAll();
}

/**
* 创建一个解决SharedPreferencesCompat.apply方法的一个兼容类
*
* @author zhy
*
*/
private static class SharedPreferencesCompat {
private static final Method sApplyMethod = findApplyMethod();

/**
* 反射查找apply的方法
*
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Method findApplyMethod() {
try {
Class clz = SharedPreferences.Editor.class;
return clz.getMethod("apply");
} catch (NoSuchMethodException e) {
}

return null;
}

/**
* 如果找到则使用apply执行,否则使用commit
*
* @param editor
*/
public static void apply(SharedPreferences.Editor editor) {
try {
if (sApplyMethod != null) {
sApplyMethod.invoke(editor);
return;
}
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
editor.commit();
}
}

}

+ 114
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/utils/T.java Parādīt failu

@@ -0,0 +1,114 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.utils;

import android.content.Context;
import android.widget.Toast;

//Toast统一管理类
public class T {

private T() {
/* cannot be instantiated */
throw new UnsupportedOperationException("cannot be instantiated");
}

private static Toast mToast;

/**
* 短时间显示Toast
*
* @param context
* @param message
*/
public static void showShort(Context context, CharSequence message) {
if (mToast == null) {
mToast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
} else {
mToast.setText(message);
mToast.setDuration(Toast.LENGTH_SHORT);
}
mToast.show();
}

/**
* 短时间显示Toast
*
* @param context
* @param message
*/
public static void showShort(Context context, int message) {
if (mToast == null) {
mToast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
} else {
mToast.setText(message);
mToast.setDuration(Toast.LENGTH_SHORT);
}
mToast.show();
}

/**
* 长时间显示Toast
*
* @param context
* @param message
*/
public static void showLong(Context context, CharSequence message) {
if (mToast == null) {
mToast = Toast.makeText(context, message, Toast.LENGTH_LONG);
} else {
mToast.setText(message);
mToast.setDuration(Toast.LENGTH_LONG);
}
mToast.show();
}

/**
* 长时间显示Toast
*
* @param context
* @param message
*/
public static void showLong(Context context, int message) {
if (mToast == null) {
mToast = Toast.makeText(context, message, Toast.LENGTH_LONG);
} else {
mToast.setText(message);
mToast.setDuration(Toast.LENGTH_LONG);
}
mToast.show();
}

/**
* 自定义显示Toast时间
*
* @param context
* @param message
* @param duration
*/
public static void show(Context context, CharSequence message, int duration) {
if (mToast == null) {
mToast = Toast.makeText(context, message, duration);
} else {
mToast.setText(message);
mToast.setDuration(duration);
}
mToast.show();
}

/**
* 自定义显示Toast时间
*
* @param context
* @param message
* @param duration
*/
public static void show(Context context, int message, int duration) {
if (mToast == null) {
mToast = Toast.makeText(context, message, duration);
} else {
mToast.setText(message);
mToast.setDuration(duration);
}
mToast.show();
}

}

+ 99
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/views/MyTextView.java Parādīt failu

@@ -0,0 +1,99 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.views;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

import aicare.net.cn.sdk.tmpsrepositoryandroid.R;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.L;


/**
* Created by Suzy on 2016/1/19.
*/

public class MyTextView extends TextView implements View.OnTouchListener{
private final static String TAG = "MyTextView";

private int mDrawableSize;// xml文件中设置的大小

public MyTextView(Context context) {
this(context, null, 0);
}

public MyTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public MyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
Drawable drawableLeft = null, drawableTop = null, drawableRight = null, drawableBottom = null;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyTextView);

int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
L.i(TAG, "attr:" + attr);
switch (attr) {
case R.styleable.MyTextView_drawable_Size:
mDrawableSize = a.getDimensionPixelSize(R.styleable.MyTextView_drawable_Size, 50);
L.i(TAG, "mDrawableSize:" + mDrawableSize);
break;
case R.styleable.MyTextView_drawable_Top:
drawableTop = a.getDrawable(attr);
break;
case R.styleable.MyTextView_drawable_Bottom:
drawableRight = a.getDrawable(attr);
break;
case R.styleable.MyTextView_drawable_Right:
drawableBottom = a.getDrawable(attr);
break;
case R.styleable.MyTextView_drawable_Left:
drawableLeft = a.getDrawable(attr);
break;
default:
break;
}
}
a.recycle();

setCompoundDrawablesWithIntrinsicBounds(drawableLeft, drawableTop, drawableRight, drawableBottom);
this.setOnTouchListener(this);
}

public void setCompoundDrawablesWithIntrinsicBounds(Drawable left,
Drawable top, Drawable right, Drawable bottom) {

if (left != null) {
left.setBounds(0, 0, mDrawableSize, mDrawableSize);
}
if (right != null) {
right.setBounds(0, 0, mDrawableSize, mDrawableSize);
}
if (top != null) {
top.setBounds(0, 0, mDrawableSize, mDrawableSize);
}
if (bottom != null) {
bottom.setBounds(0, 0, mDrawableSize, mDrawableSize);
}
setCompoundDrawables(left, top, right, bottom);
}

@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
v.setAlpha(0.5f);
return true;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
v.setAlpha(1f);
return true;
}
return false;
}
}

+ 158
- 0
app/src/main/java/aicare/net/cn/sdk/tmpsrepositoryandroid/views/SetIdDialog.java Parādīt failu

@@ -0,0 +1,158 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid.views;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import java.util.EnumMap;
import java.util.Map;

import aicare.net.cn.sdk.tmpsrepositoryandroid.OnIdSetListener;
import aicare.net.cn.sdk.tmpsrepositoryandroid.R;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.Config;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.Configs;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.ParseData;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.SPUtils;
import aicare.net.cn.sdk.tmpsrepositoryandroid.utils.T;


/**
* Created by Suzy on 2016/2/22.
*/
public class SetIdDialog extends Dialog implements View.OnClickListener {

private Context context;

private EnumMap<Config.DevicePosition, String> deviceIdMap;

private EditText et_left_front, et_left_rear, et_right_front, et_right_rear;
private Button btn_query;

private OnIdSetListener onIdSetListener;

public SetIdDialog(Context context, EnumMap<Config.DevicePosition, String> deviceIdMap, OnIdSetListener onIdSetListener) {
super(context, R.style.MyDialog);
this.context = context;
this.deviceIdMap = deviceIdMap;
this.onIdSetListener = onIdSetListener;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initViews();
initEvents();
setInfo();
}

private void setInfo() {
if (deviceIdMap.size() != 0) {
for (Map.Entry<Config.DevicePosition, String> entry : deviceIdMap.entrySet()) {
switch (entry.getKey()) {
case LEFT_FRONT:
if (!TextUtils.isEmpty(entry.getValue())) {
et_left_front.setText(entry.getValue());
}
et_left_front.setSelection(entry.getValue().length());
break;
case LEFT_REAR:
if (!TextUtils.isEmpty(entry.getValue())) {
et_left_rear.setText(entry.getValue());
}
et_left_rear.setSelection(entry.getValue().length());
break;
case RIGHT_FRONT:
if (!TextUtils.isEmpty(entry.getValue())) {
et_right_front.setText(entry.getValue());
}
et_right_front.setSelection(entry.getValue().length());
break;
case RIGHT_REAR:
if (!TextUtils.isEmpty(entry.getValue())) {
et_right_rear.setText(entry.getValue());
}
et_right_rear.setSelection(entry.getValue().length());
break;
}
}
}
}

private void initViews() {
setContentView(R.layout.dialog_set_id);
btn_query = (Button) findViewById(R.id.btn_query);
et_left_front = (EditText) findViewById(R.id.et_left_front);
et_left_rear = (EditText) findViewById(R.id.et_left_rear);
et_right_front = (EditText) findViewById(R.id.et_right_front);
et_right_rear = (EditText) findViewById(R.id.et_right_rear);
}

private void initEvents() {
btn_query.setOnClickListener(this);
}

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_query:
if (onIdSetListener != null) {
String leftFront = et_left_front.getText().toString().trim().toUpperCase();
String leftRear = et_left_rear.getText().toString().trim().toUpperCase();
String rightFront = et_right_front.getText().toString().trim().toUpperCase();
String rightRear = et_right_rear.getText().toString().trim().toUpperCase();
boolean isLfIdOk = setDeviceIdMap(Config.DevicePosition.LEFT_FRONT, leftFront);
boolean isLrIdOk = setDeviceIdMap(Config.DevicePosition.LEFT_REAR, leftRear);
boolean isRfIdOk = setDeviceIdMap(Config.DevicePosition.RIGHT_FRONT, rightFront);
boolean isRrIdOk = setDeviceIdMap(Config.DevicePosition.RIGHT_REAR, rightRear);
if (showToast(isLfIdOk, isLrIdOk, isRfIdOk, isRrIdOk)) {
onIdSetListener.onIdSet();
dismiss();
}
}
break;
}
}

private boolean setDeviceIdMap(Config.DevicePosition devicePosition, String id) {
if (!TextUtils.isEmpty(id)) {
if (!ParseData.isDeviceId(id)) {
return false;
}
}
switch (devicePosition) {
case LEFT_FRONT:
SPUtils.put(context, Configs.LEFT_FRONT, id);
break;
case LEFT_REAR:
SPUtils.put(context, Configs.LEFT_REAR, id);
break;
case RIGHT_FRONT:
SPUtils.put(context, Configs.RIGHT_FRONT, id);
break;
case RIGHT_REAR:
SPUtils.put(context, Configs.RIGHT_REAR, id);
break;
}
return true;
}

private boolean showToast(boolean isLfIdOk, boolean isLrIdOk, boolean isRfIdOk, boolean isRrIdOk) {
if (!isLfIdOk) {
T.showShort(context, R.string.left_front_error);
} else if (!isLrIdOk) {
T.showShort(context, R.string.left_rear_error);
} else if (!isRfIdOk) {
T.showShort(context, R.string.right_front_error);
} else if (!isRrIdOk) {
T.showShort(context, R.string.right_rear_error);
} else {
T.showShort(context, R.string.set_id_success);
return true;
}
return false;
}
}

+ 34
- 0
app/src/main/res/drawable-v24/ic_launcher_foreground.xml Parādīt failu

@@ -0,0 +1,34 @@
<vector xmlns:aapt="http://schemas.android.com/aapt"
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0"/>
<item
android:color="#00000000"
android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
</vector>

+ 7
- 0
app/src/main/res/drawable/bg.xml Parādīt failu

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@android:color/white"/>
<stroke android:color="@android:color/darker_gray" android:width="3dp"/>
</shape>

+ 11
- 0
app/src/main/res/drawable/hw_bluetooth_scan_tv.xml Parādīt failu

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="125"
android:color="@android:color/holo_red_light"
android:state_pressed="true" />
<item android:alpha="125"
android:color="@android:color/black"
android:state_enabled="false" />
<item android:alpha="255"
android:color="@android:color/black"/>
</selector>

+ 171
- 0
app/src/main/res/drawable/ic_launcher_background.xml Parādīt failu

@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z"/>
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
</vector>

+ 87
- 0
app/src/main/res/layout/activity_main.xml Parādīt failu

@@ -0,0 +1,87 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">

<Button
android:id="@+id/btn_get_info"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="扫描(获取胎压信息)"/>


<Button
android:id="@+id/btn_clear_log"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="清空Log"/>

<Button
android:id="@+id/btn_stop_scan"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="停止扫描"/>
</LinearLayout>

<LinearLayout
android:id="@+id/ll_set_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg"
android:gravity="center"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/tv_left_front"
style="@style/TVTyreId"
android:text="@string/left_front_id"/>

<TextView
android:id="@+id/tv_right_front"
style="@style/TVTyreId"
android:text="@string/right_front_id"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/tv_left_rear"
style="@style/TVTyreId"
android:text="@string/left_rear_id"/>

<TextView
android:id="@+id/tv_right_rear"
style="@style/TVTyreId"
android:text="@string/right_rear_id"/>
</LinearLayout>
</LinearLayout>

<ListView
android:id="@+id/lv_show_log"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

+ 24
- 0
app/src/main/res/layout/device_id_item.xml Parādīt failu

@@ -0,0 +1,24 @@
<?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"
android:orientation="horizontal">

<TextView
android:id="@+id/tv_device_id"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"/>

<TextView
android:id="@+id/tv_count"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"/>
</LinearLayout>

+ 18
- 0
app/src/main/res/layout/dialog_get_id.xml Parādīt failu

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="200dp"
android:background="@drawable/bg"
android:orientation="vertical">

<ListView
android:id="@+id/lv_show_id"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>

<Button
android:id="@+id/btn_query"
style="@style/BtnQuery"
android:text="@string/cancel"/>
</LinearLayout>

+ 71
- 0
app/src/main/res/layout/dialog_set_id.xml Parādīt failu

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="160dp"
android:background="@drawable/bg"
android:orientation="vertical">

<TextView
style="@style/TvDialogTitle"
android:text="@string/please_set_id"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="2"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:weightSum="2">

<TextView
style="@style/TvSetId"
android:text="@string/left_front_hint"/>

<EditText
android:id="@+id/et_left_front"
style="@style/EtSetId"/>

<TextView
style="@style/TvSetId"
android:text="@string/right_front_hint"/>

<EditText
android:id="@+id/et_right_front"
style="@style/EtSetId"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:weightSum="2">

<TextView
style="@style/TvSetId"
android:text="@string/left_rear_hint"/>

<EditText
android:id="@+id/et_left_rear"
style="@style/EtSetId"/>

<TextView
style="@style/TvSetId"
android:text="@string/right_rear_hint"/>

<EditText
android:id="@+id/et_right_rear"
style="@style/EtSetId"/>
</LinearLayout>
</LinearLayout>

<Button
android:id="@+id/btn_query"
android:text="@string/query"
style="@style/BtnQuery"/>
</LinearLayout>

+ 5
- 0
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml Parādīt failu

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

+ 5
- 0
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml Parādīt failu

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

Binārs
app/src/main/res/mipmap-hdpi/ic_launcher.png Parādīt failu


Binārs
app/src/main/res/mipmap-hdpi/ic_launcher_round.png Parādīt failu


Binārs
app/src/main/res/mipmap-mdpi/ic_launcher.png Parādīt failu


Binārs
app/src/main/res/mipmap-mdpi/ic_launcher_round.png Parādīt failu


Binārs
app/src/main/res/mipmap-xhdpi/ic_launcher.png Parādīt failu


Binārs
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Parādīt failu


Binārs
app/src/main/res/mipmap-xxhdpi/ic_launcher.png Parādīt failu


Binārs
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Parādīt failu


Binārs
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Parādīt failu


Binārs
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Parādīt failu


+ 10
- 0
app/src/main/res/values/attrs.xml Parādīt failu

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MyTextView">
<attr name="drawable_Size" format="dimension"/>
<attr name="drawable_Top" format="reference"/>
<attr name="drawable_Left" format="reference"/>
<attr name="drawable_Right" format="reference"/>
<attr name="drawable_Bottom" format="reference"/>
</declare-styleable>
</resources>

+ 8
- 0
app/src/main/res/values/colors.xml Parādīt failu

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>

<color name="black">#000000</color>
</resources>

+ 5
- 0
app/src/main/res/values/dimens.xml Parādīt failu

@@ -0,0 +1,5 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

+ 23
- 0
app/src/main/res/values/strings.xml Parādīt failu

@@ -0,0 +1,23 @@
<resources>
<string name="app_name">TmpsRepositoryAndroid</string>

<string name="left_front_id">左前:%1$s</string>
<string name="right_front_id">右前:%1$s</string>
<string name="left_rear_id">左后:%1$s</string>
<string name="right_rear_id">右后:%1$s</string>
<string name="please_set_id">请设置ID</string>

<string name="left_front_hint">左前:</string>
<string name="left_rear_hint">左后:</string>
<string name="right_front_hint">右前:</string>
<string name="right_rear_hint">右后:</string>

<string name="left_front_error">左前ID错误</string>
<string name="left_rear_error">左后ID错误</string>
<string name="right_front_error">右前ID错误</string>
<string name="right_rear_error">右后ID错误</string>
<string name="set_id_success">设置成功</string>
<string name="query">确定</string>
<string name="cancel">退出</string>

</resources>

+ 68
- 0
app/src/main/res/values/styles.xml Parādīt failu

@@ -0,0 +1,68 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>


<style name="TVTyreId">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:gravity">center</item>
<item name="android:layout_weight">1</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
</style>

<style name="MyDialog" parent="android:Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:background">@null</item>
<item name="android:windowFrame">@null</item>
<!-- 是否浮现在activity之上 -->
<item name="android:windowIsFloating">true</item>
<!-- 半透明 -->
<item name="android:windowIsTranslucent">true</item>
<!-- 无标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 模糊 -->
<item name="android:backgroundDimEnabled">true</item>
</style>

<style name="TvSetId">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@color/black</item>
</style>

<style name="EtSetId">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:maxLength">6</item>
<item name="android:textColor">@color/black</item>
</style>


<style name="BtnQuery">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">40dp</item>
<item name="android:layout_marginLeft">40dp</item>
<item name="android:layout_marginRight">40dp</item>
<item name="android:textColor">@color/black</item>
</style>

<style name="TvDialogTitle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">40dp</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@color/black</item>
<item name="android:textSize">20sp</item>
</style>

</resources>

+ 17
- 0
app/src/test/java/aicare/net/cn/sdk/tmpsrepositoryandroid/ExampleUnitTest.java Parādīt failu

@@ -0,0 +1,17 @@
package aicare.net.cn.sdk.tmpsrepositoryandroid;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

+ 27
- 0
build.gradle Parādīt failu

@@ -0,0 +1,27 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

+ 20
- 0
gradle.properties Parādīt failu

@@ -0,0 +1,20 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true


Binārs
gradle/wrapper/gradle-wrapper.jar Parādīt failu


+ 6
- 0
gradle/wrapper/gradle-wrapper.properties Parādīt failu

@@ -0,0 +1,6 @@
#Wed Apr 08 11:31:02 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

+ 172
- 0
gradlew Parādīt failu

@@ -0,0 +1,172 @@
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
echo "$*"
}

die () {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"

+ 84
- 0
gradlew.bat Parādīt failu

@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega

+ 1
- 0
settings.gradle Parādīt failu

@@ -0,0 +1 @@
include ':app', ':tpmslibrary'

+ 1
- 0
tpmslibrary/.gitignore Parādīt failu

@@ -0,0 +1 @@
/build

+ 41
- 0
tpmslibrary/build.gradle Parādīt failu

@@ -0,0 +1,41 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"


defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41"
api files('libs/tpmslib.jar')

}

Binārs
tpmslibrary/libs/arm64-v8a/libtpms-lib.so Parādīt failu


Binārs
tpmslibrary/libs/armeabi-v7a/libtpms-lib.so Parādīt failu


Binārs
tpmslibrary/libs/tpmslib.jar Parādīt failu


Binārs
tpmslibrary/libs/x86/libtpms-lib.so Parādīt failu


Binārs
tpmslibrary/libs/x86_64/libtpms-lib.so Parādīt failu


+ 21
- 0
tpmslibrary/proguard-rules.pro Parādīt failu

@@ -0,0 +1,21 @@
# 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

+ 27
- 0
tpmslibrary/src/androidTest/java/aicare/net/cn/sdk/tpmslibrary/ExampleInstrumentedTest.java Parādīt failu

@@ -0,0 +1,27 @@
package aicare.net.cn.sdk.tpmslibrary;

import android.content.Context;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.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.getTargetContext();

assertEquals("aicare.net.cn.sdk.tpmslibrary.test", appContext.getPackageName());
}
}

+ 2
- 0
tpmslibrary/src/main/AndroidManifest.xml Parādīt failu

@@ -0,0 +1,2 @@
<manifest package="aicare.net.cn.sdk.tpmslibrary"
xmlns:android="http://schemas.android.com/apk/res/android"/>

+ 3
- 0
tpmslibrary/src/main/res/values/strings.xml Parādīt failu

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">TpmsLibrary</string>
</resources>

+ 17
- 0
tpmslibrary/src/test/java/aicare/net/cn/sdk/tpmslibrary/ExampleUnitTest.java Parādīt failu

@@ -0,0 +1,17 @@
package aicare.net.cn.sdk.tpmslibrary;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

Notiek ielāde…
Atcelt
Saglabāt