| @@ -6,7 +6,7 @@ android { | |||
| applicationId "aicare.net.cn.sdk.ailinksdkdemoandroid" | |||
| minSdkVersion 19 | |||
| targetSdkVersion 31 | |||
| versionName "1.11.9" | |||
| versionName "1.11.10" | |||
| versionCode getVersionCodeNumber(versionName) | |||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | |||
| } | |||
| @@ -64,10 +64,11 @@ dependencies { | |||
| implementation fileTree(dir: 'libs', include: ['*.jar']) | |||
| implementation 'androidx.appcompat:appcompat:1.4.2' | |||
| implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | |||
| implementation 'androidx.cardview:cardview:1.0.0' | |||
| testImplementation 'junit:junit:4.12' | |||
| implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.13.11'//蓝牙核心库 | |||
| implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.14.1'//蓝牙核心库 | |||
| implementation 'com.github.elinkthings:AILinkSDKOtaLibraryAndroid:1.0.3'//OTA库,需要依赖核心库 | |||
| implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.8.4'//蓝牙解析库 | |||
| implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.9.1'//蓝牙解析库 | |||
| implementation 'androidx.recyclerview:recyclerview:1.2.1' | |||
| implementation 'com.jakewharton:butterknife:10.2.0' | |||
| annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0' | |||
| @@ -113,6 +113,10 @@ | |||
| <activity | |||
| android:name=".modules.broadcast_weight_sacle.BroadcastWeightScaleActivity" | |||
| android:screenOrientation="unspecified" /> | |||
| <activity | |||
| android:name=".modules.barometric_temp_humidity.BarometricTempHygrometerActivity" | |||
| android:screenOrientation="portrait" /> | |||
| <activity android:name=".modules.wifible_sphy.WifiBleSphyActivity" /> | |||
| <provider | |||
| android:name="androidx.core.content.FileProvider" | |||
| @@ -31,6 +31,7 @@ import com.pingwang.bluetoothlib.listener.OnMcuParameterListener; | |||
| import com.pingwang.bluetoothlib.utils.BleDensityUtil; | |||
| import com.pingwang.bluetoothlib.utils.BleLog; | |||
| import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @@ -5,6 +5,7 @@ import android.view.View; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.AppBaseActivity; | |||
| /** | |||
| * xing<br> | |||
| * 2022/4/6<br> | |||
| @@ -232,7 +232,7 @@ public class BroadcastBloodOxygenActivity extends BleBaseActivity implements OnC | |||
| int vid = bleValueBean.getVid(); | |||
| int pid = bleValueBean.getPid(); | |||
| if (mDevice != null) | |||
| mDevice.onNotifyData(manufacturerData, cid, vid, pid); | |||
| mDevice.onNotifyData("",manufacturerData, cid, vid, pid); | |||
| } | |||
| } | |||
| @@ -35,7 +35,6 @@ import cn.net.aicare.modulelibrary.module.BroadcastScale.BroadcastScaleDeviceDat | |||
| import cn.net.aicare.modulelibrary.module.babyscale.BabyBleConfig; | |||
| /** | |||
| * xing<br> | |||
| * 2020/08/10<br> | |||
| @@ -378,7 +377,7 @@ public class BroadcastScaleActivity extends BleNewBaseActivity implements OnCall | |||
| int vid = bleValueBean.getVid(); | |||
| int pid = bleValueBean.getPid(); | |||
| if (mDevice != null) { | |||
| mDevice.onNotifyData( manufacturerData, cid, vid, pid); | |||
| mDevice.onNotifyData("", manufacturerData, cid, vid, pid); | |||
| } | |||
| } | |||
| } | |||
| @@ -26,12 +26,12 @@ import com.pingwang.bluetoothlib.listener.OnMcuParameterListener; | |||
| import com.pingwang.bluetoothlib.utils.BleDensityUtil; | |||
| import com.pingwang.bluetoothlib.utils.BleLog; | |||
| import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||
| import cn.net.aicare.modulelibrary.module.height.HeightDeviceData; | |||
| @@ -15,13 +15,13 @@ import com.pingwang.bluetoothlib.bean.BleValueBean; | |||
| import com.pingwang.bluetoothlib.bean.SupportUnitBean; | |||
| import com.pingwang.bluetoothlib.device.BleDevice; | |||
| import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.AllUnitUtils; | |||
| import java.lang.ref.WeakReference; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.AllUnitUtils; | |||
| import cn.net.aicare.algorithmutil.AlgorithmUtil; | |||
| import cn.net.aicare.algorithmutil.BodyFatData; | |||
| import cn.net.aicare.modulelibrary.module.HeightWeightScale.HeightBodyFatBleData; | |||
| @@ -91,6 +91,7 @@ public class MainActivity extends AppCompatActivity { | |||
| } | |||
| }); | |||
| MyListener listener = new MyListener(); | |||
| // Button btn_shpy = findViewById(R.id.btn_sphy); | |||
| @@ -122,6 +123,7 @@ public class MainActivity extends AppCompatActivity { | |||
| // Button btn_wifi_ble_weight = findViewById(R.id.btn_wifi_ble_weight); | |||
| // Button btn_baby_body_fat = findViewById(R.id.btn_baby_body_fat); | |||
| mList.add(findViewById(R.id.btn_sphy)); | |||
| mList.add(findViewById(R.id.btn_sphy_wifi_ble)); | |||
| mList.add(findViewById(R.id.btn_tempgun)); | |||
| mList.add(findViewById(R.id.btn_temp)); | |||
| mList.add(findViewById(R.id.btn_baby)); | |||
| @@ -178,6 +180,7 @@ public class MainActivity extends AppCompatActivity { | |||
| mList.add(findViewById(R.id.btn_weight_scale)); | |||
| mList.add(findViewById(R.id.btn_broadcast_scale_weight)); | |||
| mList.add(findViewById(R.id.btn_meat_probe)); | |||
| mList.add(findViewById(R.id.btn_barometric_temp_humidity)); | |||
| for (View view : mList) { | |||
| view.setOnClickListener(listener); | |||
| } | |||
| @@ -292,6 +295,9 @@ public class MainActivity extends AppCompatActivity { | |||
| case R.id.btn_sphy: | |||
| type = BleDeviceConfig.BLOOD_PRESSURE; | |||
| break; | |||
| case R.id.btn_sphy_wifi_ble: | |||
| type = BleDeviceConfig.SPHY_WIFI_BLE; | |||
| break; | |||
| case R.id.btn_tempgun: | |||
| type = BleDeviceConfig.INFRARED_THERMOMETER; | |||
| break; | |||
| @@ -304,6 +310,9 @@ public class MainActivity extends AppCompatActivity { | |||
| case R.id.btn_height: | |||
| type = BleDeviceConfig.HEIGHT_METER; | |||
| break; | |||
| case R.id.btn_lock: | |||
| type = BleDeviceConfig.SMART_LOCK; | |||
| break; | |||
| case R.id.btn_ad_weight: | |||
| type = BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_AD; | |||
| break; | |||
| @@ -485,6 +494,9 @@ public class MainActivity extends AppCompatActivity { | |||
| // 食物探针 | |||
| type = BleDeviceConfig.MEAT_PROBE; | |||
| break; | |||
| case R.id.btn_barometric_temp_humidity: | |||
| type = BleDeviceConfig.BAROMETRIC_TEMP_HUMIDITY; | |||
| break; | |||
| case R.id.btn_mqtt: | |||
| return; | |||
| @@ -544,12 +556,17 @@ public class MainActivity extends AppCompatActivity { | |||
| boolean bleStatus = AppStart.isLocServiceEnable(mContext); | |||
| if (!bleStatus) { | |||
| //没有开启定位服务 | |||
| mHintDataDialog = HintDataDialogFragment.newInstance().setTitle("提示", 0).setCancel("取消", 0).setOk("确定", 0).setContent("请求开启定位服务", true).setOnDialogListener(new HintDataDialogFragment.onDialogListener() { | |||
| @Override | |||
| public void onSucceedListener(View v) { | |||
| startLocationActivity(); | |||
| } | |||
| }); | |||
| mHintDataDialog = HintDataDialogFragment.newInstance() | |||
| .setTitle("提示", 0) | |||
| .setCancel("取消", 0) | |||
| .setOk("确定", 0) | |||
| .setContent("请求开启定位服务", true) | |||
| .setOnDialogListener(new HintDataDialogFragment.onDialogListener() { | |||
| @Override | |||
| public void onSucceedListener(View v) { | |||
| startLocationActivity(); | |||
| } | |||
| }); | |||
| mHintDataDialog.show(getSupportFragmentManager()); | |||
| @@ -584,12 +601,17 @@ public class MainActivity extends AppCompatActivity { | |||
| ActivityCompat.requestPermissions(this, LOCATION_PERMISSION, PERMISSION); | |||
| } else { | |||
| //权限请求失败,选中“不再提示”选项 | |||
| mHintDataDialog = HintDataDialogFragment.newInstance().setTitle("提示", 0).setCancel("取消", 0).setOk("确定", 0).setContent("请求开启定位权限", true).setOnDialogListener(new HintDataDialogFragment.onDialogListener() { | |||
| @Override | |||
| public void onSucceedListener(View v) { | |||
| AppStart.startUseSetActivity(mContext); | |||
| } | |||
| }); | |||
| mHintDataDialog = HintDataDialogFragment.newInstance() | |||
| .setTitle("提示", 0) | |||
| .setCancel("取消", 0) | |||
| .setOk("确定", 0) | |||
| .setContent("请求开启定位权限", true) | |||
| .setOnDialogListener(new HintDataDialogFragment.onDialogListener() { | |||
| @Override | |||
| public void onSucceedListener(View v) { | |||
| AppStart.startUseSetActivity(mContext); | |||
| } | |||
| }); | |||
| mHintDataDialog.show(getSupportFragmentManager()); | |||
| } | |||
| @@ -28,6 +28,7 @@ import androidx.core.app.ActivityCompat; | |||
| import androidx.recyclerview.widget.LinearLayoutManager; | |||
| import androidx.recyclerview.widget.RecyclerView; | |||
| import com.pingwang.bluetoothlib.bean.BleScanAddAilinkBean; | |||
| import com.pingwang.bluetoothlib.bean.BleValueBean; | |||
| import com.pingwang.bluetoothlib.config.BleConfig; | |||
| import com.pingwang.bluetoothlib.device.BleDevice; | |||
| @@ -38,9 +39,7 @@ import com.pingwang.bluetoothlib.utils.BleLog; | |||
| import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.UUID; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.adapter.StringAdapter; | |||
| @@ -52,6 +51,7 @@ import aicare.net.cn.sdk.ailinksdkdemoandroid.find.FindDeviceNewActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.PublicBleNetworkCmdActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.TempInstrument.TempInstrumentActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.airdetector.AirDetectorActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.barometric_temp_humidity.BarometricTempHygrometerActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.ble_nutrition.BleNutritionActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.blood_pressure_tc.BloodPressureTcActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.coffee_scale.CoffeeScaleActivity; | |||
| @@ -68,6 +68,7 @@ import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.share_socket.ShareSocketAc | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.toothbrush.ToothBrushWifiBleActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.toothbrush_test.ToothbrushTestActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.weight_scale.WeightScaleActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.wifible_sphy.WifiBleSphyActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.CheckPermissionUtils; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.view.MyItemDecoration; | |||
| import cn.net.aicare.modulelibrary.module.RopeSkipping.RopeSkippingBleData; | |||
| @@ -142,7 +143,9 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| // 如果是蓝牙牙刷,就弹个框提醒 | |||
| if (mType == BleDeviceConfig.TOOTHBRUSH_TEST) { | |||
| new AlertDialog.Builder(mContext).setMessage("启动牙刷,工作10秒钟,然后关闭牙刷(让牙刷处于广播状态),然后点击搜索,选中列表中的牙刷,开始测试").setPositiveButton("确认", null).show(); | |||
| new AlertDialog.Builder(mContext).setMessage("启动牙刷,工作10秒钟,然后关闭牙刷(让牙刷处于广播状态),然后点击搜索,选中列表中的牙刷,开始测试") | |||
| .setPositiveButton("确认", null) | |||
| .show(); | |||
| } | |||
| } | |||
| @@ -157,7 +160,8 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| mBleValueList = new ArrayList<>(); | |||
| RecyclerView recyclerView = findViewById(R.id.rv_data); | |||
| recyclerView.setLayoutManager(new LinearLayoutManager(mContext)); | |||
| recyclerView.addItemDecoration(new MyItemDecoration(mContext, LinearLayoutManager.VERTICAL, 1, mContext.getResources().getColor(R.color.public_press_bg))); | |||
| recyclerView.addItemDecoration(new MyItemDecoration(mContext, LinearLayoutManager.VERTICAL, 1, mContext.getResources() | |||
| .getColor(R.color.public_press_bg))); | |||
| Button btn = findViewById(R.id.btn); | |||
| Button btn1 = findViewById(R.id.btn1); | |||
| Button clear = findViewById(R.id.clear); | |||
| @@ -186,12 +190,12 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| mFilterName = et_filter_name.getText().toString().trim(); | |||
| mFilterMac = et_filter_mac.getText().toString().trim(); | |||
| if (mType == BleDeviceConfig.SMART_SCOOTER) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put(SkateboardBleConfig.UUID_BROADCAST.toString(), "37,3,1");//37=0x0025=电滑板的cid | |||
| mBluetoothService.startScan(30 * 1000, map, BleConfig.UUID_SERVER_AILINK, SkateboardBleConfig.UUID_BROADCAST); | |||
| List<BleScanAddAilinkBean> list = new ArrayList<>(); | |||
| list.add(new BleScanAddAilinkBean(0x37, 0x03, 0x01, SkateboardBleConfig.UUID_BROADCAST)); | |||
| mBluetoothService.startScan(30 * 1000, list, BleConfig.UUID_SERVER_AILINK, SkateboardBleConfig.UUID_BROADCAST); | |||
| } else { | |||
| //0000FEE7=手表 | |||
| mBluetoothService.startScan(1000, BleConfig.UUID_SERVER_AILINK, UUID.fromString("0000FEE7-0000-1000-8000-00805F9B34FB"), SkateboardBleConfig.UUID_BROADCAST); | |||
| mBluetoothService.startScan(30 * 1000, BleConfig.UUID_BROADCAST_AILINK, BleConfig.UUID_SERVER_BROADCAST_AILINK, UUID.fromString("0000FEE7-0000-1000-8000-00805F9B34FB"), SkateboardBleConfig.UUID_BROADCAST); | |||
| } | |||
| mBleValueList.clear(); | |||
| listAdapter.notifyDataSetChanged(); | |||
| @@ -203,7 +207,7 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| @Override | |||
| public void onClick(View v) { | |||
| if (mBluetoothService != null) { | |||
| mBluetoothService.stopScan(); | |||
| mBluetoothService.stopScan(10000); | |||
| } | |||
| } | |||
| }); | |||
| @@ -292,7 +296,11 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| } | |||
| String data2 = BleStrUtils.byte2HexStr(bleValueBean.getManufacturerData()); | |||
| showData.append(data2); | |||
| HintDataDialogFragment.newInstance().setTitle("自定义厂商数据", 0).setContent(showData.toString(), false).setOk("", 0).show(getSupportFragmentManager()); | |||
| HintDataDialogFragment.newInstance() | |||
| .setTitle("自定义厂商数据", 0) | |||
| .setContent(showData.toString(), false) | |||
| .setOk("", 0) | |||
| .show(getSupportFragmentManager()); | |||
| } | |||
| }); | |||
| recyclerView.setAdapter(listAdapter); | |||
| @@ -329,10 +337,9 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| BleValueBean bleValueBean = mBleValueList.get(i); | |||
| if (bleValueBean.equals(data)) { | |||
| bleValueBean.setRssi(data.getRssi()); | |||
| if (!oldData) { | |||
| oldData = true; | |||
| } | |||
| oldData = true; | |||
| listAdapter.notifyItemChanged(i); | |||
| break; | |||
| } | |||
| } | |||
| if (!oldData) { | |||
| @@ -384,9 +391,11 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| intent.setClass(ShowBleActivity.this, TempGunCmdActivity.class); | |||
| break; | |||
| case BleDeviceConfig.BLOOD_PRESSURE: | |||
| case BleDeviceConfig.SPHY_WIFI_BLE: | |||
| intent.setClass(ShowBleActivity.this, SphyCmdActivity.class); | |||
| break; | |||
| case BleDeviceConfig.SPHY_WIFI_BLE: | |||
| intent.setClass(ShowBleActivity.this, WifiBleSphyActivity.class); | |||
| break; | |||
| case BleDeviceConfig.THERMOMETER: | |||
| intent.setClass(ShowBleActivity.this, TempCmdActivity.class); | |||
| break; | |||
| @@ -529,7 +538,10 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| case BleDeviceConfig.MEAT_PROBE: | |||
| intent.setClass(ShowBleActivity.this, MeatProbeActivity.class); | |||
| break; | |||
| case BleDeviceConfig.BAROMETRIC_TEMP_HUMIDITY: | |||
| // 气压温湿度计 | |||
| intent.setClass(ShowBleActivity.this, BarometricTempHygrometerActivity.class); | |||
| break; | |||
| default: | |||
| break; | |||
| @@ -561,7 +573,6 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| @Override | |||
| public boolean onFilter(BleValueBean bleValueBean) { | |||
| int cid = bleValueBean.getCid(); | |||
| BleLog.i(TAG, "绑定设备广播类型:" + cid + "||添加的类型:" + mType); | |||
| boolean nameAndMac = false; | |||
| if (TextUtils.isEmpty(mFilterName) && TextUtils.isEmpty(mFilterMac)) { | |||
| nameAndMac = true; | |||
| @@ -586,6 +597,9 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| if (mScanCid == BleDeviceConfig.FOOD_TEMP && nameAndMac) { | |||
| return cid == BleDeviceConfig.FOOD_TEMP || cid == 63; | |||
| } | |||
| // if (mScanCid == BleDeviceConfig.BLOOD_PRESSURE && nameAndMac) { | |||
| // return cid == BleDeviceConfig.BLOOD_PRESSURE || cid == BleDeviceConfig.SPHY_WIFI_BLE; | |||
| // } | |||
| if (mScanCid < 0) { | |||
| return nameAndMac; | |||
| } else { | |||
| @@ -596,24 +610,11 @@ public class ShowBleActivity extends BleBaseActivity implements OnCallbackBle, O | |||
| private boolean isCheckDevice(int scanCid, int cid, boolean nameAndMac) { | |||
| boolean okDevice = false; | |||
| if (scanCid == BleDeviceConfig.BLOOD_PRESSURE) { | |||
| //血压计包含wifi+bel | |||
| if (nameAndMac) { | |||
| okDevice = (scanCid == cid) || (cid == BleDeviceConfig.SPHY_WIFI_BLE); | |||
| } | |||
| } else { | |||
| okDevice = scanCid == cid && nameAndMac; | |||
| } | |||
| boolean okDevice = scanCid == cid && nameAndMac; | |||
| return okDevice; | |||
| } | |||
| @Override | |||
| public void onScanRecord(BleValueBean mBle) { | |||
| //TODO 过滤后的设备 | |||
| } | |||
| @Override | |||
| public void onScanTimeOut() { | |||
| @@ -303,11 +303,15 @@ public class WeightScaleBleActivity extends BleBaseActivity implements View.OnCl | |||
| break; | |||
| case BodyFatDataUtil.TEST_FINISH: | |||
| mlogList.add(0, "测量状态:" + status + " 测量完成"); | |||
| if (bodyFatBleUtilsData != null) { | |||
| bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().updataPresentUser(selectUser)); | |||
| } | |||
| break; | |||
| case BodyFatDataUtil.MUC_REQUEST_USER_INFO: | |||
| mlogList.add(0, "测量状态:" + status + "请求用户信息"); | |||
| if (bodyFatBleUtilsData != null) | |||
| if (bodyFatBleUtilsData != null) { | |||
| bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().setUserInfo(selectUser, BleDeviceConfig.WEIGHT_BODY_FAT_SCALE)); | |||
| } | |||
| break; | |||
| default: | |||
| mlogList.add(0, "测量状态:" + status); | |||
| @@ -502,8 +506,9 @@ public class WeightScaleBleActivity extends BleBaseActivity implements View.OnCl | |||
| int userid = Integer.parseInt(mEditText.getText().toString().trim()); | |||
| if (mUsers.size() >= userid) { | |||
| selectUser = mUsers.get(userid - 1); | |||
| if (bodyFatBleUtilsData != null) | |||
| if (bodyFatBleUtilsData != null) { | |||
| bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().updataPresentUser(selectUser)); | |||
| } | |||
| } | |||
| } | |||
| break; | |||
| @@ -15,11 +15,10 @@ import android.widget.TextView; | |||
| import androidx.annotation.Nullable; | |||
| import androidx.appcompat.widget.Toolbar; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.HintDataDialogFragment; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.CheckPermissionUtils; | |||
| import java.lang.ref.WeakReference; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.HintDataDialogFragment; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.CheckPermissionUtils; | |||
| import butterknife.ButterKnife; | |||
| import butterknife.Unbinder; | |||
| @@ -12,9 +12,11 @@ import com.pingwang.bluetoothlib.AILinkBleManager; | |||
| import com.pingwang.bluetoothlib.bean.BleValueBean; | |||
| import com.pingwang.bluetoothlib.config.BleConfig; | |||
| import com.pingwang.bluetoothlib.utils.BleLog; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.BuildConfig; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||
| /** | |||
| * xing<br> | |||
| * 2019/4/25<br> | |||
| @@ -10,9 +10,11 @@ import com.pingwang.bluetoothlib.AILinkBleManager; | |||
| import com.pingwang.bluetoothlib.bean.BleValueBean; | |||
| import com.pingwang.bluetoothlib.config.BleConfig; | |||
| import com.pingwang.bluetoothlib.utils.BleLog; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.BuildConfig; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||
| /** | |||
| * xing<br> | |||
| * 2019/4/25<br> | |||
| @@ -2,8 +2,6 @@ package aicare.net.cn.sdk.ailinksdkdemoandroid.base; | |||
| import android.app.Application; | |||
| import com.pingwang.bluetoothlib.AILinkSDK; | |||
| public class MyApplication extends Application { | |||
| private static MyApplication sInstance; | |||
| @@ -12,7 +10,6 @@ public class MyApplication extends Application { | |||
| public void onCreate() { | |||
| super.onCreate(); | |||
| sInstance = this; | |||
| AILinkSDK.getInstance().init(this); | |||
| } | |||
| public static MyApplication getInstance(){ | |||
| @@ -0,0 +1,532 @@ | |||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.dialog; | |||
| import android.app.Dialog; | |||
| import android.content.Context; | |||
| import android.content.DialogInterface; | |||
| import android.graphics.Color; | |||
| import android.graphics.drawable.ColorDrawable; | |||
| import android.graphics.drawable.Drawable; | |||
| import android.os.Bundle; | |||
| import android.text.Editable; | |||
| import android.text.InputFilter; | |||
| import android.text.InputType; | |||
| import android.text.TextUtils; | |||
| import android.text.TextWatcher; | |||
| import android.util.DisplayMetrics; | |||
| import android.view.Gravity; | |||
| import android.view.KeyEvent; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.view.Window; | |||
| import android.view.WindowManager; | |||
| import android.widget.EditText; | |||
| import android.widget.TextView; | |||
| import androidx.annotation.ColorInt; | |||
| import androidx.annotation.IntDef; | |||
| import androidx.annotation.NonNull; | |||
| import androidx.annotation.Nullable; | |||
| import androidx.fragment.app.DialogFragment; | |||
| import androidx.fragment.app.FragmentManager; | |||
| import java.lang.annotation.Retention; | |||
| import java.lang.annotation.RetentionPolicy; | |||
| import java.util.regex.Pattern; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||
| /** | |||
| * 修改信息的弹框 | |||
| */ | |||
| public class MoveDataDialogFragment extends DialogFragment implements View.OnClickListener { | |||
| private String TAG = MoveDataDialogFragment.class.getName(); | |||
| public static final int EMAIL = 2; | |||
| public static final int NAME = 1; | |||
| public static final int PAW = 3; | |||
| @IntDef({EMAIL, NAME, PAW}) | |||
| @Retention(RetentionPolicy.SOURCE) | |||
| public @interface MoveDataType { | |||
| } | |||
| private Context mContext; | |||
| private OnDialogListener mOnDialogListener; | |||
| private EditText mEtName; | |||
| private TextView mTvCancel, mTvSucceed, mTvTitle, mTvTitleHint; | |||
| private int mNameLength = 32; | |||
| private CharSequence mTitle = ""; | |||
| private CharSequence mTitleHint; | |||
| private CharSequence mContent = ""; | |||
| private CharSequence mContentHint = ""; | |||
| private CharSequence mCancel = ""; | |||
| @ColorInt | |||
| private int mCancelColor = 0; | |||
| private CharSequence mOkStr = ""; | |||
| private String mRegular = ""; | |||
| @ColorInt | |||
| private int mOkColor = 0; | |||
| private boolean mBottom; | |||
| /** | |||
| * 点击确定后是否自动关闭,默认true | |||
| */ | |||
| private boolean autoDismiss = true; | |||
| /** | |||
| * 是否显示灰色背景 | |||
| */ | |||
| private boolean mBackground = true; | |||
| /** | |||
| * 点击空白区域是否关闭 | |||
| */ | |||
| private boolean mCancelBlank; | |||
| /** | |||
| * 是否显示 | |||
| */ | |||
| private boolean mShow; | |||
| /** | |||
| * 类型 | |||
| */ | |||
| private int mType; | |||
| /** | |||
| * 确认按钮背景 | |||
| */ | |||
| private Drawable drawable; | |||
| public static MoveDataDialogFragment newInstance() { | |||
| return new MoveDataDialogFragment(); | |||
| } | |||
| @Override | |||
| public void onCreate(@Nullable Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| setStyle(STYLE_NO_FRAME, R.style.MyDialog); | |||
| } | |||
| @NonNull | |||
| @Override | |||
| public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { | |||
| setStyle(STYLE_NO_FRAME, R.style.MyDialog); | |||
| Dialog dialogView = new Dialog(requireContext(), R.style.MyDialog);// 创建自定义样式dialog | |||
| dialogView.setCancelable(false);//设置是否可以关闭 | |||
| dialogView.setCanceledOnTouchOutside(mCancelBlank);//设置点击空白处是否可以取消 | |||
| dialogView.setOnKeyListener((dialog, keyCode, event) -> { | |||
| if (mCancelBlank) { | |||
| return false; | |||
| } else { | |||
| //返回不关闭 | |||
| return keyCode == KeyEvent.KEYCODE_BACK; | |||
| } | |||
| }); | |||
| return dialogView; | |||
| } | |||
| @Nullable | |||
| @Override | |||
| public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, | |||
| @Nullable Bundle savedInstanceState) { | |||
| return inflater.inflate(R.layout.dialog_move_data, container); | |||
| } | |||
| @Override | |||
| public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |||
| super.onViewCreated(view, savedInstanceState); | |||
| mContext = view.getContext(); | |||
| init(view, mType); | |||
| initData(mTitle, mTitleHint, mContent, mContentHint, mCancelColor, mOkColor, mType); | |||
| } | |||
| @Override | |||
| public void onActivityCreated(@Nullable Bundle savedInstanceState) { | |||
| super.onActivityCreated(savedInstanceState); | |||
| Dialog dialog = getDialog(); | |||
| if (dialog != null) { | |||
| Window window = dialog.getWindow(); | |||
| if (window != null) { | |||
| window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); | |||
| WindowManager.LayoutParams params = window.getAttributes(); | |||
| if (mBackground) { | |||
| params.dimAmount = 0.5f; | |||
| } else { | |||
| params.dimAmount = 0f; | |||
| } | |||
| if (mBottom) { | |||
| params.y = 10;//设置Dialog距离底部的距离 | |||
| params.gravity = Gravity.BOTTOM; | |||
| } | |||
| window.setAttributes(params); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * 初始化控件 | |||
| */ | |||
| private void init(View view, int type) { | |||
| mEtName = view.findViewById(R.id.et_move_data_context); | |||
| mTvCancel = view.findViewById(R.id.tv_move_data_cancel); | |||
| mTvSucceed = view.findViewById(R.id.tv_move_data_ok); | |||
| mTvTitle = view.findViewById(R.id.tv_move_data_title); | |||
| mTvTitleHint = view.findViewById(R.id.tv_move_data_title_hint); | |||
| if (type == NAME) { | |||
| mEtName.addTextChangedListener(new TextWatcher() { | |||
| @Override | |||
| public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |||
| } | |||
| @Override | |||
| public void onTextChanged(CharSequence s, int start, int before, int count) { | |||
| } | |||
| @Override | |||
| public void afterTextChanged(Editable s) { | |||
| String name = s.toString().trim(); | |||
| if (name.length() > mNameLength) { | |||
| mEtName.setText(name.substring(0, mNameLength)); | |||
| mEtName.setSelection(mEtName.getText().length()); | |||
| } | |||
| } | |||
| }); | |||
| } else if (type == EMAIL) { | |||
| mEtName.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); | |||
| mEtName.setSelection(mEtName.getText().length()); | |||
| } | |||
| if (!TextUtils.isEmpty(mRegular)) { | |||
| mEtName.setFilters(new InputFilter[]{(charSequence, start, end, dest, dstart, dend) -> { | |||
| boolean isChinese = Pattern.matches(mRegular, charSequence.toString()); | |||
| if (isChinese) { | |||
| return ""; | |||
| } | |||
| return null; | |||
| }}); | |||
| } | |||
| if (mOnDialogListener != null) { | |||
| mOnDialogListener.onModifyName(mEtName); | |||
| } | |||
| mTvCancel.setOnClickListener(this); | |||
| mTvSucceed.setOnClickListener(this); | |||
| } | |||
| /** | |||
| * 点击确定后是否自动关闭,默认true | |||
| * | |||
| * @param autoDismiss 默认true | |||
| * @return MoveDataDialogFragment | |||
| */ | |||
| public MoveDataDialogFragment setAutoDismiss(boolean autoDismiss) { | |||
| this.autoDismiss = autoDismiss; | |||
| return this; | |||
| } | |||
| @Override | |||
| public void onClick(View v) { | |||
| int i = v.getId(); | |||
| if (i == R.id.tv_move_data_cancel) { | |||
| if (mOnDialogListener != null) { | |||
| mOnDialogListener.onCancelListener(v); | |||
| } | |||
| dismiss(); | |||
| } else if (i == R.id.tv_move_data_ok) { | |||
| if (mOnDialogListener != null) { | |||
| String data = mEtName.getText().toString().trim(); | |||
| mOnDialogListener.onSucceedListener(v, data); | |||
| } | |||
| if (!mEtName.getText().toString().trim().isEmpty() && autoDismiss) { | |||
| dismiss(); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * 初始化数据 | |||
| * | |||
| * @param title 标题 | |||
| * @param titleHint 标题提示 | |||
| * @param content 输入框内容 | |||
| * @param contentHint 输入框提示 | |||
| * @param cancelColor 取消颜色 | |||
| * @param okColor 确定颜色 | |||
| * @param type 类型(名称,email){@link MoveDataType} | |||
| */ | |||
| private void initData(CharSequence title, CharSequence titleHint, CharSequence content, | |||
| CharSequence contentHint, int cancelColor, int okColor, int type) { | |||
| setTitle(title, titleHint); | |||
| setContent(content, contentHint, type); | |||
| setCancel("", cancelColor); | |||
| setOk("", okColor, drawable); | |||
| } | |||
| /** | |||
| * @param content 输入框内容 | |||
| * @param contentHint 输入框提示 | |||
| * @param type {@link MoveDataType} | |||
| * @return | |||
| */ | |||
| public MoveDataDialogFragment setContent(CharSequence content, CharSequence contentHint, @MoveDataType int type) { | |||
| this.mType = type; | |||
| if (mType == NAME) { | |||
| if (mContent != null && mContent.length() > mNameLength) { | |||
| mContent = content.toString().substring(0, mNameLength); | |||
| } else { | |||
| this.mContent = content; | |||
| } | |||
| } else { | |||
| this.mContent = content; | |||
| } | |||
| this.mContentHint = contentHint; | |||
| if (mEtName != null) { | |||
| if (mContent != null && !mContent.equals("")) { | |||
| mEtName.setText(mContent); | |||
| mEtName.setSelection(mEtName.getText().length()); | |||
| } else if (mContent == null) { | |||
| mEtName.setText(""); | |||
| } | |||
| if (mContentHint != null && !mContentHint.equals("")) { | |||
| mEtName.setHint(mContentHint); | |||
| } else if (mContentHint == null || mContentHint.equals("")) { | |||
| mEtName.setHint(""); | |||
| } | |||
| if (mType == PAW) { | |||
| mEtName.setInputType(8194); | |||
| mEtName.setFilters(new InputFilter[]{new InputFilter.LengthFilter(6)}); | |||
| } | |||
| } | |||
| return this; | |||
| } | |||
| public MoveDataDialogFragment setTitle(CharSequence title, CharSequence titleHint) { | |||
| this.mTitle = title; | |||
| this.mTitleHint = titleHint; | |||
| if (mTvTitle != null) { | |||
| if (mTitle != null && !mTitle.equals("")) { | |||
| mTvTitle.setVisibility(View.VISIBLE); | |||
| mTvTitle.setText(mTitle); | |||
| } else if (mTitle == null) { | |||
| mTvTitle.setVisibility(View.GONE); | |||
| } | |||
| } | |||
| if (mTvTitleHint != null) { | |||
| if (mTitleHint != null && mTitleHint.length() != 0) { | |||
| mTvTitleHint.setVisibility(View.VISIBLE); | |||
| mTvTitleHint.setText(mTitleHint); | |||
| } else { | |||
| mTvTitleHint.setVisibility(View.GONE); | |||
| } | |||
| } | |||
| return this; | |||
| } | |||
| public MoveDataDialogFragment setCancel(CharSequence cancel, @ColorInt int cancelColor) { | |||
| this.mCancel = cancel; | |||
| this.mCancelColor = cancelColor; | |||
| if (mTvCancel != null) { | |||
| if (mCancel != null && !mCancel.equals("")) { | |||
| mTvCancel.setVisibility(View.VISIBLE); | |||
| mTvCancel.setText(mCancel); | |||
| } else if (mCancel == null) { | |||
| mTvCancel.setVisibility(View.GONE); | |||
| } | |||
| if (mCancelColor > 0) { | |||
| mTvCancel.setTextColor(mCancelColor); | |||
| } | |||
| } | |||
| return this; | |||
| } | |||
| /** | |||
| * 确认按钮 | |||
| */ | |||
| public MoveDataDialogFragment setOk(CharSequence ok, @ColorInt int okColor) { | |||
| return setOk(ok, okColor, null); | |||
| } | |||
| public MoveDataDialogFragment setOk(CharSequence ok, @ColorInt int okColor, Drawable drawable) { | |||
| this.mOkStr = ok; | |||
| this.mOkColor = okColor; | |||
| this.drawable = drawable; | |||
| if (mTvSucceed != null) { | |||
| if (mOkStr != null && !mOkStr.equals("")) { | |||
| mTvSucceed.setVisibility(View.VISIBLE); | |||
| mTvSucceed.setText(mOkStr); | |||
| } else if (mOkStr == null) { | |||
| mTvSucceed.setVisibility(View.GONE); | |||
| } | |||
| if (mOkColor > 0) { | |||
| mTvSucceed.setTextColor(mOkColor); | |||
| } | |||
| if (drawable != null) { | |||
| mTvSucceed.setBackground(drawable); | |||
| } | |||
| } | |||
| return this; | |||
| } | |||
| /** | |||
| * 设置edittext输入的过滤 | |||
| * | |||
| * @param regular 过滤的正则 | |||
| * @return | |||
| */ | |||
| public MoveDataDialogFragment setFilters(String regular) { | |||
| this.mRegular = regular; | |||
| return this; | |||
| } | |||
| /** | |||
| * 设置dialog是否在底部 | |||
| */ | |||
| public MoveDataDialogFragment setBottom(boolean bottom) { | |||
| mBottom = bottom; | |||
| return this; | |||
| } | |||
| /** | |||
| * 设置dialog是否有灰色背景,默认显示灰色背景 | |||
| */ | |||
| public MoveDataDialogFragment setBackground(boolean background) { | |||
| mBackground = background; | |||
| return this; | |||
| } | |||
| /** | |||
| * 设置点击空白区域是否可以关闭,默认false | |||
| */ | |||
| public MoveDataDialogFragment setCancelBlank(boolean cancelable) { | |||
| mCancelBlank = cancelable; | |||
| return this; | |||
| } | |||
| public MoveDataDialogFragment setOnDialogListener(OnDialogListener mOnDialogListener) { | |||
| this.mOnDialogListener = mOnDialogListener; | |||
| return this; | |||
| } | |||
| public MoveDataDialogFragment setNameLength(int nameLength) { | |||
| mNameLength = nameLength; | |||
| return this; | |||
| } | |||
| public MoveDataDialogFragment setOkBack(int nameLength) { | |||
| mNameLength = nameLength; | |||
| return this; | |||
| } | |||
| /** | |||
| * 当前是否显示 | |||
| */ | |||
| public boolean isShow() { | |||
| return mShow; | |||
| } | |||
| @Override | |||
| public void show(@NonNull FragmentManager manager, @Nullable String tag) { | |||
| try { | |||
| if (!mShow) { | |||
| super.show(manager, tag); | |||
| mShow = true; | |||
| } | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public void show(@NonNull FragmentManager manager) { | |||
| this.show(manager, "HintDataDialogFragment"); | |||
| } | |||
| @Override | |||
| public void onDismiss(@NonNull DialogInterface dialog) { | |||
| super.onDismiss(dialog); | |||
| mShow = false; | |||
| } | |||
| @Override | |||
| public void dismiss() { | |||
| try { | |||
| mShow = false; | |||
| super.dismiss(); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public interface OnDialogListener { | |||
| /** | |||
| * 取消的点击事件 | |||
| */ | |||
| default void onCancelListener(View v) { | |||
| } | |||
| /** | |||
| * 成功的点击事件 | |||
| */ | |||
| default void onSucceedListener(View v, String data) { | |||
| } | |||
| /** | |||
| * 修改名称的控件 | |||
| */ | |||
| default void onModifyName(EditText v) { | |||
| } | |||
| } | |||
| @Override | |||
| public void onDestroyView() { | |||
| super.onDestroyView(); | |||
| mShow = false; | |||
| } | |||
| @Override | |||
| public void onStart() { | |||
| super.onStart(); | |||
| Dialog dialog = getDialog(); | |||
| if (dialog != null) { | |||
| dialog.setOnDismissListener(this); | |||
| DisplayMetrics dm = new DisplayMetrics(); | |||
| if (getActivity() != null) { | |||
| getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); | |||
| if (dialog.getWindow() != null) | |||
| { | |||
| //设置宽度为80% | |||
| dialog.getWindow().setLayout((int) (dm.widthPixels * 0.8), | |||
| ViewGroup.LayoutParams.WRAP_CONTENT); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -27,29 +27,31 @@ import java.util.ArrayList; | |||
| import java.util.List; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.L; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.view.MyItemDecoration; | |||
| /** | |||
| * 列表显示的dialog | |||
| * | |||
| * @author xing | |||
| * @date 2023/09/23 | |||
| */ | |||
| public class ShowListDialogFragment extends DialogFragment implements View.OnClickListener { | |||
| private String TAG = ShowListDialogFragment.class.getName(); | |||
| private Context mContext; | |||
| private onDialogListener mOnDialogListener; | |||
| private TextView mTvCancel, mTvTitle; | |||
| private TextView mTvCancel, mTvTitle, tv_dialog_list_data_hint; | |||
| private RecyclerView rv_dialog_list; | |||
| private DialogStringImageAdapter mAdapter; | |||
| private int mCancelColor; | |||
| private CharSequence mCancel; | |||
| private CharSequence mTitle; | |||
| private CharSequence mCancel = ""; | |||
| private CharSequence mTitle = ""; | |||
| private ArrayList<DialogStringImageBean> mList; | |||
| private boolean mBottom; | |||
| /** | |||
| * 是否显示灰色背景 | |||
| */ | |||
| private boolean mBackground=true; | |||
| private boolean mBackground = true; | |||
| /** | |||
| * 点击空白区域是否关闭 | |||
| @@ -102,7 +104,6 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| @Override | |||
| public void onActivityCreated(@Nullable Bundle savedInstanceState) { | |||
| super.onActivityCreated(savedInstanceState); | |||
| L.i(TAG,"onActivityCreated"); | |||
| Dialog dialog = getDialog(); | |||
| if (dialog != null) { | |||
| Window window = dialog.getWindow(); | |||
| @@ -124,7 +125,6 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| } | |||
| /** | |||
| * 初始化控件,数据 | |||
| */ | |||
| @@ -132,10 +132,10 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| mTvTitle = view.findViewById(R.id.tv_dialog_list_data_title); | |||
| mTvCancel = view.findViewById(R.id.tv_dialog_photo_cancel); | |||
| rv_dialog_list = view.findViewById(R.id.rv_dialog_list); | |||
| tv_dialog_list_data_hint = view.findViewById(R.id.tv_dialog_list_data_hint); | |||
| rv_dialog_list.setLayoutManager(new LinearLayoutManager(mContext)); | |||
| rv_dialog_list.addItemDecoration(new MyItemDecoration(mContext, | |||
| LinearLayoutManager.VERTICAL, 1, | |||
| mContext.getResources().getColor(R.color.public_press_bg))); | |||
| rv_dialog_list.addItemDecoration(new MyItemDecoration(mContext, LinearLayoutManager.VERTICAL, 1, mContext.getResources() | |||
| .getColor(R.color.public_press_bg))); | |||
| } | |||
| @@ -145,8 +145,9 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| */ | |||
| private void initData(ArrayList<DialogStringImageBean> list, CharSequence title, CharSequence cancel, int cancelColor) { | |||
| if (mList == null) | |||
| if (mList == null) { | |||
| mList = new ArrayList<>(); | |||
| } | |||
| mAdapter = new DialogStringImageAdapter(mContext, mList, position -> { | |||
| if (mOnDialogListener != null) { | |||
| //item点击事件 | |||
| @@ -185,8 +186,9 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| } else if (mCancel == null) { | |||
| mTvCancel.setVisibility(View.GONE); | |||
| } | |||
| if (mCancelColor != 0) | |||
| if (mCancelColor != 0) { | |||
| mTvCancel.setTextColor(mCancelColor); | |||
| } | |||
| } | |||
| @@ -199,10 +201,20 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| public ShowListDialogFragment setList(List<DialogStringImageBean> list) { | |||
| if (mList == null) { | |||
| mList = new ArrayList<>(); | |||
| mList.addAll(list); | |||
| } | |||
| if (mAdapter != null) | |||
| mList.clear(); | |||
| mList.addAll(list); | |||
| if (tv_dialog_list_data_hint != null) { | |||
| if (mList.size() == 0) { | |||
| tv_dialog_list_data_hint.setVisibility(View.VISIBLE); | |||
| } else { | |||
| tv_dialog_list_data_hint.setVisibility(View.GONE); | |||
| } | |||
| } | |||
| if (mAdapter != null) { | |||
| mAdapter.notifyDataSetChanged(); | |||
| } | |||
| return this; | |||
| } | |||
| @@ -215,8 +227,9 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| public void onClick(View v) { | |||
| int i = v.getId(); | |||
| if (i == R.id.tv_dialog_photo_cancel) { | |||
| if (mOnDialogListener != null) | |||
| if (mOnDialogListener != null) { | |||
| mOnDialogListener.onCancelListener(v); | |||
| } | |||
| dismiss(); | |||
| } | |||
| } | |||
| @@ -263,7 +276,6 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| mShow = true; | |||
| } | |||
| } catch (Exception e) { | |||
| L.e(TAG, "显示异常"); | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| @@ -287,7 +299,6 @@ public class ShowListDialogFragment extends DialogFragment implements View.OnCli | |||
| mShow = false; | |||
| super.dismiss(); | |||
| } catch (Exception e) { | |||
| L.e(TAG, "关闭异常"); | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| @@ -19,7 +19,7 @@ import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||
| * | |||
| * @author xing | |||
| */ | |||
| public class BleDemoActivity extends BleBaseActivity { | |||
| public class BleDemoActivity extends BleBaseActivity { | |||
| private ListView list_view; | |||
| @@ -499,7 +499,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| public SendBleBean checkWiFiState() { | |||
| byte[] bytes = new byte[1]; | |||
| bytes[0] = 0x26; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| @@ -507,13 +507,13 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| byte[] bytes = new byte[2]; | |||
| bytes[0] = (byte) CmdConfig.GET_SCAN_WIFI_RESULT; | |||
| bytes[1] = 0x01; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| public SendBleBean getSnDeviceId() { | |||
| byte[] bytes = new byte[1]; | |||
| bytes[0] = (byte) 0x93; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| public SendBleBean setWifiMac(String mac) { | |||
| @@ -521,9 +521,9 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| bytes[0] = (byte) CmdConfig.SET_WIFI_MAC; | |||
| String[] s = mac.split(":"); | |||
| for (int i = 0; i < s.length; i++) { | |||
| bytes[i + 1] = (byte) Integer.parseInt(s[i]); | |||
| bytes[i + 1] = (byte) Integer.parseInt(s[s.length -1 - i], 16); | |||
| } | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| @@ -541,7 +541,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| bytes1 = new byte[1]; | |||
| bytes1[0] = (byte) 0x86; | |||
| } | |||
| return getSendBleBeam(bytes1); | |||
| return getSendBleBean(bytes1); | |||
| } | |||
| @@ -549,7 +549,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| byte[] bytes = new byte[2]; | |||
| bytes[0] = (byte) CmdConfig.DIS_OR_CON_WIFI; | |||
| bytes[1] = 0x01; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| /** | |||
| @@ -562,7 +562,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| byte[] bytes = new byte[2]; | |||
| bytes[0] = (byte) CmdConfig.DIS_OR_CON_WIFI; | |||
| bytes[1] = 0x00; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| /** | |||
| @@ -574,7 +574,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| public SendBleBean getConnectWifiName() { | |||
| byte[] bytes = new byte[1]; | |||
| bytes[0] = (byte) CmdConfig.GET_WIFI_NAME; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| /** | |||
| @@ -585,14 +585,14 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| public SendBleBean getConnectWifiPwd() { | |||
| byte[] bytes = new byte[1]; | |||
| bytes[0] = (byte) CmdConfig.GET_WIFI_PWD; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| public SendBleBean reset() { | |||
| byte[] bytes = new byte[2]; | |||
| bytes[0] = 0x22; | |||
| bytes[1] = 0x01; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| @@ -600,19 +600,19 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| public SendBleBean checkIp() { | |||
| byte[] bytes = new byte[1]; | |||
| bytes[0] = (byte) 0x8c; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| public SendBleBean checkPort() { | |||
| byte[] bytes = new byte[1]; | |||
| bytes[0] = (byte) 0x8e; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| public SendBleBean checkUrl() { | |||
| byte[] bytes = new byte[1]; | |||
| bytes[0] = (byte) 0x97; | |||
| return getSendBleBeam(bytes); | |||
| return getSendBleBean(bytes); | |||
| } | |||
| @@ -628,7 +628,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| bytes1[0] = (byte) 0x8b; | |||
| } | |||
| return getSendBleBeam(bytes1); | |||
| return getSendBleBean(bytes1); | |||
| } | |||
| @@ -638,7 +638,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| bytes1[0] = (byte) 0x8d; | |||
| bytes1[1] = (byte) (port >> 8); | |||
| bytes1[2] = (byte) (port & 0xff); | |||
| return getSendBleBeam(bytes1); | |||
| return getSendBleBean(bytes1); | |||
| } | |||
| @@ -654,7 +654,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| bytes1[0] = (byte) 0x96; | |||
| } | |||
| return getSendBleBeam(bytes1); | |||
| return getSendBleBean(bytes1); | |||
| } | |||
| @@ -765,7 +765,7 @@ public class PublicBleNetworkCmdActivity extends BleBaseActivity implements OnCa | |||
| } | |||
| } | |||
| private SendBleBean getSendBleBeam(byte[] bytes) { | |||
| private SendBleBean getSendBleBean(byte[] bytes) { | |||
| SendBleBean sendBleBean = new SendBleBean(); | |||
| sendBleBean.setHex(bytes); | |||
| return sendBleBean; | |||
| @@ -0,0 +1,314 @@ | |||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.barometric_temp_humidity; | |||
| import android.app.AlertDialog; | |||
| import android.os.Bundle; | |||
| import android.text.TextUtils; | |||
| import android.view.View; | |||
| import android.widget.ArrayAdapter; | |||
| import android.widget.EditText; | |||
| import android.widget.ListView; | |||
| import androidx.annotation.Nullable; | |||
| import androidx.lifecycle.Lifecycle; | |||
| import androidx.recyclerview.widget.LinearLayoutManager; | |||
| import androidx.recyclerview.widget.RecyclerView; | |||
| import com.pingwang.bluetoothlib.AILinkBleManager; | |||
| import com.pingwang.bluetoothlib.device.BleDevice; | |||
| import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||
| import com.pingwang.bluetoothlib.utils.BleLog; | |||
| import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleNewBaseActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | |||
| import cn.net.aicare.modulelibrary.module.BoraTempHumidity.BarometricTempHumidityBleData; | |||
| import cn.net.aicare.modulelibrary.module.BoraTempHumidity.BleSendUtils; | |||
| /** | |||
| * @author yesp | |||
| */ | |||
| public class BarometricTempHygrometerActivity extends BleNewBaseActivity implements BarometricTempHumidityBleData.BaroTempHygrometerListener, | |||
| OnCallbackBle, BarometricTempHumidityBleData.LogInterface { | |||
| private static final String TAG = "BarometricTempHygrometerActivity"; | |||
| private BarometricTempHumidityBleData mBarometricTempHumidityBleData; | |||
| private String mAddress; | |||
| private ListView lvLogs; | |||
| private List<String> mLogList; | |||
| private ArrayAdapter<String> listAdapter; | |||
| private RecyclerView rvInstruction; | |||
| private InstructionAdapter mInstructionAdapter; | |||
| private List<String> mHistoryList; | |||
| private EditText etTime; | |||
| @Override | |||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| setContentView(R.layout.activity_barometric_temp_humidity); | |||
| initView(); | |||
| } | |||
| private void initView() { | |||
| lvLogs = findViewById(R.id.lv_log); | |||
| mLogList = new ArrayList<>(); | |||
| listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mLogList); | |||
| lvLogs.setAdapter(listAdapter); | |||
| mHistoryList = new ArrayList<>(); | |||
| rvInstruction = findViewById(R.id.rv_inst); | |||
| rvInstruction.setLayoutManager(new LinearLayoutManager(this)); | |||
| mInstructionAdapter = new InstructionAdapter(this, getInstructionList()); | |||
| rvInstruction.setAdapter(mInstructionAdapter); | |||
| mInstructionAdapter.setItemClickListener(this::sendInstruction); | |||
| etTime = findViewById(R.id.et_time); | |||
| } | |||
| public static ArrayList<InstructionBean> getInstructionList() { | |||
| ArrayList<InstructionBean> list = new ArrayList<>(); | |||
| list.add(new InstructionBean(0, "获取支持功能")); | |||
| list.add(new InstructionBean(1, "获取设备状态")); | |||
| list.add(new InstructionBean(2, "设置设备变化阀值: 1℃, 1% , 10hpa")); | |||
| list.add(new InstructionBean(3, "设置设备变化阀值: 2℃, 2% , 20hpa")); | |||
| list.add(new InstructionBean(4, "读取设备的历史数据: time - 0")); | |||
| list.add(new InstructionBean(5, "读取设备的历史数据: 自定义time")); | |||
| list.add(new InstructionBean(6, "发下一组离线数据")); | |||
| list.add(new InstructionBean(7, "离线数据接收完毕")); | |||
| list.add(new InstructionBean(8, "设置采样频率(10s),保存频率(20s), 间隔(2s)")); | |||
| list.add(new InstructionBean(9, "设置采样频率(自定义)")); | |||
| list.add(new InstructionBean(10, "读取校准值")); | |||
| list.add(new InstructionBean(11, "设置校准值: +1℃, +1% , +10hpa")); | |||
| list.add(new InstructionBean(12, "设置校准值: -1℃, -1% , -10hpa")); | |||
| list.add(new InstructionBean(13, "开始寻物")); | |||
| list.add(new InstructionBean(14, "停止寻物")); | |||
| list.add(new InstructionBean(15, "读取蜂鸣器状态")); | |||
| list.add(new InstructionBean(16, "设置蜂鸣器-开")); | |||
| list.add(new InstructionBean(17, "设置蜂鸣器-关")); | |||
| list.add(new InstructionBean(18, "绑定设备")); | |||
| return list; | |||
| } | |||
| private void sendInstruction(InstructionBean bean) { | |||
| if (bean == null || mBarometricTempHumidityBleData == null) { | |||
| return; | |||
| } | |||
| byte[] sendBytes = null; | |||
| switch (bean.getIndex()) { | |||
| case 0: | |||
| sendBytes = BleSendUtils.getSupportFunction(); | |||
| break; | |||
| case 1: | |||
| sendBytes = BleSendUtils.getDeviceStatus(); | |||
| break; | |||
| case 2: | |||
| sendBytes = BleSendUtils.setThreshold(10, 10, 10); | |||
| break; | |||
| case 3: | |||
| sendBytes = BleSendUtils.setThreshold(20, 20, 20); | |||
| break; | |||
| case 4: | |||
| sendBytes = BleSendUtils.getOfflineRecord(0); | |||
| break; | |||
| case 5: | |||
| String time = etTime.getText().toString().trim(); | |||
| if (TextUtils.isEmpty(time)) { | |||
| addLog("请在顶部输入时间"); | |||
| return; | |||
| } else { | |||
| sendBytes = BleSendUtils.getOfflineRecord(Long.parseLong(time)); | |||
| } | |||
| break; | |||
| case 6: | |||
| sendBytes = BleSendUtils.sendOfflineStatus(1); | |||
| break; | |||
| case 7: | |||
| sendBytes = BleSendUtils.sendOfflineStatus(0); | |||
| break; | |||
| case 8: | |||
| sendBytes = BleSendUtils.setFrequency(5, 10, 20); | |||
| break; | |||
| case 9: | |||
| EditParamsDialog dialog = EditParamsDialog.newInstance(); | |||
| dialog.setOnDialogListener(new EditParamsDialog.OnDialogListener() { | |||
| @Override | |||
| public void tvCancelListener(View v) { | |||
| } | |||
| @Override | |||
| public void tvSucceedListener(View v, int value1, int value2, int value3) { | |||
| byte[] sendBytesT = BleSendUtils.setFrequency(value1, value2, value3); | |||
| mBarometricTempHumidityBleData.sendDataA7(sendBytesT); | |||
| addLog(bean.getName() + ", 发送的 payload 数据:\n" + BleStrUtils.byte2HexStr(sendBytesT)); | |||
| } | |||
| }); | |||
| dialog.show(getSupportFragmentManager()); | |||
| break; | |||
| case 10: | |||
| sendBytes = BleSendUtils.getCalibration(); | |||
| break; | |||
| case 11: | |||
| sendBytes = BleSendUtils.setCalibration(10, 10, 10); | |||
| break; | |||
| case 12: | |||
| sendBytes = BleSendUtils.setCalibration(-10, -10, -10); | |||
| break; | |||
| case 13: | |||
| sendBytes = BleSendUtils.findDevice(0); | |||
| break; | |||
| case 14: | |||
| sendBytes = BleSendUtils.findDevice(1); | |||
| break; | |||
| case 15: | |||
| sendBytes = BleSendUtils.getSound(); | |||
| break; | |||
| case 16: | |||
| sendBytes = BleSendUtils.setSound(true); | |||
| break; | |||
| case 17: | |||
| sendBytes = BleSendUtils.setSound(false); | |||
| break; | |||
| case 18: | |||
| sendBytes = BleSendUtils.startBindDevice(); | |||
| break; | |||
| default: | |||
| break; | |||
| } | |||
| if (sendBytes != null) { | |||
| mBarometricTempHumidityBleData.sendDataA7(sendBytes); | |||
| addLog(bean.getName() + ", 发送的 payload 数据:\n" + BleStrUtils.byte2HexStr(sendBytes)); | |||
| } | |||
| } | |||
| @Override | |||
| public void onServiceSuccess() { | |||
| if (AILinkBleManager.getInstance() != null) { | |||
| mAddress = getIntent().getStringExtra("mac"); | |||
| AILinkBleManager.getInstance().setOnCallbackBle(this); | |||
| BleDevice bleDevice = AILinkBleManager.getInstance().getBleDevice(mAddress); | |||
| BarometricTempHumidityBleData.init(bleDevice, BleDeviceConfig.BAROMETRIC_TEMP_HUMIDITY); | |||
| mBarometricTempHumidityBleData = BarometricTempHumidityBleData.getInstance(); | |||
| mBarometricTempHumidityBleData.setBaroTempHygrometerListener(this); | |||
| mBarometricTempHumidityBleData.setLogInterface(this); | |||
| } | |||
| } | |||
| @Override | |||
| public void onDisConnected(String mac, int code) { | |||
| if (mac.equals(mAddress) && getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { | |||
| BleLog.i(TAG, "设备断开连接,请退出重新连接"); | |||
| new AlertDialog.Builder(this) | |||
| .setTitle("ERROR:") | |||
| .setMessage("\n" + "设备断开连接,请退出重新连接") | |||
| .setPositiveButton("确认", (dialog, which) -> finish()) | |||
| .show(); | |||
| } | |||
| } | |||
| private void addLog(String str) { | |||
| mLogList.add(str); | |||
| listAdapter.notifyDataSetChanged(); | |||
| lvLogs.smoothScrollToPosition(listAdapter.getCount() - 1); | |||
| } | |||
| private void addLog(List<String> strList) { | |||
| mLogList.addAll(strList); | |||
| listAdapter.notifyDataSetChanged(); | |||
| lvLogs.smoothScrollToPosition(listAdapter.getCount() - 1); | |||
| } | |||
| @Override | |||
| public void onServiceErr() { | |||
| } | |||
| @Override | |||
| public void unbindServices() { | |||
| AILinkBleManager.getInstance().disconnect(mAddress); | |||
| if (mBarometricTempHumidityBleData != null) { | |||
| mBarometricTempHumidityBleData.clear(); | |||
| mBarometricTempHumidityBleData = null; | |||
| } | |||
| } | |||
| @Override | |||
| public void onDeviceStatus(int battery, long time, int temp, int humidity, int barometric) { | |||
| addLog("当前设备状态:电量:" + battery + ", 开机时间:" + time + ", 温度:" + temp / 10f + "℃, 湿度:" + humidity / 10 + "%, 气压:" + barometric); | |||
| } | |||
| @Override | |||
| public void onFunctionList(int calibration, int buzzerAlarm, int alarmFunction, int reportPunctually, int nightLight, int bgLight, int findDevice, byte[] bytes) { | |||
| addLog("当前支持功能:气压温湿度校准:" + (calibration == 1) + | |||
| ", \n蜂鸣器报警:" + (buzzerAlarm == 1) + | |||
| ", \n闹钟功能:" + (alarmFunction == 1) + | |||
| ", \n整点报时:" + (reportPunctually == 1) + | |||
| ", \n小夜灯:" + (nightLight == 1) + | |||
| ", \n背光亮度:" + (bgLight == 1) + | |||
| ", \n寻物功能:" + (findDevice == 1)); | |||
| } | |||
| @Override | |||
| public void onOffLineRecordNum(long total, long sendNum) { | |||
| addLog("离线记录总数: " + "总数:" + total + ", 已发数量:" + sendNum); | |||
| addLog(mHistoryList); | |||
| mHistoryList.clear(); | |||
| } | |||
| @Override | |||
| public void onOffLineRecord(long time, int temp, int humidity, int barometric) { | |||
| mHistoryList.add("离线记录:" + "时间:" + time + ", 温度:" + temp / 10f + "℃, 湿度:" + humidity / 10f + "%, 气压:" + barometric + "hpa"); | |||
| } | |||
| @Override | |||
| public void onVersion(String version) { | |||
| } | |||
| @Override | |||
| public void onThreshold(int tempT, int humidityT, int barometricT) { | |||
| addLog("当前设备变化阀值:" + "温度:" + tempT / 10f + "℃, 湿度:" + humidityT / 10f + "%, 气压:" + barometricT + "hpa"); | |||
| } | |||
| @Override | |||
| public void onFrequency(int samplingFrequency, int saveFrequency, int timerInterval) { | |||
| int interval = timerInterval * 100; | |||
| addLog("当前频率:" + "采样频率:" + samplingFrequency * interval + "ms, 保存频率:" + saveFrequency * interval + "ms, 设备定时器间隔:" + interval + "ms"); | |||
| } | |||
| @Override | |||
| public void onFindDevice(int status) { | |||
| String result; | |||
| if (status == 0) { | |||
| result = "正在报警"; | |||
| } else if (status == 1) { | |||
| result = "停止报警"; | |||
| } else { | |||
| result = "未知"; | |||
| } | |||
| addLog("寻物状态:" + result); | |||
| } | |||
| @Override | |||
| public void onBuzzer(boolean isOpen) { | |||
| addLog("蜂鸣器状态:" + (isOpen ? "开" : "关")); | |||
| } | |||
| @Override | |||
| public void onCalibration(int tempCal, int humidityCal, int barometricCal) { | |||
| addLog("当前校准值:" + "温度:" + tempCal / 10f + "℃, 湿度:" + humidityCal / 10f + "%, 气压:" + barometricCal + "hpa"); | |||
| } | |||
| @Override | |||
| public void onBindStatus(boolean success) { | |||
| addLog("绑定设备结果:" + (success ? "成功" : "失败")); | |||
| } | |||
| @Override | |||
| public void onLog(byte[] bytes) { | |||
| addLog("接收到的 payload 数据:" + BleStrUtils.byte2HexStr(bytes)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,214 @@ | |||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.barometric_temp_humidity; | |||
| import android.app.Dialog; | |||
| import android.content.Context; | |||
| import android.content.DialogInterface; | |||
| import android.content.Intent; | |||
| import android.os.Bundle; | |||
| import android.view.KeyEvent; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.EditText; | |||
| import android.widget.TextView; | |||
| import android.widget.Toast; | |||
| import androidx.annotation.NonNull; | |||
| import androidx.annotation.Nullable; | |||
| import androidx.fragment.app.DialogFragment; | |||
| import androidx.fragment.app.FragmentManager; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||
| public class EditParamsDialog extends DialogFragment implements View.OnClickListener { | |||
| /** | |||
| * 是否显示 | |||
| */ | |||
| private EditText etContent1, etContent2, etContent3; | |||
| private TextView mTvCancel, mTvSucceed; | |||
| private boolean mShow; | |||
| private boolean mCancelBlank; | |||
| private Context mContext; | |||
| private OnDialogListener mOnDialogListener; | |||
| public static EditParamsDialog newInstance() { | |||
| return new EditParamsDialog(); | |||
| } | |||
| @NonNull | |||
| @Override | |||
| public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { | |||
| Dialog dialogView = new Dialog(requireContext(), R.style.MyDialog);// 创建自定义样式dialog | |||
| dialogView.setCancelable(false);//设置是否可以关闭 | |||
| dialogView.setCanceledOnTouchOutside(mCancelBlank);//设置点击空白处是否可以取消 | |||
| dialogView.setOnKeyListener((dialog, keyCode, event) -> { | |||
| if (mCancelBlank) { | |||
| return false; | |||
| } else { | |||
| //返回不关闭 | |||
| return keyCode == KeyEvent.KEYCODE_BACK; | |||
| } | |||
| }); | |||
| return dialogView; | |||
| } | |||
| @Nullable | |||
| @Override | |||
| public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||
| return inflater.inflate(R.layout.dialog_edit_params, container); | |||
| } | |||
| @Override | |||
| public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |||
| super.onViewCreated(view, savedInstanceState); | |||
| mContext = view.getContext(); | |||
| init(view); | |||
| } | |||
| @Override | |||
| public void onActivityResult(int requestCode, int resultCode, Intent data) { | |||
| super.onActivityResult(requestCode, resultCode, data); | |||
| } | |||
| private void init(View view) { | |||
| etContent1 = view.findViewById(R.id.et_context1); | |||
| etContent2 = view.findViewById(R.id.et_context2); | |||
| etContent3 = view.findViewById(R.id.et_context3); | |||
| mTvCancel = view.findViewById(R.id.tv_cancel); | |||
| mTvSucceed = view.findViewById(R.id.tv_ok); | |||
| mTvCancel.setOnClickListener(this); | |||
| mTvSucceed.setOnClickListener(this); | |||
| } | |||
| @Override | |||
| public void onClick(View v) { | |||
| int i = v.getId(); | |||
| if (i == R.id.tv_cancel) { | |||
| if (mOnDialogListener != null) { | |||
| mOnDialogListener.tvCancelListener(v); | |||
| } | |||
| dismiss(); | |||
| } else if (i == R.id.tv_ok) { | |||
| if (mOnDialogListener != null) { | |||
| String content1 = etContent1.getText().toString().trim(); | |||
| String content2 = etContent2.getText().toString().trim(); | |||
| String content3 = etContent3.getText().toString().trim(); | |||
| int value1 = 1; | |||
| int value2 = 30; | |||
| int value3 = 20; | |||
| try { | |||
| value1 = Integer.parseInt(content1); | |||
| if (value1 > 10 || value1 < 1) { | |||
| Toast.makeText(mContext, "采样频率输入有误", Toast.LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| } catch (NumberFormatException e) { | |||
| Toast.makeText(mContext, "采样频率输入有误", Toast.LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| try { | |||
| value2 = Integer.parseInt(content2); | |||
| if (value2 > 60 || value2 < 1) { | |||
| Toast.makeText(mContext, "保存频率输入有误", Toast.LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| } catch (NumberFormatException e) { | |||
| Toast.makeText(mContext, "保存频率输入有误", Toast.LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| try { | |||
| value3 = Integer.parseInt(content3); | |||
| if (value3 > 20 || value3 < 2) { | |||
| Toast.makeText(mContext, "设备定时器间隔输入有误", Toast.LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| } catch (NumberFormatException e) { | |||
| Toast.makeText(mContext, "设备定时器间隔输入有误", Toast.LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| mOnDialogListener.tvSucceedListener(v, value1, value2, value3); | |||
| } | |||
| dismiss(); | |||
| } | |||
| } | |||
| public EditParamsDialog setOnDialogListener(OnDialogListener onDialogListener) { | |||
| mOnDialogListener = onDialogListener; | |||
| return this; | |||
| } | |||
| /** | |||
| * 当前是否显示 | |||
| */ | |||
| public boolean isShow() { | |||
| return mShow; | |||
| } | |||
| @Override | |||
| public void show(@NonNull FragmentManager manager, @Nullable String tag) { | |||
| try { | |||
| if (!mShow) { | |||
| super.show(manager, tag); | |||
| mShow = true; | |||
| } | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public void show(@NonNull FragmentManager manager) { | |||
| this.show(manager, "DialogFragment"); | |||
| } | |||
| @Override | |||
| public void onDismiss(@NonNull DialogInterface dialog) { | |||
| super.onDismiss(dialog); | |||
| mShow = false; | |||
| } | |||
| @Override | |||
| public void dismiss() { | |||
| try { | |||
| mShow = false; | |||
| super.dismiss(); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public interface OnDialogListener { | |||
| /** | |||
| * 取消的点击事件 | |||
| */ | |||
| default void tvCancelListener(View v) { | |||
| } | |||
| /** | |||
| * 成功的点击事件 | |||
| */ | |||
| default void tvSucceedListener(View v, int value1, int value2, int value3) { | |||
| } | |||
| } | |||
| @Override | |||
| public void onDestroyView() { | |||
| super.onDestroyView(); | |||
| mShow = false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,93 @@ | |||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.barometric_temp_humidity; | |||
| import android.content.Context; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.TextView; | |||
| import androidx.annotation.NonNull; | |||
| import androidx.recyclerview.widget.RecyclerView; | |||
| import java.util.ArrayList; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||
| /** | |||
| * 指令 adapter | |||
| * | |||
| * @author yesp | |||
| */ | |||
| public class InstructionAdapter extends RecyclerView.Adapter<InstructionAdapter.ViewHolder> { | |||
| private Context context; | |||
| private ArrayList<InstructionBean> list; | |||
| private ItemClickListener itemClickListener; | |||
| public InstructionAdapter(Context context, ArrayList<InstructionBean> list) { | |||
| this.context = context; | |||
| this.list = list; | |||
| } | |||
| public void setList(ArrayList<InstructionBean> list) { | |||
| this.list = list; | |||
| } | |||
| public void setItemClickListener(ItemClickListener itemClickListener) { | |||
| this.itemClickListener = itemClickListener; | |||
| } | |||
| @NonNull | |||
| @Override | |||
| public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |||
| ViewHolder holder = new ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_instruction, parent, false)); | |||
| holder.itemView.setOnClickListener(v -> { | |||
| if (itemClickListener != null) { | |||
| int position = holder.getAdapterPosition(); | |||
| if (position < 0 || position >= list.size()) { | |||
| return; | |||
| } | |||
| itemClickListener.onItemClick(list.get(position)); | |||
| } | |||
| }); | |||
| return holder; | |||
| } | |||
| @Override | |||
| public void onBindViewHolder(@NonNull ViewHolder holder, int position) { | |||
| InstructionBean bean = list.get(position); | |||
| if (bean == null) { | |||
| return; | |||
| } | |||
| String content = bean.getName(); | |||
| holder.tvContent.setText(content); | |||
| } | |||
| @Override | |||
| public int getItemCount() { | |||
| return list != null ? list.size() : 0; | |||
| } | |||
| public class ViewHolder extends RecyclerView.ViewHolder { | |||
| private TextView tvContent; | |||
| public ViewHolder(@NonNull View itemView) { | |||
| super(itemView); | |||
| tvContent = itemView.findViewById(R.id.tv_content); | |||
| } | |||
| } | |||
| public interface ItemClickListener { | |||
| /** | |||
| * item 点击 | |||
| * | |||
| * @param bean bean | |||
| */ | |||
| void onItemClick(InstructionBean bean); | |||
| } | |||
| } | |||
| @@ -0,0 +1,27 @@ | |||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.barometric_temp_humidity; | |||
| public class InstructionBean { | |||
| private int index; | |||
| private String name; | |||
| public InstructionBean(int index, String name) { | |||
| this.index = index; | |||
| this.name = name; | |||
| } | |||
| public int getIndex() { | |||
| return index; | |||
| } | |||
| public void setIndex(int index) { | |||
| this.index = index; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| } | |||
| @@ -357,7 +357,7 @@ public class BroadcastWeightScaleActivity extends BleNewBaseActivity implements | |||
| int vid = bleValueBean.getVid(); | |||
| int pid = bleValueBean.getPid(); | |||
| if (mDevice != null) { | |||
| mDevice.onNotifyData(bleValueBean.getManufacturerData(), cid, vid, pid); | |||
| mDevice.onNotifyData(bleValueBean.getManufacturerData(),payload, cid, vid, pid); | |||
| } | |||
| } | |||
| } | |||
| @@ -205,7 +205,7 @@ public class MeatProbeChargerActivity extends BleBaseActivity implements View.On | |||
| */ | |||
| private void cancelDialog() { | |||
| ShowListDialogFragment.newInstance().setTitle("选择探针").setCancel("取消", 0).setCancelBlank(true).setBackground(true).setBottom(false).setList(mDialogMacList) | |||
| .setOnDialogListener(new ShowListDialogFragment.onDialogListener() { | |||
| .setOnDialogListener(new ShowListDialogFragment.onDialogListener() { | |||
| @Override | |||
| public void onItemListener(int position) { | |||
| Toast.makeText(MeatProbeChargerActivity.this, mDialogMacList.get(position).getName() + "设置该指令", Toast.LENGTH_SHORT).show(); | |||
| @@ -149,7 +149,7 @@ public class RopeSkippingSetActivity extends BleBaseActivity implements View.OnC | |||
| private void refreshLog(String content) { | |||
| if (!isPauseLog) { | |||
| content=TimeUtils.getTime(System.currentTimeMillis())+content; | |||
| content= TimeUtils.getTime(System.currentTimeMillis())+content; | |||
| logList.add( content); | |||
| mArrayAdapter.notifyDataSetChanged(); | |||
| } | |||
| @@ -295,7 +295,7 @@ public class ToothBrushWifiBleActivity extends BleBaseActivity implements View.O | |||
| if (data.equals("") || data.length() > 8) { | |||
| dataPaw = data.trim(); | |||
| mToothBrushWiFiBleUtilsData.setWifimac(wifimacMap.get(selectWifi)); | |||
| mToothBrushWiFiBleUtilsData.setWifiMac(wifimacMap.get(selectWifi)); | |||
| } else { | |||
| Toast.makeText(ToothBrushWifiBleActivity.this, "密码格式不对", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| @@ -6,6 +6,7 @@ import android.os.Handler; | |||
| import android.os.Looper; | |||
| import android.os.Message; | |||
| import android.text.TextUtils; | |||
| import android.view.View; | |||
| import android.widget.Button; | |||
| import android.widget.TextView; | |||
| @@ -105,6 +106,39 @@ public class ToothbrushTestActivity extends BleBaseActivity implements Toothbrus | |||
| recycler_view.setLayoutManager(new LinearLayoutManager(this)); | |||
| recycler_view.setAdapter(mAdapter); | |||
| mAdapter.setOnSelectListener(this); | |||
| btn_toothbrush_prevent_splash_test = findViewById(R.id.btn_toothbrush_prevent_splash_test); | |||
| btn_toothbrush_prevent_splash = findViewById(R.id.btn_toothbrush_prevent_splash); | |||
| tv_toothbrush_status = findViewById(R.id.tv_toothbrush_status); | |||
| tv_toothbrush_status.setTag(false); | |||
| btn_toothbrush_prevent_splash_test.setOnClickListener(new View.OnClickListener() { | |||
| @Override | |||
| public void onClick(View v) { | |||
| ToothBrushBleUtilsData.init(mBleDevice, new ToothBrushBleUtilsData.BleToothBrushCallback() { | |||
| @Override | |||
| public void onPreventSplash(boolean support, boolean status) { | |||
| if (tv_toothbrush_status != null) { | |||
| tv_toothbrush_status.setText("是否支持防飞溅:" + support + "\n防飞溅当前开关:" + status); | |||
| tv_toothbrush_status.setTag(status); | |||
| } | |||
| } | |||
| }); | |||
| ToothBrushBleUtilsData.getInstance().getPreventSplash(); | |||
| } | |||
| }); | |||
| btn_toothbrush_prevent_splash.setOnClickListener(new View.OnClickListener() { | |||
| @Override | |||
| public void onClick(View v) { | |||
| ToothBrushBleUtilsData instance = ToothBrushBleUtilsData.getInstance(); | |||
| if (instance != null) { | |||
| boolean status = (boolean) tv_toothbrush_status.getTag(); | |||
| instance.setPreventSplash(!status); | |||
| } | |||
| } | |||
| }); | |||
| } | |||
| @Override | |||
| @@ -0,0 +1,697 @@ | |||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.wifible_sphy; | |||
| import android.content.Context; | |||
| import android.os.Bundle; | |||
| import android.os.Handler; | |||
| import android.os.Looper; | |||
| import android.os.Message; | |||
| import android.text.TextUtils; | |||
| import android.view.View; | |||
| import android.widget.ArrayAdapter; | |||
| import android.widget.Button; | |||
| import android.widget.EditText; | |||
| import android.widget.ListView; | |||
| import android.widget.TextView; | |||
| import androidx.annotation.NonNull; | |||
| import androidx.annotation.Nullable; | |||
| import com.pingwang.bluetoothlib.config.CmdConfig; | |||
| import com.pingwang.bluetoothlib.device.BleDevice; | |||
| import com.pingwang.bluetoothlib.device.BleSendCmdUtil; | |||
| import com.pingwang.bluetoothlib.device.SendBleBean; | |||
| import com.pingwang.bluetoothlib.listener.CallbackDisIm; | |||
| import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | |||
| import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | |||
| import com.pingwang.bluetoothlib.listener.OnCallbackDis; | |||
| import com.pingwang.bluetoothlib.listener.OnMcuParameterListener; | |||
| import com.pingwang.bluetoothlib.utils.BleDensityUtil; | |||
| import com.pingwang.bluetoothlib.utils.BleLog; | |||
| import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.DialogStringImageBean; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.MoveDataDialogFragment; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.ShowListDialogFragment; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.L; | |||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||
| import cn.net.aicare.modulelibrary.module.sphygmomanometer.SphyBleConfig; | |||
| import cn.net.aicare.modulelibrary.module.sphygmomanometer.SphyWifiBleDeviceData; | |||
| import cn.net.aicare.modulelibrary.module.wifibleDevice.WifiBleDeviceData; | |||
| import cn.net.aicare.modulelibrary.module.wifibleDevice.WifiBleInfoBean; | |||
| /** | |||
| * wifi ble 血压计界面 | |||
| * | |||
| * @author xing | |||
| * @date 2023/10/07 | |||
| */ | |||
| public class WifiBleSphyActivity extends BleBaseActivity implements OnCallbackDis, OnBleVersionListener, OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener { | |||
| private static String TAG = WifiBleSphyActivity.class.getName(); | |||
| private final int REFRESH_DATA = 3; | |||
| private List<String> mList; | |||
| private ArrayAdapter listAdapter; | |||
| private TextView tv_wifi_ssid, tv_wifi_status; | |||
| private EditText et_url, et_port, et_path; | |||
| private Context mContext; | |||
| private SphyWifiBleDeviceData mSphyWifiBleDeviceData; | |||
| private WifiBleDeviceData mWifiBleDeviceData; | |||
| private List<DialogStringImageBean> mWifiList = new ArrayList<>(); | |||
| private String mAddress; | |||
| private BleSendCmdUtil mBleSendCmdUtil; | |||
| private int mType; | |||
| private int mCid; | |||
| private byte unit = 0; | |||
| private Handler mHandler = new Handler(Looper.getMainLooper()) { | |||
| @Override | |||
| public void handleMessage(Message msg) { | |||
| if (msg.what == REFRESH_DATA) { | |||
| if (listAdapter != null) | |||
| listAdapter.notifyDataSetChanged(); | |||
| } | |||
| } | |||
| }; | |||
| @Override | |||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| setContentView(R.layout.activity_sphy_wifi_ble); | |||
| mContext = this; | |||
| mAddress = getIntent().getStringExtra("mac"); | |||
| mType = getIntent().getIntExtra("type", -1); | |||
| mCid = getIntent().getIntExtra("cid", -1); | |||
| mBleSendCmdUtil = BleSendCmdUtil.getInstance(); | |||
| init(); | |||
| } | |||
| private void init() { | |||
| mList = new ArrayList<>(); | |||
| ListView listView = findViewById(R.id.listview); | |||
| listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||
| listView.setAdapter(listAdapter); | |||
| Button clear = findViewById(R.id.clear); | |||
| clear.setOnClickListener(new View.OnClickListener() { | |||
| @Override | |||
| public void onClick(View v) { | |||
| if (mList != null) | |||
| mList.clear(); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| }); | |||
| tv_wifi_ssid = findViewById(R.id.tv_wifi_ssid); | |||
| tv_wifi_status = findViewById(R.id.tv_wifi_status); | |||
| et_url = findViewById(R.id.et_url); | |||
| et_port = findViewById(R.id.et_port); | |||
| et_path = findViewById(R.id.et_path); | |||
| findViewById(R.id.btnVersion).setOnClickListener(this); | |||
| findViewById(R.id.btnBattery).setOnClickListener(this); | |||
| findViewById(R.id.btn_get_did).setOnClickListener(this); | |||
| findViewById(R.id.btn_voice).setOnClickListener(this); | |||
| findViewById(R.id.clear).setOnClickListener(this); | |||
| findViewById(R.id.btn_wifi).setOnClickListener(this); | |||
| findViewById(R.id.btn_config).setOnClickListener(this); | |||
| findViewById(R.id.btn_read_config).setOnClickListener(this); | |||
| findViewById(R.id.btn_read_wifi_status).setOnClickListener(this); | |||
| cmdBtn(); | |||
| } | |||
| private void cmdBtn() { | |||
| Button btn_set_unit = findViewById(R.id.btn_set_unit); | |||
| btn_set_unit.setOnClickListener(new View.OnClickListener() { | |||
| @Override | |||
| public void onClick(View v) { | |||
| if (unit == SphyBleConfig.SPHY_UNIT_MMHG) { | |||
| unit = SphyBleConfig.SPHY_UNIT_KPA; | |||
| mSphyWifiBleDeviceData.setUnit(unit); | |||
| } else { | |||
| unit = SphyBleConfig.SPHY_UNIT_MMHG; | |||
| mSphyWifiBleDeviceData.setUnit(unit); | |||
| } | |||
| } | |||
| }); | |||
| Button btn_start = findViewById(R.id.btn_start); | |||
| btn_start.setOnClickListener(new View.OnClickListener() { | |||
| @Override | |||
| public void onClick(View v) { | |||
| mSphyWifiBleDeviceData.startMeasuring(); | |||
| } | |||
| }); | |||
| Button btn_stop = findViewById(R.id.btn_stop); | |||
| btn_stop.setOnClickListener(new View.OnClickListener() { | |||
| @Override | |||
| public void onClick(View v) { | |||
| mSphyWifiBleDeviceData.stopMeasuring(); | |||
| } | |||
| }); | |||
| } | |||
| private int mVoiceStatus = 0; | |||
| @Override | |||
| public void onClick(View v) { | |||
| SendBleBean sendBleBean = new SendBleBean(); | |||
| switch (v.getId()) { | |||
| case R.id.btnVersion: | |||
| sendBleBean.setHex(mBleSendCmdUtil.getBleVersion()); | |||
| mSphyWifiBleDeviceData.sendData(sendBleBean); | |||
| break; | |||
| case R.id.btnBattery: | |||
| sendBleBean.setHex(mBleSendCmdUtil.getMcuBatteryStatus()); | |||
| mSphyWifiBleDeviceData.sendData(sendBleBean); | |||
| break; | |||
| case R.id.btn_get_did: | |||
| sendBleBean.setHex(mBleSendCmdUtil.getDid()); | |||
| mSphyWifiBleDeviceData.sendData(sendBleBean); | |||
| break; | |||
| case R.id.btn_voice: | |||
| if (mVoiceStatus == 0) { | |||
| mVoiceStatus = 1; | |||
| } else { | |||
| mVoiceStatus = 0; | |||
| } | |||
| mSphyWifiBleDeviceData.setSphyVoice(mVoiceStatus); | |||
| break; | |||
| case R.id.clear: | |||
| if (mList != null) | |||
| mList.clear(); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| break; | |||
| case R.id.btn_config: | |||
| String ip = et_url.getText().toString().trim(); | |||
| String port = et_port.getText().toString().trim(); | |||
| String path = et_path.getText().toString().trim(); | |||
| if (ip.length() == 0 || port.length() == 0) { | |||
| mList.add(TimeUtils.getTime() + "配置失败:ip或端口为空"); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| return; | |||
| } | |||
| setServiceInfo(ip, Integer.parseInt(port), path); | |||
| mList.add(TimeUtils.getTime() + "配置服务器信息中..."); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| break; | |||
| case R.id.btn_read_config: | |||
| getWifiConnectInfo(); | |||
| break; | |||
| case R.id.btn_read_wifi_status: | |||
| if (mWifiBleDeviceData != null) { | |||
| mWifiBleDeviceData.getWifiCurrentState(); | |||
| } | |||
| break; | |||
| case R.id.btn_wifi: | |||
| if (mWifiBleDeviceData != null) { | |||
| mWifiBleDeviceData.getWifiList(); | |||
| mList.add(TimeUtils.getTime() + "正在扫描附近可用的wifi..."); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| showWifiList(); | |||
| break; | |||
| default: | |||
| break; | |||
| } | |||
| } | |||
| /** | |||
| * 获取wifi连接信息 | |||
| */ | |||
| public void getWifiConnectInfo() { | |||
| if (mWifiBleDeviceData != null) { | |||
| mWifiBleDeviceData.getIp(); | |||
| mWifiBleDeviceData.getPort(); | |||
| mWifiBleDeviceData.getPath(); | |||
| mWifiBleDeviceData.getDeviceSn(); | |||
| } | |||
| } | |||
| /** | |||
| * 设置服务信息 | |||
| * | |||
| * @param ip 知识产权 | |||
| * @param port 港口 | |||
| * @param path 路径 | |||
| */ | |||
| public void setServiceInfo(String ip, int port, String path) { | |||
| if (mWifiBleDeviceData != null) { | |||
| mWifiBleDeviceData.setServiceInfo(ip, port, path); | |||
| } | |||
| } | |||
| private ShowListDialogFragment mShowListDialogFragment; | |||
| private void showWifiList() { | |||
| if (mShowListDialogFragment == null) { | |||
| mShowListDialogFragment = ShowListDialogFragment.newInstance(); | |||
| mShowListDialogFragment.setList(mWifiList); | |||
| mShowListDialogFragment.setTitle("选择WIFI"); | |||
| mShowListDialogFragment.setCancel("取消", 0); | |||
| mShowListDialogFragment.setOnDialogListener(new ShowListDialogFragment.onDialogListener() { | |||
| @Override | |||
| public void onItemListener(int position) { | |||
| WifiBleInfoBean wifiBleInfoBean = mWifiBleInfoBeanList.get(position); | |||
| String ssid = wifiBleInfoBean.getSsid(); | |||
| MoveDataDialogFragment.newInstance() | |||
| .setTitle(ssid, "") | |||
| .setContent("", "请输入密码", MoveDataDialogFragment.NAME) | |||
| .setOk("OK", 0) | |||
| .setCancel("取消", 0) | |||
| .setOnDialogListener(new MoveDataDialogFragment.OnDialogListener() { | |||
| @Override | |||
| public void onSucceedListener(View v, String data) { | |||
| String pwd = data.trim(); | |||
| setConnectWifi(wifiBleInfoBean.getMac(), pwd); | |||
| } | |||
| }) | |||
| .show(getSupportFragmentManager()); | |||
| } | |||
| @Override | |||
| public void onCancelListener(View v) { | |||
| } | |||
| }); | |||
| } | |||
| mShowListDialogFragment.show(getSupportFragmentManager()); | |||
| } | |||
| //-------------------BLE send--------------- | |||
| /** | |||
| * 设置连接wifi | |||
| * | |||
| * @param mac mac | |||
| * @param pwd 密码 | |||
| */ | |||
| private void setConnectWifi(String mac, String pwd) { | |||
| if (mWifiBleDeviceData != null) { | |||
| mWifiBleDeviceData.setConnectWifiMac(mac, pwd); | |||
| mList.add(TimeUtils.getTime() + "正在连接wifi..."); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| } | |||
| //---------------------------------服务--------------------------------------------------- | |||
| @Override | |||
| public void onServiceSuccess() { | |||
| CallbackDisIm.getInstance().addListListener(this); | |||
| BleLog.i(TAG, "服务与界面建立连接成功"); | |||
| //与服务建立连接 | |||
| if (mBluetoothService != null) { | |||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||
| if (bleDevice != null) { | |||
| mSphyWifiBleDeviceData = SphyWifiBleDeviceData.getInstance(bleDevice); | |||
| mWifiBleDeviceData = mSphyWifiBleDeviceData.getWifiBleDeviceData(); | |||
| mWifiBleDeviceData.setOnWiFiBleCallback(new WifiBleDeviceListener()); | |||
| mSphyWifiBleDeviceData.setType(mCid); | |||
| mSphyWifiBleDeviceData.setOnNotifyData(new NotifyData()); | |||
| mSphyWifiBleDeviceData.setOnBleVersionListener(WifiBleSphyActivity.this); | |||
| mSphyWifiBleDeviceData.setOnMcuParameterListener(WifiBleSphyActivity.this); | |||
| mSphyWifiBleDeviceData.setOnCompanyListener(WifiBleSphyActivity.this); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public void onServiceErr() { | |||
| BleLog.i(TAG, "服务与界面连接断开"); | |||
| //与服务断开连接 | |||
| mBluetoothService = null; | |||
| } | |||
| @Override | |||
| public void unbindServices() { | |||
| CallbackDisIm.getInstance().removeListener(this); | |||
| if (mSphyWifiBleDeviceData != null) { | |||
| mSphyWifiBleDeviceData.disconnect(); | |||
| mSphyWifiBleDeviceData.clear(); | |||
| mSphyWifiBleDeviceData = null; | |||
| } | |||
| } | |||
| //-----------------状态------------------- | |||
| @Override | |||
| public void onConnecting(@NonNull String mac) { | |||
| //TODO 连接中 | |||
| if (mAddress.equals(mac)) { | |||
| BleLog.i(TAG, "连接中"); | |||
| } | |||
| } | |||
| @Override | |||
| public void onDisConnected(@NonNull String mac, int code) { | |||
| //TODO 连接断开 | |||
| if (mAddress.equals(mac)) { | |||
| BleLog.i(TAG, "连接断开"); | |||
| finish(); | |||
| } | |||
| } | |||
| @Override | |||
| public void onServicesDiscovered(@NonNull String mac) { | |||
| //TODO 连接成功(获取服务成功) | |||
| if (mAddress.equals(mac)) | |||
| BleLog.i(TAG, "连接成功(获取服务成功)"); | |||
| } | |||
| @Override | |||
| public void bleOpen() { | |||
| } | |||
| @Override | |||
| public void bleClose() { | |||
| BleLog.i(TAG, "蓝牙未开启,可请求开启"); | |||
| finish(); | |||
| } | |||
| //-----------------通知------------------- | |||
| private class NotifyData implements SphyWifiBleDeviceData.onNotifyData { | |||
| @Override | |||
| public void onData(byte[] status, int type) { | |||
| String data = ""; | |||
| if (status != null) | |||
| data = BleStrUtils.byte2HexStr(status); | |||
| if (type == 100) { | |||
| mList.add(TimeUtils.getTime() + "send->" + data); | |||
| } else { | |||
| mList.add(TimeUtils.getTime() + "notify->" + data); | |||
| } | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onSphyCmd(byte cmd) { | |||
| String cmdStr = ""; | |||
| switch (cmd) { | |||
| case SphyBleConfig.SHPY_CMD_START: | |||
| cmdStr += "开始测量"; | |||
| break; | |||
| case SphyBleConfig.SHPY_CMD_STOP: | |||
| cmdStr += "停止测试"; | |||
| break; | |||
| case SphyBleConfig.SHPY_CMD_MCU_START: | |||
| cmdStr += "mcu 开机"; | |||
| break; | |||
| case SphyBleConfig.SHPY_CMD_MCU_STOP: | |||
| cmdStr += "mcu 关机"; | |||
| break; | |||
| } | |||
| mList.add(TimeUtils.getTime() + "指令:" + cmdStr); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onSphyVoice(byte cmd) { | |||
| String cmdStr = ""; | |||
| switch (cmd) { | |||
| case 0x00: | |||
| cmdStr += "打开语音"; | |||
| break; | |||
| case 0x01: | |||
| cmdStr += "关闭语音"; | |||
| break; | |||
| } | |||
| mList.add(TimeUtils.getTime() + "指令:" + cmdStr); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onSphyDataNow(int dia, int sys, int decimal, int pul, int unit) { | |||
| String diaStr = BleDensityUtil.getInstance().holdDecimals(dia, decimal); | |||
| String sysStr = BleDensityUtil.getInstance().holdDecimals(sys, decimal); | |||
| mList.add(TimeUtils.getTime() + "实时:舒张压=" + diaStr + " 收缩压=" + sysStr + " 心率=" + pul + " 单位=" + (unit == 0 ? "mmhg" : "kPa")); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onSphyData(int dia, int sys, int decimal, int pul, int unit) { | |||
| String diaStr = BleDensityUtil.getInstance().holdDecimals(dia, decimal); | |||
| String sysStr = BleDensityUtil.getInstance().holdDecimals(sys, decimal); | |||
| mList.add(TimeUtils.getTime() + "稳定:舒张压=" + diaStr + " 收缩压=" + sysStr + " 心率=" + pul + " 单位=" + (unit == 0 ? "mmhg" : "kPa")); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onUnit(int unit) { | |||
| String showData = ""; | |||
| switch (unit) { | |||
| case CmdConfig.SETTING_SUCCESS: | |||
| showData = "设置单位成功"; | |||
| break; | |||
| case CmdConfig.SETTING_FAILURE: | |||
| showData = "设置单位失败"; | |||
| break; | |||
| case CmdConfig.SETTING_ERR: | |||
| showData = "设置单位错误"; | |||
| break; | |||
| } | |||
| mList.add(TimeUtils.getTime() + showData); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onErr(byte status) { | |||
| String errStr = ""; | |||
| switch ((int) status) { | |||
| case 0: | |||
| errStr += "未找到高压"; | |||
| break; | |||
| case 1: | |||
| errStr += "无法正常加压,请检查是否插入袖带,或者重新插拔袖带气 管"; | |||
| break; | |||
| case 2: | |||
| errStr += "电量低"; | |||
| break; | |||
| case 3: | |||
| errStr += "传感器信号异常"; | |||
| break; | |||
| case 4: | |||
| errStr += "测量结果异常"; | |||
| break; | |||
| case 5: | |||
| errStr += "腕带过紧或气路堵塞"; | |||
| break; | |||
| case 60: | |||
| errStr += "测量中压力干扰严重"; | |||
| break; | |||
| case 7: | |||
| errStr += "压力超 290"; | |||
| break; | |||
| case 8: | |||
| errStr += "标定数据异常或存储 IC 异常"; | |||
| break; | |||
| } | |||
| mList.add(TimeUtils.getTime() + "错误:" + errStr); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| } | |||
| private List<WifiBleInfoBean> mWifiBleInfoBeanList; | |||
| private class WifiBleDeviceListener implements WifiBleDeviceData.OnWiFiBleCallback { | |||
| /** | |||
| * 在ble和wifi状态 | |||
| * | |||
| * @param bleStatus ble状态 | |||
| * @param wifiStatus wifi状态 | |||
| * @param workStatus 工作状态 | |||
| */ | |||
| @Override | |||
| public void onBleAndWifiStatus(int bleStatus, int wifiStatus, int workStatus) { | |||
| String wifiStatusStr = ""; | |||
| switch (wifiStatus) { | |||
| case 0: | |||
| wifiStatusStr = "未配置AP"; | |||
| break; | |||
| case 1: | |||
| wifiStatusStr = "连接AP失败"; | |||
| break; | |||
| case 2: | |||
| wifiStatusStr = "连接的AP信号不好"; | |||
| break; | |||
| case 3: | |||
| wifiStatusStr = "成功连接上AP"; | |||
| break; | |||
| case 4: | |||
| wifiStatusStr = "正在连接AP"; | |||
| break; | |||
| } | |||
| mList.add("蓝牙状态:" + bleStatus + "\nwifi状态:" + wifiStatusStr + "\n工作状态:" + workStatus); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| if (tv_wifi_status != null) { | |||
| tv_wifi_status.setText(wifiStatusStr); | |||
| } | |||
| } | |||
| @Override | |||
| public void onWifiScanStatus(int status) { | |||
| } | |||
| @Override | |||
| public void onConnectWifiName(String name) { | |||
| if (tv_wifi_ssid != null) { | |||
| tv_wifi_ssid.setText(name); | |||
| } | |||
| } | |||
| @Override | |||
| public void onWifiScanBean(WifiBleInfoBean wifiBleInfoBean) { | |||
| L.i("扫描到的wifi信息:" + wifiBleInfoBean.toString()); | |||
| } | |||
| @Override | |||
| public void onWifiScanFinish(List<WifiBleInfoBean> list) { | |||
| if (mWifiBleInfoBeanList == null) { | |||
| mWifiBleInfoBeanList = new ArrayList<>(); | |||
| } | |||
| mWifiBleInfoBeanList.clear(); | |||
| mWifiList.clear(); | |||
| for (WifiBleInfoBean wifiBleInfoBean : list) { | |||
| String ssid = wifiBleInfoBean.getSsid(); | |||
| if (TextUtils.isEmpty(ssid)) { | |||
| continue; | |||
| } | |||
| mWifiList.add(new DialogStringImageBean(ssid, wifiBleInfoBean.getType())); | |||
| mWifiBleInfoBeanList.add(wifiBleInfoBean); | |||
| } | |||
| if (mShowListDialogFragment != null) { | |||
| mShowListDialogFragment.setList(mWifiList); | |||
| } | |||
| } | |||
| /** | |||
| * 设置wifi名字或密码的状态回调 | |||
| * | |||
| * @param type 类型 | |||
| * @param status 状态 | |||
| */ | |||
| @Override | |||
| public void onSetWifiNameOrPwdOrConnectCallback(int type, int status) { | |||
| } | |||
| @Override | |||
| public void onWifiConnecting(int status) { | |||
| L.i("wifi正在连接中:" + status); | |||
| mList.add("wifi正在连接中..."); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| /** | |||
| * 当前连接的wifi mac地址 | |||
| * | |||
| * @param mac mac | |||
| */ | |||
| @Override | |||
| public void onConnectWifiMac(String mac) { | |||
| } | |||
| @Override | |||
| public void onDeviceSn(String sn) { | |||
| //主要用于查询设备是否在服务器注册成功 | |||
| mList.add("设备SN号:" + sn); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onServerIp(String ip) { | |||
| mList.add("设备ip地址:" + ip); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onServerPort(int port) { | |||
| mList.add("设备端口:" + port); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onServerPath(String path) { | |||
| mList.add("设备路径地址:" + path); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onServerSettingInfo(boolean status) { | |||
| mList.add("服务器配置:" + (status?"成功":"失败")); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| } | |||
| @Override | |||
| public void onBmVersion(String version) { | |||
| mList.add(TimeUtils.getTime() + "版本号:" + version); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void OnDID(int cid, int vid, int pid) { | |||
| String didStr = "cid:" + cid + "||vid:" + vid + "||pid:" + pid; | |||
| mList.add(TimeUtils.getTime() + "ID:" + didStr); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onMcuBatteryStatus(int status, int battery) { | |||
| mList.add(TimeUtils.getTime() + "电量:" + battery + "%"); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| public void onSysTime(int status, int[] times) { | |||
| String time = times[0] + "-" + times[1] + "-" + times[2] + " " + times[3] + ":" + times[4] + ":" + times[5]; | |||
| mList.add(TimeUtils.getTime() + "系统时间:" + time); | |||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||
| } | |||
| @Override | |||
| protected void onDestroy() { | |||
| super.onDestroy(); | |||
| BleLog.i(TAG, "onDestroy"); | |||
| } | |||
| } | |||
| @@ -21,10 +21,11 @@ public class MyBleStrUtils { | |||
| for (byte aB : b) { | |||
| int a = aB & 0XFF; | |||
| stmp = getHexString(a); | |||
| if (stmp.length() == 1) | |||
| if (stmp.length() == 1) { | |||
| hs.append("0").append(stmp); | |||
| else | |||
| } else { | |||
| hs.append(stmp); | |||
| } | |||
| hs.append(" "); | |||
| } | |||
| return hs.toString(); | |||
| @@ -18,7 +18,7 @@ | |||
| android:layout_margin="16dp" | |||
| android:text="开始\n测试" | |||
| android:textSize="18dp" | |||
| android:textColor="@color/public_white" | |||
| android:textColor="@color/white" | |||
| android:background="@drawable/ic_round" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| app:layout_constraintEnd_toEndOf="parent" /> | |||
| @@ -0,0 +1,85 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent"> | |||
| <TextView | |||
| android:id="@+id/tv_ins" | |||
| android:layout_width="0dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="16dp" | |||
| android:layout_marginTop="8dp" | |||
| android:gravity="center" | |||
| android:text="请选择指令" | |||
| android:textColor="@color/colorAccent" | |||
| android:textSize="16dp" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <TextView | |||
| android:id="@+id/tv_time" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="16dp" | |||
| android:layout_marginTop="8dp" | |||
| android:gravity="center" | |||
| android:text="开机时间(读取历史记录):" | |||
| android:textColor="@color/colorAccent" | |||
| android:textSize="16dp" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toBottomOf="@id/tv_ins" /> | |||
| <EditText | |||
| android:id="@+id/et_time" | |||
| android:layout_width="0dp" | |||
| android:layout_height="wrap_content" | |||
| android:inputType="number" | |||
| android:hint="自定义time" | |||
| app:layout_constraintBottom_toBottomOf="@id/tv_time" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintTop_toTopOf="@id/tv_time" | |||
| app:layout_constraintStart_toEndOf="@id/tv_time" /> | |||
| <androidx.recyclerview.widget.RecyclerView | |||
| android:id="@+id/rv_inst" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="0dp" | |||
| android:layout_marginTop="8dp" | |||
| android:layout_marginBottom="4dp" | |||
| app:layout_constraintBottom_toTopOf="@id/mid_driver" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toBottomOf="@id/tv_time" /> | |||
| <View | |||
| android:id="@+id/mid_driver" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="1dp" | |||
| android:background="@color/black" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <TextView | |||
| android:id="@+id/tv_logs" | |||
| android:layout_width="0dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="16dp" | |||
| android:layout_marginTop="8dp" | |||
| android:gravity="center" | |||
| android:text="log:" | |||
| android:textColor="@color/colorAccent" | |||
| android:textSize="16dp" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toBottomOf="@id/mid_driver" /> | |||
| <ListView | |||
| android:id="@+id/lv_log" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="0dp" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toBottomOf="@id/tv_logs" /> | |||
| </androidx.constraintlayout.widget.ConstraintLayout> | |||
| @@ -78,8 +78,13 @@ | |||
| android:id="@+id/btn_sphy" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="血压计" /> | |||
| android:text="BLE血压计" /> | |||
| <Button | |||
| android:id="@+id/btn_sphy_wifi_ble" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="wifi血压计" /> | |||
| <Button | |||
| android:id="@+id/btn_tempgun" | |||
| android:layout_width="wrap_content" | |||
| @@ -92,11 +97,7 @@ | |||
| android:layout_height="wrap_content" | |||
| android:text="体温计" /> | |||
| <Button | |||
| android:id="@+id/btn_baby" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="婴儿秤" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| @@ -110,7 +111,12 @@ | |||
| android:layout_height="wrap_content" | |||
| android:text="身高仪" /> | |||
| <Button | |||
| android:id="@+id/btn_lock" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:visibility="gone" | |||
| android:text="电子锁" /> | |||
| <Button | |||
| @@ -124,7 +130,11 @@ | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="口罩" /> | |||
| <Button | |||
| android:id="@+id/btn_baby" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="婴儿秤" /> | |||
| </LinearLayout> | |||
| @@ -142,7 +152,7 @@ | |||
| android:id="@+id/btn_broadcast_scale" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="广播体脂秤" /> | |||
| android:text="广播秤" /> | |||
| <Button | |||
| android:id="@+id/btn_broadcast_blood_oxygen" | |||
| @@ -476,7 +486,19 @@ | |||
| android:id="@+id/btn_weight_scale" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="连接体重秤"/> | |||
| android:text="体重秤"/> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content"> | |||
| <Button | |||
| android:id="@+id/btn_barometric_temp_humidity" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="气压温湿度计" /> | |||
| </LinearLayout> | |||
| @@ -1,24 +1,21 @@ | |||
| <?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="vertical" | |||
| android:focusable="true" | |||
| android:focusableInTouchMode="true" | |||
| > | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:focusable="true" | |||
| android:focusableInTouchMode="true" | |||
| android:orientation="vertical"> | |||
| <ScrollView | |||
| android:layout_width="match_parent" | |||
| android:layout_height="0dp" | |||
| android:layout_weight="1" | |||
| > | |||
| android:layout_weight="1"> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="vertical" | |||
| > | |||
| android:orientation="vertical"> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| @@ -26,13 +23,11 @@ | |||
| android:padding="10dp"> | |||
| <Button | |||
| android:id="@+id/clear" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="清空" | |||
| /> | |||
| android:text="清空" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| @@ -44,31 +39,29 @@ | |||
| android:id="@+id/btn_set_unit" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="set_unit" | |||
| /> | |||
| android:text="set_unit" /> | |||
| <Button | |||
| android:id="@+id/btn_start" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="start" | |||
| /> | |||
| android:text="start" /> | |||
| <Button | |||
| android:id="@+id/btn_stop" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="stop" | |||
| /> | |||
| android:text="stop" /> | |||
| <Button | |||
| android:id="@+id/btn_voice" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="voice" | |||
| /> | |||
| android:text="voice" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| @@ -78,15 +71,13 @@ | |||
| android:id="@+id/btn_get_did" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="get_did" | |||
| /> | |||
| android:text="get_did" /> | |||
| <Button | |||
| android:id="@+id/btnVersion" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="version" | |||
| /> | |||
| android:text="version" /> | |||
| <Button | |||
| android:id="@+id/btnBattery" | |||
| @@ -107,8 +98,7 @@ | |||
| android:layout_weight="2" | |||
| android:padding="10dp" | |||
| android:stackFromBottom="true" | |||
| android:transcriptMode="alwaysScroll" | |||
| > | |||
| android:transcriptMode="alwaysScroll"> | |||
| </ListView> | |||
| @@ -0,0 +1,249 @@ | |||
| <?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:focusable="true" | |||
| android:focusableInTouchMode="true" | |||
| android:orientation="vertical"> | |||
| <ScrollView | |||
| android:layout_width="match_parent" | |||
| android:layout_height="0dp" | |||
| android:layout_weight="3"> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="10dp" | |||
| android:orientation="vertical"> | |||
| <androidx.constraintlayout.widget.ConstraintLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="10dp" | |||
| android:layout_marginEnd="10dp"> | |||
| <TextView | |||
| android:id="@+id/tv_wifi_title" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="WIFI:" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <TextView | |||
| android:id="@+id/tv_wifi_ssid" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| app:layout_constraintStart_toEndOf="@id/tv_wifi_title" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <TextView | |||
| android:id="@+id/tv_wifi_status" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| app:layout_constraintStart_toEndOf="@id/tv_wifi_title" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <Button | |||
| android:id="@+id/btn_wifi" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="配网" | |||
| app:layout_constraintEnd_toStartOf="@id/btn_read_wifi_status" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <Button | |||
| android:id="@+id/btn_read_wifi_status" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="读状态" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| </androidx.constraintlayout.widget.ConstraintLayout> | |||
| <View | |||
| android:layout_width="match_parent" | |||
| android:layout_height="0.1dp" | |||
| android:layout_marginTop="5dp" | |||
| android:layout_marginBottom="5dp" | |||
| android:background="#000000" /> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="10dp" | |||
| android:layout_marginEnd="10dp" | |||
| android:orientation="horizontal"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="URL(IP):" /> | |||
| <EditText | |||
| android:id="@+id/et_url" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:text="ailink.iot.aicare.net.cn" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="10dp" | |||
| android:layout_marginEnd="10dp" | |||
| android:orientation="horizontal"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="Port:" /> | |||
| <EditText | |||
| android:id="@+id/et_port" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:inputType="number" | |||
| android:text="80" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="10dp" | |||
| android:layout_marginEnd="10dp" | |||
| android:orientation="horizontal"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="Path:" /> | |||
| <EditText | |||
| android:id="@+id/et_path" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="10dp" | |||
| android:layout_marginEnd="10dp" | |||
| android:orientation="horizontal"> | |||
| <Button | |||
| android:id="@+id/btn_config" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="配置信息" /> | |||
| <Button | |||
| android:id="@+id/btn_read_config" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="读取信息" /> | |||
| </LinearLayout> | |||
| <View | |||
| android:layout_width="match_parent" | |||
| android:layout_height="0.1dp" | |||
| android:layout_marginTop="5dp" | |||
| android:layout_marginBottom="5dp" | |||
| android:background="#000000" /> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="1dp" | |||
| android:padding="10dp"> | |||
| <Button | |||
| android:id="@+id/btn_set_unit" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="set_unit" /> | |||
| <Button | |||
| android:id="@+id/btn_start" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="start" /> | |||
| <Button | |||
| android:id="@+id/btn_stop" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="stop" /> | |||
| <Button | |||
| android:id="@+id/btn_voice" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="voice" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:padding="10dp"> | |||
| <Button | |||
| android:id="@+id/btn_get_did" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="get_did" /> | |||
| <Button | |||
| android:id="@+id/btnVersion" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="version" /> | |||
| <Button | |||
| android:id="@+id/btnBattery" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="Battery" /> | |||
| </LinearLayout> | |||
| </LinearLayout> | |||
| </ScrollView> | |||
| <Button | |||
| android:id="@+id/clear" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginStart="10dp" | |||
| android:text="清空" /> | |||
| <ListView | |||
| android:id="@+id/listview" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="0dp" | |||
| android:layout_weight="2" | |||
| android:padding="10dp" | |||
| android:stackFromBottom="true" | |||
| android:transcriptMode="alwaysScroll"> | |||
| </ListView> | |||
| </LinearLayout> | |||
| @@ -46,7 +46,7 @@ | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:digits="0123456789ABCDEFabcdef" | |||
| android:hint="输入payload数据" /> | |||
| android:hint="输入payload数据(16进制)" /> | |||
| <Button | |||
| android:id="@+id/send" | |||
| @@ -68,7 +68,7 @@ | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:digits="0123456789ABCDEFabcdef" | |||
| android:hint="输入payload数据" /> | |||
| android:hint="输入payload数据(16进制)" /> | |||
| <Button | |||
| android:id="@+id/send_a6" | |||
| @@ -89,7 +89,7 @@ | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:digits="0123456789ABCDEFabcdef" | |||
| android:hint="输入完整的指令" | |||
| android:hint="输入完整的指令(16进制)" | |||
| android:textColorHint="@color/colorAccent" /> | |||
| <Button | |||
| @@ -1,10 +1,10 @@ | |||
| <?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:background="@drawable/bg_btn_white_dialog" | |||
| android:orientation="vertical"> | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:background="@drawable/bg_btn_white_dialog" | |||
| android:orientation="vertical"> | |||
| <TextView | |||
| @@ -15,19 +15,40 @@ | |||
| android:padding="10dp" | |||
| android:text="请选择" | |||
| android:textColor="@android:color/black" | |||
| android:textSize="16dp"/> | |||
| android:textSize="16dp" /> | |||
| <androidx.recyclerview.widget.RecyclerView | |||
| android:id="@+id/rv_dialog_list" | |||
| <androidx.constraintlayout.widget.ConstraintLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:overScrollMode="never" | |||
| android:scrollbars="none"/> | |||
| android:layout_height="wrap_content"> | |||
| <androidx.recyclerview.widget.RecyclerView | |||
| android:id="@+id/rv_dialog_list" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="200dp" | |||
| android:overScrollMode="never" | |||
| android:padding="5dp" | |||
| android:scrollbars="none" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <TextView | |||
| android:id="@+id/tv_dialog_list_data_hint" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="200dp" | |||
| android:gravity="center" | |||
| android:text="加载中..." | |||
| android:textSize="20dp" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| </androidx.constraintlayout.widget.ConstraintLayout> | |||
| <View | |||
| android:layout_width="match_parent" | |||
| android:layout_height="1px" | |||
| android:background="@android:color/black"/> | |||
| android:background="@android:color/black" /> | |||
| <TextView | |||
| android:id="@+id/tv_dialog_photo_cancel" | |||
| @@ -36,8 +57,7 @@ | |||
| android:gravity="center" | |||
| android:padding="10dp" | |||
| android:text="取消" | |||
| android:textColor="@android:color/black" | |||
| /> | |||
| android:textColor="@android:color/black" /> | |||
| </LinearLayout> | |||
| @@ -1,9 +1,9 @@ | |||
| <?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:background="#ffffff" | |||
| android:orientation="vertical"> | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:background="#ffffff" | |||
| android:orientation="vertical"> | |||
| <TextView | |||
| @@ -18,7 +18,7 @@ | |||
| android:textSize="20dp" | |||
| /> | |||
| /> | |||
| <TextView | |||
| @@ -28,60 +28,56 @@ | |||
| android:layout_marginTop="10dp" | |||
| android:gravity="center" | |||
| android:padding="10dp" | |||
| android:text="title_2" | |||
| android:text="" | |||
| android:textColor="#000000" | |||
| android:textSize="18dp" | |||
| /> | |||
| /> | |||
| <EditText | |||
| android:id="@+id/et_move_data_context" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginEnd="25dp" | |||
| android:layout_marginStart="25dp" | |||
| android:layout_marginTop="20dp" | |||
| android:layout_marginEnd="25dp" | |||
| android:focusable="true" | |||
| android:padding="8dp" | |||
| android:singleLine="true" | |||
| android:textColor="#000000" | |||
| android:textSize="18dp" | |||
| android:focusable="true" | |||
| /> | |||
| <TextView | |||
| android:id="@+id/tv_move_data_ok" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginEnd="25dp" | |||
| android:layout_marginStart="25dp" | |||
| android:layout_marginTop="40dp" | |||
| android:layout_marginEnd="25dp" | |||
| android:background="#2878ce" | |||
| android:gravity="center" | |||
| android:padding="10dp" | |||
| android:text="确认" | |||
| android:textColor="#ffffff" | |||
| android:textSize="18dp" | |||
| /> | |||
| android:textSize="18dp" /> | |||
| <TextView | |||
| android:id="@+id/tv_move_data_cancel" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginEnd="25dp" | |||
| android:layout_marginStart="25dp" | |||
| android:layout_marginTop="10dp" | |||
| android:layout_marginEnd="25dp" | |||
| android:gravity="center" | |||
| android:padding="10dp" | |||
| android:text="取消" | |||
| android:textSize="15dp" | |||
| /> | |||
| android:textSize="15dp" /> | |||
| <View | |||
| android:layout_width="match_parent" | |||
| android:layout_height="20dp"/> | |||
| android:layout_height="20dp" /> | |||
| </LinearLayout> | |||
| @@ -0,0 +1,24 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.cardview.widget.CardView 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="wrap_content" | |||
| android:layout_marginBottom="12dp" | |||
| app:cardBackgroundColor="@android:color/holo_blue_dark" | |||
| app:cardCornerRadius="8dp" | |||
| app:cardElevation="0dp" | |||
| android:layout_marginStart="24dp" | |||
| android:layout_marginEnd="24dp" | |||
| app:contentPadding="8dp"> | |||
| <TextView | |||
| android:id="@+id/tv_content" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:gravity="center" | |||
| android:paddingStart="8dp" | |||
| android:paddingEnd="8dp" | |||
| android:textColor="@android:color/white" | |||
| android:textSize="18dp" /> | |||
| </androidx.cardview.widget.CardView> | |||