Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Android 11 API and workaround for android tv #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import androidx.core.view.WindowInsetsCompat;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

androidx is a dependancy right? You were able to add this without changing the gradle file?

Last time I tried bringing AndroidX it caused issues for a lot of users, so I reverted it.


import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
Expand Down Expand Up @@ -70,9 +71,15 @@ public void onGlobalLayout() {
Rect r = new Rect();
mainView.getWindowVisibleDisplayFrame(r);

// check if the visible part of the screen is less than 85%
// if it is then the keyboard is showing
boolean newState = ((double)r.height() / (double)mainView.getRootView().getHeight()) < 0.85;
boolean newState = false;

if (android.os.Build.VERSION.SDK_INT >= 30){
newState = mainView.getRootWindowInsets().isVisible(WindowInsetsCompat.Type.ime());
} else{
// check if the visible part of the screen is less than 85%
// if it is then the keyboard is showing
newState = ((double)r.height() / (double)mainView.getRootView().getHeight()) < 0.85;
}

if (newState != isVisible) {
isVisible = newState;
Expand Down