diff --git a/code/core/api/core.api b/code/core/api/core.api index 39d1e2200..5ab422d6d 100644 --- a/code/core/api/core.api +++ b/code/core/api/core.api @@ -227,10 +227,12 @@ public final class com/adobe/marketing/mobile/MobileCore { public static fun dispatchResponseEvent (Lcom/adobe/marketing/mobile/Event;Lcom/adobe/marketing/mobile/Event;Lcom/adobe/marketing/mobile/ExtensionErrorCallback;)Z public static fun extensionVersion ()Ljava/lang/String; public static fun getApplication ()Landroid/app/Application; + public static fun getLargeIconResourceID ()I public static fun getLogLevel ()Lcom/adobe/marketing/mobile/LoggingMode; public static fun getMessagingDelegate ()Lcom/adobe/marketing/mobile/services/MessagingDelegate; public static fun getPrivacyStatus (Lcom/adobe/marketing/mobile/AdobeCallback;)V public static fun getSdkIdentities (Lcom/adobe/marketing/mobile/AdobeCallback;)V + public static fun getSmallIconResourceID ()I public static fun lifecyclePause ()V public static fun lifecycleStart (Ljava/util/Map;)V public static fun log (Lcom/adobe/marketing/mobile/LoggingMode;Ljava/lang/String;Ljava/lang/String;)V diff --git a/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt b/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt index c397b505e..d36d4797c 100644 --- a/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt +++ b/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt @@ -13,7 +13,7 @@ package com.adobe.marketing.mobile.internal internal object CoreConstants { const val LOG_TAG = "MobileCore" - const val VERSION = "2.4.0" + const val VERSION = "2.5.0" object EventDataKeys { /** diff --git a/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java b/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java index 889f92730..43e7af221 100644 --- a/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java +++ b/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java @@ -319,7 +319,16 @@ public static void setSmallIconResourceID(final int resourceID) { } /** - * Sets the resource Id for small icon. + * Returns the resource Id for small icon if it was set by `setSmallIconResourceID`. + * + * @return a `int` value if it has been set, otherwise -1 + */ + public static int getSmallIconResourceID() { + return AppResourceStore.INSTANCE.getSmallIconResourceID(); + } + + /** + * Sets the resource Id for large icon. * * @param resourceID the resource Id of the icon */ @@ -327,6 +336,15 @@ public static void setLargeIconResourceID(final int resourceID) { AppResourceStore.INSTANCE.setLargeIconResourceID(resourceID); } + /** + * Returns the resource Id for large icon if it was set by `setLargeIconResourceID`. + * + * @return a `int` value if it has been set, otherwise -1 + */ + public static int getLargeIconResourceID() { + return AppResourceStore.INSTANCE.getLargeIconResourceID(); + } + // ======================================================== // Identifiers // ======================================================== diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt b/code/core/src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt index 2b64cb7ac..4d459cbc7 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt +++ b/code/core/src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt @@ -35,7 +35,7 @@ import kotlin.test.assertTrue @RunWith(MockitoJUnitRunner.Silent::class) class MobileCoreTests { - private var EXTENSION_VERSION = "2.4.0" + private var EXTENSION_VERSION = "2.5.0" @Mock private lateinit var mockedEventHub: EventHub diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java b/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java index e8aec2620..cf2c5c6c8 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java +++ b/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java @@ -15,12 +15,14 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; import android.content.Context; import android.content.SharedPreferences; import com.adobe.marketing.mobile.services.AppContextService; import com.adobe.marketing.mobile.services.ServiceProviderModifier; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -55,11 +57,44 @@ public void beforeEach() { ServiceProviderModifier.setAppContextService(mockAppContextService); } + @After + public void afterEach() { + reset(mockSharedPreferences); + AppResourceStore.INSTANCE.setLargeIconResourceID(-1); + AppResourceStore.INSTANCE.setSmallIconResourceID(-1); + } + + // ****************************************************************************************** + // SmallIconResourceId Tests + // ****************************************************************************************** + @Test - public void testSetLargeIconResourceId_ValidIdSet() { + public void testGetSmallIconResourceId_ValidIdSet() { + // Setup + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + .thenReturn(123456); + + // Test + int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); + assertEquals(123456, actualResourceId); + } + + @Test + public void testGetSmallIconResourceId_NoIdSet() { + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())).thenReturn(-1); + + // Test + int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); + assertEquals(actualResourceId, -1); + } + + @Test + public void testSetSmallIconResourceId_ValidIdSetTwice() { // Setup final int expectedValueStored = 123456; - when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) + AppResourceStore.INSTANCE.setSmallIconResourceID(11111); + + when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) .thenAnswer( new Answer() { @Override @@ -72,13 +107,15 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) }); // Test - AppResourceStore.INSTANCE.setLargeIconResourceID(expectedValueStored); + AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored); } @Test public void testSetSmallIconResourceId_ValidIdSet() { // Setup final int expectedValueStored = 123456; + AppResourceStore.INSTANCE.setSmallIconResourceID(11111); + when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) .thenAnswer( new Answer() { @@ -95,12 +132,34 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored); } + // ****************************************************************************************** + // LargeIconResourceId Tests + // ****************************************************************************************** + @Test - public void testSetLargeIconResourceId_ValidIdSetTwice() { + public void testLargeIconResourceId_ValidIdSet() { // Setup - final int expectedValueStored = 123456; - AppResourceStore.INSTANCE.setLargeIconResourceID(111111); + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) + .thenReturn(123456); + + // Test + int actualResourceId = AppResourceStore.INSTANCE.getLargeIconResourceID(); + assertEquals(123456, actualResourceId); + } + + @Test + public void testGetLargeIconResourceId_NoIdSet() { + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())).thenReturn(-1); + + // Test + int actualResourceId = AppResourceStore.INSTANCE.getLargeIconResourceID(); + assertEquals(actualResourceId, -1); + } + @Test + public void testSetLargeIconResourceId_ValidIdSet() { + // Setup + final int expectedValueStored = 123456; when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) .thenAnswer( new Answer() { @@ -118,12 +177,12 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) } @Test - public void testSetSmallIconResourceId_ValidIdSetTwice() { + public void testSetLargeIconResourceId_ValidIdSetTwice() { // Setup final int expectedValueStored = 123456; - AppResourceStore.INSTANCE.setSmallIconResourceID(11111); + AppResourceStore.INSTANCE.setLargeIconResourceID(111111); - when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) .thenAnswer( new Answer() { @Override @@ -136,6 +195,6 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) }); // Test - AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored); + AppResourceStore.INSTANCE.setLargeIconResourceID(expectedValueStored); } } diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/internal/configuration/ConfigurationExtensionTests.kt b/code/core/src/test/java/com/adobe/marketing/mobile/internal/configuration/ConfigurationExtensionTests.kt index 083db7254..2b8fee992 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/internal/configuration/ConfigurationExtensionTests.kt +++ b/code/core/src/test/java/com/adobe/marketing/mobile/internal/configuration/ConfigurationExtensionTests.kt @@ -60,7 +60,7 @@ import kotlin.test.assertTrue @RunWith(MockitoJUnitRunner.Silent::class) class ConfigurationExtensionTests { - private var EXTENSION_VERSION = "2.4.0" + private var EXTENSION_VERSION = "2.5.0" @Mock private lateinit var mockServiceProvider: ServiceProvider diff --git a/code/gradle.properties b/code/gradle.properties index eb7862553..15549a7e9 100644 --- a/code/gradle.properties +++ b/code/gradle.properties @@ -6,7 +6,7 @@ android.useAndroidX=true # #Maven artifacts #Core extension -coreExtensionVersion=2.4.0 +coreExtensionVersion=2.5.0 coreExtensionName=core coreExtensionAARName=core-phone-release.aar coreMavenRepoName=AdobeMobileCoreSdk