mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Refactor: Improve connection state display in UI (#2353)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
5fdf383539
commit
fa0679b3f2
9 changed files with 110 additions and 88 deletions
|
|
@ -24,6 +24,7 @@ import android.content.Context
|
|||
import android.content.SharedPreferences
|
||||
import android.hardware.usb.UsbManager
|
||||
import android.os.RemoteException
|
||||
import androidx.core.content.edit
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
|
|
@ -51,8 +52,8 @@ import kotlinx.coroutines.flow.launchIn
|
|||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import javax.inject.Inject
|
||||
import org.json.JSONArray
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@Suppress("LongParameterList", "TooManyFunctions")
|
||||
|
|
@ -126,7 +127,7 @@ class BTScanModel @Inject constructor(
|
|||
}
|
||||
|
||||
// Include saved IP connections
|
||||
recent?.forEach { address ->
|
||||
recent.forEach { address ->
|
||||
addDevice(DeviceListEntry(context.getString(R.string.meshtastic), address, true))
|
||||
}
|
||||
|
||||
|
|
@ -303,9 +304,9 @@ class BTScanModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun setRecentAddresses(addresses: List<String>) {
|
||||
val editor = preferences.edit()
|
||||
editor.putString("recent-ip-addresses", addresses.toString())
|
||||
editor.apply()
|
||||
preferences.edit {
|
||||
putString("recent-ip-addresses", addresses.toString())
|
||||
}
|
||||
recentIpAddresses.value = addresses
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue