kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
commit
d13fa11dc8
|
@ -31,8 +31,8 @@ android {
|
||||||
applicationId "com.geeksville.mesh"
|
applicationId "com.geeksville.mesh"
|
||||||
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
|
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 20146 // format is Mmmss (where M is 1+the numeric major number
|
versionCode 20148 // format is Mmmss (where M is 1+the numeric major number
|
||||||
versionName "1.1.46"
|
versionName "1.1.48"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
// per https://developer.android.com/studio/write/vector-asset-studio
|
// per https://developer.android.com/studio/write/vector-asset-studio
|
||||||
|
@ -117,14 +117,14 @@ dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'androidx.core:core-ktx:1.3.2'
|
implementation 'androidx.core:core-ktx:1.3.2'
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.2.5'
|
implementation 'androidx.fragment:fragment-ktx:1.3.0'
|
||||||
implementation 'androidx.cardview:cardview:1.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
implementation 'com.google.android.material:material:1.3.0'
|
implementation 'com.google.android.material:material:1.3.0'
|
||||||
implementation 'androidx.viewpager2:viewpager2:1.0.0'
|
implementation 'androidx.viewpager2:viewpager2:1.0.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0'
|
||||||
implementation "androidx.room:room-runtime:$room_version"
|
implementation "androidx.room:room-runtime:$room_version"
|
||||||
kapt "androidx.room:room-compiler:$room_version"
|
kapt "androidx.room:room-compiler:$room_version"
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.geeksville.mesh.databinding.AdvancedSettingsBinding
|
||||||
import com.geeksville.mesh.model.ChannelOption
|
import com.geeksville.mesh.model.ChannelOption
|
||||||
import com.geeksville.mesh.model.UIViewModel
|
import com.geeksville.mesh.model.UIViewModel
|
||||||
import com.geeksville.mesh.service.MeshService
|
import com.geeksville.mesh.service.MeshService
|
||||||
|
import com.geeksville.util.exceptionToSnackbar
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
|
||||||
class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
||||||
|
@ -54,7 +55,9 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
||||||
?: ChannelOption.defaultMinBroadcastPeriod
|
?: ChannelOption.defaultMinBroadcastPeriod
|
||||||
|
|
||||||
if (n != null && n < MAX_INT_DEVICE && (n == 0 || n >= minBroadcastPeriodSecs)) {
|
if (n != null && n < MAX_INT_DEVICE && (n == 0 || n >= minBroadcastPeriodSecs)) {
|
||||||
|
exceptionToSnackbar(requireView()) {
|
||||||
model.positionBroadcastSecs = n
|
model.positionBroadcastSecs = n
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// restore the value in the edit field
|
// restore the value in the edit field
|
||||||
textEdit.setText(model.positionBroadcastSecs.toString())
|
textEdit.setText(model.positionBroadcastSecs.toString())
|
||||||
|
@ -73,7 +76,9 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
||||||
val str = binding.lsSleepEditText.text.toString()
|
val str = binding.lsSleepEditText.text.toString()
|
||||||
val n = str.toIntOrNull()
|
val n = str.toIntOrNull()
|
||||||
if (n != null && n < MAX_INT_DEVICE && n >= 0) {
|
if (n != null && n < MAX_INT_DEVICE && n >= 0) {
|
||||||
|
exceptionToSnackbar(requireView()) {
|
||||||
model.lsSleepSecs = n
|
model.lsSleepSecs = n
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(requireView(), "Bad value: $str", Snackbar.LENGTH_LONG).show()
|
Snackbar.make(requireView(), "Bad value: $str", Snackbar.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ import com.geeksville.mesh.service.SoftwareUpdateService.Companion.ProgressNotSt
|
||||||
import com.geeksville.mesh.service.SoftwareUpdateService.Companion.ProgressSuccess
|
import com.geeksville.mesh.service.SoftwareUpdateService.Companion.ProgressSuccess
|
||||||
import com.geeksville.util.anonymize
|
import com.geeksville.util.anonymize
|
||||||
import com.geeksville.util.exceptionReporter
|
import com.geeksville.util.exceptionReporter
|
||||||
|
import com.geeksville.util.exceptionToSnackbar
|
||||||
import com.google.android.gms.location.LocationRequest
|
import com.google.android.gms.location.LocationRequest
|
||||||
import com.google.android.gms.location.LocationServices
|
import com.google.android.gms.location.LocationServices
|
||||||
import com.google.android.gms.location.LocationSettingsRequest
|
import com.google.android.gms.location.LocationSettingsRequest
|
||||||
|
@ -226,8 +227,14 @@ class BTScanModel(app: Application) : AndroidViewModel(app), Logging {
|
||||||
debug("onScanResult ${entry}")
|
debug("onScanResult ${entry}")
|
||||||
|
|
||||||
// If nothing was selected, by default select the first valid thing we see
|
// If nothing was selected, by default select the first valid thing we see
|
||||||
val activity =
|
val activity: MainActivity? = try {
|
||||||
GeeksvilleApplication.currentActivity as MainActivity? // Can be null if app is shutting down
|
GeeksvilleApplication.currentActivity as MainActivity? // Can be null if app is shutting down
|
||||||
|
} catch (_: ClassCastException) {
|
||||||
|
// Buggy "Z812" phones apparently have the wrong class type for this
|
||||||
|
errormsg("Unexpected class for main activity")
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedAddress == null && entry.bonded && activity != null)
|
if (selectedAddress == null && entry.bonded && activity != null)
|
||||||
changeScanSelection(
|
changeScanSelection(
|
||||||
activity,
|
activity,
|
||||||
|
@ -265,7 +272,10 @@ class BTScanModel(app: Application) : AndroidViewModel(app), Logging {
|
||||||
debug("BTScan component active")
|
debug("BTScan component active")
|
||||||
selectedAddress = RadioInterfaceService.getDeviceAddress(context)
|
selectedAddress = RadioInterfaceService.getDeviceAddress(context)
|
||||||
|
|
||||||
return if (bluetoothAdapter == null || RadioInterfaceService.isMockInterfaceAvailable(context)) {
|
return if (bluetoothAdapter == null || RadioInterfaceService.isMockInterfaceAvailable(
|
||||||
|
context
|
||||||
|
)
|
||||||
|
) {
|
||||||
warn("No bluetooth adapter. Running under emulation?")
|
warn("No bluetooth adapter. Running under emulation?")
|
||||||
|
|
||||||
val testnodes = listOf(
|
val testnodes = listOf(
|
||||||
|
@ -495,10 +505,12 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
binding.updateProgressBar.visibility = View.VISIBLE
|
binding.updateProgressBar.visibility = View.VISIBLE
|
||||||
binding.updateProgressBar.progress = 0 // start from scratch
|
binding.updateProgressBar.progress = 0 // start from scratch
|
||||||
|
|
||||||
|
exceptionToSnackbar(requireView()) {
|
||||||
// We rely on our broadcast receiver to show progress as this progresses
|
// We rely on our broadcast receiver to show progress as this progresses
|
||||||
service.startFirmwareUpdate()
|
service.startFirmwareUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
@ -578,7 +590,6 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Only let user edit their name or set software update while connected to a radio
|
// Only let user edit their name or set software update while connected to a radio
|
||||||
model.isConnected.observe(viewLifecycleOwner, Observer { connectionState ->
|
model.isConnected.observe(viewLifecycleOwner, Observer { connectionState ->
|
||||||
val connected = connectionState == MeshService.ConnectionState.CONNECTED
|
val connected = connectionState == MeshService.ConnectionState.CONNECTED
|
||||||
|
@ -665,11 +676,12 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
binding.scanProgressBar.visibility = visible
|
binding.scanProgressBar.visibility = visible
|
||||||
binding.deviceRadioGroup.visibility = visible
|
binding.deviceRadioGroup.visibility = visible
|
||||||
}
|
}
|
||||||
private fun updateDevicesButtons( devices: MutableMap<String, BTScanModel.DeviceListEntry>?) {
|
|
||||||
|
private fun updateDevicesButtons(devices: MutableMap<String, BTScanModel.DeviceListEntry>?) {
|
||||||
// Remove the old radio buttons and repopulate
|
// Remove the old radio buttons and repopulate
|
||||||
binding.deviceRadioGroup.removeAllViews()
|
binding.deviceRadioGroup.removeAllViews()
|
||||||
|
|
||||||
if(devices == null) return
|
if (devices == null) return
|
||||||
|
|
||||||
val adapter = scanModel.bluetoothAdapter
|
val adapter = scanModel.bluetoothAdapter
|
||||||
var hasShownOurDevice = false
|
var hasShownOurDevice = false
|
||||||
|
@ -696,7 +708,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
scanModel.selectedAddress!!,
|
scanModel.selectedAddress!!,
|
||||||
bDevice.bondState == BOND_BONDED
|
bDevice.bondState == BOND_BONDED
|
||||||
)
|
)
|
||||||
addDeviceButton(curDevice, model.isConnected.value == MeshService.ConnectionState.CONNECTED)
|
addDeviceButton(
|
||||||
|
curDevice,
|
||||||
|
model.isConnected.value == MeshService.ConnectionState.CONNECTED
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else if (scanModel.selectedUSB != null) {
|
} else if (scanModel.selectedUSB != null) {
|
||||||
// Must be a USB device, show a placeholder disabled entry
|
// Must be a USB device, show a placeholder disabled entry
|
||||||
|
@ -714,7 +729,8 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
|
|
||||||
// get rid of the warning text once at least one device is paired.
|
// get rid of the warning text once at least one device is paired.
|
||||||
// If we are running on an emulator, always leave this message showing so we can test the worst case layout
|
// If we are running on an emulator, always leave this message showing so we can test the worst case layout
|
||||||
binding.warningNotPaired.visibility = if (hasBonded && !RadioInterfaceService.isMockInterfaceAvailable(requireContext())) View.GONE else View.VISIBLE
|
binding.warningNotPaired.visibility =
|
||||||
|
if (hasBonded && !RadioInterfaceService.isMockInterfaceAvailable(requireContext())) View.GONE else View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Setup the GUI to do a classic (pre SDK 26 BLE scan)
|
/// Setup the GUI to do a classic (pre SDK 26 BLE scan)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ee6611838637d096b39e11365930eb90a5f0fd2e
|
Subproject commit fb14fb659d0b235d325a0d9195cb5f47424dff51
|
Ładowanie…
Reference in New Issue