-/*
- * Copyright 2016-2022 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2016-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
+ * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android/>.
*
- * Privacy Browser Android is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
*
- * Privacy Browser Android is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
*
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser Android. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.stoutner.privacybrowser.fragments
import android.content.Intent
import android.content.res.Configuration
-import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import com.stoutner.privacybrowser.R
// Define the class constants.
-private const val TAB_NUMBER = "tab_number"
-private const val SCROLL_Y = "scroll_y"
+private const val TAB_NUMBER = "A"
+private const val SCROLL_Y = "B"
class GuideWebViewFragment : Fragment() {
// Define the class variables.
// Set a WebView client.
tabWebView.webViewClient = object : WebViewClient() {
- // Send external links back to the main Privacy Browser WebView. The deprecated `shouldOverrideUrlLoading` must be used until API >= 24.
- @Deprecated("Deprecated in Java")
- override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
+ // Send external links back to the main Privacy Browser WebView.
+ override fun shouldOverrideUrlLoading(view: WebView, webResourceRequest: WebResourceRequest): Boolean {
// Create an intent to view the URL.
val urlIntent = Intent(Intent.ACTION_VIEW)
// Add the URL to the intent.
- urlIntent.data = Uri.parse(url)
+ urlIntent.data = webResourceRequest.url
// Make it so.
startActivity(urlIntent)
9 -> tabWebView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.android_asset_path) + "/guide_interface.html")
}
- // Scroll the WebView if the saved instance state is not null.
+ // Restore the WebView scroll position if the activity has been restarted.
if (savedInstanceState != null) {
tabWebView.post {
tabWebView.scrollY = savedInstanceState.getInt(SCROLL_Y)