Skip to content

Commit 1682f27

Browse files
Merge pull request #95 from NordicSemiconductor/bugfix/swipe-to-delete
Swipe to delete
2 parents fedcf99 + af379ca commit 1682f27

File tree

91 files changed

+1924
-1984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1924
-1984
lines changed

app/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ dependencies {
5454
implementation(project(":feature:application-keys"))
5555
implementation(project(":feature:scenes"))
5656
implementation(project(":feature:provisioners"))
57-
implementation(project(":feature:ranges"))
5857
implementation(project(":feature:export"))
5958
implementation(project(":mesh:core"))
6059
implementation(project(":mesh:provisioning"))

app/proguard-rules.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@
1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
2121
#-renamesourcefileattribute SourceFile
22-
-keep class no.nordicsemi.android.nrfmesh.core.navigation.ClickableSetting { *; }
22+
-keep class no.nordicsemi.android.nrfmesh.core.navigation.ClickableSetting { *; }
23+
-keep class no.nordicsemi.kotlin.mesh.** { *; }
24+
-dontwarn no.nordicsemi.kotlin.mesh.**

app/src/main/java/no/nordicsemi/android/nrfmesh/ui/network/NetworkRoute.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fun NetworkRoute(
280280
keyboardOptions = KeyboardOptions(
281281
capitalization = KeyboardCapitalization.Characters
282282
),
283-
regex = Regex("[0-9A-Fa-f]{0,4}"),
283+
regex = Regex("^[0-9A-Fa-f]{0,4}$"),
284284
isError = isError,
285285
)
286286
Row(

core/common/src/main/java/no/nordicsemi/android/nrfmesh/core/common/Utils.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ import no.nordicsemi.kotlin.mesh.core.exception.SceneInUse
4545
import no.nordicsemi.kotlin.mesh.core.exception.SecurityException
4646
import no.nordicsemi.kotlin.mesh.core.layers.access.AccessError
4747
import no.nordicsemi.kotlin.mesh.logger.LogLevel
48+
import kotlin.concurrent.atomics.AtomicLong
49+
import kotlin.concurrent.atomics.ExperimentalAtomicApi
50+
import kotlin.concurrent.atomics.incrementAndFetch
4851

4952
/**
5053
* Helper object containing utility methods.
@@ -127,3 +130,15 @@ fun copyToClipboard(
127130
clipboard.setClipEntry(clipEntry = ClipEntry(clipData = clip))
128131
}
129132
}
133+
134+
object KeyIdGenerator {
135+
@OptIn(ExperimentalAtomicApi::class)
136+
private val counter = AtomicLong(0)
137+
138+
/**
139+
* Generates the next unique ID. This is a helper method used to generate unique IDs for keys in
140+
* a LazyColumn
141+
*/
142+
@OptIn(ExperimentalAtomicApi::class)
143+
fun nextId() = counter.incrementAndFetch()
144+
}

core/data/src/main/java/no/nordicsemi/android/nrfmesh/core/data/CoreDataRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class CoreDataRepository @Inject constructor(
229229
* @param boundNetworkKey Bound Network Key
230230
*/
231231
fun addApplicationKey(
232-
name: String = "Application Key ${meshNetwork.applicationKeys.size}",
232+
name: String = "Application Key ${meshNetwork.applicationKeys.size + 1}",
233233
boundNetworkKey: NetworkKey,
234234
): ApplicationKey = meshNetwork.add(
235235
name = name,

core/data/src/main/java/no/nordicsemi/android/nrfmesh/core/data/bearer/AndroidGattBearer.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class AndroidGattBearer(
2222
peripheral = peripheral
2323
) {
2424
@OptIn(ExperimentalUuidApi::class)
25-
override suspend fun open() {
26-
super.open()
25+
override suspend fun configurePeripheral(peripheral: Peripheral) {
2726
// Request highest connection parameters after connect in the super.open()
2827
peripheral.requestHighestValueLength()
2928
}

core/data/src/main/java/no/nordicsemi/android/nrfmesh/core/data/bearer/AndroidPbGattBearer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class AndroidPbGattBearer(
2222
peripheral = peripheral
2323
) {
2424
@OptIn(ExperimentalUuidApi::class)
25-
override suspend fun open() {
26-
super.open()
25+
override suspend fun configurePeripheral(peripheral: Peripheral) {
2726
// Request highest connection parameters after connect in the super.open()
2827
peripheral.requestHighestValueLength()
28+
2929
}
3030
}

core/data/src/main/java/no/nordicsemi/android/nrfmesh/core/data/models/ApplicationKeyData.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,44 @@
22

33
package no.nordicsemi.android.nrfmesh.core.data.models
44

5+
import no.nordicsemi.android.nrfmesh.core.common.KeyIdGenerator
56
import no.nordicsemi.kotlin.mesh.core.model.ApplicationKey
67
import no.nordicsemi.kotlin.mesh.core.model.KeyIndex
7-
import no.nordicsemi.kotlin.mesh.core.model.NetworkKey
8+
import kotlin.uuid.ExperimentalUuidApi
89

910
/**
1011
* Application Keys are used to secure communications at the upper transport layer.
1112
* The application key (AppKey) shall be generated using a random number generator
1213
* compatible with the requirements in Volume 2, Part H, Section 2 of the Core Specification [1].
1314
*
14-
* @property index The index property contains an integer from 0 to 4095 that
15-
* represents the NetKey index for this network key.
1615
* @property name Human-readable name for the application functionality associated
1716
* with this application key.
18-
* @property boundNetKeyIndex The boundNetKey property contains a corresponding Network Key index
19-
* of the network key in the mesh network.
17+
* @property index The index property contains an integer from 0 to 4095 that
18+
* represents the NetKey index for this network key.
2019
* @property key 128-bit application key.
2120
* @property oldKey OldKey property contains the previous application key.
22-
* @property boundNetworkKey Network key to which this application key is bound to.
23-
* @param key 128-bit application key.
21+
* @property boundNetKeyIndex The boundNetKey property contains a corresponding Network Key index
22+
* of the network key in the mesh network.
23+
* @property isInUse True if the application key is currently in use in the mesh network.
2424
*/
25+
@OptIn(ExperimentalUuidApi::class)
2526
data class ApplicationKeyData(
2627
val name: String,
2728
val index: KeyIndex,
2829
val key: ByteArray,
2930
val oldKey: ByteArray? = null,
3031
val boundNetKeyIndex: KeyIndex,
31-
val boundNetworkKey: NetworkKey?,
32-
val isInUse: Boolean
32+
val boundNetworkKeyName: String,
33+
val isInUse: Boolean,
34+
val id: Long = KeyIdGenerator.nextId()
3335
) {
3436
constructor(key: ApplicationKey) : this(
3537
name = key.name,
3638
index = key.index,
3739
key = key.key,
3840
oldKey = key.oldKey,
39-
boundNetKeyIndex = key.boundNetKeyIndex,
40-
boundNetworkKey = key.boundNetworkKey,
41+
boundNetKeyIndex = key.boundNetworkKey.index,
42+
boundNetworkKeyName = key.boundNetworkKey.name,
4143
isInUse = key.isInUse
4244
)
4345

@@ -55,7 +57,6 @@ data class ApplicationKeyData(
5557
if (!oldKey.contentEquals(other.oldKey)) return false
5658
} else if (other.oldKey != null) return false
5759
if (boundNetKeyIndex != other.boundNetKeyIndex) return false
58-
if (boundNetworkKey != other.boundNetworkKey) return false
5960
if (isInUse != other.isInUse) return false
6061

6162
return true
@@ -67,7 +68,6 @@ data class ApplicationKeyData(
6768
result = 31 * result + key.contentHashCode()
6869
result = 31 * result + (oldKey?.contentHashCode() ?: 0)
6970
result = 31 * result + boundNetKeyIndex.hashCode()
70-
result = 31 * result + (boundNetworkKey?.hashCode() ?: 0)
7171
result = 31 * result + isInUse.hashCode()
7272
return result
7373
}

core/data/src/main/java/no/nordicsemi/android/nrfmesh/core/data/models/NetworkKeyData.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package no.nordicsemi.android.nrfmesh.core.data.models
44

5+
import no.nordicsemi.android.nrfmesh.core.common.KeyIdGenerator
56
import kotlin.time.Instant
67
import no.nordicsemi.kotlin.mesh.core.model.KeyIndex
78
import no.nordicsemi.kotlin.mesh.core.model.KeyRefreshPhase
@@ -56,7 +57,8 @@ data class NetworkKeyData internal constructor(
5657
val oldNetworkId: ByteArray?,
5758
val timestamp: Instant,
5859
val isPrimary: Boolean,
59-
val isInUse: Boolean
60+
val isInUse: Boolean,
61+
val id: Long = KeyIdGenerator.nextId(),
6062
) {
6163
/**
6264
* Convenience constructor for creating a new network key

core/data/src/main/java/no/nordicsemi/android/nrfmesh/core/data/models/NodeData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ data class NodeData internal constructor(
140140
excluded = node.excluded,
141141
heartbeatPublication = node.heartbeatPublication,
142142
heartbeatSubscription = node.heartbeatSubscription,
143-
primaryElementData = node.primaryElement?.let { ElementData(it) },
143+
primaryElementData = ElementData(node.primaryElement),
144144
elementsCount = node.elementsCount,
145145
addresses = node.addresses,
146146
unicastRange = node.unicastRange,

0 commit comments

Comments
 (0)