Skip to content

Commit

Permalink
Merge pull request #367 from NordicSemiconductor/migration/commons
Browse files Browse the repository at this point in the history
Migration to nordic.common libs 1.0.25
  • Loading branch information
philips77 authored Oct 6, 2022
2 parents ccf296f + cfa7b38 commit f44a644
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 119 deletions.
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ dependencies {
implementation project(":lib_storage")
implementation project(":profile_dfu")

implementation "no.nordicsemi.android.common:theme:1.0.24"
implementation "no.nordicsemi.android.common:navigation:1.0.24"
implementation "no.nordicsemi.android.common:theme:$nordic_common_version"
implementation "no.nordicsemi.android.common:navigation:$nordic_common_version"

implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material3:material3:1.0.0-beta03"
implementation "androidx.compose.material3:material3:$material3_version"
implementation "androidx.activity:activity-compose:1.6.0"

implementation "com.google.dagger:hilt-android:2.43.2"
kapt "com.google.dagger:hilt-compiler:2.43.2"
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation "com.google.dagger:hilt-android:$dagger_version"
kapt "com.google.dagger:hilt-compiler:$dagger_version"
// kapt "androidx.hilt:hilt-compiler:1.0.0"
}
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/NordicTheme">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:theme="@style/AppTheme.SplashScreen">
android:theme="@style/NordicTheme.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class MainActivity : NordicActivity() {

