Skip to content

Commit

Permalink
Merge pull request #3 from Emotional-Wellbeing/dominguez
Browse files Browse the repository at this point in the history
Lint project
  • Loading branch information
VicDominguez authored May 16, 2024
2 parents 5e62029 + 44989b7 commit 58a0162
Show file tree
Hide file tree
Showing 40 changed files with 75 additions and 734 deletions.
95 changes: 0 additions & 95 deletions .github/workflows/actions_dev.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/dev.yml → .github/workflows/dominguez.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test App
on:
push:
branches:
- dev
- dominguez
tags:
- '*alpha*'
- '*beta*'
Expand Down Expand Up @@ -43,4 +43,4 @@ jobs:
- name: Upload APK
uses: actions/upload-artifact@v3
with:
path: app/build/outputs/apk/debug/app-debug.apk
path: app/build/outputs/apk/debug/app-debug.apk
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![master workflow](https://github.com/Emotional-Wellbeing/App/actions/workflows/master.yml/badge.svg)
![dev workflow](https://github.com/Emotional-Wellbeing/App/actions/workflows/dev.yml/badge.svg)
![dominguez workflow](https://github.com/Emotional-Wellbeing/App/actions/workflows/dominguez.yml/badge.svg)


# SBE - App
Expand Down
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ dependencies {

// Jetpack compose
// Kotlin extensions for 'lifecycle' artifact
//noinspection GradleDependency
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
// Compose integration with Lifecycle
//noinspection GradleDependency
implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version"
// Compose integration with Lifecycle ViewModel
//noinspection GradleDependency
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"

implementation "androidx.activity:activity-compose:$activity_compose_version"
Expand Down Expand Up @@ -117,6 +120,7 @@ dependencies {
implementation "androidx.datastore:datastore-preferences:$datastore_preferences_version"

// Settings
//noinspection GradleDependency
implementation "com.github.alorma:compose-settings-ui-m3:$compose_settings_version"

// Navigation
Expand All @@ -133,7 +137,9 @@ dependencies {
ksp "io.github.raamcosta.compose-destinations:ksp:$compose_destination_version"

// Room
//noinspection GradleDependency
implementation "androidx.room:room-runtime:$room_version"
//noinspection GradleDependency
implementation "androidx.room:room-ktx:$room_version"
ksp "androidx.room:room-compiler:$room_version"

Expand All @@ -160,10 +166,13 @@ dependencies {

// Vico
// Includes the core logic for charts and other elements.
//noinspection GradleDependency
implementation "com.patrykandpatrick.vico:core:$vico_version"
// For Jetpack Compose.
//noinspection GradleDependency
implementation "com.patrykandpatrick.vico:compose:$vico_version"
// For `compose`. Creates a `ChartStyle` based on an M3 Material Theme.
//noinspection GradleDependency
implementation "com.patrykandpatrick.vico:compose-m3:$vico_version"

// Work Manager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.upm.bienestaremocional.data
package es.upm.bienestaremocional.data.crypto

import java.security.MessageDigest
import java.util.UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import javax.crypto.KeyGenerator
import javax.crypto.SecretKey

object SecretKey {
private const val secretKeyAlias = "database_key"
private const val provider = "AndroidKeyStore"
private const val algorithm = KeyProperties.KEY_ALGORITHM_AES
private const val cipherMode = KeyProperties.BLOCK_MODE_GCM
private const val SECRET_KEY_ALIAS = "database_key"
private const val PROVIDER = "AndroidKeyStore"
private const val ALGORITHM = KeyProperties.KEY_ALGORITHM_AES
private const val CIPHER_MODE = KeyProperties.BLOCK_MODE_GCM

private fun generateSecretKey(): SecretKey {
val keyGenerator = KeyGenerator.getInstance(algorithm, provider)
val keyGenerator = KeyGenerator.getInstance(ALGORITHM, PROVIDER)
val spec = KeyGenParameterSpec
.Builder(secretKeyAlias, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(cipherMode)
.Builder(SECRET_KEY_ALIAS, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(CIPHER_MODE)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
.build()

Expand All @@ -26,9 +26,9 @@ object SecretKey {

fun getSecretKey(): SecretKey {
// Get keyStore instance, no parameters at load stage are needed
val keyStore = KeyStore.getInstance(provider).apply { load(null) }
val keyStore = KeyStore.getInstance(PROVIDER).apply { load(null) }
// Get key entry
val secretKeyEntry = keyStore.getEntry(secretKeyAlias, null) as KeyStore.SecretKeyEntry?
val secretKeyEntry = keyStore.getEntry(SECRET_KEY_ALIAS, null) as KeyStore.SecretKeyEntry?
// Get the key itself or if is null generate it
return secretKeyEntry?.secretKey ?: generateSecretKey()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import es.upm.bienestaremocional.data.generateUID
import es.upm.bienestaremocional.data.crypto.generateUID
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.content.pm.PackageManager
import android.database.Cursor
import android.provider.CallLog.Calls.*
import androidx.core.content.ContextCompat
import es.upm.bienestaremocional.data.securePrivateData
import es.upm.bienestaremocional.data.crypto.securePrivateData

class PhoneInfo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,6 @@ enum class Level(
Severe("severe", R.string.severe);

companion object {
/**
* Obtain the LevelLabel from their id
* @param id: The id to query
* @return The LevelLabel if the id matches with any LevelLabel or null if doesn't
*/
fun decodeFromId(id: String): Level? {
return when (id) {
Low.id -> Low
Moderate.id -> Moderate
High.id -> High
Minimal.id -> Minimal
Mild.id -> Mild
ModeratelySevere.id -> ModeratelySevere
Severe.id -> Severe
else -> null
}
}

@Composable
fun Level.getColor(): Color {
return when (this) {
Expand Down
Loading

0 comments on commit 58a0162

Please sign in to comment.