Skip to content

Commit 4c45ca2

Browse files
authored
Merge branch 'staging' into fix_stop_views
2 parents bbb1af7 + 78e52f4 commit 4c45ca2

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 24.7.7
22
* Mitigated an issue where an automaticly closed autostopped view's duration could have increased when opening new views
3+
* Mitigated an issue where, on Android 35 and above, the navigation bar was overlapping with the content display.
34

45
## 24.7.6
56
* Added support for localization of content blocks.
@@ -8,6 +9,7 @@
89
* Fixed a bug where passing the global content callback was not possible.
910
* Mitigated an issue related to content actions navigation.
1011
* Mitigated an issue that parsing internal content event segmentation.
12+
1113
## 24.7.5
1214
* ! Minor breaking change ! All active views will now automatically stop when consent for "views" is revoked.
1315

sdk/src/main/java/ly/count/android/sdk/TransparentActivity.java

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.content.res.Configuration;
88
import android.graphics.Color;
99
import android.net.Uri;
10+
import android.os.Build;
1011
import android.os.Bundle;
1112
import android.util.DisplayMetrics;
1213
import android.util.Log;
@@ -53,16 +54,24 @@ protected void onCreate(Bundle savedInstanceState) {
5354
Log.v(Countly.TAG, "[TransparentActivity] onCreate, configPortrait x: [" + configPortrait.x + "] y: [" + configPortrait.y + "] width: [" + configPortrait.width + "] height: [" + configPortrait.height + "]");
5455

5556
TransparentActivityConfig config;
57+
int navBarHeight = 0;
5658
if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
5759
config = configLandscape;
5860
} else {
61+
// This is only needed for the portrait mode and
62+
// after android 35 the function that gives height gives the full height of the screen
63+
// so we need to subtract the height of the navigation bar
64+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
65+
navBarHeight = getNavigationBarHeight();
66+
}
67+
5968
config = configPortrait;
6069
}
6170

6271
config = setupConfig(config);
6372

6473
int width = config.width;
65-
int height = config.height;
74+
int height = config.height - navBarHeight;
6675

6776
configLandscape.listeners.add((url, webView) -> {
6877
if (url.startsWith(URL_START)) {
@@ -126,23 +135,23 @@ private TransparentActivityConfig setupConfig(@Nullable TransparentActivityConfi
126135
return config;
127136
}
128137

129-
private void changeOrientation(TransparentActivityConfig config) {
138+
private void changeOrientation(TransparentActivityConfig config, int navBarHeight) {
130139
Log.d(Countly.TAG, "[TransparentActivity] changeOrientation, config x: [" + config.x + "] y: [" + config.y + "] width: [" + config.width + "] height: [" + config.height + "]");
131140
WindowManager.LayoutParams params = getWindow().getAttributes();
132141
params.x = config.x;
133142
params.y = config.y;
134-
params.height = config.height;
143+
params.height = config.height - navBarHeight;
135144
params.width = config.width;
136145
getWindow().setAttributes(params);
137146

138147
ViewGroup.LayoutParams layoutParams = relativeLayout.getLayoutParams();
139148
layoutParams.width = config.width;
140-
layoutParams.height = config.height;
149+
layoutParams.height = config.height - navBarHeight;
141150
relativeLayout.setLayoutParams(layoutParams);
142151

143152
ViewGroup.LayoutParams webLayoutParams = webView.getLayoutParams();
144153
webLayoutParams.width = config.width;
145-
webLayoutParams.height = config.height;
154+
webLayoutParams.height = config.height - navBarHeight;
146155
webView.setLayoutParams(webLayoutParams);
147156
}
148157

@@ -163,13 +172,21 @@ private void changeOrientationInternal() {
163172
case Configuration.ORIENTATION_LANDSCAPE:
164173
if (configLandscape != null) {
165174
configLandscape = setupConfig(configLandscape);
166-
changeOrientation(configLandscape);
175+
changeOrientation(configLandscape, 0);
167176
}
168177
break;
169178
case Configuration.ORIENTATION_PORTRAIT:
170179
if (configPortrait != null) {
171180
configPortrait = setupConfig(configPortrait);
172-
changeOrientation(configPortrait);
181+
// This is only needed for the portrait mode and
182+
// after android 35 the function that gives height gives the full height of the screen
183+
// so we need to subtract the height of the navigation bar
184+
// this is implemented twice because in the future resize_me action will be able to change the height of the content
185+
int navBarHeight = 0;
186+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
187+
navBarHeight = getNavigationBarHeight();
188+
}
189+
changeOrientation(configPortrait, navBarHeight);
173190
}
174191
break;
175192
default:
@@ -368,4 +385,12 @@ private WebView createWebView(TransparentActivityConfig config) {
368385
webView.loadUrl(config.url);
369386
return webView;
370387
}
388+
389+
private int getNavigationBarHeight() {
390+
int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
391+
if (resourceId > 0) {
392+
return getResources().getDimensionPixelSize(resourceId);
393+
}
394+
return 0;
395+
}
371396
}

0 commit comments

Comments
 (0)