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
28 changes: 21 additions & 7 deletions androidApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
compileSdkVersion 33
defaultConfig {
applicationId "org.mifos.openbanking"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -38,19 +38,29 @@ android {
}

dependencies {

constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation 'com.google.code.gson:gson:2.8.6'
testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

Expand All @@ -75,3 +85,7 @@ dependencies {
// SHIMMER ANIMATION
implementation 'com.facebook.shimmer:shimmer:0.5.0'
}

configurations {
all*.exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-serialization-runtime-jvm'
}
2 changes: 1 addition & 1 deletion androidApp/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
9 changes: 8 additions & 1 deletion androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.mifos.openbanking">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:name=".MifosOpenBankingApplication"
Expand All @@ -18,7 +24,8 @@
<activity
android:name=".auth.LoginActivity"
android:windowSoftInputMode="adjustPan"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
25 changes: 13 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.72'
ext.sql_delight_version = "1.4.0"
ext.kotlin_version = '1.7.20'
ext.sql_delight_version = "1.5.4"
repositories {
google()
jcenter()


mavenCentral()
maven { url "https://dl.bintray.com/kodein-framework/Kodein-DI/org/kodein/di/" }
maven { url "https://repo1.maven.org/maven2/org/kodein/di/" }

}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

classpath 'com.android.tools.build:gradle:4.0.1'
classpath "com.android.tools.build:gradle:7.3.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "com.squareup.sqldelight:gradle-plugin:$sql_delight_version"
Expand All @@ -28,22 +28,23 @@ allprojects {
repositories {
google()
jcenter()
mavenCentral()


maven { url = uri("https://dl.bintray.com/icerockdev/moko") }
maven { url "https://dl.bintray.com/florent37/maven" }
maven { url "https://dl.bintray.com/kodein-framework/Kodein-DI" }
maven { url = uri("https://repo1.maven.org/maven2/dev/icerock/moko") }
maven { url = uri("https://repo1.maven.org/maven2/org/kodein/di") }
maven { url = uri("https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core") }
}
}

ext {
coroutine_version = "1.3.2"
serializer_version = "0.20.0"
coroutine_version = "1.3.8"
serializer_core_version = "1.0-M1-1.4.0-rc"
serializer_native_version = "0.20.0-1.4-M1-release-99"
serializer_json_version = "1.5.1"
ktor_version = "1.3.2"
kodeinVersion = "6.5.3"
moko_mvvm_version = "0.6.0"
moko_mvvm_version = "0.10.0"
mockk_version = "1.9.3"
preferences_version = "1.0.0"
}

task clean(type: Delete) {
Expand Down
40 changes: 23 additions & 17 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ apply plugin: 'com.android.library'
apply plugin: 'com.squareup.sqldelight'

android {
compileSdkVersion(29)
compileSdkVersion(33)

defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
targetSdkVersion(33)
}

// By default the android gradle plugin expects to find the kotlin source files in
Expand All @@ -31,11 +31,20 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += ["-Xskip-prerelease-check"]
}
}
configurations {
create("androidTestApi")
create("androidTestDebugApi")
create("androidTestReleaseApi")
create("testApi")
create("testDebugApi")
create("testReleaseApi")
}
}

