Skip to content

Commit

Permalink
Release 18.1.3 (#1481)
Browse files Browse the repository at this point in the history
* Release 18.1.3

* WIP

* Pass fallback size to image loader in more places, tidy up glide image loader, fix AirshipEmbeddedViewState

* Enable MC item thumbnails in Sample app

* Tweak banner nub style to match iOS

* Update changelog

* Fix rendering issue on Android

* Fix possible crash

* Catch color parse errors

* Fix embedded size

* Update 18.1.3 release date

* default to transparent status bar for modal scenes

* Fix button padding

# Conflicts:
#	urbanairship-layout/src/main/java/com/urbanairship/android/layout/util/LayoutUtils.java

* Update release date

---------

Co-authored-by: Ryan Lepinski <[email protected]>
  • Loading branch information
jyaganeh and rlepinski authored Jul 30, 2024
1 parent 6d67ccc commit 1a8c125
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 87 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

[Migration Guides](https://github.com/urbanairship/android-library/tree/main/documentation/migration)

## Version 18.1.1, June 28, 2024
## Version 18.1.3, July 30, 2024
Patch release that includes bug fixes for Embedded Content and Preference Center, and accessibility improvements for Message Center.

### Changes
- Fixed an issue with container child item measurement in Scenes, when margins were set on the container items.
- Fixed a Preference Center bug that could lead to subscription channel chips not being visible when initially displaying a Preference Center.
- Fixed dismissing multiple embedded views in the same session.
- Fixed an issue with automation trigger state not correctly persisting across sessions.
- Message Center accessibility improvements.
- Updated the default style for the pull to dismiss view in In-App Message Banners to better match iOS.

## Version 18.1.2, July 15, 2024
Patch release that includes fixes for Preference Center.

### Changes
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext {
// Airship Version - major.minor.patch
airshipVersion = '18.1.2'
airshipVersion = '18.1.3'

// Airship Version Qualifier beta, release, etc...
// airshipVersionQualifier = "alpha"
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<style name="AppTheme.MessageCenter" parent="MessageCenter">
<item name="messageCenterItemTitleTextAppearance">@style/AppTheme.MessageCenter.TitleTextAppearance</item>
<item name="messageCenterItemDateTextAppearance">@style/AppTheme.MessageCenter.DateTextAppearance</item>
<item name="messageCenterItemIconEnabled">true</item>
</style>

<!-- Custom message title text style -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ internal abstract class AutomationStore : RoomDatabase(), AutomationStoreInterfa
val name = config.configOptions.appKey + "_automation_store"
val path = File(ContextCompat.getNoBackupFilesDir(context), name).absolutePath
return databaseBuilder(context, AutomationStore::class.java, path)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
.fallbackToDestructiveMigrationOnDowngrade()
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public data class PreparedScheduleInfo(
reportingContext = content.get(REPORTING_CONTEXT),
// Default to a UUID for backwards compatibility
triggerSessionId = content.optionalField(TRIGGER_SESSION_ID) ?: UUID.randomUUID().toString(),
additionalAudienceCheckResult = content.requireField(ADDITIONAL_AUDIENCE_CHECK_RESULT)
additionalAudienceCheckResult = content.optionalField(ADDITIONAL_AUDIENCE_CHECK_RESULT) ?: true
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.widget.ImageView
import android.widget.ProgressBar
import androidx.core.view.doOnPreDraw
import com.urbanairship.UAirship
import com.urbanairship.android.layout.util.ResourceUtils
import com.urbanairship.iam.info.InAppMessageMediaInfo
import com.urbanairship.images.ImageRequestOptions
import com.urbanairship.util.ManifestUtils
Expand Down Expand Up @@ -87,11 +88,16 @@ internal class MediaView @JvmOverloads constructor(
imageView.contentDescription = mediaInfo.description
val url = cachedMediaUrl ?: mediaInfo.url

val fallbackWidth = ResourceUtils.getDisplayWidthPixels(context)
val fallbackHeight = ResourceUtils.getDisplayHeightPixels(context)

imageView.doOnPreDraw {
UAirship.shared().imageLoader.load(
context,
imageView,
ImageRequestOptions.newBuilder(url).build()
ImageRequestOptions.newBuilder(url)
.setFallbackDimensions(fallbackWidth, fallbackHeight)
.build()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@

<!-- Dismiss pull view -->
<style name="UrbanAirship.InAppBanner.Pull">
<item name="android:layout_width">40dp</item>
<item name="android:layout_height">8dp</item>
<item name="android:layout_width">36dp</item>
<item name="android:layout_height">4dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:background">@drawable/ua_iam_banner_pull_background</item>
</style>

<!-- Dismiss pull overrides for top banner placement -->
<style name="UrbanAirship.InAppBanner.Pull.Top">
<item name="android:layout_marginBottom">8dp</item>
<item name="android:layout_marginTop">16dp</item>
</style>

<!-- Dismiss pull overrides for bottom banner placement -->
<style name="UrbanAirship.InAppBanner.Pull.Bottom">
<item name="android:layout_marginTop">8dp</item>
<item name="android:layout_marginBottom">16dp</item>
</style>

<!-- Media -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.urbanairship.images
import android.content.Context
import android.graphics.drawable.Drawable
import android.util.Size
import android.view.View
import android.view.ViewGroup
import android.view.ViewParent
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver.OnPreDrawListener
import android.widget.ImageView
Expand Down Expand Up @@ -80,62 +82,69 @@ internal object AirshipGlideImageLoader : ImageLoader {
private val zeroWidthFallback: Int?,
private val zeroHeightFallback: Int?,
private val subtractPadding: Boolean = true,
) : DrawableImageViewTarget(view) {
) : DrawableImageViewTarget(view) {

override fun getSize(cb: SizeReadyCallback) {
// Fast path: the view is already measured or has fallback width/height
val size = getSize()
if (size != null) {
if (size.width > 0 && size.height > 0) {
cb.onSizeReady(size.width, size.height)
return@getSize
}

// Slow path: wait for the view to be measured...
val viewTreeObserver = view.viewTreeObserver
val preDrawListener = object : OnPreDrawListener {
private var isResumed = false

override fun onPreDraw(): Boolean {
getSize()?.let { size ->
viewTreeObserver.removePreDrawListenerSafe(this)

if (!isResumed) {
isResumed = true
cb.onSizeReady(size.width, size.height)
} else {
// Slow path: wait for the view to be measured...
val viewTreeObserver = view.viewTreeObserver
val preDrawListener = object : OnPreDrawListener {
private var isResumed = false

override fun onPreDraw(): Boolean {
getSize().let { size ->
viewTreeObserver.removePreDrawListenerSafe(this)

if (!isResumed) {
isResumed = true
cb.onSizeReady(size.width, size.height)
}
}
return true
}
return true
}
}

viewTreeObserver.addOnPreDrawListener(preDrawListener)
viewTreeObserver.addOnPreDrawListener(preDrawListener)
}
}

fun getSize(): Size? {
val width = getWidth() ?: return null
val height = getHeight() ?: return null
return Size(width, height)
}
fun getSize(): Size = Size(getWidth(), getHeight())

fun getWidth() = getDimension(
paramSize = view.layoutParams?.width ?: -1,
paramSize = view.layoutParams?.width ?: ViewGroup.LayoutParams.MATCH_PARENT,
viewSize = view.width,
paddingSize = if (subtractPadding) view.paddingLeft + view.paddingRight else 0
) ?: zeroWidthFallback
) ?: zeroWidthFallback.let {
if (it == null || it < 0) {
Target.SIZE_ORIGINAL
} else {
it
}
}

fun getHeight() = getDimension(
paramSize = view.layoutParams?.height ?: -1,
paramSize = view.layoutParams?.height ?: ViewGroup.LayoutParams.MATCH_PARENT,
viewSize = view.height,
paddingSize = if (subtractPadding) view.paddingTop + view.paddingBottom else 0
) ?: zeroHeightFallback
) ?: zeroHeightFallback.let {
if (it == null || it < 0) {
Target.SIZE_ORIGINAL
} else {
it
}
}

fun getDimension(
paramSize: Int,
viewSize: Int,
paddingSize: Int
): Int? {
// If the dimension is set to WRAP_CONTENT, then the dimension is undefined.
if (paramSize == ViewGroup.LayoutParams.WRAP_CONTENT) {
// If the dimension is set to WRAP_CONTENT or MATCH_PARENT, then the dimension is undefined.
if (paramSize <= 0) {
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package com.urbanairship.android.layout.property
import android.graphics.Color
import androidx.annotation.ColorInt
import androidx.core.graphics.ColorUtils
import com.urbanairship.UALog
import com.urbanairship.UALog.w
import com.urbanairship.json.JsonMap

Expand All @@ -25,10 +26,15 @@ public object HexColor {
return null
}

var color = Color.parseColor(hex)
if (alpha != 1f) {
color = ColorUtils.setAlphaComponent(color, (alpha * 255).toInt())
return try {
var color = Color.parseColor(hex)
if (alpha != 1f) {
color = ColorUtils.setAlphaComponent(color, (alpha * 255).toInt())
}
color
} catch (e: Exception) {
UALog.e(e) { "Invalid color $hex " }
null
}
return color
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public ConstraintSetBuilder width(@Nullable Size size, @IdRes int viewId) {

@NonNull
public ConstraintSetBuilder width(@Nullable Size size, boolean ignoreSafeArea, @IdRes int viewId) {
return size(size, ignoreSafeArea, viewId, ConstraintSet.WRAP_CONTENT);
return width(size, ignoreSafeArea, viewId, ConstraintSet.WRAP_CONTENT);
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
Expand Down Expand Up @@ -50,10 +51,12 @@

/**
* Helpers for layout rendering.
*
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public final class LayoutUtils {

private static final float PRESSED_ALPHA_PERCENT = 0.2f;
private static final int DEFAULT_STROKE_WIDTH_DPS = 2;
private static final int DEFAULT_BORDER_RADIUS = 0;
Expand All @@ -72,9 +75,9 @@ public static void applyBorderAndBackground(@NonNull View view, @NonNull BaseMod
}

public static void applyBorderAndBackground(
@NonNull View view,
@Nullable Border border,
@Nullable Color backgroundColor
@NonNull View view,
@Nullable Border border,
@Nullable Color backgroundColor
) {
Context context = view.getContext();

Expand Down Expand Up @@ -123,7 +126,7 @@ public static void applyBorderAndBackground(
private static void mergeBackground(@NonNull View view, @NonNull Drawable drawable) {
Drawable background = drawable;
if (view.getBackground() != null) {
background = new LayerDrawable(new Drawable[]{view.getBackground(), drawable});
background = new LayerDrawable(new Drawable[] { view.getBackground(), drawable });
}
view.setBackground(background);
}
Expand All @@ -136,35 +139,35 @@ public static void applyButtonModel(@NonNull MaterialButton button, @NonNull Lab

int textColor = textAppearance.getColor().resolve(context);
int backgroundColor = model.getBackgroundColor() == null
? Color.TRANSPARENT
: model.getBackgroundColor().resolve(button.getContext());
? Color.TRANSPARENT
: model.getBackgroundColor().resolve(button.getContext());
int pressedColor = ColorUtils.setAlphaComponent(textColor, Math.round(Color.alpha(textColor) * PRESSED_ALPHA_PERCENT));
int disabledColor = generateDisabledColor(backgroundColor);
int strokeWidth = model.getBorder() == null || model.getBorder().getStrokeWidth() == null
? DEFAULT_STROKE_WIDTH_DPS
: model.getBorder().getStrokeWidth();
? DEFAULT_STROKE_WIDTH_DPS
: model.getBorder().getStrokeWidth();
int strokeColor = model.getBorder() == null || model.getBorder().getStrokeColor() == null
? backgroundColor
: model.getBorder().getStrokeColor().resolve(context);
? backgroundColor
: model.getBorder().getStrokeColor().resolve(context);
int disabledStrokeColor = generateDisabledColor(strokeColor);
int borderRadius = model.getBorder() == null || model.getBorder().getRadius() == null
? DEFAULT_BORDER_RADIUS
: model.getBorder().getRadius();
? DEFAULT_BORDER_RADIUS
: model.getBorder().getRadius();

button.setBackgroundTintList(new ColorStateListBuilder()
.add(disabledColor, -android.R.attr.state_enabled)
.add(backgroundColor)
.build());
.add(disabledColor, -android.R.attr.state_enabled)
.add(backgroundColor)
.build());
button.setRippleColor(ColorStateList.valueOf(pressedColor));
int strokeWidthDp = (int) dpToPx(context, strokeWidth);
button.setStrokeWidth(strokeWidthDp);
if (strokeWidthDp > 0) {
addPadding(button, strokeWidthDp);
}
int strokeWidthPixels = (int) dpToPx(context, strokeWidth);
button.setStrokeWidth(strokeWidthPixels);
button.setStrokeColor(new ColorStateListBuilder()
.add(disabledStrokeColor, -android.R.attr.state_enabled)
.add(strokeColor)
.build());
.add(disabledStrokeColor, -android.R.attr.state_enabled)
.add(strokeColor)
.build());

button.setEllipsize(TextUtils.TruncateAt.END);
button.setIncludeFontPadding(false);
button.setCornerRadius((int) dpToPx(context, borderRadius));
button.setSingleLine(false);
}
Expand Down Expand Up @@ -229,9 +232,9 @@ public static void applyTextAppearance(@NonNull TextView textView, @NonNull Text
int disabledTextColor = generateDisabledColor(Color.TRANSPARENT, textColor);

textView.setTextColor(new ColorStateListBuilder()
.add(disabledTextColor, -android.R.attr.state_enabled)
.add(textColor)
.build());
.add(disabledTextColor, -android.R.attr.state_enabled)
.add(textColor)
.build());

int typefaceFlags = Typeface.NORMAL;
int paintFlags = Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG;
Expand Down Expand Up @@ -344,10 +347,10 @@ public static void addPadding(@NonNull View view, int padding) {

public static void addPadding(@NonNull View view, int left, int top, int right, int bottom) {
view.setPadding(
view.getPaddingLeft() + left,
view.getPaddingTop() + top,
view.getPaddingRight() + right,
view.getPaddingBottom() + bottom
view.getPaddingLeft() + left,
view.getPaddingTop() + top,
view.getPaddingRight() + right,
view.getPaddingBottom() + bottom
);
}

Expand All @@ -373,12 +376,13 @@ public static int generateDisabledColor(@ColorInt int background, @ColorInt int

@ColorInt
private static int overlayColors(
@ColorInt int backgroundColor,
@ColorInt int overlayColor,
@FloatRange(from = 0, to = 1) float overlayAlpha
@ColorInt int backgroundColor,
@ColorInt int overlayColor,
@FloatRange(from = 0, to = 1) float overlayAlpha
) {
int alpha = Math.round(Color.alpha(overlayColor) * overlayAlpha);
int overlay = ColorUtils.setAlphaComponent(overlayColor, alpha);
return ColorUtils.compositeColors(overlay, backgroundColor);
}

}
Loading

0 comments on commit 1a8c125

Please sign in to comment.