replace deprecated api uses

This commit is contained in:
Pratyush 2022-10-02 18:42:24 +05:30 committed by Daniel Micay
parent 7ff831769e
commit 5fadf7f47d
2 changed files with 8 additions and 7 deletions

View File

@ -569,12 +569,12 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
} }
private void showSystemUi() { private void showSystemUi() {
ViewKt.showSystemUi(binding.getRoot()); ViewKt.showSystemUi(binding.getRoot(), getWindow());
getSupportActionBar().show(); getSupportActionBar().show();
} }
private void hideSystemUi() { private void hideSystemUi() {
ViewKt.hideSystemUi(binding.getRoot()); ViewKt.hideSystemUi(binding.getRoot(), getWindow());
getSupportActionBar().hide(); getSupportActionBar().hide();
} }

View File

@ -1,19 +1,20 @@
package app.grapheneos.pdfviewer.ktx package app.grapheneos.pdfviewer.ktx
import android.view.View import android.view.View
import androidx.core.view.ViewCompat import android.view.Window
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat import androidx.core.view.WindowInsetsControllerCompat
private val systemBars = WindowInsetsCompat.Type.statusBars() private val systemBars = WindowInsetsCompat.Type.statusBars()
fun View.hideSystemUi() { fun View.hideSystemUi(window: Window) {
val controller = ViewCompat.getWindowInsetsController(this) ?: return val controller = WindowCompat.getInsetsController(window, this)
controller.systemBarsBehavior = controller.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
controller.hide(systemBars) controller.hide(systemBars)
} }
fun View.showSystemUi() { fun View.showSystemUi(window: Window) {
ViewCompat.getWindowInsetsController(this)?.show(systemBars) WindowCompat.getInsetsController(window, this).show(systemBars)
} }