From 7fa168ab2c29bf7bd055bbe8e870fcde0ddedb36 Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 15 Apr 2020 07:49:39 -0700 Subject: [PATCH] 0.3.9 - fix channel setting autobug and update to latest google libs --- app/build.gradle | 12 ++++----- .../java/com/geeksville/mesh/model/UIState.kt | 3 ++- .../com/geeksville/mesh/ui/ChannelFragment.kt | 27 +++++++++++++------ app/src/main/res/values/strings.xml | 1 + build.gradle | 2 +- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 553c15997..79aa4cabf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,8 +16,8 @@ android { applicationId "com.geeksville.mesh" minSdkVersion 22 // The oldest emulator image I have tried is 22 (though 21 probably works) targetSdkVersion 29 - versionCode 138 - versionName "0.3.8" + versionCode 139 + versionName "0.3.9" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -97,8 +97,8 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' implementation 'com.google.android.material:material:1.1.0' implementation 'androidx.viewpager2:viewpager2:1.0.0' - implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.1.0' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' @@ -123,10 +123,10 @@ dependencies { implementation 'com.google.android.gms:play-services-location:17.0.0' // For Google Sign-In (owner name accesss) - implementation 'com.google.android.gms:play-services-auth:17.0.0' + implementation 'com.google.android.gms:play-services-auth:18.0.0' // Add the Firebase SDK for Crashlytics. - implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta03' + implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta04' // alas implementation bug deep in the bowels when I tried it for my SyncBluetoothDevice class // implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3" diff --git a/app/src/main/java/com/geeksville/mesh/model/UIState.kt b/app/src/main/java/com/geeksville/mesh/model/UIState.kt index 7650f575f..38939a0fc 100644 --- a/app/src/main/java/com/geeksville/mesh/model/UIState.kt +++ b/app/src/main/java/com/geeksville/mesh/model/UIState.kt @@ -73,7 +73,8 @@ class UIViewModel(app: Application) : AndroidViewModel(app), Logging { fun setRadioConfig(c: MeshProtos.RadioConfig) { debug("Setting new radio config!") meshService?.radioConfig = c.toByteArray() - radioConfig.value = c + radioConfig.value = + c // Must be done after calling the service, so we will will properly throw if the service failed (and therefore not cache invalid new settings) getPreferences(context).edit(commit = true) { this.putString("channel-url", getChannel(c)!!.getChannelUrl().toString()) diff --git a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt index a9d9a4dbc..b012fb741 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt @@ -4,6 +4,7 @@ import android.content.Intent import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter import android.os.Bundle +import android.os.RemoteException import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -19,7 +20,9 @@ import com.geeksville.android.hideKeyboard import com.geeksville.mesh.R import com.geeksville.mesh.model.UIViewModel import com.geeksville.mesh.service.MeshService +import com.geeksville.util.Exceptions import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.google.android.material.snackbar.Snackbar import kotlinx.android.synthetic.main.channel_fragment.* @@ -128,12 +131,6 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { editableCheckbox.setOnCheckedChangeListener { _, checked -> if (!checked) { // User just locked it, we should warn and then apply changes to radio - /* Snackbar.make( - editableCheckbox, - "Changing channels is not yet supported", - Snackbar.LENGTH_SHORT - ).show() */ - MaterialAlertDialogBuilder(requireContext()) .setTitle(R.string.change_channel) .setMessage(R.string.are_you_sure_channel) @@ -146,8 +143,22 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { val newSettings = old.settings.toBuilder() newSettings.name = channelNameEdit.text.toString().trim() // FIXME, regenerate a new preshared key! - model.setChannel(newSettings.build()) - // Since we are writing to radioconfig, that will trigger the rest of the GUI update (QR code etc) + + // Try to change the radio, if it fails, tell the user why and throw away their redits + try { + model.setChannel(newSettings.build()) + // Since we are writing to radioconfig, that will trigger the rest of the GUI update (QR code etc) + } catch (ex: RemoteException) { + setGUIfromModel() // Throw away user edits + + // Tell the user to try again + Snackbar.make( + editableCheckbox, + R.string.radio_sleeping, + Snackbar.LENGTH_SHORT + ).show() + Exceptions.report(ex, "ignoring channel problem") + } } } .show() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 04630e796..771a35e8a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -36,4 +36,5 @@ If you would like to see the map, you\'ll need to turn on analytics in the Settings pane (also, for the time being you might need to force restart the application).\n\n If you are interested in us paying for mapbox (or switching to a different map provider), please post in our forum. A required permission is missing, Meshtastic won\'t be able to work properly. Please enable in application settings. + Radio was sleeping, could not change channel diff --git a/build.gradle b/build.gradle index 7c9083db8..c5812afc0 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ buildscript { // Check that you have the Google Services Gradle plugin v4.3.2 or later // (if not, add it). classpath 'com.google.gms:google-services:4.3.3' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta03' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04' // protobuf plugin - docs here https://github.com/google/protobuf-gradle-plugin classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'