Skip to content

Commit

Permalink
Renaming isFullscreen to isFullbleed to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
emawby committed Nov 9, 2021
1 parent 9778522 commit e24b912
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.webkit.WebView;
Expand Down Expand Up @@ -287,16 +286,11 @@ private void createPopupWindow(@NonNull RelativeLayout parentRelativeLayout) {
true
);

OSViewUtils.getWindowHeight(currentActivity);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
popupWindow.setTouchable(true);
// NOTE: This seems like the key to getting fullscreen under notches working?!
// NOTE: This is required for getting fullscreen under notches working in portrait mode
popupWindow.setClippingEnabled(false);

View container = (View)popupWindow.getContentView();
System.out.println("container: " + container);
System.out.println("container.getClass: " + container.getClass());

int gravity = 0;
if (!hasBackground) {
switch (displayLocation) {
Expand All @@ -315,7 +309,7 @@ private void createPopupWindow(@NonNull RelativeLayout parentRelativeLayout) {

// Using panel for fullbleed IAMs and dialog for non-fullbleed. The attached dialog type
// does not allow content to bleed under notches but panel does.
int displayType = this.messageContent.isFullScreen() ?
int displayType = this.messageContent.isFullBleed() ?
WindowManager.LayoutParams.TYPE_APPLICATION_PANEL :
WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
PopupWindowCompat.setWindowLayoutType(
Expand Down Expand Up @@ -414,7 +408,7 @@ private CardView createCardView(Context context) {
cardView.setClipChildren(false);
cardView.setClipToPadding(false);
cardView.setPreventCornerOverlap(false);
cardView.setBackgroundColor(Color.TRANSPARENT);
cardView.setCardBackgroundColor(Color.TRANSPARENT);

return cardView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal open class OSInAppMessageContent constructor(jsonObject: JSONObject) {
var contentHtml: String? = null
var useHeightMargin: Boolean = true
var useWidthMargin: Boolean = true
var isFullScreen: Boolean = false
var isFullBleed: Boolean = false
// The following properties are populated from Javascript events
var displayLocation: WebViewManager.Position? = null
var displayDuration: Double? = null
Expand All @@ -24,6 +24,6 @@ internal open class OSInAppMessageContent constructor(jsonObject: JSONObject) {
var styles: JSONObject? = jsonObject.optJSONObject(STYLES)
useHeightMargin = !(styles?.optBoolean(REMOVE_HEIGHT_MARGIN, false) ?: false)
useWidthMargin = !(styles?.optBoolean(REMOVE_WIDTH_MARGIN, false) ?: false)
isFullScreen = !useHeightMargin
isFullBleed = !useHeightMargin
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.onesignal;


import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
Expand Down Expand Up @@ -145,7 +144,7 @@ private static void setContentSafeAreaInsets(OSInAppMessageContent content, @Non
}

private static void initInAppMessage(@NonNull final Activity currentActivity, @NonNull OSInAppMessageInternal message, @NonNull final OSInAppMessageContent content) {
if (content.isFullScreen()) {
if (content.isFullBleed()) {
setContentSafeAreaInsets(content, currentActivity);
}
try {
Expand All @@ -161,7 +160,7 @@ private static void initInAppMessage(@NonNull final Activity currentActivity, @N
OSUtils.runOnMainUIThread(new Runnable() {
@Override
public void run() {
webViewManager.setupWebView(currentActivity, base64Str, content.isFullScreen());
webViewManager.setupWebView(currentActivity, base64Str, content.isFullBleed());
}
});
} catch (UnsupportedEncodingException e) {
Expand Down Expand Up @@ -229,7 +228,7 @@ public void postMessage(String message) {
}

private void handleResize() {
if (messageContent.isFullScreen()) {
if (messageContent.isFullBleed()) {
updateSafeAreaInsets();
}
}
Expand Down Expand Up @@ -324,8 +323,8 @@ private void calculateHeightAndShowWebViewAfterNewActivity() {
if (messageView == null)
return;

// Don't need a CSS / HTML height update for fullscreen
if (messageView.getDisplayPosition() == Position.FULL_SCREEN && !messageContent.isFullScreen()) {
// Don't need a CSS / HTML height update for fullscreen unless its fullbleed
if (messageView.getDisplayPosition() == Position.FULL_SCREEN && !messageContent.isFullBleed()) {
showMessageView(null);
return;
}
Expand All @@ -339,7 +338,7 @@ public void run() {
// At time point the webView isn't attached to a view
// Set the WebView to the max screen size then run JS to evaluate the height.
setWebViewToMaxSize(activity);
if (messageContent.isFullScreen()) {
if (messageContent.isFullBleed()) {
updateSafeAreaInsets();
}

Expand Down Expand Up @@ -502,7 +501,7 @@ private static void enableWebViewRemoteDebugging() {
}

private int getWebViewMaxSizeX(Activity activity) {
if (messageContent.isFullScreen()) {
if (messageContent.isFullBleed()) {
return getFullbleedWindowWidth(activity);
} else {

Expand All @@ -512,7 +511,7 @@ private int getWebViewMaxSizeX(Activity activity) {
}

private int getWebViewMaxSizeY(Activity activity) {
int margin = messageContent.isFullScreen() ? 0 : (MARGIN_PX_SIZE * 2);
int margin = messageContent.isFullBleed() ? 0 : (MARGIN_PX_SIZE * 2);
return OSViewUtils.getWindowHeight(activity) - margin;
}

Expand Down
Loading

0 comments on commit e24b912

Please sign in to comment.