Skip to content

Commit

Permalink
Merge pull request #80 from NordicSemiconductor/migration/dependencies
Browse files Browse the repository at this point in the history
Migration to latest dependencies
  • Loading branch information
philips77 authored Sep 29, 2023
2 parents 0b3fcbc + 9483b8d commit ff40394
Show file tree
Hide file tree
Showing 39 changed files with 1,705 additions and 73 deletions.
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ android {
}

dependencies {
implementation(project(":scanner"))
implementation(project(":blinky:spec"))
implementation(project(":blinky:ui"))
implementation(project(":blinky:ble"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package no.nordicsemi.android.blinky
import android.os.Bundle
import androidx.activity.compose.setContent
import dagger.hilt.android.AndroidEntryPoint
import no.nordicsemi.android.blinky.control.BlinkyDestination
import no.nordicsemi.android.blinky.scanner.ScannerDestination
import no.nordicsemi.android.blinky.ui.control.BlinkyDestination
import no.nordicsemi.android.blinky.ui.scanner.ScannerDestination
import no.nordicsemi.android.common.navigation.NavigationView
import no.nordicsemi.android.common.theme.NordicActivity
import no.nordicsemi.android.common.theme.NordicTheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.android.scopes.ViewModelScoped
import no.nordicsemi.android.blinky.ble.BlinkyManager
import no.nordicsemi.android.blinky.control.Blinky
import no.nordicsemi.android.blinky.ui.control.Blinky
import no.nordicsemi.android.blinky.spec.Blinky
import no.nordicsemi.android.blinky.spec.R
import no.nordicsemi.android.common.navigation.get
Expand Down Expand Up @@ -58,7 +58,7 @@ abstract class BlinkyModule {

@Binds
abstract fun bindBlinky(
BlinkManager: BlinkyManager
blinkyManager: BlinkyManager
): Blinky

}
2 changes: 1 addition & 1 deletion blinky/ble/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,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/AndroidLKotlinConventionPlugin.kt
// https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt
alias(libs.plugins.nordic.kotlin)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ private class BlinkyManagerImpl(
}
.stateIn(scope, SharingStarted.Lazily, Blinky.State.NOT_AVAILABLE)


private val buttonCallback by lazy {
object : ButtonCallback() {
override fun onButtonStateChanged(device: BluetoothDevice, state: Boolean) {
_buttonState.tryEmit(state)
}
}
}

private val ledCallback by lazy {
object : LedCallback() {
override fun onLedStateChanged(device: BluetoothDevice, state: Boolean) {
_ledState.tryEmit(state)
}
}
}

override suspend fun connect() = connect(device)
.retry(3, 300)
.useAutoConnect(false)
Expand Down Expand Up @@ -96,22 +113,6 @@ private class BlinkyManagerImpl(
return Log.VERBOSE
}

private val buttonCallback by lazy {
object : ButtonCallback() {
override fun onButtonStateChanged(device: BluetoothDevice, state: Boolean) {
_buttonState.tryEmit(state)
}
}
}

private val ledCallback by lazy {
object : LedCallback() {
override fun onLedStateChanged(device: BluetoothDevice, state: Boolean) {
_ledState.tryEmit(state)
}
}
}

override fun isRequiredServiceSupported(gatt: BluetoothGatt): Boolean {
// Get the LBS Service from the gatt object.
gatt.getService(BlinkySpec.BLINKY_SERVICE_UUID)?.apply {
Expand Down Expand Up @@ -164,5 +165,4 @@ private class BlinkyManagerImpl(
ledCharacteristic = null
buttonCharacteristic = null
}

}
2 changes: 1 addition & 1 deletion blinky/spec/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,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/AndroidLKotlinConventionPlugin.kt
// https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt
alias(libs.plugins.nordic.kotlin)
}

Expand Down
9 changes: 5 additions & 4 deletions blinky/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ plugins {
// https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/AndroidFeatureConventionPlugin.kt
alias(libs.plugins.nordic.feature)
// https://developer.android.com/kotlin/parcelize
id("kotlin-parcelize")
alias(libs.plugins.kotlin.parcelize)
}

android {
namespace = "no.nordicsemi.android.blinky.control"
namespace = "no.nordicsemi.android.blinky.ui"
}

dependencies {
implementation(project(":blinky:spec"))
implementation(project(":scanner"))

implementation(libs.nordic.theme)
implementation(libs.nordic.logger)
implementation(libs.nordic.uilogger)
implementation(libs.nordic.uiscanner)
implementation(libs.nordic.navigation)
implementation(libs.nordic.permission)
implementation(libs.nordic.permissions.ble)
implementation(libs.nordic.log.timber)

implementation(libs.androidx.compose.material.iconsExtended)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package no.nordicsemi.android.blinky.control
package no.nordicsemi.android.blinky.ui.control

import android.bluetooth.BluetoothDevice
import android.os.Parcelable
import androidx.hilt.navigation.compose.hiltViewModel
import kotlinx.parcelize.Parcelize
import no.nordicsemi.android.blinky.control.view.BlinkyScreen
import no.nordicsemi.android.blinky.ui.control.view.BlinkyScreen
import no.nordicsemi.android.common.navigation.createDestination
import no.nordicsemi.android.common.navigation.defineDestination
import no.nordicsemi.android.common.navigation.viewmodel.SimpleNavigationViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nordicsemi.android.blinky.control.repository
package no.nordicsemi.android.blinky.ui.control.repository

import android.content.Context
import android.net.Uri
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nordicsemi.android.blinky.control.view
package no.nordicsemi.android.blinky.ui.control.view

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nordicsemi.android.blinky.control.view
package no.nordicsemi.android.blinky.ui.control.view

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
Expand All @@ -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.control.R
import no.nordicsemi.android.blinky.control.viewmodel.BlinkyViewModel
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.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.permission.RequireBluetooth
import no.nordicsemi.android.common.permissions.ble.RequireBluetooth
import no.nordicsemi.android.common.theme.view.NordicAppBar
import no.nordicsemi.android.common.ui.scanner.view.DeviceConnectingView
import no.nordicsemi.android.common.ui.scanner.view.DeviceDisconnectedView
import no.nordicsemi.android.common.ui.scanner.view.Reason

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nordicsemi.android.blinky.control.view
package no.nordicsemi.android.blinky.ui.control.view

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
Expand All @@ -17,7 +17,7 @@ import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import no.nordicsemi.android.blinky.control.R
import no.nordicsemi.android.blinky.ui.R
import no.nordicsemi.android.common.theme.NordicTheme

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nordicsemi.android.blinky.control.view
package no.nordicsemi.android.blinky.ui.control.view

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
Expand All @@ -16,7 +16,7 @@ import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import no.nordicsemi.android.blinky.control.R
import no.nordicsemi.android.blinky.ui.R
import no.nordicsemi.android.common.theme.NordicTheme

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nordicsemi.android.blinky.control.viewmodel
package no.nordicsemi.android.blinky.ui.control.viewmodel

import android.app.Application
import android.content.Context
Expand All @@ -11,8 +11,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import no.nordicsemi.android.blinky.control.repository.BlinkyRepository
import no.nordicsemi.android.common.logger.NordicLogger
import no.nordicsemi.android.blinky.ui.control.repository.BlinkyRepository
import no.nordicsemi.android.common.logger.LoggerLauncher
import javax.inject.Inject
import javax.inject.Named

Expand Down 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() {
NordicLogger.launch(getApplication(), repository.sessionUri)
LoggerLauncher.launch(getApplication(), repository.sessionUri)
}

override fun onCleared() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package no.nordicsemi.android.blinky.scanner
package no.nordicsemi.android.blinky.ui.scanner

import androidx.hilt.navigation.compose.hiltViewModel
import no.nordicsemi.android.blinky.control.Blinky
import no.nordicsemi.android.blinky.control.BlinkyDevice
import no.nordicsemi.android.blinky.scanner.view.BlinkyScanner
import no.nordicsemi.android.blinky.ui.control.Blinky
import no.nordicsemi.android.blinky.ui.control.BlinkyDevice
import no.nordicsemi.android.blinky.ui.scanner.view.BlinkyScanner
import no.nordicsemi.android.common.navigation.createSimpleDestination
import no.nordicsemi.android.common.navigation.defineDestination
import no.nordicsemi.android.common.navigation.viewmodel.SimpleNavigationViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package no.nordicsemi.android.blinky.scanner.view
package no.nordicsemi.android.blinky.ui.scanner.view

import android.bluetooth.BluetoothDevice
import android.os.ParcelUuid
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import no.nordicsemi.android.blinky.scanner.R
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
import no.nordicsemi.android.common.ui.scanner.DeviceSelected
import no.nordicsemi.android.common.ui.scanner.ScannerScreen

@Composable
fun BlinkyScanner(
Expand Down
2 changes: 2 additions & 0 deletions blinky/ui/src/main/res/values/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
<string name="blinky_button_descr">The button state</string>
<string name="blinky_on">ON</string>
<string name="blinky_off">OFF</string>

<string name="scanner_title">nRF Blinky</string>
</resources>
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.hilt) apply false

// Nordic plugins are defined in https://github.com/NordicSemiconductor/Android-Gradle-Plugins
alias(libs.plugins.nordic.application) apply false
alias(libs.plugins.nordic.application.compose) apply false
alias(libs.plugins.nordic.library) apply false
alias(libs.plugins.nordic.library.compose) apply false
alias(libs.plugins.nordic.feature) apply false
alias(libs.plugins.nordic.kotlin) apply false
alias(libs.plugins.nordic.hilt) apply false
alias(libs.plugins.nordic.kotlin) apply false
}
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Sep 21 12:47:34 CEST 2022
#Thu Sep 28 13:02:20 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 10 additions & 5 deletions scanner/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
plugins {
// https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/AndroidFeatureConventionPlugin.kt
alias(libs.plugins.nordic.feature)
// https://developer.android.com/kotlin/parcelize
alias(libs.plugins.kotlin.parcelize)
}

android {
namespace = "no.nordicsemi.android.blinky.scanner"
namespace = "no.nordicsemi.android.scanner"
}

dependencies {
implementation(project(":blinky:spec"))
implementation(project(":blinky:ui"))

implementation(libs.nordic.uiscanner)
implementation(libs.nordic.core)
implementation(libs.nordic.theme)
implementation(libs.nordic.scanner)
implementation(libs.nordic.navigation)
implementation(libs.nordic.permissions.ble)

implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.material.iconsExtended)
}
Loading

0 comments on commit ff40394

Please sign in to comment.