蓝牙传感器添加sdk

master
wenfei 2 months ago
parent f30327c6d2
commit eba3627d9a

@ -116,6 +116,8 @@ dependencies {
//SDK
implementation files('libs/SangforSDK.aar')
//W3SDK
implementation files('libs/blemanager.aar')
implementation libs.circleimageview
//APP
implementation libs.crashreport

Binary file not shown.

@ -7,11 +7,12 @@
android:name="android.hardware.bluetooth_le"
android:required="true" /> <!-- Android 12 中的新蓝牙权限开始 -->
<!-- Request legacy Bluetooth permissions on older devices. -->
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="31" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />

@ -272,6 +272,7 @@ public class Contans {
public final static String LOGIN_TOKEN = "LOGIN_TOKEN";
public final static String NFCBM = "NFCBM";
public final static String KEY_BLUE_TOOTH = "KEY_BLUE_TOOTH";
public final static String USERNAME = "USERNAME";
public final static String SCID = "scid";

@ -1,19 +1,27 @@
package com.rehome.dywoa.bleUtil;
import android.Manifest;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanResult;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import com.bjzc.blemanager.BluetoothLeService;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
@ -23,14 +31,20 @@ import androidx.core.app.ActivityCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.clj.fastble.BleManager;
//import com.clj.fastble.BleManager;
import com.bjzc.blemanager.BleManager;
import com.clj.fastble.callback.BleScanCallback;
import com.clj.fastble.data.BleDevice;
import com.clj.fastble.data.BleScanState;
import com.clj.fastble.scan.BleScanRuleConfig;
import com.google.gson.Gson;
import com.rehome.dywoa.Contans;
import com.rehome.dywoa.R;
import com.rehome.dywoa.adapter.XzjhAdapter;
import com.rehome.dywoa.base.BaseActivity;
import com.rehome.dywoa.utils.SPUtils;
import java.util.ArrayList;
import java.util.List;
@ -42,6 +56,7 @@ import java.util.List;
public class BlueToothDeviceActivity extends BaseActivity {
ListView lv;
TextView tx_data;
private BluetoothAdapter mBluetoothAdapter;
private ArrayList<String> mPermissionList = new ArrayList();
private BluetoothLeScanner bluetoothLeScanner;
@ -54,6 +69,10 @@ public class BlueToothDeviceActivity extends BaseActivity {
//private LeDeviceListAdapter leDeviceListAdapter = new LeDeviceListAdapter();
private LeDeviceListAdapter mLeDeviceListAdapter;
private BleManager ble;
private int selectItem = -1;
private String cmd = "";
@Override
public int getContentViewID() {
return R.layout.activity_blue_tooth_device;
@ -61,6 +80,84 @@ public class BlueToothDeviceActivity extends BaseActivity {
@Override
public void initView() {
lv = findViewById(R.id.lv);
tx_data = findViewById(R.id.tx_data);
ble= BleManager.getInstance();
String str=ble.init(BlueToothDeviceActivity.this);
showLog(str);
if("BLE is not supported".equals(str)){
showToast("当前设备不支持低功耗蓝牙,无法连接传感器采集数据");
}
if("Bluetooth not supported".equals(str)){
showToast("当前设备不支持蓝牙功能");
}
if("Bluetooth not enabled".equals(str)){
showToast("蓝牙功能没有开启");
}
if("ACCESS_COARSE_LOCATION permission denied".equals(str)){
showToast("您未授权开启蓝牙扫描附近的设备,请先开启蓝牙权限");
}
if("context is no Activity".equals(str)){
showToast("Init(context)方法的参数必须是 Activity");
}
ble.setOnReceiveListener(new BleManager.OnReceiveListener() {
@SuppressLint("SetTextI18n")
@Override
public void onShowMessage(Context context, Intent intent) {
final String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (ActivityCompat.checkSelfPermission(BlueToothDeviceActivity.this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
showLog("扫描发现设备" + device.getName() + "," + device.getAddress());
String deviceName = device.getName();
if (deviceName != null && !deviceName.isEmpty()){
//showLog(new Gson().toJson(device));
mLeDeviceListAdapter.addDevice(device);
mLeDeviceListAdapter.notifyDataSetChanged();
}
} else if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
showLog("连接");
mLeDeviceListAdapter.setSelectItem(selectItem);
mLeDeviceListAdapter.notifyDataSetChanged();
BluetoothDevice device = mLeDeviceListAdapter.getDevice(selectItem);
String deviceName = device.getName();
if (deviceName != null && !deviceName.isEmpty()){
SPUtils.put(context, Contans.KEY_BLUE_TOOTH,device.getAddress());
}
} else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
showLog("断开");
} else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
showLog("数据传输通道准备就绪,可以发送数据了。");
} else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
byte[] data= intent.getByteArrayExtra(BluetoothLeService.EXTRA_DATA);
String resultReceive = new String(data);
showLog("收到传感器数据" + resultReceive);
if("VR".equals(cmd)){
showLog(resultReceive);
}else{
tx_data.setText("接收数值:"+resultReceive);
}
if("0F3101".equals(cmd)){
ble.write("VR", false);
cmd="VR";
}
}
}
});
initToolbar("蓝牙数据管理", "扫描并确认", new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -68,14 +165,69 @@ public class BlueToothDeviceActivity extends BaseActivity {
mLeDeviceListAdapter.clear();
mLeDeviceListAdapter.notifyDataSetChanged();
//initBlueTooth();
if(BleManager.getInstance().isSupportBle()){
initBlueToothFastBle();
// if(BleManager.getInstance().isSupportBle()){
// initBlueToothFastBle();
// }else{
// showToast("当前设备不支持低功耗蓝牙,无法连接传感器采集数据");
// }
if("OK".equals(str)){
ble.scan();
}
}
});
BleManager.getInstance().init(getApplication());
lv = findViewById(R.id.lv);
mLeDeviceListAdapter = new LeDeviceListAdapter(BlueToothDeviceActivity.this);
//BleManager.getInstance().init(getApplication());
mLeDeviceListAdapter = new LeDeviceListAdapter(new LeDeviceListAdapter.CallBackBlueToothBind() {
@Override
public void Click(int position) {
showLog(String.valueOf(position));
BluetoothDevice device = mLeDeviceListAdapter.getDevice(position);
if (ActivityCompat.checkSelfPermission(BlueToothDeviceActivity.this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
selectItem=position;
ble.connect(device.getAddress(),device.getName());
}
}, new LeDeviceListAdapter.CallBackBlueToothUnBind() {
@Override
public void Click(int position) {
}
}, new LeDeviceListAdapter.CallBackBlueToothSendData() {
@Override
public void Click(int position) {
//ble.write(String cmd, Boolean ishex)
//读固件版本号
//ble.write("VR", false);
//读电量
//ble.write("BV", false);
//温度测量
ble.write("0B0B6300", true);
//距离测量
//ble.write("4453", true);
//转速测量
//ble.write("0F3101", true);
//cmd="0F3101";
//加速度测量
//ble.write("1F11", true);
//速度测量。
//ble.write("1F12", true);
//位移测量
//ble.write("1F13", true);
}
});
lv.setAdapter(mLeDeviceListAdapter);
}
@ -84,6 +236,19 @@ public class BlueToothDeviceActivity extends BaseActivity {
}
@Override
protected void onDestroy() {
super.onDestroy();
ble.scan();
ble.disconnect();
// if(BleManager.getInstance().getScanSate()== BleScanState.STATE_SCANNING){
// BleManager.getInstance().cancelScan();
// }
// BleManager.getInstance().disconnectAllDevice();
// BleManager.getInstance().destroy();
}
private void initPermission(){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
// Android 版本大于等于 Android12 时
@ -135,12 +300,12 @@ public class BlueToothDeviceActivity extends BaseActivity {
public void initBlueTooth() {
boolean bluetoothAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
if(bluetoothAvailable){
showLog("传统蓝牙可用");
}else{
showLog("传统蓝牙不可用");
}
// boolean bluetoothAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
// if(bluetoothAvailable){
// showLog("传统蓝牙可用");
// }else{
// showLog("传统蓝牙不可用");
// }
boolean bluetoothLEAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE);
if(bluetoothLEAvailable){
@ -152,41 +317,65 @@ public class BlueToothDeviceActivity extends BaseActivity {
}
}
public void initBlueToothFastBle() {
BleManager.getInstance()
.enableLog(true)
.setReConnectCount(1, 5000)
.setSplitWriteNum(20)
.setConnectOverTime(10000)
.setOperateTimeout(5000);
// public void initBlueToothFastBle() {
// if(BleManager.getInstance().getScanSate()== BleScanState.STATE_SCANNING){
// BleManager.getInstance().cancelScan();
// }
// BleManager.getInstance()
// .enableLog(true)
// .setReConnectCount(1, 5000)
// .setSplitWriteNum(20)
// .setConnectOverTime(10000)
// .setOperateTimeout(5000);
//
// BleScanRuleConfig scanRuleConfig = new BleScanRuleConfig.Builder()
// .setAutoConnect(true)
// .setScanTimeOut(10000)
// .build();
// BleManager.getInstance().initScanRule(scanRuleConfig);
BleManager.getInstance().scan(new BleScanCallback() {
@Override
public void onScanStarted(boolean success) {
showToast("开始蓝牙扫描");
}
@Override
public void onScanning(BleDevice bleDevice) {
showToast("发现设备");
mLeDeviceListAdapter.addDevice(bleDevice.getDevice());
mLeDeviceListAdapter.notifyDataSetChanged();
}
@Override
public void onScanFinished(List<BleDevice> scanResultList) {
showToast("蓝牙扫描结束");
showLog(String.valueOf(scanResultList.size()));
showLog(new Gson().toJson(scanResultList));
}
});
}
//
// BleManager.getInstance().scan(new BleScanCallback() {
// @Override
// public void onScanStarted(boolean success) {
// showToast("开始蓝牙扫描");
// }
//
// @Override
// public void onScanning(BleDevice bleDevice) {
//// if (context != null && !BlueToothDeviceActivity.this.isFinishing() && !BlueToothDeviceActivity.this.isDestroyed()) {
//// showToast("发现设备");
//// }
// BluetoothDevice device = bleDevice.getDevice();
// if(device!=null){
// if (ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// // TODO: Consider calling
// // ActivityCompat#requestPermissions
// // here to request the missing permissions, and then overriding
// // public void onRequestPermissionsResult(int requestCode, String[] permissions,
// // int[] grantResults)
// // to handle the case where the user grants the permission. See the documentation
// // for ActivityCompat#requestPermissions for more details.
// return;
// }
// String deviceName = device.getName();
// if (deviceName != null && !deviceName.isEmpty()){
// showLog(new Gson().toJson(device));
// mLeDeviceListAdapter.addDevice(bleDevice.getDevice());
// mLeDeviceListAdapter.notifyDataSetChanged();
// }
// }
// }
//
// @Override
// public void onScanFinished(List<BleDevice> scanResultList) {
// if (context != null && !BlueToothDeviceActivity.this.isFinishing() && !BlueToothDeviceActivity.this.isDestroyed()) {
// showToast("蓝牙扫描结束");
// }
// showLog(String.valueOf(mLeDeviceListAdapter.getCount()));
// showLog(new Gson().toJson(scanResultList));
// }
// });
// }
private void scanLeDevice() {
if (!scanning) {
@ -238,4 +427,151 @@ public class BlueToothDeviceActivity extends BaseActivity {
}
};
private class LeDeviceListAdapter extends BaseAdapter {
private class ViewHolder {
TextView deviceName;
TextView deviceStatus;
TextView deviceBind;
TextView deviceDeBind;
TextView sendData;
}
private ArrayList<BluetoothDevice> mLeDevices;
private LayoutInflater mInflator;
private CallBackBlueToothBind callBackBlueToothBind;
private CallBackBlueToothUnBind callBackBlueToothUnBind;
private CallBackBlueToothSendData callBackBlueToothSendData;
public LeDeviceListAdapter(CallBackBlueToothBind callBackBlueToothBind,CallBackBlueToothUnBind callBackBlueToothUnBind,
CallBackBlueToothSendData callBackBlueToothSendData) {
super();
mLeDevices = new ArrayList<BluetoothDevice>();
mInflator = BlueToothDeviceActivity.this.getLayoutInflater();
this.callBackBlueToothBind=callBackBlueToothBind;
this.callBackBlueToothUnBind=callBackBlueToothUnBind;
this.callBackBlueToothSendData=callBackBlueToothSendData;
}
public interface CallBackBlueToothBind {
void Click(int position);
}
public interface CallBackBlueToothUnBind {
void Click(int position);
}
public interface CallBackBlueToothSendData {
void Click(int position);
}
public void addDevice(BluetoothDevice device) {
if (!mLeDevices.contains(device)) {
mLeDevices.add(device);
}
}
public BluetoothDevice getDevice(int position) {
return mLeDevices.get(position);
}
public void clear() {
mLeDevices.clear();
}
@Override
public int getCount() {
return mLeDevices.size();
}
@Override
public Object getItem(int i) {
return mLeDevices.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
LeDeviceListAdapter.ViewHolder viewHolder;
if (view == null) {
view = mInflator.inflate(R.layout.listitem_device, null);
viewHolder = new LeDeviceListAdapter.ViewHolder();
viewHolder.deviceName = view.findViewById(R.id.device_name);
viewHolder.deviceStatus = view.findViewById(R.id.device_status);
viewHolder.deviceBind = view.findViewById(R.id.device_bind);
viewHolder.deviceDeBind = view.findViewById(R.id.device_de_bind);
viewHolder.sendData = view.findViewById(R.id.send_data);
view.setTag(viewHolder);
} else {
viewHolder = (LeDeviceListAdapter.ViewHolder) view.getTag();
}
BluetoothDevice device = mLeDevices.get(i);
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return null;
}
String deviceName = device.getName();
if (deviceName != null && !deviceName.isEmpty())
viewHolder.deviceName.setText(deviceName);
else{
viewHolder.deviceName.setText(R.string.unknown_device);
}
//当前点击选中的变色
if (i == selectItem) {
viewHolder.deviceName.getPaint().setFakeBoldText(true);
//viewHolder.deviceName.setTextColor(Color.parseColor("#00FF7F"));//连接之后的颜色
viewHolder.deviceStatus.setTextColor(Color.parseColor("#00FF7F"));//连接之后的颜色
viewHolder.deviceStatus.setText("已连接");
} else {
viewHolder.deviceName.getPaint().setFakeBoldText(false);
//viewHolder.deviceName.setTextColor(Color.parseColor("#00FF7F"));//连接之后的颜色
viewHolder.deviceStatus.setTextColor(Color.parseColor("#000000"));
viewHolder.deviceStatus.setText("未绑定");
}
viewHolder.deviceBind.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(callBackBlueToothBind!=null){
callBackBlueToothBind.Click(i);
}
}
});
viewHolder.deviceDeBind.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(callBackBlueToothUnBind!=null){
callBackBlueToothUnBind.Click(i);
}
}
});
viewHolder.sendData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(callBackBlueToothSendData!=null){
callBackBlueToothSendData.Click(i);
}
}
});
return view;
}
public void setSelectItem(int selectItem) {
this.selectItem = selectItem;
}
private int selectItem = -1;
}
}

@ -4,6 +4,8 @@ package com.rehome.dywoa.ui.fragment;
import static android.app.Activity.RESULT_OK;
import android.Manifest;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Environment;
@ -20,7 +22,11 @@ import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import com.bjzc.blemanager.BleManager;
import com.bjzc.blemanager.BluetoothLeService;
import com.google.gson.Gson;
import com.rehome.dywoa.App;
import com.rehome.dywoa.Contans;
import com.rehome.dywoa.MainActivity;
@ -105,6 +111,8 @@ public class HomeFragment extends BaseFragment {
SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
private BleManager ble;
//人脸识别
ActivityResultLauncher<Intent> launcherResultFaceRecognition;
@ -125,6 +133,45 @@ public class HomeFragment extends BaseFragment {
username = App.getInstance().getUserInfo().getManid();
firstDeparment = App.getInstance().getUserInfo().getFirstDeparment();
ble= BleManager.getInstance();
String str=ble.init(requireActivity());
if("OK".equals(str)){
}
ble.setOnReceiveListener(new BleManager.OnReceiveListener() {
@Override
public void onShowMessage(Context context, Intent intent) {
final String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (ActivityCompat.checkSelfPermission(requireActivity(), Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
showLog("扫描发现设备" + device.getName() + "," + device.getAddress());
String deviceName = device.getName();
if (deviceName != null && !deviceName.isEmpty()){
showLog(new Gson().toJson(device));
}
} else if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
showLog("连接");
} else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
showLog("断开");
} else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
showLog("数据传输通道准备就绪,可以发送数据了。");
} else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
byte[] data= intent.getByteArrayExtra(BluetoothLeService.EXTRA_DATA);
showLog("收到传感器数据" + new String(data));
}
}
});
//android 10 以上
if (context.getExternalFilesDir(null) != null) {

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#999999" />
<stroke
android:width="1dip"
android:color="#4fa5d5" />
<corners android:radius="3dp" />
</shape>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 正常状态 -->
<item android:drawable="@drawable/btn_normal" android:state_pressed="false"/>
<!-- 按下状态 -->
<item android:drawable="@drawable/btn_pressed_bt" android:state_pressed="true"/>
</selector>

@ -10,7 +10,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_height="wrap_content"
android:minHeight="80dp"
android:layout_margin="10dp"
android:orientation="vertical">

@ -5,37 +5,129 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="6dp"
app:cardBackgroundColor="@color/xui_config_color_white"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardPreventCornerOverlap="true"
app:contentPaddingTop="5dp"
app:contentPaddingBottom="10dp"
app:contentPaddingBottom="5dp"
app:contentPaddingLeft="10dp"
app:contentPaddingRight="10dp">
app:contentPaddingRight="10dp"
app:contentPaddingTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:baselineAligned="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="蓝牙名称:"
android:textSize="30px" />
<TextView
android:id="@+id/device_name"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|left"
android:textSize="30px" />
</LinearLayout>
android:layout_height="wrap_content"
android:baselineAligned="false"
android:gravity="center_vertical"
android:minHeight="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="蓝牙名称:"
android:textColor="#666666"
android:textSize="16sp" />
<TextView
android:id="@+id/device_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:gravity="center|left"
android:textColor="#666666"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:baselineAligned="false"
android:gravity="center_vertical"
android:minHeight="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="蓝牙状态:"
android:textColor="#666666"
android:textSize="16sp" />
<TextView
android:id="@+id/device_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:gravity="center|left"
android:textColor="#666666"
android:text="未绑定"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:baselineAligned="false"
android:gravity="center_vertical"
android:minHeight="30dp"
android:orientation="horizontal">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/device_bind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="3dp"
android:background="@drawable/btn_selector_bt"
android:textColor="#ffffff"
android:text="蓝牙绑定"
android:textSize="16sp" />
<TextView
android:id="@+id/device_de_bind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="3dp"
android:text="蓝牙解绑"
android:background="@drawable/btn_selector"
android:textColor="#ffffff"
android:visibility="gone"
android:textSize="16sp" />
</FrameLayout>
<TextView
android:id="@+id/send_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:padding="3dp"
android:gravity="center|left"
android:background="@drawable/btn_selector"
android:textColor="#ffffff"
android:text="数据采集"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

Loading…
Cancel
Save