Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iakanoe committed Oct 27, 2023
0 parents commit 037823b
Show file tree
Hide file tree
Showing 65 changed files with 2,363 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .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 .idea/.gitignore

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

1 change: 1 addition & 0 deletions .idea/.name

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

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

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

17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

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

32 changes: 32 additions & 0 deletions .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 .idea/kotlinc.xml

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

12 changes: 12 additions & 0 deletions .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 .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 app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
88 changes: 88 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

plugins {
kotlin("kapt")
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.dagger.hilt.android")
}

android {
namespace = "io.iakanoe.github.dolarcito"
compileSdk = 34

defaultConfig {
applicationId = "io.iakanoe.github.dolarcito"
minSdk = 27
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}

buildConfigField("String", "API_KEY", gradleLocalProperties(rootDir).getProperty("API_KEY"))
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

buildFeatures {
compose = true
buildConfig = true
}

composeOptions {
kotlinCompilerExtensionVersion = "1.5.3"
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

kapt {
correctErrorTypes = true
}

dependencies {
implementation("com.google.dagger:hilt-android:2.48")
kapt("com.google.dagger:hilt-android-compiler:2.48")

implementation("androidx.hilt:hilt-navigation-compose:1.1.0-rc01")

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2")
implementation("androidx.activity:activity-compose:1.8.0")
implementation("androidx.navigation:navigation-compose:2.7.4")
implementation("androidx.datastore:datastore-preferences:1.0.0")

implementation(platform("androidx.compose:compose-bom:2023.10.01"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}
21 changes: 21 additions & 0 deletions 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
32 changes: 32 additions & 0 deletions 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=".DolarcitoApplication"
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.Dolarcito"
tools:targetApi="31">

<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.Dolarcito">
<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 io.iakanoe.github.dolarcito

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

@HiltAndroidApp
class DolarcitoApplication : Application()
21 changes: 21 additions & 0 deletions app/src/main/java/io/iakanoe/github/dolarcito/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.iakanoe.github.dolarcito

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import dagger.hilt.android.AndroidEntryPoint
import io.iakanoe.github.dolarcito.ui.DolarcitoNavigation
import io.iakanoe.github.dolarcito.ui.common.theme.DolarcitoTheme

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
DolarcitoTheme {
DolarcitoNavigation()
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.iakanoe.github.dolarcito.data

import io.iakanoe.github.dolarcito.gateway.DolarcitoApiGateway

class ExchangeRateRepository(
private val apiGateway: DolarcitoApiGateway
) {
suspend fun getExchangeRates() =
apiGateway.getRates().values.filterNotNull()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.iakanoe.github.dolarcito.data

import io.iakanoe.github.dolarcito.gateway.SettingsGateway
import io.iakanoe.github.dolarcito.model.Settings
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine

class SettingsRepository(
private val settingsGateway: SettingsGateway
) {
fun getSettings(): Flow<Settings> {
val showingRatesNames = settingsGateway.retrieveShowingRatesNames()
val hiddenRatesNames = settingsGateway.retrieveHiddenRatesNames()
return combine(showingRatesNames, hiddenRatesNames) { showing, hidden ->
Settings(showing, hidden)
}
}

suspend fun setSettings(settings: Settings) =
settingsGateway.saveBothRatesNames(settings.showingRatesNames, settings.hiddenRatesNames)
}
33 changes: 33 additions & 0 deletions app/src/main/java/io/iakanoe/github/dolarcito/di/GatewayModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.iakanoe.github.dolarcito.di

import android.content.Context
import com.google.gson.Gson
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import io.iakanoe.github.dolarcito.gateway.DolarcitoApiGateway
import io.iakanoe.github.dolarcito.gateway.SettingsGateway
import retrofit2.Retrofit
import retrofit2.create
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object GatewayModule {

@Provides
@Singleton
fun providesDolarcitoApiGateway(
retrofit: Retrofit
) = retrofit.create<DolarcitoApiGateway>()

@Provides
@Singleton
fun providesSettingsGateway(
@ApplicationContext context: Context,
gson: Gson
) = SettingsGateway(context, gson)

}
17 changes: 17 additions & 0 deletions app/src/main/java/io/iakanoe/github/dolarcito/di/GsonModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.iakanoe.github.dolarcito.di

import com.google.gson.Gson
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object GsonModule {

@Provides
@Singleton
fun provideGson() = Gson()
}
Loading

0 comments on commit 037823b

Please sign in to comment.