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

Commit afc0502

Browse files
committed
2020-02-18 Version 1.3.0: Fixed detekt issues
1 parent b11dbc5 commit afc0502

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed

app/src/main/java/com/smlnskgmail/jaman/remotetemperaturecontrol/logic/monitor/MonitorFragment.kt

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,39 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget {
4141
if (bluetoothIsEnabled()) {
4242
@Suppress("ConstantConditionIf")
4343
if (BuildConfig.API_IMPL == "DEVICE_BT") {
44-
if (btIsEnabled()) {
45-
val btDevices = getBtDevices()
46-
if (btDevices.isNotEmpty()) {
47-
btMonitor = DeviceBtMonitor(this)
48-
showDevicesList(btDevices)
49-
} else {
50-
showBtDevicesNotFoundWarning()
51-
}
44+
val btDevices = getBtDevices()
45+
if (btDevices.isNotEmpty()) {
46+
btMonitor = DeviceBtMonitor(this)
47+
showDevicesList(btDevices)
5248
} else {
53-
showBtDisabledWarning()
49+
showBtDevicesNotFoundWarning()
5450
}
5551
} else {
5652
startInDebugMode()
5753
initializeButtons()
5854
}
5955
} else {
60-
AppDialog.show(
61-
context!!,
62-
R.string.bluetooth_error_dialog_title,
63-
R.string.bluetooth_error_dialog_message,
64-
R.string.bluetooth_error_dialog_button_text,
65-
DialogInterface.OnClickListener { dialog, _ ->
66-
dialog.cancel()
67-
activity!!.finish()
68-
}
69-
)
56+
showBluetoothErrorDialog()
7057
}
7158
}
7259

7360
private fun bluetoothIsEnabled(): Boolean {
7461
return btAdapter!!.isEnabled
7562
}
7663

64+
private fun showBluetoothErrorDialog() {
65+
AppDialog.show(
66+
context!!,
67+
R.string.bluetooth_error_dialog_title,
68+
R.string.bluetooth_error_dialog_message,
69+
R.string.bluetooth_error_dialog_button_text,
70+
DialogInterface.OnClickListener { dialog, _ ->
71+
dialog.cancel()
72+
activity!!.finish()
73+
}
74+
)
75+
}
76+
7777
@SuppressLint("SetTextI18n")
7878
private fun startInDebugMode() {
7979
btMonitor = DebugBtMonitor(this)
@@ -92,8 +92,6 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget {
9292
}.start()
9393
}
9494

95-
private fun btIsEnabled() = true
96-
9795
private fun showDevicesList(btDevices: List<BtDevice>) {
9896
val devicesBottomSheet = BtDevicesBottomSheet()
9997
devicesBottomSheet.setBtDevices(btDevices)
@@ -180,18 +178,6 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget {
180178
tv_connected_device_info.text = name
181179
}
182180

183-
private fun showBtDisabledWarning() {
184-
AppDialog.show(
185-
context!!,
186-
R.string.title_warning,
187-
R.string.message_bt_is_disabled,
188-
R.string.action_exit,
189-
DialogInterface.OnClickListener { _, _ ->
190-
activity!!.finish()
191-
}
192-
)
193-
}
194-
195181
private fun showBtDevicesNotFoundWarning() {
196182
AppDialog.show(
197183
context!!,

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<string name="action_exit">Exit</string>
2222

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

2726
<!-- Bluetooth error dialog -->

0 commit comments

Comments
 (0)