Skip to content

Commit

Permalink
Updating Android SDK to version 33.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlogan committed Oct 3, 2024
1 parent 04d10e6 commit f0df61c
Show file tree
Hide file tree
Showing 41 changed files with 244 additions and 145 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## 33.0.0

[Release Date](https://github.com/braze-inc/braze-android-sdk/releases/tag/v33.0.0)

##### Breaking
- Updated Kotlin from 1.8 to Kotlin 2.0.

##### Fixed
- Braze HTML In-App Message bridge method `incrementCustomUserAttribute()` will use the provided value as the increment amount instead of always incrementing by 1.
- Fixed an issue where In-App Message text alignments would not match what was set in the dashboard in some cases.
- Removed `android:supportsRtl="true"` from android-sdk-ui `AndroidManifest.xml`. You should have this in your application `AndroidManifest.xml`.
- Removed `android:textAlignment="viewStart"` from the In-App Message layouts, since this is sent by the server.
- Fixed an issue where Content Cards and Feature Flags were not refreshing after a session started due to a session timeout.
- Fixed an issue with SDK Authentication where tokens that expired and refreshed mid session would be treated as failed.

##### Changed
- Braze HTML In-App Message bridge method will now also accept strings for `incrementCustomUserAttribute()`, `setDateOfBirth()`, `setCustomLocationAttribute()`, and `logPurchase()`.

## 32.1.0

[Release Date](https://github.com/braze-inc/braze-android-sdk/releases/tag/v32.1.0)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Successful marketing automation is essential to the future of your mobile app. B

- The Braze Android SDK supports Android 5.0+ / API 21+ (Lollipop and up).
- Last Target SDK Version: 35
- Kotlin version: `org.jetbrains.kotlin:kotlin-stdlib:1.8.10`
- Kotlin version: `org.jetbrains.kotlin:kotlin-stdlib:2.0.20`
- Last Compiled Firebase Cloud Messaging Version: 23.2.0
- Braze uses [Font Awesome](https://fortawesome.github.io/Font-Awesome/) 4.3.0 for in-app message icons. Check out the [cheat sheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) to browse available icons.

Expand All @@ -36,8 +36,8 @@ Our SDK is now hosted in Maven Central. You can remove `https://braze-inc.github

```
dependencies {
implementation 'com.braze:android-sdk-ui:32.1.+'
implementation 'com.braze:android-sdk-location:32.1.+'
implementation 'com.braze:android-sdk-ui:33.0.+'
implementation 'com.braze:android-sdk-location:33.0.+'
...
}
```
Expand All @@ -56,7 +56,7 @@ repositories {

```
dependencies {
implementation 'com.braze:android-sdk-ui:32.1.+'
implementation 'com.braze:android-sdk-ui:33.0.+'
}
```

Expand Down
11 changes: 4 additions & 7 deletions android-sdk-jetpack-compose/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "org.jetbrains.kotlin.plugin.compose"

dependencies {
api "com.braze:android-sdk-base:${BRAZE_SDK_VERSION}"
Expand Down Expand Up @@ -28,18 +29,14 @@ android {
}

kotlinOptions {
freeCompilerArgs = ['-Xjvm-default=all', '-Xopt-in=kotlin.RequiresOptIn']
freeCompilerArgs = ["-Xjvm-default=all", "-opt-in=kotlin.RequiresOptIn"]
jvmTarget = "1.8"
}

buildFeatures {
compose true
}

composeOptions {
kotlinCompilerExtensionVersion "${KOTLIN_COMPILER_EXTENSION_VERSION}"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import com.braze.jetpackcompose.contentcards.cards.ContentCard
import com.braze.jetpackcompose.contentcards.styling.ContentCardListStyling
import com.braze.jetpackcompose.contentcards.styling.ContentCardStyling
import com.braze.models.cards.Card
import com.braze.support.BrazeLogger.Priority.W
import com.braze.support.BrazeLogger.Priority.V
import com.braze.support.BrazeLogger.Priority.W
import com.braze.support.BrazeLogger.brazelog
import com.braze.ui.contentcards.BrazeContentCardUtils
import kotlinx.coroutines.Dispatchers
Expand All @@ -76,6 +76,8 @@ import kotlinx.coroutines.launch
* or return `false` and have the card rendered by default.
* If you use this, you are responsible for handling all aspects of card rendering (unread, pinned, etc.).
* You also need to handle card clicks (See `BrazeContentCardUtils.handleCardClick`).
* @param style The styling for the list of content cards.
* @param cardStyle The styling for the individual content cards.
*/
fun ContentCardsList(
cards: List<Card>? = null,
Expand Down Expand Up @@ -103,7 +105,7 @@ fun ContentCardsList(
var didInitialLoad by remember { mutableStateOf(false) }

val refreshScope = rememberCoroutineScope()
var refreshing by remember { mutableStateOf(false) }
var isRefreshing by remember { mutableStateOf(false) }

var networkUnavailableJob: Job? = null

Expand All @@ -114,13 +116,13 @@ fun ContentCardsList(
val AUTO_HIDE_REFRESH_INDICATOR_DELAY_MS = 2500L

fun refresh() = refreshScope.launch {
refreshing = true
isRefreshing = true
Braze.getInstance(context).requestContentCardsRefresh()
delay(AUTO_HIDE_REFRESH_INDICATOR_DELAY_MS)
refreshing = false
isRefreshing = false
}

val refreshState = rememberPullRefreshState(refreshing, ::refresh)
val refreshState = rememberPullRefreshState(isRefreshing, ::refresh)

val impressedCards = remember {
mutableStateListOf<String>()
Expand All @@ -129,7 +131,7 @@ fun ContentCardsList(
fun networkUnavailable() {
brazelog(TAG) { "Network is unavailable." }
networkUnavailableJob = null
refreshing = false
isRefreshing = false
}

@Composable
Expand Down Expand Up @@ -192,7 +194,7 @@ fun ContentCardsList(
networkUnavailableJob?.cancel()
networkUnavailableJob = null
replaceCards(event.allCards)
refreshing = false
isRefreshing = false
}

fun logCardImpression(card: Card) {
Expand Down Expand Up @@ -277,7 +279,7 @@ fun ContentCardsList(
if (myCards.isEmpty() && Braze.getInstance(context).areCachedContentCardsStale()) {
Braze.getInstance(context).requestContentCardsRefresh()
if (networkUnavailableJob == null) {
refreshing = true
isRefreshing = true
networkUnavailableJob =
BrazeCoroutineScope.launchDelayed(NETWORK_PROBLEM_WARNING_MS, Dispatchers.Main) {
networkUnavailable()
Expand Down Expand Up @@ -437,7 +439,7 @@ fun ContentCardsList(
}
}
if (cards == null) {
PullRefreshIndicator(refreshing, refreshState, Modifier.align(Alignment.TopCenter))
PullRefreshIndicator(isRefreshing, refreshState, Modifier.align(Alignment.TopCenter))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@ fun ContentCard(
val lifecycleOwner = LocalLifecycleOwner.current
DisposableEffect(LocalLifecycleOwner.current) {
val observer = LifecycleEventObserver { _, event ->
when (event) {
Lifecycle.Event.ON_PAUSE -> {
brazelog(TAG) { "OnPause called in ContentCardComposable" }
if (!card.isIndicatorHighlighted) {
card.isIndicatorHighlighted = true
isUnread = false
}
if (event == Lifecycle.Event.ON_PAUSE) {
brazelog(TAG) { "OnPause called in ContentCardComposable" }
if (!card.isIndicatorHighlighted) {
card.isIndicatorHighlighted = true
isUnread = false
}
else -> Unit
} else {
Unit
}
}
lifecycleOwner.lifecycle.addObserver(observer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ val UndefinedAlignment: Alignment = BiasAlignment(-2.0f, -2.0f)
* @property shortNewsContentCardStyle Style to use specifically for Short News Content Cards. See note above.
* @property captionedImageContentCardStyle Style to use specifically for Captioned Image Content Cards. See note above.
*/
@Suppress("LongParameterList", "TooManyFunctions")
@Suppress("LongParameterList", "TooManyFunctions", "BooleanPropertyNaming")
open class ContentCardStyling(
val modifier: Modifier? = null,
val pinnedResourceId: Int = R.drawable.com_braze_content_card_icon_pinned,
Expand Down Expand Up @@ -105,7 +105,8 @@ open class ContentCardStyling(
val descriptionTextColor: Color = Color.Unspecified,
val actionHintTextColor: Color = Color.Unspecified,
val imageOnlyContentCardStyle: BrazeImageOnlyContentCardStyling = BrazeImageOnlyContentCardStyling(),
val textAnnouncementContentCardStyle: BrazeTextAnnouncementContentCardStyling = BrazeTextAnnouncementContentCardStyling(),
val textAnnouncementContentCardStyle: BrazeTextAnnouncementContentCardStyling =
BrazeTextAnnouncementContentCardStyling(),
val shortNewsContentCardStyle: BrazeShortNewsContentCardStyling = BrazeShortNewsContentCardStyling(),
val captionedImageContentCardStyle: BrazeCaptionedImageContentCardStyling = BrazeCaptionedImageContentCardStyling(),
) {
Expand Down Expand Up @@ -636,6 +637,7 @@ open class ContentCardStyling(
* NOTE: If modifier is used, then it should have a background color specified in it.
*
* @param type
* @param extraPadding
* @return
*/
@SuppressLint("ModifierFactoryExtensionFunction")
Expand Down Expand Up @@ -764,7 +766,7 @@ class BrazeImageOnlyContentCardStyling(
shadowRadius = shadowRadius
)

@Suppress("LongParameterList")
@Suppress("LongParameterList", "BooleanPropertyNaming")
class BrazeTextAnnouncementContentCardStyling(
modifier: Modifier? = null,
pinnedResourceId: Int = 0,
Expand Down Expand Up @@ -826,7 +828,7 @@ class BrazeTextAnnouncementContentCardStyling(
actionHintTextColor = actionHintTextColor
)

@Suppress("LongParameterList")
@Suppress("LongParameterList", "BooleanPropertyNaming")
class BrazeShortNewsContentCardStyling(
modifier: Modifier? = null,
pinnedResourceId: Int = 0,
Expand Down Expand Up @@ -895,7 +897,7 @@ class BrazeShortNewsContentCardStyling(
actionHintTextColor = actionHintTextColor
)

@Suppress("LongParameterList")
@Suppress("LongParameterList", "BooleanPropertyNaming")
class BrazeCaptionedImageContentCardStyling(
modifier: Modifier? = null,
pinnedResourceId: Int = 0,
Expand Down
6 changes: 3 additions & 3 deletions android-sdk-location/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: "com.android.library"
apply plugin: "kotlin-android"

dependencies {
api "com.braze:android-sdk-base:${BRAZE_SDK_VERSION}"
Expand All @@ -20,7 +20,7 @@ android {
}

kotlinOptions {
freeCompilerArgs = ['-Xjvm-default=all', '-Xopt-in=kotlin.RequiresOptIn']
freeCompilerArgs = ["-Xjvm-default=all", "-opt-in=kotlin.RequiresOptIn"]
jvmTarget = "1.8"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ object GooglePlayLocationUtils {
desiredGeofencesToRegister: List<BrazeGeofence>,
geofenceRequestIntent: PendingIntent,
removalFunction: (List<String>) -> Unit = { removeGeofencesRegisteredWithGeofencingClient(context, it) },
registerFunction: (List<BrazeGeofence>) -> Unit = { registerGeofencesWithGeofencingClient(context, it, geofenceRequestIntent) }
registerFunction: (List<BrazeGeofence>) -> Unit = {
registerGeofencesWithGeofencingClient(context, it, geofenceRequestIntent)
}
) {
brazelog(V) { "registerGeofencesWithGooglePlayIfNecessary called with $desiredGeofencesToRegister" }
try {
Expand Down Expand Up @@ -97,6 +99,7 @@ object GooglePlayLocationUtils {
/**
* Requests a single location update from Google Play Location Services for the given pending intent.
*
* @param context
* @param resultListener A callback of type [IBrazeGeofenceLocationUpdateListener]
* which will be informed of the result of location update.
*/
Expand Down Expand Up @@ -136,6 +139,7 @@ object GooglePlayLocationUtils {
/**
* Registers a list of [Geofence] with a [com.google.android.gms.location.GeofencingClient].
*
* @param context
* @param newGeofencesToRegister List of [BrazeGeofence]s to register
* @param geofenceRequestIntent A pending intent to fire on completion of adding the [Geofence]s with
* the [com.google.android.gms.location.GeofencingClient].
Expand Down Expand Up @@ -184,6 +188,7 @@ object GooglePlayLocationUtils {
/**
* Un-registers a list of [Geofence] with a [com.google.android.gms.location.GeofencingClient].
*
* @param context
* @param obsoleteGeofenceIds List of [String]s containing Geofence IDs that needs to be un-registered
*/
@VisibleForTesting
Expand Down Expand Up @@ -229,6 +234,7 @@ object GooglePlayLocationUtils {
/**
* Stores the list of [BrazeGeofence] which are successfully registered.
*
* @param context
* @param newGeofencesToRegister List of [BrazeGeofence]s to store in SharedPreferences
*/
@VisibleForTesting
Expand All @@ -244,6 +250,7 @@ object GooglePlayLocationUtils {
/**
* Removes the list of [BrazeGeofence] which are now un-registered with Google Play Services.
*
* @param context
* @param obsoleteGeofenceIds List of [String]s containing Geofence IDs that are un-registered
*/
private fun removeGeofencesFromSharedPrefs(context: Context, obsoleteGeofenceIds: List<String>) {
Expand Down
2 changes: 1 addition & 1 deletion android-sdk-ui/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<uses-sdk tools:overrideLibrary="com.google.firebase.messaging"/>
<application android:supportsRtl="true">
<application>
<activity
android:name="com.braze.ui.BrazeWebViewActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var brazeBridge = {
},
addToCustomAttributeArray: function(key, value) { brazeInternalBridge.getUser().addToCustomAttributeArray(key, value); },
removeFromCustomAttributeArray: function(key, value) { brazeInternalBridge.getUser().removeFromCustomAttributeArray(key, value); },
incrementCustomUserAttribute: function(key) { brazeInternalBridge.getUser().incrementCustomUserAttribute(key); },
incrementCustomUserAttribute: function(key, value) { brazeInternalBridge.getUser().incrementCustomUserAttribute(key, value != null ? value : 1); },
setDateOfBirth: function(year, month, day) { brazeInternalBridge.getUser().setDateOfBirth(year, month, day); },
setCountry: function(country) { brazeInternalBridge.getUser().setCountry(country); },
setPhoneNumber: function(phone) { brazeInternalBridge.getUser().setPhoneNumber(phone); },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import com.braze.ui.inappmessage.BrazeInAppMessageManager
* will not occur. Each class should be retrieved via [Activity.getClass].
* If null, an empty set is used instead.
*/
@Suppress("TooManyFunctions")
@Suppress("TooManyFunctions", "BooleanPropertyNaming")
open class BrazeActivityLifecycleCallbackListener @JvmOverloads constructor(
private val sessionHandlingEnabled: Boolean = true,
private val registerInAppMessageManager: Boolean = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ open class BrazeFirebaseMessagingService : FirebaseMessagingService() {
* Consumes an incoming [RemoteMessage] if it originated from Braze. If the [RemoteMessage] did
* not originate from Braze, then this method does nothing and returns false.
*
* @param context
* @param remoteMessage The [RemoteMessage] from Firebase.
* @return true iff the [RemoteMessage] originated from Braze and was consumed. Returns false
* if the [RemoteMessage] did not originate from Braze or otherwise could not be handled by Braze.
Expand Down Expand Up @@ -122,7 +123,9 @@ open class BrazeFirebaseMessagingService : FirebaseMessagingService() {
internal fun invokeFallbackFirebaseService(classpath: String, remoteMessage: RemoteMessage, context: Context) {
val fallbackObject = constructObjectQuietly(classpath)
if (fallbackObject == null) {
brazelog { "Fallback firebase messaging service $classpath could not be constructed. Not routing fallback RemoteMessage." }
brazelog {
"Fallback firebase messaging service $classpath could not be constructed. Not routing fallback RemoteMessage."
}
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.core.app.NotificationCompat
import com.braze.models.push.BrazeNotificationPayload
import com.braze.models.push.BrazeNotificationPayload.ActionButton
import com.braze.Braze
import com.braze.BrazeInternal
import com.braze.Constants
import com.braze.IBrazeDeeplinkHandler.IntentFlagPurpose
import com.braze.models.push.BrazeNotificationPayload
import com.braze.models.push.BrazeNotificationPayload.ActionButton
import com.braze.push.BrazeNotificationUtils.cancelNotification
import com.braze.push.BrazeNotificationUtils.notificationReceiverClass
import com.braze.push.BrazeNotificationUtils.routeUserWithNotificationOpenedIntent
Expand Down Expand Up @@ -181,6 +181,7 @@ object BrazeNotificationActionUtils {
*
* @param context
* @param intent the action button click intent
* @param actionType the type of action button that was clicked
*/
fun logNotificationActionClicked(context: Context, intent: Intent, actionType: String?) {
val campaignId = intent.getStringExtra(Constants.BRAZE_PUSH_CAMPAIGN_ID_KEY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import android.app.Notification
import android.content.Context
import android.os.Bundle
import androidx.core.app.NotificationCompat
import com.braze.models.push.BrazeNotificationPayload
import com.braze.IBrazeNotificationFactory
import com.braze.configuration.BrazeConfigurationProvider
import com.braze.models.push.BrazeNotificationPayload
import com.braze.push.BrazeNotificationActionUtils.addNotificationActions
import com.braze.push.BrazeNotificationStyleFactory.Companion.setStyleIfSupported
import com.braze.push.BrazeNotificationUtils.getOrCreateNotificationChannelId
Expand Down Expand Up @@ -93,9 +93,7 @@ open class BrazeNotificationFactory : IBrazeNotificationFactory {
*/
@JvmStatic
val instance: BrazeNotificationFactory
get() {
return internalInstance
}
get() = internalInstance

/**
* Returns a notification builder populated with all fields from the notification extras and
Expand Down
Loading

0 comments on commit f0df61c

Please sign in to comment.