Skip to content

Commit 523843d

Browse files
authored
Banner sizing (#178)
1 parent 3f0923b commit 523843d

File tree

6 files changed

+77
-69
lines changed

6 files changed

+77
-69
lines changed

firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/internal/FiamWindowManager.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,6 @@ public void show(@NonNull final BindingWrapper bindingWrapper, @NonNull Activity
5555
// action bar or anything else. This will become more pressing as notches
5656
// become more common on Android phones.
5757

58-
// Set the dialog view outer bounds from the window bounds.
59-
//
60-
// This is often overwritten later by the dialog width/height as specified,
61-
// but it gives good base behavior.
62-
View dialogView = bindingWrapper.getDialogView();
63-
ViewGroup.LayoutParams dialogParams = dialogView.getLayoutParams();
64-
dialogParams.width = config.windowWidth();
65-
dialogParams.height = config.windowHeight();
66-
dialogView.setLayoutParams(dialogParams);
67-
dialogView.requestLayout();
68-
6958
if (bindingWrapper.canSwipeToDismiss()) {
7059
SwipeDismissTouchListener listener =
7160
getSwipeListener(config, bindingWrapper, windowManager, layoutParams);

firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/internal/bindingwrappers/BannerBindingWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
import com.google.firebase.inappmessaging.display.internal.InAppMessageLayoutConfig;
1616
import com.google.firebase.inappmessaging.display.internal.ResizableImageView;
1717
import com.google.firebase.inappmessaging.display.internal.injection.scopes.InAppMessageScope;
18-
import com.google.firebase.inappmessaging.display.internal.layout.FiamRelativeLayout;
18+
import com.google.firebase.inappmessaging.display.internal.layout.FiamFrameLayout;
1919
import com.google.firebase.inappmessaging.model.InAppMessage;
2020
import javax.inject.Inject;
2121

2222
@InAppMessageScope
2323
@SuppressWarnings("Convert2Lambda")
2424
public class BannerBindingWrapper extends BindingWrapper {
2525

26-
private FiamRelativeLayout bannerRoot;
26+
private FiamFrameLayout bannerRoot;
2727
private ViewGroup bannerContentRoot;
2828

2929
private TextView bannerBody;

firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/internal/injection/modules/InflaterConfigModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ InAppMessageLayoutConfig providesBannerLandscapeLayoutConfig(DisplayMetrics disp
172172
.setMaxDialogWidthPx((int) (0.9f * displayMetrics.widthPixels))
173173
.setViewWindowGravity(Gravity.TOP)
174174
.setWindowFlag(ENABLED_BG_FLAG)
175-
.setWindowWidth(ViewGroup.LayoutParams.WRAP_CONTENT)
175+
.setWindowWidth(ViewGroup.LayoutParams.MATCH_PARENT)
176176
.setWindowHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
177177
.setBackgroundEnabled(true)
178178
.setAnimate(true)
Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<com.google.firebase.inappmessaging.display.internal.layout.FiamRelativeLayout
2+
<com.google.firebase.inappmessaging.display.internal.layout.FiamFrameLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:app="http://schemas.android.com/apk/res-auto"
55
xmlns:tools="http://schemas.android.com/tools"
@@ -9,64 +9,73 @@
99
android:clipChildren="false"
1010
android:clipToPadding="false">
1111

12-
<android.support.constraint.ConstraintLayout
13-
android:id="@+id/banner_content_root"
14-
style="@style/FiamUI.Banner"
12+
<LinearLayout
1513
android:layout_width="match_parent"
1614
android:layout_height="wrap_content"
17-
android:layout_gravity="center_horizontal"
18-
android:layout_margin="8dp"
19-
android:background="@drawable/rounded_layout"
20-
android:clickable="true"
21-
android:focusable="true"
22-
android:orientation="vertical"
23-
android:padding="8dp">
15+
android:orientation="horizontal"
16+
android:gravity="center_horizontal"
17+
android:weightSum="@dimen/bannerWeightSum">
2418

25-
<com.google.firebase.inappmessaging.display.internal.ResizableImageView
26-
android:id="@+id/banner_image"
27-
style="@style/FiamUI.ResizableImageView"
28-
android:adjustViewBounds="true"
29-
android:minWidth="64dp"
30-
android:minHeight="64dp"
31-
android:src="@drawable/image_placeholder"
32-
android:visibility="invisible"
33-
app:layout_constraintBottom_toBottomOf="parent"
34-
app:layout_constraintStart_toStartOf="parent"
35-
app:layout_constraintTop_toTopOf="parent"
36-
app:layout_constraintVertical_bias="0.0"
37-
tools:background="#ffbaba"
38-
tools:src="null"
39-
tools:visibility="visible" />
40-
41-
<TextView
42-
android:id="@+id/banner_title"
43-
style="@style/FiamUI.Text.BannerTitle"
44-
android:layout_width="wrap_content"
45-
android:layout_height="wrap_content"
46-
android:layout_marginStart="8dp"
47-
android:layout_marginLeft="8dp"
48-
app:layout_constraintEnd_toEndOf="parent"
49-
app:layout_constraintHorizontal_bias="0"
50-
app:layout_constraintStart_toEndOf="@+id/banner_image"
51-
app:layout_constraintTop_toTopOf="parent"
52-
tools:text="Banner Title" />
53-
54-
<TextView
55-
android:id="@+id/banner_body"
56-
style="@style/Base.TextAppearance.AppCompat.Small"
19+
<android.support.constraint.ConstraintLayout
20+
android:id="@+id/banner_content_root"
21+
style="@style/FiamUI.Banner"
5722
android:layout_width="0dp"
5823
android:layout_height="wrap_content"
59-
android:layout_marginEnd="8dp"
60-
android:layout_marginRight="8dp"
61-
android:layout_marginBottom="8dp"
62-
android:ellipsize="end"
63-
app:layout_constraintBottom_toBottomOf="parent"
64-
app:layout_constraintEnd_toEndOf="parent"
65-
app:layout_constraintStart_toStartOf="@+id/banner_title"
66-
app:layout_constraintTop_toBottomOf="@+id/banner_title"
67-
app:layout_constraintVertical_bias="0.0"
68-
tools:text="@string/placeholder_lorem_ipsum_short" />
24+
android:layout_margin="8dp"
25+
android:layout_weight="@dimen/bannerContentWeight"
26+
android:background="@drawable/rounded_layout"
27+
android:clickable="true"
28+
android:focusable="true"
29+
android:orientation="vertical"
30+
android:padding="8dp">
31+
32+
<com.google.firebase.inappmessaging.display.internal.ResizableImageView
33+
android:id="@+id/banner_image"
34+
style="@style/FiamUI.ResizableImageView"
35+
android:adjustViewBounds="true"
36+
android:minHeight="64dp"
37+
android:minWidth="64dp"
38+
android:src="@drawable/image_placeholder"
39+
android:visibility="invisible"
40+
app:layout_constraintBottom_toBottomOf="parent"
41+
app:layout_constraintStart_toStartOf="parent"
42+
app:layout_constraintTop_toTopOf="parent"
43+
app:layout_constraintVertical_bias="0.0"
44+
tools:background="#ffbaba"
45+
tools:src="null"
46+
tools:visibility="visible" />
47+
48+
<TextView
49+
android:id="@+id/banner_title"
50+
style="@style/FiamUI.Text.BannerTitle"
51+
android:layout_width="wrap_content"
52+
android:layout_height="wrap_content"
53+
android:layout_marginLeft="8dp"
54+
android:layout_marginStart="8dp"
55+
app:layout_constraintEnd_toEndOf="parent"
56+
app:layout_constraintHorizontal_bias="0"
57+
app:layout_constraintStart_toEndOf="@+id/banner_image"
58+
app:layout_constraintTop_toTopOf="parent"
59+
tools:text="Banner Title" />
60+
61+
<TextView
62+
android:id="@+id/banner_body"
63+
style="@style/Base.TextAppearance.AppCompat.Small"
64+
android:layout_width="0dp"
65+
android:layout_height="wrap_content"
66+
android:layout_marginBottom="8dp"
67+
android:layout_marginEnd="8dp"
68+
android:layout_marginRight="8dp"
69+
android:ellipsize="end"
70+
app:layout_constraintBottom_toBottomOf="parent"
71+
app:layout_constraintEnd_toEndOf="parent"
72+
app:layout_constraintStart_toStartOf="@+id/banner_title"
73+
app:layout_constraintTop_toBottomOf="@+id/banner_title"
74+
app:layout_constraintVertical_bias="0.0"
75+
tools:text="@string/placeholder_lorem_ipsum_short" />
76+
77+
</android.support.constraint.ConstraintLayout>
6978

70-
</android.support.constraint.ConstraintLayout>
79+
</LinearLayout>
7180

72-
</com.google.firebase.inappmessaging.display.internal.layout.FiamRelativeLayout>
81+
</com.google.firebase.inappmessaging.display.internal.layout.FiamFrameLayout>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<!-- In landscape, banner only fills a fraction (bannerContentWeight/bannerWeightSum) -->
4+
<dimen name="bannerWeightSum">5</dimen>
5+
<dimen name="bannerContentWeight">3</dimen>
6+
</resources>

firebase-inappmessaging-display/src/main/res/values/dimen.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@
77

88
<dimen name="modalPortraitHeightPct">0.80</dimen>
99
<dimen name="modalPortraitWidthPct">0.85</dimen>
10+
11+
<!-- In portrait, banner fills available. -->
12+
<dimen name="bannerWeightSum">1</dimen>
13+
<dimen name="bannerContentWeight">1</dimen>
1014
</resources>

0 commit comments

Comments
 (0)