sforkowany z mirror/meshtastic-android
don't let users edit their name when not connected to radio
rodzic
5e57fd69e1
commit
4c39d9e3f9
|
|
@ -29,6 +29,7 @@ import com.geeksville.mesh.MainActivity
|
|||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.anonymized
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.service.MeshService
|
||||
import com.geeksville.mesh.service.RadioInterfaceService
|
||||
import com.geeksville.util.exceptionReporter
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
|
@ -310,6 +311,11 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
usernameEditText.setText(name)
|
||||
})
|
||||
|
||||
// Only let user edit their name while connected to a radio
|
||||
model.isConnected.observe(viewLifecycleOwner, Observer { connected ->
|
||||
usernameView.isEnabled = connected == MeshService.ConnectionState.CONNECTED
|
||||
})
|
||||
|
||||
usernameEditText.on(EditorInfo.IME_ACTION_DONE) {
|
||||
debug("did IME action")
|
||||
val n = usernameEditText.text.toString().trim()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
app:layout_constraintTop_toBottomOf="@+id/deviceRadioGroup" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInputLayout2"
|
||||
android:id="@+id/usernameView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
android:text="@string/looking_for_meshtastic_devices"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textInputLayout2" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/usernameView" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/scanProgressBar"
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue