Merge pull request #373 from meshtastic/release

1.2.58
1.2-legacy 1.2.58
Andre Kirchhoff 2022-02-13 08:42:41 -03:00 zatwierdzone przez GitHub
commit 69dc99cdbc
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
6 zmienionych plików z 74 dodań i 65 usunięć

Wyświetl plik

@ -43,8 +43,8 @@ android {
applicationId "com.geeksville.mesh"
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 30 // 30 can't work until an explicit location permissions dialog is added
versionCode 20257 // format is Mmmss (where M is 1+the numeric major number
versionName "1.2.57"
versionCode 20258 // format is Mmmss (where M is 1+the numeric major number
versionName "1.2.58"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// per https://developer.android.com/studio/write/vector-asset-studio

Wyświetl plik

@ -737,24 +737,32 @@ class MainActivity : AppCompatActivity(), Logging,
}
private fun showSnackbar(msgId: Int) {
Snackbar.make(
findViewById(android.R.id.content),
msgId,
Snackbar.LENGTH_LONG
).show()
try {
Snackbar.make(
findViewById(android.R.id.content),
msgId,
Snackbar.LENGTH_LONG
).show()
} catch (ex: IllegalStateException) {
reportError("Snackbar couldn't find view for msgId $msgId")
}
}
private fun showSnackbar(msg: String) {
Snackbar.make(
findViewById(android.R.id.content),
msg,
Snackbar.LENGTH_INDEFINITE
)
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
.setAction(R.string.okay) {
// dismiss
}
.show()
try {
Snackbar.make(
findViewById(android.R.id.content),
msg,
Snackbar.LENGTH_INDEFINITE
)
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
.setAction(R.string.okay) {
// dismiss
}
.show()
} catch (ex: IllegalStateException) {
reportError("Snackbar couldn't find view for msgString $msg")
}
}
fun perhapsChangeChannel(url: Uri? = requestedChannelUrl) {

Wyświetl plik

@ -25,6 +25,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.BufferedWriter
import java.io.FileNotFoundException
import java.io.FileWriter
import java.text.SimpleDateFormat
import java.util.*
@ -350,12 +351,16 @@ class UIViewModel @Inject constructor(
private suspend inline fun writeToUri(uri: Uri, crossinline block: suspend (BufferedWriter) -> Unit) {
withContext(Dispatchers.IO) {
app.contentResolver.openFileDescriptor(uri, "wt")?.use { parcelFileDescriptor ->
FileWriter(parcelFileDescriptor.fileDescriptor).use { fileWriter ->
BufferedWriter(fileWriter).use { writer ->
block.invoke(writer)
try {
app.contentResolver.openFileDescriptor(uri, "wt")?.use { parcelFileDescriptor ->
FileWriter(parcelFileDescriptor.fileDescriptor).use { fileWriter ->
BufferedWriter(fileWriter).use { writer ->
block.invoke(writer)
}
}
}
} catch (ex: FileNotFoundException) {
errormsg("Can't write file error: ${ex.message}")
}
}
}

Wyświetl plik

@ -112,15 +112,14 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
/** Return true if this address is still acceptable. For BLE that means, still bonded */
@SuppressLint("NewApi", "MissingPermission")
override fun addressValid(context: Context, rest: String): Boolean {
val allPaired = if (hasCompanionDeviceApi(context)) {
/* val allPaired = if (hasCompanionDeviceApi(context)) {
val deviceManager: CompanionDeviceManager by lazy {
context.getSystemService(Context.COMPANION_DEVICE_SERVICE) as CompanionDeviceManager
}
deviceManager.associations.map { it }.toSet()
} else {
getBluetoothAdapter(context)?.bondedDevices.orEmpty()
} else { */
val allPaired = getBluetoothAdapter(context)?.bondedDevices.orEmpty()
.map { it.address }.toSet()
}
return if (!allPaired.contains(rest)) {
warn("Ignoring stale bond to ${rest.anonymize}")
false

Wyświetl plik

@ -286,22 +286,6 @@ class RadioInterfaceService : Service(), Logging {
debug("Setting bonded device to ${address.anonymize}")
// We only keep an association to one device at a time... (move to BluetoothInterface?)
if (BluetoothInterface.hasCompanionDeviceApi(this)) {
if (address != null) {
val deviceManager = getSystemService(CompanionDeviceManager::class.java)
val c = address[0]
val rest = address.substring(1)
deviceManager.associations.forEach { old ->
if (rest != old) {
debug("Forgetting old BLE association ${old.anonymize}")
deviceManager.disassociate(old)
}
}
}
}
getPrefs(this).edit(commit = true) {
if (address == null)
this.remove(DEVADDR_KEY)

Wyświetl plik

@ -813,7 +813,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
if (curRadio != null && !MockInterface.addressValid(requireContext(), "")) {
binding.warningNotPaired.visibility = View.GONE
// binding.scanStatusText.text = getString(R.string.current_pair).format(curRadio)
} else {
} else if (model.bluetoothEnabled.value == true){
binding.warningNotPaired.visibility = View.VISIBLE
binding.scanStatusText.text = getString(R.string.not_paired_yet)
}
@ -883,7 +883,6 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
deviceManager.associate(
pairingRequest,
object : CompanionDeviceManager.Callback() {
override fun onDeviceFound(chooserLauncher: IntentSender) {
debug("Found one device - enabling changeRadioButton")
binding.changeRadioButton.isEnabled = true
@ -914,8 +913,6 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
updateDevicesButtons(devices)
startCompanionScan()
}
startCompanionScan()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -952,13 +949,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
fun weNeedAccess(warningReason: String) {
warn("Telling user we need need location access")
Snackbar.make(requireView(), warningReason, Snackbar.LENGTH_INDEFINITE)
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
.setAction(R.string.okay) {
// dismiss
}
.show()
showSnackbar(warningReason)
}
locationSettingsResponse.addOnSuccessListener {
@ -1001,6 +992,23 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
}
}
private fun showSnackbar(msg: String) {
try {
Snackbar.make(
requireView(),
msg,
Snackbar.LENGTH_INDEFINITE
)
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
.setAction(R.string.okay) {
// dismiss
}
.show()
} catch (ex: IllegalStateException) {
reportError("Snackbar couldn't find view for msgString $msg")
}
}
override fun onPause() {
super.onPause()
@ -1022,15 +1030,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
if (!hasUSB) {
// Warn user if BLE is disabled
if (scanModel.bluetoothAdapter?.isEnabled != true) {
Snackbar.make(
requireView(),
R.string.error_bluetooth,
Snackbar.LENGTH_INDEFINITE
)
.setAction(R.string.okay) {
// dismiss
}
.show()
showSnackbar(getString(R.string.error_bluetooth))
} else {
if (binding.provideLocationCheckbox.isChecked)
checkLocationEnabled(getString(R.string.location_disabled))
@ -1038,17 +1038,30 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
}
}
@SuppressLint("MissingPermission")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
if (hasCompanionDeviceApi && myActivity.hasConnectPermission()
&& requestCode == MainActivity.SELECT_DEVICE_REQUEST_CODE
&& resultCode == Activity.RESULT_OK
) {
val deviceToPair: BluetoothDevice =
data?.getParcelableExtra(CompanionDeviceManager.EXTRA_DEVICE)!!
if (deviceToPair.bondState != BOND_BONDED) {
deviceToPair.createBond()
// We only keep an association to one device at a time...
deviceManager.associations.forEach { old ->
if (deviceToPair.address != old) {
debug("Forgetting old BLE association ${old.anonymize}")
deviceManager.disassociate(old)
}
}
scanModel.changeScanSelection(myActivity, "x${deviceToPair.address}")
scanModel.onSelected(
myActivity,
BTScanModel.DeviceListEntry(
deviceToPair.name,
"x${deviceToPair.address}",
deviceToPair.bondState == BOND_BONDED
)
)
} else {
super.onActivityResult(requestCode, resultCode, data)
}