Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/fix_galaxy_bug' into feature/2.4.0-beta01
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshihideSogawa committed Sep 28, 2018
2 parents 90243bc + c6a466b commit 857ef6c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class FloatingView extends FrameLayout implements ViewTreeObserver.OnPreDrawList
/**
* status bar's height(landscape)
*/
private int mBaseStatusBarRotatedHeight;
private final int mBaseStatusBarRotatedHeight;

/**
* Current status bar's height
Expand Down Expand Up @@ -568,17 +568,17 @@ public boolean onPreDraw() {
* @param isHideStatusBar If true, the status bar is hidden
* @param isHideNavigationBar If true, the navigation bar is hidden
* @param isPortrait If true, the device orientation is portrait
* @param windowLeftOffset Left side offset of device display
* @param windowRect {@link Rect} of system window
*/
void onUpdateSystemLayout(boolean isHideStatusBar, boolean isHideNavigationBar, boolean isPortrait, int windowLeftOffset) {
void onUpdateSystemLayout(boolean isHideStatusBar, boolean isHideNavigationBar, boolean isPortrait, Rect windowRect) {
// status bar
updateStatusBarHeight(isHideStatusBar, isPortrait);
// touch X offset(support Cutout)
updateTouchXOffset(isHideNavigationBar, windowLeftOffset);
updateTouchXOffset(isHideNavigationBar, windowRect.left);
// touch Y offset(support Cutout)
mTouchYOffset = isPortrait ? mSafeInsetRect.top : 0;
// navigation bar
updateNavigationBarOffset(isHideNavigationBar, isPortrait);
updateNavigationBarOffset(isHideNavigationBar, isPortrait, windowRect);
refreshLimitRect();
}

Expand Down Expand Up @@ -636,17 +636,54 @@ private void updateTouchXOffset(boolean isHideNavigationBar, int windowLeftOffse
*
* @param isHideNavigationBar If true, the navigation bar is hidden
* @param isPortrait If true, the device orientation is portrait
*/
private void updateNavigationBarOffset(boolean isHideNavigationBar, boolean isPortrait) {
* @param windowRect {@link Rect} of system window
*/
private void updateNavigationBarOffset(boolean isHideNavigationBar, boolean isPortrait, Rect windowRect) {
int currentNavigationBarHeight = 0;
int currentNavigationBarWidth = 0;
int navigationBarVerticalDiff = 0;
final boolean hasSoftNavigationBar = hasSoftNavigationBar();
// auto hide navigation bar(Galaxy S8, S9 and so on.)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
final DisplayMetrics realDisplayMetrics = new DisplayMetrics();
mWindowManager.getDefaultDisplay().getRealMetrics(realDisplayMetrics);
currentNavigationBarHeight = realDisplayMetrics.heightPixels - windowRect.bottom;
currentNavigationBarWidth = realDisplayMetrics.widthPixels - mMetrics.widthPixels;
navigationBarVerticalDiff = mBaseNavigationBarHeight - currentNavigationBarHeight;
}

if (!isHideNavigationBar) {
mNavigationBarVerticalOffset = 0;
// auto hide navigation bar
// 他デバイスとの矛盾をもとに推測する
// 1.デバイスに組み込まれたナビゲーションバー(mBaseNavigationBarHeight == 0)はシステムの状態によって高さに差が発生しない
// 2.デバイスに組み込まれたナビゲーションバー(!hasSoftNavigationBar)は意図的にBaseを0にしているので、矛盾している
if (navigationBarVerticalDiff != 0 && mBaseNavigationBarHeight == 0 ||
!hasSoftNavigationBar && mBaseNavigationBarHeight != 0) {
if (hasSoftNavigationBar) {
// 1.auto hide mode -> show mode
// 2.show mode -> auto hide mode -> home
mNavigationBarVerticalOffset = 0;
} else {
// show mode -> home
mNavigationBarVerticalOffset = -currentNavigationBarHeight;
}
} else {
// normal device
mNavigationBarVerticalOffset = 0;
}

mNavigationBarHorizontalOffset = 0;
return;
}

// If the portrait, is displayed at the bottom of the screen
if (isPortrait) {
mNavigationBarVerticalOffset = mBaseNavigationBarHeight;
// auto hide navigation bar
if (!hasSoftNavigationBar && mBaseNavigationBarHeight != 0) {
mNavigationBarVerticalOffset = 0;
} else {
mNavigationBarVerticalOffset = mBaseNavigationBarHeight;
}
mNavigationBarHorizontalOffset = 0;
return;
}
Expand All @@ -658,7 +695,17 @@ private void updateNavigationBarOffset(boolean isHideNavigationBar, boolean isPo
mNavigationBarHorizontalOffset = 0;
} else {
mNavigationBarVerticalOffset = 0;
mNavigationBarHorizontalOffset = mBaseNavigationBarRotatedHeight;
// auto hide navigation bar
// 他デバイスとの矛盾をもとに推測する
// 1.デバイスに組み込まれたナビゲーションバー(!hasSoftNavigationBar)は、意図的にBaseを0にしているので、矛盾している
if (!hasSoftNavigationBar && mBaseNavigationBarRotatedHeight != 0) {
mNavigationBarHorizontalOffset = 0;
} else if (hasSoftNavigationBar && mBaseNavigationBarRotatedHeight == 0) {
// 2.ソフトナビゲーションバーの場合、Baseが設定されるため矛盾している
mNavigationBarHorizontalOffset = currentNavigationBarWidth;
} else {
mNavigationBarHorizontalOffset = mBaseNavigationBarRotatedHeight;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,20 @@ public void onScreenChanged(Rect windowRect, int visibility) {
final boolean isHideNavigationBar;
if (visibility == FullscreenObserverView.NO_LAST_VISIBILITY) {
// At the first it can not get the correct value, so do special processing
mWindowManager.getDefaultDisplay().getMetrics(mDisplayMetrics);
isHideNavigationBar = windowRect.width() - mDisplayMetrics.widthPixels > 0 || windowRect.height() - mDisplayMetrics.heightPixels > 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
mWindowManager.getDefaultDisplay().getRealMetrics(mDisplayMetrics);
isHideNavigationBar = windowRect.width() - mDisplayMetrics.widthPixels == 0 && windowRect.bottom - mDisplayMetrics.heightPixels == 0;
} else {
mWindowManager.getDefaultDisplay().getMetrics(mDisplayMetrics);
isHideNavigationBar = windowRect.width() - mDisplayMetrics.widthPixels > 0 || windowRect.height() - mDisplayMetrics.heightPixels > 0;
}
} else {
isHideNavigationBar = (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
}
final boolean isPortrait = mResources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

final boolean isPortrait = mResources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
// update FloatingView layout
mTargetFloatingView.onUpdateSystemLayout(isHideStatusBar, isHideNavigationBar, isPortrait, windowRect.left);
mTargetFloatingView.onUpdateSystemLayout(isHideStatusBar, isHideNavigationBar, isPortrait, windowRect);

// フルスクリーンでの非表示モードでない場合は何もしない
if (mDisplayMode != DISPLAY_MODE_HIDE_FULLSCREEN) {
Expand Down

0 comments on commit 857ef6c

Please sign in to comment.