Skip to content

Commit

Permalink
Merge pull request #89 from NordicSemiconductor/migration/dependencies
Browse files Browse the repository at this point in the history
Migration to latest dependencies
  • Loading branch information
philips77 authored Dec 2, 2024
2 parents 506cabe + 879f2c6 commit 720472a
Show file tree
Hide file tree
Showing 27 changed files with 425 additions and 335 deletions.
2 changes: 1 addition & 1 deletion blinky/ble/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
// /~https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt
alias(libs.plugins.nordic.library)
// /~https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt
alias(libs.plugins.nordic.kotlin)
alias(libs.plugins.nordic.kotlin.android)
}

android {
Expand Down
2 changes: 1 addition & 1 deletion blinky/spec/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
// /~https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt
alias(libs.plugins.nordic.library)
// /~https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt
alias(libs.plugins.nordic.kotlin)
alias(libs.plugins.nordic.kotlin.android)
}

android {
Expand Down
3 changes: 1 addition & 2 deletions blinky/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ dependencies {
implementation(project(":blinky:spec"))
implementation(project(":scanner"))

implementation(libs.nordic.theme)
implementation(libs.nordic.ui)
implementation(libs.nordic.logger)
implementation(libs.nordic.uilogger)
implementation(libs.nordic.navigation)
implementation(libs.nordic.permissions.ble)
implementation(libs.nordic.log.timber)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package no.nordicsemi.android.blinky.ui.control.repository

import android.content.Context
import android.net.Uri
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onEach
import no.nordicsemi.android.blinky.spec.Blinky
import no.nordicsemi.android.log.ILogSession
import no.nordicsemi.android.log.LogContract
import no.nordicsemi.android.log.timber.nRFLoggerTree
import timber.log.Timber
Expand All @@ -28,14 +28,14 @@ class BlinkyRepository @Inject constructor(
/** Timber tree that logs to nRF Logger. */
private val tree: Timber.Tree

/** If the nRF Logger is installed, this URI will allow to open the session. */
internal val sessionUri: Uri?
/** If the nRF Logger is installed, this will allow to open the session. */
internal val logSession: ILogSession?

init {
// Plant a new Tree that logs to nRF Logger.
tree = nRFLoggerTree(context, null, deviceId, deviceName)
.also { Timber.plant(it) }
.also { sessionUri = it.session?.sessionUri }
.also { logSession = it.session }
}

val loggedLedState: Flow<Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import no.nordicsemi.android.common.theme.NordicTheme

@Composable
internal fun BlinkyControlView(
Expand All @@ -34,12 +33,10 @@ internal fun BlinkyControlView(
@Preview
@Composable
private fun BlinkyControlViewPreview() {
NordicTheme {
BlinkyControlView(
ledState = true,
buttonState = true,
onStateChanged = {},
modifier = Modifier.padding(16.dp),
)
}
BlinkyControlView(
ledState = true,
buttonState = true,
onStateChanged = {},
modifier = Modifier.padding(16.dp),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import no.nordicsemi.android.blinky.spec.Blinky
import no.nordicsemi.android.blinky.ui.R
import no.nordicsemi.android.blinky.ui.control.viewmodel.BlinkyViewModel
import no.nordicsemi.android.blinky.spec.Blinky
import no.nordicsemi.android.common.logger.view.LoggerAppBarIcon
import no.nordicsemi.android.common.permissions.ble.RequireBluetooth
import no.nordicsemi.android.common.ui.view.NordicAppBar
import no.nordicsemi.android.scanner.view.DeviceConnectingView
import no.nordicsemi.android.scanner.view.DeviceDisconnectedView
import no.nordicsemi.android.scanner.view.Reason
import no.nordicsemi.android.common.logger.view.LoggerAppBarIcon
import no.nordicsemi.android.common.permissions.ble.RequireBluetooth
import no.nordicsemi.android.common.theme.view.NordicAppBar

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -38,7 +38,7 @@ internal fun BlinkyScreen(
horizontalAlignment = Alignment.CenterHorizontally,
) {
NordicAppBar(
text = viewModel.deviceName,
title = { Text(text = viewModel.deviceName) },
onNavigationButtonClick = onNavigateUp,
actions = {
LoggerAppBarIcon(onClick = { viewModel.openLogger() })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import no.nordicsemi.android.blinky.ui.R
import no.nordicsemi.android.common.theme.NordicTheme

@Composable
internal fun ButtonControlView(
Expand Down Expand Up @@ -69,10 +68,8 @@ internal fun ButtonControlView(
@Composable
@Preview
private fun ButtonControlViewPreview() {
NordicTheme {
ButtonControlView(
state = true,
modifier = Modifier.padding(16.dp),
)
}
ButtonControlView(
state = true,
modifier = Modifier.padding(16.dp),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package no.nordicsemi.android.blinky.ui.control.view

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Lightbulb
import androidx.compose.material3.MaterialTheme
Expand All @@ -17,7 +20,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import no.nordicsemi.android.blinky.ui.R
import no.nordicsemi.android.common.theme.NordicTheme

@Composable
internal fun LedControlView(
Expand Down Expand Up @@ -67,11 +69,9 @@ internal fun LedControlView(
@Composable
@Preview
private fun LecControlViewPreview() {
NordicTheme {
LedControlView(
state = true,
onStateChanged = {},
modifier = Modifier.padding(16.dp),
)
}
LedControlView(
state = true,
onStateChanged = {},
modifier = Modifier.padding(16.dp),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BlinkyViewModel @Inject constructor(
* Opens nRF Logger app with the log or Google Play if the app is not installed.
*/
fun openLogger() {
LoggerLauncher.launch(getApplication(), repository.sessionUri)
LoggerLauncher.launch(getApplication(), repository.logSession)
}

override fun onCleared() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ package no.nordicsemi.android.blinky.ui.scanner.view

import android.bluetooth.BluetoothDevice
import android.os.ParcelUuid
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import no.nordicsemi.android.blinky.spec.BlinkySpec
import no.nordicsemi.android.blinky.ui.R
import no.nordicsemi.android.scanner.DeviceSelected
import no.nordicsemi.android.scanner.ScannerScreen
import no.nordicsemi.android.blinky.spec.BlinkySpec

@Composable
fun BlinkyScanner(
onDeviceSelected: (BluetoothDevice, String?) -> Unit,
) {
ScannerScreen(
title = stringResource(id = R.string.scanner_title),
title = { Text(stringResource(id = R.string.scanner_title)) },
uuid = ParcelUuid(BlinkySpec.BLINKY_SERVICE_UUID),
cancellable = false,
onResult = { result ->
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ plugins {
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.compose.compiler) apply false

// Nordic plugins are defined in /~https://github.com/NordicSemiconductor/Android-Gradle-Plugins
alias(libs.plugins.nordic.application.compose) apply false
alias(libs.plugins.nordic.library) apply false
alias(libs.plugins.nordic.feature) apply false
alias(libs.plugins.nordic.kotlin) apply false
alias(libs.plugins.nordic.kotlin.android) apply false
alias(libs.plugins.nordic.hilt) apply false
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Thu Sep 28 13:02:20 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 720472a

Please sign in to comment.