Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
2020-02-18 Version 1.3.0: Fixed detekt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fartem committed Feb 18, 2020
1 parent b11dbc5 commit afc0502
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,39 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget {
if (bluetoothIsEnabled()) {
@Suppress("ConstantConditionIf")
if (BuildConfig.API_IMPL == "DEVICE_BT") {
if (btIsEnabled()) {
val btDevices = getBtDevices()
if (btDevices.isNotEmpty()) {
btMonitor = DeviceBtMonitor(this)
showDevicesList(btDevices)
} else {
showBtDevicesNotFoundWarning()
}
val btDevices = getBtDevices()
if (btDevices.isNotEmpty()) {
btMonitor = DeviceBtMonitor(this)
showDevicesList(btDevices)
} else {
showBtDisabledWarning()
showBtDevicesNotFoundWarning()
}
} else {
startInDebugMode()
initializeButtons()
}
} else {
AppDialog.show(
context!!,
R.string.bluetooth_error_dialog_title,
R.string.bluetooth_error_dialog_message,
R.string.bluetooth_error_dialog_button_text,
DialogInterface.OnClickListener { dialog, _ ->
dialog.cancel()
activity!!.finish()
}
)
showBluetoothErrorDialog()
}
}

private fun bluetoothIsEnabled(): Boolean {
return btAdapter!!.isEnabled
}

private fun showBluetoothErrorDialog() {
AppDialog.show(
context!!,
R.string.bluetooth_error_dialog_title,
R.string.bluetooth_error_dialog_message,
R.string.bluetooth_error_dialog_button_text,
DialogInterface.OnClickListener { dialog, _ ->
dialog.cancel()
activity!!.finish()
}
)
}

@SuppressLint("SetTextI18n")
private fun startInDebugMode() {
btMonitor = DebugBtMonitor(this)
Expand All @@ -92,8 +92,6 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget {
}.start()
}

private fun btIsEnabled() = true

private fun showDevicesList(btDevices: List<BtDevice>) {
val devicesBottomSheet = BtDevicesBottomSheet()
devicesBottomSheet.setBtDevices(btDevices)
Expand Down Expand Up @@ -180,18 +178,6 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget {
tv_connected_device_info.text = name
}

private fun showBtDisabledWarning() {
AppDialog.show(
context!!,
R.string.title_warning,
R.string.message_bt_is_disabled,
R.string.action_exit,
DialogInterface.OnClickListener { _, _ ->
activity!!.finish()
}
)
}

private fun showBtDevicesNotFoundWarning() {
AppDialog.show(
context!!,
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<string name="action_exit">Exit</string>

<!-- Messages -->
<string name="message_bt_is_disabled">Bluetooth is disabled on this device! Please enable Bluetooth and restart app</string>
<string name="message_no_available_devices">Cannot find available Bluetooth devices! Please add specified Bluetooth device and restart app</string>

<!-- Bluetooth error dialog -->
Expand Down

0 comments on commit afc0502

Please sign in to comment.