setContent {
NordicTheme {
Surface {
NavigationView(DFUDestinations + ScannerDestinations)
}
NavigationView(DFUDestinations + ScannerDestinations)
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
buildscript {

ext {
compose_version = '1.3.0-beta03'
compose_compiler_version = '1.3.0'
kotlin_version = '1.7.10'
kotlin_version = '1.7.20'
compose_version = '1.3.0-rc01'
compose_compiler_version = '1.3.2'
material3_version = '1.0.0-rc01'
dagger_version = '2.44'
nordic_common_version = '1.0.25'

android_api_version = 33
android_min_api_version_dfu = 18
android_min_api_version = 21
Expand All @@ -20,7 +24,7 @@ buildscript {
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath "io.spring.gradle:dependency-management-plugin:1.0.12.RELEASE"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.43.2"
classpath "com.google.dagger:hilt-android-gradle-plugin:$dagger_version"
classpath "com.autonomousapps:dependency-analysis-gradle-plugin:1.11.3"
// https://plugins.gradle.org/plugin/io.github.gradle-nexus.publish-plugin
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
Expand Down
8 changes: 3 additions & 5 deletions lib_analytics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ android {
}

dependencies {
implementation "no.nordicsemi.android.common:analytics:1.0.24"
implementation "no.nordicsemi.android.common:analytics:$nordic_common_version"

implementation 'com.google.dagger:hilt-android:2.43.2'
kapt 'com.google.dagger:hilt-compiler:2.43.2'
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
kapt 'androidx.hilt:hilt-compiler:1.0.0'
implementation "com.google.dagger:hilt-android:$dagger_version"
kapt "com.google.dagger:hilt-compiler:$dagger_version"
}
5 changes: 2 additions & 3 deletions lib_storage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ android {
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"

implementation "com.google.dagger:hilt-android:2.43.2"
kapt "com.google.dagger:hilt-compiler:2.43.2"
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation "com.google.dagger:hilt-android:$dagger_version"
kapt "com.google.dagger:hilt-compiler:$dagger_version"
}
23 changes: 11 additions & 12 deletions profile_dfu/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,24 @@ dependencies {
implementation project(":lib_dfu")
implementation project(":lib_storage")

implementation "no.nordicsemi.android.common:core:1.0.24"
implementation "no.nordicsemi.android.common:theme:1.0.24"
implementation "no.nordicsemi.android.common:navigation:1.0.24"
implementation "no.nordicsemi.android.common:uiscanner:1.0.24"
implementation "no.nordicsemi.android.common:uilogger:1.0.24"
implementation "no.nordicsemi.android.common:permission:1.0.24"
implementation "no.nordicsemi.android.common:analytics:1.0.24"
implementation "no.nordicsemi.android.common:core:$nordic_common_version"
implementation "no.nordicsemi.android.common:theme:$nordic_common_version"
implementation "no.nordicsemi.android.common:navigation:$nordic_common_version"
implementation "no.nordicsemi.android.common:uiscanner:$nordic_common_version"
implementation "no.nordicsemi.android.common:uilogger:$nordic_common_version"
implementation "no.nordicsemi.android.common:permission:$nordic_common_version"
implementation "no.nordicsemi.android.common:analytics:$nordic_common_version"

implementation "androidx.compose.material3:material3:1.0.0-beta03"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material3:material3:$material3_version"
implementation "androidx.compose.material:material-icons-core:$compose_version"
implementation "androidx.compose.material:material-icons-extended:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.core:core-ktx:1.9.0"
implementation "androidx.activity:activity-compose:1.6.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0-alpha02"
implementation "androidx.datastore:datastore-preferences:1.0.0"

implementation "com.google.dagger:hilt-android:2.43.2"
kapt "com.google.dagger:hilt-compiler:2.43.2"
implementation "com.google.dagger:hilt-android:$dagger_version"
kapt "com.google.dagger:hilt-compiler:$dagger_version"
implementation "androidx.hilt:hilt-navigation-compose:1.0.0"
kapt "androidx.hilt:hilt-compiler:1.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Upload
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -130,67 +129,60 @@ private fun DFUIdleProgressView(

@Composable
private fun ProgressItem(viewEntity: ProgressItemViewEntity) {
Column(
modifier = Modifier.padding(start = 8.dp)
) {
ProgressItem(
text = BootloaderItem.toDisplayString(status = viewEntity.bootloaderStatus),
status = viewEntity.bootloaderStatus,
iconRightPadding = 24.dp,
)
Spacer(modifier = Modifier.size(8.dp))
ProgressItem(
text = BootloaderItem.toDisplayString(status = viewEntity.bootloaderStatus),
status = viewEntity.bootloaderStatus,
iconRightPadding = 24.dp,
)

ProgressItem(
text = DfuItem.toDisplayString(status = viewEntity.dfuStatus),
status = viewEntity.dfuStatus,
iconRightPadding = 24.dp,
)

if (viewEntity.installationStatus == ProgressItemStatus.WORKING) {
ProgressItem(
text = DfuItem.toDisplayString(status = viewEntity.dfuStatus),
status = viewEntity.dfuStatus,
text = viewEntity.progress.toLabel(),
status = viewEntity.installationStatus,
iconRightPadding = 24.dp,
)
Spacer(modifier = Modifier.size(8.dp))

if (viewEntity.installationStatus == ProgressItemStatus.WORKING) {
Column {
ProgressItem(
text = viewEntity.progress.toLabel(),
status = viewEntity.installationStatus,
iconRightPadding = 24.dp,
) {
LinearProgressIndicator(
progress = viewEntity.progress.progress / 100f,
modifier = Modifier.fillMaxWidth()
)
Text(
text = stringResource(
id = R.string.dfu_display_status_progress_speed,
viewEntity.progress.avgSpeed
),
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.End
)
}
}
} else {
ProgressItem(
text = FirmwareItem.toDisplayString(status = viewEntity.installationStatus),
status = viewEntity.installationStatus,
iconRightPadding = 24.dp,
) {
LinearProgressIndicator(
progress = viewEntity.progress.progress / 100f,
modifier = Modifier.fillMaxWidth()
)
}
Spacer(modifier = Modifier.size(8.dp))
if (viewEntity.resultStatus != ProgressItemStatus.ERROR) {
ProgressItem(
text = stringResource(id = R.string.dfu_progress_stage_completed),
status = viewEntity.resultStatus,
iconRightPadding = 24.dp,
)
} else {
ProgressItem(
Text(
text = stringResource(
id = R.string.dfu_progress_stage_error,
viewEntity.errorMessage ?: stringResource(id = R.string.dfu_unknown)
id = R.string.dfu_display_status_progress_speed,
viewEntity.progress.avgSpeed
),
status = viewEntity.resultStatus,
iconRightPadding = 24.dp,
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.End
)
}
} else {
ProgressItem(
text = FirmwareItem.toDisplayString(status = viewEntity.installationStatus),
status = viewEntity.installationStatus,
iconRightPadding = 24.dp,
)
}

if (viewEntity.resultStatus != ProgressItemStatus.ERROR) {
ProgressItem(
text = stringResource(id = R.string.dfu_progress_stage_completed),
status = viewEntity.resultStatus,
iconRightPadding = 24.dp,
)
} else {
ProgressItem(
text = stringResource(
id = R.string.dfu_progress_stage_error,
viewEntity.errorMessage ?: stringResource(id = R.string.dfu_unknown)
),
status = viewEntity.resultStatus,
iconRightPadding = 24.dp,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,22 @@

package no.nordicsemi.android.dfu.profile.main.view

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -54,6 +56,7 @@ import no.nordicsemi.android.common.theme.view.NordicAppBar
import no.nordicsemi.android.dfu.profile.R
import no.nordicsemi.android.dfu.profile.main.viewmodel.DFUViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DFUScreen() {
val viewModel: DFUViewModel = hiltViewModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,14 @@ internal fun DFUSelectedDeviceView(
),
state = WizardStepState.COMPLETED,
) {
Column {
Text(
text = String.format(DEVICE_NAME, viewEntity.device.displayName ?: "No name").parseBold(),
style = MaterialTheme.typography.bodyMedium
)

Spacer(modifier = Modifier.size(4.dp))
Text(
text = String.format(DEVICE_NAME, viewEntity.device.displayName ?: "No name").parseBold(),
style = MaterialTheme.typography.bodyMedium
)

Text(
text = String.format(DEVICE_ADDRESS, viewEntity.device.address).parseBold(),
style = MaterialTheme.typography.bodyMedium,
)
}
Text(
text = String.format(DEVICE_ADDRESS, viewEntity.device.address).parseBold(),
style = MaterialTheme.typography.bodyMedium,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,19 @@ internal fun DFUNotSelectedFileView(viewEntity: NotSelectedFileViewEntity, onEve
),
state = WizardStepState.CURRENT,
) {
Column {
Text(
text = stringResource(id = R.string.dfu_choose_info),
style = MaterialTheme.typography.bodyMedium,
)
if (viewEntity.isError) {
Spacer(modifier = Modifier.size(8.dp))

Text(
text = stringResource(id = R.string.dfu_choose_info),
style = MaterialTheme.typography.bodyMedium,
text = stringResource(id = R.string.dfu_load_file_error),
style = MaterialTheme.typography.labelMedium,
modifier = Modifier.padding(horizontal = 16.dp),
color = MaterialTheme.colorScheme.error
)
if (viewEntity.isError) {
Spacer(modifier = Modifier.size(8.dp))
Text(
text = stringResource(id = R.string.dfu_load_file_error),
style = MaterialTheme.typography.labelMedium,
modifier = Modifier.padding(horizontal = 16.dp),
color = MaterialTheme.colorScheme.error
)
}
}
}
}
Expand Down Expand Up @@ -163,8 +162,6 @@ internal fun DFUSelectFileView(
style = MaterialTheme.typography.bodyMedium
)

Spacer(modifier = Modifier.size(4.dp))

Text(
text = String.format(FILE_SIZE, zipFile.size).parseBold(),
style = MaterialTheme.typography.bodyMedium,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import no.nordicsemi.android.dfu.BuildConfig.VERSION_NAME
import no.nordicsemi.android.dfu.profile.R
import no.nordicsemi.android.dfu.profile.settings.viewmodel.SettingsViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun SettingsScreen() {
val viewModel = hiltViewModel<SettingsViewModel>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import no.nordicsemi.android.common.theme.view.NordicAppBar
import no.nordicsemi.android.dfu.profile.R
import no.nordicsemi.android.dfu.profile.welcome.viewmodel.WelcomeViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun WelcomeScreen() {
val viewModel = hiltViewModel<WelcomeViewModel>()
Expand Down

0 comments on commit f44a644

Please sign in to comment.