diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/resolver/HomeserverResolver.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/resolver/HomeserverResolver.kt index 7c692f5208..b1ccd8e684 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/resolver/HomeserverResolver.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/resolver/HomeserverResolver.kt @@ -19,11 +19,10 @@ package io.element.android.features.login.impl.resolver import io.element.android.features.login.impl.resolver.network.WellknownRequest import io.element.android.libraries.core.bool.orFalse import io.element.android.libraries.core.coroutine.CoroutineDispatchers +import io.element.android.libraries.core.coroutine.parallelMap import io.element.android.libraries.core.data.tryOrNull import io.element.android.libraries.core.uri.ensureProtocol import io.element.android.libraries.core.uri.isValidUrl -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll import kotlinx.coroutines.currentCoroutineContext import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow @@ -49,30 +48,28 @@ class HomeserverResolver @Inject constructor( val currentList = Collections.synchronizedList(mutableListOf()) // Run all the requests in parallel withContext(dispatchers.io) { - list.map { url -> - async { - val wellKnown = tryOrNull { - withTimeout(5000) { - wellknownRequest.execute(url) - } - } - val isValid = wellKnown?.isValid().orFalse() - if (isValid) { - val supportSlidingSync = wellKnown?.supportSlidingSync().orFalse() - // Emit the list as soon as possible - currentList.add( - HomeserverData( - homeserverUrl = url, - isWellknownValid = true, - supportSlidingSync = supportSlidingSync - ) - ) - withContext(flowContext) { - emit(currentList.toList()) - } + list.parallelMap { url -> + val wellKnown = tryOrNull { + withTimeout(5000) { + wellknownRequest.execute(url) } } - }.awaitAll() + val isValid = wellKnown?.isValid().orFalse() + if (isValid) { + val supportSlidingSync = wellKnown?.supportSlidingSync().orFalse() + // Emit the list as soon as possible + currentList.add( + HomeserverData( + homeserverUrl = url, + isWellknownValid = true, + supportSlidingSync = supportSlidingSync + ) + ) + withContext(flowContext) { + emit(currentList.toList()) + } + } + } } // If list is empty, and the user has entered an URL, do not block the user. if (currentList.isEmpty() && trimmedUserInput.isValidUrl()) { diff --git a/features/messages/impl/proguard-rules.pro b/features/messages/impl/proguard-rules.pro deleted file mode 100644 index 481bb43481..0000000000 --- a/features/messages/impl/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 \ No newline at end of file diff --git a/libraries/androidutils/proguard-rules.pro b/libraries/androidutils/proguard-rules.pro deleted file mode 100644 index 481bb43481..0000000000 --- a/libraries/androidutils/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 \ No newline at end of file diff --git a/libraries/dateformatter/api/proguard-rules.pro b/libraries/dateformatter/api/proguard-rules.pro deleted file mode 100644 index ff59496d81..0000000000 --- a/libraries/dateformatter/api/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/libraries/dateformatter/impl/proguard-rules.pro b/libraries/dateformatter/impl/proguard-rules.pro deleted file mode 100644 index ff59496d81..0000000000 --- a/libraries/dateformatter/impl/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/libraries/dateformatter/test/proguard-rules.pro b/libraries/dateformatter/test/proguard-rules.pro deleted file mode 100644 index ff59496d81..0000000000 --- a/libraries/dateformatter/test/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/libraries/designsystem/build.gradle.kts b/libraries/designsystem/build.gradle.kts index 8ffdb17cdd..35b7a65cb4 100644 --- a/libraries/designsystem/build.gradle.kts +++ b/libraries/designsystem/build.gradle.kts @@ -30,7 +30,7 @@ android { buildTypes { getByName("release") { isMinifyEnabled = true - consumerProguardFiles("proguard-rules.pro") + consumerProguardFiles("consumer-rules.pro") } } diff --git a/libraries/designsystem/consumer-rules.pro b/libraries/designsystem/consumer-rules.pro index e69de29bb2..dabf5661a4 100644 --- a/libraries/designsystem/consumer-rules.pro +++ b/libraries/designsystem/consumer-rules.pro @@ -0,0 +1,23 @@ +# 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 + +-keep class io.element.android.libraries.designsystem.showkase.DesignSystemShowkaseRootModuleCodegen { } diff --git a/libraries/designsystem/proguard-rules.pro b/libraries/designsystem/proguard-rules.pro deleted file mode 100644 index dabf5661a4..0000000000 --- a/libraries/designsystem/proguard-rules.pro +++ /dev/null @@ -1,23 +0,0 @@ -# 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 - --keep class io.element.android.libraries.designsystem.showkase.DesignSystemShowkaseRootModuleCodegen { } diff --git a/libraries/network/build.gradle.kts b/libraries/network/build.gradle.kts index e133f94ba1..f2c62188f9 100644 --- a/libraries/network/build.gradle.kts +++ b/libraries/network/build.gradle.kts @@ -20,6 +20,13 @@ plugins { android { namespace = "io.element.android.libraries.network" + + buildTypes { + release { + isMinifyEnabled = true + consumerProguardFiles("consumer-rules.pro") + } + } } anvil { diff --git a/libraries/network/consumer-rules.pro b/libraries/network/consumer-rules.pro new file mode 100644 index 0000000000..1026dca840 --- /dev/null +++ b/libraries/network/consumer-rules.pro @@ -0,0 +1,9 @@ +# From https://github.com/square/retrofit/issues/3751#issuecomment-1192043644 +# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). +-keep,allowobfuscation,allowshrinking interface retrofit2.Call +-keep,allowobfuscation,allowshrinking class retrofit2.Response + +# With R8 full mode generic signatures are stripped for classes that are not +# kept. Suspend functions are wrapped in continuations where the type argument +# is used. +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation diff --git a/samples/minimal/proguard-rules.pro b/samples/minimal/proguard-rules.pro deleted file mode 100644 index 481bb43481..0000000000 --- a/samples/minimal/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 \ No newline at end of file diff --git a/tests/uitests/proguard-rules.pro b/tests/uitests/proguard-rules.pro deleted file mode 100644 index ff59496d81..0000000000 --- a/tests/uitests/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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