|
|
@ -4,11 +4,13 @@ import android.annotation.SuppressLint |
|
|
|
import android.content.pm.ActivityInfo |
|
|
|
import android.content.pm.ActivityInfo |
|
|
|
import android.net.Uri |
|
|
|
import android.net.Uri |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
|
|
|
|
import android.view.KeyEvent |
|
|
|
import android.view.Menu |
|
|
|
import android.view.Menu |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
import android.webkit.* |
|
|
|
import android.webkit.* |
|
|
|
import androidx.activity.viewModels |
|
|
|
import androidx.activity.viewModels |
|
|
|
|
|
|
|
import androidx.core.view.size |
|
|
|
import androidx.webkit.WebSettingsCompat |
|
|
|
import androidx.webkit.WebSettingsCompat |
|
|
|
import androidx.webkit.WebViewFeature |
|
|
|
import androidx.webkit.WebViewFeature |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
@ -131,6 +133,38 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean { |
|
|
|
|
|
|
|
when (keyCode) { |
|
|
|
|
|
|
|
KeyEvent.KEYCODE_BACK -> { |
|
|
|
|
|
|
|
finish() |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return super.onKeyLongPress(keyCode, event) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean { |
|
|
|
|
|
|
|
event?.let { |
|
|
|
|
|
|
|
when (keyCode) { |
|
|
|
|
|
|
|
KeyEvent.KEYCODE_BACK -> if (event.isTracking && !event.isCanceled && binding.webView.canGoBack()) { |
|
|
|
|
|
|
|
if (binding.customWebView.size > 0) { |
|
|
|
|
|
|
|
customWebViewCallback?.onCustomViewHidden() |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} else if (binding.webView.copyBackForwardList().size > 1) { |
|
|
|
|
|
|
|
binding.webView.goBack() |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return super.onKeyUp(keyCode, event) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
|
|
|
|
super.onDestroy() |
|
|
|
|
|
|
|
binding.webView.destroy() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inner class CustomWebChromeClient : WebChromeClient() { |
|
|
|
inner class CustomWebChromeClient : WebChromeClient() { |
|
|
|
|
|
|
|
|
|
|
|
override fun onReceivedTitle(view: WebView?, title: String?) { |
|
|
|
override fun onReceivedTitle(view: WebView?, title: String?) { |
|
|
|