Skip to content
Snippets Groups Projects
Commit f5754b63 authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Merge branch 'gradle_refactor' into origin/xxclient

parents 14c07bc7 ab4fe097
No related branches found
No related tags found
No related merge requests found
Showing
with 1 addition and 339 deletions
Elixxir dApps SDK Kotlin
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="11" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/buildSrc" />
<option value="$PROJECT_DIR$/cmix" />
<option value="$PROJECT_DIR$/depconstraints" />
<option value="$PROJECT_DIR$/xxclient" />
</set>
</option>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
/build
\ No newline at end of file
plugins {
id("com.android.library")
kotlin("android")
kotlin("kapt")
}
android {
compileSdk = Config.COMPILE_SDK
defaultConfig {
minSdk = Config.MIN_SDK
targetSdk = Config.TARGET_SDK
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
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"
}
}
dependencies {
implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs")))
implementation((project(":cmix")))
api(platform(project(":depconstraints")))
kapt(platform(project(":depconstraints")))
androidTestApi(platform(project(":depconstraints")))
implementation(Libs.CORE_KTX)
implementation(Libs.COROUTINES)
implementation(Libs.TIMBER)
testImplementation(Libs.JUNIT)
testImplementation(Libs.TRUTH)
androidTestImplementation(Libs.ESPRESSO_CORE)
androidTestImplementation(Libs.EXT_JUNIT)
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# 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
\ No newline at end of file
package io.elixxir.dapp
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("io.elixxir.dapp", appContext.packageName)
}
}
\ No newline at end of file
<?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="io.elixxir.dapp">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:targetApi="31" />
</manifest>
\ No newline at end of file
package io.elixxir.dapp
import io.elixxir.dapp.android.model.AndroidConfig
import io.elixxir.dapp.api.model.*
import io.elixxir.dapp.logger.data.Logger
import io.elixxir.dapp.api.model.CommonProperties
import io.elixxir.dapp.api.model.DappConfig
/**
* Singleton entry point to modules provided by the dApp SDK.
*/
class DappModule private constructor(
config: DappConfig,
logger: Logger = Logger.newInstance(config.loggerConfig)
) : DappApi,
AndroidConfig by config.androidConfig,
Logger by logger,
CommonProperties
{
override val accountApi: AccountApi
get() = TODO("Not yet implemented")
override val directoryApi: DirectoryApi
get() = TODO("Not yet implemented")
override val messagesApi: MessagesApi
get() = TODO("Not yet implemented")
override val networkApi: NetworkApi
get() = TODO("Not yet implemented")
override val requestsApi: RequestsApi
get() = TODO("Not yet implemented")
override val groupsApi: GroupsApi
get() = TODO("Not yet implemented")
companion object {
@Volatile
private var instance: DappModule? = null
fun getInstance(config: DappConfig): DappModule {
return instance ?: DappModule(config).apply {
instance = this
}
}
}
}
\ No newline at end of file
package io.elixxir.dapp.android.data
import android.content.Context
import io.elixxir.dapp.android.model.AndroidConfig
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
data class DefaultAndroidConfig(
override val context: () -> Context,
override val dispatcher: CoroutineDispatcher = Dispatchers.IO,
) : AndroidConfig
\ No newline at end of file
package io.elixxir.dapp.android.model
import android.content.Context
import kotlinx.coroutines.CoroutineDispatcher
/**
* Android-specific properties used at runtime.
*/
interface AndroidConfig {
val context: () -> Context
val dispatcher: CoroutineDispatcher
}
\ No newline at end of file
package io.elixxir.dapp.api.data
import io.elixxir.dapp.api.model.AccountApi
import io.elixxir.dapp.backup.model.Backup
import io.elixxir.dapp.session.repository.SessionDataSource
import io.elixxir.dapp.user.model.User
import io.elixxir.dapp.user.model.UserUpdateData
import kotlinx.coroutines.*
internal class AccountModule(
private val sessionManager: SessionDataSource
) : AccountApi {
private val scope: CoroutineScope = CoroutineScope(
CoroutineName("AccountModule")
+ Job()
+ Dispatchers.Default
)
override fun getCurrentUser(): User {
TODO("Not yet implemented")
}
override fun createAccount(username: String) {
scope.launch {
sessionManager.createSession()
}
}
override fun restoreAccount(backup: Backup) {
TODO("Not yet implemented")
}
override fun updateAccount(updateData: UserUpdateData) {
TODO("Not yet implemented")
}
override fun deleteAccount() {
scope.launch {
sessionManager.deleteSession()
}
}
}
\ No newline at end of file
package io.elixxir.dapp.api.data
import io.elixxir.dapp.api.model.NetworkApi
import io.elixxir.dapp.network.model.ConnectionStatus
import io.elixxir.dapp.network.data.NetworkManager
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.Flow
internal class NetworkModule(
private val networkManager: NetworkManager
) : NetworkApi {
private val scope: CoroutineScope = CoroutineScope(
CoroutineName("AccountModule")
+ Job()
+ Dispatchers.Default
)
override val connectionStatus: Flow<ConnectionStatus> by networkManager::connectionStatus
override fun connect(): Result<ConnectionStatus> {
TODO("Not yet implemented")
}
override fun disconnect(): Result<ConnectionStatus> {
TODO("Not yet implemented")
}
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.backup.model.Backup
import io.elixxir.dapp.user.model.User
import io.elixxir.dapp.user.model.UserUpdateData
interface AccountApi {
fun getCurrentUser(): User
fun createAccount(username: String)
fun restoreAccount(backup: Backup)
fun updateAccount(updateData: UserUpdateData)
fun deleteAccount()
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.android.model.AndroidConfig
import io.elixxir.dapp.logger.data.Logger
internal interface CommonProperties : Logger, AndroidConfig
\ No newline at end of file
package io.elixxir.dapp.api.model
interface DappApi {
val accountApi: AccountApi
val directoryApi: DirectoryApi
val messagesApi: MessagesApi
val networkApi: NetworkApi
val requestsApi: RequestsApi
val groupsApi: GroupsApi
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.android.model.AndroidConfig
import io.elixxir.dapp.logger.model.LoggerConfig
import io.elixxir.dapp.network.model.NetworkConfig
/**
* Describes configurable options, and satisfies dependencies for,
* modules exposed by the dApps Kotlin SDK.
*/
interface DappConfig {
val androidConfig: AndroidConfig
val loggerConfig: LoggerConfig
val networkConfig: NetworkConfig
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.user.model.User
import io.elixxir.dapp.user.model.UserQuery
interface DirectoryApi {
fun getContacts(): List<User>
fun findUser(params: UserQuery): User?
fun blockUser(user: User)
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.group.model.Group
import io.elixxir.dapp.messaging.model.Message
import io.elixxir.dapp.user.model.User
import kotlinx.coroutines.flow.Flow
interface GroupsApi {
val groupMessages: Flow<Message>
fun sendInvitation(group: Group)
fun resendInvitation(member: User)
fun joinGroup(group: Group)
fun leaveGroup(group: Group)
fun sendMessage(message: Message, group: Group)
fun retryMessage(message: Message, group: Group)
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.messaging.model.Message
import io.elixxir.dapp.user.model.User
import kotlinx.coroutines.flow.Flow
interface MessagesApi {
val messages: Flow<Message>
fun sendMessage(message: Message, recipient: User)
fun retryMessage(message: Message, recipient: User)
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment