diff --git a/iterableapi-ui/build.gradle b/iterableapi-ui/build.gradle index d781c17ed..46c088d41 100644 --- a/iterableapi-ui/build.gradle +++ b/iterableapi-ui/build.gradle @@ -34,6 +34,7 @@ dependencies { implementation 'com.google.android.flexbox:flexbox:3.0.0' implementation 'androidx.cardview:cardview:1.0.0' implementation "com.github.bumptech.glide:glide:4.8.0" + implementation 'com.google.android.material:material:1.2.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' diff --git a/iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/embedded/IterableEmbeddedView.kt b/iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/embedded/IterableEmbeddedView.kt index 1dde61e47..cec97ed48 100644 --- a/iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/embedded/IterableEmbeddedView.kt +++ b/iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/embedded/IterableEmbeddedView.kt @@ -7,6 +7,7 @@ import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.ImageView +import android.widget.LinearLayout import android.widget.TextView import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment @@ -23,14 +24,14 @@ class IterableEmbeddedView( private var config: IterableEmbeddedViewConfig? ): Fragment() { - private val defaultBackgroundColor : Int by lazy { getDefaultColor(viewType, R.color.notification_background_color, R.color.banner_background_color) } - private val defaultBorderColor : Int by lazy { getDefaultColor(viewType, R.color.notification_border_color, R.color.banner_border_color) } - private val defaultPrimaryBtnBackgroundColor: Int by lazy { getDefaultColor(viewType, R.color.white, R.color.banner_button_color) } - private val defaultPrimaryBtnTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.white) } - private val defaultSecondaryBtnBackgroundColor: Int by lazy { getDefaultColor(viewType, R.color.notification_background_color, R.color.white) } - private val defaultSecondaryBtnTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.banner_button_color) } - private val defaultTitleTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.title_text_color) } - private val defaultBodyTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.body_text_color) } + private val defaultBackgroundColor : Int by lazy { getDefaultColor(viewType, R.color.notification_background_color, R.color.banner_background_color, R.color.banner_background_color) } + private val defaultBorderColor : Int by lazy { getDefaultColor(viewType, R.color.notification_border_color, R.color.banner_border_color, R.color.banner_border_color) } + private val defaultPrimaryBtnBackgroundColor: Int by lazy { getDefaultColor(viewType, R.color.white, R.color.white, R.color.banner_button_color) } + private val defaultPrimaryBtnTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.banner_button_color, R.color.white) } + private val defaultSecondaryBtnBackgroundColor: Int by lazy { getDefaultColor(viewType, R.color.notification_background_color, R.color.white, R.color.white) } + private val defaultSecondaryBtnTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.banner_button_color, R.color.banner_button_color) } + private val defaultTitleTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.title_text_color, R.color.title_text_color) } + private val defaultBodyTextColor: Int by lazy { getDefaultColor(viewType, R.color.notification_text_color, R.color.body_text_color, R.color.body_text_color) } private val defaultBorderWidth = 1 private val defaultBorderCornerRadius = 8f @@ -108,10 +109,6 @@ class IterableEmbeddedView( else ContextCompat.getDrawable(requireContext(), R.drawable.secondary_banner_button_background) as? GradientDrawable secondaryBtnBackgroundDrawable?.setColor(secondaryBtnBackgroundColor) - val params = secondButton.layoutParams as FlexboxLayout.LayoutParams - params.leftMargin = (8 * resources.displayMetrics.density).toInt() - secondButton.layoutParams = params - secondButton.setBackgroundDrawable(secondaryBtnBackgroundDrawable) } @@ -184,9 +181,10 @@ class IterableEmbeddedView( } } - private fun getDefaultColor(viewType: IterableEmbeddedViewType, notificationColor: Int, bannerColor: Int): Int { + private fun getDefaultColor(viewType: IterableEmbeddedViewType, notificationColor: Int, cardColor: Int, bannerColor: Int): Int { return when (viewType) { IterableEmbeddedViewType.NOTIFICATION -> ContextCompat.getColor(requireContext(), notificationColor) + IterableEmbeddedViewType.CARD -> ContextCompat.getColor(requireContext(), cardColor) else -> ContextCompat.getColor(requireContext(), bannerColor) } } diff --git a/iterableapi-ui/src/main/res/drawable/primary_card_button_background.xml b/iterableapi-ui/src/main/res/drawable/primary_card_button_background.xml new file mode 100644 index 000000000..eb087387a --- /dev/null +++ b/iterableapi-ui/src/main/res/drawable/primary_card_button_background.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/iterableapi-ui/src/main/res/drawable/secondary_card_button_background.xml b/iterableapi-ui/src/main/res/drawable/secondary_card_button_background.xml new file mode 100644 index 000000000..eb087387a --- /dev/null +++ b/iterableapi-ui/src/main/res/drawable/secondary_card_button_background.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/iterableapi-ui/src/main/res/layout-v21/banner_view.xml b/iterableapi-ui/src/main/res/layout-v21/banner_view.xml index 289b9368a..e55e32468 100644 --- a/iterableapi-ui/src/main/res/layout-v21/banner_view.xml +++ b/iterableapi-ui/src/main/res/layout-v21/banner_view.xml @@ -1,94 +1,107 @@ - - - - - - + android:layout_marginStart="16dp" + android:layout_marginTop="16dp" + android:ellipsize="end" + android:maxLines="2" + android:text="" + android:textSize="16sp" + android:textStyle="bold" + app:layout_constraintEnd_toStartOf="@+id/embedded_message_image" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - + - + - - - + android:layout_marginEnd="16dp" + android:orientation="horizontal" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintBottom_toBottomOf="parent">