Skip to content

Commit 18761b3

Browse files
empratyushthestinger
authored andcommitted
replace deprecated api uses
1 parent 43f971c commit 18761b3

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

app/src/main/java/app/grapheneos/pdfviewer/PdfViewer.java

+4-13
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import app.grapheneos.pdfviewer.fragment.DocumentPropertiesFragment;
4545
import app.grapheneos.pdfviewer.fragment.PasswordPromptFragment;
4646
import app.grapheneos.pdfviewer.fragment.JumpToPageFragment;
47+
import app.grapheneos.pdfviewer.ktx.ViewKt;
4748
import app.grapheneos.pdfviewer.loader.DocumentPropertiesLoader;
4849
import app.grapheneos.pdfviewer.viewModel.PasswordStatus;
4950

@@ -331,8 +332,7 @@ public boolean onTapUp() {
331332
if (mUri != null) {
332333
binding.webview.evaluateJavascript("isTextSelected()", selection -> {
333334
if (!Boolean.parseBoolean(selection)) {
334-
if ((getWindow().getDecorView().getSystemUiVisibility() &
335-
View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
335+
if (getSupportActionBar().isShowing()) {
336336
hideSystemUi();
337337
} else {
338338
showSystemUi();
@@ -569,21 +569,12 @@ public void onJumpToPageInDocument(final int selected_page) {
569569
}
570570

571571
private void showSystemUi() {
572-
getWindow().getDecorView().setSystemUiVisibility(
573-
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
574-
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
575-
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
572+
ViewKt.showSystemUi(binding.getRoot());
576573
getSupportActionBar().show();
577574
}
578575

579576
private void hideSystemUi() {
580-
getWindow().getDecorView().setSystemUiVisibility(
581-
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
582-
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
583-
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
584-
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
585-
View.SYSTEM_UI_FLAG_FULLSCREEN |
586-
View.SYSTEM_UI_FLAG_IMMERSIVE);
577+
ViewKt.hideSystemUi(binding.getRoot());
587578
getSupportActionBar().hide();
588579
}
589580

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package app.grapheneos.pdfviewer.ktx
2+
3+
import android.view.View
4+
import androidx.core.view.ViewCompat
5+
import androidx.core.view.WindowInsetsCompat
6+
import androidx.core.view.WindowInsetsControllerCompat
7+
8+
private val systemBars = WindowInsetsCompat.Type.statusBars()
9+
10+
fun View.hideSystemUi() {
11+
val controller = ViewCompat.getWindowInsetsController(this) ?: return
12+
controller.systemBarsBehavior =
13+
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
14+
controller.hide(systemBars)
15+
}
16+
17+
fun View.showSystemUi() {
18+
ViewCompat.getWindowInsetsController(this)?.show(systemBars)
19+
}

0 commit comments

Comments
 (0)