-/*
- * Copyright 2019-2022 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2019-2023, 2025 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.dialogs
import android.content.Context
import android.content.DialogInterface
import android.net.Uri
+import android.os.Build
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
+import androidx.core.view.isVisible
import androidx.fragment.app.DialogFragment
import androidx.preference.PreferenceManager
// The public interface is used to send information back to the parent activity.
interface OpenListener {
- fun onOpen(dialogFragment: DialogFragment)
+ fun openFile(dialogFragment: DialogFragment)
}
override fun onAttach(context: Context) {
// Set the open button listener.
dialogBuilder.setPositiveButton(R.string.open) { _: DialogInterface?, _: Int ->
// Return the dialog fragment to the parent activity.
- openListener.onOpen(this)
+ openListener.openFile(this)
}
// Create an alert dialog from the builder.
// Initially disable the open button.
openButton.isEnabled = false
+ // Only display the MHT check box if the API <= 34 (Android 14).
+ if (Build.VERSION.SDK_INT <= 34)
+ mhtCheckBox.visibility = View.VISIBLE
+ else
+ mhtCheckBox.visibility = View.GONE
+
// Update the status of the open button when the file name changes.
fileNameEditText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
super.onSaveInstanceState(savedInstanceState)
// Add the MHT explanation visibility status to the bundle.
- savedInstanceState.putBoolean(MHT_EXPLANATION_VISIBILITY, mhtExplanationTextView.visibility == View.VISIBLE)
+ savedInstanceState.putBoolean(MHT_EXPLANATION_VISIBILITY, mhtExplanationTextView.isVisible)
}
}