diff --git a/.gitignore b/.gitignore index ee7f3004..f79e099d 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,5 @@ app/google-services_2.json /build-other.gradle /gradle/libs.versions-other.toml /alfresco-auth/ +/build-app.gradle +/gradle/libs.versions-app.toml diff --git a/account/src/main/kotlin/com/alfresco/content/account/Account.kt b/account/src/main/kotlin/com/alfresco/content/account/Account.kt index d6d3eb54..d7ea4753 100644 --- a/account/src/main/kotlin/com/alfresco/content/account/Account.kt +++ b/account/src/main/kotlin/com/alfresco/content/account/Account.kt @@ -54,12 +54,29 @@ data class Account( b.putString(myFilesKey, myFiles) b.putString(hostNameKey, hostName) b.putString(clientIdKey, clientId) - val acc = AndroidAccount(id, context.getString(R.string.android_auth_account_type)) + + val accountType = context.getString(R.string.android_auth_account_type) + + println("Account.createAccount == $id") + + val acc = AndroidAccount(id, accountType) // Save credentials securely using the SecureSharedPreferencesManager sharedSecure.saveCredentials(email, authState, displayName, hostName, clientId) - AccountManager.get(context).addAccountExplicitly(acc, KEY_PASSWORD, b) + val accountManager = AccountManager.get(context) + val accounts = accountManager.getAccountsByType(accountType) + + // Filter accounts with the same ID + val removeOtherAccounts = accounts.filter { it.name != id } + + if (removeOtherAccounts.isNotEmpty()) { + // If there are duplicates, remove all but one + removeOtherAccounts.forEach { account -> + accountManager.removeAccountExplicitly(account) + } + } + accountManager.addAccountExplicitly(acc, KEY_PASSWORD, b) } fun update(context: Context, id: String, authState: String) { diff --git a/auth/build.gradle b/auth/build.gradle index 9c900fae..38480fad 100644 --- a/auth/build.gradle +++ b/auth/build.gradle @@ -21,7 +21,8 @@ dependencies { implementation libs.kotlin.stdlib - api libs.alfresco.auth +// api libs.alfresco.auth + api project(":alfresco-auth") implementation libs.google.material diff --git a/build.gradle b/build.gradle index 8b058070..b9ad323f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,4 @@ + buildscript { repositories { google() @@ -6,12 +7,14 @@ buildscript { dependencies { classpath libs.android.gradle classpath libs.kotlin.gradle + classpath libs.kotlin.serialization.plugin classpath libs.objectbox classpath libs.google.services.gradle classpath libs.firebase.crashlytics.gradle + classpath libs.dokka classpath libs.spotless classpath libs.gradleVersionsPlugin classpath libs.gradleLicensePlugin diff --git a/data/build.gradle b/data/build.gradle index 854dbfd0..c08a9b31 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -19,7 +19,8 @@ dependencies { api project(':session') implementation project(':download') - implementation libs.alfresco.auth +// implementation libs.alfresco.auth + implementation project(":alfresco-auth") implementation libs.alfresco.content implementation libs.alfresco.contentKtx diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 47e3a0e2..9ac2d8dd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,3 +1,4 @@ + [versions] camera = "1.2.3" coil = "2.4.0" @@ -12,12 +13,11 @@ test = "1.5.0" activity-compose = "1.7.0" compose-bom = "2023.10.01" ui-tooling = "1.5.4" -appcompat = "1.6.1" -material = "1.11.0" constraintlayout = "2.1.4" +auth0 = "2.10.2" [libraries] -alfresco-auth = "com.alfresco.android:auth:0.8.2-SNAPSHOT" +#alfresco-auth = "com.alfresco.android:auth:0.8.1-SNAPSHOT" alfresco-content = "com.alfresco.android:content:0.3.4-SNAPSHOT" alfresco-contentKtx = "com.alfresco.android:content-ktx:0.3.2-SNAPSHOT" alfresco-process = "com.alfresco.android:process:0.1.3-SNAPSHOT" @@ -136,4 +136,17 @@ ui-compose-viewbinding = "androidx.compose.ui:ui-viewbinding:1.6.3" navigation-compose = "androidx.navigation:navigation-compose:2.7.6" compose-runtime = "androidx.compose.runtime:runtime:1.5.4" androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "ui-tooling" } -constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } \ No newline at end of file +constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } + +kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" } +kotlin-serialization-json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0" +dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.8.10" + +appauth = "net.openid:appauth:0.11.1" + +auth0 = { module = "com.auth0.android:auth0", version.ref = "auth0" } + +jwtdecode = "com.auth0.android:jwtdecode:2.0.2" +androidx-lifecycle-viewmodelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1" +androidx-browser = "androidx.browser:browser:1.5.0" +okhttp = "com.squareup.okhttp3:okhttp:4.11.0" \ No newline at end of file diff --git a/session/build.gradle b/session/build.gradle index 2a46f2d6..4d5bcb80 100644 --- a/session/build.gradle +++ b/session/build.gradle @@ -11,7 +11,8 @@ dependencies { implementation project(':base') api project(':account') - implementation libs.alfresco.auth +// implementation libs.alfresco.auth + implementation project(":alfresco-auth") implementation libs.alfresco.content implementation libs.kotlin.stdlib diff --git a/settings.gradle b/settings.gradle index 1043d23a..27a0ea55 100644 --- a/settings.gradle +++ b/settings.gradle @@ -24,3 +24,4 @@ include ':move' include ':component' include ':app' include ':process-app' +include ':alfresco-auth'