mirror of
https://github.com/mollyim/mollyim-android.git
synced 2025-05-12 21:30:39 +01:00
parent
75a14fe543
commit
6351f730a2
5 changed files with 10 additions and 3 deletions
|
@ -41,6 +41,9 @@ class UnifiedPushValues(store: KeyValueStore) : SignalStoreValues(store) {
|
|||
.apply()
|
||||
}
|
||||
|
||||
fun isMollySocketDevice(deviceId: Int): Boolean =
|
||||
deviceId != 0 && getInteger(MOLLYSOCKET_DEVICE_ID, 0) == deviceId
|
||||
|
||||
var registrationStatus: RegistrationStatus
|
||||
get() = RegistrationStatus.fromValue(getInteger(MOLLYSOCKET_STATUS, -1)) ?: RegistrationStatus.UNKNOWN
|
||||
set(status) {
|
||||
|
|
|
@ -3,4 +3,4 @@ package org.thoughtcrime.securesms.linkdevice
|
|||
/**
|
||||
* Class that represents a linked device
|
||||
*/
|
||||
data class Device(val id: Int, val name: String?, val createdMillis: Long, val lastSeenMillis: Long)
|
||||
data class Device(val id: Int, val name: String?, val createdMillis: Long, val lastSeenMillis: Long, val canRename: Boolean = true)
|
||||
|
|
|
@ -578,6 +578,7 @@ fun DeviceRow(device: Device, setDeviceToRemove: (Device) -> Unit, onEditDevice:
|
|||
)
|
||||
}
|
||||
},
|
||||
enabled = device.canRename,
|
||||
onClick = {
|
||||
onEditDevice(device)
|
||||
controller.hide()
|
||||
|
|
|
@ -85,7 +85,8 @@ object LinkDeviceRepository {
|
|||
}
|
||||
|
||||
private fun DeviceInfo.toDevice(): Device {
|
||||
val defaultDevice = Device(getId(), getName(), getCreated(), getLastSeen())
|
||||
val canRename = !SignalStore.unifiedpush.isMollySocketDevice(getId())
|
||||
val defaultDevice = Device(getId(), getName(), getCreated(), getLastSeen(), canRename = canRename)
|
||||
try {
|
||||
if (getName().isNullOrEmpty() || getName().length < 4) {
|
||||
Log.w(TAG, "Invalid DeviceInfo name.")
|
||||
|
@ -104,7 +105,7 @@ object LinkDeviceRepository {
|
|||
return defaultDevice
|
||||
}
|
||||
|
||||
return Device(getId(), String(plaintext), getCreated(), getLastSeen())
|
||||
return Device(getId(), String(plaintext), getCreated(), getLastSeen(), canRename = canRename)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed while reading the protobuf.", e)
|
||||
}
|
||||
|
|
|
@ -60,12 +60,14 @@ object DropdownMenus {
|
|||
contentPadding: PaddingValues = PaddingValues(horizontal = 16.dp),
|
||||
text: @Composable () -> Unit,
|
||||
onClick: () -> Unit,
|
||||
enabled: Boolean = true,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
contentPadding = contentPadding,
|
||||
text = text,
|
||||
onClick = onClick,
|
||||
enabled = enabled,
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue