check bluetooth enabled

This commit is contained in:
Zhengyu Peng committed 2022-02-24 10:07:50 -05:00
1 parent 36d9080fc9
commit dc5d349db6
1 file changed
+2 -3
@@ -124,7 +124,6 @@ class MainActivity : AppCompatActivity() {
if (bluetoothAdapter != null) {
if (!bluetoothAdapter.isEnabled) {
alertDialog(ERROR_BLUETOOTH_DISABLED)
}
} else {
if (btConnectPermission && btScanPermission) {
val serverIntent = Intent(this, DeviceListActivity::class.java)
@@ -134,6 +133,7 @@ class MainActivity : AppCompatActivity() {
}
}
}
}
if (tabLayout.selectedTabPosition == 0) {
ipLayout.visibility = View.VISIBLE
@@ -176,7 +176,6 @@ class MainActivity : AppCompatActivity() {
if (bluetoothAdapter != null) {
if (!bluetoothAdapter.isEnabled) {
alertDialog(ERROR_BLUETOOTH_DISABLED)
}
} else {
if (btConnectPermission && btScanPermission) {
saveSharedPref()
@@ -189,6 +188,7 @@ class MainActivity : AppCompatActivity() {
alertDialog(ERROR_NO_PERMISSION)
}
}
}
} else {
alertDialog(ERROR_NO_DEVICE)
}
@@ -242,7 +242,6 @@ class MainActivity : AppCompatActivity() {
} else if (requestCode == BLUETOOTH_SCAN_CODE) {
btScanPermission = true
}
}
}