Skip to content

Commit 6e33f54

Browse files
committed
Fix webview overlap with keyboard on SDK 35
1 parent 5028a20 commit 6e33f54

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

common/src/main/java/com/microsoft/identity/common/internal/providers/oauth2/WebViewAuthorizationFragment.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,41 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
239239
mProgressBar = view.findViewById(R.id.common_auth_webview_progressbar);
240240

241241
final FragmentActivity activity = getActivity();
242+
242243
if (activity == null) {
243244
return null;
244245
}
246+
247+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
248+
activity.getWindow().setDecorFitsSystemWindows(false);
249+
view.setOnApplyWindowInsetsListener((v, insets) -> {
250+
android.graphics.Insets systemBarInsets = insets.getInsets(
251+
android.view.WindowInsets.Type.systemBars()
252+
);
253+
android.graphics.Insets imeInsets = insets.getInsets(
254+
android.view.WindowInsets.Type.ime()
255+
);
256+
257+
v.setPadding(
258+
systemBarInsets.left,
259+
systemBarInsets.top,
260+
systemBarInsets.right,
261+
imeInsets.bottom
262+
);
263+
264+
return insets;
265+
});
266+
} else {
267+
if (activity.getWindow() != null) {
268+
activity.getWindow().setSoftInputMode(
269+
android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE |
270+
android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
271+
);
272+
}
273+
}
274+
275+
view.setFitsSystemWindows(true);
276+
245277
mAADWebViewClient = new AzureActiveDirectoryWebViewClient(
246278
activity,
247279
new AuthorizationCompletionCallback(),
@@ -324,6 +356,9 @@ public boolean onTouch(final View view, final MotionEvent event) {
324356
mWebView.getSettings().setUseWideViewPort(true);
325357
mWebView.getSettings().setBuiltInZoomControls(webViewZoomControlsEnabled);
326358
mWebView.getSettings().setSupportZoom(webViewZoomEnabled);
359+
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
360+
mWebView.setFocusable(true);
361+
mWebView.setFocusableInTouchMode(true);
327362
mWebView.setVisibility(View.INVISIBLE);
328363
mWebView.setWebViewClient(webViewClient);
329364
mWebView.setWebChromeClient(new WebChromeClient() {

0 commit comments

Comments
 (0)