Skip to content

Commit

Permalink
replace deprecated api uses
Browse files Browse the repository at this point in the history
  • Loading branch information
empratyush authored and thestinger committed Sep 30, 2022
1 parent e083d1b commit e4a787b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
17 changes: 4 additions & 13 deletions app/src/main/java/app/grapheneos/pdfviewer/PdfViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import app.grapheneos.pdfviewer.fragment.DocumentPropertiesFragment;
import app.grapheneos.pdfviewer.fragment.PasswordPromptFragment;
import app.grapheneos.pdfviewer.fragment.JumpToPageFragment;
import app.grapheneos.pdfviewer.ktx.ViewKt;
import app.grapheneos.pdfviewer.loader.DocumentPropertiesLoader;
import app.grapheneos.pdfviewer.viewModel.PasswordStatus;

Expand Down Expand Up @@ -331,8 +332,7 @@ public boolean onTapUp() {
if (mUri != null) {
binding.webview.evaluateJavascript("isTextSelected()", selection -> {
if (!Boolean.parseBoolean(selection)) {
if ((getWindow().getDecorView().getSystemUiVisibility() &
View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
if (getSupportActionBar().isShowing()) {
hideSystemUi();
} else {
showSystemUi();
Expand Down Expand Up @@ -569,21 +569,12 @@ public void onJumpToPageInDocument(final int selected_page) {
}

private void showSystemUi() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
ViewKt.showSystemUi(binding.getRoot());
getSupportActionBar().show();
}

private void hideSystemUi() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE);
ViewKt.hideSystemUi(binding.getRoot());
getSupportActionBar().hide();
}

Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/app/grapheneos/pdfviewer/ktx/View.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package app.grapheneos.pdfviewer.ktx

import android.view.View
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat

private val systemBars = WindowInsetsCompat.Type.statusBars()

fun View.hideSystemUi() {
val controller = ViewCompat.getWindowInsetsController(this) ?: return
controller.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
controller.hide(systemBars)
}

fun View.showSystemUi() {
ViewCompat.getWindowInsetsController(this)?.show(systemBars)
}

0 comments on commit e4a787b

Please sign in to comment.