From 270fa52220ad539f179953de65426f5a8a88de52 Mon Sep 17 00:00:00 2001 From: tehcneko <7741672-NekoInverter@users.noreply.gitlab.com> Date: Sun, 23 Jan 2022 16:38:07 +0800 Subject: [PATCH] Try to fix fullscreen --- .../hippo/ehviewer/ui/GalleryActivity.java | 4 +++- .../hippo/ehviewer/widget/SeekBarPanel.java | 22 +++++++++++++++++-- app/src/main/res/layout/activity_gallery.xml | 3 +-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java index d858e51d8..28fca9799 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java @@ -387,12 +387,14 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan mGalleryProvider.setGLRoot(mGLRootView); WindowCompat.setDecorFitsSystemWindows(getWindow(), false); - insetsController = ViewCompat.getWindowInsetsController(getWindow().getDecorView()); + insetsController = WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView()); if (insetsController != null) { if (Settings.getReadingFullscreen()) { insetsController.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + // This does not hide navigation bar sometimes on 31, framework bug??? insetsController.hide(WindowInsetsCompat.Type.systemBars()); } else { + insetsController.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); insetsController.show(WindowInsetsCompat.Type.systemBars()); } boolean night = ConfigurationKt.isNight(getResources().getConfiguration()); diff --git a/app/src/main/java/com/hippo/ehviewer/widget/SeekBarPanel.java b/app/src/main/java/com/hippo/ehviewer/widget/SeekBarPanel.java index 2df3541f1..08f9401ee 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/SeekBarPanel.java +++ b/app/src/main/java/com/hippo/ehviewer/widget/SeekBarPanel.java @@ -24,6 +24,7 @@ import android.widget.LinearLayout; import android.widget.SeekBar; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.hippo.ehviewer.R; import com.hippo.yorozuya.ViewUtils; @@ -35,14 +36,31 @@ public class SeekBarPanel extends LinearLayout { public SeekBarPanel(Context context) { super(context); + init(); } - public SeekBarPanel(Context context, AttributeSet attrs) { + public SeekBarPanel(Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) { super(context, attrs); + init(); } - public SeekBarPanel(Context context, AttributeSet attrs, int defStyleAttr) { + public SeekBarPanel(Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); + init(); + } + + public SeekBarPanel(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + init(); + } + + private void init() { + post(() -> { + var rootWindowInsets = getRootWindowInsets(); + if (rootWindowInsets != null) { + setPadding(0, 0, 0, rootWindowInsets.getSystemWindowInsetBottom()); + } + }); } @Override diff --git a/app/src/main/res/layout/activity_gallery.xml b/app/src/main/res/layout/activity_gallery.xml index ec37e607e..2367c2462 100644 --- a/app/src/main/res/layout/activity_gallery.xml +++ b/app/src/main/res/layout/activity_gallery.xml @@ -71,8 +71,7 @@ android:orientation="horizontal" android:paddingLeft="16dp" android:paddingRight="16dp" - android:visibility="invisible" - app:fitsSystemWindowsInsets="bottom"> + android:visibility="invisible">