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

修复预览页单击图片进入全屏观看模式后直接返回上一页状态栏没恢复 #2875

Open
wants to merge 1 commit into
base: version_component
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 @@ -162,6 +162,7 @@ public class PictureSelectorPreviewFragment extends PictureCommonFragment {
protected List<View> mAnimViews = new ArrayList<>();

private boolean isPause = false;
private boolean isEnterWindowFullScreen = false;

public static PictureSelectorPreviewFragment newInstance() {
PictureSelectorPreviewFragment fragment = new PictureSelectorPreviewFragment();
Expand Down Expand Up @@ -745,6 +746,7 @@ public void onBackPressed() {
onBackCurrentFragment();
}
}
exitWindowFullScreen();
}
});
titleBar.setTitle((curPosition + 1) + "/" + totalNum);
Expand Down Expand Up @@ -1294,6 +1296,7 @@ private void onKeyDownBackToMin() {
} else {
onBackCurrentFragment();
}
exitWindowFullScreen();
}
}

Expand Down Expand Up @@ -1325,20 +1328,10 @@ private void previewFullScreenMode() {
@Override
public void onAnimationEnd(Animator animation) {
isAnimationStart = false;
if (SdkVersionUtils.isP() && isAdded()) {
Window window = requireActivity().getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
if (isAnimInit) {
lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
lp.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
window.setAttributes(lp);
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} else {
lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.setAttributes(lp);
window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
if (isAnimInit) {
enterWindowFullScreen();
} else {
exitWindowFullScreen();
}
}
});
Expand All @@ -1350,6 +1343,30 @@ public void onAnimationEnd(Animator animation) {
}
}

private void enterWindowFullScreen() {
if (SdkVersionUtils.isP() && isAdded() && !isEnterWindowFullScreen) {
isEnterWindowFullScreen = true;
Window window = requireActivity().getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
lp.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
window.setAttributes(lp);
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
}

private void exitWindowFullScreen() {
if (SdkVersionUtils.isP() && isAdded() && isEnterWindowFullScreen) {
isEnterWindowFullScreen = false;
Window window = requireActivity().getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.setAttributes(lp);
window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
}

/**
* 全屏模式
*/
Expand Down