solve API 30 deprecation with getSystemWindowInsetTop

Signed-off-by: June <june@eridan.me>
This commit is contained in:
June 2022-02-06 03:25:11 +00:00 committed by Daniel Micay
parent 5494376175
commit 851dd55d43

View File

@ -6,6 +6,7 @@ import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
@ -23,6 +24,7 @@ import android.webkit.WebViewClient;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
@ -37,6 +39,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
public class PdfViewer extends AppCompatActivity implements LoaderManager.LoaderCallbacks<List<CharSequence>> {
public static final String TAG = "PdfViewer";
@ -163,7 +166,10 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
}
mWebView.setOnApplyWindowInsetsListener((view, insets) -> {
windowInsetTop = insets.getSystemWindowInsetTop();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
insets.getInsets(windowInsetTop);
else
windowInsetTop = insets.getSystemWindowInsetTop();
mWebView.evaluateJavascript("updateInset()", null);
return insets;
});