|
|
@@ -20,9 +20,6 @@ import kr.co.zumo.app.lifeplus.util.ResourceUtil;
|
|
|
*/
|
|
|
public class FullScreenWithKeyBoardLayout {
|
|
|
|
|
|
- private Activity activity;
|
|
|
- private FrameLayout parentContent;
|
|
|
-
|
|
|
public static void assistActivity(Activity activity) {
|
|
|
new FullScreenWithKeyBoardLayout(activity);
|
|
|
}
|
|
|
@@ -32,15 +29,16 @@ public class FullScreenWithKeyBoardLayout {
|
|
|
private FrameLayout.LayoutParams frameLayoutParams;
|
|
|
private View decorView;
|
|
|
|
|
|
-
|
|
|
- public FullScreenWithKeyBoardLayout(Activity activity) {
|
|
|
- parentContent = activity.findViewById(android.R.id.content);
|
|
|
+ private FullScreenWithKeyBoardLayout(Activity activity) {
|
|
|
+ FrameLayout parentContent = activity.findViewById(android.R.id.content);
|
|
|
childContent = parentContent.getChildAt(0);
|
|
|
- this.activity = activity;
|
|
|
childContent.getViewTreeObserver().addOnGlobalLayoutListener(this::possiblyResizeChildOfContent);
|
|
|
+
|
|
|
frameLayoutParams = (FrameLayout.LayoutParams) childContent.getLayoutParams();
|
|
|
decorView = activity.getWindow().getDecorView();
|
|
|
- test();
|
|
|
+
|
|
|
+ setOnSystemUiVisibilityChange();
|
|
|
+ setOnSystemUiVisibilityChangeListener();
|
|
|
}
|
|
|
|
|
|
private void possiblyResizeChildOfContent() {
|
|
|
@@ -59,12 +57,10 @@ public class FullScreenWithKeyBoardLayout {
|
|
|
//keyboard probably just became visible
|
|
|
heightDifference = heightDifference - ResourceUtil.getStatusBarHeightManual() - ResourceUtil.getNavBarHeight();
|
|
|
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
|
|
|
- frameLayoutParams.height = usableHeightNow;
|
|
|
}
|
|
|
else {
|
|
|
//keyboard probably just became hidden
|
|
|
frameLayoutParams.height = usableHeightSansKeyboard;
|
|
|
- frameLayoutParams.height = usableHeightNow;
|
|
|
}
|
|
|
childContent.requestLayout();
|
|
|
}
|
|
|
@@ -73,7 +69,7 @@ public class FullScreenWithKeyBoardLayout {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 실시간 화면 높이 계산
|
|
|
+ * 실사용 화면 높이
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -83,22 +79,25 @@ public class FullScreenWithKeyBoardLayout {
|
|
|
return (r.bottom - r.top);
|
|
|
}
|
|
|
|
|
|
- private void test() {
|
|
|
- decorView.setOnSystemUiVisibilityChangeListener
|
|
|
- (visibility -> {
|
|
|
- setOnSystemUiVisibilityChange();
|
|
|
-
|
|
|
- });
|
|
|
+ private void setOnSystemUiVisibilityChangeListener() {
|
|
|
+ decorView.setOnSystemUiVisibilityChangeListener(visibility -> {
|
|
|
+ setOnSystemUiVisibilityChange();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- public void setOnSystemUiVisibilityChange() {
|
|
|
+ /**
|
|
|
+ * 화면 크기에 맞게 레이아웃 변경
|
|
|
+ * - 하단 네비바 유무에 따라서 스크린 사이즈 변경 됨
|
|
|
+ */
|
|
|
+ private void setOnSystemUiVisibilityChange() {
|
|
|
int finalUsableHeightNow = computeUsableHeight();
|
|
|
+
|
|
|
+ // 풀 스크린 버젼은 상단 스테이터스바의 높이가 계산되지 않아서 크기를 더해줌
|
|
|
if (AppUtil.isFullScreenVersion()) {
|
|
|
- finalUsableHeightNow = finalUsableHeightNow + ResourceUtil.getStatusBarHeight();
|
|
|
+ finalUsableHeightNow += ResourceUtil.getStatusBarHeight();
|
|
|
}
|
|
|
|
|
|
- int finalUsableHeightNow1 = finalUsableHeightNow;
|
|
|
- frameLayoutParams.height = finalUsableHeightNow1;
|
|
|
+ frameLayoutParams.height = finalUsableHeightNow;
|
|
|
childContent.requestLayout();
|
|
|
}
|
|
|
}
|