Skip to content

Commit 85ea4c0

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

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,29 @@ 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 keyboardInsets = insets.getInsets(android.view.WindowInsets.Type.ime());
251+
v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), keyboardInsets.bottom);
252+
return insets;
253+
});
254+
} else {
255+
if (activity.getWindow() != null) {
256+
activity.getWindow().setSoftInputMode(
257+
android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE |
258+
android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
259+
);
260+
}
261+
}
262+
263+
view.setFitsSystemWindows(true);
264+
245265
mAADWebViewClient = new AzureActiveDirectoryWebViewClient(
246266
activity,
247267
new AuthorizationCompletionCallback(),
@@ -324,6 +344,9 @@ public boolean onTouch(final View view, final MotionEvent event) {
324344
mWebView.getSettings().setUseWideViewPort(true);
325345
mWebView.getSettings().setBuiltInZoomControls(webViewZoomControlsEnabled);
326346
mWebView.getSettings().setSupportZoom(webViewZoomEnabled);
347+
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
348+
mWebView.setFocusable(true);
349+
mWebView.setFocusableInTouchMode(true);
327350
mWebView.setVisibility(View.INVISIBLE);
328351
mWebView.setWebViewClient(webViewClient);
329352
mWebView.setWebChromeClient(new WebChromeClient() {

0 commit comments

Comments
 (0)