kotlin {
Expand Down Expand Up @@ -66,13 +75,16 @@ kotlin {
api 'org.jetbrains.kotlin:kotlin-stdlib-common'

// COROUTINES
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutine_core_version"

// MOKO - MVVM
implementation "dev.icerock.moko:mvvm:$moko_mvvm_version"

// SERIALIZATION
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializer_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializer_core_version"

// SERIALIZATION - JSON Format
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serializer_json_version"

// KODE IN
implementation "org.kodein.di:kodein-di-core:$kodeinVersion"
Expand All @@ -81,9 +93,6 @@ kotlin {
// KTOR
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-auth-native:$ktor_version"

// Preferences
implementation "com.github.florent37:multiplatform-preferences:$preferences_version"
}

androidMain.dependencies {
Expand All @@ -93,20 +102,17 @@ kotlin {
// COROUTINES
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"

// MOKO - MVVM
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$androidx_lifecycle_version"

// SERIALIZATION
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializer_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializer_core_version"

// KTOR
implementation "io.ktor:ktor-client-android:$ktor_version"

// SQL Delight
implementation "com.squareup.sqldelight:android-driver:$sql_delight_version"

// Preferences
implementation "com.github.florent37:multiplatform-preferences-android:$preferences_version"
}

iosMain.dependencies {
Expand All @@ -116,22 +122,22 @@ kotlin {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutine_version"

// SERIALIZATION
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serializer_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serializer_native_version"

// KTOR
implementation "io.ktor:ktor-client-ios:$ktor_version"

// SQL Delight
implementation "com.squareup.sqldelight:native-driver:$sql_delight_version"

// Preferences
implementation "com.github.florent37:multiplatform-preferences-ios:$preferences_version"
}

commonTest.dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
implementation "io.mockk:mockk:$mockk_version"
implementation "junit:junit:4.13.2"
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions common/src/androidMainTest/kotlin/SampleTestsAndroid.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.mifos.openbanking.common

import org.junit.Assert.assertTrue
import org.junit.Test
import org.mifos.openbanking.hello
import kotlin.test.Test
import kotlin.test.assertTrue

class SampleTestsAndroid {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.mifos.openbanking.data.datasources.disk.preferencesHelper

import com.github.florent37.preferences.Preferences
import kotlinx.serialization.builtins.list
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.mifos.openbanking.domain.usecase.fetchBanks.Bank
import org.mifos.openbanking.viewModel.model.UserModel
Expand All @@ -13,23 +13,103 @@ class PreferencesHelper {
private val supportedBanksKey: String = "supported_banks"

fun saveUserModel(userModel: UserModel) {
preferences.setString(userModelKey, Json.stringify(UserModel.serializer(), userModel))
preferences.setString(userModelKey, Json.encodeToString(userModel))
}

fun getUserModel(): UserModel? {
return if (preferences.hasKey(userModelKey)) {
Json.parse(UserModel.serializer(), preferences.getString(userModelKey)!!)
Json.decodeFromString(UserModel.serializer(),preferences.getString(userModelKey)!!)
} else {
null
}
}


fun saveSupportedBanks(bankList: List<Bank>) {
preferences.setString(supportedBanksKey, Json.stringify(Bank.serializer().list, bankList))
preferences.setString(supportedBanksKey, Json.encodeToString(bankList))
}


fun getSupportedBanks(): List<Bank> {
return Json.parse(Bank.serializer().list, preferences.getString(supportedBanksKey)!!)
return Json.decodeFromString(ListSerializer(Bank.serializer()), preferences.getString(supportedBanksKey)!!)
}
}

class Preferences(private val name: String? = null) {

private val preferences = mutableMapOf<String, Any>()

fun setInt(key: String, value: Int) {
preferences[key] = value
}

}
fun getInt(key: String, defaultValue: Int): Int {
return preferences[key] as? Int? ?: defaultValue
}

fun getInt(key: String): Int? {
return preferences[key] as? Int
}

fun setFloat(key: String, value: Float) {
preferences[key] = value
}

fun getFloat(key: String, defaultValue: Float): Float {
return preferences[key] as? Float? ?: defaultValue
}

fun getFloat(key: String): Float? {
return preferences[key] as? Float
}

fun setLong(key: String, value: Long) {
preferences[key] = value
}

fun getLong(key: String, defaultValue: Long): Long {
return preferences[key] as? Long? ?: defaultValue
}

fun getLong(key: String): Long? {
return preferences[key] as? Long
}

fun setString(key: String, value: String) {
preferences[key] = value
}

fun getString(key: String, defaultValue: String): String {
return preferences[key] as? String? ?: defaultValue
}

fun getString(key: String): String? {
return preferences[key] as? String
}

fun setBoolean(key: String, value: Boolean) {
preferences[key] = value
}

fun getBoolean(key: String, defaultValue: Boolean): Boolean {
return preferences[key] as? Boolean? ?: defaultValue
}

fun getBoolean(key: String): Boolean? {
return preferences[key] as? Boolean
}

fun remove(key: String) {
preferences.remove(key)
}

fun clear() {
preferences.clear()
}

fun hasKey(key: String): Boolean {
return preferences.containsKey(key)
}
}


Loading