Panagiotis Triantafyllou

webview android 15 and up fixes

1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="AndroidProjectSystem">
4 + <option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 + <component name="GradleMigrationSettings" migrationVersion="1" />
3 <component name="GradleSettings"> 4 <component name="GradleSettings">
4 <option name="linkedExternalProjectsSettings"> 5 <option name="linkedExternalProjectsSettings">
5 <GradleProjectSettings> 6 <GradleProjectSettings>
...@@ -13,7 +14,6 @@ ...@@ -13,7 +14,6 @@
13 <option value="$PROJECT_DIR$/warply_android_sdk" /> 14 <option value="$PROJECT_DIR$/warply_android_sdk" />
14 </set> 15 </set>
15 </option> 16 </option>
16 - <option name="resolveExternalAnnotations" value="false" />
17 </GradleProjectSettings> 17 </GradleProjectSettings>
18 </option> 18 </option>
19 </component> 19 </component>
......
...@@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true ...@@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true
5 5
6 ext { 6 ext {
7 PUBLISH_GROUP_ID = 'ly.warp' 7 PUBLISH_GROUP_ID = 'ly.warp'
8 - PUBLISH_VERSION = '4.5.5.5' 8 + PUBLISH_VERSION = '4.5.5.6'
9 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 9 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
10 } 10 }
11 11
......
1 /* 1 /*
2 * Copyright 2010-2013 Warply Ltd. All rights reserved. 2 * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 - * 3 + *
4 * Redistribution and use in source and binary forms, without modification, are 4 * Redistribution and use in source and binary forms, without modification, are
5 * permitted provided that the following conditions are met: 5 * permitted provided that the following conditions are met:
6 - * 6 + *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 - * 9 + *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 - * 13 + *
14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR 14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
...@@ -30,7 +30,9 @@ import android.content.Intent; ...@@ -30,7 +30,9 @@ import android.content.Intent;
30 import android.graphics.Color; 30 import android.graphics.Color;
31 import android.os.Build; 31 import android.os.Build;
32 import android.os.Bundle; 32 import android.os.Bundle;
33 +
33 import androidx.annotation.NonNull; 34 import androidx.annotation.NonNull;
35 +
34 import android.text.TextUtils; 36 import android.text.TextUtils;
35 import android.view.KeyEvent; 37 import android.view.KeyEvent;
36 import android.view.View; 38 import android.view.View;
...@@ -43,10 +45,14 @@ import java.security.SecureRandom; ...@@ -43,10 +45,14 @@ import java.security.SecureRandom;
43 import java.util.concurrent.ThreadLocalRandom; 45 import java.util.concurrent.ThreadLocalRandom;
44 import java.util.concurrent.TimeUnit; 46 import java.util.concurrent.TimeUnit;
45 47
48 +import androidx.core.graphics.Insets;
49 +import androidx.core.view.ViewCompat;
50 +import androidx.core.view.WindowInsetsCompat;
46 import androidx.work.Constraints; 51 import androidx.work.Constraints;
47 import androidx.work.NetworkType; 52 import androidx.work.NetworkType;
48 import androidx.work.OneTimeWorkRequest; 53 import androidx.work.OneTimeWorkRequest;
49 import androidx.work.WorkManager; 54 import androidx.work.WorkManager;
55 +
50 import ly.warp.sdk.Warply; 56 import ly.warp.sdk.Warply;
51 import ly.warp.sdk.services.PushEventsClickedWorkerService; 57 import ly.warp.sdk.services.PushEventsClickedWorkerService;
52 import ly.warp.sdk.utils.WarpJSONParser; 58 import ly.warp.sdk.utils.WarpJSONParser;
...@@ -116,7 +122,68 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -116,7 +122,68 @@ public class WarpViewActivity extends WarpBaseActivity {
116 // Methods 122 // Methods
117 // =========================================================== 123 // ===========================================================
118 124
125 + //OLD with edge to edge enabled
126 +// private void initViews() {
127 +//
128 +// RelativeLayout root = new RelativeLayout(this);
129 +// root.setBackgroundColor(Color.WHITE);
130 +//
131 +// final ImageView ivLogo = new ImageView(this);
132 +// RelativeLayout.LayoutParams ivLogoParams = new RelativeLayout.LayoutParams(
133 +// RelativeLayout.LayoutParams.WRAP_CONTENT,
134 +// RelativeLayout.LayoutParams.WRAP_CONTENT);
135 +// ivLogoParams.addRule(RelativeLayout.CENTER_IN_PARENT);
136 +// root.addView(ivLogo, ivLogoParams);
137 +//
138 +// ivLogo.setImageDrawable(WarplyProperty.getProgressDrawable(this));
139 +// ivLogo.startAnimation(WarpUtils.getPulseAnimation());
140 +//
141 +// mWarpView = new WarpView(this);
142 +// RelativeLayout.LayoutParams warpViewParams = new RelativeLayout.LayoutParams(
143 +// RelativeLayout.LayoutParams.MATCH_PARENT,
144 +// RelativeLayout.LayoutParams.MATCH_PARENT);
145 +// root.addView(mWarpView, warpViewParams);
146 +//
147 +//
148 +// int progressHeightDp = 7;
149 +// final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
150 +// progressBar.setProgressDrawable(WarpUtils.getHorizontalProgressDrawable(WarplyProperty.getProgressColor(this)));
151 +// RelativeLayout.LayoutParams progressBarParams = new RelativeLayout.LayoutParams(
152 +// RelativeLayout.LayoutParams.MATCH_PARENT, (int)
153 +// (progressHeightDp * getResources().getDisplayMetrics().density + 0.5f));
154 +// mWarpView.setProgressChangeListener(new WarpView.ProgressChangeListener() {
155 +// @Override
156 +// public void onProgressChanged(WebView view, int newProgress) {
157 +//
158 +// progressBar.setProgress(newProgress);
159 +// if (progressBar.getProgress() == 100) {
160 +// WarpUtils.animateVisibility(ivLogo, View.INVISIBLE);
161 +// WarpUtils.animateVisibility(progressBar, View.INVISIBLE);
162 +// } else {
163 +// WarpUtils.animateVisibility(ivLogo, View.VISIBLE);
164 +// WarpUtils.animateVisibility(progressBar, View.VISIBLE);
165 +// }
166 +// }
167 +// });
168 +
169 + /// / root.addView(progressBar, progressBarParams);
170 +// setContentView(root);
171 +// }
172 +
173 +
174 + // NEW that handles edge to edge properly
119 private void initViews() { 175 private void initViews() {
176 + // Enable edge-to-edge display for SDK 35
177 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
178 + getWindow().setDecorFitsSystemWindows(false);
179 + } else {
180 + // For older Android versions
181 + getWindow().getDecorView().setSystemUiVisibility(
182 + View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
183 + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
184 + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
185 + );
186 + }
120 187
121 RelativeLayout root = new RelativeLayout(this); 188 RelativeLayout root = new RelativeLayout(this);
122 root.setBackgroundColor(Color.WHITE); 189 root.setBackgroundColor(Color.WHITE);
...@@ -131,12 +198,45 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -131,12 +198,45 @@ public class WarpViewActivity extends WarpBaseActivity {
131 ivLogo.setImageDrawable(WarplyProperty.getProgressDrawable(this)); 198 ivLogo.setImageDrawable(WarplyProperty.getProgressDrawable(this));
132 ivLogo.startAnimation(WarpUtils.getPulseAnimation()); 199 ivLogo.startAnimation(WarpUtils.getPulseAnimation());
133 200
201 + // Create a container for the WebView to handle insets properly
202 + RelativeLayout webViewContainer = new RelativeLayout(this);
203 + RelativeLayout.LayoutParams containerParams = new RelativeLayout.LayoutParams(
204 + RelativeLayout.LayoutParams.MATCH_PARENT,
205 + RelativeLayout.LayoutParams.MATCH_PARENT);
206 + root.addView(webViewContainer, containerParams);
207 +
134 mWarpView = new WarpView(this); 208 mWarpView = new WarpView(this);
135 RelativeLayout.LayoutParams warpViewParams = new RelativeLayout.LayoutParams( 209 RelativeLayout.LayoutParams warpViewParams = new RelativeLayout.LayoutParams(
136 RelativeLayout.LayoutParams.MATCH_PARENT, 210 RelativeLayout.LayoutParams.MATCH_PARENT,
137 RelativeLayout.LayoutParams.MATCH_PARENT); 211 RelativeLayout.LayoutParams.MATCH_PARENT);
138 - root.addView(mWarpView, warpViewParams); 212 + webViewContainer.addView(mWarpView, warpViewParams);
213 +
214 + // Handle window insets for the WebView container
215 + ViewCompat.setOnApplyWindowInsetsListener(webViewContainer, (v, insets) -> {
216 + Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
217 +
218 + // Apply padding to the WebView container (parent layout) instead of WebView directly
219 + webViewContainer.setPadding(
220 + systemBars.left,
221 + systemBars.top,
222 + systemBars.right,
223 + systemBars.bottom
224 + );
225 +
226 + return WindowInsetsCompat.CONSUMED;
227 + });
139 228
229 + // Force apply insets immediately with fallback values
230 + webViewContainer.post(() -> {
231 + // Get status bar height programmatically as fallback
232 + int statusBarHeight = getStatusBarHeight();
233 + int navigationBarHeight = getNavigationBarHeight();
234 +
235 + // Apply fallback padding to container if insets haven't been applied yet
236 + if (webViewContainer.getPaddingTop() == 0 && statusBarHeight > 0) {
237 + webViewContainer.setPadding(0, statusBarHeight, 0, navigationBarHeight);
238 + }
239 + });
140 240
141 int progressHeightDp = 7; 241 int progressHeightDp = 7;
142 final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); 242 final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
...@@ -144,10 +244,10 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -144,10 +244,10 @@ public class WarpViewActivity extends WarpBaseActivity {
144 RelativeLayout.LayoutParams progressBarParams = new RelativeLayout.LayoutParams( 244 RelativeLayout.LayoutParams progressBarParams = new RelativeLayout.LayoutParams(
145 RelativeLayout.LayoutParams.MATCH_PARENT, (int) 245 RelativeLayout.LayoutParams.MATCH_PARENT, (int)
146 (progressHeightDp * getResources().getDisplayMetrics().density + 0.5f)); 246 (progressHeightDp * getResources().getDisplayMetrics().density + 0.5f));
247 +
147 mWarpView.setProgressChangeListener(new WarpView.ProgressChangeListener() { 248 mWarpView.setProgressChangeListener(new WarpView.ProgressChangeListener() {
148 @Override 249 @Override
149 public void onProgressChanged(WebView view, int newProgress) { 250 public void onProgressChanged(WebView view, int newProgress) {
150 -
151 progressBar.setProgress(newProgress); 251 progressBar.setProgress(newProgress);
152 if (progressBar.getProgress() == 100) { 252 if (progressBar.getProgress() == 100) {
153 WarpUtils.animateVisibility(ivLogo, View.INVISIBLE); 253 WarpUtils.animateVisibility(ivLogo, View.INVISIBLE);
...@@ -158,10 +258,28 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -158,10 +258,28 @@ public class WarpViewActivity extends WarpBaseActivity {
158 } 258 }
159 } 259 }
160 }); 260 });
161 -// root.addView(progressBar, progressBarParams); 261 +
162 setContentView(root); 262 setContentView(root);
163 } 263 }
164 264
265 + private int getStatusBarHeight() {
266 + int result = 0;
267 + int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
268 + if (resourceId > 0) {
269 + result = getResources().getDimensionPixelSize(resourceId);
270 + }
271 + return result;
272 + }
273 +
274 + private int getNavigationBarHeight() {
275 + int result = 0;
276 + int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
277 + if (resourceId > 0) {
278 + result = getResources().getDimensionPixelSize(resourceId);
279 + }
280 + return result;
281 + }
282 +
165 private void setPageAccordingToIntent() { 283 private void setPageAccordingToIntent() {
166 284
167 Intent intent = getIntent(); 285 Intent intent = getIntent();
...@@ -226,4 +344,4 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -226,4 +344,4 @@ public class WarpViewActivity extends WarpBaseActivity {
226 public static Intent createIntentFromURL(Context context, String url) { 344 public static Intent createIntentFromURL(Context context, String url) {
227 return new Intent(context, WarpViewActivity.class).putExtra("sessionUrl", url); 345 return new Intent(context, WarpViewActivity.class).putExtra("sessionUrl", url);
228 } 346 }
229 -}
...\ No newline at end of file ...\ No newline at end of file
347 +}
......
...@@ -30,7 +30,7 @@ public class WarpConstants { ...@@ -30,7 +30,7 @@ public class WarpConstants {
30 /** 30 /**
31 * The version of the SDK installed in the device 31 * The version of the SDK installed in the device
32 */ 32 */
33 - public static final String SDK_VERSION = "4.5.5.5"; 33 + public static final String SDK_VERSION = "4.5.5.6";
34 34
35 /** 35 /**
36 * The URL of the server where it should ping 36 * The URL of the server where it should ping
......