Commit 7370633a by chengchong

Merge remote-tracking branch 'origin/master'

parents 49dd5df2 ea6bc7f4
......@@ -19,6 +19,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>
......
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\jniLibs"/></dataSet></merger>
\ No newline at end of file
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/jniLibs"/></dataSet></merger>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\shaders"/></dataSet></merger>
\ No newline at end of file
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/shaders"/></dataSet></merger>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\assets"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\intermediates\shader_assets\debug\out"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\assets"/></dataSet></merger>
\ No newline at end of file
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/assets"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/intermediates/shader_assets/debug/out"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/assets"/></dataSet></merger>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\res"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\rs\debug"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\res"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\rs\debug"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\res"/></dataSet><mergedItems/></merger>
\ No newline at end of file
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/res"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/rs/debug"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/resValues/debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/res"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/rs/debug"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/resValues/debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/res"/></dataSet><mergedItems/></merger>
\ No newline at end of file
......@@ -6,21 +6,21 @@
6
7 <uses-sdk
8 android:minSdkVersion="14"
8-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
8-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
9 android:targetSdkVersion="30" />
9-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
9-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
10
11 <uses-permission android:name="android.permission.BLUETOOTH" />
11-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:5-68
11-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:22-65
11-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:5-68
11-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:22-65
12 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
12-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:5-74
12-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:22-71
12-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:5-74
12-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:22-71
13 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
13-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:5-81
13-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:22-78
13-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:5-81
13-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:22-78
14 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
14-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:5-79
14-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:22-76
14-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:5-79
14-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:22-76
15
16</manifest>
-- Merging decision tree log ---
manifest
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
package
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:2:5-30
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:2:5-30
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:versionName
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:versionCode
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
xmlns:android
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:11-69
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:11-69
uses-permission#android.permission.BLUETOOTH
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:5-68
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:5-68
android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:22-65
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:22-65
uses-permission#android.permission.BLUETOOTH_ADMIN
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:5-74
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:5-74
android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:22-71
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:22-71
uses-permission#android.permission.ACCESS_COARSE_LOCATION
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:5-81
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:5-81
android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:22-78
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:22-78
uses-permission#android.permission.ACCESS_FINE_LOCATION
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:5-79
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:5-79
android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:22-76
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:22-76
uses-sdk
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml reason: use-sdk injection requested
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml reason: use-sdk injection requested
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:targetSdkVersion
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:minSdkVersion
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
......@@ -65,6 +65,7 @@ dependencies {
implementation project(path: ':library')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
......
package com.example.blu.toys.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.Toast;
import androidx.appcompat.widget.AppCompatImageView;
import com.example.blu.toys.MainActivity;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import butterknife.BindView;
import butterknife.OnClick;
......
package com.example.blu.toys.activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
......@@ -77,20 +79,24 @@ public class PlayActivity extends BaseActivity {
public void handleMessage(Message msg) {
super.handleMessage(msg);
LogUtils.e("定时器在走111", msg.what, mHour, mMin, mSecond);
if ((mHour + mMin + mSecond) < 1) {
if (totalSecond < 1) {
suspendAndContinue = 0;
}else{
if (suspendAndContinue == 1) {
computeTime();
}
}
if (suspendAndContinue == 1) {
String mHourStr = addZeroForNum(mHour + "", 2);
String mMinStr = addZeroForNum(mMin + "", 2);
String mSecondStr = addZeroForNum(mSecond + "", 2);
typefaceTextView.setText(mHourStr + ":" + mMinStr + ":" + mSecondStr);
}
String mHourStr = addZeroForNum(mHour + "", 2);
String mMinStr = addZeroForNum(mMin + "", 2);
String mSecondStr = addZeroForNum(mSecond + "", 2);
typefaceTextView.setText(mHourStr + ":" + mMinStr + ":" + mSecondStr);
sendBleData();
computeTime();
}
};
......@@ -182,6 +188,8 @@ public class PlayActivity extends BaseActivity {
@OnClick(R.id.back_but)
public void onViewClicked() {
//点击返回的时候 不用提示就返回到上个页面即可
timerManager.cancelTimer();
AppManager.getInstance().finishActivity();
}
......@@ -189,9 +197,7 @@ public class PlayActivity extends BaseActivity {
@Override
public void onBackPressed() {
timerManager.cancelTimer();
Intent intent = new Intent(PlayActivity.this, SetTimeActivity.class);
startActivity(intent);
AppManager.getInstance().finishActivity();
}
@OnClick({R.id.cancel_but, R.id.pause_but, R.id.resume_but})
......@@ -205,23 +211,56 @@ public class PlayActivity extends BaseActivity {
switch (view.getId()) {
case R.id.cancel_but://取消 关机
timerManager.cancelTimer();
TrafficLightBean trafficLightBean = new TrafficLightBean(
1, 0,
0, 0, 0, 0, 0, 0);
byte[] bytes = trafficLightBean.toByte();
BlePlay.getInstance().sendStard(bytes, new BleWriteCallback() {
//需要有个提示 直接返回加号页面
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("提示:将断开蓝牙连接");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onWriteSuccess(int current, int total, byte[] justWrite) {
ToastUtils.show("关机-发送成功");
AppManager.getInstance().finishActivity();
}
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
timerManager.cancelTimer();
TrafficLightBean trafficLightBean = new TrafficLightBean(
1, 0,
0, 0, 0, 0, 0, 0);
byte[] bytes = trafficLightBean.toByte();
BlePlay.getInstance().sendStard(bytes, new BleWriteCallback() {
@Override
public void onWriteSuccess(int current, int total, byte[] justWrite) {
ToastUtils.show("关机-发送成功");
BlePlay.getInstance().closeBle();
Intent intent=new Intent(PlayActivity.this,AddDeviceActivity.class);
startActivity(intent);
}
@Override
public void onWriteFailure(BleException exception) {
}
});
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onWriteFailure(BleException exception) {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
builder.create();
builder.show();
break;
case R.id.pause_but://暂停
......
package com.example.blu.toys.activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.Switch;
import com.blankj.utilcode.util.LogUtils;
import com.clj.fastble.callback.BleWriteCallback;
import com.clj.fastble.exception.BleException;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.ble.BlePlay;
import com.example.blu.toys.ble.agreement.TrafficLightBean;
import com.example.blu.toys.utils.SpUtils;
import com.example.blu.toys.view.TypefaceTextView;
import com.hjq.toast.ToastUtils;
import butterknife.BindView;
import butterknife.OnClick;
......@@ -35,13 +43,38 @@ public class SelectTimerActivity extends BaseActivity {
return R.layout.activity_select_timer;
}
private void sendBle(){
SpUtils spUtils = SpUtils.getSpUtils(SelectTimerActivity.this);
int close = spUtils.getSPValue("close", 1);
int open = spUtils.getSPValue("open", 10);
int alarm = spUtils.getSPValue("alarm", 1);
int green = spUtils.getSPValue("green", 1);
int brightness = spUtils.getSPValue("brightness", 50);
TrafficLightBean ttt = new TrafficLightBean(2, 0,
0, brightness, open, close, green, alarm);
byte[] bytes12 = ttt.toByte();
BlePlay.getInstance().sendPause(bytes12, new BleWriteCallback() {
@Override
public void onWriteSuccess(int current, int total, byte[] justWrite) {
LogUtils.e("发送成功:" );
}
@Override
public void onWriteFailure(BleException exception) {
}
});
}
@Override
public void init(Bundle savedInstanceState) {
SpUtils spUtils = SpUtils.getSpUtils(this);
spUtils.getSPValue("close",1);
spUtils.getSPValue("open",10);
int open= spUtils.getSPValue("open",1);
int alarm = spUtils.getSPValue("alarm", 1);
int green = spUtils.getSPValue("green", 1);
int brightness = spUtils.getSPValue("brightness", 50);
......@@ -49,6 +82,8 @@ public class SelectTimerActivity extends BaseActivity {
//数据回显
alarmSwitch.setChecked(alarm == 1 ? true : false);
greenSwitch.setChecked(green == 1 ? true : false);
musicSwitch.setChecked(open == 1 ? true : false);
brightnessBar.setProgress(brightness);
......@@ -58,10 +93,18 @@ public class SelectTimerActivity extends BaseActivity {
} else {
spUtils.putSPValue("alarm", 0);
}
sendBle();
});
musicSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
startActivity(new Intent(SelectTimerActivity.this, MusicActivity.class));
//startActivity(new Intent(SelectTimerActivity.this, MusicActivity.class));
if (isChecked) {
spUtils.putSPValue("open", 1);
} else {
spUtils.putSPValue("open", 0);
}
sendBle();
});
greenSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
......@@ -70,12 +113,14 @@ public class SelectTimerActivity extends BaseActivity {
} else {
spUtils.putSPValue("green", 0);
}
sendBle();
});
brightnessBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
spUtils.putSPValue("brightness", progress);
sendBle();
}
@Override
......@@ -100,6 +145,9 @@ public class SelectTimerActivity extends BaseActivity {
@OnClick(R.id.back_but)
public void onViewClicked() {
AppManager.getInstance().finishActivity();
}
}
\ No newline at end of file
package com.example.blu.toys.activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
......@@ -339,8 +341,39 @@ public class SetTimeActivity extends BaseActivity {
@Override
public void onBackPressed() {
BlePlay.getInstance().closeBle();
AppManager.getInstance().finishActivity();
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("提示:将断开蓝牙连接");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
BlePlay.getInstance().closeBle();
Intent intent=new Intent(SetTimeActivity.this,AddDeviceActivity.class);
startActivity(intent);
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
builder.create();
builder.show();
// BlePlay.getInstance().closeBle();
// AppManager.getInstance().finishActivity();
}
......@@ -360,8 +393,32 @@ public class SetTimeActivity extends BaseActivity {
startActivity(intent);
break;
case R.id.back_but:
BlePlay.getInstance().closeBle();
AppManager.getInstance().finishActivity();
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("提示:将断开蓝牙连接");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
BlePlay.getInstance().closeBle();
Intent intent=new Intent(SetTimeActivity.this,AddDeviceActivity.class);
startActivity(intent);
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
builder.create();
builder.show();
break;
case R.id.start_but:
boolean bleOpen = BlePlay.getInstance().isBleOpen();
......
......@@ -26,7 +26,7 @@ public class TimerManager {
@Override
public void run() {
if (handler != null) {
LogUtils.e("定时器在走");
// LogUtils.e("定时器在走");
Message msg = new Message();
handler.sendMessage(msg);
......
......@@ -22,7 +22,7 @@ public class BleDeviceAdapter extends BaseQuickAdapter<BleDevice, BaseViewHolder
@Override
protected void convert(BaseViewHolder helper, BleDevice item) {
String deviceName = item.getName();
if (!TextUtils.isEmpty(deviceName) && deviceName.contains("Traffic")) {
if ((!TextUtils.isEmpty(deviceName) && deviceName.contains("Traffic"))||!TextUtils.isEmpty(deviceName) && deviceName.contains("blector")) {
helper.setText(R.id.dv_name, item.getName() + "");
}
}
......
package com.example.blu.toys.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.clj.fastble.data.BleDevice;
import com.example.blu.toys.R;
import com.example.blu.toys.utils.SpUtils;
......
package com.example.blu.toys.ble.agreement;
public class BCD8421Operater {
/**
* BCD字节数组===>String
* 中间
* @param bytes
* @return 十进制字符串
*/
public static String bcd2String(byte[] bytes) {
StringBuilder temp = new StringBuilder(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
// 高四位
temp.append((bytes[i] & 0xf0) >>> 4);
// 低四位
temp.append(bytes[i] & 0x0f);
}
return temp.toString().substring(0, 1).equalsIgnoreCase("0") ? temp.toString().substring(1) : temp.toString();
}
/**
* 字符串==>BCD字节数组
*
* @param str
* @return BCD字节数组
*/
public static byte[] string2Bcd(String str) {
// 奇数,前补零
if ((str.length() & 0x1) == 1) {
str = "0" + str;
}
byte ret[] = new byte[str.length() / 2];
byte bs[] = str.getBytes();
for (int i = 0; i < ret.length; i++) {
byte high = ascII2Bcd(bs[2 * i]);
byte low = ascII2Bcd(bs[2 * i + 1]);
// TODO 只遮罩BCD低四位?
ret[i] = (byte) ((high << 4) | low);
}
return ret;
}
private static byte ascII2Bcd(byte asc) {
if ((asc >= '0') && (asc <= '9'))
return (byte) (asc - '0');
else if ((asc >= 'A') && (asc <= 'F'))
return (byte) (asc - 'A' + 10);
else if ((asc >= 'a') && (asc <= 'f'))
return (byte) (asc - 'a' + 10);
else
return (byte) (asc - 48);
}
// public static void main(String[] sr){
// String aa=ByteUtil.bytesToHexString(BCD8421Operater.string2Bcd("211212121213"));
// System.out.println(aa);
//
// }
}
\ No newline at end of file
package com.example.blu.toys.ble.agreement;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
public class HexStringUtils {
private static final char[] DIGITS_HEX = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
protected static char[] encodeHex(byte[] data) {
int l = data.length;
char[] out = new char[l << 1];
for (int i = 0, j = 0; i < l; i++) {
out[j++] = DIGITS_HEX[(0xF0 & data[i]) >>> 4];
out[j++] = DIGITS_HEX[0x0F & data[i]];
}
return out;
}
protected static byte[] decodeHex(char[] data) {
int len = data.length;
if ((len & 0x01) != 0) {
throw new RuntimeException("字符个数应该为偶数");
}
byte[] out = new byte[len >> 1];
for (int i = 0, j = 0; j < len; i++) {
int f = toDigit(data[j], j) << 4;
j++;
f |= toDigit(data[j], j);
j++;
out[i] = (byte) (f & 0xFF);
}
return out;
}
protected static int toDigit(char ch, int index) {
int digit = Character.digit(ch, 16);
if (digit == -1) {
throw new RuntimeException("Illegal hexadecimal character " + ch + " at index " + index);
}
return digit;
}
public static String toHexString(byte[] bs) {
return new String(encodeHex(bs));
}
public static byte[] hexString2Bytes(String hex) {
return decodeHex(hex.toCharArray());
}
public static byte[] chars2Bytes(char[] bs) {
return decodeHex(bs);
}
}
\ No newline at end of file
package com.example.blu.toys.ble.agreement;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TrafficLightBean {
/**
* 固定头 1字节
*/
private byte begin=0x24;
/**
* 长度 1字节
*/
private byte length=0x11;
/**
* 协议编号 01:关机协议 02:暂停于继续协议 1字节
*/
private byte cmd;
/**
* 手机时间 yyMMddHHssmm 6个字节
*/
private byte[] phoneTime;
/**
* 暂停继续 0:暂停 1:继续 1字节
*/
private byte suspendAndContinue;
/**
* 剩余时间(小端) 秒为单位 2字节
*/
private byte[] timeRemaining;
/**
* 亮度调节 0-100 1字节
*/
private byte brightness;
/**
* 开机声音编号 1-20 1字节
*/
private byte openSoundNo;
/**
* 关机声音编号 1-20 1字节
*/
private byte closeSoundNo;
/**
* 红绿灯变更方式 0: 由绿变红 1:由红变黄 1字节
*/
private byte trafficLightUpdateSet;
/**
* 警报开关 0:关 1:开 1字节
*/
private byte alarm;
private byte key;
/**
*
* @param protocolNo 协议编号
* @param suspendAndContinue 暂停或者继续
* @param timeRemaining 剩余时间 毫秒
* @param brightness 亮度值 0-100 默认 50
* @param openSoundNo 开机声音编号 默认 1
* @param closeSoundNo 关机声音编号 默认 10
* @param trafficLightUpdateSet 红绿灯变更方式 默认 1
* @param alarm 报警状态 默认 0
*/
public TrafficLightBean(Integer protocolNo,Integer suspendAndContinue,Integer timeRemaining,Integer brightness,Integer openSoundNo,Integer closeSoundNo,Integer trafficLightUpdateSet,Integer alarm){
this.cmd= BitOperator.integerTo1Byte(protocolNo);
this.suspendAndContinue=BitOperator.integerTo1Byte(suspendAndContinue);
System.out.println("传入的剩余时间:"+timeRemaining);
this.timeRemaining=toLH(timeRemaining); //BitOperator.integerTo2Bytes();
this.brightness=BitOperator.integerTo1Byte(brightness);
this.openSoundNo=BitOperator.integerTo1Byte(openSoundNo);
this.closeSoundNo=BitOperator.integerTo1Byte(closeSoundNo);
this.trafficLightUpdateSet=BitOperator.integerTo1Byte(trafficLightUpdateSet);
this.alarm=BitOperator.integerTo1Byte(alarm);
SimpleDateFormat format= new SimpleDateFormat("yyMMddHHmmss");
String phoneTime= format.format(new Date());
this.phoneTime= BCD8421Operater.string2Bcd(phoneTime);
String yy= phoneTime.substring(0,2);
String MM= phoneTime.substring(2,4);
String dd= phoneTime.substring(4,6);
String HH= phoneTime.substring(6,8);
String mm= phoneTime.substring(8,10);
String ss= phoneTime.substring(10,12);
Integer bo1=BCD8421Operater.string2Bcd(yy)[0]+BCD8421Operater.string2Bcd(HH)[0];
Integer bo2=BCD8421Operater.string2Bcd(MM)[0]^BCD8421Operater.string2Bcd(mm)[0];
Integer bo3=BCD8421Operater.string2Bcd(dd)[0]+BCD8421Operater.string2Bcd(ss)[0];
Integer key=(bo1^bo2)+bo3;
this.key=BitOperator.integerTo1Byte(key);
System.out.println("时间:"+phoneTime);
System.out.println("key 10进制:"+key);
System.out.println("key byte:"+this.key);
}
/**
* int 转换小端
* @param n
* @return
*/
public static byte[] toLH(int n) {
byte[] b = new byte[2];
b[0] = (byte) (n & 0xff);
b[1] = (byte) (n >> 8 & 0xff);
return b;
}
public byte[] toByte(){
//数据要加密的
byte[] resData=new byte[17];
resData[0]=this.begin;
resData[1]=this.length;
resData[2]=BitOperator.integerTo1Byte(this.cmd+this.key);
resData[3]=this.phoneTime[0];//1 不需要加密
resData[4]=this.phoneTime[1];//2 不需要加密
resData[5]=this.phoneTime[2];//3 不需要加密
resData[6]=this.phoneTime[3];//4 不需要加密
resData[7]=this.phoneTime[4];//5 不需要急吗
resData[8]=this.phoneTime[5];//6 不需要加密
resData[9]=BitOperator.integerTo1Byte(this.suspendAndContinue+this.key);
resData[10]=BitOperator.integerTo1Byte(this.timeRemaining[0]+this.key);
resData[11]=BitOperator.integerTo1Byte(this.timeRemaining[1]+this.key);
resData[12]=BitOperator.integerTo1Byte(this.brightness+this.key);
resData[13]=BitOperator.integerTo1Byte(this.openSoundNo+this.key);
resData[14]=BitOperator.integerTo1Byte(this.closeSoundNo+this.key);
resData[15]=BitOperator.integerTo1Byte(this.trafficLightUpdateSet+this.key);
resData[16]=BitOperator.integerTo1Byte(this.alarm+this.key);
System.out.println("发送数据为:"+HexStringUtils.toHexString(resData));
return resData;
}
public static void main(String[] args) {
TrafficLightBean trafficLightBean=new TrafficLightBean(2,0,
300,100,10,20,01,01);
System.out.println(HexStringUtils.toHexString(trafficLightBean.toByte()));
// System.out.printf("00000000");
}
}
\ No newline at end of file
......@@ -234,28 +234,7 @@
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dp_20"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_80"
android:src="@mipmap/shopbutton" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_80"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_8"
android:src="@mipmap/settingsbutton" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_80"
android:src="@mipmap/ratebutton" />
</LinearLayout>
android:orientation="horizontal"/>
</RelativeLayout>
\ No newline at end of file
......@@ -8,11 +8,16 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0'
}
}
allprojects {
repositories {
google()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment