From 6056e590994d027b3d13d24b0f1382ac94d20e5f Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:09:47 +0530 Subject: [PATCH 1/4] fixed cache clear login crash --- .gitignore | 2 ++ .../com/alfresco/content/account/Account.kt | 21 +++++++++++++++++-- auth/build.gradle | 3 ++- build.gradle | 3 +++ data/build.gradle | 3 ++- gradle/libs.versions.toml | 21 +++++++++++++++---- session/build.gradle | 3 ++- settings.gradle | 1 + 8 files changed, 48 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index ee7f30047..f79e099d0 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 d6d3eb543..d7ea47537 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 9c900faeb..38480fad0 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 8b0580709..b9ad323f1 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 854dbfd08..c08a9b31a 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 47e3a0e28..9ac2d8ddc 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 2a46f2d63..4d5bcb80c 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 1043d23a8..27a0ea55f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -24,3 +24,4 @@ include ':move' include ':component' include ':app' include ':process-app' +include ':alfresco-auth' From 20e9a70f7af776031e2a5323fe60b12aeec0c8c4 Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:14:44 +0530 Subject: [PATCH 2/4] fixed cache clear login crash --- auth/build.gradle | 3 +-- build.gradle | 3 --- data/build.gradle | 3 +-- gradle/libs.versions.toml | 21 ++++----------------- session/build.gradle | 3 +-- settings.gradle | 1 - 6 files changed, 7 insertions(+), 27 deletions(-) diff --git a/auth/build.gradle b/auth/build.gradle index 38480fad0..9c900faeb 100644 --- a/auth/build.gradle +++ b/auth/build.gradle @@ -21,8 +21,7 @@ dependencies { implementation libs.kotlin.stdlib -// api libs.alfresco.auth - api project(":alfresco-auth") + api libs.alfresco.auth implementation libs.google.material diff --git a/build.gradle b/build.gradle index b9ad323f1..8b0580709 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,3 @@ - buildscript { repositories { google() @@ -7,14 +6,12 @@ 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 c08a9b31a..854dbfd08 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -19,8 +19,7 @@ dependencies { api project(':session') implementation project(':download') -// implementation libs.alfresco.auth - implementation project(":alfresco-auth") + implementation libs.alfresco.auth implementation libs.alfresco.content implementation libs.alfresco.contentKtx diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9ac2d8ddc..47e3a0e28 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,4 +1,3 @@ - [versions] camera = "1.2.3" coil = "2.4.0" @@ -13,11 +12,12 @@ 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.1-SNAPSHOT" +alfresco-auth = "com.alfresco.android:auth:0.8.2-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,17 +136,4 @@ 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" } - -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 +constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } \ No newline at end of file diff --git a/session/build.gradle b/session/build.gradle index 4d5bcb80c..2a46f2d63 100644 --- a/session/build.gradle +++ b/session/build.gradle @@ -11,8 +11,7 @@ dependencies { implementation project(':base') api project(':account') -// implementation libs.alfresco.auth - implementation project(":alfresco-auth") + implementation libs.alfresco.auth implementation libs.alfresco.content implementation libs.kotlin.stdlib diff --git a/settings.gradle b/settings.gradle index 27a0ea55f..1043d23a8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -24,4 +24,3 @@ include ':move' include ':component' include ':app' include ':process-app' -include ':alfresco-auth' From 2139563cf41e71d538dff4c4e2978bc346f75775 Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:15:55 +0530 Subject: [PATCH 3/4] fixed cache clear login crash --- account/src/main/kotlin/com/alfresco/content/account/Account.kt | 2 -- 1 file changed, 2 deletions(-) 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 d7ea47537..204096c8a 100644 --- a/account/src/main/kotlin/com/alfresco/content/account/Account.kt +++ b/account/src/main/kotlin/com/alfresco/content/account/Account.kt @@ -67,11 +67,9 @@ data class Account( 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) } From b34d2549438a29a1b1cc88515410cd8fecff840d Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:16:38 +0530 Subject: [PATCH 4/4] fixed cache clear login crash --- account/src/main/kotlin/com/alfresco/content/account/Account.kt | 2 -- 1 file changed, 2 deletions(-) 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 204096c8a..2daaeaaa0 100644 --- a/account/src/main/kotlin/com/alfresco/content/account/Account.kt +++ b/account/src/main/kotlin/com/alfresco/content/account/Account.kt @@ -57,8 +57,6 @@ data class Account( 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