Skip to content
Open
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
15 changes: 15 additions & 0 deletions Safrando/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions Safrando/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Safrando/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Safrando/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Safrando/.idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Safrando/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Safrando/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Safrando/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
94 changes: 94 additions & 0 deletions Safrando/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'com.google.dagger.hilt.android'
}

android {
namespace 'com.nandoligeiro.safrando'
compileSdk 33

defaultConfig {
applicationId "com.nandoligeiro.safrando"
minSdk 19
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}

buildFeatures {
viewBinding = true
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.activity:activity-ktx:1.7.2"

def navigate_version = "2.6.0"
implementation "androidx.navigation:navigation-fragment-ktx:$navigate_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigate_version"


def lifecycle_version = "2.6.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"

def coroutines_version = "1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:$coroutines_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"

//DataStore
implementation "androidx.datastore:datastore-preferences:1.0.0"

def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"

def okhttp_version = "5.0.0-alpha.3"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:mockwebserver:$okhttp_version"
//HTTP LOG
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"

// Hilt DI
def hilt_version = "2.44.2"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"

def mockk_version = "1.13.5"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation "io.mockk:mockk-android:$mockk_version"
testImplementation "io.mockk:mockk-agent:$mockk_version"

testImplementation 'junit:junit:4.13.2'
testImplementation 'androidx.arch.core:core-testing:2.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
21 changes: 21 additions & 0 deletions Safrando/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.nandoligeiro.safrando

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.nandoligeiro.safrando", appContext.packageName)
}
}
32 changes: 32 additions & 0 deletions Safrando/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".SafrandoApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Safrando"
tools:targetApi="31">
<activity
android:name=".presentation.statements.view.StatementActivity"
android:exported="false" />
<activity
android:name=".presentation.login.view.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.nandoligeiro.safrando

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class SafrandoApp: Application()
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.nandoligeiro.safrando.data.api

import com.nandoligeiro.safrando.datasource.bankstatement.entity.BankStatementEntity
import com.nandoligeiro.safrando.datasource.login.entity.LoginEntity
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

interface SafrandoService {

@POST("login")
suspend fun postLogin(@Body user: String, @Body password: String): LoginEntity

@GET("statements/{id}")
suspend fun getBankStatements(@Path("id") userId: Int): List<BankStatementEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.nandoligeiro.safrando.data.bankstatement.datasource

import com.nandoligeiro.safrando.data.bankstatement.model.BankStatementData

interface BankStatementDataSource {
suspend fun getBankStatement(userId: Int): List<BankStatementData>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.nandoligeiro.safrando.data.bankstatement.mapper

import com.nandoligeiro.safrando.data.bankstatement.model.BankStatementData
import com.nandoligeiro.safrando.domain.statements.model.BankStatementDomain

class BankStatementDataToDomainMapper {

fun toDomainBankStatement(statements: List<BankStatementData>) =
statements.map { statement ->
BankStatementDomain(
nameStatement = statement.nameStatement,
description = statement.description,
amount = statement.amount,
statementDate = statement.statementDate
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.nandoligeiro.safrando.data.bankstatement.model

data class BankStatementData(
val nameStatement: String,
val description: String,
val amount: String,
val statementDate: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.nandoligeiro.safrando.data.bankstatement.repository

import com.nandoligeiro.safrando.data.bankstatement.datasource.BankStatementDataSource
import com.nandoligeiro.safrando.data.bankstatement.mapper.BankStatementDataToDomainMapper
import com.nandoligeiro.safrando.domain.statements.repository.BankStatementRepository
import javax.inject.Inject

class BankStatementRepositoryImpl @Inject constructor(
private val dataSource: BankStatementDataSource,
private val toDomainMapper: BankStatementDataToDomainMapper
) : BankStatementRepository {
override suspend fun getBankStatement(
userId: Int
) = toDomainMapper.toDomainBankStatement(dataSource.getBankStatement(userId))

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.nandoligeiro.safrando.data.login.datasource

import kotlinx.coroutines.flow.Flow

interface LocalLoginDataSource {
suspend fun saveLogin(user: String)
suspend fun getLocalLogin(): Flow<String>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.nandoligeiro.safrando.data.login.datasource

import com.nandoligeiro.safrando.data.login.model.LoginData

interface RemoteLoginDataSource {
suspend fun postLogin(user: String, password: String): LoginData
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nandoligeiro.safrando.data.login.mapper

import com.nandoligeiro.safrando.data.login.model.LoginData
import com.nandoligeiro.safrando.domain.login.model.LoginDomain

class LoginDataToDomainMapper {
fun toDomainLogin(login: LoginData) = LoginDomain(
id = 1,
name = login.name,
agency = login.agency,
account = login.account,
balance = login.balance
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nandoligeiro.safrando.data.login.model

data class LoginData(
val id: Int,
val name: String,
val agency: String,
val account: String,
val balance: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nandoligeiro.safrando.data.login.repository

import com.nandoligeiro.safrando.data.login.datasource.LocalLoginDataSource
import com.nandoligeiro.safrando.domain.login.repository.LocalLoginRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class LocalLoginRepositoryImpl @Inject constructor(
private val localLoginDataSource: LocalLoginDataSource,
) : LocalLoginRepository {
override suspend fun save(user: String) = localLoginDataSource.saveLogin(user)

override suspend fun getUser() = localLoginDataSource.getLocalLogin()
}
Loading