From 9ed04e811954dbf85867a9465171eee2463aba7c Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Wed, 2 Jun 2021 09:43:30 +0200 Subject: [PATCH 01/12] add keystore to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6853ad7..cbd4bd7 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ Thumbs.db google-services.json agconnect-services.json hms.properties +keystore From 5d97303f665f44ed13072b1073bb31636b07d2b2 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Wed, 2 Jun 2021 11:00:37 +0200 Subject: [PATCH 02/12] update gradle version and target sdk version --- ChoiceSDK/build.gradle | 2 +- ChoiceSDK/choicesdk-app/build.gradle | 4 ++-- ChoiceSDK/choicesdk-app/src/main/AndroidManifest.xml | 1 - .../main/java/com/bluesource/choicesdk_app/map/MapActivity.kt | 1 - ChoiceSDK/gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ChoiceSDK/build.gradle b/ChoiceSDK/build.gradle index 4078078..cc73a30 100644 --- a/ChoiceSDK/build.gradle +++ b/ChoiceSDK/build.gradle @@ -22,7 +22,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.1.3' + classpath 'com.android.tools.build:gradle:4.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.jaredsburrows:gradle-license-plugin:0.8.80' diff --git a/ChoiceSDK/choicesdk-app/build.gradle b/ChoiceSDK/choicesdk-app/build.gradle index 097ed94..e9f30cf 100644 --- a/ChoiceSDK/choicesdk-app/build.gradle +++ b/ChoiceSDK/choicesdk-app/build.gradle @@ -18,7 +18,7 @@ def hmsProperties = new Properties() hmsProperties.load(new FileInputStream(hmsPropertiesFile)) android { - compileSdkVersion 29 + compileSdkVersion 30 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -28,7 +28,7 @@ android { defaultConfig { applicationId "com.bluesource.choicesdk_app" minSdkVersion 19 - targetSdkVersion 29 + targetSdkVersion 30 versionCode project.versionCode versionName project.appVersionName multiDexEnabled true diff --git a/ChoiceSDK/choicesdk-app/src/main/AndroidManifest.xml b/ChoiceSDK/choicesdk-app/src/main/AndroidManifest.xml index caa4e4b..8d40579 100644 --- a/ChoiceSDK/choicesdk-app/src/main/AndroidManifest.xml +++ b/ChoiceSDK/choicesdk-app/src/main/AndroidManifest.xml @@ -11,7 +11,6 @@ - Date: Mon, 7 Jun 2021 08:49:57 +0200 Subject: [PATCH 03/12] refactor map fragment initialization in demo app --- .../com/bluesource/choicesdk_app/map/MapActivity.kt | 13 +++++-------- documentation/map.md | 9 ++++----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/map/MapActivity.kt b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/map/MapActivity.kt index 318b7fc..af7afd9 100644 --- a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/map/MapActivity.kt +++ b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/map/MapActivity.kt @@ -14,8 +14,6 @@ import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat -import androidx.fragment.app.FragmentManager -import androidx.fragment.app.FragmentTransaction import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.location.common.FusedLocationProviderClient import at.bluesource.choicesdk.location.factory.FusedLocationProviderFactory @@ -36,12 +34,11 @@ class MapActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_map) - val fragmentManager: FragmentManager = supportFragmentManager - val fragmentTransaction: FragmentTransaction = fragmentManager.beginTransaction() - - mapFragment = MapFragment.newInstance() - fragmentTransaction.add(R.id.mapContainer, mapFragment) - fragmentTransaction.commit() + supportFragmentManager.beginTransaction().apply { + mapFragment = MapFragment.newInstance() + add(R.id.mapContainer, mapFragment) + commit() + } if (!hasPermissions(this)) { ActivityCompat.requestPermissions(this, PERMISSIONS, 3) diff --git a/documentation/map.md b/documentation/map.md index 4e3cdb7..a3ac8fd 100644 --- a/documentation/map.md +++ b/documentation/map.md @@ -21,12 +21,11 @@ If the app accesses the user's current location by enabling the `MyLocation` lay Create the map fragment and add it to a `FrameLayout` with id `mapContainer`: ```kotlin -val fragmentManager: FragmentManager = supportFragmentManager -val fragmentTransaction: FragmentTransaction = fragmentManager.beginTransaction() - val mapFragment: MapFragment = MapFragment.newInstance() -fragmentTransaction.add(R.id.mapContainer, mapFragment) -fragmentTransaction.commit() +supportFragmentManager.beginTransaction().apply { + add(R.id.mapContainer, mapFragment) + commit() +} ``` Working with the map: From ad65a710b69aa6c1c152d4066328608813bf6af7 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 07:34:02 +0200 Subject: [PATCH 04/12] bump version to 0.2.0 --- ChoiceSDK/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChoiceSDK/build.gradle b/ChoiceSDK/build.gradle index cc73a30..085fcee 100644 --- a/ChoiceSDK/build.gradle +++ b/ChoiceSDK/build.gradle @@ -8,9 +8,9 @@ buildscript { } project.ext.buildNumber = buildNumber - project.ext.sdkVersionName = "0.1.6" + project.ext.sdkVersionName = "0.2.0" project.ext.appVersionName = "${project.sdkVersionName}.${project.buildNumber}" - project.ext.versionCode = 7 + project.ext.versionCode = 8 project.ext.groupId = "at.bluesource.choicesdk" ext.kotlin_version = "1.4.32" From 820bc0509a40b70742fe8959932973b226fd74e3 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 07:34:38 +0200 Subject: [PATCH 05/12] update Kotlin to 1.5.20 and gradle plugin version to 4.2.2 --- ChoiceSDK/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChoiceSDK/build.gradle b/ChoiceSDK/build.gradle index 085fcee..69b4e9e 100644 --- a/ChoiceSDK/build.gradle +++ b/ChoiceSDK/build.gradle @@ -13,7 +13,7 @@ buildscript { project.ext.versionCode = 8 project.ext.groupId = "at.bluesource.choicesdk" - ext.kotlin_version = "1.4.32" + ext.kotlin_version = "1.5.20" repositories { google() @@ -22,7 +22,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.2.1' + classpath 'com.android.tools.build:gradle:4.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.jaredsburrows:gradle-license-plugin:0.8.80' From 748e6184fd7eeb07450a755b994e67e932d2cfe3 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 07:34:51 +0200 Subject: [PATCH 06/12] update nexus publish plugin to 1.1.0 --- ChoiceSDK/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChoiceSDK/build.gradle b/ChoiceSDK/build.gradle index 69b4e9e..cf75104 100644 --- a/ChoiceSDK/build.gradle +++ b/ChoiceSDK/build.gradle @@ -40,7 +40,7 @@ buildscript { plugins { id("org.jetbrains.dokka") version "1.4.0" - id "io.github.gradle-nexus.publish-plugin" version "1.0.0" + id "io.github.gradle-nexus.publish-plugin" version "1.1.0" } allprojects { From 63deb99579c8e70fd2a6eacc02d62bc13ad41555 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 07:35:15 +0200 Subject: [PATCH 07/12] fix warnings in location sdk --- .../location/common/LocationAvailability.kt | 20 +++----- .../location/common/LocationRequest.kt | 51 +++++++++---------- .../location/common/LocationSettingsStates.kt | 6 +-- 3 files changed, 33 insertions(+), 44 deletions(-) diff --git a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationAvailability.kt b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationAvailability.kt index 1eac4a7..d1b5497 100644 --- a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationAvailability.kt +++ b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationAvailability.kt @@ -23,33 +23,25 @@ interface LocationAvailability { @Suppress("ExplicitThis") companion object { - fun extractLocationAvailability(intent: Intent?): LocationAvailability? { + fun extractLocationAvailability(intent: Intent): LocationAvailability? { return when { MobileServicesDetector.isGmsAvailable() -> { - return com.google.android.gms.location.LocationAvailability.extractLocationAvailability( - intent - )?.toChoiceLocationAvailability() + return com.google.android.gms.location.LocationAvailability.extractLocationAvailability(intent).toChoiceLocationAvailability() } MobileServicesDetector.isHmsAvailable() -> { - return com.huawei.hms.location.LocationAvailability.extractLocationAvailability( - intent - ).toChoiceLocationAvailability() + return com.huawei.hms.location.LocationAvailability.extractLocationAvailability(intent).toChoiceLocationAvailability() } else -> null } } - fun hasLocationAvailability(intent: Intent?): Boolean { + fun hasLocationAvailability(intent: Intent): Boolean { return when { MobileServicesDetector.isGmsAvailable() -> { - return com.google.android.gms.location.LocationAvailability.hasLocationAvailability( - intent - ) + return com.google.android.gms.location.LocationAvailability.hasLocationAvailability(intent) } MobileServicesDetector.isHmsAvailable() -> { - return com.huawei.hms.location.LocationAvailability.hasLocationAvailability( - intent - ) + return com.huawei.hms.location.LocationAvailability.hasLocationAvailability(intent) } else -> false } diff --git a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationRequest.kt b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationRequest.kt index d5fc4f6..c8add78 100644 --- a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationRequest.kt +++ b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationRequest.kt @@ -181,36 +181,35 @@ interface LocationRequest { } internal fun LocationRequest.toGmsLocationRequest(): com.google.android.gms.location.LocationRequest { - return com.google.android.gms.location.LocationRequest().also { - it.setSmallestDisplacement(smallestDisplacement) - .setNumUpdates(numUpdates) - .setMaxWaitTime(maxWaitTime) - .setInterval(interval) - .setFastestInterval(fastestInterval) - .setExpirationTime(expirationTime) - .setExpirationDuration(expirationDuration) - .setPriority(priority) - } + return com.google.android.gms.location.LocationRequest.create() + .setSmallestDisplacement(smallestDisplacement) + .setNumUpdates(numUpdates) + .setMaxWaitTime(maxWaitTime) + .setInterval(interval) + .setFastestInterval(fastestInterval) + .setExpirationTime(expirationTime) + .setExpirationDuration(expirationDuration) + .setPriority(priority) } internal fun LocationRequest.toHmsLocationRequest(): com.huawei.hms.location.LocationRequest { - return com.huawei.hms.location.LocationRequest().also { - it.setSmallestDisplacement(smallestDisplacement) - .setNumUpdates(numUpdates) - .setMaxWaitTime(maxWaitTime) - .setInterval(interval) - .setFastestInterval(fastestInterval) - .setExpirationTime(expirationTime) - .setExpirationDuration(expirationDuration) - .setNeedAddress(needAddress) - .setLanguage(language) - .setCountryCode(countryCode) - .setPriority(priority) - - extras?.forEach { entry -> - it.putExtras(entry.key, entry.value) + return com.huawei.hms.location.LocationRequest.create() + .setSmallestDisplacement(smallestDisplacement) + .setNumUpdates(numUpdates) + .setMaxWaitTime(maxWaitTime) + .setInterval(interval) + .setFastestInterval(fastestInterval) + .setExpirationTime(expirationTime) + .setExpirationDuration(expirationDuration) + .setNeedAddress(needAddress) + .setLanguage(language) + .setCountryCode(countryCode) + .setPriority(priority) + .apply { + extras?.forEach { entry -> + putExtras(entry.key, entry.value) + } } - } } } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt index 4223a7a..8a02d5a 100644 --- a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt +++ b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt @@ -28,12 +28,10 @@ interface LocationSettingsStates { return when { MobileServicesDetector.isGmsAvailable() -> { - com.google.android.gms.location.LocationSettingsStates.fromIntent(intent) - .toChoiceLocationSettingsStates() + com.google.android.gms.location.LocationSettingsStates.fromIntent(intent)?.toChoiceLocationSettingsStates() } MobileServicesDetector.isHmsAvailable() -> { - com.huawei.hms.location.LocationSettingsStates.fromIntent(intent) - .toChoiceLocationSettingsStates() + com.huawei.hms.location.LocationSettingsStates.fromIntent(intent)?.toChoiceLocationSettingsStates() } else -> null } From 2b443ef6ad7df7f6b22095a4d5a84d8ac773e1a0 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 09:18:27 +0200 Subject: [PATCH 08/12] HUAW-101 add possibility to prioritize mobile services to SDK initializer --- .../analytics/factory/AnalyticsFactory.kt | 30 +++-------- .../bluesource/choicesdk_app/MainActivity.kt | 12 +++-- .../messages/MessagesActivity.kt | 24 +++++---- .../at/bluesource/choicesdk/core/ChoiceSdk.kt | 17 +++++- .../choicesdk/core/MobileService.kt | 12 +++++ .../choicesdk/core/MobileServicesDetector.kt | 26 +++++++-- .../location/common/LocationAvailability.kt | 27 +++++----- .../location/common/LocationSettingsStates.kt | 15 +++--- .../factory/FusedLocationProviderFactory.kt | 24 +++------ .../location/factory/SettingsClientFactory.kt | 54 +++++++------------ .../maps/common/CameraUpdateFactory.kt | 25 +++++---- .../common/CameraUpdateFactoryProvider.kt | 15 ++---- .../choicesdk/maps/common/LatLng.kt | 12 ++--- .../choicesdk/maps/common/LatLngBounds.kt | 15 +++--- .../choicesdk/maps/common/MapFragment.kt | 9 ++-- .../choicesdk/maps/common/MapOptions.kt | 8 +-- .../choicesdk/maps/common/MapView.kt | 15 +++--- .../choicesdk/maps/common/MapsInitializer.kt | 8 +-- .../common/SphericalMercatorProjection.kt | 8 +-- .../bluesource/choicesdk/maps/common/Tile.kt | 8 +-- .../maps/factory/BitmapDescriptorFactory.kt | 19 ++----- .../factory/GroundOverlayOptionsFactory.kt | 17 ++---- .../maps/factory/MarkerOptionsFactory.kt | 17 ++---- .../maps/factory/TileOverlayOptionsFactory.kt | 17 ++---- .../messaging/factory/MessagingFactory.kt | 14 ++--- .../factory/MessagingRepositoryFactory.kt | 15 ++---- .../choicesdk/signin/common/Scopes.kt | 15 +++--- .../choicesdk/signin/factory/SignInFactory.kt | 14 ++--- 28 files changed, 218 insertions(+), 274 deletions(-) create mode 100644 ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/MobileService.kt diff --git a/ChoiceSDK/choicesdk-analytics/src/main/java/at/bluesource/choicesdk/analytics/factory/AnalyticsFactory.kt b/ChoiceSDK/choicesdk-analytics/src/main/java/at/bluesource/choicesdk/analytics/factory/AnalyticsFactory.kt index 9daef2d..af46e5a 100644 --- a/ChoiceSDK/choicesdk-analytics/src/main/java/at/bluesource/choicesdk/analytics/factory/AnalyticsFactory.kt +++ b/ChoiceSDK/choicesdk-analytics/src/main/java/at/bluesource/choicesdk/analytics/factory/AnalyticsFactory.kt @@ -6,6 +6,7 @@ import androidx.annotation.RequiresPermission import at.bluesource.choicesdk.analytics.common.Analytics import at.bluesource.choicesdk.analytics.gms.FirebaseAnalytics import at.bluesource.choicesdk.analytics.hms.HuaweiAnalytics +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector /** @@ -19,39 +20,22 @@ import at.bluesource.choicesdk.core.MobileServicesDetector */ class AnalyticsFactory { companion object { - private const val EXCEPTION_MESSAGE = "Missing underlying GMS/HMS API." @Throws(UnsupportedOperationException::class) @RequiresPermission(allOf = ["android.permission.ACCESS_NETWORK_STATE", "android.permission.INTERNET", "android.permission.WAKE_LOCK"]) fun getAnalytics(context: Context): Analytics { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - FirebaseAnalytics.getInstance(context) - } - MobileServicesDetector.isHmsAvailable() -> { - HuaweiAnalytics.getInstance(context) - } - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> FirebaseAnalytics.getInstance(context) + MobileService.HMS -> HuaweiAnalytics.getInstance(context) } } @Throws(UnsupportedOperationException::class) @RequiresPermission(allOf = ["android.permission.ACCESS_NETWORK_STATE", "android.permission.INTERNET", "android.permission.WAKE_LOCK"]) fun getAnalytics(activity: Activity): Analytics { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - FirebaseAnalytics.getInstance(activity) - } - MobileServicesDetector.isHmsAvailable() -> { - HuaweiAnalytics.getInstance(activity) - } - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> FirebaseAnalytics.getInstance(activity) + MobileService.HMS -> HuaweiAnalytics.getInstance(activity) } } } diff --git a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/MainActivity.kt b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/MainActivity.kt index 5f8c23d..0469a5d 100644 --- a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/MainActivity.kt +++ b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/MainActivity.kt @@ -6,6 +6,7 @@ import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import com.bluesource.choicesdk_app.analytics.AnalyticsActivity import com.bluesource.choicesdk_app.biometrics.BiometricsActivity @@ -35,10 +36,13 @@ class MainActivity : AppCompatActivity() { val crashBtn: Button = findViewById(R.id.btn_crash_it) val txtVersion: TextView = findViewById(R.id.txt_version) - txtView.text = when { - MobileServicesDetector.isGmsAvailable() -> "GMS detected | GMS demo" - MobileServicesDetector.isHmsAvailable() -> "HMS detected | HMS demo" - else -> "No GMS nor HMS service detected!" + txtView.text = try { + when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> "GMS detected | GMS demo" + MobileService.HMS -> "HMS detected | HMS demo" + } + } catch (e: UnsupportedOperationException) { + "No GMS nor HMS service detected!" } locationBtn.setOnClickListener { diff --git a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/messages/MessagesActivity.kt b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/messages/MessagesActivity.kt index 63d1fbf..9b660f2 100644 --- a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/messages/MessagesActivity.kt +++ b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/messages/MessagesActivity.kt @@ -14,6 +14,7 @@ import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.messaging.common.MessagingService import at.bluesource.choicesdk.messaging.common.RemoteMessage @@ -100,10 +101,13 @@ class MessagesActivity : AppCompatActivity() { textViewPush.movementMethod = ScrollingMovementMethod() val txtPushServiceType = findViewById(R.id.textView_push_service_type) - txtPushServiceType.text = when { - MobileServicesDetector.isGmsAvailable() -> "Using GSM Push Service" - MobileServicesDetector.isHmsAvailable() -> "Using HSM Push Service" - else -> "" + txtPushServiceType.text = try { + when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> "Using GMS Push Service" + MobileService.HMS -> "Using HMS Push Service" + } + } catch (e: UnsupportedOperationException) { + "" } btnToken.setOnClickListener { getToken() } @@ -169,12 +173,14 @@ class MessagesActivity : AppCompatActivity() { } private fun getServiceType(): String { - if (MobileServicesDetector.isGmsAvailable()) { - return "google" - } else if (MobileServicesDetector.isHmsAvailable()) { - return "huawei" + return try { + when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> "google" + MobileService.HMS -> "huawei" + } + } catch (e: UnsupportedOperationException) { + "" } - return "" } private fun triggerNotification() { diff --git a/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/ChoiceSdk.kt b/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/ChoiceSdk.kt index ad75905..b5aab5c 100644 --- a/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/ChoiceSdk.kt +++ b/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/ChoiceSdk.kt @@ -11,15 +11,28 @@ class ChoiceSdk { companion object { private lateinit var appContext: Application + internal var mobileServicePriorities: List = listOf(MobileService.GMS, MobileService.HMS) /** - * Initialize the ChoiceSdk with the application context + * Initialize the ChoiceSdk. * * @param context - Application context */ @JvmStatic fun init(context: Application) { - appContext = context + this.appContext = context + } + + /** + * Initialize the ChoiceSdk with custom mobile service priorities. + * + * @param context - Application context + * @param mobileServicePriorities - Mobile services (GMS, HMS) are prioritized in the order of this list. + */ + @JvmStatic + fun init(context: Application, mobileServicePriorities: List) { + this.appContext = context + this.mobileServicePriorities = mobileServicePriorities } /** diff --git a/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/MobileService.kt b/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/MobileService.kt new file mode 100644 index 0000000..3864fb8 --- /dev/null +++ b/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/MobileService.kt @@ -0,0 +1,12 @@ +package at.bluesource.choicesdk.core + +enum class MobileService { + GMS, HMS; + + fun isAvailable(): Boolean { + return when (this) { + GMS -> com.google.android.gms.common.GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(ChoiceSdk.getContext()) == com.google.android.gms.common.ConnectionResult.SUCCESS + HMS -> com.huawei.hms.api.HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(ChoiceSdk.getContext()) == com.huawei.hms.api.ConnectionResult.SUCCESS + } + } +} \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/MobileServicesDetector.kt b/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/MobileServicesDetector.kt index 30a8327..b4e0cb7 100644 --- a/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/MobileServicesDetector.kt +++ b/ChoiceSDK/choicesdk-core/src/main/java/at/bluesource/choicesdk/core/MobileServicesDetector.kt @@ -13,25 +13,45 @@ class MobileServicesDetector { companion object { + /** + * Checks which mobile service is available. This check considers the priorities set during [ChoiceSdk] initialization. + * @throws UnsupportedOperationException if no mobile service is available. + */ + @Throws(UnsupportedOperationException::class) + fun getAvailableMobileService(): MobileService { + ChoiceSdk.mobileServicePriorities.forEach { mobileService -> + if (mobileService.isAvailable()) { + return mobileService + } + } + + throw UnsupportedOperationException("Missing underlying GMS/HMS API.") + } + /** * Check if Google Play Services are available */ fun isGmsAvailable(): Boolean { - return com.google.android.gms.common.GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(ChoiceSdk.getContext()) == com.google.android.gms.common.ConnectionResult.SUCCESS + return MobileService.GMS.isAvailable() } /** * Check if Huawei Mobile Services are available */ fun isHmsAvailable(): Boolean { - return com.huawei.hms.api.HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(ChoiceSdk.getContext()) == com.huawei.hms.api.ConnectionResult.SUCCESS + return MobileService.HMS.isAvailable() } /** * Check of any mobile services are available */ fun anyMobileServicesAvailable(): Boolean { - return isGmsAvailable() || isHmsAvailable() + return try { + getAvailableMobileService() + true + } catch (e: UnsupportedOperationException) { + false + } } } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationAvailability.kt b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationAvailability.kt index d1b5497..8cbb3bb 100644 --- a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationAvailability.kt +++ b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationAvailability.kt @@ -1,6 +1,7 @@ package at.bluesource.choicesdk.location.common import android.content.Intent +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector @@ -24,26 +25,24 @@ interface LocationAvailability { @Suppress("ExplicitThis") companion object { fun extractLocationAvailability(intent: Intent): LocationAvailability? { - return when { - MobileServicesDetector.isGmsAvailable() -> { - return com.google.android.gms.location.LocationAvailability.extractLocationAvailability(intent).toChoiceLocationAvailability() + return try { + when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> com.google.android.gms.location.LocationAvailability.extractLocationAvailability(intent).toChoiceLocationAvailability() + MobileService.HMS -> com.huawei.hms.location.LocationAvailability.extractLocationAvailability(intent).toChoiceLocationAvailability() } - MobileServicesDetector.isHmsAvailable() -> { - return com.huawei.hms.location.LocationAvailability.extractLocationAvailability(intent).toChoiceLocationAvailability() - } - else -> null + } catch (e: UnsupportedOperationException) { + null } } fun hasLocationAvailability(intent: Intent): Boolean { - return when { - MobileServicesDetector.isGmsAvailable() -> { - return com.google.android.gms.location.LocationAvailability.hasLocationAvailability(intent) - } - MobileServicesDetector.isHmsAvailable() -> { - return com.huawei.hms.location.LocationAvailability.hasLocationAvailability(intent) + return try { + when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> com.google.android.gms.location.LocationAvailability.hasLocationAvailability(intent) + MobileService.HMS -> com.huawei.hms.location.LocationAvailability.hasLocationAvailability(intent) } - else -> false + } catch (e: UnsupportedOperationException) { + false } } diff --git a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt index 8a02d5a..056e246 100644 --- a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt +++ b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt @@ -1,6 +1,7 @@ package at.bluesource.choicesdk.location.common import android.content.Intent +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector /** @@ -25,15 +26,13 @@ interface LocationSettingsStates { companion object { fun fromIntent(intent: Intent): LocationSettingsStates? { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - com.google.android.gms.location.LocationSettingsStates.fromIntent(intent)?.toChoiceLocationSettingsStates() - } - MobileServicesDetector.isHmsAvailable() -> { - com.huawei.hms.location.LocationSettingsStates.fromIntent(intent)?.toChoiceLocationSettingsStates() + return try { + when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> com.google.android.gms.location.LocationSettingsStates.fromIntent(intent)?.toChoiceLocationSettingsStates() + MobileService.HMS -> com.huawei.hms.location.LocationSettingsStates.fromIntent(intent)?.toChoiceLocationSettingsStates() } - else -> null + } catch (e: UnsupportedOperationException) { + null } } diff --git a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/factory/FusedLocationProviderFactory.kt b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/factory/FusedLocationProviderFactory.kt index 55a245f..0e30b49 100644 --- a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/factory/FusedLocationProviderFactory.kt +++ b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/factory/FusedLocationProviderFactory.kt @@ -2,6 +2,7 @@ package at.bluesource.choicesdk.location.factory import android.app.Activity import android.content.Context +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.location.common.FusedLocationProviderClient import at.bluesource.choicesdk.location.gms.GmsFusedLocationProviderClient @@ -18,39 +19,28 @@ import at.bluesource.choicesdk.location.hms.HmsFusedLocationProviderClient */ class FusedLocationProviderFactory { companion object { - private const val EXCEPTION_MESSAGE = "Missing underlying GMS/HMS API." @Throws(UnsupportedOperationException::class) fun getFusedLocationProviderClient(context: Context): FusedLocationProviderClient { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsFusedLocationProviderClient( + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsFusedLocationProviderClient( com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(context) ) - - MobileServicesDetector.isHmsAvailable() -> HmsFusedLocationProviderClient( + MobileService.HMS -> HmsFusedLocationProviderClient( com.huawei.hms.location.LocationServices.getFusedLocationProviderClient(context) ) - - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } } } @Throws(UnsupportedOperationException::class) fun getFusedLocationProviderClient(activity: Activity): FusedLocationProviderClient { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsFusedLocationProviderClient( + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsFusedLocationProviderClient( com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(activity) ) - - MobileServicesDetector.isHmsAvailable() -> HmsFusedLocationProviderClient( + MobileService.HMS -> HmsFusedLocationProviderClient( com.huawei.hms.location.LocationServices.getFusedLocationProviderClient(activity) ) - - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } } } } diff --git a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/factory/SettingsClientFactory.kt b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/factory/SettingsClientFactory.kt index b081293..7fe95f6 100644 --- a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/factory/SettingsClientFactory.kt +++ b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/factory/SettingsClientFactory.kt @@ -2,6 +2,7 @@ package at.bluesource.choicesdk.location.factory import android.app.Activity import android.content.Context +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.location.common.SettingsClient import at.bluesource.choicesdk.location.gms.GmsSettingsClient @@ -19,53 +20,36 @@ import com.google.android.gms.location.LocationServices */ class SettingsClientFactory { companion object { - private const val EXCEPTION_MESSAGE = "Missing underlying GMS/HMS API." @Throws(UnsupportedOperationException::class) fun getSettingsClient(context: Context): SettingsClient { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsSettingsClient( - LocationServices.getSettingsClient( - context - ) + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsSettingsClient( + LocationServices.getSettingsClient( + context ) - } - MobileServicesDetector.isHmsAvailable() -> { - HmsSettingsClient( - com.huawei.hms.location.LocationServices.getSettingsClient( - context - ) + ) + MobileService.HMS -> HmsSettingsClient( + com.huawei.hms.location.LocationServices.getSettingsClient( + context ) - } - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } + ) } } @Throws(UnsupportedOperationException::class) fun getSettingsClient(activity: Activity): SettingsClient { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsSettingsClient( - LocationServices.getSettingsClient( - activity - ) + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsSettingsClient( + LocationServices.getSettingsClient( + activity ) - } - MobileServicesDetector.isHmsAvailable() -> { - HmsSettingsClient( - com.huawei.hms.location.LocationServices.getSettingsClient( - activity - ) + ) + MobileService.HMS -> HmsSettingsClient( + com.huawei.hms.location.LocationServices.getSettingsClient( + activity ) - } - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } + ) } } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/CameraUpdateFactory.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/CameraUpdateFactory.kt index de6373c..e99f762 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/CameraUpdateFactory.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/CameraUpdateFactory.kt @@ -1,6 +1,7 @@ package at.bluesource.choicesdk.maps.common import android.graphics.Point +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.gms.GmsCameraUpdateFactory import at.bluesource.choicesdk.maps.hms.HmsCameraUpdateFactory @@ -21,17 +22,17 @@ interface CameraUpdateFactory { fun newLatLngBounds(bounds: LatLngBounds, padding: Int): CameraUpdate fun newLatLngBounds( - latLngNorthEast: LatLng, - latLngSouthWest: LatLng, - width: Int, - height: Int, - padding: Int + latLngNorthEast: LatLng, + latLngSouthWest: LatLng, + width: Int, + height: Int, + padding: Int ): CameraUpdate fun newLatLngBounds( - latLngNorthEast: LatLng, - latLngSouthWest: LatLng, - padding: Int + latLngNorthEast: LatLng, + latLngSouthWest: LatLng, + padding: Int ): CameraUpdate fun newLatLngZoom(latLng: LatLng, zoom: Float): CameraUpdate @@ -46,11 +47,9 @@ interface CameraUpdateFactory { @JvmStatic fun get(): CameraUpdateFactory { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsCameraUpdateFactory.getInstance() - MobileServicesDetector.isHmsAvailable() -> HmsCameraUpdateFactory.getInstance() - else -> throw UnsupportedOperationException("Missing underlying GMS/HMS API.") - + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsCameraUpdateFactory.getInstance() + MobileService.HMS -> HmsCameraUpdateFactory.getInstance() } } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/CameraUpdateFactoryProvider.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/CameraUpdateFactoryProvider.kt index 95f2ed5..d908b8b 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/CameraUpdateFactoryProvider.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/CameraUpdateFactoryProvider.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.maps.common +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.gms.GmsCameraUpdateFactory import at.bluesource.choicesdk.maps.hms.HmsCameraUpdateFactory @@ -8,17 +9,9 @@ object CameraUpdateFactoryProvider { @JvmStatic fun get(): CameraUpdateFactory { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsCameraUpdateFactory.getInstance() - } - MobileServicesDetector.isHmsAvailable() -> { - HmsCameraUpdateFactory.getInstance() - } - else -> { - throw UnsupportedOperationException("Missing underlying GMS/HMS API.") - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsCameraUpdateFactory.getInstance() + MobileService.HMS -> HmsCameraUpdateFactory.getInstance() } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/LatLng.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/LatLng.kt index 7ecc1f2..9dda4a8 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/LatLng.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/LatLng.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.maps.common +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.gms.GmsLatLngFactory import at.bluesource.choicesdk.maps.hms.HmsLatLngFactory @@ -49,10 +50,9 @@ data class LatLng(var latitude: Double, var longitude: Double) { @JvmStatic fun getFactory(): Factory { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsLatLngFactory() - MobileServicesDetector.isHmsAvailable() -> HmsLatLngFactory() - else -> throw IllegalStateException("Neither GMS nor HMS services are available.") + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsLatLngFactory() + MobileService.HMS -> HmsLatLngFactory() } } @@ -72,8 +72,8 @@ data class LatLng(var latitude: Double, var longitude: Double) { @JvmStatic fun com.huawei.hms.maps.model.LatLng.toChoiceLatLng(): LatLng { return LatLng( - latitude, - longitude + latitude, + longitude ) } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/LatLngBounds.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/LatLngBounds.kt index a5daf50..051222c 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/LatLngBounds.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/LatLngBounds.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.maps.common +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.common.LatLng.Companion.toGmsLatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toHmsLatLng @@ -48,19 +49,17 @@ interface LatLngBounds { companion object { fun getBuilder(): Builder { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsLatLngBoundsBuilder() - MobileServicesDetector.isHmsAvailable() -> HmsLatLngBoundsBuilder() - else -> throw IllegalStateException("Neither GMS nor HMS services are available.") + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsLatLngBoundsBuilder() + MobileService.HMS -> HmsLatLngBoundsBuilder() } } @JvmStatic fun getFactory(): Factory { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsLatLngBoundsFactory() - MobileServicesDetector.isHmsAvailable() -> HmsLatLngBoundsFactory() - else -> throw IllegalStateException("Neither GMS nor HMS services are available.") + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsLatLngBoundsFactory() + MobileService.HMS -> HmsLatLngBoundsFactory() } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapFragment.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapFragment.kt index 4fad3c2..e3c3067 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapFragment.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapFragment.kt @@ -5,6 +5,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.R import at.bluesource.choicesdk.maps.common.Map.Companion.toChoiceMap @@ -45,8 +46,8 @@ open class MapFragment( override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val mapFragment: Fragment = when { - MobileServicesDetector.isGmsAvailable() -> { + val mapFragment: Fragment = when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> { val instance = if (options == null) { com.google.android.gms.maps.SupportMapFragment.newInstance() } else { @@ -60,7 +61,7 @@ open class MapFragment( instance } - MobileServicesDetector.isHmsAvailable() -> { + MobileService.HMS -> { val instance = if (options == null) { com.huawei.hms.maps.SupportMapFragment.newInstance() } else { @@ -73,8 +74,6 @@ open class MapFragment( instance } - - else -> throw IllegalArgumentException("Neither GMS nor HMS services are available. Therefore no MapFragment can be instantiated.") } replaceFragment(mapFragment) diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapOptions.kt index 0259179..144539c 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapOptions.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.maps.common +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.gms.GmsMapOptionsFactory import at.bluesource.choicesdk.maps.hms.HmsMapOptionsFactory @@ -22,10 +23,9 @@ interface MapOptions { @JvmStatic fun getFactory(): Factory { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsMapOptionsFactory() - MobileServicesDetector.isHmsAvailable() -> HmsMapOptionsFactory() - else -> throw IllegalStateException("Neither GMS nor HMS services are available.") + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsMapOptionsFactory() + MobileService.HMS -> HmsMapOptionsFactory() } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapView.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapView.kt index 4317625..72dad41 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapView.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapView.kt @@ -4,6 +4,7 @@ import android.content.Context import android.os.Bundle import android.util.AttributeSet import android.widget.FrameLayout +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.gms.GmsMapView import at.bluesource.choicesdk.maps.hms.HmsMapView @@ -22,18 +23,16 @@ abstract class MapView @JvmOverloads constructor(context: Context, attrs: Attrib companion object Factory { fun create(context: Context): MapView { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsMapView(context) - MobileServicesDetector.isHmsAvailable() -> HmsMapView(context) - else -> throw IllegalStateException("Neither GMS nor HMS is available.") + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsMapView(context) + MobileService.HMS -> HmsMapView(context) } } fun create(context: Context, options: MapOptions): MapView { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsMapView(context, options) - MobileServicesDetector.isHmsAvailable() -> HmsMapView(context, options) - else -> throw IllegalStateException("Neither GMS nor HMS is available.") + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsMapView(context, options) + MobileService.HMS -> HmsMapView(context, options) } } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapsInitializer.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapsInitializer.kt index ce044e2..05b0cfc 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapsInitializer.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/MapsInitializer.kt @@ -1,6 +1,7 @@ package at.bluesource.choicesdk.maps.common import android.content.Context +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector class MapsInitializer { @@ -8,10 +9,9 @@ class MapsInitializer { companion object { @JvmStatic fun initialize(context: Context) { - when { - MobileServicesDetector.isGmsAvailable() -> com.google.android.gms.maps.MapsInitializer.initialize(context) - MobileServicesDetector.isHmsAvailable() -> com.huawei.hms.maps.MapsInitializer.initialize(context) - else -> throw IllegalStateException("Neither GMS nor HMS services are available.") + when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> com.google.android.gms.maps.MapsInitializer.initialize(context) + MobileService.HMS -> com.huawei.hms.maps.MapsInitializer.initialize(context) } } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/SphericalMercatorProjection.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/SphericalMercatorProjection.kt index d9590a0..27e3a11 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/SphericalMercatorProjection.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/SphericalMercatorProjection.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.maps.common +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.gms.GmsSphericalMercatorProjectionFactory import at.bluesource.choicesdk.maps.hms.HmsSphericalMercatorProjectionFactory @@ -16,10 +17,9 @@ abstract class SphericalMercatorProjection { companion object { @JvmStatic fun getFactory(): Factory { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsSphericalMercatorProjectionFactory() - MobileServicesDetector.isHmsAvailable() -> HmsSphericalMercatorProjectionFactory() - else -> throw IllegalStateException("Neither GMS nor HMS services are available.") + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsSphericalMercatorProjectionFactory() + MobileService.HMS -> HmsSphericalMercatorProjectionFactory() } } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Tile.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Tile.kt index 017191d..848f015 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Tile.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Tile.kt @@ -1,6 +1,7 @@ package at.bluesource.choicesdk.maps.common import android.os.Parcel +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.gms.GmsTile import at.bluesource.choicesdk.maps.gms.GmsTileFactory @@ -25,10 +26,9 @@ abstract class Tile(val width: Int, val height: Int, val data: ByteArray?) { @JvmStatic fun getFactory(): Factory { - return when { - MobileServicesDetector.isGmsAvailable() -> GmsTileFactory() - MobileServicesDetector.isHmsAvailable() -> HmsTileFactory() - else -> throw IllegalStateException("Neither GMS nor HMS services are available.") + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsTileFactory() + MobileService.HMS -> HmsTileFactory() } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/BitmapDescriptorFactory.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/BitmapDescriptorFactory.kt index aabe477..7839f05 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/BitmapDescriptorFactory.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/BitmapDescriptorFactory.kt @@ -1,11 +1,10 @@ package at.bluesource.choicesdk.maps.factory +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.common.BitmapDescriptorFactory import at.bluesource.choicesdk.maps.gms.GmsBitmapDescriptorFactory -import at.bluesource.choicesdk.maps.gms.GmsCameraUpdateFactory import at.bluesource.choicesdk.maps.hms.HmsBitmapDescriptorFactory -import at.bluesource.choicesdk.maps.hms.HmsCameraUpdateFactory /** * BitmapDescriptorFactory factory, uses [MobileServicesDetector] to get instance of [BitmapDescriptorFactory] @@ -18,21 +17,11 @@ import at.bluesource.choicesdk.maps.hms.HmsCameraUpdateFactory */ internal class BitmapDescriptorFactory { companion object { - private const val EXCEPTION_MESSAGE = "Missing underlying GMS/HMS API." - @Throws(UnsupportedOperationException::class) fun getBitmapDescriptorFactory(): BitmapDescriptorFactory { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsBitmapDescriptorFactory.getInstance() - } - MobileServicesDetector.isHmsAvailable() -> { - HmsBitmapDescriptorFactory.getInstance() - } - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsBitmapDescriptorFactory.getInstance() + MobileService.HMS -> HmsBitmapDescriptorFactory.getInstance() } } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/GroundOverlayOptionsFactory.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/GroundOverlayOptionsFactory.kt index 49ce435..bf024f3 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/GroundOverlayOptionsFactory.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/GroundOverlayOptionsFactory.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.maps.factory +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.common.options.GroundOverlayOptions import at.bluesource.choicesdk.maps.gms.GmsGroundOverlayOptions @@ -16,21 +17,11 @@ import at.bluesource.choicesdk.maps.hms.HmsGroundOverlayOptions */ internal class GroundOverlayOptionsFactory { companion object { - private const val EXCEPTION_MESSAGE = "Missing underlying GMS/HMS API." - @Throws(UnsupportedOperationException::class) fun getGroundOverlayOptions(): GroundOverlayOptions { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsGroundOverlayOptions(com.google.android.gms.maps.model.GroundOverlayOptions()) - } - MobileServicesDetector.isHmsAvailable() -> { - HmsGroundOverlayOptions(com.huawei.hms.maps.model.GroundOverlayOptions()) - } - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsGroundOverlayOptions(com.google.android.gms.maps.model.GroundOverlayOptions()) + MobileService.HMS -> HmsGroundOverlayOptions(com.huawei.hms.maps.model.GroundOverlayOptions()) } } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/MarkerOptionsFactory.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/MarkerOptionsFactory.kt index 3d08c9a..c04304e 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/MarkerOptionsFactory.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/MarkerOptionsFactory.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.maps.factory +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.common.options.MarkerOptions import at.bluesource.choicesdk.maps.gms.GmsMarkerOptions @@ -16,21 +17,11 @@ import at.bluesource.choicesdk.maps.hms.HmsMarkerOptions */ internal class MarkerOptionsFactory { companion object { - private const val EXCEPTION_MESSAGE = "Missing underlying GMS/HMS API." - @Throws(UnsupportedOperationException::class) fun getMarkerOptions(): MarkerOptions { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsMarkerOptions(com.google.android.gms.maps.model.MarkerOptions()) - } - MobileServicesDetector.isHmsAvailable() -> { - HmsMarkerOptions(com.huawei.hms.maps.model.MarkerOptions()) - } - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsMarkerOptions(com.google.android.gms.maps.model.MarkerOptions()) + MobileService.HMS -> HmsMarkerOptions(com.huawei.hms.maps.model.MarkerOptions()) } } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/TileOverlayOptionsFactory.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/TileOverlayOptionsFactory.kt index 2507efe..8f75c71 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/TileOverlayOptionsFactory.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/factory/TileOverlayOptionsFactory.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.maps.factory +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.maps.common.options.TileOverlayOptions import at.bluesource.choicesdk.maps.gms.GmsTileOverlayOptions @@ -16,21 +17,11 @@ import at.bluesource.choicesdk.maps.hms.HmsTileOverlayOptions */ internal class TileOverlayOptionsFactory { companion object { - private const val EXCEPTION_MESSAGE = "Missing underlying GMS/HMS API." - @Throws(UnsupportedOperationException::class) fun getTileOverlayOptions(): TileOverlayOptions { - - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsTileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions()) - } - MobileServicesDetector.isHmsAvailable() -> { - HmsTileOverlayOptions(com.huawei.hms.maps.model.TileOverlayOptions()) - } - else -> { - throw UnsupportedOperationException(EXCEPTION_MESSAGE) - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsTileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions()) + MobileService.HMS -> HmsTileOverlayOptions(com.huawei.hms.maps.model.TileOverlayOptions()) } } } diff --git a/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/factory/MessagingFactory.kt b/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/factory/MessagingFactory.kt index d4d1d7f..c87ce64 100644 --- a/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/factory/MessagingFactory.kt +++ b/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/factory/MessagingFactory.kt @@ -1,6 +1,7 @@ package at.bluesource.choicesdk.messaging.factory import at.bluesource.choicesdk.core.ChoiceSdk +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.messaging.common.Messaging import at.bluesource.choicesdk.messaging.gms.GmsMessaging @@ -19,16 +20,9 @@ class MessagingFactory { companion object { @Throws(UnsupportedOperationException::class) fun getMessaging(): Messaging { - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsMessaging.getInstance() - } - MobileServicesDetector.isHmsAvailable() -> { - HmsMessaging.getInstance(ChoiceSdk.getContext()) - } - else -> { - throw UnsupportedOperationException("Missing underlying GMS/HMS API.") - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsMessaging.getInstance() + MobileService.HMS -> HmsMessaging.getInstance(ChoiceSdk.getContext()) } } } diff --git a/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/factory/MessagingRepositoryFactory.kt b/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/factory/MessagingRepositoryFactory.kt index de20fa6..7eaecbe 100644 --- a/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/factory/MessagingRepositoryFactory.kt +++ b/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/factory/MessagingRepositoryFactory.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.messaging.factory +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.messaging.common.MessagingRepository import at.bluesource.choicesdk.messaging.common.MessagingService @@ -25,18 +26,10 @@ class MessagingRepositoryFactory { @Throws(UnsupportedOperationException::class) fun getTokenProvider(): TokenProvider { - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsTokenProvider - } - MobileServicesDetector.isHmsAvailable() -> { - HmsTokenProvider - } - else -> { - throw UnsupportedOperationException("Missing underlying GMS/HMS API.") - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsTokenProvider + MobileService.HMS -> HmsTokenProvider } - } } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/common/Scopes.kt b/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/common/Scopes.kt index 0c85507..fcdfefd 100644 --- a/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/common/Scopes.kt +++ b/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/common/Scopes.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.signin.common +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector /** @@ -13,14 +14,14 @@ sealed class Scopes { const val PROFILE = "profile" const val OPEN_ID = "openid" const val EMAIL = "email" - val GAMES = when { - MobileServicesDetector.isGmsAvailable() -> { - "https://www.googleapis.com/auth/games" - } - MobileServicesDetector.isHmsAvailable() -> { - "https://www.huawei.com/auth/games" + + val GAMES = try { + when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> "https://www.googleapis.com/auth/games" + MobileService.HMS -> "https://www.huawei.com/auth/games" } - else -> "" + } catch (e: UnsupportedOperationException) { + "" } } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/factory/SignInFactory.kt b/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/factory/SignInFactory.kt index 3544713..44092cd 100644 --- a/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/factory/SignInFactory.kt +++ b/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/factory/SignInFactory.kt @@ -1,5 +1,6 @@ package at.bluesource.choicesdk.signin.factory +import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.signin.common.SignInService import at.bluesource.choicesdk.signin.gms.GmsSignInService @@ -18,16 +19,9 @@ internal class SignInFactory { companion object { @Throws(UnsupportedOperationException::class) fun getSignIn(): SignInService { - return when { - MobileServicesDetector.isGmsAvailable() -> { - GmsSignInService.getInstance() - } - MobileServicesDetector.isHmsAvailable() -> { - HmsSignInService.getInstance() - } - else -> { - throw UnsupportedOperationException("Missing underlying GMS/HMS API.") - } + return when (MobileServicesDetector.getAvailableMobileService()) { + MobileService.GMS -> GmsSignInService.getInstance() + MobileService.HMS -> HmsSignInService.getInstance() } } } From 6f0b9103fed324477a8416aef15a3b4aa87116e7 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 10:01:06 +0200 Subject: [PATCH 09/12] update Firebase dependencies and fix nullability warnings for certain properties --- ChoiceSDK/build.gradle | 4 ++-- ChoiceSDK/choicesdk-analytics/build.gradle | 2 +- ChoiceSDK/choicesdk-maps/build.gradle | 4 ++-- .../java/at/bluesource/choicesdk/maps/common/Map.kt | 4 ++-- .../bluesource/choicesdk/maps/common/TileProvider.kt | 2 +- .../maps/common/listener/OnSnapshotReadyCallback.kt | 2 +- .../maps/common/options/GroundOverlayOptions.kt | 4 ++-- .../choicesdk/maps/common/options/MarkerOptions.kt | 4 ++-- .../maps/common/options/TileOverlayOptions.kt | 6 +++--- .../choicesdk/maps/gms/GmsGroundOverlayOptions.kt | 8 ++++---- .../java/at/bluesource/choicesdk/maps/gms/GmsMap.kt | 12 ++++++------ .../at/bluesource/choicesdk/maps/gms/GmsMapView.kt | 10 +++++++++- .../choicesdk/maps/gms/GmsMarkerOptions.kt | 4 ++-- .../choicesdk/maps/gms/GmsTileOverlayOptions.kt | 8 ++++---- .../bluesource/choicesdk/maps/gms/GmsTileProvider.kt | 4 ++-- .../choicesdk/maps/hms/HmsGroundOverlayOptions.kt | 8 ++++---- .../java/at/bluesource/choicesdk/maps/hms/HmsMap.kt | 10 +++++----- .../choicesdk/maps/hms/HmsMarkerOptions.kt | 4 ++-- .../choicesdk/maps/hms/HmsTileOverlayOptions.kt | 8 ++++---- .../bluesource/choicesdk/maps/hms/HmsTileProvider.kt | 4 ++-- ChoiceSDK/choicesdk-messaging/build.gradle | 4 ++-- 21 files changed, 62 insertions(+), 54 deletions(-) diff --git a/ChoiceSDK/build.gradle b/ChoiceSDK/build.gradle index cf75104..be5f801 100644 --- a/ChoiceSDK/build.gradle +++ b/ChoiceSDK/build.gradle @@ -28,8 +28,8 @@ buildscript { classpath 'com.jaredsburrows:gradle-license-plugin:0.8.80' // GMS - classpath 'com.google.gms:google-services:4.3.5' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.0' + classpath 'com.google.gms:google-services:4.3.8' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1' // HMS classpath 'com.huawei.agconnect:agcp:1.5.0.300' diff --git a/ChoiceSDK/choicesdk-analytics/build.gradle b/ChoiceSDK/choicesdk-analytics/build.gradle index b2b0d4c..5ba0ea0 100644 --- a/ChoiceSDK/choicesdk-analytics/build.gradle +++ b/ChoiceSDK/choicesdk-analytics/build.gradle @@ -60,7 +60,7 @@ dependencies { api project(":choicesdk-core") // GMS - implementation platform('com.google.firebase:firebase-bom:26.5.0') + implementation platform('com.google.firebase:firebase-bom:28.2.0') implementation 'com.google.firebase:firebase-analytics-ktx' // HMS diff --git a/ChoiceSDK/choicesdk-maps/build.gradle b/ChoiceSDK/choicesdk-maps/build.gradle index 9696cf6..485a15a 100644 --- a/ChoiceSDK/choicesdk-maps/build.gradle +++ b/ChoiceSDK/choicesdk-maps/build.gradle @@ -60,12 +60,12 @@ dependencies { api project(":choicesdk-core") // GMS - implementation 'com.google.android.gms:play-services-maps:17.0.0' + implementation 'com.google.android.gms:play-services-maps:17.0.1' implementation 'com.google.maps.android:android-maps-utils:0.5' // HMS implementation 'com.huawei.hms:maps:5.0.5.301' - implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.0" + implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1" } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Map.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Map.kt index 39dfd07..93ec8c2 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Map.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Map.kt @@ -64,10 +64,10 @@ interface Map { @Throws(ApiException::class) fun addCircle(options: CircleOptions): Circle fun addGroundOverlay(options: GroundOverlayOptions) - fun addMarker(options: MarkerOptions): Marker + fun addMarker(options: MarkerOptions): Marker? fun addPolygon(options: PolygonOptions): Polygon fun addPolyline(options: PolylineOptions): Polyline - fun addTileOverlay(options: TileOverlayOptions): TileOverlay + fun addTileOverlay(options: TileOverlayOptions): TileOverlay? fun animateCamera(update: CameraUpdate) fun animateCamera(update: CameraUpdate, callback: CancelableCallback?) fun animateCamera( diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/TileProvider.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/TileProvider.kt index 3ce937a..dd2662a 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/TileProvider.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/TileProvider.kt @@ -13,7 +13,7 @@ import at.bluesource.choicesdk.maps.hms.HmsTileProvider */ fun interface TileProvider { - fun getTile(x: Int, y: Int, zoom: Int): Tile + fun getTile(x: Int, y: Int, zoom: Int): Tile? companion object { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/listener/OnSnapshotReadyCallback.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/listener/OnSnapshotReadyCallback.kt index e0d6904..5b7319e 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/listener/OnSnapshotReadyCallback.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/listener/OnSnapshotReadyCallback.kt @@ -8,5 +8,5 @@ import android.graphics.Bitmap * This is called on the Android UI thread. */ fun interface OnSnapshotReadyCallback { - fun onSnapShotReady(snapshot: Bitmap) + fun onSnapShotReady(snapshot: Bitmap?) } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/GroundOverlayOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/GroundOverlayOptions.kt index 1fc496c..0bbea4f 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/GroundOverlayOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/GroundOverlayOptions.kt @@ -25,10 +25,10 @@ interface GroundOverlayOptions { fun getAnchorU(): Float fun getAnchorV(): Float fun getBearing(): Float - fun getBounds(): LatLngBounds + fun getBounds(): LatLngBounds? fun getHeight(): Float fun getImage(): BitmapDescriptor - fun getLocation(): LatLng + fun getLocation(): LatLng? fun getTransparency(): Float fun getWidth(): Float fun getZIndex(): Float diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/MarkerOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/MarkerOptions.kt index 4305bf9..922dfad 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/MarkerOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/MarkerOptions.kt @@ -37,8 +37,8 @@ interface MarkerOptions { fun getInfoWindowAnchorV(): Float fun getPosition(): LatLng fun getRotation(): Float - fun getSnippet(): String - fun getTitle(): String + fun getSnippet(): String? + fun getTitle(): String? fun getZIndex(): Float fun icon(bitmapDescriptor: BitmapDescriptor): MarkerOptions fun defaultIcon(): MarkerOptions diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/TileOverlayOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/TileOverlayOptions.kt index f55cf2b..97e13ba 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/TileOverlayOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/options/TileOverlayOptions.kt @@ -18,11 +18,11 @@ import at.bluesource.choicesdk.maps.hms.HmsTileOverlayOptions interface TileOverlayOptions { fun fadeIn(fadeIn: Boolean): TileOverlayOptions fun getFadeIn(): Boolean - fun getTileProvider(): TileProvider + fun getTileProvider(): TileProvider? fun getTransparency(): Float fun getZIndex(): Float fun isVisible(): Boolean - fun tileProvider(tileProvider: TileProvider): TileOverlayOptions + fun tileProvider(tileProvider: TileProvider?): TileOverlayOptions fun transparency(transparency: Float): TileOverlayOptions fun visible(visible: Boolean): TileOverlayOptions fun writeToParcel(out: Parcel, flags: Int) @@ -38,7 +38,7 @@ interface TileOverlayOptions { fun com.google.android.gms.maps.model.TileOverlayOptions.toChoice(): TileOverlayOptions { return create() .fadeIn(this.fadeIn) - .tileProvider(this.tileProvider.toChoiceTileProvider()) + .tileProvider(this.tileProvider?.toChoiceTileProvider()) .transparency(this.transparency) .visible(this.isVisible) .zIndex(this.zIndex) diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsGroundOverlayOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsGroundOverlayOptions.kt index 5bbdf8c..8cf4088 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsGroundOverlayOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsGroundOverlayOptions.kt @@ -46,8 +46,8 @@ internal class GmsGroundOverlayOptions(private val groundOverlayOptions: com.goo return groundOverlayOptions.bearing } - override fun getBounds(): LatLngBounds { - return groundOverlayOptions.bounds.toChoiceLatLngBounds() + override fun getBounds(): LatLngBounds? { + return groundOverlayOptions.bounds?.toChoiceLatLngBounds() } override fun getHeight(): Float { @@ -58,8 +58,8 @@ internal class GmsGroundOverlayOptions(private val groundOverlayOptions: com.goo return BitmapDescriptor.GmsBitmapDescriptor(groundOverlayOptions.image) } - override fun getLocation(): LatLng { - return groundOverlayOptions.location.toChoiceLatLng() + override fun getLocation(): LatLng? { + return groundOverlayOptions.location?.toChoiceLatLng() } override fun getTransparency(): Float { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMap.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMap.kt index 34b67b1..b4a1e36 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMap.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMap.kt @@ -214,8 +214,8 @@ internal class GmsMap(private val map: GoogleMap) : Map { * Other ***************/ - override fun addMarker(options: MarkerOptions): Marker { - return GmsMarker(map.addMarker(options.toGmsMarkerOptions())) + override fun addMarker(options: MarkerOptions): Marker? { + return map.addMarker(options.toGmsMarkerOptions())?.let { GmsMarker(it) } } override fun addCircle(options: CircleOptions): Circle { @@ -223,7 +223,7 @@ internal class GmsMap(private val map: GoogleMap) : Map { } override fun addGroundOverlay(options: GroundOverlayOptions) { - map.addGroundOverlay(options.toGmsGroundOverlayOptions()) + options.toGmsGroundOverlayOptions()?.let { map.addGroundOverlay(it) } } override fun addPolygon(options: PolygonOptions): Polygon { @@ -234,9 +234,9 @@ internal class GmsMap(private val map: GoogleMap) : Map { return map.addPolyline(options.toGmsPolylineOptions()).toChoicePolyline() } - override fun addTileOverlay(options: TileOverlayOptions): TileOverlay { - val overlay = map.addTileOverlay(options.toGmsTileOverlayOptions()) - return TileOverlay.create(overlay) + override fun addTileOverlay(options: TileOverlayOptions): TileOverlay? { + val overlay = options.toGmsTileOverlayOptions()?.let { map.addTileOverlay(it) } + return if (overlay != null) TileOverlay.create(overlay) else null } override fun animateCamera(update: CameraUpdate) { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMapView.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMapView.kt index 684b7a5..c127bb0 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMapView.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMapView.kt @@ -11,7 +11,15 @@ import at.bluesource.choicesdk.maps.common.OnMapReadyCallback class GmsMapView : MapView { - constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr) { + constructor(context: Context) : super(context) { + mapView = com.google.android.gms.maps.MapView(context) + } + + constructor(context: Context, attrs: AttributeSet? = null) : super(context, attrs) { + mapView = com.google.android.gms.maps.MapView(context, attrs) + } + + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr) { mapView = com.google.android.gms.maps.MapView(context, attrs, defStyleAttr) } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMarkerOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMarkerOptions.kt index aab1bec..2f8d894 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMarkerOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMarkerOptions.kt @@ -61,11 +61,11 @@ internal class GmsMarkerOptions(private val markerOptions: com.google.android.gm return markerOptions.rotation } - override fun getSnippet(): String { + override fun getSnippet(): String? { return markerOptions.snippet } - override fun getTitle(): String { + override fun getTitle(): String? { return markerOptions.title } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsTileOverlayOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsTileOverlayOptions.kt index 5aff191..89756cc 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsTileOverlayOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsTileOverlayOptions.kt @@ -23,8 +23,8 @@ internal class GmsTileOverlayOptions(private val tileOverlayOptions: com.google. return tileOverlayOptions.fadeIn } - override fun getTileProvider(): TileProvider { - return tileOverlayOptions.tileProvider.toChoiceTileProvider() + override fun getTileProvider(): TileProvider? { + return tileOverlayOptions.tileProvider?.toChoiceTileProvider() } override fun getTransparency(): Float { @@ -39,8 +39,8 @@ internal class GmsTileOverlayOptions(private val tileOverlayOptions: com.google. return tileOverlayOptions.isVisible } - override fun tileProvider(tileProvider: TileProvider): TileOverlayOptions { - tileOverlayOptions.tileProvider(tileProvider.toGmsTileProvider()) + override fun tileProvider(tileProvider: TileProvider?): TileOverlayOptions { + tileProvider?.toGmsTileProvider()?.let { tileOverlayOptions.tileProvider(it) } return this } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsTileProvider.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsTileProvider.kt index d2e7960..c94fc29 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsTileProvider.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsTileProvider.kt @@ -12,8 +12,8 @@ import at.bluesource.choicesdk.maps.common.TileProvider */ internal class GmsTileProvider(private val tileProvider: com.google.android.gms.maps.model.TileProvider) : TileProvider { - override fun getTile(x: Int, y: Int, zoom: Int): Tile { - return tileProvider.getTile(x, y, zoom).toChoiceTile() + override fun getTile(x: Int, y: Int, zoom: Int): Tile? { + return tileProvider.getTile(x, y, zoom)?.toChoiceTile() } internal fun getTileProvider(): com.google.android.gms.maps.model.TileProvider { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsGroundOverlayOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsGroundOverlayOptions.kt index 22c4ed3..18e9df4 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsGroundOverlayOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsGroundOverlayOptions.kt @@ -46,8 +46,8 @@ internal class HmsGroundOverlayOptions(private val groundOverlayOptions: com.hua return groundOverlayOptions.bearing } - override fun getBounds(): LatLngBounds { - return groundOverlayOptions.bounds.toChoiceLatLngBounds() + override fun getBounds(): LatLngBounds? { + return groundOverlayOptions.bounds?.toChoiceLatLngBounds() } override fun getHeight(): Float { @@ -58,8 +58,8 @@ internal class HmsGroundOverlayOptions(private val groundOverlayOptions: com.hua return BitmapDescriptor.HmsBitmapDescriptor(groundOverlayOptions.image) } - override fun getLocation(): LatLng { - return groundOverlayOptions.location.toChoiceLatLng() + override fun getLocation(): LatLng? { + return groundOverlayOptions.location?.toChoiceLatLng() } override fun getTransparency(): Float { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMap.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMap.kt index 4bb9cc4..0f69497 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMap.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMap.kt @@ -215,8 +215,8 @@ internal class HmsMap(private var map: HuaweiMap) : Map { * Other ***************/ - override fun addMarker(options: MarkerOptions): Marker { - return HmsMarker(map.addMarker(options.toHmsMarkerOptions())) + override fun addMarker(options: MarkerOptions): Marker? { + return map.addMarker(options.toHmsMarkerOptions())?.let { HmsMarker(it) } } override fun addCircle(options: CircleOptions): Circle { @@ -235,9 +235,9 @@ internal class HmsMap(private var map: HuaweiMap) : Map { return map.addPolyline(options.toHmsPolylineOptions()).toChoicePolyline() } - override fun addTileOverlay(options: TileOverlayOptions): TileOverlay { - val overlay = map.addTileOverlay(options.toHmsTileOverlayOptions()) - return TileOverlay.create(overlay) + override fun addTileOverlay(options: TileOverlayOptions): TileOverlay? { + val overlay = options.toHmsTileOverlayOptions()?.let { map.addTileOverlay(it) } + return if (overlay != null) TileOverlay.create(overlay) else null } override fun animateCamera(update: CameraUpdate) { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMarkerOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMarkerOptions.kt index a9dc54c..c4ae27e 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMarkerOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMarkerOptions.kt @@ -61,11 +61,11 @@ internal class HmsMarkerOptions(private val markerOptions: com.huawei.hms.maps.m return markerOptions.rotation } - override fun getSnippet(): String { + override fun getSnippet(): String? { return markerOptions.snippet } - override fun getTitle(): String { + override fun getTitle(): String? { return markerOptions.title } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsTileOverlayOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsTileOverlayOptions.kt index 5801662..25b89ad 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsTileOverlayOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsTileOverlayOptions.kt @@ -23,8 +23,8 @@ internal class HmsTileOverlayOptions(private val tileOverlayOptions: com.huawei. return tileOverlayOptions.fadeIn } - override fun getTileProvider(): TileProvider { - return tileOverlayOptions.tileProvider.toChoiceTileProvider() + override fun getTileProvider(): TileProvider? { + return tileOverlayOptions.tileProvider?.toChoiceTileProvider() } override fun getTransparency(): Float { @@ -39,8 +39,8 @@ internal class HmsTileOverlayOptions(private val tileOverlayOptions: com.huawei. return tileOverlayOptions.isVisible } - override fun tileProvider(tileProvider: TileProvider): TileOverlayOptions { - tileOverlayOptions.tileProvider(tileProvider.toHmsTileProvider()) + override fun tileProvider(tileProvider: TileProvider?): TileOverlayOptions { + tileProvider?.toHmsTileProvider()?.let { tileOverlayOptions.tileProvider(it) } return this } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsTileProvider.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsTileProvider.kt index 11095c3..3eece1d 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsTileProvider.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsTileProvider.kt @@ -13,8 +13,8 @@ import at.bluesource.choicesdk.maps.common.TileProvider internal class HmsTileProvider(private val tileProvider: com.huawei.hms.maps.model.TileProvider) : TileProvider { - override fun getTile(x: Int, y: Int, zoom: Int): Tile { - return tileProvider.getTile(x, y, zoom).toChoiceTile() + override fun getTile(x: Int, y: Int, zoom: Int): Tile? { + return tileProvider.getTile(x, y, zoom)?.toChoiceTile() } internal fun getTileProvider(): com.huawei.hms.maps.model.TileProvider { diff --git a/ChoiceSDK/choicesdk-messaging/build.gradle b/ChoiceSDK/choicesdk-messaging/build.gradle index 051596c..9286b2a 100644 --- a/ChoiceSDK/choicesdk-messaging/build.gradle +++ b/ChoiceSDK/choicesdk-messaging/build.gradle @@ -65,8 +65,8 @@ dependencies { api project(":choicesdk-core") // GMS - implementation platform('com.google.firebase:firebase-bom:26.5.0') - implementation 'com.google.firebase:firebase-messaging' + implementation platform('com.google.firebase:firebase-bom:28.2.0') + implementation 'com.google.firebase:firebase-messaging-ktx' // HMS implementation 'com.huawei.hms:push:5.0.0.300' From 6d9f35eb1f9d8feb6f036679ef28c82989266cd7 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 10:41:03 +0200 Subject: [PATCH 10/12] update dependencies (androidx libraries, RxJava, Coroutines) --- ChoiceSDK/choicesdk-analytics/build.gradle | 4 ++-- ChoiceSDK/choicesdk-app/build.gradle | 8 +++++--- .../choicesdk_app/messages/MessagesActivity.kt | 9 ++++----- ChoiceSDK/choicesdk-core/build.gradle | 2 +- ChoiceSDK/choicesdk-location/build.gradle | 4 ++-- ChoiceSDK/choicesdk-maps/build.gradle | 4 ++-- ChoiceSDK/choicesdk-messaging/build.gradle | 6 +++--- .../choicesdk/messaging/common/MessagingRepository.kt | 11 +++++------ ChoiceSDK/choicesdk-signin/build.gradle | 4 ++-- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ChoiceSDK/choicesdk-analytics/build.gradle b/ChoiceSDK/choicesdk-analytics/build.gradle index 5ba0ea0..35a01c8 100644 --- a/ChoiceSDK/choicesdk-analytics/build.gradle +++ b/ChoiceSDK/choicesdk-analytics/build.gradle @@ -47,10 +47,10 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.core:core-ktx:1.6.0' // RX - api 'io.reactivex.rxjava3:rxjava:3.0.3' + api 'io.reactivex.rxjava3:rxjava:3.0.13' api 'io.reactivex.rxjava3:rxandroid:3.0.0' // RxRelay diff --git a/ChoiceSDK/choicesdk-app/build.gradle b/ChoiceSDK/choicesdk-app/build.gradle index e9f30cf..7da9c2e 100644 --- a/ChoiceSDK/choicesdk-app/build.gradle +++ b/ChoiceSDK/choicesdk-app/build.gradle @@ -90,8 +90,8 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'com.android.support:multidex:1.0.3' @@ -109,7 +109,7 @@ dependencies { implementation 'com.huawei.hms:hianalytics:5.0.1.300' // Coroutines - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0" // HTTP Lib implementation "com.squareup.retrofit2:retrofit:2.9.0" @@ -117,6 +117,8 @@ dependencies { implementation "androidx.biometric:biometric:1.1.0" + implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1" + } afterEvaluate { diff --git a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/messages/MessagesActivity.kt b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/messages/MessagesActivity.kt index 9b660f2..06e9488 100644 --- a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/messages/MessagesActivity.kt +++ b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/messages/MessagesActivity.kt @@ -14,6 +14,7 @@ import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import androidx.lifecycle.lifecycleScope import at.bluesource.choicesdk.core.MobileService import at.bluesource.choicesdk.core.MobileServicesDetector import at.bluesource.choicesdk.messaging.common.MessagingService @@ -24,7 +25,6 @@ import com.bluesource.choicesdk_app.R import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.observers.DisposableObserver -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import okhttp3.OkHttpClient import retrofit2.Retrofit @@ -85,9 +85,8 @@ class MessagesActivity : AppCompatActivity() { disposables.addAll(tokenObserver, messageObserver) - messagingService.getNewTokenObservable().subscribeWith(tokenObserver) - messagingService.getMessageReceivedObservable().observeOn(AndroidSchedulers.mainThread()) - .subscribeWith(messageObserver) + messagingService.getNewTokenObservable().observeOn(AndroidSchedulers.mainThread()).subscribeWith(tokenObserver) + messagingService.getMessageReceivedObservable().observeOn(AndroidSchedulers.mainThread()).subscribeWith(messageObserver) } @@ -184,7 +183,7 @@ class MessagesActivity : AppCompatActivity() { } private fun triggerNotification() { - GlobalScope.launch { + lifecycleScope.launch { try { val response: String = notificationApi.triggerNotification(getServiceType(), token) Log.d("ChoiceSDK", "Response: $response") diff --git a/ChoiceSDK/choicesdk-core/build.gradle b/ChoiceSDK/choicesdk-core/build.gradle index 78c31ce..e8eab21 100644 --- a/ChoiceSDK/choicesdk-core/build.gradle +++ b/ChoiceSDK/choicesdk-core/build.gradle @@ -47,7 +47,7 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.core:core-ktx:1.6.0' // GMS implementation 'com.google.android.gms:play-services-base:17.6.0' diff --git a/ChoiceSDK/choicesdk-location/build.gradle b/ChoiceSDK/choicesdk-location/build.gradle index 574bfad..b44cc4f 100644 --- a/ChoiceSDK/choicesdk-location/build.gradle +++ b/ChoiceSDK/choicesdk-location/build.gradle @@ -47,10 +47,10 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.core:core-ktx:1.6.0' // RX - api 'io.reactivex.rxjava3:rxjava:3.0.3' + api 'io.reactivex.rxjava3:rxjava:3.0.13' api 'io.reactivex.rxjava3:rxandroid:3.0.0' // RxRelay3 diff --git a/ChoiceSDK/choicesdk-maps/build.gradle b/ChoiceSDK/choicesdk-maps/build.gradle index 485a15a..394f06d 100644 --- a/ChoiceSDK/choicesdk-maps/build.gradle +++ b/ChoiceSDK/choicesdk-maps/build.gradle @@ -47,10 +47,10 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.core:core-ktx:1.6.0' // RX - api 'io.reactivex.rxjava3:rxjava:3.0.3' + api 'io.reactivex.rxjava3:rxjava:3.0.13' api 'io.reactivex.rxjava3:rxandroid:3.0.0' // RxRelay diff --git a/ChoiceSDK/choicesdk-messaging/build.gradle b/ChoiceSDK/choicesdk-messaging/build.gradle index 9286b2a..1035c70 100644 --- a/ChoiceSDK/choicesdk-messaging/build.gradle +++ b/ChoiceSDK/choicesdk-messaging/build.gradle @@ -47,15 +47,15 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.core:core-ktx:1.6.0' - def coroutines_version = "1.4.2" + def coroutines_version = "1.5.0" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx3:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutines_version" // RX - api 'io.reactivex.rxjava3:rxjava:3.0.3' + api 'io.reactivex.rxjava3:rxjava:3.0.13' api 'io.reactivex.rxjava3:rxandroid:3.0.0' // RxRelay3 diff --git a/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/common/MessagingRepository.kt b/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/common/MessagingRepository.kt index f021e36..593e6ff 100644 --- a/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/common/MessagingRepository.kt +++ b/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/common/MessagingRepository.kt @@ -8,10 +8,7 @@ import at.bluesource.choicesdk.messaging.factory.MessagingRepositoryFactory import com.jakewharton.rxrelay3.BehaviorRelay import com.jakewharton.rxrelay3.PublishRelay import io.reactivex.rxjava3.core.Observable -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext +import kotlinx.coroutines.* /** * Common class for the messaging service to communicate with @@ -34,7 +31,7 @@ internal class MessagingRepository : MessagingService { override fun requestToken(context: Context) { Log.d("ChoiceSDK", "Request token") - GlobalScope.launch { + applicationScope.launch { val token = tokenProvider.requestToken(context) withContext(Dispatchers.Main) { tokenRelay.accept(token) @@ -48,7 +45,7 @@ internal class MessagingRepository : MessagingService { override fun deleteToken(context: Context) { Log.d("ChoiceSDK", "Delete token") - GlobalScope.launch { + applicationScope.launch { tokenProvider.deleteToken(context) withContext(Dispatchers.Main) { tokenRelay.accept("") @@ -89,6 +86,8 @@ internal class MessagingRepository : MessagingService { } companion object { + private val applicationScope = CoroutineScope(SupervisorJob()) + @Volatile private var INSTANCE: MessagingRepository? = null diff --git a/ChoiceSDK/choicesdk-signin/build.gradle b/ChoiceSDK/choicesdk-signin/build.gradle index 55ae5be..c1fc97a 100644 --- a/ChoiceSDK/choicesdk-signin/build.gradle +++ b/ChoiceSDK/choicesdk-signin/build.gradle @@ -47,10 +47,10 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.core:core-ktx:1.6.0' // RX - api 'io.reactivex.rxjava3:rxjava:3.0.3' + api 'io.reactivex.rxjava3:rxjava:3.0.13' api 'io.reactivex.rxjava3:rxandroid:3.0.0' // RxRelay3 From 151b62c099328bacbf9ca6fc523a4e9c505ec84e Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 12:54:06 +0200 Subject: [PATCH 11/12] update Huawei dependencies --- ChoiceSDK/build.gradle | 3 +-- ChoiceSDK/choicesdk-analytics/build.gradle | 3 +-- .../src/main/AndroidManifest.xml | 4 ---- ChoiceSDK/choicesdk-app/build.gradle | 8 ++----- .../analytics/AnalyticsActivity.kt | 3 ++- ChoiceSDK/choicesdk-core/build.gradle | 2 +- ChoiceSDK/choicesdk-location/build.gradle | 2 +- .../src/main/AndroidManifest.xml | 12 +++++++--- .../location/common/LocationSettingsStates.kt | 4 ++-- ChoiceSDK/choicesdk-maps/build.gradle | 2 +- .../src/main/AndroidManifest.xml | 11 +++++++++- ChoiceSDK/choicesdk-messaging/build.gradle | 2 +- .../src/main/AndroidManifest.xml | 6 +++++ .../choicesdk/messaging/hms/HmsMessaging.kt | 5 ++--- ChoiceSDK/choicesdk-signin/build.gradle | 2 +- .../src/main/AndroidManifest.xml | 9 ++++++++ .../choicesdk/signin/hms/HmsSignInAccount.kt | 3 ++- README.md | 6 ++--- documentation/analytics.md | 22 ------------------- documentation/hmscoresdksetup.md | 10 +++------ 20 files changed, 57 insertions(+), 62 deletions(-) diff --git a/ChoiceSDK/build.gradle b/ChoiceSDK/build.gradle index be5f801..7ce7c3e 100644 --- a/ChoiceSDK/build.gradle +++ b/ChoiceSDK/build.gradle @@ -32,8 +32,7 @@ buildscript { classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1' // HMS - classpath 'com.huawei.agconnect:agcp:1.5.0.300' - classpath 'com.huawei.hms.plugin:analytics:5.0.1.300' + classpath 'com.huawei.agconnect:agcp:1.5.2.300' } } diff --git a/ChoiceSDK/choicesdk-analytics/build.gradle b/ChoiceSDK/choicesdk-analytics/build.gradle index 35a01c8..3f241dd 100644 --- a/ChoiceSDK/choicesdk-analytics/build.gradle +++ b/ChoiceSDK/choicesdk-analytics/build.gradle @@ -64,11 +64,10 @@ dependencies { implementation 'com.google.firebase:firebase-analytics-ktx' // HMS - implementation 'com.huawei.hms:hianalytics:5.0.1.300' + implementation 'com.huawei.hms:hianalytics:6.0.0.300' } - dokkaHtml { outputDirectory.set(file("$buildDir/dokka")) dokkaSourceSets { diff --git a/ChoiceSDK/choicesdk-analytics/src/main/AndroidManifest.xml b/ChoiceSDK/choicesdk-analytics/src/main/AndroidManifest.xml index f66bcf4..a5012f9 100644 --- a/ChoiceSDK/choicesdk-analytics/src/main/AndroidManifest.xml +++ b/ChoiceSDK/choicesdk-analytics/src/main/AndroidManifest.xml @@ -2,10 +2,6 @@ - - - - diff --git a/ChoiceSDK/choicesdk-app/build.gradle b/ChoiceSDK/choicesdk-app/build.gradle index 7da9c2e..24b2971 100644 --- a/ChoiceSDK/choicesdk-app/build.gradle +++ b/ChoiceSDK/choicesdk-app/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'com.google.gms.google-services' +apply plugin: 'com.huawei.agconnect' apply plugin: 'com.google.firebase.crashlytics' -apply plugin: 'com.huawei.hms.plugin.analytics' apply plugin: 'com.jaredsburrows.license' apply from: "../licenseCheck.gradle" @@ -102,11 +102,7 @@ dependencies { implementation project(":choicesdk-signin") // for HMS map clustering - implementation 'com.huawei.hms:maps:5.0.5.301' - - // hms plugin version of analytics needs to have a dependency - // in the gradle file where the plugin is applied - implementation 'com.huawei.hms:hianalytics:5.0.1.300' + implementation 'com.huawei.hms:maps:5.3.0.300' // Coroutines implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0" diff --git a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/analytics/AnalyticsActivity.kt b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/analytics/AnalyticsActivity.kt index 6b143bf..54ac9f0 100644 --- a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/analytics/AnalyticsActivity.kt +++ b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/analytics/AnalyticsActivity.kt @@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity import at.bluesource.choicesdk.analytics.common.Analytics import at.bluesource.choicesdk.analytics.factory.AnalyticsFactory import com.bluesource.choicesdk_app.R +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.observers.DisposableObserver @@ -55,7 +56,7 @@ class AnalyticsActivity : AppCompatActivity() { } disposables.add(observer) - analytics.getAppInstanceIdObservable().subscribeWith(observer) + analytics.getAppInstanceIdObservable().observeOn(AndroidSchedulers.mainThread()).subscribeWith(observer) } override fun onDestroy() { diff --git a/ChoiceSDK/choicesdk-core/build.gradle b/ChoiceSDK/choicesdk-core/build.gradle index e8eab21..fd7b626 100644 --- a/ChoiceSDK/choicesdk-core/build.gradle +++ b/ChoiceSDK/choicesdk-core/build.gradle @@ -53,7 +53,7 @@ dependencies { implementation 'com.google.android.gms:play-services-base:17.6.0' // HMS - implementation "com.huawei.hms:base:5.0.5.300" + implementation "com.huawei.hms:base:5.3.0.301" } diff --git a/ChoiceSDK/choicesdk-location/build.gradle b/ChoiceSDK/choicesdk-location/build.gradle index b44cc4f..12af5c0 100644 --- a/ChoiceSDK/choicesdk-location/build.gradle +++ b/ChoiceSDK/choicesdk-location/build.gradle @@ -63,7 +63,7 @@ dependencies { implementation 'com.google.android.gms:play-services-location:18.0.0' // HMS - implementation 'com.huawei.hms:location:5.0.4.300' + implementation 'com.huawei.hms:location:5.1.0.303' } dokkaHtml { diff --git a/ChoiceSDK/choicesdk-location/src/main/AndroidManifest.xml b/ChoiceSDK/choicesdk-location/src/main/AndroidManifest.xml index c8211d6..efe36f4 100644 --- a/ChoiceSDK/choicesdk-location/src/main/AndroidManifest.xml +++ b/ChoiceSDK/choicesdk-location/src/main/AndroidManifest.xml @@ -2,8 +2,14 @@ - - - + + + + + + + + + \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt index 056e246..e33c3a5 100644 --- a/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt +++ b/ChoiceSDK/choicesdk-location/src/main/java/at/bluesource/choicesdk/location/common/LocationSettingsStates.kt @@ -62,9 +62,9 @@ interface LocationSettingsStates { return object : LocationSettingsStates { override val isGpsUsable: Boolean - get() = this@toChoiceLocationSettingsStates.isGpsUsable + get() = this@toChoiceLocationSettingsStates.isGnssUsable override val isGpsPresent: Boolean - get() = this@toChoiceLocationSettingsStates.isGpsPresent + get() = this@toChoiceLocationSettingsStates.isGnssPresent override val isNetworkLocationUsable: Boolean get() = this@toChoiceLocationSettingsStates.isNetworkLocationUsable override val isNetworkLocationPresent: Boolean diff --git a/ChoiceSDK/choicesdk-maps/build.gradle b/ChoiceSDK/choicesdk-maps/build.gradle index 394f06d..7a173e3 100644 --- a/ChoiceSDK/choicesdk-maps/build.gradle +++ b/ChoiceSDK/choicesdk-maps/build.gradle @@ -64,7 +64,7 @@ dependencies { implementation 'com.google.maps.android:android-maps-utils:0.5' // HMS - implementation 'com.huawei.hms:maps:5.0.5.301' + implementation 'com.huawei.hms:maps:5.3.0.300' implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1" } diff --git a/ChoiceSDK/choicesdk-maps/src/main/AndroidManifest.xml b/ChoiceSDK/choicesdk-maps/src/main/AndroidManifest.xml index 46872cd..3de4f63 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/AndroidManifest.xml +++ b/ChoiceSDK/choicesdk-maps/src/main/AndroidManifest.xml @@ -2,6 +2,15 @@ - + + + + + + + + + + \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-messaging/build.gradle b/ChoiceSDK/choicesdk-messaging/build.gradle index 1035c70..ad1ae80 100644 --- a/ChoiceSDK/choicesdk-messaging/build.gradle +++ b/ChoiceSDK/choicesdk-messaging/build.gradle @@ -69,7 +69,7 @@ dependencies { implementation 'com.google.firebase:firebase-messaging-ktx' // HMS - implementation 'com.huawei.hms:push:5.0.0.300' + implementation 'com.huawei.hms:push:5.3.0.301' } dokkaHtml { diff --git a/ChoiceSDK/choicesdk-messaging/src/main/AndroidManifest.xml b/ChoiceSDK/choicesdk-messaging/src/main/AndroidManifest.xml index 4d745fb..edee195 100644 --- a/ChoiceSDK/choicesdk-messaging/src/main/AndroidManifest.xml +++ b/ChoiceSDK/choicesdk-messaging/src/main/AndroidManifest.xml @@ -25,4 +25,10 @@ + + + + + + \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/hms/HmsMessaging.kt b/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/hms/HmsMessaging.kt index aa0e05a..9760ba8 100644 --- a/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/hms/HmsMessaging.kt +++ b/ChoiceSDK/choicesdk-messaging/src/main/java/at/bluesource/choicesdk/messaging/hms/HmsMessaging.kt @@ -14,8 +14,7 @@ import com.huawei.hms.push.HmsMessaging * * @see com.huawei.hms.push.HmsMessaging */ -internal class HmsMessaging(private var context: Context) : - Messaging { +internal class HmsMessaging(private var context: Context) : Messaging { override fun isAutoInitEnabled(): Boolean { return HmsMessaging.getInstance(context).isAutoInitEnabled @@ -50,7 +49,7 @@ internal class HmsMessaging(private var context: Context) : fun getInstance(context: Context): at.bluesource.choicesdk.messaging.hms.HmsMessaging { return INSTANCE ?: synchronized(this) { - HmsMessaging(context).also { + at.bluesource.choicesdk.messaging.hms.HmsMessaging(context).also { INSTANCE = it } } diff --git a/ChoiceSDK/choicesdk-signin/build.gradle b/ChoiceSDK/choicesdk-signin/build.gradle index c1fc97a..eb12c72 100644 --- a/ChoiceSDK/choicesdk-signin/build.gradle +++ b/ChoiceSDK/choicesdk-signin/build.gradle @@ -63,7 +63,7 @@ dependencies { implementation 'com.google.android.gms:play-services-auth:19.0.0' // HMS - implementation 'com.huawei.hms:hwid:4.0.4.300' // account kit + implementation 'com.huawei.hms:hwid:5.3.0.302' // account kit } dokkaHtml { diff --git a/ChoiceSDK/choicesdk-signin/src/main/AndroidManifest.xml b/ChoiceSDK/choicesdk-signin/src/main/AndroidManifest.xml index 443fb32..2005bc7 100644 --- a/ChoiceSDK/choicesdk-signin/src/main/AndroidManifest.xml +++ b/ChoiceSDK/choicesdk-signin/src/main/AndroidManifest.xml @@ -2,4 +2,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/hms/HmsSignInAccount.kt b/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/hms/HmsSignInAccount.kt index 573d74d..d5fd0a9 100644 --- a/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/hms/HmsSignInAccount.kt +++ b/ChoiceSDK/choicesdk-signin/src/main/java/at/bluesource/choicesdk/signin/hms/HmsSignInAccount.kt @@ -2,6 +2,7 @@ package at.bluesource.choicesdk.signin.hms import android.accounts.Account import android.net.Uri +import at.bluesource.choicesdk.core.ChoiceSdk import at.bluesource.choicesdk.signin.common.Scope import at.bluesource.choicesdk.signin.common.Scope.Companion.toChoiceScope import at.bluesource.choicesdk.signin.common.SignInAccount @@ -15,7 +16,7 @@ import com.huawei.hms.support.hwid.result.AuthHuaweiId */ internal class HmsSignInAccount(private val hmsAccount: AuthHuaweiId) : SignInAccount { override val account: Account? - get() = hmsAccount.huaweiAccount + get() = hmsAccount.getHuaweiAccount(ChoiceSdk.getContext()) override val displayName: String? get() = hmsAccount.displayName override val email: String? diff --git a/README.md b/README.md index be1537e..9db2361 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,10 @@ buildscript{ dependencies { // GMS - classpath 'com.google.gms:google-services:4.3.3' + classpath 'com.google.gms:google-services:4.3.8' // HMS - classpath 'com.huawei.agconnect:agcp:1.4.1.300' + classpath 'com.huawei.agconnect:agcp:1.5.2.300' } } @@ -69,7 +69,7 @@ apply plugin: 'com.huawei.agconnect' Add the following dependencies as required to your app. GMS, Firebase and HMS dependencies are included, so they do not need to be declared in your app. ```gradle dependencies { - def choicesdk_version = '0.1.6' + def choicesdk_version = '0.2.0' implementation "at.bluesource.choicesdk:choicesdk-analytics:$choicesdk_version" implementation "at.bluesource.choicesdk:choicesdk-location:$choicesdk_version" implementation "at.bluesource.choicesdk:choicesdk-maps:$choicesdk_version" diff --git a/documentation/analytics.md b/documentation/analytics.md index 69bb88e..7df771b 100644 --- a/documentation/analytics.md +++ b/documentation/analytics.md @@ -2,28 +2,6 @@ Analytics are fairly simple as the main logging happens in the background. HMS has some extra functionality where the page exit can be set as well, this might be needed to get improved analytics accuracy. -## Additional setup for "Advanced Analytics Service" - -We recommend to enabled "Advanced Analytics Service" in AppGallery Connect (under "HUAWEI Analytics"). Please make sure to re-download `agconnect-services.json` after enabling it and add additional Gradle dependencies: - -`Project` gradle: -```gradle -buildscript { - dependencies { - classpath 'com.huawei.hms.plugin:analytics:5.0.1.300' - } -} -``` - -`App` gradle: -```gradle -apply plugin: 'com.huawei.hms.plugin.analytics' - -dependencies { - implementation 'com.huawei.hms:hianalytics:5.0.1.300' -} -``` - ## Usage Getting the analytics instance: diff --git a/documentation/hmscoresdksetup.md b/documentation/hmscoresdksetup.md index 0e2bd4f..13f0549 100644 --- a/documentation/hmscoresdksetup.md +++ b/documentation/hmscoresdksetup.md @@ -62,8 +62,9 @@ Project integration: repositories { maven { url 'http://developer.huawei.com/repo/' } } + dependencies { - classpath 'com.huawei.agconnect:agcp:1.5.0.300' + classpath 'com.huawei.agconnect:agcp:1.5.2.300' } } @@ -73,14 +74,9 @@ Project integration: } } ``` -- Add dependencies and plugin to app-level `build.gradle` file +- Add this plugin to app-level `build.gradle` file ```gradle apply plugin: 'com.huawei.agconnect' - - dependencies { - // Add dependencies. - implementation 'com.huawei.agconnect:agconnect-core:1.4.0.300' - } ``` - If needed: Configure Proguard to prevent HMS from being obfuscated ```java From 00d5c75acbcd9701624426b7b0bfbd5951eca284 Mon Sep 17 00:00:00 2001 From: Stefan Brabenetz Date: Thu, 1 Jul 2021 13:09:50 +0200 Subject: [PATCH 12/12] update readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 9db2361..9de4fc3 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,11 @@ class YourApp : Application() { } ``` +By default the SDK checks for GMS availability first. It is also possible to set the priority in which order the service availability is checked (for example if you prefer HMS services over GMS services on devices where both are available): +```kotlin +ChoiceSdk.init(this, listOf(MobileService.HMS, MobileService.GMS)) +``` + ## Usage Usually instances of SDK classes can be created by using their corresponding factory, for example `AnalyticsFactory.getAnalytics(this)`. These calls can throw an `UnsupportedOperationException` if neither GMS nor HMS services are available, so make sure to check beforehand.