From 111fb1626611ec1379d0618eb54caa68056d0ebd Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Sat, 2 Dec 2023 21:05:06 -0600 Subject: [PATCH] webview version check --- app/build.gradle | 1 + .../novel/novelreader/NovelReaderActivity.kt | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index bdb75b22..eb978148 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,6 +67,7 @@ dependencies { implementation 'com.github.Blatzar:NiceHttp:0.4.4' implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0' implementation 'androidx.preference:preference:1.2.1' + implementation 'androidx.webkit:webkit:1.9.0' // Glide ext.glide_version = '4.16.0' diff --git a/app/src/main/java/ani/dantotsu/media/novel/novelreader/NovelReaderActivity.kt b/app/src/main/java/ani/dantotsu/media/novel/novelreader/NovelReaderActivity.kt index 8cc990e5..069fef28 100644 --- a/app/src/main/java/ani/dantotsu/media/novel/novelreader/NovelReaderActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/novel/novelreader/NovelReaderActivity.kt @@ -2,8 +2,10 @@ package ani.dantotsu.media.novel.novelreader import android.animation.ObjectAnimator import android.annotation.SuppressLint +import android.content.Intent import android.content.pm.ActivityInfo import android.graphics.Color +import android.net.Uri import android.os.Build import android.os.Bundle import android.util.Base64 @@ -14,12 +16,14 @@ import android.view.ViewGroup import android.view.WindowManager import android.view.animation.OvershootInterpolator import android.widget.AdapterView +import android.widget.Toast import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatActivity import androidx.core.net.toUri import androidx.core.view.GestureDetectorCompat import androidx.core.view.updateLayoutParams import androidx.lifecycle.lifecycleScope +import androidx.webkit.WebViewCompat import ani.dantotsu.GesturesListener import ani.dantotsu.NoPaddingArrayAdapter import ani.dantotsu.R @@ -137,6 +141,20 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + //check for supported webview + val webViewVersion = WebViewCompat.getCurrentWebViewPackage(this)?.versionName + val firstVersion = webViewVersion?.split(".")?.firstOrNull()?.toIntOrNull() + if (webViewVersion == null || firstVersion == null || firstVersion < 87) { + Toast.makeText(this, "Please update WebView from PlayStore", Toast.LENGTH_LONG).show() + //open playstore + val intent = Intent(Intent.ACTION_VIEW) + intent.data = Uri.parse("https://play.google.com/store/apps/details?id=com.google.android.webview") + startActivity(intent) + //stop reader + finish() + return + } + LangSet.setLocale(this) ThemeManager(this).applyTheme() binding = ActivityNovelReaderBinding.inflate(layoutInflater)