diff --git a/app/src/main/java/com/smlnskgmail/jaman/remotetemperaturecontrol/logic/monitor/MonitorFragment.kt b/app/src/main/java/com/smlnskgmail/jaman/remotetemperaturecontrol/logic/monitor/MonitorFragment.kt index fce4215..61e66f5 100644 --- a/app/src/main/java/com/smlnskgmail/jaman/remotetemperaturecontrol/logic/monitor/MonitorFragment.kt +++ b/app/src/main/java/com/smlnskgmail/jaman/remotetemperaturecontrol/logic/monitor/MonitorFragment.kt @@ -41,32 +41,19 @@ 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() } } @@ -74,6 +61,19 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget { 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) @@ -92,8 +92,6 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget { }.start() } - private fun btIsEnabled() = true - private fun showDevicesList(btDevices: List) { val devicesBottomSheet = BtDevicesBottomSheet() devicesBottomSheet.setBtDevices(btDevices) @@ -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!!, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc496db..2cec02c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -21,7 +21,6 @@ Exit - Bluetooth is disabled on this device! Please enable Bluetooth and restart app Cannot find available Bluetooth devices! Please add specified Bluetooth device and restart app