Skip to content

Commit 9c28f44

Browse files
authored
Merge pull request #907 from Iterable/evan/MOB-11311
[MOB-11311] Embedded OOTB views - migrate to material buttons
2 parents 06e6dce + f4e5852 commit 9c28f44

13 files changed

+85
-194
lines changed

iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/embedded/IterableEmbeddedView.kt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,11 @@ class IterableEmbeddedView(
9494
val titleText = view.findViewById<TextView>(R.id.embedded_message_title)
9595
val bodyText = view.findViewById<TextView>(R.id.embedded_message_body)
9696

97-
if(config?.primaryBtnBackgroundColor != null) {
98-
val primaryBtnBackgroundDrawable = if(viewType == IterableEmbeddedViewType.NOTIFICATION)
99-
ContextCompat.getDrawable(requireContext(), R.drawable.primary_notification_button_background) as? GradientDrawable
100-
else ContextCompat.getDrawable(requireContext(), R.drawable.primary_banner_button_background) as? GradientDrawable
101-
primaryBtnBackgroundDrawable?.setColor(primaryBtnBackgroundColor)
102-
103-
firstButton.background = primaryBtnBackgroundDrawable
104-
}
105-
106-
if(config?.secondaryBtnBackgroundColor != null) {
107-
val secondaryBtnBackgroundDrawable = if(viewType == IterableEmbeddedViewType.NOTIFICATION)
108-
ContextCompat.getDrawable(requireContext(), R.drawable.secondary_notification_button_background) as? GradientDrawable
109-
else ContextCompat.getDrawable(requireContext(), R.drawable.secondary_banner_button_background) as? GradientDrawable
110-
secondaryBtnBackgroundDrawable?.setColor(secondaryBtnBackgroundColor)
97+
firstButton.setBackgroundColor(primaryBtnBackgroundColor)
98+
firstButton.setTextColor(primaryBtnTextColor)
11199

112-
secondButton.background = secondaryBtnBackgroundDrawable
113-
}
100+
secondButton.setBackgroundColor(secondaryBtnBackgroundColor)
101+
secondButton.setTextColor(secondaryBtnTextColor)
114102

115103
firstButton.setTextColor(primaryBtnTextColor)
116104
secondButton.setTextColor(secondaryBtnTextColor)

iterableapi-ui/src/main/res/drawable/primary_banner_button_background.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

iterableapi-ui/src/main/res/drawable/primary_card_button_background.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

iterableapi-ui/src/main/res/drawable/primary_notification_button_background.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

iterableapi-ui/src/main/res/drawable/secondary_banner_button_background.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

iterableapi-ui/src/main/res/drawable/secondary_card_button_background.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

iterableapi-ui/src/main/res/drawable/secondary_notification_button_background.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

iterableapi-ui/src/main/res/layout-v21/banner_view.xml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,43 +69,37 @@
6969
app:layout_constraintStart_toStartOf="parent"
7070
app:layout_constraintBottom_toBottomOf="parent">
7171

72-
<Button
72+
<com.google.android.material.button.MaterialButton
7373
android:id="@+id/embedded_message_first_button"
7474
android:layout_width="wrap_content"
75-
android:layout_height="36dp"
76-
android:background="@drawable/primary_banner_button_background"
77-
android:ellipsize="end"
75+
android:layout_height="48dp"
7876
android:layout_marginStart="16dp"
79-
android:layout_marginEnd="8dp"
80-
android:layout_marginLeft="16dp"
81-
android:layout_marginRight="8dp"
82-
android:paddingTop="0dp"
83-
android:paddingBottom="0dp"
77+
android:ellipsize="end"
78+
android:paddingTop="8dp"
79+
android:paddingBottom="8dp"
8480
android:paddingStart="12dp"
8581
android:paddingEnd="12dp"
8682
android:singleLine="true"
8783
android:stateListAnimator="@null"
8884
android:textAllCaps="false"
8985
android:textSize="14sp"
90-
android:textColor="@color/white"
91-
app:cornerRadius="32dp" />
86+
app:cornerRadius="18dp" />
9287

93-
<Button
88+
<com.google.android.material.button.MaterialButton
9489
android:id="@+id/embedded_message_second_button"
9590
android:layout_width="wrap_content"
96-
android:layout_height="36dp"
97-
android:background="@drawable/secondary_banner_button_background"
91+
android:layout_height="48dp"
92+
android:layout_marginEnd="16dp"
9893
android:ellipsize="end"
99-
android:paddingTop="0dp"
100-
android:paddingBottom="0dp"
94+
android:paddingTop="8dp"
95+
android:paddingBottom="8dp"
10196
android:paddingStart="12dp"
10297
android:paddingEnd="12dp"
10398
android:singleLine="true"
10499
android:stateListAnimator="@null"
105100
android:textAllCaps="false"
106101
android:textSize="14sp"
107-
android:textColor="@color/white"
108-
app:cornerRadius="32dp" />
102+
app:cornerRadius="18dp" />
109103

110104
</LinearLayout>
111105

iterableapi-ui/src/main/res/layout-v21/card_view.xml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,42 +81,38 @@
8181
app:layout_constraintStart_toStartOf="parent"
8282
app:layout_constraintBottom_toBottomOf="parent">
8383

84-
<Button
84+
<com.google.android.material.button.MaterialButton
8585
android:id="@+id/embedded_message_first_button"
86+
style="@style/Widget.MaterialComponents.Button"
8687
android:layout_width="wrap_content"
87-
android:layout_height="36dp"
88-
android:background="@drawable/primary_card_button_background"
89-
android:ellipsize="end"
88+
android:layout_height="48dp"
9089
android:layout_marginStart="16dp"
91-
android:layout_marginEnd="8dp"
92-
android:layout_marginLeft="16dp"
93-
android:layout_marginRight="8dp"
94-
android:paddingTop="0dp"
95-
android:paddingBottom="0dp"
90+
android:ellipsize="end"
91+
android:paddingTop="8dp"
92+
android:paddingBottom="8dp"
9693
android:paddingStart="12dp"
9794
android:paddingEnd="12dp"
9895
android:singleLine="true"
9996
android:stateListAnimator="@null"
10097
android:textAllCaps="false"
10198
android:textSize="14sp"
102-
android:textColor="@color/white"
10399
app:cornerRadius="32dp" />
104100

105-
<Button
101+
<com.google.android.material.button.MaterialButton
106102
android:id="@+id/embedded_message_second_button"
103+
style="@style/Widget.MaterialComponents.Button"
107104
android:layout_width="wrap_content"
108-
android:layout_height="36dp"
109-
android:background="@drawable/secondary_card_button_background"
105+
android:layout_height="48dp"
106+
android:layout_marginEnd="16dp"
110107
android:ellipsize="end"
111-
android:paddingTop="0dp"
112-
android:paddingBottom="0dp"
108+
android:paddingTop="8dp"
109+
android:paddingBottom="8dp"
113110
android:paddingStart="12dp"
114111
android:paddingEnd="12dp"
115112
android:singleLine="true"
116113
android:stateListAnimator="@null"
114+
android:text=""
117115
android:textAllCaps="false"
118-
android:textSize="14sp"
119-
android:textColor="@color/white"
120116
app:cornerRadius="32dp" />
121117

122118
</LinearLayout>

iterableapi-ui/src/main/res/layout-v21/notification_view.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,34 @@
5858
app:layout_constraintStart_toStartOf="parent"
5959
app:layout_constraintBottom_toBottomOf="parent">
6060

61-
<Button
61+
<com.google.android.material.button.MaterialButton
6262
android:id="@+id/embedded_message_first_button"
63+
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
6364
android:layout_width="wrap_content"
64-
android:layout_height="36dp"
65+
android:layout_height="48dp"
6566
android:layout_marginStart="16dp"
66-
android:layout_marginEnd="8dp"
67-
android:textColor="@color/notification_text_color"
68-
android:background="@drawable/primary_notification_button_background"
6967
android:ellipsize="end"
70-
android:paddingTop="0dp"
71-
android:paddingBottom="0dp"
68+
android:paddingTop="8dp"
69+
android:paddingBottom="8dp"
7270
android:paddingStart="12dp"
7371
android:paddingEnd="12dp"
7472
android:singleLine="true"
7573
android:stateListAnimator="@null"
7674
android:textAllCaps="false"
7775
android:textSize="14sp"
78-
app:cornerRadius="32dp" />
76+
app:cornerRadius="32dp"
77+
app:strokeColor="@color/notification_button_border_color"
78+
app:strokeWidth="1dp"/>
7979

80-
<Button
80+
<com.google.android.material.button.MaterialButton
8181
android:id="@+id/embedded_message_second_button"
82+
style="@style/Widget.MaterialComponents.Button"
8283
android:layout_width="wrap_content"
83-
android:layout_height="36dp"
84-
android:textColor="@color/notification_text_color"
85-
android:background="@drawable/secondary_notification_button_background"
84+
android:layout_height="48dp"
85+
android:layout_marginEnd="16dp"
8686
android:ellipsize="end"
87-
android:paddingTop="0dp"
88-
android:paddingBottom="0dp"
87+
android:paddingTop="8dp"
88+
android:paddingBottom="8dp"
8989
android:paddingStart="12dp"
9090
android:paddingEnd="12dp"
9191
android:singleLine="true"

0 commit comments

Comments
 (0)