refactor: simplify setOwner logic

This commit is contained in:
andrekir 2023-05-26 16:18:02 -03:00
parent 956db658e9
commit 7ca724142f
3 changed files with 10 additions and 27 deletions

View file

@ -2,6 +2,7 @@ package com.geeksville.mesh
import android.graphics.Color
import android.os.Parcelable
import com.geeksville.mesh.MeshProtos.User
import com.geeksville.mesh.util.bearing
import com.geeksville.mesh.util.latLongToMeter
import com.geeksville.mesh.util.anonymize
@ -27,6 +28,9 @@ data class MeshUser(
return "MeshUser(id=${id.anonymize}, longName=${longName.anonymize}, shortName=${shortName.anonymize}, hwModel=${hwModelString}, isLicensed=${isLicensed})"
}
fun toProto(): User = User.newBuilder().setId(id).setLongName(longName).setShortName(shortName)
.setHwModel(hwModel).setIsLicensed(isLicensed).build()
/** a string version of the hardware model, converted into pretty lowercase and changing _ to -, and p to dot
* or null if unset
* */