1.2-legacy
Kevin Hester 2021-03-03 13:51:33 +08:00
rodzic dbc91e4ac5
commit b53acd206b
2 zmienionych plików z 32 dodań i 9 usunięć

Wyświetl plik

@ -19,6 +19,7 @@ import android.view.LayoutInflater
import android.view.View 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.ArrayAdapter
import android.widget.RadioButton import android.widget.RadioButton
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
@ -585,6 +586,12 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
/// Setup the ui widgets unrelated to BLE scanning /// Setup the ui widgets unrelated to BLE scanning
private fun initCommonUI() { private fun initCommonUI() {
val regions = arrayOf("US", "CN", "EU488")
val spinner = binding.regionSpinner
val regionAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, regions)
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
spinner.adapter = regionAdapter
model.ownerName.observe(viewLifecycleOwner, { name -> model.ownerName.observe(viewLifecycleOwner, { name ->
binding.usernameEditText.setText(name) binding.usernameEditText.setText(name)
}) })
@ -593,7 +600,7 @@ 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
binding.usernameView.isEnabled = connected binding.nodeSettings.visibility = if(connected) View.VISIBLE else View.GONE
if (connectionState == MeshService.ConnectionState.DISCONNECTED) if (connectionState == MeshService.ConnectionState.DISCONNECTED)
model.ownerName.value = "" model.ownerName.value = ""

Wyświetl plik

@ -10,14 +10,14 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="0dp"
android:layout_marginTop="16dp">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/warningNotPaired" android:id="@+id/warningNotPaired"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:autoLink="web" android:autoLink="web"
android:ems="10" android:ems="10"
@ -27,17 +27,25 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/deviceRadioGroup" /> app:layout_constraintTop_toBottomOf="@+id/deviceRadioGroup" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/nodeSettings"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:id="@+id/usernameView" android:id="@+id/usernameView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:hint="@string/your_name" android:hint="@string/your_name"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/regionSpinner"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
@ -48,6 +56,16 @@
android:singleLine="true" /> android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<Spinner
android:id="@+id/regionSpinner"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/usernameView"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/scanStatusText" android:id="@+id/scanStatusText"
@ -59,7 +77,7 @@
android:text="@string/looking_for_meshtastic_devices" android:text="@string/looking_for_meshtastic_devices"
app:layout_constraintEnd_toStartOf="@+id/updateFirmwareButton" app:layout_constraintEnd_toStartOf="@+id/updateFirmwareButton"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/usernameView" /> app:layout_constraintTop_toBottomOf="@+id/nodeSettings" />
<ProgressBar <ProgressBar
android:id="@+id/scanProgressBar" android:id="@+id/scanProgressBar"
@ -150,7 +168,5 @@
app:layout_constraintStart_toStartOf="@+id/updateFirmwareButton" app:layout_constraintStart_toStartOf="@+id/updateFirmwareButton"
app:layout_constraintTop_toBottomOf="@+id/updateFirmwareButton" /> app:layout_constraintTop_toBottomOf="@+id/updateFirmwareButton" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>