Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7] - Release Teira 1.0 #72

Merged
merged 18 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build_artifact_and_release_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
java-version: '17'
cache: 'gradle'

- name: Update Secrets
env:
MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }}
run: echo 'MAPS_API_KEY=${{ secrets.MAPS_API_KEY }}' > ./local.properties

- name: Build the Release AAB
run: ./gradlew bundleRelease
env:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pull_request_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ jobs:
java-version: '17'
cache: 'gradle'

- name: Update Secrets
env:
MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }}
run: echo 'MAPS_API_KEY=${{ secrets.MAPS_API_KEY }}' > ./local.properties
- name: Unit tests
run: ./gradlew testQa
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ plugins {
id 'kotlin-kapt'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}

android {
compileSdk 33
compileSdk 34
namespace 'br.com.tick.teira'

defaultConfig {
Expand Down Expand Up @@ -101,6 +102,7 @@ dependencies {
implementation "androidx.hilt:hilt-work:$hiltWorkVersion"
implementation "androidx.work:work-runtime-ktx:$workManagerVersion"


kapt "androidx.hilt:hilt-compiler:$hiltCompilerVersion"
kapt "com.google.dagger:hilt-compiler:$hiltVersion"

Expand Down
24 changes: 20 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/teira_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/teira_launcher"
android:supportsRtl="true"
android:theme="@style/Theme.Teira"
tools:targetApi="31">

<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -31,6 +32,21 @@
android:authorities="${applicationId}.androidx-startup"
tools:node="remove">
</provider>
</application>

</manifest>
<!-- Holds information to google maps api -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${MAPS_API_KEY}" />

<!-- Setup for holding reference and creating files for photos -->
<provider
android:name="br.com.tick.utils.ComposeFileProvider"
android:authorities="br.com.tick.teira.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
</application>
</manifest>
74 changes: 74 additions & 0 deletions app/src/main/res/drawable/teira_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>
5 changes: 0 additions & 5 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

This file was deleted.

5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/teira_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/teira_launcher_background"/>
<foreground android:drawable="@mipmap/teira_launcher_foreground"/>
</adaptive-icon>
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/teira_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/teira_launcher_background"/>
<foreground android:drawable="@mipmap/teira_launcher_foreground"/>
</adaptive-icon>
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-hdpi/teira_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-mdpi/teira_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-xhdpi/teira_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/teira_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ buildscript {
composeMaterialVersion = '1.2.0-beta03'
composeFoundation = '1.4.0-alpha03'
composeUi = '1.4.0-alpha03'
composeUiUtil = '1.5.0'
composeMaterial3Version = '1.1.0-rc01'
coroutinesVersion = '1.6.4'
coreKtxVersion = '1.9.0'
Expand All @@ -22,7 +23,7 @@ buildscript {
hiltNavigationComposeVersion = '1.0.0'
roomVersion = '2.4.3'
dataStoreVersion = '1.0.0'
navigationVersion = '2.5.3'
navigationVersion = '2.7.0'
vicoVersion = '1.6.4'
composeColorPicker = '0.7.0'
firebaseCrashlytics = '18.3.5'
Expand All @@ -31,6 +32,10 @@ buildscript {
hiltWorkVersion = '1.0.0'
hiltCompilerVersion = '1.0.0'
acompanistPermissionVersion = '0.30.0'
googleMaps = '2.14.0'
playServicesMap = '18.1.0'
playServicesLocation = '21.0.1'
coilVersion = '2.4.0'

dependencies {
classpath("com.google.dagger:hilt-android-gradle-plugin:$hiltVersion")
Expand All @@ -47,6 +52,7 @@ plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
}

task clean(type: Delete) {
Expand Down
3 changes: 2 additions & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

android {
compileSdk 33
compileSdk 34
namespace 'br.com.tick.sdk'

defaultConfig {
Expand Down Expand Up @@ -48,6 +48,7 @@ dependencies {
kapt "com.google.dagger:hilt-compiler:$hiltVersion"

implementation "androidx.datastore:datastore-preferences:$dataStoreVersion"
implementation "com.google.android.gms:play-services-maps:$playServicesMap"

// Unit Tests dependencies
testImplementation "junit:junit:$jUnitVersion"
Expand Down
7 changes: 7 additions & 0 deletions sdk/src/main/java/br/com/tick/sdk/database/ExpenseDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package br.com.tick.sdk.database
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import br.com.tick.sdk.database.entities.Expense
import kotlinx.coroutines.flow.Flow

Expand All @@ -12,6 +13,9 @@ interface ExpenseDao {
@Insert
suspend fun addExpense(expense: Expense)

@Update
suspend fun updateExpense(expense: Expense)

@Query("DELETE FROM expense WHERE expense_id = :expenseId")
suspend fun removeExpenseById(expenseId: Int)

Expand All @@ -20,4 +24,7 @@ interface ExpenseDao {

@Query("SELECT * FROM expense")
fun getAllExpenses(): Flow<List<Expense>>

@Query("SELECT * FROM expense WHERE expense_id = :expenseId")
fun getExpense(expenseId: Int): Flow<Expense>
}
2 changes: 1 addition & 1 deletion sdk/src/main/java/br/com/tick/sdk/database/UserDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlinx.coroutines.flow.Flow
interface UserDao {

@Query("SELECT * FROM user WHERE user_id = 1")
fun getUniqueUser(): Flow<User>
fun getUniqueUser(): Flow<User?>

@Insert(onConflict = OnConflictStrategy.ABORT)
fun setInitialUser(user: User)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package br.com.tick.sdk.database.converters

import androidx.room.TypeConverter
import com.google.android.gms.maps.model.LatLng

class LatLngConverter {

companion object {
const val LAT_LNG_SPLITTER = "|"
}

@TypeConverter
fun toString(location: LatLng?): String? {
if (location == null) return null

return "${location.latitude}$LAT_LNG_SPLITTER${location.longitude}"
}

@TypeConverter
fun fromString(location: String?): LatLng? {
if (location == null) return null

val locationFromString = location.split(LAT_LNG_SPLITTER)
return LatLng(locationFromString[0].toDouble(), locationFromString[1].toDouble())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class LocalDateConverter {
fun fromLong(value: Long): LocalDate {
return LocalDate.ofEpochDay(value)
}
}
}
13 changes: 11 additions & 2 deletions sdk/src/main/java/br/com/tick/sdk/database/entities/Expense.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import br.com.tick.sdk.database.converters.LatLngConverter
import br.com.tick.sdk.database.converters.LocalDateConverter
import com.google.android.gms.maps.model.LatLng
import java.time.LocalDate

@Entity
@TypeConverters(LocalDateConverter::class)
@TypeConverters(LocalDateConverter::class, LatLngConverter::class)
data class Expense(

@PrimaryKey(autoGenerate = true)
Expand All @@ -25,5 +27,12 @@ data class Expense(
val value: Double,

@ColumnInfo(name = "date")
val date: LocalDate
val date: LocalDate,

@ColumnInfo(name = "location")
val location: LatLng?,

@ColumnInfo(name = "photoUri")
val photoUri: String?

)
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package br.com.tick.sdk.domain

import android.net.Uri
import com.google.android.gms.maps.model.LatLng
import java.time.LocalDate

data class CategorizedExpense(
val expenseId: Int,
val name: String,
val expenseValue: Double,
val date: LocalDate,
val category: ExpenseCategory
val category: ExpenseCategory,
val location: LatLng?,
val picture: Uri?
)
5 changes: 1 addition & 4 deletions sdk/src/main/java/br/com/tick/sdk/domain/ExpenseRisk.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package br.com.tick.sdk.domain

/**
* This class holds business logic to determine weather an expense value is categorized as certain threshold.
*/
enum class ExpenseRisk(private val percentageThreshold: Double) {
HIGHEST(20.0),
HIGH(10.0),
Expand All @@ -12,7 +9,7 @@ enum class ExpenseRisk(private val percentageThreshold: Double) {

companion object {
fun getRiskFromValue(monthlyIncome: Double, expenseValue: Double): ExpenseRisk {
require(expenseValue > 0) { "There's no way to calculate risks for a negative value. What is that anyway?" }
require(expenseValue >= 0) { "There's no way to calculate risks for a negative value. What is that anyway?" }

return when ((expenseValue * 100) / monthlyIncome) {
in 0.0..LOWEST.percentageThreshold -> LOWEST
Expand Down
Loading