-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Detect window dimension change when virtual buttons are show/hidden on samsung s8 #14887
Comments
@aidan2129 any news on that ? |
@machard Nothing so far :/ |
I've got the same issue. I tried https://github.com/Sunhat/react-native-extra-dimensions-android which gives the size of the virtual menu bar but it doesn't tell you if the virtual menu bar is showing or not. |
this problem happen too with note 8 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
This issue haven't been fixed. Please keep it open Stale bot |
I'm currently experiencing this issue as well. I attempted to use https://github.com/mockingbot/react-native-immersive but this doesn't seem to work on the S8 |
Yeah I am having this issue. Help needed! |
It seems that we have different ways:
But what about take this functionality directly into React Native? |
I am also having this issue in S8 |
I'm having this issue in A8 |
I think this #20999 will affect this issue. |
Same on S9 . So I went into this ugly hack in my main component:
|
@io-pan where did you put this code? I tried setting this to the view both inside and outside the Modal, but it didn't work, here's a code snippet:
|
@vcapretz I put it on the root view of my root component. getWindowDimension is triggered when I lock/unlock virtual buttons and when I change the orientation of my phone (portrait / lanscape).
|
@io-pan This is a good idea. It would be wonderful if React-Native had an eventListener when the hardware-bar is toggle/untoggle. addEventListener() would be great but Dimensions props never change... |
I'm an Expo user who has been grappling with this issue the past few weeks, and I was just able to reproduce the issue on my Galaxy S8 and then make it go away by changing the Here's the issue: expo/expo#2399 |
It is also happening to me on Galaxy S8+ and RN 0.55.4. The issue goes away if you force to re-render the inner
I came up with that reasoning after adding a state variable as part of the inner
It seems that method is related to the height calculation, I'm just wondering, I did not dig deeper yet. In the meantime, I was not able to make the inner Any thoughts? |
@kelset, one question, do you think #20999 could potentially fix this issue?, I see that PR is kind of stale at this point, and in the context of my comment above, I'm not sure that PR will actually fix the issue. Were you able to have a look at this issue from your end?, we are planning to invest some time on it near soon, but I wanted to check if anyone else was working on this first (not a workaround, not changing node_modules files, but an actual change in the codebase to address this issue). We have been looking at it on different Android/Samsung device combinations, and it is reproducible in all of them. |
@c0d3m3nt0r I think the PR will fix the issue, because it's going to provide a nice way to measure the available space. It will be really similar to #14887 (comment) I am looking into this right now. |
The problem can be broken down into two parts. First one, when you hide the navigation bar, by calling Second problem is that inside From the Google documentation:
I am not sure if "the system subtracts the space" means it subtracted even when decor elements are not visible. Either way, we can use We already use the It seems to be working properly when entering immersive mode on Android too. I would suggest that we just rewrite the logic inside I am not even sure why we need CC: @janicduplessis @hramos please let me know what you think |
Looks like this is going to be fixed in #20999 and I don't think any major rewrites will happen to Dimensions API since this one is meant to replace it. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Pull Request #20999
The pull request was not merged as it had some performance issues, more infos at #20999 Seems to me a complex change. |
is there any fix or workaround for this. extra dimension library does not update. |
it is giving 0 value |
As mentioned already by a few folks, it seems that the PR that supposedly was going to fix this (#20999) has been actually closed and the solution implemented in a separated library: https://github.com/th3rdwave/react-native-safe-area-context It doesn't seem that that library provides a dimensions endpoint, though. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
came back reading #14887 (comment) while working on #23693
This are my considerations: SOLUTION 1
/**
* Interface definition for a callback to be invoked when the status bar changes visibility. This
* reports <strong>global</strong> changes to the system UI state, not what the application is
* requesting.
*
* @see
* View#setOnSystemUiVisibilityChangeListener(android.view.View.OnSystemUiVisibilityChangeListener)
* @deprecated Use {@link WindowInsets#isVisible(int)} to find out about system bar visibilities
* by setting a {@link OnApplyWindowInsetsListener} on this view.
*/
@Deprecated
public interface OnSystemUiVisibilityChangeListener {
/**
* Called when the status bar changes visibility because of a call to {@link
* View#setSystemUiVisibility(int)}.
*
* @param visibility Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE}, {@link
* #SYSTEM_UI_FLAG_HIDE_NAVIGATION}, and {@link #SYSTEM_UI_FLAG_FULLSCREEN}. This tells you
* the <strong>global</strong> state of these UI visibility flags, not what your app is
* currently applying.
*/
public void onSystemUiVisibilityChange(int visibility);
} SOLUTION 2 This is the solution implemented by Janic Duplessis in pr #20999 to somehow (I still don't understand) trigger the update with the objc libraries |
about point 2 of #14887 (comment)
as this is relevant for my pr #30919 I notice the deprecation and started testing alternative solution with react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.java Lines 67 to 74 in 63e8942
I guess it may not be compatible with the calculation of the Keyboard Height based on react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java Lines 746 to 748 in 24bfa46
the calculation of the keyboard height is the difference between:
it is not possible to use For example in the specific case of calculating the soft-keyboard height, The result of using CLICK TO OPEN ANDROID SOURCECODE
https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/view/View.java /**
* Retrieve the overall visible display size in which the window this view is attached to has been
* positioned in. This takes into account screen decorations above the window, for both cases
* where the window itself is being position inside of them or the window is being placed under
* then and covered insets are used for the window to position its content inside. In effect, this
* tells you the available area where content can be placed and remain visible to users.
*
* <p>This function requires an IPC back to the window manager to retrieve the requested
* information, so should not be used in performance critical code like drawing.
*
* @param outRect Filled in with the visible display frame. If the view is not attached to a
* window, this is simply the raw display size.
*/
public void getWindowVisibleDisplayFrame(Rect outRect) {
if (mAttachInfo != null) {
try {
mAttachInfo.mSession.getDisplayFrame(mAttachInfo.mWindow, outRect);
} catch (RemoteException e) {
return;
}
// XXX This is really broken, and probably all needs to be done
// in the window manager, and we need to know more about whether
// we want the area behind or in front of the IME.
final Rect insets = mAttachInfo.mVisibleInsets;
outRect.left += insets.left;
outRect.top += insets.top;
outRect.right -= insets.right;
outRect.bottom -= insets.bottom;
return;
}
// The view is not attached to a display so we don't have a context.
// Make a best guess about the display size.
Display d = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
d.getRectSize(outRect);
} I agree that this, #23693 and #30919 problems should all be solved at their root (in I reviewed the solution proposed in https://github.com/facebook/react-native/pull/20999/files#diff-c6c68fb9580db5698d241fdd97b31a25ca1fdc061023a1bf1959f64fc4a00743R492-R512 by Janic Duplessis and I hopefully I will find a solution in the upcoming days. Thanks ☮️ |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Is this a bug report?
Yes
Have you read the Bugs section of the Contributing to React Native Guide?
Yes
Environment
react-native -v
:0.44.2node -v
:7.4.0npm -v
:4.0.0yarn --version
(if you use Yarn):Then, specify:
Steps to Reproduce
(Write your steps here:)
1.use Dimensions.get("window").height
2. On the samsung s8 the virtual home/back button can be hidden so i will toggle this on or of and a layout change is detected but the value is not changed but is when i change device orientation
Expected Behavior
(Write what you thought would happen.)
I expect the window height to change from 692 to 716 on my device anyway whenever the buttons are hidden.
Actual Behavior
The height should be changing to match the window height change when this is hidden. If i use the nativeEvent.layout the correct height value is shown but using this means the height is always undefined on first render which is not ideal.
Reproducible Demo
I don't think a snack example will be any good as i cant reproduce this issue on it but i will add a gif showing the issue on my device.
As you can see above when the orientation changes the height changes to 360 but when i toggle the virtual home buttons the height is not changing samsung s8 screen resolution is 360x740 pixels if that is helpful.
Sorry a gif was the only way i could think to show this as a actual demo, Wouldn't show anything without the code on the correct device.
The text was updated successfully, but these errors were encountered: