mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
about to remove compose
This commit is contained in:
parent
b83c1a0394
commit
8709d9db8c
4 changed files with 44 additions and 27 deletions
|
|
@ -16,6 +16,7 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
|
|
@ -24,10 +25,7 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
|
|||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.geeksville.android.Logging
|
||||
import com.geeksville.android.ServiceClient
|
||||
import com.geeksville.mesh.model.MessagesState
|
||||
import com.geeksville.mesh.model.NodeDB
|
||||
import com.geeksville.mesh.model.TextMessage
|
||||
import com.geeksville.mesh.model.UIState
|
||||
import com.geeksville.mesh.model.*
|
||||
import com.geeksville.mesh.service.*
|
||||
import com.geeksville.mesh.ui.*
|
||||
import com.geeksville.util.Exceptions
|
||||
|
|
@ -106,26 +104,8 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
bluetoothManager.adapter
|
||||
}
|
||||
|
||||
/*
|
||||
<!-- Screen.messages -> MessagesContent()
|
||||
Screen.settings -> SettingsContent()
|
||||
Screen.users -> UsersContent()
|
||||
Screen.channel -> ChannelContent(UIState.getChannel())
|
||||
Screen.map -> MapContent() -->
|
||||
private val model: UIViewModel by viewModels()
|
||||
|
||||
/--
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:icon="@drawable/ic_twotone_message_24"
|
||||
android:text="Messages"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:icon="@drawable/ic_twotone_settings_applications_24"
|
||||
android:text="Settings"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content" /> -->
|
||||
*/
|
||||
data class TabInfo(val text: String, val icon: Int, val content: Fragment)
|
||||
|
||||
// private val tabIndexes = generateSequence(0) { it + 1 } FIXME, instead do withIndex or zip? to get the ids below, also stop duplicating strings
|
||||
|
|
@ -503,6 +483,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
}) {
|
||||
override fun onConnected(service: com.geeksville.mesh.IMeshService) {
|
||||
UIState.meshService = service
|
||||
model.meshService = service
|
||||
|
||||
// We don't start listening for packets until after we are connected to the service
|
||||
registerMeshReceiver()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.os.Bundle
|
|||
import android.os.RemoteException
|
||||
import androidx.compose.mutableStateOf
|
||||
import androidx.core.content.edit
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.geeksville.android.BuildUtils.isEmulator
|
||||
|
|
@ -48,10 +49,45 @@ class UIViewModel : ViewModel(), Logging {
|
|||
var meshService: IMeshService? = null
|
||||
|
||||
/// Are we connected to our radio device
|
||||
val isConnected = MutableLiveData(MeshService.ConnectionState.DISCONNECTED)
|
||||
val isConnected =
|
||||
object : LiveData<MeshService.ConnectionState>(MeshService.ConnectionState.DISCONNECTED) {
|
||||
/**
|
||||
* Called when the number of active observers change to 1 from 0.
|
||||
*
|
||||
*
|
||||
* This callback can be used to know that this LiveData is being used thus should be kept
|
||||
* up to date.
|
||||
*/
|
||||
override fun onActive() {
|
||||
super.onActive()
|
||||
|
||||
// Get the current radio config from the service
|
||||
meshService?.let {
|
||||
debug("Getting connection state from service")
|
||||
value = MeshService.ConnectionState.valueOf(it.connectionState())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// various radio settings (including the channel)
|
||||
val radioConfig = MutableLiveData<MeshProtos.RadioConfig?>(null)
|
||||
val radioConfig = object : MutableLiveData<MeshProtos.RadioConfig?>(null) {
|
||||
/**
|
||||
* Called when the number of active observers change to 1 from 0.
|
||||
*
|
||||
*
|
||||
* This callback can be used to know that this LiveData is being used thus should be kept
|
||||
* up to date.
|
||||
*/
|
||||
override fun onActive() {
|
||||
super.onActive()
|
||||
|
||||
// Get the current radio config from the service
|
||||
meshService?.let {
|
||||
debug("Getting latest radioconfig from service")
|
||||
value = MeshProtos.RadioConfig.parseFrom(it.radioConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the radio config (also updates our saved copy in preferences)
|
||||
fun setRadioConfig(context: Context, c: MeshProtos.RadioConfig) {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="64dp"
|
||||
android:hint="Channel options"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/qrView">
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 65f39f90ce365263620d5f9cbddca0c8abebcf9a
|
||||
Subproject commit 953a657184b2d4cde8a0867d1b520e1f7190cfd6
|
||||
Loading…
Add table
Add a link
Reference in a new issue