kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
#38: Don't warn about bluetooth so much - just on the settings page
rodzic
12c5edb0b7
commit
a69560d056
|
@ -1,12 +1,7 @@
|
||||||
package com.geeksville.mesh.ui
|
package com.geeksville.mesh.ui
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter
|
|
||||||
import android.bluetooth.BluetoothManager
|
|
||||||
import android.content.Context
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.geeksville.android.GeeksvilleApplication
|
import com.geeksville.android.GeeksvilleApplication
|
||||||
import com.geeksville.mesh.R
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A fragment that represents a current 'screen' in our app.
|
* A fragment that represents a current 'screen' in our app.
|
||||||
|
@ -14,24 +9,10 @@ import com.geeksville.mesh.R
|
||||||
* Useful for tracking analytics
|
* Useful for tracking analytics
|
||||||
*/
|
*/
|
||||||
open class ScreenFragment(private val screenName: String) : Fragment() {
|
open class ScreenFragment(private val screenName: String) : Fragment() {
|
||||||
private val bluetoothAdapter: BluetoothAdapter? by lazy(LazyThreadSafetyMode.NONE) {
|
|
||||||
val bluetoothManager =
|
|
||||||
requireContext().getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
|
|
||||||
bluetoothManager.adapter
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
GeeksvilleApplication.analytics.sendScreenView(screenName)
|
GeeksvilleApplication.analytics.sendScreenView(screenName)
|
||||||
|
|
||||||
// Keep reminding user BLE is still off
|
|
||||||
if (bluetoothAdapter?.isEnabled != true) {
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(),
|
|
||||||
R.string.error_bluetooth,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.RadioButton
|
import android.widget.RadioButton
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
@ -748,6 +749,15 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
if (!hasCompanionDeviceApi && model.bluetoothEnabled.value!!)
|
if (!hasCompanionDeviceApi && model.bluetoothEnabled.value!!)
|
||||||
scanModel.startScan()
|
scanModel.startScan()
|
||||||
|
|
||||||
|
// Keep reminding user BLE is still off
|
||||||
|
if (scanModel.bluetoothAdapter?.isEnabled != true) {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
R.string.error_bluetooth,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue