<PersistentState>
<option name="values">
<map>
- <entry key="url" value="jar:file:/home/soren/Android/android-studio/plugins/android/lib/android.jar!/images/material_design_icons/action/ic_open_in_browser_black_24dp.xml" />
+ <entry key="url" value="jar:file:/home/soren/Android/android-studio/plugins/android/lib/android.jar!/images/material/icons/materialicons/share/baseline_share_24.xml" />
</map>
</option>
</PersistentState>
</option>
<option name="values">
<map>
- <entry key="outputName" value="proxy_enabled_light" />
+ <entry key="autoMirrored" value="true" />
+ <entry key="outputName" value="share_day" />
<entry key="sourceFile" value="$USER_HOME$/ownCloud/Android/Privacy Browser/Icons/Icons/link_off_light.svg" />
</map>
</option>
<p><img class="icon" src="../shared_images/select_all_dark.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_dark.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_dark.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_night.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_dark.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_dark.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_dark.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_light.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_light.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_light.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_day.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_light.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_light.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_light.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_dark.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_dark.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_dark.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_night.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_dark.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_dark.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_dark.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_light.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_light.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_light.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_day.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_light.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_light.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_light.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_dark.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_dark.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_dark.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_night.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_dark.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_dark.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_dark.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_light.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_light.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_light.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_day.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_light.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_light.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_light.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_dark.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_dark.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_dark.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_night.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_dark.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_dark.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_dark.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_light.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_light.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_light.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_day.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_light.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_light.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_light.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_dark.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_dark.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_dark.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_night.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_dark.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_dark.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_dark.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_light.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_light.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_light.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_day.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_light.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_light.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_light.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_dark.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_dark.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_dark.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_night.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_dark.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_dark.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_dark.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_light.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_light.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_light.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_day.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_light.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_light.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_light.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_dark.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_dark.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_dark.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_night.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_dark.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_dark.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_dark.png"> style.</p>
<p><img class="icon" src="../shared_images/select_all_light.png"> select_all.</p>
<p><img class="icon" src="../shared_images/settings_light.png"> settings.</p>
<p><img class="icon" src="../shared_images/settings_overscan_light.png"> settings_overscan.</p>
+ <p><img class="icon" src="../shared_images/share_day.png"> share.</p>
<p><img class="icon" src="../shared_images/smartphone_light.png"> smartphone.</p>
<p><img class="icon" src="../shared_images/sort_light.png"> sort.</p>
<p><img class="icon" src="../shared_images/style_light.png"> style.</p>
package com.stoutner.privacybrowser.activities;
+import android.Manifest;
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.media.MediaScannerConnection;
+import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.view.View;
import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+import androidx.core.content.FileProvider;
+import androidx.fragment.app.DialogFragment;
import androidx.viewpager.widget.ViewPager;
+import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import com.stoutner.privacybrowser.adapters.AboutPagerAdapter;
import com.stoutner.privacybrowser.R;
+import com.stoutner.privacybrowser.asynctasks.SaveAboutVersionImage;
+import com.stoutner.privacybrowser.dialogs.SaveDialog;
+import com.stoutner.privacybrowser.dialogs.StoragePermissionDialog;
+import com.stoutner.privacybrowser.fragments.AboutVersionFragment;
+import com.stoutner.privacybrowser.helpers.FileNameHelper;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
+
+public class AboutActivity extends AppCompatActivity implements SaveDialog.SaveListener, StoragePermissionDialog.StoragePermissionDialogListener {
+ // Declare the class variables.
+ private String filePathString;
+ private AboutPagerAdapter aboutPagerAdapter;
+
+ // Declare the class views.
+ private LinearLayout aboutVersionLinearLayout;
-public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// Get a handle for the shared preferences.
// Display the home arrow on action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
- // Setup the ViewPager.
- aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager(), getApplicationContext(), blocklistVersions));
+ // Initialize the about pager adapter.
+ aboutPagerAdapter = new AboutPagerAdapter(getSupportFragmentManager(), getApplicationContext(), blocklistVersions);
+
+ // Setup the ViewPager.
+ aboutViewPager.setAdapter(aboutPagerAdapter);
// Keep all the tabs in memory. This prevents the memory usage updater from running multiple times.
aboutViewPager.setOffscreenPageLimit(10);
// Connect the tab layout to the view pager.
aboutTabLayout.setupWithViewPager(aboutViewPager);
}
+
+ @Override
+ public void onSave(int saveType, DialogFragment dialogFragment) {
+ // Get a handle for the dialog.
+ Dialog dialog = dialogFragment.getDialog();
+
+ // Remove the lint warning below that the dialog might be null.
+ assert dialog != null;
+
+ // Get a handle for the file name edit text.
+ EditText fileNameEditText = dialog.findViewById(R.id.file_name_edittext);
+
+ // Get the file path string.
+ filePathString = fileNameEditText.getText().toString();
+
+ // Get a handle for the about version linear layout.
+ aboutVersionLinearLayout = findViewById(R.id.about_version_linearlayout);
+
+ // check to see if the storage permission is needed.
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { // The storage permission has been granted.
+ // Save the file according to the type.
+ switch (saveType) {
+ case SaveDialog.SAVE_ABOUT_VERSION_TEXT:
+ // Save the about version text.
+ saveAsText(filePathString);
+ break;
+
+ case SaveDialog.SAVE_ABOUT_VERSION_IMAGE:
+ // Save the about version image.
+ new SaveAboutVersionImage(this, this, filePathString, aboutVersionLinearLayout).execute();
+ break;
+ }
+
+ // Reset the file path string.
+ filePathString = "";
+ } else { // The storage permission has not been granted.
+ // Get the external private directory file.
+ File externalPrivateDirectoryFile = getExternalFilesDir(null);
+
+ // Remove the incorrect lint error below that the file might be null.
+ assert externalPrivateDirectoryFile != null;
+
+ // Get the external private directory string.
+ String externalPrivateDirectory = externalPrivateDirectoryFile.toString();
+
+ // Check to see if the file path is in the external private directory.
+ if (filePathString.startsWith(externalPrivateDirectory)) { // The file path is in the external private directory.
+ // Save the webpage according to the type.
+ switch (saveType) {
+ case SaveDialog.SAVE_ABOUT_VERSION_TEXT:
+ // Save the about version text.
+ saveAsText(filePathString);
+ break;
+
+ case SaveDialog.SAVE_ABOUT_VERSION_IMAGE:
+ // Save the about version image.
+ new SaveAboutVersionImage(this, this, filePathString, aboutVersionLinearLayout).execute();
+ break;
+ }
+
+ // Reset the file path string.
+ filePathString = "";
+ } else { // The file path is in a public directory.
+ // Check if the user has previously denied the storage permission.
+ if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { // Show a dialog explaining the request first.
+ // Declare a storage permission dialog fragment.
+ DialogFragment storagePermissionDialogFragment;
+
+ // Instantiate the storage permission alert dialog according to the type.
+ if (saveType == SaveDialog.SAVE_ABOUT_VERSION_TEXT) {
+ storagePermissionDialogFragment = StoragePermissionDialog.displayDialog(StoragePermissionDialog.SAVE_TEXT);
+ } else {
+ storagePermissionDialogFragment = StoragePermissionDialog.displayDialog(StoragePermissionDialog.SAVE_IMAGE);
+ }
+
+ // Show the storage permission alert dialog. The permission will be requested when the dialog is closed.
+ storagePermissionDialogFragment.show(getSupportFragmentManager(), getString(R.string.storage_permission));
+ } else { // Show the permission request directly.
+ switch (saveType) {
+ case SaveDialog.SAVE_ABOUT_VERSION_TEXT:
+ // Request the write external storage permission. The text will be saved when it finishes.
+ ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, StoragePermissionDialog.SAVE_TEXT);
+ break;
+
+ case SaveDialog.SAVE_ABOUT_VERSION_IMAGE:
+ // Request the write external storage permission. The image will be saved when it finishes.
+ ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, StoragePermissionDialog.SAVE_IMAGE);
+ break;
+ }
+
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onCloseStoragePermissionDialog(int requestType) {
+ // Request the write external storage permission according to the request type. About version will be saved when it finishes.
+ ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, requestType);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ //Only process the results if they exist (this method is triggered when a dialog is presented the first time for an app, but no grant results are included).
+ if (grantResults.length > 0) {
+ // Check to see if the storage permission was granted. If the dialog was canceled the grant results will be empty.
+ if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // The storage permission was granted.
+ switch (requestCode) {
+ case StoragePermissionDialog.SAVE_TEXT:
+ // Save the about version text.
+ saveAsText(filePathString);
+ break;
+
+ case StoragePermissionDialog.SAVE_IMAGE:
+ // Save the about version image.
+ new SaveAboutVersionImage(this, this, filePathString, aboutVersionLinearLayout).execute();
+ break;
+ }
+ } else{ // the storage permission was not granted.
+ // Display an error snackbar.
+ Snackbar.make(aboutVersionLinearLayout, getString(R.string.cannot_use_location), Snackbar.LENGTH_LONG).show();
+ }
+
+ // Reset the file path string.
+ filePathString = "";
+ }
+ }
+
+ // The activity result is called after browsing for a file in the save alert dialog.
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ // Run the default commands.
+ super.onActivityResult(requestCode, resultCode, data);
+
+ // Only do something if the user didn't press back from the file picker.
+ if (resultCode == Activity.RESULT_OK) {
+ // Get a handle for the save dialog fragment.
+ DialogFragment saveDialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(getString(R.string.save_dialog));
+
+ // Only update the file name if the dialog still exists.
+ if (saveDialogFragment != null) {
+ // Get a handle for the save dialog.
+ Dialog saveDialog = saveDialogFragment.getDialog();
+
+ // Remove the lint warning below that the dialog might be null.
+ assert saveDialog != null;
+
+ // Get a handle for the dialog view.
+ EditText fileNameEditText = saveDialog.findViewById(R.id.file_name_edittext);
+ TextView fileExistsWarningTextView = saveDialog.findViewById(R.id.file_exists_warning_textview);
+
+ // Get the file name URI from the intent.
+ Uri fileNameUri = data.getData();
+
+ // Process the file name URI if it is not null.
+ if (fileNameUri != null) {
+ // Instantiate a file name helper.
+ FileNameHelper fileNameHelper = new FileNameHelper();
+
+ // Convert the file name URI to a file name path.
+ String fileNamePath = fileNameHelper.convertUriToFileNamePath(fileNameUri);
+
+ // Set the file name path as the text of the file nam edit text.
+ fileNameEditText.setText(fileNamePath);
+
+ // Move the cursor to the end of the file name edit text.
+ fileNameEditText.setSelection(fileNamePath.length());
+
+ // Hid ethe file exists warning.
+ fileExistsWarningTextView.setVisibility(View.GONE);
+ }
+ }
+ }
+ }
+
+ private void saveAsText(String fileNameString) {
+ try {
+ // Get a handle for the about about version fragment.
+ AboutVersionFragment aboutVersionFragment = (AboutVersionFragment) aboutPagerAdapter.getTabFragment(0);
+
+ // Get the about version text.
+ String aboutVersionString = aboutVersionFragment.getAboutVersionString();
+
+ // Create an input stream with the contents of about version.
+ InputStream aboutVersionInputStream = new ByteArrayInputStream(aboutVersionString.getBytes(StandardCharsets.UTF_8));
+
+ // Create an about version buffered reader.
+ BufferedReader aboutVersionBufferedReader = new BufferedReader(new InputStreamReader(aboutVersionInputStream));
+
+ // Create a file from the file name string.
+ File saveFile = new File(fileNameString);
+
+ // Delete the file if it already exists.
+ if (saveFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ saveFile.delete();
+ }
+
+ // Create a file buffered writer.
+ BufferedWriter fileBufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(saveFile)));
+
+ // Create a transfer string.
+ String transferString;
+
+ // Use the transfer string to copy the about version text from the buffered reader to the buffered writer.
+ while ((transferString = aboutVersionBufferedReader.readLine()) != null) {
+ // Append the line to the buffered writer.
+ fileBufferedWriter.append(transferString);
+
+ // Append a line break.
+ fileBufferedWriter.append("\n");
+ }
+
+ // Close the buffered reader and writer.
+ aboutVersionBufferedReader.close();
+ fileBufferedWriter.close();
+
+ // Add the file to the list of recent files. This doesn't currently work, but maybe it will someday.
+ MediaScannerConnection.scanFile(this, new String[] {fileNameString}, new String[] {"text/plain"}, null);
+
+ // Create an about version saved snackbar.
+ Snackbar aboutVersionSavedSnackbar = Snackbar.make(aboutVersionLinearLayout, getString(R.string.file_saved) + " " + fileNameString, Snackbar.LENGTH_SHORT);
+
+ // Add an open option to the snackbar.
+ aboutVersionSavedSnackbar.setAction(R.string.open, (View view) -> {
+ // Get a file for the file name string.
+ File file = new File(fileNameString);
+
+ // Declare a file URI variable.
+ Uri fileUri;
+
+ // Get the URI for the file according to the Android version.
+ if (Build.VERSION.SDK_INT >= 24) { // Use a file provider.
+ fileUri = FileProvider.getUriForFile(this, getString(R.string.file_provider), file);
+ } else { // Get the raw file path URI.
+ fileUri = Uri.fromFile(file);
+ }
+
+ // Get a handle for the content resolver.
+ ContentResolver contentResolver = getContentResolver();
+
+ // Create an open intent with `ACTION_VIEW`.
+ Intent openIntent = new Intent(Intent.ACTION_VIEW);
+
+ // Set the URI and the MIME type.
+ openIntent.setDataAndType(fileUri, contentResolver.getType(fileUri));
+
+ // Allow the app to read the file URI.
+ openIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+
+ // Show the chooser.
+ startActivity(Intent.createChooser(openIntent, getString(R.string.open)));
+ });
+
+ // Show the about version saved snackbar.
+ aboutVersionSavedSnackbar.show();
+ } catch (Exception exception) {
+ // Display a snackbar with the error message.
+ Snackbar.make(aboutVersionLinearLayout, getString(R.string.error_saving_file) + " " + exception.toString(), Snackbar.LENGTH_INDEFINITE).show();
+ }
+ }
}
\ No newline at end of file
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
// Get the ID of the menu item that was selected.
- int menuItemID = menuItem.getItemId();
+ int menuItemId = menuItem.getItemId();
// Get a handle for the fragment manager.
FragmentManager fragmentManager = getSupportFragmentManager();
- switch (menuItemID) {
+ switch (menuItemId) {
case android.R.id.home: // The home arrow is identified as `android.R.id.home`, not just `R.id.home`.
if (twoPanedMode) { // The device is in two-paned mode.
// Save the current domain settings if the domain settings fragment is displayed.
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipboardManager;
+import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.media.MediaScannerConnection;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.TypedValue;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
+import androidx.core.content.FileProvider;
import androidx.fragment.app.DialogFragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.stoutner.privacybrowser.R;
import com.stoutner.privacybrowser.asynctasks.GetLogcat;
import com.stoutner.privacybrowser.dialogs.StoragePermissionDialog;
-import com.stoutner.privacybrowser.dialogs.SaveLogcatDialog;
+import com.stoutner.privacybrowser.dialogs.SaveDialog;
import com.stoutner.privacybrowser.helpers.FileNameHelper;
import java.io.BufferedReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
-public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialog.SaveLogcatListener, StoragePermissionDialog.StoragePermissionDialogListener {
- // Initialize the saved instance state constants.
+public class LogcatActivity extends AppCompatActivity implements SaveDialog.SaveListener, StoragePermissionDialog.StoragePermissionDialogListener {
+ // Declare the class constants.
private final String SCROLLVIEW_POSITION = "scrollview_position";
- // Define the class variables.
+ // Declare the class variables.
private String filePathString;
// Define the class views.
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
// Get the screenshot preference.
- boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+ boolean allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false);
// Disable screenshots if not allowed.
if (!allowScreenshots) {
int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
// Set the refresh color scheme according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- swipeRefreshLayout.setColorSchemeResources(R.color.blue_500);
- } else {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
swipeRefreshLayout.setColorSchemeResources(R.color.blue_700);
+ } else {
+ swipeRefreshLayout.setColorSchemeResources(R.color.blue_500);
}
// Initialize a color background typed value.
// Get a handle for the clipboard manager.
ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
- // Save the logcat in a ClipData.
- ClipData logcatClipData = ClipData.newPlainText(getString(R.string.logcat), logcatTextView.getText());
-
- // Remove the incorrect lint error that `clipboardManager.setPrimaryClip()` might produce a null pointer exception.
+ // Remove the incorrect lint error below that the clipboard manager might be null.
assert clipboardManager != null;
- // Place the ClipData on the clipboard.
+ // Save the logcat in a clip data.
+ ClipData logcatClipData = ClipData.newPlainText(getString(R.string.logcat), logcatTextView.getText());
+
+ // Place the clip data on the clipboard.
clipboardManager.setPrimaryClip(logcatClipData);
// Display a snackbar.
case R.id.save:
// Instantiate the save alert dialog.
- DialogFragment saveDialogFragment = new SaveLogcatDialog();
+ DialogFragment saveDialogFragment = SaveDialog.save(SaveDialog.SAVE_LOGCAT);
// Show the save alert dialog.
saveDialogFragment.show(getSupportFragmentManager(), getString(R.string.save_logcat));
}
@Override
- public void onSaveLogcat(DialogFragment dialogFragment) {
- // Get a handle for the dialog fragment.
+ public void onSave(int saveType, DialogFragment dialogFragment) {
+ // Get a handle for the dialog.
Dialog dialog = dialogFragment.getDialog();
- // Remove the lint warning below that the dialog fragment might be null.
+ // Remove the lint warning below that the dialog might be null.
assert dialog != null;
// Get a handle for the file name edit text.
// Save the logcat.
saveLogcat(filePathString);
} else { // The storage permission has not been granted.
- // Get the external private directory `File`.
+ // Get the external private directory file.
File externalPrivateDirectoryFile = getExternalFilesDir(null);
// Remove the incorrect lint error below that the file might be null.
if (filePathString.startsWith(externalPrivateDirectory)) { // The file path is in the external private directory.
// Save the logcat.
saveLogcat(filePathString);
- } else { // The file path in in a public directory.
+ } else { // The file path is in a public directory.
// Check if the user has previously denied the storage permission.
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { // Show a dialog explaining the request first.
- // Instantiate the storage permission alert dialog.
+ // Instantiate the storage permission alert dialog. The type is specified as `0` because it currently isn't used for this activity.
DialogFragment storagePermissionDialogFragment = StoragePermissionDialog.displayDialog(0);
// Show the storage permission alert dialog. The permission will be requested when the dialog is closed.
}
@Override
- public void onCloseStoragePermissionDialog(int type) {
+ public void onCloseStoragePermissionDialog(int requestType) {
// Request the write external storage permission. The logcat will be saved when it finishes.
ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
}
}
}
+ // The activity result is called after browsing for a file in the save alert dialog.
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ // Run the default commands.
+ super.onActivityResult(requestCode, resultCode, data);
+
+ // Only do something if the user didn't press back from the file picker.
+ if (resultCode == Activity.RESULT_OK) {
+ // Get a handle for the save dialog fragment.
+ DialogFragment saveDialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(getString(R.string.save_logcat));
+
+ // Only update the file name if the dialog still exists.
+ if (saveDialogFragment != null) {
+ // Get a handle for the save dialog.
+ Dialog saveDialog = saveDialogFragment.getDialog();
+
+ // Remove the lint warning below that the save dialog might be null.
+ assert saveDialog != null;
+
+ // Get a handle for the dialog views.
+ EditText fileNameEditText = saveDialog.findViewById(R.id.file_name_edittext);
+ TextView fileExistsWarningTextView = saveDialog.findViewById(R.id.file_exists_warning_textview);
+
+ // Get the file name URI from the intent.
+ Uri fileNameUri = data.getData();
+
+ // Process the file name URI if it is not null.
+ if (fileNameUri != null) {
+ // Instantiate a file name helper.
+ FileNameHelper fileNameHelper = new FileNameHelper();
+
+ // Convert the file name URI to a file name path.
+ String fileNamePath = fileNameHelper.convertUriToFileNamePath(fileNameUri);
+
+ // Set the file name path as the text of the file name edit text.
+ fileNameEditText.setText(fileNamePath);
+
+ // Move the cursor to the end of the file name edit text.
+ fileNameEditText.setSelection(fileNamePath.length());
+
+ // Hide the file exists warning.
+ fileExistsWarningTextView.setVisibility(View.GONE);
+ }
+ }
+ }
+ }
+
private void saveLogcat(String fileNameString) {
try {
// Get the logcat as a string.
// Create a file from the file name string.
File saveFile = new File(fileNameString);
+ // Delete the file if it already exists.
+ if (saveFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ saveFile.delete();
+ }
+
// Create a file buffered writer.
BufferedWriter fileBufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(saveFile)));
// Add the file to the list of recent files. This doesn't currently work, but maybe it will someday.
MediaScannerConnection.scanFile(this, new String[] {fileNameString}, new String[] {"text/plain"}, null);
- // Display a snackbar.
- Snackbar.make(logcatTextView, getString(R.string.file_saved_successfully), Snackbar.LENGTH_SHORT).show();
- } catch (Exception exception) {
- // Display a snackbar with the error message.
- Snackbar.make(logcatTextView, getString(R.string.save_failed) + " " + exception.toString(), Snackbar.LENGTH_INDEFINITE).show();
- }
- }
+ // Create a logcat saved snackbar.
+ Snackbar logcatSavedSnackbar = Snackbar.make(logcatTextView, getString(R.string.file_saved) + " " + fileNameString, Snackbar.LENGTH_SHORT);
- // The activity result is called after browsing for a file in the save alert dialog.
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- // Run the default commands.
- super.onActivityResult(requestCode, resultCode, data);
-
- // Don't do anything if the user pressed back from the file picker.
- if (resultCode == Activity.RESULT_OK) {
- // Get a handle for the save dialog fragment.
- DialogFragment saveDialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(getString(R.string.save_logcat));
-
- // Only update the file name if the dialog still exists.
- if (saveDialogFragment != null) {
- // Get a handle for the save dialog.
- Dialog saveDialog = saveDialogFragment.getDialog();
+ // Add an open action to the snackbar.
+ logcatSavedSnackbar.setAction(R.string.open, (View view) -> {
+ // Get a file for the file name string.
+ File file = new File(fileNameString);
- // Remove the lint warning below that the save dialog might be null.
- assert saveDialog != null;
+ // Declare a file URI variable.
+ Uri fileUri;
- // Get a handle for the dialog views.
- EditText fileNameEditText = saveDialog.findViewById(R.id.file_name_edittext);
- TextView fileExistsWarningTextView = saveDialog.findViewById(R.id.file_exists_warning_textview);
+ // Get the URI for the file according to the Android version.
+ if (Build.VERSION.SDK_INT >= 24) { // Use a file provider.
+ fileUri = FileProvider.getUriForFile(this, getString(R.string.file_provider), file);
+ } else { // Get the raw file path URI.
+ fileUri = Uri.fromFile(file);
+ }
- // Instantiate the file name helper.
- FileNameHelper fileNameHelper = new FileNameHelper();
+ // Get a handle for the content resolver.
+ ContentResolver contentResolver = getContentResolver();
- // Get the file name URI from the intent.
- Uri fileNameUri= data.getData();
+ // Create an open intent with `ACTION_VIEW`.
+ Intent openIntent = new Intent(Intent.ACTION_VIEW);
- // Process the file name URI if it is not null.
- if (fileNameUri != null) {
- // Convert the file name URI to a file name path.
- String fileNamePath = fileNameHelper.convertUriToFileNamePath(fileNameUri);
+ // Set the URI and the MIME type.
+ openIntent.setDataAndType(fileUri, contentResolver.getType(fileUri));
- // Set the file name path as the text of the file name edit text.
- fileNameEditText.setText(fileNamePath);
+ // Allow the app to read the file URI.
+ openIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- // Move the cursor to the end of the file name edit text.
- fileNameEditText.setSelection(fileNamePath.length());
+ // Show the chooser.
+ startActivity(Intent.createChooser(openIntent, getString(R.string.open)));
+ });
- // Hide the file exists warning.
- fileExistsWarningTextView.setVisibility(View.GONE);
- }
- }
+ // Show the logcat saved snackbar.
+ logcatSavedSnackbar.show();
+ } catch (Exception exception) {
+ // Display a snackbar with the error message.
+ Snackbar.make(logcatTextView, getString(R.string.error_saving_file) + " " + exception.toString(), Snackbar.LENGTH_INDEFINITE).show();
}
}
}
\ No newline at end of file
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
+import androidx.core.content.FileProvider;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import com.stoutner.privacybrowser.dialogs.OpenDialog;
import com.stoutner.privacybrowser.dialogs.ProxyNotInstalledDialog;
import com.stoutner.privacybrowser.dialogs.PinnedMismatchDialog;
-import com.stoutner.privacybrowser.dialogs.SaveDialog;
+import com.stoutner.privacybrowser.dialogs.SaveWebpageDialog;
import com.stoutner.privacybrowser.dialogs.SslCertificateErrorDialog;
import com.stoutner.privacybrowser.dialogs.StoragePermissionDialog;
import com.stoutner.privacybrowser.dialogs.UrlHistoryDialog;
public class MainWebViewActivity extends AppCompatActivity implements CreateBookmarkDialog.CreateBookmarkListener, CreateBookmarkFolderDialog.CreateBookmarkFolderListener,
EditBookmarkFolderDialog.EditBookmarkFolderListener, FontSizeDialog.UpdateFontSizeListener, NavigationView.OnNavigationItemSelectedListener, OpenDialog.OpenListener,
- PinnedMismatchDialog.PinnedMismatchListener, PopulateBlocklists.PopulateBlocklistsListener, SaveDialog.SaveWebpageListener, StoragePermissionDialog.StoragePermissionDialogListener,
+ PinnedMismatchDialog.PinnedMismatchListener, PopulateBlocklists.PopulateBlocklistsListener, SaveWebpageDialog.SaveWebpageListener, StoragePermissionDialog.StoragePermissionDialogListener,
UrlHistoryDialog.NavigateHistoryListener, WebViewTabFragment.NewTabListener {
// The executor service handles background tasks. It is accessed from `ViewSourceActivity`.
// It will be updated in `applyAppSettings()`, but it needs to be initialized here or the first run of `onPrepareOptionsMenu()` crashes.
public static String proxyMode = ProxyHelper.NONE;
-
- // The permission result request codes are used in `onCreateContextMenu()`, `onRequestPermissionResult()`, `onSaveWebpage()`, `onCloseStoragePermissionDialog()`, and `initializeWebView()`.
- private final int PERMISSION_OPEN_REQUEST_CODE = 0;
- private final int PERMISSION_SAVE_URL_REQUEST_CODE = 1;
- private final int PERMISSION_SAVE_AS_ARCHIVE_REQUEST_CODE = 2;
- private final int PERMISSION_SAVE_AS_IMAGE_REQUEST_CODE = 3;
-
// Define the saved instance state constants.
private final String SAVED_STATE_ARRAY_LIST = "saved_state_array_list";
private final String SAVED_NESTED_SCROLL_WEBVIEW_STATE_ARRAY_LIST = "saved_nested_scroll_webview_state_array_list";
}
@Override
- // Remove Android Studio's warning about the dangers of using SetJavaScriptEnabled.
+ // Remove Android Studio's warning about the dangers of enabling JavaScript. We know. Oh, how we know.
@SuppressLint("SetJavaScriptEnabled")
public boolean onOptionsItemSelected(MenuItem menuItem) {
// Get the selected menu item ID.
// Consume the event.
return true;
- case R.id.save_as_archive:
- // Prepare the save dialog. The dialog will be displayed once the file size and the content disposition have been acquired.
- new PrepareSaveDialog(this, this, getSupportFragmentManager(), StoragePermissionDialog.SAVE_AS_ARCHIVE, currentWebView.getSettings().getUserAgentString(),
- currentWebView.getAcceptFirstPartyCookies()).execute(currentWebView.getCurrentUrl());
+ case R.id.save_archive:
+ // Instantiate the save dialog.
+ DialogFragment saveArchiveFragment = SaveWebpageDialog.saveWebpage(StoragePermissionDialog.SAVE_ARCHIVE, null, null, getString(R.string.webpage_mht), null,
+ false);
+
+ // Show the save dialog. It must be named `save_dialog` so that the file picker can update the file name.
+ saveArchiveFragment.show(getSupportFragmentManager(), getString(R.string.save_dialog));
// Consume the event.
return true;
- case R.id.save_as_image:
- // Prepare the save dialog. The dialog will be displayed once the file size adn the content disposition have been acquired.
- new PrepareSaveDialog(this, this, getSupportFragmentManager(), StoragePermissionDialog.SAVE_AS_IMAGE, currentWebView.getSettings().getUserAgentString(),
- currentWebView.getAcceptFirstPartyCookies()).execute(currentWebView.getCurrentUrl());
+ case R.id.save_image:
+ // Instantiate the save dialog.
+ DialogFragment saveImageFragment = SaveWebpageDialog.saveWebpage(StoragePermissionDialog.SAVE_IMAGE, null, null, getString(R.string.webpage_png), null,
+ false);
+
+ // Show the save dialog. It must be named `save_dialog` so that the file picker can update the file name.
+ saveImageFragment.show(getSupportFragmentManager(), getString(R.string.save_dialog));
// Consume the event.
return true;
// Create the share intent.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
+
+ // Add the share string to the intent.
shareIntent.putExtra(Intent.EXTRA_TEXT, shareString);
+
+ // Set the MIME type.
shareIntent.setType("text/plain");
+ // Set the intent to open in a new task.
+ shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
// Make it so.
startActivity(Intent.createChooser(shareIntent, getString(R.string.share_url)));
// `FLAG_ACTIVITY_NEW_TASK` opens the email program in a new task instead as part of Privacy Browser.
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- // Make it so.
- startActivity(emailIntent);
+ try {
+ // Make it so.
+ startActivity(emailIntent);
+ } catch (ActivityNotFoundException exception) {
+ // Display a snackbar.
+ Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show();
+ }
// Consume the event.
return true;
storagePermissionDialogFragment.show(getSupportFragmentManager(), getString(R.string.storage_permission));
} else { // Show the permission request directly.
// Request the write external storage permission. The file will be opened when it finishes.
- ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_OPEN_REQUEST_CODE);
+ ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, StoragePermissionDialog.OPEN);
}
}
}
new SaveUrl(this, this, saveWebpageFilePath, currentWebView.getSettings().getUserAgentString(), currentWebView.getAcceptFirstPartyCookies()).execute(saveWebpageUrl);
break;
- case StoragePermissionDialog.SAVE_AS_ARCHIVE:
+ case StoragePermissionDialog.SAVE_ARCHIVE:
// Save the webpage archive.
- currentWebView.saveWebArchive(saveWebpageFilePath);
+ saveWebpageArchive();
break;
- case StoragePermissionDialog.SAVE_AS_IMAGE:
+ case StoragePermissionDialog.SAVE_IMAGE:
// Save the webpage image.
- new SaveWebpageImage(this, currentWebView).execute(saveWebpageFilePath);
+ new SaveWebpageImage(this, this, saveWebpageFilePath, currentWebView).execute();
break;
}
} else { // The storage permission has not been granted.
new SaveUrl(this, this, saveWebpageFilePath, currentWebView.getSettings().getUserAgentString(), currentWebView.getAcceptFirstPartyCookies()).execute(saveWebpageUrl);
break;
- case StoragePermissionDialog.SAVE_AS_ARCHIVE:
+ case StoragePermissionDialog.SAVE_ARCHIVE:
// Save the webpage archive.
- currentWebView.saveWebArchive(saveWebpageFilePath);
+ saveWebpageArchive();
break;
- case StoragePermissionDialog.SAVE_AS_IMAGE:
+ case StoragePermissionDialog.SAVE_IMAGE:
// Save the webpage image.
- new SaveWebpageImage(this, currentWebView).execute(saveWebpageFilePath);
+ new SaveWebpageImage(this, this, saveWebpageFilePath, currentWebView).execute();
break;
}
} else { // The file path is in a public directory.
// Show the storage permission alert dialog. The permission will be requested when the dialog is closed.
storagePermissionDialogFragment.show(getSupportFragmentManager(), getString(R.string.storage_permission));
} else { // Show the permission request directly.
- switch (saveType) {
- case StoragePermissionDialog.SAVE_URL:
- // Request the write external storage permission. The URL will be saved when it finishes.
- ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_SAVE_URL_REQUEST_CODE);
-
- case StoragePermissionDialog.SAVE_AS_ARCHIVE:
- // Request the write external storage permission. The webpage archive will be saved when it finishes.
- ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_SAVE_AS_ARCHIVE_REQUEST_CODE);
- break;
-
- case StoragePermissionDialog.SAVE_AS_IMAGE:
- // Request the write external storage permission. The webpage image will be saved when it finishes.
- ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_SAVE_AS_IMAGE_REQUEST_CODE);
- break;
- }
+ // Request the write external storage permission according to the save type. The URL will be saved when it finishes.
+ ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, saveType);
}
}
}
@Override
public void onCloseStoragePermissionDialog(int requestType) {
- switch (requestType) {
- case StoragePermissionDialog.OPEN:
- // Request the write external storage permission. The file will be opened when it finishes.
- ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_OPEN_REQUEST_CODE);
- break;
+ // Request the write external storage permission according to the request type. The file will be opened when it finishes.
+ ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, requestType);
- case StoragePermissionDialog.SAVE_URL:
- // Request the write external storage permission. The URL will be saved when it finishes.
- ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_SAVE_URL_REQUEST_CODE);
- break;
-
- case StoragePermissionDialog.SAVE_AS_ARCHIVE:
- // Request the write external storage permission. The webpage archive will be saved when it finishes.
- ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_SAVE_AS_ARCHIVE_REQUEST_CODE);
- break;
-
- case StoragePermissionDialog.SAVE_AS_IMAGE:
- // Request the write external storage permission. The webpage image will be saved when it finishes.
- ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_SAVE_AS_IMAGE_REQUEST_CODE);
- break;
- }
}
@Override
//Only process the results if they exist (this method is triggered when a dialog is presented the first time for an app, but no grant results are included).
if (grantResults.length > 0) {
switch (requestCode) {
- case PERMISSION_OPEN_REQUEST_CODE:
+ case StoragePermissionDialog.OPEN:
// Check to see if the storage permission was granted. If the dialog was canceled the grant results will be empty.
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // The storage permission was granted.
// Load the file.
openFilePath = "";
break;
- case PERMISSION_SAVE_URL_REQUEST_CODE:
+ case StoragePermissionDialog.SAVE_URL:
// Check to see if the storage permission was granted. If the dialog was canceled the grant results will be empty.
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // The storage permission was granted.
// Save the raw URL.
saveWebpageFilePath = "";
break;
- case PERMISSION_SAVE_AS_ARCHIVE_REQUEST_CODE:
+ case StoragePermissionDialog.SAVE_ARCHIVE:
// Check to see if the storage permission was granted. If the dialog was canceled the grant results will be empty.
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // The storage permission was granted.
// Save the webpage archive.
- currentWebView.saveWebArchive(saveWebpageFilePath);
+ saveWebpageArchive();
} else { // The storage permission was not granted.
// Display an error snackbar.
Snackbar.make(currentWebView, getString(R.string.cannot_use_location), Snackbar.LENGTH_LONG).show();
saveWebpageFilePath = "";
break;
- case PERMISSION_SAVE_AS_IMAGE_REQUEST_CODE:
+ case StoragePermissionDialog.SAVE_IMAGE:
// Check to see if the storage permission was granted. If the dialog was canceled the grant results will be empty.
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // The storage permission was granted.
// Save the webpage image.
- new SaveWebpageImage(this, currentWebView).execute(saveWebpageFilePath);
+ new SaveWebpageImage(this, this, saveWebpageFilePath, currentWebView).execute();
} else { // The storage permission was not granted.
// Display an error snackbar.
Snackbar.make(currentWebView, getString(R.string.cannot_use_location), Snackbar.LENGTH_LONG).show();
appBarLayout.setExpanded(true);
}
+ private void saveWebpageArchive() {
+ // Save the webpage archive.
+ currentWebView.saveWebArchive(saveWebpageFilePath);
+
+ // Display a snackbar.
+ Snackbar saveWebpageArchiveSnackbar = Snackbar.make(currentWebView, getString(R.string.file_saved) + " " + saveWebpageFilePath, Snackbar.LENGTH_SHORT);
+
+ // Add an open option to the snackbar.
+ saveWebpageArchiveSnackbar.setAction(R.string.open, (View view) -> {
+ // Get a file for the file name string.
+ File file = new File(saveWebpageFilePath);
+
+ // Declare a file URI variable.
+ Uri fileUri;
+
+ // Get the URI for the file according to the Android version.
+ if (Build.VERSION.SDK_INT >= 24) { // Use a file provider.
+ fileUri = FileProvider.getUriForFile(this, getString(R.string.file_provider), file);
+ } else { // Get the raw file path URI.
+ fileUri = Uri.fromFile(file);
+ }
+
+ // Get a handle for the content resolver.
+ ContentResolver contentResolver = getContentResolver();
+
+ // Create an open intent with `ACTION_VIEW`.
+ Intent openIntent = new Intent(Intent.ACTION_VIEW);
+
+ // Set the URI and the MIME type.
+ openIntent.setDataAndType(fileUri, contentResolver.getType(fileUri));
+
+ // Allow the app to read the file URI.
+ openIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+
+ // Show the chooser.
+ startActivity(Intent.createChooser(openIntent, getString(R.string.open)));
+ });
+
+ // Show the snackbar.
+ saveWebpageArchiveSnackbar.show();
+
+ // Reset the save Webpage file path.
+ saveWebpageFilePath = "";
+ }
+
private void clearAndExit() {
// Get a handle for the shared preferences.
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String fileNameString = PrepareSaveDialog.getFileNameFromContentDisposition(this, contentDisposition, downloadUrl);
// Instantiate the save dialog.
- DialogFragment saveDialogFragment = SaveDialog.saveUrl(StoragePermissionDialog.SAVE_URL, downloadUrl, formattedFileSizeString, fileNameString, userAgent,
+ DialogFragment saveDialogFragment = SaveWebpageDialog.saveWebpage(StoragePermissionDialog.SAVE_URL, downloadUrl, formattedFileSizeString, fileNameString, userAgent,
nestedScrollWebView.getAcceptFirstPartyCookies());
// Show the save dialog. It must be named `save_dialog` so that the file picker can update the file name.
// Open the email program in a new task instead of as part of Privacy Browser.
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- // Make it so.
- startActivity(emailIntent);
+ try {
+ // Make it so.
+ startActivity(emailIntent);
+ } catch (ActivityNotFoundException exception) {
+ // Display a snackbar.
+ Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show();
+ }
+
// Returning true indicates Privacy Browser is handling the URL by creating an intent.
return true;
// Open the dialer in a new task instead of as part of Privacy Browser.
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- // Make it so.
- startActivity(dialIntent);
+ try {
+ // Make it so.
+ startActivity(dialIntent);
+ } catch (ActivityNotFoundException exception) {
+ // Display a snackbar.
+ Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show();
+ }
// Returning true indicates Privacy Browser is handling the URL by creating an intent.
return true;
import androidx.fragment.app.FragmentPagerAdapter;
import com.stoutner.privacybrowser.R;
-import com.stoutner.privacybrowser.fragments.AboutTabFragment;
+import com.stoutner.privacybrowser.fragments.AboutVersionFragment;
+import com.stoutner.privacybrowser.fragments.AboutWebViewFragment;
+
+import java.util.LinkedList;
public class AboutPagerAdapter extends FragmentPagerAdapter {
// Define the class variables.
private Context context;
private String[] blocklistVersions;
+ private LinkedList<Fragment> aboutFragmentList = new LinkedList<>();
public AboutPagerAdapter(FragmentManager fragmentManager, Context context, String[] blocklistVersions) {
// Run the default commands.
@NonNull
// Setup each tab.
public Fragment getItem(int tabNumber) {
- return AboutTabFragment.createTab(tabNumber, blocklistVersions);
+ // Create the tab fragment and add it to the list.
+ if (tabNumber == 0){
+ // Add the version tab to the list.
+ aboutFragmentList.add(AboutVersionFragment.createTab(blocklistVersions));
+ } else {
+ // Add the WebView tab to the list.
+ aboutFragmentList.add(AboutWebViewFragment.createTab(tabNumber));
+ }
+
+ // Return the tab number fragment.
+ return aboutFragmentList.get(tabNumber);
+ }
+
+ public Fragment getTabFragment(int tabNumber) {
+ // Return the tab fragment.
+ return aboutFragmentList.get(tabNumber);
}
}
\ No newline at end of file
}
public WebViewTabFragment getPageFragment(int pageNumber) {
+ // Return the page fragment.
return webViewFragmentsList.get(pageNumber);
}
}
\ No newline at end of file
import androidx.fragment.app.FragmentManager;
import com.stoutner.privacybrowser.R;
-import com.stoutner.privacybrowser.dialogs.SaveDialog;
+import com.stoutner.privacybrowser.dialogs.SaveWebpageDialog;
import com.stoutner.privacybrowser.helpers.ProxyHelper;
import java.lang.ref.WeakReference;
}
// Instantiate the save dialog.
- DialogFragment saveDialogFragment = SaveDialog.saveUrl(saveType, urlString, fileStringArray[0], fileStringArray[1], userAgent, cookiesEnabled);
+ DialogFragment saveDialogFragment = SaveWebpageDialog.saveWebpage(saveType, urlString, fileStringArray[0], fileStringArray[1], userAgent, cookiesEnabled);
// Show the save dialog. It must be named `save_dialog` so that the file picker can update the file name.
saveDialogFragment.show(fragmentManager, activity.getString(R.string.save_dialog));
--- /dev/null
+/*
+ * Copyright © 2020 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.asynctasks;
+
+import android.app.Activity;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import androidx.core.content.FileProvider;
+
+import com.google.android.material.snackbar.Snackbar;
+
+import com.stoutner.privacybrowser.R;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.lang.ref.WeakReference;
+
+public class SaveAboutVersionImage extends AsyncTask<Void, Void, String> {
+ // Declare the weak references.
+ private WeakReference<Context> contextWeakReference;
+ private WeakReference<Activity> activityWeakReference;
+ private WeakReference<LinearLayout> aboutVersionLinearLayoutWeakReference;
+
+ // Declare the class constants.
+ private final String SUCCESS = "Success";
+
+ // Declare the class variables.
+ private Snackbar savingImageSnackbar;
+ private Bitmap aboutVersionBitmap;
+ private String filePathString;
+
+ // The public constructor.
+ public SaveAboutVersionImage(Context context, Activity activity, String filePathString, LinearLayout aboutVersionLinearLayout) {
+ // Populate the weak references.
+ contextWeakReference = new WeakReference<>(context);
+ activityWeakReference = new WeakReference<>(activity);
+ aboutVersionLinearLayoutWeakReference = new WeakReference<>(aboutVersionLinearLayout);
+
+ // Store the class variables.
+ this.filePathString = filePathString;
+ }
+
+ // `onPreExecute()` operates on the UI thread.
+ @Override
+ protected void onPreExecute() {
+ // Get handles for the activity and the linear layout.
+ Activity activity = activityWeakReference.get();
+ LinearLayout aboutVersionLinearLayout = aboutVersionLinearLayoutWeakReference.get();
+
+ // Abort if the activity or the linear layout is gone.
+ if ((activity == null) || activity.isFinishing() || aboutVersionLinearLayout == null) {
+ return;
+ }
+
+ // Create a saving image snackbar.
+ savingImageSnackbar = Snackbar.make(aboutVersionLinearLayout, activity.getString(R.string.processing_image) + " " + filePathString, Snackbar.LENGTH_INDEFINITE);
+
+ // Display the saving image snackbar.
+ savingImageSnackbar.show();
+
+ // Create the about version bitmap. This can be replaced by PixelCopy once the minimum API >= 26.
+ // Once the Minimum API >= 26 Bitmap.Config.RBGA_F16 can be used instead of ARGB_8888. The linear layout commands must be run on the UI thread.
+ aboutVersionBitmap = Bitmap.createBitmap(aboutVersionLinearLayout.getWidth(), aboutVersionLinearLayout.getHeight(), Bitmap.Config.ARGB_8888);
+
+ // Create a canvas.
+ Canvas aboutVersionCanvas = new Canvas(aboutVersionBitmap);
+
+ // Draw the current about version onto the bitmap. The linear layout commands must be run on the UI thread.
+ aboutVersionLinearLayout.draw(aboutVersionCanvas);
+ }
+
+ @Override
+ protected String doInBackground(Void... Void) {
+ // Get a handle for the activity.
+ Activity activity = activityWeakReference.get();
+
+ // Abort if the activity is gone.
+ if (((activity == null) || activity.isFinishing())) {
+ return "";
+ }
+
+ // Create an about version PNG byte array output stream.
+ ByteArrayOutputStream aboutVersionByteArrayOutputStream = new ByteArrayOutputStream();
+
+ // Convert the bitmap to a PNG. `0` is for lossless compression (the only option for a PNG). This compression takes a long time. Once the minimum API >= 30 this could be replaced with WEBP_LOSSLESS.
+ aboutVersionBitmap.compress(Bitmap.CompressFormat.PNG, 0, aboutVersionByteArrayOutputStream);
+
+ // Get a file for the image.
+ File imageFile = new File(filePathString);
+
+ // Delete the current file if it exists.
+ if (imageFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ imageFile.delete();
+ }
+
+ // Create a file creation disposition string.
+ String fileCreationDisposition = SUCCESS;
+
+ try {
+ // Create an image file output stream.
+ FileOutputStream imageFileOutputStream = new FileOutputStream(imageFile);
+
+ // Write the webpage image to the image file.
+ aboutVersionByteArrayOutputStream.writeTo(imageFileOutputStream);
+
+ // Create a media scanner intent, which adds items like pictures to Android's recent file list.
+ Intent mediaScannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+
+ // Add the URI to the media scanner intent.
+ mediaScannerIntent.setData(Uri.fromFile(imageFile));
+
+ // Make it so.
+ activity.sendBroadcast(mediaScannerIntent);
+ } catch (Exception exception) {
+ // Store the error in the file creation disposition string.
+ fileCreationDisposition = exception.toString();
+ }
+
+ // return the file creation disposition string.
+ return fileCreationDisposition;
+ }
+
+ // `onPostExecute()` operates on the UI thread.
+ @Override
+ protected void onPostExecute(String fileCreationDisposition) {
+ // Get handles for the weak references.
+ Context context = contextWeakReference.get();
+ Activity activity = activityWeakReference.get();
+ LinearLayout aboutVersionLinearLayout = aboutVersionLinearLayoutWeakReference.get();
+
+ // Abort if the activity is gone.
+ if ((activity == null) || activity.isFinishing()) {
+ return;
+ }
+
+ // Dismiss the saving image snackbar.
+ savingImageSnackbar.dismiss();
+
+ // Display a file creation disposition snackbar.
+ if (fileCreationDisposition.equals(SUCCESS)) {
+ // Create a file saved snackbar.
+ Snackbar imageSavedSnackbar = Snackbar.make(aboutVersionLinearLayout, activity.getString(R.string.file_saved) + " " + filePathString, Snackbar.LENGTH_SHORT);
+
+ // Add an open action.
+ imageSavedSnackbar.setAction(R.string.open, (View view) -> {
+ // Get a file for the file path string.
+ File file = new File(filePathString);
+
+ // Declare a file URI variable.
+ Uri fileUri;
+
+ // Get the URI for the file according to the Android version.
+ if (Build.VERSION.SDK_INT >= 24) { // Use a file provider.
+ fileUri = FileProvider.getUriForFile(context, activity.getString(R.string.file_provider), file);
+ } else { // Get the raw file path URI.
+ fileUri = Uri.fromFile(file);
+ }
+
+ // Get a handle for the content resolver.
+ ContentResolver contentResolver = context.getContentResolver();
+
+ // Create an open intent with `ACTION_VIEW`.
+ Intent openIntent = new Intent(Intent.ACTION_VIEW);
+
+ // Autodetect the MIME type.
+ openIntent.setDataAndType(fileUri, contentResolver.getType(fileUri));
+
+ // Allow the app to read the file URI.
+ openIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+
+ // Show the chooser.
+ activity.startActivity(Intent.createChooser(openIntent, context.getString(R.string.open)));
+ });
+
+ // Show the image saved snackbar.
+ imageSavedSnackbar.show();
+ } else {
+ Snackbar.make(aboutVersionLinearLayout, activity.getString(R.string.error_saving_file) + " " + fileCreationDisposition, Snackbar.LENGTH_INDEFINITE).show();
+ }
+ }
+}
\ No newline at end of file
package com.stoutner.privacybrowser.asynctasks;
import android.app.Activity;
-import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import java.text.NumberFormat;
public class SaveUrl extends AsyncTask<String, Long, String> {
- // Define a weak references for the calling context and activity.
+ // Define a weak references.
private WeakReference<Context> contextWeakReference;
private WeakReference<Activity> activityWeakReference;
// Check to see if a download percentage has been calculated.
if (downloadPercentage[0] < 0) { // There is no download percentage. The negative number represents the raw downloaded kilobytes.
// Calculate the number of bytes downloaded. When the `downloadPercentage` is negative, it is actually the raw number of kilobytes downloaded.
- long numberOfBytesDownloaded = 0 - downloadPercentage[0];
+ long numberOfBytesDownloaded = - downloadPercentage[0];
// Format the number of bytes downloaded.
String formattedNumberOfBytesDownloaded = NumberFormat.getInstance().format(numberOfBytesDownloaded);
// Add an open action if the file is not an APK on API >= 26 (that scenario requires the REQUEST_INSTALL_PACKAGES permission).
if (!(Build.VERSION.SDK_INT >= 26 && filePathString.endsWith(".apk"))) {
- fileSavedSnackbar.setAction(R.string.open, (View v) -> {
+ fileSavedSnackbar.setAction(R.string.open, (View view) -> {
// Get a file for the file path string.
File file = new File(filePathString);
- // Define a file URI variable
+ // Declare a file URI variable.
Uri fileUri;
// Get the URI for the file according to the Android version.
// Allow the app to read the file URI.
openIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- // Try the intent.
- try {
- // Show the chooser.
- activity.startActivity(openIntent);
- } catch (ActivityNotFoundException exception) { // There are no apps available to open the URL.
- // Show a snackbar with the error.
- Snackbar.make(noSwipeViewPager, activity.getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show();
- }
+ // Show the chooser.
+ activity.startActivity(Intent.createChooser(openIntent, context.getString(R.string.open)));
});
}
/*
- * Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
package com.stoutner.privacybrowser.asynctasks;
import android.app.Activity;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.net.Uri;
import android.os.AsyncTask;
+import android.os.Build;
+import android.view.View;
+
+import androidx.core.content.FileProvider;
import com.google.android.material.snackbar.Snackbar;
import com.stoutner.privacybrowser.R;
import com.stoutner.privacybrowser.views.NestedScrollWebView;
-import com.stoutner.privacybrowser.views.NoSwipeViewPager;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.ref.WeakReference;
-public class SaveWebpageImage extends AsyncTask<String, Void, String> {
- // Define the weak references.
+public class SaveWebpageImage extends AsyncTask<Void, Void, String> {
+ // Declare the weak references.
+ private WeakReference<Context> contextWeakReference;
private WeakReference<Activity> activityWeakReference;
private WeakReference<NestedScrollWebView> nestedScrollWebViewWeakReference;
- // Define a success string constant.
+ // Declare the class constants.
private final String SUCCESS = "Success";
- // Define the saving image snackbar and the webpage bitmap.
+ // Declare the class variables.
private Snackbar savingImageSnackbar;
private Bitmap webpageBitmap;
+ private String filePathString;
// The public constructor.
- public SaveWebpageImage(Activity activity, NestedScrollWebView nestedScrollWebView) {
+ public SaveWebpageImage(Context context, Activity activity, String filePathString, NestedScrollWebView nestedScrollWebView) {
// Populate the weak references.
+ contextWeakReference = new WeakReference<>(context);
activityWeakReference = new WeakReference<>(activity);
nestedScrollWebViewWeakReference = new WeakReference<>(nestedScrollWebView);
+
+ // Populate the class variables.
+ this.filePathString = filePathString;
}
// `onPreExecute()` operates on the UI thread.
@Override
protected void onPreExecute() {
- // Get a handle for the activity and the nested scroll WebView.
+ // Get handles for the activity and the nested scroll WebView.
Activity activity = activityWeakReference.get();
NestedScrollWebView nestedScrollWebView = nestedScrollWebViewWeakReference.get();
}
// Create a saving image snackbar.
- savingImageSnackbar = Snackbar.make(nestedScrollWebView, R.string.saving_image, Snackbar.LENGTH_INDEFINITE);
+ savingImageSnackbar = Snackbar.make(nestedScrollWebView, activity.getString(R.string.processing_image) + " " + filePathString, Snackbar.LENGTH_INDEFINITE);
// Display the saving image snackbar.
savingImageSnackbar.show();
}
@Override
- protected String doInBackground(String... fileName) {
+ protected String doInBackground(Void... Void) {
// Get a handle for the activity.
Activity activity = activityWeakReference.get();
// Create a webpage PNG byte array output stream.
ByteArrayOutputStream webpageByteArrayOutputStream = new ByteArrayOutputStream();
- // Convert the bitmap to a PNG. `0` is for lossless compression (the only option for a PNG). This compression takes a long time.
+ // Convert the bitmap to a PNG. `0` is for lossless compression (the only option for a PNG). This compression takes a long time. Once the minimum API >= 30 this could be replaced with WEBP_LOSSLESS.
webpageBitmap.compress(Bitmap.CompressFormat.PNG, 0, webpageByteArrayOutputStream);
// Get a file for the image.
- File imageFile = new File(fileName[0]);
+ File imageFile = new File(filePathString);
// Delete the current file if it exists.
if (imageFile.exists()) {
// Write the webpage image to the image file.
webpageByteArrayOutputStream.writeTo(imageFileOutputStream);
+
+ // Create a media scanner intent, which adds items like pictures to Android's recent file list.
+ Intent mediaScannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+
+ // Add the URI to the media scanner intent.
+ mediaScannerIntent.setData(Uri.fromFile(imageFile));
+
+ // Make it so.
+ activity.sendBroadcast(mediaScannerIntent);
} catch (Exception exception) {
// Store the error in the file creation disposition string.
fileCreationDisposition = exception.toString();
// `onPostExecute()` operates on the UI thread.
@Override
protected void onPostExecute(String fileCreationDisposition) {
- // Get a handle for the activity.
+ // Get handles for the weak references.
+ Context context = contextWeakReference.get();
Activity activity = activityWeakReference.get();
+ NestedScrollWebView nestedScrollWebView = nestedScrollWebViewWeakReference.get();
// Abort if the activity is gone.
if ((activity == null) || activity.isFinishing()) {
return;
}
- // Get a handle for the no swipe view pager.
- NoSwipeViewPager noSwipeViewPager = activity.findViewById(R.id.webviewpager);
-
// Dismiss the saving image snackbar.
savingImageSnackbar.dismiss();
// Display a file creation disposition snackbar.
if (fileCreationDisposition.equals(SUCCESS)) {
- Snackbar.make(noSwipeViewPager, R.string.image_saved, Snackbar.LENGTH_SHORT).show();
+ // Create a file saved snackbar.
+ Snackbar imageSavedSnackbar = Snackbar.make(nestedScrollWebView, activity.getString(R.string.file_saved) + " " + filePathString, Snackbar.LENGTH_SHORT);
+
+ // Add an open action.
+ imageSavedSnackbar.setAction(R.string.open, (View view) -> {
+ // Get a file for the file path string.
+ File file = new File(filePathString);
+
+ // Declare a file URI variable.
+ Uri fileUri;
+
+ // Get the URI for the file according to the Android version.
+ if (Build.VERSION.SDK_INT >= 24) { // Use a file provider.
+ fileUri = FileProvider.getUriForFile(context, activity.getString(R.string.file_provider), file);
+ } else { // Get the raw file path URI.
+ fileUri = Uri.fromFile(file);
+ }
+
+ // Get a handle for the content resolver.
+ ContentResolver contentResolver = context.getContentResolver();
+
+ // Create an open intent with `ACTION_VIEW`.
+ Intent openIntent = new Intent(Intent.ACTION_VIEW);
+
+ // Autodetect the MIME type.
+ openIntent.setDataAndType(fileUri, contentResolver.getType(fileUri));
+
+ // Allow the app to read the file URI.
+ openIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+
+ // Show the chooser.
+ activity.startActivity(Intent.createChooser(openIntent, context.getString(R.string.open)));
+ });
+
+ // Show the image saved snackbar.
+ imageSavedSnackbar.show();
} else {
- Snackbar.make(noSwipeViewPager, activity.getString(R.string.error_saving_image) + " " + fileCreationDisposition, Snackbar.LENGTH_INDEFINITE).show();
+ // Display the file saving error.
+ Snackbar.make(nestedScrollWebView, activity.getString(R.string.error_saving_file) + " " + fileCreationDisposition, Snackbar.LENGTH_INDEFINITE).show();
}
}
}
\ No newline at end of file
/*
- * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
+import android.preference.PreferenceManager;
import android.provider.DocumentsContract;
import android.text.Editable;
import android.text.TextWatcher;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
-import androidx.preference.PreferenceManager;
import com.stoutner.privacybrowser.R;
-import com.stoutner.privacybrowser.activities.MainWebViewActivity;
-import com.stoutner.privacybrowser.asynctasks.GetUrlSize;
import com.stoutner.privacybrowser.helpers.DownloadLocationHelper;
import java.io.File;
public class SaveDialog extends DialogFragment {
- // Define the save webpage listener.
- private SaveWebpageListener saveWebpageListener;
+ // Declare the save listener.
+ private SaveListener saveListener;
// The public interface is used to send information back to the parent activity.
- public interface SaveWebpageListener {
- void onSaveWebpage(int saveType, DialogFragment dialogFragment);
+ public interface SaveListener {
+ void onSave(int saveType, DialogFragment dialogFragment);
}
- // Define the get URL size AsyncTask. This allows previous instances of the task to be cancelled if a new one is run.
- private AsyncTask getUrlSize;
+ // Declare the class constants.
+ public static final int SAVE_LOGCAT = 0;
+ public static final int SAVE_ABOUT_VERSION_TEXT = 1;
+ public static final int SAVE_ABOUT_VERSION_IMAGE = 2;
+ private static final String SAVE_TYPE = "save_type";
+
+ // Declare the class variables.
+ String fileName;
@Override
public void onAttach(@NonNull Context context) {
// Run the default commands.
super.onAttach(context);
- // Get a handle for the save webpage listener from the launching context.
- saveWebpageListener = (SaveWebpageListener) context;
+ // Get a handle for save listener from the launching context.
+ saveListener = (SaveListener) context;
}
- public static SaveDialog saveUrl(int saveType, String urlString, String fileSizeString, String contentDispositionFileNameString, String userAgentString, boolean cookiesEnabled) {
+ public static SaveDialog save(int saveType) {
// Create an arguments bundle.
Bundle argumentsBundle = new Bundle();
// Store the arguments in the bundle.
- argumentsBundle.putInt("save_type", saveType);
- argumentsBundle.putString("url_string", urlString);
- argumentsBundle.putString("file_size_string", fileSizeString);
- argumentsBundle.putString("content_disposition_file_name_string", contentDispositionFileNameString);
- argumentsBundle.putString("user_agent_string", userAgentString);
- argumentsBundle.putBoolean("cookies_enabled", cookiesEnabled);
+ argumentsBundle.putInt(SAVE_TYPE, saveType);
- // Create a new instance of the save webpage dialog.
- SaveDialog saveWebpageDialog = new SaveDialog();
+ // Create a new instance of the save dialog.
+ SaveDialog saveDialog = new SaveDialog();
- // Add the arguments bundle to the new dialog.
- saveWebpageDialog.setArguments(argumentsBundle);
+ // Add the arguments bundle to the dialog.
+ saveDialog.setArguments(argumentsBundle);
// Return the new dialog.
- return saveWebpageDialog;
+ return saveDialog;
}
// `@SuppressLint("InflateParams")` removes the warning about using null as the parent view group when inflating the alert dialog.
assert arguments != null;
// Get the arguments from the bundle.
- int saveType = arguments.getInt("save_type");
- String urlString = arguments.getString("url_string");
- String fileSizeString = arguments.getString("file_size_string");
- String contentDispositionFileNameString = arguments.getString("content_disposition_file_name_string");
- String userAgentString = arguments.getString("user_agent_string");
- boolean cookiesEnabled = arguments.getBoolean("cookies_enabled");
+ int saveType = arguments.getInt(SAVE_TYPE);
// Get a handle for the activity and the context.
Activity activity = requireActivity();
// Get the current theme status.
int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // The night theme is enabled.
- // Set the icon according to the save type.
- switch (saveType) {
- case StoragePermissionDialog.SAVE_URL:
- dialogBuilder.setIcon(R.drawable.copy_enabled_night);
- break;
-
- case StoragePermissionDialog.SAVE_AS_ARCHIVE:
- dialogBuilder.setIcon(R.drawable.dom_storage_cleared_night);
- break;
-
- case StoragePermissionDialog.SAVE_AS_IMAGE:
- dialogBuilder.setIcon(R.drawable.images_enabled_night);
- break;
- }
- } else { // The day theme is enabled.
- // Set the icon according to the save type.
- switch (saveType) {
- case StoragePermissionDialog.SAVE_URL:
- dialogBuilder.setIcon(R.drawable.copy_enabled_day);
- break;
-
- case StoragePermissionDialog.SAVE_AS_ARCHIVE:
- dialogBuilder.setIcon(R.drawable.dom_storage_cleared_day);
- break;
-
- case StoragePermissionDialog.SAVE_AS_IMAGE:
- dialogBuilder.setIcon(R.drawable.images_enabled_day);
- break;
- }
- }
-
- // Set the title according to the type.
+ // Set the title and icon according to the type.
switch (saveType) {
- case StoragePermissionDialog.SAVE_URL:
- dialogBuilder.setTitle(R.string.save);
+ case SAVE_LOGCAT:
+ // Set the title.
+ dialogBuilder.setTitle(R.string.save_logcat);
+
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ dialogBuilder.setIcon(R.drawable.save_dialog_day);
+ } else {
+ dialogBuilder.setIcon(R.drawable.save_dialog_night);
+ }
break;
- case StoragePermissionDialog.SAVE_AS_ARCHIVE:
- dialogBuilder.setTitle(R.string.save_archive);
+ case SAVE_ABOUT_VERSION_TEXT:
+ // Set the title.
+ dialogBuilder.setTitle(R.string.save_text);
+
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ dialogBuilder.setIcon(R.drawable.save_text_blue_day);
+ } else {
+ dialogBuilder.setIcon(R.drawable.save_text_blue_night);
+ }
break;
- case StoragePermissionDialog.SAVE_AS_IMAGE:
+ case SAVE_ABOUT_VERSION_IMAGE:
+ // Set the title.
dialogBuilder.setTitle(R.string.save_image);
+
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ dialogBuilder.setIcon(R.drawable.images_enabled_day);
+ } else {
+ dialogBuilder.setIcon(R.drawable.images_enabled_night);
+ }
break;
}
// Set the save button listener.
dialogBuilder.setPositiveButton(R.string.save, (DialogInterface dialog, int which) -> {
// Return the dialog fragment to the parent activity.
- saveWebpageListener.onSaveWebpage(saveType, this);
+ saveListener.onSave(saveType, this);
});
// Create an alert dialog from the builder.
AlertDialog alertDialog = dialogBuilder.create();
- // Remove the incorrect lint warning below that the window might be null.
+ // Remove the incorrect lint warning below that `getWindow()` might be null.
assert alertDialog.getWindow() != null;
// Get a handle for the shared preferences.
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
// Get the screenshot preference.
- boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+ boolean allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false);
// Disable screenshots if not allowed.
if (!allowScreenshots) {
alertDialog.show();
// Get handles for the layout items.
- EditText urlEditText = alertDialog.findViewById(R.id.url_edittext);
EditText fileNameEditText = alertDialog.findViewById(R.id.file_name_edittext);
Button browseButton = alertDialog.findViewById(R.id.browse_button);
- TextView fileSizeTextView = alertDialog.findViewById(R.id.file_size_textview);
TextView fileExistsWarningTextView = alertDialog.findViewById(R.id.file_exists_warning_textview);
TextView storagePermissionTextView = alertDialog.findViewById(R.id.storage_permission_textview);
Button saveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
- // Remove the incorrect warnings that the views might be null.
- assert urlEditText != null;
+ // Remove the incorrect lint warnings below that the views might be null.
assert fileNameEditText != null;
assert browseButton != null;
- assert fileSizeTextView != null;
assert fileExistsWarningTextView != null;
assert storagePermissionTextView != null;
- // Set the file size text view.
- fileSizeTextView.setText(fileSizeString);
-
- // Modify the layout based on the save type.
- if (saveType == StoragePermissionDialog.SAVE_URL) { // A URL is being saved.
- // Populate the URL edit text. This must be done before the text change listener is created below so that the file size isn't requested again.
- urlEditText.setText(urlString);
-
- // Update the file size and the status of the save button when the URL changes.
- urlEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- // Do nothing.
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- // Do nothing.
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
- // Cancel the get URL size AsyncTask if it is running.
- if ((getUrlSize != null)) {
- getUrlSize.cancel(true);
- }
-
- // Get the current URL to save.
- String urlToSave = urlEditText.getText().toString();
-
- // Wipe the file size text view.
- fileSizeTextView.setText("");
-
- // Get the file size for the current URL.
- getUrlSize = new GetUrlSize(context, alertDialog, userAgentString, cookiesEnabled).execute(urlToSave);
-
- // Enable the save button if the URL and file name are populated.
- saveButton.setEnabled(!urlToSave.isEmpty() && !fileNameEditText.getText().toString().isEmpty());
- }
- });
- } else { // An archive or an image is being saved.
- // Hide the URL edit text and the file size text view.
- urlEditText.setVisibility(View.GONE);
- fileSizeTextView.setVisibility(View.GONE);
- }
-
// Update the status of the save button when the file name changes.
fileNameEditText.addTextChangedListener(new TextWatcher() {
@Override
fileExistsWarningTextView.setVisibility(View.GONE);
}
- // Enable the save button based on the save type.
- if (saveType == StoragePermissionDialog.SAVE_URL) { // A URL is being saved.
- // Enable the save button if the file name and the URL is populated.
- saveButton.setEnabled(!fileNameString.isEmpty() && !urlEditText.getText().toString().isEmpty());
- } else { // An archive or an image is being saved.
- // Enable the save button if the file name is populated.
- saveButton.setEnabled(!fileNameString.isEmpty());
- }
+ // Enable the save button if the file name is populated.
+ saveButton.setEnabled(!fileNameString.isEmpty());
}
});
- // Create a file name string.
- String fileName = "";
-
// Set the file name according to the type.
switch (saveType) {
- case StoragePermissionDialog.SAVE_URL:
- // Use the file name from the content disposition.
- fileName = contentDispositionFileNameString;
+ case SAVE_LOGCAT:
+ // Use a file name ending in `.txt`.
+ fileName = getString(R.string.privacy_browser_logcat_txt);
break;
- case StoragePermissionDialog.SAVE_AS_ARCHIVE:
- // Use an archive name ending in `.mht`.
- fileName = getString(R.string.webpage_mht);
+ case SAVE_ABOUT_VERSION_TEXT:
+ // Use a file name ending in `.txt`.
+ fileName = getString(R.string.privacy_browser_version_txt);
break;
- case StoragePermissionDialog.SAVE_AS_IMAGE:
+ case SAVE_ABOUT_VERSION_IMAGE:
// Use a file name ending in `.png`.
- fileName = getString(R.string.webpage_png);
+ fileName = getString(R.string.privacy_browser_version_png);
break;
}
- // Save the file name as the default file name. This must be final to be used in the lambda below.
- final String defaultFileName = fileName;
-
// Instantiate the download location helper.
DownloadLocationHelper downloadLocationHelper = new DownloadLocationHelper();
// Get the default file path.
- String defaultFilePath = downloadLocationHelper.getDownloadLocation(context) + "/" + defaultFileName;
+ String defaultFilePath = downloadLocationHelper.getDownloadLocation(context) + "/" + fileName;
- // Populate the file name edit text.
+ // Display the default file path.
fileNameEditText.setText(defaultFilePath);
- // Move the cursor to the end of the default file path.
- fileNameEditText.setSelection(defaultFilePath.length());
+ // Hide the storage permission text view if the permission has already been granted.
+ if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ storagePermissionTextView.setVisibility(View.GONE);
+ }
// Handle clicks on the browse button.
browseButton.setOnClickListener((View view) -> {
// Set the intent MIME type to include all files so that everything is visible.
browseIntent.setType("*/*");
- // Set the initial file name according to the type.
- browseIntent.putExtra(Intent.EXTRA_TITLE, defaultFileName);
+ // Set the initial file name.
+ browseIntent.putExtra(Intent.EXTRA_TITLE, fileName);
// Set the initial directory if the minimum API >= 26.
if (Build.VERSION.SDK_INT >= 26) {
// Request a file that can be opened.
browseIntent.addCategory(Intent.CATEGORY_OPENABLE);
- // Start the file picker. This must be started under `activity` so that the request code is returned correctly.
- activity.startActivityForResult(browseIntent, MainWebViewActivity.BROWSE_SAVE_WEBPAGE_REQUEST_CODE);
+ // Launch the file picker. There is only one `startActivityForResult()`, so the request code is simply set to 0, but it must be run under `activity` so the request code is correct.
+ activity.startActivityForResult(browseIntent, 0);
});
- // Hide the storage permission text view if the permission has already been granted.
- if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
- storagePermissionTextView.setVisibility(View.GONE);
- }
-
// Return the alert dialog.
return alertDialog;
}
+++ /dev/null
-/*
- * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
- *
- * Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.stoutner.privacybrowser.dialogs;
-
-import android.Manifest;
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.app.Dialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.content.res.Configuration;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Environment;
-import android.preference.PreferenceManager;
-import android.provider.DocumentsContract;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AlertDialog;
-import androidx.core.content.ContextCompat;
-import androidx.fragment.app.DialogFragment;
-
-import com.stoutner.privacybrowser.R;
-import com.stoutner.privacybrowser.helpers.DownloadLocationHelper;
-
-import java.io.File;
-
-public class SaveLogcatDialog extends DialogFragment {
- // Define the save logcat listener.
- private SaveLogcatListener saveLogcatListener;
-
- // The public interface is used to send information back to the parent activity.
- public interface SaveLogcatListener {
- void onSaveLogcat(DialogFragment dialogFragment);
- }
-
- @Override
- public void onAttach(@NonNull Context context) {
- // Run the default commands.
- super.onAttach(context);
-
- // Get a handle for save logcat listener from the launching context.
- saveLogcatListener = (SaveLogcatListener) context;
- }
-
- // `@SuppressLint("InflateParams")` removes the warning about using null as the parent view group when inflating the alert dialog.
- @SuppressLint("InflateParams")
- @Override
- @NonNull
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- // Get a handle for the activity and the context.
- Activity activity = requireActivity();
- Context context = requireContext();
-
- // Use an alert dialog builder to create the alert dialog.
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialog);
- // Set the title.
- dialogBuilder.setTitle(R.string.save_logcat);
-
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- dialogBuilder.setIcon(R.drawable.save_dialog_night);
- } else {
- dialogBuilder.setIcon(R.drawable.save_dialog_day);
- }
-
- // Set the view. The parent view is null because it will be assigned by the alert dialog.
- dialogBuilder.setView(activity.getLayoutInflater().inflate(R.layout.save_logcat_dialog, null));
-
- // Set the cancel button listener.
- dialogBuilder.setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> {
- // Do nothing. The alert dialog will close automatically.
- });
-
- // Set the save button listener.
- dialogBuilder.setPositiveButton(R.string.save, (DialogInterface dialog, int which) -> {
- // Return the dialog fragment to the parent activity.
- saveLogcatListener.onSaveLogcat(this);
- });
-
- // Create an alert dialog from the builder.
- AlertDialog alertDialog = dialogBuilder.create();
-
- // Remove the incorrect lint warning below that `getWindow()` might be null.
- assert alertDialog.getWindow() != null;
-
- // Get a handle for the shared preferences.
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
- // Get the screenshot preference.
- boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
- // Disable screenshots if not allowed.
- if (!allowScreenshots) {
- alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
- }
-
- // The alert dialog must be shown before items in the layout can be modified.
- alertDialog.show();
-
- // Get handles for the layout items.
- EditText fileNameEditText = alertDialog.findViewById(R.id.file_name_edittext);
- Button browseButton = alertDialog.findViewById(R.id.browse_button);
- TextView fileExistsWarningTextView = alertDialog.findViewById(R.id.file_exists_warning_textview);
- TextView storagePermissionTextView = alertDialog.findViewById(R.id.storage_permission_textview);
- Button saveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
-
- // Remove the incorrect lint warnings below that the views might be null.
- assert fileNameEditText != null;
- assert browseButton != null;
- assert fileExistsWarningTextView != null;
- assert storagePermissionTextView != null;
-
- // Update the status of the save button when the file name changes.
- fileNameEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- // Do nothing.
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- // Do nothing.
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- // Get the current file name.
- String fileNameString = fileNameEditText.getText().toString();
-
- // Convert the file name string to a file.
- File file = new File(fileNameString);
-
- // Check to see if the file exists.
- if (file.exists()) {
- // Show the file exists warning.
- fileExistsWarningTextView.setVisibility(View.VISIBLE);
- } else {
- // Hide the file exists warning.
- fileExistsWarningTextView.setVisibility(View.GONE);
- }
-
- // Enable the save button if the file name is populated.
- saveButton.setEnabled(!fileNameString.isEmpty());
- }
- });
-
- // Instantiate the download location helper.
- DownloadLocationHelper downloadLocationHelper = new DownloadLocationHelper();
-
- // Get the default file path.
- String defaultFilePath = downloadLocationHelper.getDownloadLocation(context) + "/" + getString(R.string.privacy_browser_logcat_txt);
-
- // Display the default file path.
- fileNameEditText.setText(defaultFilePath);
-
- // Hide the storage permission text view if the permission has already been granted.
- if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
- storagePermissionTextView.setVisibility(View.GONE);
- }
-
- // Handle clicks on the browse button.
- browseButton.setOnClickListener((View view) -> {
- // Create the file picker intent.
- Intent browseIntent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
-
- // Set the intent MIME type to include all files so that everything is visible.
- browseIntent.setType("*/*");
-
- // Set the initial file name.
- browseIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.privacy_browser_logcat_txt));
-
- // Set the initial directory if the minimum API >= 26.
- if (Build.VERSION.SDK_INT >= 26) {
- browseIntent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.getExternalStorageDirectory());
- }
-
- // Request a file that can be opened.
- browseIntent.addCategory(Intent.CATEGORY_OPENABLE);
-
- // Launch the file picker. There is only one `startActivityForResult()`, so the request code is simply set to 0, but it must be run under `activity` so the request code is correct.
- activity.startActivityForResult(browseIntent, 0);
- });
-
- // Return the alert dialog.
- return alertDialog;
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.dialogs;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.provider.DocumentsContract;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.DialogFragment;
+import androidx.preference.PreferenceManager;
+
+import com.google.android.material.textfield.TextInputLayout;
+import com.stoutner.privacybrowser.R;
+import com.stoutner.privacybrowser.activities.MainWebViewActivity;
+import com.stoutner.privacybrowser.asynctasks.GetUrlSize;
+import com.stoutner.privacybrowser.helpers.DownloadLocationHelper;
+
+import java.io.File;
+
+public class SaveWebpageDialog extends DialogFragment {
+ // Define the save webpage listener.
+ private SaveWebpageListener saveWebpageListener;
+
+ // The public interface is used to send information back to the parent activity.
+ public interface SaveWebpageListener {
+ void onSaveWebpage(int saveType, DialogFragment dialogFragment);
+ }
+
+ // Define the get URL size AsyncTask. This allows previous instances of the task to be cancelled if a new one is run.
+ private AsyncTask getUrlSize;
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ // Run the default commands.
+ super.onAttach(context);
+
+ // Get a handle for the save webpage listener from the launching context.
+ saveWebpageListener = (SaveWebpageListener) context;
+ }
+
+ public static SaveWebpageDialog saveWebpage(int saveType, String urlString, String fileSizeString, String contentDispositionFileNameString, String userAgentString, boolean cookiesEnabled) {
+ // Create an arguments bundle.
+ Bundle argumentsBundle = new Bundle();
+
+ // Store the arguments in the bundle.
+ argumentsBundle.putInt("save_type", saveType);
+ argumentsBundle.putString("url_string", urlString);
+ argumentsBundle.putString("file_size_string", fileSizeString);
+ argumentsBundle.putString("content_disposition_file_name_string", contentDispositionFileNameString);
+ argumentsBundle.putString("user_agent_string", userAgentString);
+ argumentsBundle.putBoolean("cookies_enabled", cookiesEnabled);
+
+ // Create a new instance of the save webpage dialog.
+ SaveWebpageDialog saveWebpageDialog = new SaveWebpageDialog();
+
+ // Add the arguments bundle to the new dialog.
+ saveWebpageDialog.setArguments(argumentsBundle);
+
+ // Return the new dialog.
+ return saveWebpageDialog;
+ }
+
+ // `@SuppressLint("InflateParams")` removes the warning about using null as the parent view group when inflating the alert dialog.
+ @SuppressLint("InflateParams")
+ @Override
+ @NonNull
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ // Get a handle for the arguments.
+ Bundle arguments = getArguments();
+
+ // Remove the incorrect lint warning that the arguments might be null.
+ assert arguments != null;
+
+ // Get the arguments from the bundle.
+ int saveType = arguments.getInt("save_type");
+ String urlString = arguments.getString("url_string");
+ String fileSizeString = arguments.getString("file_size_string");
+ String contentDispositionFileNameString = arguments.getString("content_disposition_file_name_string");
+ String userAgentString = arguments.getString("user_agent_string");
+ boolean cookiesEnabled = arguments.getBoolean("cookies_enabled");
+
+ // Get a handle for the activity and the context.
+ Activity activity = requireActivity();
+ Context context = requireContext();
+
+ // Use an alert dialog builder to create the alert dialog.
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.PrivacyBrowserAlertDialog);
+
+ // Get the current theme status.
+ int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // The night theme is enabled.
+ // Set the icon according to the save type.
+ switch (saveType) {
+ case StoragePermissionDialog.SAVE_URL:
+ dialogBuilder.setIcon(R.drawable.copy_enabled_night);
+ break;
+
+ case StoragePermissionDialog.SAVE_ARCHIVE:
+ dialogBuilder.setIcon(R.drawable.dom_storage_cleared_night);
+ break;
+
+ case StoragePermissionDialog.SAVE_IMAGE:
+ dialogBuilder.setIcon(R.drawable.images_enabled_night);
+ break;
+ }
+ } else { // The day theme is enabled.
+ // Set the icon according to the save type.
+ switch (saveType) {
+ case StoragePermissionDialog.SAVE_URL:
+ dialogBuilder.setIcon(R.drawable.copy_enabled_day);
+ break;
+
+ case StoragePermissionDialog.SAVE_ARCHIVE:
+ dialogBuilder.setIcon(R.drawable.dom_storage_cleared_day);
+ break;
+
+ case StoragePermissionDialog.SAVE_IMAGE:
+ dialogBuilder.setIcon(R.drawable.images_enabled_day);
+ break;
+ }
+ }
+
+ // Set the title according to the type.
+ switch (saveType) {
+ case StoragePermissionDialog.SAVE_URL:
+ dialogBuilder.setTitle(R.string.save);
+ break;
+
+ case StoragePermissionDialog.SAVE_ARCHIVE:
+ dialogBuilder.setTitle(R.string.save_archive);
+ break;
+
+ case StoragePermissionDialog.SAVE_IMAGE:
+ dialogBuilder.setTitle(R.string.save_image);
+ break;
+ }
+
+ // Set the view. The parent view is null because it will be assigned by the alert dialog.
+ dialogBuilder.setView(activity.getLayoutInflater().inflate(R.layout.save_url_dialog, null));
+
+ // Set the cancel button listener. Using `null` as the listener closes the dialog without doing anything else.
+ dialogBuilder.setNegativeButton(R.string.cancel, null);
+
+ // Set the save button listener.
+ dialogBuilder.setPositiveButton(R.string.save, (DialogInterface dialog, int which) -> {
+ // Return the dialog fragment to the parent activity.
+ saveWebpageListener.onSaveWebpage(saveType, this);
+ });
+
+ // Create an alert dialog from the builder.
+ AlertDialog alertDialog = dialogBuilder.create();
+
+ // Remove the incorrect lint warning below that the window might be null.
+ assert alertDialog.getWindow() != null;
+
+ // Get a handle for the shared preferences.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+
+ // Get the screenshot preference.
+ boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
+ // Disable screenshots if not allowed.
+ if (!allowScreenshots) {
+ alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+ }
+
+ // The alert dialog must be shown before items in the layout can be modified.
+ alertDialog.show();
+
+ // Get handles for the layout items.
+ TextInputLayout urlTextInputLayout = alertDialog.findViewById(R.id.url_textinputlayout);
+ EditText urlEditText = alertDialog.findViewById(R.id.url_edittext);
+ EditText fileNameEditText = alertDialog.findViewById(R.id.file_name_edittext);
+ Button browseButton = alertDialog.findViewById(R.id.browse_button);
+ TextView fileSizeTextView = alertDialog.findViewById(R.id.file_size_textview);
+ TextView fileExistsWarningTextView = alertDialog.findViewById(R.id.file_exists_warning_textview);
+ TextView storagePermissionTextView = alertDialog.findViewById(R.id.storage_permission_textview);
+ Button saveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
+
+ // Remove the incorrect warnings that the views might be null.
+ assert urlTextInputLayout != null;
+ assert urlEditText != null;
+ assert fileNameEditText != null;
+ assert browseButton != null;
+ assert fileSizeTextView != null;
+ assert fileExistsWarningTextView != null;
+ assert storagePermissionTextView != null;
+
+ // Set the file size text view.
+ fileSizeTextView.setText(fileSizeString);
+
+ // Modify the layout based on the save type.
+ if (saveType == StoragePermissionDialog.SAVE_URL) { // A URL is being saved.
+ // Populate the URL edit text. This must be done before the text change listener is created below so that the file size isn't requested again.
+ urlEditText.setText(urlString);
+
+ // Update the file size and the status of the save button when the URL changes.
+ urlEditText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ // Do nothing.
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ // Do nothing.
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ // Cancel the get URL size AsyncTask if it is running.
+ if ((getUrlSize != null)) {
+ getUrlSize.cancel(true);
+ }
+
+ // Get the current URL to save.
+ String urlToSave = urlEditText.getText().toString();
+
+ // Wipe the file size text view.
+ fileSizeTextView.setText("");
+
+ // Get the file size for the current URL.
+ getUrlSize = new GetUrlSize(context, alertDialog, userAgentString, cookiesEnabled).execute(urlToSave);
+
+ // Enable the save button if the URL and file name are populated.
+ saveButton.setEnabled(!urlToSave.isEmpty() && !fileNameEditText.getText().toString().isEmpty());
+ }
+ });
+ } else { // An archive or an image is being saved.
+ // Hide the URL edit text and the file size text view.
+ urlTextInputLayout.setVisibility(View.GONE);
+ fileSizeTextView.setVisibility(View.GONE);
+ }
+
+ // Update the status of the save button when the file name changes.
+ fileNameEditText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // Do nothing.
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ // Do nothing.
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ // Get the current file name.
+ String fileNameString = fileNameEditText.getText().toString();
+
+ // Convert the file name string to a file.
+ File file = new File(fileNameString);
+
+ // Check to see if the file exists.
+ if (file.exists()) {
+ // Show the file exists warning.
+ fileExistsWarningTextView.setVisibility(View.VISIBLE);
+ } else {
+ // Hide the file exists warning.
+ fileExistsWarningTextView.setVisibility(View.GONE);
+ }
+
+ // Enable the save button based on the save type.
+ if (saveType == StoragePermissionDialog.SAVE_URL) { // A URL is being saved.
+ // Enable the save button if the file name and the URL is populated.
+ saveButton.setEnabled(!fileNameString.isEmpty() && !urlEditText.getText().toString().isEmpty());
+ } else { // An archive or an image is being saved.
+ // Enable the save button if the file name is populated.
+ saveButton.setEnabled(!fileNameString.isEmpty());
+ }
+ }
+ });
+
+ // Create a file name string.
+ String fileName = "";
+
+ // Set the file name according to the type.
+ switch (saveType) {
+ case StoragePermissionDialog.SAVE_URL:
+ // Use the file name from the content disposition.
+ fileName = contentDispositionFileNameString;
+ break;
+
+ case StoragePermissionDialog.SAVE_ARCHIVE:
+ // Use an archive name ending in `.mht`.
+ fileName = getString(R.string.webpage_mht);
+ break;
+
+ case StoragePermissionDialog.SAVE_IMAGE:
+ // Use a file name ending in `.png`.
+ fileName = getString(R.string.webpage_png);
+ break;
+ }
+
+ // Save the file name as the default file name. This must be final to be used in the lambda below.
+ final String defaultFileName = fileName;
+
+ // Instantiate the download location helper.
+ DownloadLocationHelper downloadLocationHelper = new DownloadLocationHelper();
+
+ // Get the default file path.
+ String defaultFilePath = downloadLocationHelper.getDownloadLocation(context) + "/" + defaultFileName;
+
+ // Populate the file name edit text.
+ fileNameEditText.setText(defaultFilePath);
+
+ // Move the cursor to the end of the default file path.
+ fileNameEditText.setSelection(defaultFilePath.length());
+
+ // Handle clicks on the browse button.
+ browseButton.setOnClickListener((View view) -> {
+ // Create the file picker intent.
+ Intent browseIntent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
+
+ // Set the intent MIME type to include all files so that everything is visible.
+ browseIntent.setType("*/*");
+
+ // Set the initial file name according to the type.
+ browseIntent.putExtra(Intent.EXTRA_TITLE, defaultFileName);
+
+ // Set the initial directory if the minimum API >= 26.
+ if (Build.VERSION.SDK_INT >= 26) {
+ browseIntent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.getExternalStorageDirectory());
+ }
+
+ // Request a file that can be opened.
+ browseIntent.addCategory(Intent.CATEGORY_OPENABLE);
+
+ // Start the file picker. This must be started under `activity` so that the request code is returned correctly.
+ activity.startActivityForResult(browseIntent, MainWebViewActivity.BROWSE_SAVE_WEBPAGE_REQUEST_CODE);
+ });
+
+ // Hide the storage permission text view if the permission has already been granted.
+ if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ storagePermissionTextView.setVisibility(View.GONE);
+ }
+
+ // Return the alert dialog.
+ return alertDialog;
+ }
+}
\ No newline at end of file
// Define the save type constants.
public static final int OPEN = 0;
public static final int SAVE_URL = 1;
- public static final int SAVE_AS_ARCHIVE = 2;
- public static final int SAVE_AS_IMAGE = 3;
+ public static final int SAVE_ARCHIVE = 2;
+ public static final int SAVE_TEXT = 3;
+ public static final int SAVE_IMAGE = 4;
// The listener is used in `onAttach()` and `onCreateDialog()`.
private StoragePermissionDialogListener storagePermissionDialogListener;
+++ /dev/null
-/*
- * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
- *
- * Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.stoutner.privacybrowser.fragments;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.app.ActivityManager;
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.Signature;
-import android.content.res.Configuration;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.style.ForegroundColorSpan;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.WebView;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import androidx.webkit.WebViewCompat;
-
-import com.stoutner.privacybrowser.BuildConfig;
-import com.stoutner.privacybrowser.R;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.Principal;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.text.DateFormat;
-import java.text.NumberFormat;
-import java.util.Date;
-
-public class AboutTabFragment extends Fragment {
- // Declare the class constants.
- final static String TAB_NUMBER = "tab_number";
- final static String BLOCKLIST_VERSIONS = "blocklist_versions";
- final long MEBIBYTE = 1048576;
-
- // Declare the class variables.
- private boolean updateMemoryUsageBoolean = true;
- private int tabNumber;
- private String[] blocklistVersions;
- private View tabLayout;
- private String appConsumedMemoryLabel;
- private String appAvailableMemoryLabel;
- private String appTotalMemoryLabel;
- private String appMaximumMemoryLabel;
- private String systemConsumedMemoryLabel;
- private String systemAvailableMemoryLabel;
- private String systemTotalMemoryLabel;
- private Runtime runtime;
- private ActivityManager activityManager;
- private ActivityManager.MemoryInfo memoryInfo;
- private NumberFormat numberFormat;
- private ForegroundColorSpan blueColorSpan;
-
- // Declare the class views.
- private TextView appConsumedMemoryTextView;
- private TextView appAvailableMemoryTextView;
- private TextView appTotalMemoryTextView;
- private TextView appMaximumMemoryTextView;
- private TextView systemConsumedMemoryTextView;
- private TextView systemAvailableMemoryTextView;
- private TextView systemTotalMemoryTextView;
-
- public static AboutTabFragment createTab(int tabNumber, String[] blocklistVersions) {
- // Create a bundle.
- Bundle argumentsBundle = new Bundle();
-
- // Store the tab number in the bundle.
- argumentsBundle.putInt(TAB_NUMBER, tabNumber);
- argumentsBundle.putStringArray(BLOCKLIST_VERSIONS, blocklistVersions);
-
- // Create a new instance of the tab fragment.
- AboutTabFragment aboutTabFragment = new AboutTabFragment();
-
- // Add the arguments bundle to the fragment.
- aboutTabFragment.setArguments(argumentsBundle);
-
- // Return the new fragment.
- return aboutTabFragment;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- // Run the default commands.
- super.onCreate(savedInstanceState);
-
- // Get a handle for the arguments.
- Bundle arguments = getArguments();
-
- // Remove the incorrect lint warning below that arguments might be null.
- assert arguments != null;
-
- // Store the arguments in class variables.
- tabNumber = getArguments().getInt(TAB_NUMBER);
- blocklistVersions = getArguments().getStringArray(BLOCKLIST_VERSIONS);
- }
-
- @Override
- public View onCreateView(@NonNull LayoutInflater layoutInflater, ViewGroup container, Bundle savedInstanceState) {
- // Get a handle for the context and assert that it isn't null.
- Context context = getContext();
- assert context != null;
-
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Load the tabs. Tab numbers start at 0.
- if (tabNumber == 0) { // Load the about tab.
- // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container. The fragment will take care of attaching the root automatically.
- tabLayout = layoutInflater.inflate(R.layout.about_tab_version, container, false);
-
- // Get handles for the text views.
- TextView versionTextView = tabLayout.findViewById(R.id.version);
- TextView brandTextView = tabLayout.findViewById(R.id.brand);
- TextView manufacturerTextView = tabLayout.findViewById(R.id.manufacturer);
- TextView modelTextView = tabLayout.findViewById(R.id.model);
- TextView deviceTextView = tabLayout.findViewById(R.id.device);
- TextView bootloaderTextView = tabLayout.findViewById(R.id.bootloader);
- TextView radioTextView = tabLayout.findViewById(R.id.radio);
- TextView androidTextView = tabLayout.findViewById(R.id.android);
- TextView securityPatchTextView = tabLayout.findViewById(R.id.security_patch);
- TextView buildTextView = tabLayout.findViewById(R.id.build);
- TextView webViewProviderTextView = tabLayout.findViewById(R.id.webview_provider);
- TextView webViewVersionTextView = tabLayout.findViewById(R.id.webview_version);
- TextView orbotTextView = tabLayout.findViewById(R.id.orbot);
- TextView i2pTextView = tabLayout.findViewById(R.id.i2p);
- TextView openKeychainTextView = tabLayout.findViewById(R.id.open_keychain);
- appConsumedMemoryTextView = tabLayout.findViewById(R.id.app_consumed_memory);
- appAvailableMemoryTextView = tabLayout.findViewById(R.id.app_available_memory);
- appTotalMemoryTextView = tabLayout.findViewById(R.id.app_total_memory);
- appMaximumMemoryTextView = tabLayout.findViewById(R.id.app_maximum_memory);
- systemConsumedMemoryTextView = tabLayout.findViewById(R.id.system_consumed_memory);
- systemAvailableMemoryTextView = tabLayout.findViewById(R.id.system_available_memory);
- systemTotalMemoryTextView = tabLayout.findViewById(R.id.system_total_memory);
- TextView easyListTextView = tabLayout.findViewById(R.id.easylist);
- TextView easyPrivacyTextView = tabLayout.findViewById(R.id.easyprivacy);
- TextView fanboyAnnoyanceTextView = tabLayout.findViewById(R.id.fanboy_annoyance);
- TextView fanboySocialTextView = tabLayout.findViewById(R.id.fanboy_social);
- TextView ultraListTextView = tabLayout.findViewById(R.id.ultralist);
- TextView ultraPrivacyTextView = tabLayout.findViewById(R.id.ultraprivacy);
- TextView certificateIssuerDNTextView = tabLayout.findViewById(R.id.certificate_issuer_dn);
- TextView certificateSubjectDNTextView = tabLayout.findViewById(R.id.certificate_subject_dn);
- TextView certificateStartDateTextView = tabLayout.findViewById(R.id.certificate_start_date);
- TextView certificateEndDateTextView = tabLayout.findViewById(R.id.certificate_end_date);
- TextView certificateVersionTextView = tabLayout.findViewById(R.id.certificate_version);
- TextView certificateSerialNumberTextView = tabLayout.findViewById(R.id.certificate_serial_number);
- TextView certificateSignatureAlgorithmTextView = tabLayout.findViewById(R.id.certificate_signature_algorithm);
-
- // Setup the labels.
- String version = getString(R.string.version) + " " + BuildConfig.VERSION_NAME + " (" + getString(R.string.version_code) + " " + BuildConfig.VERSION_CODE + ")";
- String brandLabel = getString(R.string.brand) + " ";
- String manufacturerLabel = getString(R.string.manufacturer) + " ";
- String modelLabel = getString(R.string.model) + " ";
- String deviceLabel = getString(R.string.device) + " ";
- String bootloaderLabel = getString(R.string.bootloader) + " ";
- String androidLabel = getString(R.string.android) + " ";
- String buildLabel = getString(R.string.build) + " ";
- String webViewVersionLabel = getString(R.string.webview_version) + " ";
- appConsumedMemoryLabel = getString(R.string.app_consumed_memory) + " ";
- appAvailableMemoryLabel = getString(R.string.app_available_memory) + " ";
- appTotalMemoryLabel = getString(R.string.app_total_memory) + " ";
- appMaximumMemoryLabel = getString(R.string.app_maximum_memory) + " ";
- systemConsumedMemoryLabel = getString(R.string.system_consumed_memory) + " ";
- systemAvailableMemoryLabel = getString(R.string.system_available_memory) + " ";
- systemTotalMemoryLabel = getString(R.string.system_total_memory) + " ";
- String easyListLabel = getString(R.string.easylist_label) + " ";
- String easyPrivacyLabel = getString(R.string.easyprivacy_label) + " ";
- String fanboyAnnoyanceLabel = getString(R.string.fanboy_annoyance_label) + " ";
- String fanboySocialLabel = getString(R.string.fanboy_social_label) + " ";
- String ultraListLabel = getString(R.string.ultralist_label) + " ";
- String ultraPrivacyLabel = getString(R.string.ultraprivacy_label) + " ";
- String issuerDNLabel = getString(R.string.issuer_dn) + " ";
- String subjectDNLabel = getString(R.string.subject_dn) + " ";
- String startDateLabel = getString(R.string.start_date) + " ";
- String endDateLabel = getString(R.string.end_date) + " ";
- String certificateVersionLabel = getString(R.string.certificate_version) + " ";
- String serialNumberLabel = getString(R.string.serial_number) + " ";
- String signatureAlgorithmLabel = getString(R.string.signature_algorithm) + " ";
-
- // The WebView layout is only used to get the default user agent from `bare_webview`. It is not used to render content on the screen.
- // Once the minimum API >= 26 this can be accomplished with the WebView package info.
- View webViewLayout = layoutInflater.inflate(R.layout.bare_webview, container, false);
- WebView tabLayoutWebView = webViewLayout.findViewById(R.id.bare_webview);
- String userAgentString = tabLayoutWebView.getSettings().getUserAgentString();
-
- // Get the device's information and store it in strings.
- String brand = Build.BRAND;
- String manufacturer = Build.MANUFACTURER;
- String model = Build.MODEL;
- String device = Build.DEVICE;
- String bootloader = Build.BOOTLOADER;
- String radio = Build.getRadioVersion();
- String android = Build.VERSION.RELEASE + " (" + getString(R.string.api) + " " + Build.VERSION.SDK_INT + ")";
- String build = Build.DISPLAY;
- // Select the substring that begins after `Chrome/` and goes until the next ` `.
- String webView = userAgentString.substring(userAgentString.indexOf("Chrome/") + 7, userAgentString.indexOf(" ", userAgentString.indexOf("Chrome/")));
-
- // Get the Orbot version name if Orbot is installed.
- String orbot;
- try {
- // Store the version name.
- orbot = context.getPackageManager().getPackageInfo("org.torproject.android", 0).versionName;
- } catch (PackageManager.NameNotFoundException exception) { // Orbot is not installed.
- orbot = "";
- }
-
- // Get the I2P version name if I2P is installed.
- String i2p;
- try {
- // Store the version name.
- i2p = context.getPackageManager().getPackageInfo("net.i2p.android.router", 0).versionName;
- } catch (PackageManager.NameNotFoundException exception) { // I2P is not installed.
- i2p = "";
- }
-
- // Get the OpenKeychain version name if it is installed.
- String openKeychain;
- try {
- // Store the version name.
- openKeychain = context.getPackageManager().getPackageInfo("org.sufficientlysecure.keychain", 0).versionName;
- } catch (PackageManager.NameNotFoundException exception) { // OpenKeychain is not installed.
- openKeychain = "";
- }
-
- // Create a spannable string builder for the hardware and software text views that needs multiple colors of text.
- SpannableStringBuilder brandStringBuilder = new SpannableStringBuilder(brandLabel + brand);
- SpannableStringBuilder manufacturerStringBuilder = new SpannableStringBuilder(manufacturerLabel + manufacturer);
- SpannableStringBuilder modelStringBuilder = new SpannableStringBuilder(modelLabel + model);
- SpannableStringBuilder deviceStringBuilder = new SpannableStringBuilder(deviceLabel + device);
- SpannableStringBuilder bootloaderStringBuilder = new SpannableStringBuilder(bootloaderLabel + bootloader);
- SpannableStringBuilder androidStringBuilder = new SpannableStringBuilder(androidLabel + android);
- SpannableStringBuilder buildStringBuilder = new SpannableStringBuilder(buildLabel + build);
- SpannableStringBuilder webViewVersionStringBuilder = new SpannableStringBuilder(webViewVersionLabel + webView);
- SpannableStringBuilder easyListStringBuilder = new SpannableStringBuilder(easyListLabel + blocklistVersions[0]);
- SpannableStringBuilder easyPrivacyStringBuilder = new SpannableStringBuilder(easyPrivacyLabel + blocklistVersions[1]);
- SpannableStringBuilder fanboyAnnoyanceStringBuilder = new SpannableStringBuilder(fanboyAnnoyanceLabel + blocklistVersions[2]);
- SpannableStringBuilder fanboySocialStringBuilder = new SpannableStringBuilder(fanboySocialLabel + blocklistVersions[3]);
- SpannableStringBuilder ultraListStringBuilder = new SpannableStringBuilder(ultraListLabel + blocklistVersions[4]);
- SpannableStringBuilder ultraPrivacyStringBuilder = new SpannableStringBuilder(ultraPrivacyLabel + blocklistVersions[5]);
-
- // Set the blue color span according to the theme. The deprecated `getResources()` must be used until the minimum API >= 23.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700));
- } else {
- blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.violet_500));
- }
-
- // Setup the spans to display the device information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
- brandStringBuilder.setSpan(blueColorSpan, brandLabel.length(), brandStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- manufacturerStringBuilder.setSpan(blueColorSpan, manufacturerLabel.length(), manufacturerStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- modelStringBuilder.setSpan(blueColorSpan, modelLabel.length(), modelStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- deviceStringBuilder.setSpan(blueColorSpan, deviceLabel.length(), deviceStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- bootloaderStringBuilder.setSpan(blueColorSpan, bootloaderLabel.length(), bootloaderStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- androidStringBuilder.setSpan(blueColorSpan, androidLabel.length(), androidStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- buildStringBuilder.setSpan(blueColorSpan, buildLabel.length(), buildStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- webViewVersionStringBuilder.setSpan(blueColorSpan, webViewVersionLabel.length(), webViewVersionStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- easyListStringBuilder.setSpan(blueColorSpan, easyListLabel.length(), easyListStringBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
- easyPrivacyStringBuilder.setSpan(blueColorSpan, easyPrivacyLabel.length(), easyPrivacyStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- fanboyAnnoyanceStringBuilder.setSpan(blueColorSpan, fanboyAnnoyanceLabel.length(), fanboyAnnoyanceStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- fanboySocialStringBuilder.setSpan(blueColorSpan, fanboySocialLabel.length(), fanboySocialStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- ultraListStringBuilder.setSpan(blueColorSpan, ultraListLabel.length(), ultraListStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- ultraPrivacyStringBuilder.setSpan(blueColorSpan, ultraPrivacyLabel.length(), ultraPrivacyStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
-
- // Display the strings in the text boxes.
- versionTextView.setText(version);
- brandTextView.setText(brandStringBuilder);
- manufacturerTextView.setText(manufacturerStringBuilder);
- modelTextView.setText(modelStringBuilder);
- deviceTextView.setText(deviceStringBuilder);
- bootloaderTextView.setText(bootloaderStringBuilder);
- androidTextView.setText(androidStringBuilder);
- buildTextView.setText(buildStringBuilder);
- webViewVersionTextView.setText(webViewVersionStringBuilder);
- easyListTextView.setText(easyListStringBuilder);
- easyPrivacyTextView.setText(easyPrivacyStringBuilder);
- fanboyAnnoyanceTextView.setText(fanboyAnnoyanceStringBuilder);
- fanboySocialTextView.setText(fanboySocialStringBuilder);
- ultraListTextView.setText(ultraListStringBuilder);
- ultraPrivacyTextView.setText(ultraPrivacyStringBuilder);
-
- // Only populate the radio text view if there is a radio in the device.
- if (!radio.isEmpty()) {
- String radioLabel = getString(R.string.radio) + " ";
- SpannableStringBuilder radioStringBuilder = new SpannableStringBuilder(radioLabel + radio);
- radioStringBuilder.setSpan(blueColorSpan, radioLabel.length(), radioStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- radioTextView.setText(radioStringBuilder);
- } else { // This device does not have a radio.
- radioTextView.setVisibility(View.GONE);
- }
-
- // Build.VERSION.SECURITY_PATCH is only available for SDK_INT >= 23.
- if (Build.VERSION.SDK_INT >= 23) {
- String securityPatchLabel = getString(R.string.security_patch) + " ";
- String securityPatch = Build.VERSION.SECURITY_PATCH;
- SpannableStringBuilder securityPatchStringBuilder = new SpannableStringBuilder(securityPatchLabel + securityPatch);
- securityPatchStringBuilder.setSpan(blueColorSpan, securityPatchLabel.length(), securityPatchStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- securityPatchTextView.setText(securityPatchStringBuilder);
- } else { // The API < 23.
- // Hide the security patch text view.
- securityPatchTextView.setVisibility(View.GONE);
- }
-
- // Only populate the WebView provider if the SDK >= 21.
- if (Build.VERSION.SDK_INT >= 21) {
- // Create the WebView provider label.
- String webViewProviderLabel = getString(R.string.webview_provider) + " ";
-
- // Get the current WebView package info.
- PackageInfo webViewPackageInfo = WebViewCompat.getCurrentWebViewPackage(context);
-
- // Remove the warning below that the package info might be null.
- assert webViewPackageInfo != null;
-
- // Get the WebView provider name.
- String webViewPackageName = webViewPackageInfo.packageName;
-
- // Create the spannable string builder.
- SpannableStringBuilder webViewProviderStringBuilder = new SpannableStringBuilder(webViewProviderLabel + webViewPackageName);
-
- // Apply the coloration.
- webViewProviderStringBuilder.setSpan(blueColorSpan, webViewProviderLabel.length(), webViewProviderStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
-
- // Display the WebView provider.
- webViewProviderTextView.setText(webViewProviderStringBuilder);
- } else { // The API < 21.
- // Hide the WebView provider text view.
- webViewProviderTextView.setVisibility(View.GONE);
- }
-
- // Only populate the Orbot text view if it is installed.
- if (!orbot.isEmpty()) {
- String orbotLabel = getString(R.string.orbot) + " ";
- SpannableStringBuilder orbotStringBuilder = new SpannableStringBuilder(orbotLabel + orbot);
- orbotStringBuilder.setSpan(blueColorSpan, orbotLabel.length(), orbotStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- orbotTextView.setText(orbotStringBuilder);
- } else { // Orbot is not installed.
- orbotTextView.setVisibility(View.GONE);
- }
-
- // Only populate the I2P text view if it is installed.
- if (!i2p.isEmpty()) {
- String i2pLabel = getString(R.string.i2p) + " ";
- SpannableStringBuilder i2pStringBuilder = new SpannableStringBuilder(i2pLabel + i2p);
- i2pStringBuilder.setSpan(blueColorSpan, i2pLabel.length(), i2pStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- i2pTextView.setText(i2pStringBuilder);
- } else { // I2P is not installed.
- i2pTextView.setVisibility(View.GONE);
- }
-
- // Only populate the OpenKeychain text view if it is installed.
- if (!openKeychain.isEmpty()) {
- String openKeychainLabel = getString(R.string.openkeychain) + " ";
- SpannableStringBuilder openKeychainStringBuilder = new SpannableStringBuilder(openKeychainLabel + openKeychain);
- openKeychainStringBuilder.setSpan(blueColorSpan, openKeychainLabel.length(), openKeychainStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- openKeychainTextView.setText(openKeychainStringBuilder);
- } else { //OpenKeychain is not installed.
- openKeychainTextView.setVisibility(View.GONE);
- }
-
- // Display the package signature.
- try {
- // Get the first package signature. Suppress the lint warning about the need to be careful in implementing comparison of certificates for security purposes.
- @SuppressLint("PackageManagerGetSignatures") Signature packageSignature = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(),
- PackageManager.GET_SIGNATURES).signatures[0];
-
- // Convert the signature to a byte array input stream.
- InputStream certificateByteArrayInputStream = new ByteArrayInputStream(packageSignature.toByteArray());
-
- // Display the certificate information on the screen.
- try {
- // Instantiate a `CertificateFactory`.
- CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
-
- // Generate an `X509Certificate`.
- X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certificateByteArrayInputStream);
-
- // Store the individual sections of the certificate that we are interested in.
- Principal issuerDNPrincipal = x509Certificate.getIssuerDN();
- Principal subjectDNPrincipal = x509Certificate.getSubjectDN();
- Date startDate = x509Certificate.getNotBefore();
- Date endDate = x509Certificate.getNotAfter();
- int certificateVersion = x509Certificate.getVersion();
- BigInteger serialNumberBigInteger = x509Certificate.getSerialNumber();
- String signatureAlgorithmNameString = x509Certificate.getSigAlgName();
-
- // Create a `SpannableStringBuilder` for each `TextView` that needs multiple colors of text.
- SpannableStringBuilder issuerDNStringBuilder = new SpannableStringBuilder(issuerDNLabel + issuerDNPrincipal.toString());
- SpannableStringBuilder subjectDNStringBuilder = new SpannableStringBuilder(subjectDNLabel + subjectDNPrincipal.toString());
- SpannableStringBuilder startDateStringBuilder = new SpannableStringBuilder(startDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(startDate));
- SpannableStringBuilder endDataStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(endDate));
- SpannableStringBuilder certificateVersionStringBuilder = new SpannableStringBuilder(certificateVersionLabel + certificateVersion);
- SpannableStringBuilder serialNumberStringBuilder = new SpannableStringBuilder(serialNumberLabel + serialNumberBigInteger);
- SpannableStringBuilder signatureAlgorithmStringBuilder = new SpannableStringBuilder(signatureAlgorithmLabel + signatureAlgorithmNameString);
-
- // Setup the spans to display the device information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
- issuerDNStringBuilder.setSpan(blueColorSpan, issuerDNLabel.length(), issuerDNStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- subjectDNStringBuilder.setSpan(blueColorSpan, subjectDNLabel.length(), subjectDNStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- startDateStringBuilder.setSpan(blueColorSpan, startDateLabel.length(), startDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- endDataStringBuilder.setSpan(blueColorSpan, endDateLabel.length(), endDataStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- certificateVersionStringBuilder.setSpan(blueColorSpan, certificateVersionLabel.length(), certificateVersionStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- serialNumberStringBuilder.setSpan(blueColorSpan, serialNumberLabel.length(), serialNumberStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- signatureAlgorithmStringBuilder.setSpan(blueColorSpan, signatureAlgorithmLabel.length(), signatureAlgorithmStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
-
- // Display the strings in the text boxes.
- certificateIssuerDNTextView.setText(issuerDNStringBuilder);
- certificateSubjectDNTextView.setText(subjectDNStringBuilder);
- certificateStartDateTextView.setText(startDateStringBuilder);
- certificateEndDateTextView.setText(endDataStringBuilder);
- certificateVersionTextView.setText(certificateVersionStringBuilder);
- certificateSerialNumberTextView.setText(serialNumberStringBuilder);
- certificateSignatureAlgorithmTextView.setText(signatureAlgorithmStringBuilder);
- } catch (CertificateException e) {
- // Do nothing if there is a certificate error.
- }
-
- // Get a handle for the runtime.
- runtime = Runtime.getRuntime();
-
- // Get a handle for the activity.
- Activity activity = getActivity();
-
- // Remove the incorrect lint warning below that the activity might be null.
- assert activity != null;
-
- // Get a handle for the activity manager.
- activityManager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
-
- // Remove the incorrect lint warning below that the activity manager might be null.
- assert activityManager != null;
-
- // Instantiate a memory info variable.
- memoryInfo = new ActivityManager.MemoryInfo();
-
- // Define a number format.
- numberFormat = NumberFormat.getInstance();
-
- // Set the minimum and maximum number of fraction digits.
- numberFormat.setMinimumFractionDigits(2);
- numberFormat.setMaximumFractionDigits(2);
-
- // Update the memory usage.
- updateMemoryUsage(getActivity());
- } catch (PackageManager.NameNotFoundException e) {
- // Do nothing if `PackageManager` says Privacy Browser isn't installed.
- }
- } else { // load a WebView for all the other tabs. Tab numbers start at 0.
- // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container. The fragment will take care of attaching the root automatically.
- tabLayout = layoutInflater.inflate(R.layout.bare_webview, container, false);
-
- // Get a handle for `tabWebView`.
- WebView tabWebView = (WebView) tabLayout;
-
- // Load the tabs according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // The dark theme is applied.
- // Set the background color. The deprecated `.getColor()` must be used until the minimum API >= 23.
- tabWebView.setBackgroundColor(getResources().getColor(R.color.gray_850));
-
- switch (tabNumber) {
- case 1:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_permissions_dark.html");
- break;
-
- case 2:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_privacy_policy_dark.html");
- break;
-
- case 3:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_changelog_dark.html");
- break;
-
- case 4:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_licenses_dark.html");
- break;
-
- case 5:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_contributors_dark.html");
- break;
-
- case 6:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_links_dark.html");
- break;
- }
- } else { // The light theme is applied.
- switch (tabNumber) {
- case 1:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_permissions_light.html");
- break;
-
- case 2:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_privacy_policy_light.html");
- break;
-
- case 3:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_changelog_light.html");
- break;
-
- case 4:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_licenses_light.html");
- break;
-
- case 5:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_contributors_light.html");
- break;
-
- case 6:
- tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_links_light.html");
- break;
- }
- }
- }
-
- // Scroll the tab if the saved instance state is not null.
- if (savedInstanceState != null) {
- tabLayout.post(() -> {
- tabLayout.setScrollX(savedInstanceState.getInt("scroll_x"));
- tabLayout.setScrollY(savedInstanceState.getInt("scroll_y"));
- });
- }
-
- // Return the formatted `tabLayout`.
- return tabLayout;
- }
-
- @Override
- public void onPause() {
- // Run the default commands.
- super.onPause();
-
- // Pause the updating of the memory usage.
- updateMemoryUsageBoolean = false;
- }
-
- @Override
- public void onResume() {
- // Run the default commands.
- super.onResume();
-
- // Resume the updating of the memory usage.
- updateMemoryUsageBoolean = true;
- }
-
- @Override
- public void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
- // Run the default commands.
- super.onSaveInstanceState(savedInstanceState);
-
- // Save the scroll positions if the tab layout is not null, which can happen if a tab is not currently selected.
- if (tabLayout != null) {
- savedInstanceState.putInt("scroll_x", tabLayout.getScrollX());
- savedInstanceState.putInt("scroll_y", tabLayout.getScrollY());
- }
- }
-
- public void updateMemoryUsage(Activity activity) {
- try {
- // Update the memory usage if enabled.
- if (updateMemoryUsageBoolean) {
- // Populate the memory info variable.
- activityManager.getMemoryInfo(memoryInfo);
-
- // Get the app memory information.
- long appAvailableMemoryLong = runtime.freeMemory();
- long appTotalMemoryLong = runtime.totalMemory();
- long appMaximumMemoryLong = runtime.maxMemory();
-
- // Calculate the app consumed memory.
- long appConsumedMemoryLong = appTotalMemoryLong - appAvailableMemoryLong;
-
- // Get the system memory information.
- long systemTotalMemoryLong = memoryInfo.totalMem;
- long systemAvailableMemoryLong = memoryInfo.availMem;
-
- // Calculate the system consumed memory.
- long systemConsumedMemoryLong = systemTotalMemoryLong - systemAvailableMemoryLong;
-
- // Convert the memory information into mebibytes.
- float appConsumedMemoryFloat = (float) appConsumedMemoryLong / MEBIBYTE;
- float appAvailableMemoryFloat = (float) appAvailableMemoryLong / MEBIBYTE;
- float appTotalMemoryFloat = (float) appTotalMemoryLong / MEBIBYTE;
- float appMaximumMemoryFloat = (float) appMaximumMemoryLong / MEBIBYTE;
- float systemConsumedMemoryFloat = (float) systemConsumedMemoryLong / MEBIBYTE;
- float systemAvailableMemoryFloat = (float) systemAvailableMemoryLong / MEBIBYTE;
- float systemTotalMemoryFloat = (float) systemTotalMemoryLong / MEBIBYTE;
-
- // Get the mebibyte string.
- String mebibyte = getString(R.string.mebibyte);
-
- // Calculate the mebibyte length.
- int mebibyteLength = mebibyte.length();
-
- // Create spannable string builders.
- SpannableStringBuilder appConsumedMemoryStringBuilder = new SpannableStringBuilder(appConsumedMemoryLabel + numberFormat.format(appConsumedMemoryFloat) + " " + mebibyte);
- SpannableStringBuilder appAvailableMemoryStringBuilder = new SpannableStringBuilder(appAvailableMemoryLabel + numberFormat.format(appAvailableMemoryFloat) + " " + mebibyte);
- SpannableStringBuilder appTotalMemoryStringBuilder = new SpannableStringBuilder(appTotalMemoryLabel + numberFormat.format(appTotalMemoryFloat) + " " + mebibyte);
- SpannableStringBuilder appMaximumMemoryStringBuilder = new SpannableStringBuilder(appMaximumMemoryLabel + numberFormat.format(appMaximumMemoryFloat) + " " + mebibyte);
- SpannableStringBuilder systemConsumedMemoryStringBuilder = new SpannableStringBuilder(systemConsumedMemoryLabel + numberFormat.format(systemConsumedMemoryFloat) + " " + mebibyte);
- SpannableStringBuilder systemAvailableMemoryStringBuilder = new SpannableStringBuilder(systemAvailableMemoryLabel + numberFormat.format(systemAvailableMemoryFloat) + " " + mebibyte);
- SpannableStringBuilder systemTotalMemoryStringBuilder = new SpannableStringBuilder(systemTotalMemoryLabel + numberFormat.format(systemTotalMemoryFloat) + " " + mebibyte);
-
- // Setup the spans to display the memory information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
- appConsumedMemoryStringBuilder.setSpan(blueColorSpan, appConsumedMemoryLabel.length(), appConsumedMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- appAvailableMemoryStringBuilder.setSpan(blueColorSpan, appAvailableMemoryLabel.length(), appAvailableMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- appTotalMemoryStringBuilder.setSpan(blueColorSpan, appTotalMemoryLabel.length(), appTotalMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- appMaximumMemoryStringBuilder.setSpan(blueColorSpan, appMaximumMemoryLabel.length(), appMaximumMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- systemConsumedMemoryStringBuilder.setSpan(blueColorSpan, systemConsumedMemoryLabel.length(), systemConsumedMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- systemAvailableMemoryStringBuilder.setSpan(blueColorSpan, systemAvailableMemoryLabel.length(), systemAvailableMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- systemTotalMemoryStringBuilder.setSpan(blueColorSpan, systemTotalMemoryLabel.length(), systemTotalMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
-
- // Display the string in the text boxes.
- appConsumedMemoryTextView.setText(appConsumedMemoryStringBuilder);
- appAvailableMemoryTextView.setText(appAvailableMemoryStringBuilder);
- appTotalMemoryTextView.setText(appTotalMemoryStringBuilder);
- appMaximumMemoryTextView.setText(appMaximumMemoryStringBuilder);
- systemConsumedMemoryTextView.setText(systemConsumedMemoryStringBuilder);
- systemAvailableMemoryTextView.setText(systemAvailableMemoryStringBuilder);
- systemTotalMemoryTextView.setText(systemTotalMemoryStringBuilder);
- }
-
- // Schedule another memory update if the activity has not been destroyed.
- if (!activity.isDestroyed()) {
- // Create a handler to update the memory usage.
- Handler updateMemoryUsageHandler = new Handler();
-
- // Create a runnable to update the memory usage.
- Runnable updateMemoryUsageRunnable = () -> updateMemoryUsage(activity);
-
- // Update the memory usage after 1000 milliseconds
- updateMemoryUsageHandler.postDelayed(updateMemoryUsageRunnable, 1000);
- }
- } catch (Exception exception) {
- // Do nothing.
- }
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.fragments;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.Signature;
+import android.content.res.Configuration;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
+import android.text.style.ForegroundColorSpan;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+import android.widget.TextView;
+
+import com.google.android.material.snackbar.Snackbar;
+import com.stoutner.privacybrowser.BuildConfig;
+import com.stoutner.privacybrowser.R;
+import com.stoutner.privacybrowser.dialogs.SaveDialog;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.Principal;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.util.Date;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+import androidx.webkit.WebViewCompat;
+
+public class AboutVersionFragment extends Fragment {
+ // Declare the class constants.
+ final static String BLOCKLIST_VERSIONS = "blocklist_versions";
+ final long MEBIBYTE = 1048576;
+
+ // Declare the class variables.
+ private boolean updateMemoryUsageBoolean = true;
+ private String[] blocklistVersions;
+ private View aboutVersionLayout;
+ private String appConsumedMemoryLabel;
+ private String appAvailableMemoryLabel;
+ private String appTotalMemoryLabel;
+ private String appMaximumMemoryLabel;
+ private String systemConsumedMemoryLabel;
+ private String systemAvailableMemoryLabel;
+ private String systemTotalMemoryLabel;
+ private Runtime runtime;
+ private ActivityManager activityManager;
+ private ActivityManager.MemoryInfo memoryInfo;
+ private NumberFormat numberFormat;
+ private ForegroundColorSpan blueColorSpan;
+
+ // Declare the class views.
+ private TextView privacyBrowserTextView;
+ private TextView versionTextView;
+ private TextView hardwareTextView;
+ private TextView brandTextView;
+ private TextView manufacturerTextView;
+ private TextView modelTextView;
+ private TextView deviceTextView;
+ private TextView bootloaderTextView;
+ private TextView radioTextView;
+ private TextView softwareTextView;
+ private TextView androidTextView;
+ private TextView securityPatchTextView;
+ private TextView buildTextView;
+ private TextView webViewProviderTextView;
+ private TextView webViewVersionTextView;
+ private TextView orbotTextView;
+ private TextView i2pTextView;
+ private TextView openKeychainTextView;
+ private TextView memoryUsageTextView;
+ private TextView appConsumedMemoryTextView;
+ private TextView appAvailableMemoryTextView;
+ private TextView appTotalMemoryTextView;
+ private TextView appMaximumMemoryTextView;
+ private TextView systemConsumedMemoryTextView;
+ private TextView systemAvailableMemoryTextView;
+ private TextView systemTotalMemoryTextView;
+ private TextView blocklistsTextView;
+ private TextView easyListTextView;
+ private TextView easyPrivacyTextView;
+ private TextView fanboyAnnoyanceTextView;
+ private TextView fanboySocialTextView;
+ private TextView ultraListTextView;
+ private TextView ultraPrivacyTextView;
+ private TextView packageSignatureTextView;
+ private TextView certificateIssuerDnTextView;
+ private TextView certificateSubjectDnTextView;
+ private TextView certificateStartDateTextView;
+ private TextView certificateEndDateTextView;
+ private TextView certificateVersionTextView;
+ private TextView certificateSerialNumberTextView;
+ private TextView certificateSignatureAlgorithmTextView;
+
+ public static AboutVersionFragment createTab(String[] blocklistVersions) {
+ // Create an arguments bundle.
+ Bundle argumentsBundle = new Bundle();
+
+ // Store the arguments in the bundle.
+ argumentsBundle.putStringArray(BLOCKLIST_VERSIONS, blocklistVersions);
+
+ // Create a new instance of the tab fragment.
+ AboutVersionFragment aboutVersionFragment = new AboutVersionFragment();
+
+ // Add the arguments bundle to the fragment.
+ aboutVersionFragment.setArguments(argumentsBundle);
+
+ // Return the new fragment.
+ return aboutVersionFragment;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ // Run the default commands.
+ super.onCreate(savedInstanceState);
+
+ // Get a handle for the arguments.
+ Bundle arguments = getArguments();
+
+ // Remove the incorrect lint warning below that the arguments might be null.
+ assert arguments != null;
+
+ // Store the arguments in class variables.
+ blocklistVersions = arguments.getStringArray(BLOCKLIST_VERSIONS);
+
+ // Enable the options menu for this fragment.
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public View onCreateView(@NonNull LayoutInflater layoutInflater, ViewGroup container, Bundle savedInstanceState) {
+ // Get a handle for the context.
+ Context context = getContext();
+
+ // Remove the incorrect lint warning below that the context might be null.
+ assert context != null;
+
+ // Get the current theme status.
+ int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+ // Inflate the layout. Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container. The fragment will take care of attaching the root automatically.
+ aboutVersionLayout = layoutInflater.inflate(R.layout.about_version, container, false);
+
+ // Get handles for the views.
+ privacyBrowserTextView = aboutVersionLayout.findViewById(R.id.privacy_browser_textview);
+ versionTextView = aboutVersionLayout.findViewById(R.id.version);
+ hardwareTextView = aboutVersionLayout.findViewById(R.id.hardware);
+ brandTextView = aboutVersionLayout.findViewById(R.id.brand);
+ manufacturerTextView = aboutVersionLayout.findViewById(R.id.manufacturer);
+ modelTextView = aboutVersionLayout.findViewById(R.id.model);
+ deviceTextView = aboutVersionLayout.findViewById(R.id.device);
+ bootloaderTextView = aboutVersionLayout.findViewById(R.id.bootloader);
+ radioTextView = aboutVersionLayout.findViewById(R.id.radio);
+ softwareTextView = aboutVersionLayout.findViewById(R.id.software);
+ androidTextView = aboutVersionLayout.findViewById(R.id.android);
+ securityPatchTextView = aboutVersionLayout.findViewById(R.id.security_patch);
+ buildTextView = aboutVersionLayout.findViewById(R.id.build);
+ webViewProviderTextView = aboutVersionLayout.findViewById(R.id.webview_provider);
+ webViewVersionTextView = aboutVersionLayout.findViewById(R.id.webview_version);
+ orbotTextView = aboutVersionLayout.findViewById(R.id.orbot);
+ i2pTextView = aboutVersionLayout.findViewById(R.id.i2p);
+ openKeychainTextView = aboutVersionLayout.findViewById(R.id.open_keychain);
+ memoryUsageTextView = aboutVersionLayout.findViewById(R.id.memory_usage);
+ appConsumedMemoryTextView = aboutVersionLayout.findViewById(R.id.app_consumed_memory);
+ appAvailableMemoryTextView = aboutVersionLayout.findViewById(R.id.app_available_memory);
+ appTotalMemoryTextView = aboutVersionLayout.findViewById(R.id.app_total_memory);
+ appMaximumMemoryTextView = aboutVersionLayout.findViewById(R.id.app_maximum_memory);
+ systemConsumedMemoryTextView = aboutVersionLayout.findViewById(R.id.system_consumed_memory);
+ systemAvailableMemoryTextView = aboutVersionLayout.findViewById(R.id.system_available_memory);
+ systemTotalMemoryTextView = aboutVersionLayout.findViewById(R.id.system_total_memory);
+ blocklistsTextView = aboutVersionLayout.findViewById(R.id.blocklists);
+ easyListTextView = aboutVersionLayout.findViewById(R.id.easylist);
+ easyPrivacyTextView = aboutVersionLayout.findViewById(R.id.easyprivacy);
+ fanboyAnnoyanceTextView = aboutVersionLayout.findViewById(R.id.fanboy_annoyance);
+ fanboySocialTextView = aboutVersionLayout.findViewById(R.id.fanboy_social);
+ ultraListTextView = aboutVersionLayout.findViewById(R.id.ultralist);
+ ultraPrivacyTextView = aboutVersionLayout.findViewById(R.id.ultraprivacy);
+ packageSignatureTextView = aboutVersionLayout.findViewById(R.id.package_signature);
+ certificateIssuerDnTextView = aboutVersionLayout.findViewById(R.id.certificate_issuer_dn);
+ certificateSubjectDnTextView = aboutVersionLayout.findViewById(R.id.certificate_subject_dn);
+ certificateStartDateTextView = aboutVersionLayout.findViewById(R.id.certificate_start_date);
+ certificateEndDateTextView = aboutVersionLayout.findViewById(R.id.certificate_end_date);
+ certificateVersionTextView = aboutVersionLayout.findViewById(R.id.certificate_version);
+ certificateSerialNumberTextView = aboutVersionLayout.findViewById(R.id.certificate_serial_number);
+ certificateSignatureAlgorithmTextView = aboutVersionLayout.findViewById(R.id.certificate_signature_algorithm);
+
+ // Setup the labels.
+ String version = getString(R.string.version) + " " + BuildConfig.VERSION_NAME + " (" + getString(R.string.version_code) + " " + BuildConfig.VERSION_CODE + ")";
+ String brandLabel = getString(R.string.brand) + " ";
+ String manufacturerLabel = getString(R.string.manufacturer) + " ";
+ String modelLabel = getString(R.string.model) + " ";
+ String deviceLabel = getString(R.string.device) + " ";
+ String bootloaderLabel = getString(R.string.bootloader) + " ";
+ String androidLabel = getString(R.string.android) + " ";
+ String buildLabel = getString(R.string.build) + " ";
+ String webViewVersionLabel = getString(R.string.webview_version) + " ";
+ appConsumedMemoryLabel = getString(R.string.app_consumed_memory) + " ";
+ appAvailableMemoryLabel = getString(R.string.app_available_memory) + " ";
+ appTotalMemoryLabel = getString(R.string.app_total_memory) + " ";
+ appMaximumMemoryLabel = getString(R.string.app_maximum_memory) + " ";
+ systemConsumedMemoryLabel = getString(R.string.system_consumed_memory) + " ";
+ systemAvailableMemoryLabel = getString(R.string.system_available_memory) + " ";
+ systemTotalMemoryLabel = getString(R.string.system_total_memory) + " ";
+ String easyListLabel = getString(R.string.easylist_label) + " ";
+ String easyPrivacyLabel = getString(R.string.easyprivacy_label) + " ";
+ String fanboyAnnoyanceLabel = getString(R.string.fanboy_annoyance_label) + " ";
+ String fanboySocialLabel = getString(R.string.fanboy_social_label) + " ";
+ String ultraListLabel = getString(R.string.ultralist_label) + " ";
+ String ultraPrivacyLabel = getString(R.string.ultraprivacy_label) + " ";
+ String issuerDNLabel = getString(R.string.issuer_dn) + " ";
+ String subjectDNLabel = getString(R.string.subject_dn) + " ";
+ String startDateLabel = getString(R.string.start_date) + " ";
+ String endDateLabel = getString(R.string.end_date) + " ";
+ String certificateVersionLabel = getString(R.string.certificate_version) + " ";
+ String serialNumberLabel = getString(R.string.serial_number) + " ";
+ String signatureAlgorithmLabel = getString(R.string.signature_algorithm) + " ";
+
+ // The WebView layout is only used to get the default user agent from `bare_webview`. It is not used to render content on the screen.
+ // Once the minimum API >= 26 this can be accomplished with the WebView package info.
+ View webViewLayout = layoutInflater.inflate(R.layout.bare_webview, container, false);
+ WebView tabLayoutWebView = webViewLayout.findViewById(R.id.bare_webview);
+ String userAgentString = tabLayoutWebView.getSettings().getUserAgentString();
+
+ // Get the device's information and store it in strings.
+ String brand = Build.BRAND;
+ String manufacturer = Build.MANUFACTURER;
+ String model = Build.MODEL;
+ String device = Build.DEVICE;
+ String bootloader = Build.BOOTLOADER;
+ String radio = Build.getRadioVersion();
+ String android = Build.VERSION.RELEASE + " (" + getString(R.string.api) + " " + Build.VERSION.SDK_INT + ")";
+ String build = Build.DISPLAY;
+ // Select the substring that begins after `Chrome/` and goes until the next ` `.
+ String webView = userAgentString.substring(userAgentString.indexOf("Chrome/") + 7, userAgentString.indexOf(" ", userAgentString.indexOf("Chrome/")));
+
+ // Get the Orbot version name if Orbot is installed.
+ String orbot;
+ try {
+ // Store the version name.
+ orbot = context.getPackageManager().getPackageInfo("org.torproject.android", 0).versionName;
+ } catch (PackageManager.NameNotFoundException exception) { // Orbot is not installed.
+ orbot = "";
+ }
+
+ // Get the I2P version name if I2P is installed.
+ String i2p;
+ try {
+ // Store the version name.
+ i2p = context.getPackageManager().getPackageInfo("net.i2p.android.router", 0).versionName;
+ } catch (PackageManager.NameNotFoundException exception) { // I2P is not installed.
+ i2p = "";
+ }
+
+ // Get the OpenKeychain version name if it is installed.
+ String openKeychain;
+ try {
+ // Store the version name.
+ openKeychain = context.getPackageManager().getPackageInfo("org.sufficientlysecure.keychain", 0).versionName;
+ } catch (PackageManager.NameNotFoundException exception) { // OpenKeychain is not installed.
+ openKeychain = "";
+ }
+
+ // Create a spannable string builder for the hardware and software text views that needs multiple colors of text.
+ SpannableStringBuilder brandStringBuilder = new SpannableStringBuilder(brandLabel + brand);
+ SpannableStringBuilder manufacturerStringBuilder = new SpannableStringBuilder(manufacturerLabel + manufacturer);
+ SpannableStringBuilder modelStringBuilder = new SpannableStringBuilder(modelLabel + model);
+ SpannableStringBuilder deviceStringBuilder = new SpannableStringBuilder(deviceLabel + device);
+ SpannableStringBuilder bootloaderStringBuilder = new SpannableStringBuilder(bootloaderLabel + bootloader);
+ SpannableStringBuilder androidStringBuilder = new SpannableStringBuilder(androidLabel + android);
+ SpannableStringBuilder buildStringBuilder = new SpannableStringBuilder(buildLabel + build);
+ SpannableStringBuilder webViewVersionStringBuilder = new SpannableStringBuilder(webViewVersionLabel + webView);
+ SpannableStringBuilder easyListStringBuilder = new SpannableStringBuilder(easyListLabel + blocklistVersions[0]);
+ SpannableStringBuilder easyPrivacyStringBuilder = new SpannableStringBuilder(easyPrivacyLabel + blocklistVersions[1]);
+ SpannableStringBuilder fanboyAnnoyanceStringBuilder = new SpannableStringBuilder(fanboyAnnoyanceLabel + blocklistVersions[2]);
+ SpannableStringBuilder fanboySocialStringBuilder = new SpannableStringBuilder(fanboySocialLabel + blocklistVersions[3]);
+ SpannableStringBuilder ultraListStringBuilder = new SpannableStringBuilder(ultraListLabel + blocklistVersions[4]);
+ SpannableStringBuilder ultraPrivacyStringBuilder = new SpannableStringBuilder(ultraPrivacyLabel + blocklistVersions[5]);
+
+ // Set the blue color span according to the theme. The deprecated `getResources()` must be used until the minimum API >= 23.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700));
+ } else {
+ blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.violet_500));
+ }
+
+ // Setup the spans to display the device information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ brandStringBuilder.setSpan(blueColorSpan, brandLabel.length(), brandStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ manufacturerStringBuilder.setSpan(blueColorSpan, manufacturerLabel.length(), manufacturerStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ modelStringBuilder.setSpan(blueColorSpan, modelLabel.length(), modelStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ deviceStringBuilder.setSpan(blueColorSpan, deviceLabel.length(), deviceStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ bootloaderStringBuilder.setSpan(blueColorSpan, bootloaderLabel.length(), bootloaderStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ androidStringBuilder.setSpan(blueColorSpan, androidLabel.length(), androidStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ buildStringBuilder.setSpan(blueColorSpan, buildLabel.length(), buildStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ webViewVersionStringBuilder.setSpan(blueColorSpan, webViewVersionLabel.length(), webViewVersionStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ easyListStringBuilder.setSpan(blueColorSpan, easyListLabel.length(), easyListStringBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ easyPrivacyStringBuilder.setSpan(blueColorSpan, easyPrivacyLabel.length(), easyPrivacyStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ fanboyAnnoyanceStringBuilder.setSpan(blueColorSpan, fanboyAnnoyanceLabel.length(), fanboyAnnoyanceStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ fanboySocialStringBuilder.setSpan(blueColorSpan, fanboySocialLabel.length(), fanboySocialStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ ultraListStringBuilder.setSpan(blueColorSpan, ultraListLabel.length(), ultraListStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ ultraPrivacyStringBuilder.setSpan(blueColorSpan, ultraPrivacyLabel.length(), ultraPrivacyStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+
+ // Display the strings in the text boxes.
+ versionTextView.setText(version);
+ brandTextView.setText(brandStringBuilder);
+ manufacturerTextView.setText(manufacturerStringBuilder);
+ modelTextView.setText(modelStringBuilder);
+ deviceTextView.setText(deviceStringBuilder);
+ bootloaderTextView.setText(bootloaderStringBuilder);
+ androidTextView.setText(androidStringBuilder);
+ buildTextView.setText(buildStringBuilder);
+ webViewVersionTextView.setText(webViewVersionStringBuilder);
+ easyListTextView.setText(easyListStringBuilder);
+ easyPrivacyTextView.setText(easyPrivacyStringBuilder);
+ fanboyAnnoyanceTextView.setText(fanboyAnnoyanceStringBuilder);
+ fanboySocialTextView.setText(fanboySocialStringBuilder);
+ ultraListTextView.setText(ultraListStringBuilder);
+ ultraPrivacyTextView.setText(ultraPrivacyStringBuilder);
+
+ // Only populate the radio text view if there is a radio in the device.
+ if (!radio.isEmpty()) {
+ String radioLabel = getString(R.string.radio) + " ";
+ SpannableStringBuilder radioStringBuilder = new SpannableStringBuilder(radioLabel + radio);
+ radioStringBuilder.setSpan(blueColorSpan, radioLabel.length(), radioStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ radioTextView.setText(radioStringBuilder);
+ } else { // This device does not have a radio.
+ radioTextView.setVisibility(View.GONE);
+ }
+
+ // Build.VERSION.SECURITY_PATCH is only available for SDK_INT >= 23.
+ if (Build.VERSION.SDK_INT >= 23) {
+ String securityPatchLabel = getString(R.string.security_patch) + " ";
+ String securityPatch = Build.VERSION.SECURITY_PATCH;
+ SpannableStringBuilder securityPatchStringBuilder = new SpannableStringBuilder(securityPatchLabel + securityPatch);
+ securityPatchStringBuilder.setSpan(blueColorSpan, securityPatchLabel.length(), securityPatchStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ securityPatchTextView.setText(securityPatchStringBuilder);
+ } else { // The API < 23.
+ // Hide the security patch text view.
+ securityPatchTextView.setVisibility(View.GONE);
+ }
+
+ // Only populate the WebView provider if the SDK >= 21.
+ if (Build.VERSION.SDK_INT >= 21) {
+ // Create the WebView provider label.
+ String webViewProviderLabel = getString(R.string.webview_provider) + " ";
+
+ // Get the current WebView package info.
+ PackageInfo webViewPackageInfo = WebViewCompat.getCurrentWebViewPackage(context);
+
+ // Remove the warning below that the package info might be null.
+ assert webViewPackageInfo != null;
+
+ // Get the WebView provider name.
+ String webViewPackageName = webViewPackageInfo.packageName;
+
+ // Create the spannable string builder.
+ SpannableStringBuilder webViewProviderStringBuilder = new SpannableStringBuilder(webViewProviderLabel + webViewPackageName);
+
+ // Apply the coloration.
+ webViewProviderStringBuilder.setSpan(blueColorSpan, webViewProviderLabel.length(), webViewProviderStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+
+ // Display the WebView provider.
+ webViewProviderTextView.setText(webViewProviderStringBuilder);
+ } else { // The API < 21.
+ // Hide the WebView provider text view.
+ webViewProviderTextView.setVisibility(View.GONE);
+ }
+
+ // Only populate the Orbot text view if it is installed.
+ if (!orbot.isEmpty()) {
+ String orbotLabel = getString(R.string.orbot) + " ";
+ SpannableStringBuilder orbotStringBuilder = new SpannableStringBuilder(orbotLabel + orbot);
+ orbotStringBuilder.setSpan(blueColorSpan, orbotLabel.length(), orbotStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ orbotTextView.setText(orbotStringBuilder);
+ } else { // Orbot is not installed.
+ orbotTextView.setVisibility(View.GONE);
+ }
+
+ // Only populate the I2P text view if it is installed.
+ if (!i2p.isEmpty()) {
+ String i2pLabel = getString(R.string.i2p) + " ";
+ SpannableStringBuilder i2pStringBuilder = new SpannableStringBuilder(i2pLabel + i2p);
+ i2pStringBuilder.setSpan(blueColorSpan, i2pLabel.length(), i2pStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ i2pTextView.setText(i2pStringBuilder);
+ } else { // I2P is not installed.
+ i2pTextView.setVisibility(View.GONE);
+ }
+
+ // Only populate the OpenKeychain text view if it is installed.
+ if (!openKeychain.isEmpty()) {
+ String openKeychainLabel = getString(R.string.openkeychain) + " ";
+ SpannableStringBuilder openKeychainStringBuilder = new SpannableStringBuilder(openKeychainLabel + openKeychain);
+ openKeychainStringBuilder.setSpan(blueColorSpan, openKeychainLabel.length(), openKeychainStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ openKeychainTextView.setText(openKeychainStringBuilder);
+ } else { //OpenKeychain is not installed.
+ openKeychainTextView.setVisibility(View.GONE);
+ }
+
+ // Display the package signature.
+ try {
+ // Get the first package signature. Suppress the lint warning about the need to be careful in implementing comparison of certificates for security purposes.
+ @SuppressLint("PackageManagerGetSignatures") Signature packageSignature = context.getPackageManager().getPackageInfo(context.getPackageName(),
+ PackageManager.GET_SIGNATURES).signatures[0];
+
+ // Convert the signature to a byte array input stream.
+ InputStream certificateByteArrayInputStream = new ByteArrayInputStream(packageSignature.toByteArray());
+
+ // Display the certificate information on the screen.
+ try {
+ // Instantiate a `CertificateFactory`.
+ CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
+
+ // Generate an `X509Certificate`.
+ X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certificateByteArrayInputStream);
+
+ // Store the individual sections of the certificate that we are interested in.
+ Principal issuerDNPrincipal = x509Certificate.getIssuerDN();
+ Principal subjectDNPrincipal = x509Certificate.getSubjectDN();
+ Date startDate = x509Certificate.getNotBefore();
+ Date endDate = x509Certificate.getNotAfter();
+ int certificateVersion = x509Certificate.getVersion();
+ BigInteger serialNumberBigInteger = x509Certificate.getSerialNumber();
+ String signatureAlgorithmNameString = x509Certificate.getSigAlgName();
+
+ // Create a `SpannableStringBuilder` for each `TextView` that needs multiple colors of text.
+ SpannableStringBuilder issuerDNStringBuilder = new SpannableStringBuilder(issuerDNLabel + issuerDNPrincipal.toString());
+ SpannableStringBuilder subjectDNStringBuilder = new SpannableStringBuilder(subjectDNLabel + subjectDNPrincipal.toString());
+ SpannableStringBuilder startDateStringBuilder = new SpannableStringBuilder(startDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(startDate));
+ SpannableStringBuilder endDataStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(endDate));
+ SpannableStringBuilder certificateVersionStringBuilder = new SpannableStringBuilder(certificateVersionLabel + certificateVersion);
+ SpannableStringBuilder serialNumberStringBuilder = new SpannableStringBuilder(serialNumberLabel + serialNumberBigInteger);
+ SpannableStringBuilder signatureAlgorithmStringBuilder = new SpannableStringBuilder(signatureAlgorithmLabel + signatureAlgorithmNameString);
+
+ // Setup the spans to display the device information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ issuerDNStringBuilder.setSpan(blueColorSpan, issuerDNLabel.length(), issuerDNStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ subjectDNStringBuilder.setSpan(blueColorSpan, subjectDNLabel.length(), subjectDNStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ startDateStringBuilder.setSpan(blueColorSpan, startDateLabel.length(), startDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ endDataStringBuilder.setSpan(blueColorSpan, endDateLabel.length(), endDataStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ certificateVersionStringBuilder.setSpan(blueColorSpan, certificateVersionLabel.length(), certificateVersionStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ serialNumberStringBuilder.setSpan(blueColorSpan, serialNumberLabel.length(), serialNumberStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ signatureAlgorithmStringBuilder.setSpan(blueColorSpan, signatureAlgorithmLabel.length(), signatureAlgorithmStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+
+ // Display the strings in the text boxes.
+ certificateIssuerDnTextView.setText(issuerDNStringBuilder);
+ certificateSubjectDnTextView.setText(subjectDNStringBuilder);
+ certificateStartDateTextView.setText(startDateStringBuilder);
+ certificateEndDateTextView.setText(endDataStringBuilder);
+ certificateVersionTextView.setText(certificateVersionStringBuilder);
+ certificateSerialNumberTextView.setText(serialNumberStringBuilder);
+ certificateSignatureAlgorithmTextView.setText(signatureAlgorithmStringBuilder);
+ } catch (CertificateException e) {
+ // Do nothing if there is a certificate error.
+ }
+
+ // Get a handle for the runtime.
+ runtime = Runtime.getRuntime();
+
+ // Get a handle for the activity.
+ Activity activity = getActivity();
+
+ // Remove the incorrect lint warning below that the activity might be null.
+ assert activity != null;
+
+ // Get a handle for the activity manager.
+ activityManager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
+
+ // Remove the incorrect lint warning below that the activity manager might be null.
+ assert activityManager != null;
+
+ // Instantiate a memory info variable.
+ memoryInfo = new ActivityManager.MemoryInfo();
+
+ // Define a number format.
+ numberFormat = NumberFormat.getInstance();
+
+ // Set the minimum and maximum number of fraction digits.
+ numberFormat.setMinimumFractionDigits(2);
+ numberFormat.setMaximumFractionDigits(2);
+
+ // Update the memory usage.
+ updateMemoryUsage(getActivity());
+ } catch (PackageManager.NameNotFoundException e) {
+ // Do nothing if `PackageManager` says Privacy Browser isn't installed.
+ }
+
+ // Scroll the tab if the saved instance state is not null.
+ if (savedInstanceState != null) {
+ aboutVersionLayout.post(() -> {
+ aboutVersionLayout.setScrollX(savedInstanceState.getInt("scroll_x"));
+ aboutVersionLayout.setScrollY(savedInstanceState.getInt("scroll_y"));
+ });
+ }
+
+ // Return the tab layout.
+ return aboutVersionLayout;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
+ // Inflate the about version menu.
+ menuInflater.inflate(R.menu.about_version_options_menu, menu);
+
+ // Run the default commands.
+ super.onCreateOptionsMenu(menu, menuInflater);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem menuItem) {
+ // Get the ID of the menu item that was selected.
+ int menuItemId = menuItem.getItemId();
+
+ // Remove the warning below that `getActivity()` might be null.
+ assert getActivity() != null;
+
+ // Run the appropriate commands.
+ switch (menuItemId) {
+ case R.id.copy:
+ // Get the about version string.
+ String aboutVersionString = getAboutVersionString();
+
+ // Get a handle for the clipboard manager.
+ ClipboardManager clipboardManager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
+
+ // Remove the incorrect lint error below that the clipboard manager might be null.
+ assert clipboardManager != null;
+
+ // Save the about version string in a clip data.
+ ClipData aboutVersionClipData = ClipData.newPlainText(getString(R.string.about), aboutVersionString);
+
+ // Place the clip data on the clipboard.
+ clipboardManager.setPrimaryClip(aboutVersionClipData);
+
+ // Display a snackbar.
+ Snackbar.make(aboutVersionLayout, R.string.version_info_copied, Snackbar.LENGTH_SHORT).show();
+
+ // Consume the event.
+ return true;
+
+ case R.id.share:
+ // Get the about version string.
+ String aboutString = getAboutVersionString();
+
+ // Create an email intent.
+ Intent emailIntent = new Intent(Intent.ACTION_SEND);
+
+ // Add the about version string to the intent.
+ emailIntent.putExtra(Intent.EXTRA_TEXT, aboutString);
+
+ // Set the MIME type.
+ emailIntent.setType("text/plain");
+
+ // Set the intent to open in a new task.
+ emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ // Make it so.
+ startActivity(Intent.createChooser(emailIntent, getString(R.string.share)));
+
+ // Consume the event.
+ return true;
+
+ case R.id.save_text:
+ // Instantiate the save alert dialog.
+ DialogFragment saveTextDialogFragment = SaveDialog.save(SaveDialog.SAVE_ABOUT_VERSION_TEXT);
+
+ // Show the save alert dialog.
+ saveTextDialogFragment.show(getActivity().getSupportFragmentManager(), getString(R.string.save_dialog));
+
+ // Consume the event.
+ return true;
+
+ case R.id.save_image:
+ // Instantiate the save alert dialog.
+ DialogFragment saveImageDialogFragment = SaveDialog.save(SaveDialog.SAVE_ABOUT_VERSION_IMAGE);
+
+ // Show the save alert dialog.
+ saveImageDialogFragment.show(getActivity().getSupportFragmentManager(), getString(R.string.save_dialog));
+
+ // Consume the event.
+ return true;
+
+ default:
+ // Don't consume the event.
+ return super.onOptionsItemSelected(menuItem);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
+ // Run the default commands.
+ super.onSaveInstanceState(savedInstanceState);
+
+ // Save the scroll positions if the layout is not null, which can happen if a tab is not currently selected.
+ if (aboutVersionLayout != null) {
+ savedInstanceState.putInt("scroll_x", aboutVersionLayout.getScrollX());
+ savedInstanceState.putInt("scroll_y", aboutVersionLayout.getScrollY());
+ }
+ }
+
+ @Override
+ public void onPause() {
+ // Run the default commands.
+ super.onPause();
+
+ // Pause the updating of the memory usage.
+ updateMemoryUsageBoolean = false;
+ }
+
+ @Override
+ public void onResume() {
+ // Run the default commands.
+ super.onResume();
+
+ // Resume the updating of the memory usage.
+ updateMemoryUsageBoolean = true;
+ }
+
+ public void updateMemoryUsage(Activity activity) {
+ try {
+ // Update the memory usage if enabled.
+ if (updateMemoryUsageBoolean) {
+ // Populate the memory info variable.
+ activityManager.getMemoryInfo(memoryInfo);
+
+ // Get the app memory information.
+ long appAvailableMemoryLong = runtime.freeMemory();
+ long appTotalMemoryLong = runtime.totalMemory();
+ long appMaximumMemoryLong = runtime.maxMemory();
+
+ // Calculate the app consumed memory.
+ long appConsumedMemoryLong = appTotalMemoryLong - appAvailableMemoryLong;
+
+ // Get the system memory information.
+ long systemTotalMemoryLong = memoryInfo.totalMem;
+ long systemAvailableMemoryLong = memoryInfo.availMem;
+
+ // Calculate the system consumed memory.
+ long systemConsumedMemoryLong = systemTotalMemoryLong - systemAvailableMemoryLong;
+
+ // Convert the memory information into mebibytes.
+ float appConsumedMemoryFloat = (float) appConsumedMemoryLong / MEBIBYTE;
+ float appAvailableMemoryFloat = (float) appAvailableMemoryLong / MEBIBYTE;
+ float appTotalMemoryFloat = (float) appTotalMemoryLong / MEBIBYTE;
+ float appMaximumMemoryFloat = (float) appMaximumMemoryLong / MEBIBYTE;
+ float systemConsumedMemoryFloat = (float) systemConsumedMemoryLong / MEBIBYTE;
+ float systemAvailableMemoryFloat = (float) systemAvailableMemoryLong / MEBIBYTE;
+ float systemTotalMemoryFloat = (float) systemTotalMemoryLong / MEBIBYTE;
+
+ // Get the mebibyte string.
+ String mebibyte = getString(R.string.mebibyte);
+
+ // Calculate the mebibyte length.
+ int mebibyteLength = mebibyte.length();
+
+ // Create spannable string builders.
+ SpannableStringBuilder appConsumedMemoryStringBuilder = new SpannableStringBuilder(appConsumedMemoryLabel + numberFormat.format(appConsumedMemoryFloat) + " " + mebibyte);
+ SpannableStringBuilder appAvailableMemoryStringBuilder = new SpannableStringBuilder(appAvailableMemoryLabel + numberFormat.format(appAvailableMemoryFloat) + " " + mebibyte);
+ SpannableStringBuilder appTotalMemoryStringBuilder = new SpannableStringBuilder(appTotalMemoryLabel + numberFormat.format(appTotalMemoryFloat) + " " + mebibyte);
+ SpannableStringBuilder appMaximumMemoryStringBuilder = new SpannableStringBuilder(appMaximumMemoryLabel + numberFormat.format(appMaximumMemoryFloat) + " " + mebibyte);
+ SpannableStringBuilder systemConsumedMemoryStringBuilder = new SpannableStringBuilder(systemConsumedMemoryLabel + numberFormat.format(systemConsumedMemoryFloat) + " " + mebibyte);
+ SpannableStringBuilder systemAvailableMemoryStringBuilder = new SpannableStringBuilder(systemAvailableMemoryLabel + numberFormat.format(systemAvailableMemoryFloat) + " " + mebibyte);
+ SpannableStringBuilder systemTotalMemoryStringBuilder = new SpannableStringBuilder(systemTotalMemoryLabel + numberFormat.format(systemTotalMemoryFloat) + " " + mebibyte);
+
+ // Setup the spans to display the memory information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ appConsumedMemoryStringBuilder.setSpan(blueColorSpan, appConsumedMemoryLabel.length(), appConsumedMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ appAvailableMemoryStringBuilder.setSpan(blueColorSpan, appAvailableMemoryLabel.length(), appAvailableMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ appTotalMemoryStringBuilder.setSpan(blueColorSpan, appTotalMemoryLabel.length(), appTotalMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ appMaximumMemoryStringBuilder.setSpan(blueColorSpan, appMaximumMemoryLabel.length(), appMaximumMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ systemConsumedMemoryStringBuilder.setSpan(blueColorSpan, systemConsumedMemoryLabel.length(), systemConsumedMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ systemAvailableMemoryStringBuilder.setSpan(blueColorSpan, systemAvailableMemoryLabel.length(), systemAvailableMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ systemTotalMemoryStringBuilder.setSpan(blueColorSpan, systemTotalMemoryLabel.length(), systemTotalMemoryStringBuilder.length() - mebibyteLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+
+ // Display the string in the text boxes.
+ appConsumedMemoryTextView.setText(appConsumedMemoryStringBuilder);
+ appAvailableMemoryTextView.setText(appAvailableMemoryStringBuilder);
+ appTotalMemoryTextView.setText(appTotalMemoryStringBuilder);
+ appMaximumMemoryTextView.setText(appMaximumMemoryStringBuilder);
+ systemConsumedMemoryTextView.setText(systemConsumedMemoryStringBuilder);
+ systemAvailableMemoryTextView.setText(systemAvailableMemoryStringBuilder);
+ systemTotalMemoryTextView.setText(systemTotalMemoryStringBuilder);
+ }
+
+ // Schedule another memory update if the activity has not been destroyed.
+ if (!activity.isDestroyed()) {
+ // Create a handler to update the memory usage.
+ Handler updateMemoryUsageHandler = new Handler();
+
+ // Create a runnable to update the memory usage.
+ Runnable updateMemoryUsageRunnable = () -> updateMemoryUsage(activity);
+
+ // Update the memory usage after 1000 milliseconds
+ updateMemoryUsageHandler.postDelayed(updateMemoryUsageRunnable, 1000);
+ }
+ } catch (Exception exception) {
+ // Do nothing.
+ }
+ }
+
+ public String getAboutVersionString() {
+ // Initialize an about version string builder.
+ StringBuilder aboutVersionStringBuilder = new StringBuilder();
+
+ // Populate the about version string builder.
+ aboutVersionStringBuilder.append(privacyBrowserTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(versionTextView.getText());
+ aboutVersionStringBuilder.append("\n\n");
+ aboutVersionStringBuilder.append(hardwareTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(brandTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(manufacturerTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(modelTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(deviceTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(bootloaderTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ if (radioTextView.getVisibility() == View.VISIBLE) {
+ aboutVersionStringBuilder.append(radioTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ }
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(softwareTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(androidTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ if (securityPatchTextView.getVisibility() == View.VISIBLE) {
+ aboutVersionStringBuilder.append(securityPatchTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ }
+ aboutVersionStringBuilder.append(buildTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ if (webViewProviderTextView.getVisibility() == View.VISIBLE) {
+ aboutVersionStringBuilder.append(webViewProviderTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ }
+ aboutVersionStringBuilder.append(webViewVersionTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ if (orbotTextView.getVisibility() == View.VISIBLE) {
+ aboutVersionStringBuilder.append(orbotTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ }
+ if (i2pTextView.getVisibility() == View.VISIBLE) {
+ aboutVersionStringBuilder.append(i2pTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ }
+ if (openKeychainTextView.getVisibility() == View.VISIBLE) {
+ aboutVersionStringBuilder.append(openKeychainTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ }
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(memoryUsageTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(appConsumedMemoryTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(appAvailableMemoryTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(appTotalMemoryTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(appMaximumMemoryTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(systemConsumedMemoryTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(systemAvailableMemoryTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(systemTotalMemoryTextView.getText());
+ aboutVersionStringBuilder.append("\n\n");
+ aboutVersionStringBuilder.append(blocklistsTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(easyListTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(easyPrivacyTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(fanboyAnnoyanceTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(fanboySocialTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(ultraListTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(ultraPrivacyTextView.getText());
+ aboutVersionStringBuilder.append("\n\n");
+ aboutVersionStringBuilder.append(packageSignatureTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(certificateIssuerDnTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(certificateSubjectDnTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(certificateStartDateTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(certificateEndDateTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(certificateVersionTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(certificateSerialNumberTextView.getText());
+ aboutVersionStringBuilder.append("\n");
+ aboutVersionStringBuilder.append(certificateSignatureAlgorithmTextView.getText());
+
+ // Return the string.
+ return aboutVersionStringBuilder.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.fragments;
+
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+import com.stoutner.privacybrowser.R;
+
+public class AboutWebViewFragment extends Fragment {
+ // Declare the class constants.
+ final static String TAB_NUMBER = "tab_number";
+
+ // Declare the class variables.
+ private int tabNumber;
+
+ // Declare the class views.
+ private View aboutWebViewLayout;
+
+ public static AboutWebViewFragment createTab(int tabNumber) {
+ // Create an arguments bundle.
+ Bundle argumentsBundle = new Bundle();
+
+ // Store the arguments in the bundle.
+ argumentsBundle.putInt(TAB_NUMBER, tabNumber);
+
+ // Create a new instance of the tab fragment.
+ AboutWebViewFragment aboutWebViewFragment = new AboutWebViewFragment();
+
+ // Add the arguments bundle to the fragment.
+ aboutWebViewFragment.setArguments(argumentsBundle);
+
+ // Return the new fragment.
+ return aboutWebViewFragment;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ // Run the default commands.
+ super.onCreate(savedInstanceState);
+
+ // Get a handle for the arguments.
+ Bundle arguments = getArguments();
+
+ // Remove the incorrect lint warning below that arguments might be null.
+ assert arguments != null;
+
+ // Store the arguments in class variables.
+ tabNumber = arguments.getInt(TAB_NUMBER);
+ }
+
+ @Override
+ public View onCreateView(@NonNull LayoutInflater layoutInflater, ViewGroup container, Bundle savedInstanceState) {
+ // Get the current theme status.
+ int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+ // Inflate the layout. Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container. The fragment will take care of attaching the root automatically.
+ aboutWebViewLayout = layoutInflater.inflate(R.layout.bare_webview, container, false);
+
+ // Get a handle for tab WebView.
+ WebView tabWebView = (WebView) aboutWebViewLayout;
+
+ // Load the tabs according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { // The light theme is applied.
+ switch (tabNumber) {
+ case 1:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_permissions_light.html");
+ break;
+
+ case 2:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_privacy_policy_light.html");
+ break;
+
+ case 3:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_changelog_light.html");
+ break;
+
+ case 4:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_licenses_light.html");
+ break;
+
+ case 5:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_contributors_light.html");
+ break;
+
+ case 6:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_links_light.html");
+ break;
+ }
+ } else { // The dark theme is applied.
+ // Set the background color. The deprecated `.getColor()` must be used until the minimum API >= 23.
+ tabWebView.setBackgroundColor(getResources().getColor(R.color.gray_850));
+
+ // Tab numbers start at 0, with the WebView tabs starting at 1.
+ switch (tabNumber) {
+ case 1:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_permissions_dark.html");
+ break;
+
+ case 2:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_privacy_policy_dark.html");
+ break;
+
+ case 3:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_changelog_dark.html");
+ break;
+
+ case 4:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_licenses_dark.html");
+ break;
+
+ case 5:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_contributors_dark.html");
+ break;
+
+ case 6:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/about_links_dark.html");
+ break;
+ }
+ }
+
+ // Scroll the tab if the saved instance state is not null.
+ if (savedInstanceState != null) {
+ aboutWebViewLayout.post(() -> {
+ aboutWebViewLayout.setScrollX(savedInstanceState.getInt("scroll_x"));
+ aboutWebViewLayout.setScrollY(savedInstanceState.getInt("scroll_y"));
+ });
+ }
+
+ // Return the tab layout.
+ return aboutWebViewLayout;
+ }
+
+ @Override
+ public void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
+ // Run the default commands.
+ super.onSaveInstanceState(savedInstanceState);
+
+ // Save the scroll positions if the layout is not null, which can happen if a tab is not currently selected.
+ if (aboutWebViewLayout != null) {
+ savedInstanceState.putInt("scroll_x", aboutWebViewLayout.getScrollX());
+ savedInstanceState.putInt("scroll_y", aboutWebViewLayout.getScrollY());
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `image`. It is released under the Apache License 2.0. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true"
+ tools:ignore="VectorRaster" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FF616161"
+ android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z" />
+</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `image`. It is released under the Apache License 2.0. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true"
+ tools:ignore="VectorRaster" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FFE0E0E0"
+ android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z" />
+</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `chrome_reader_mode`. It is released under the Apache License 2.0. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true"
+ tools:ignore="VectorRaster" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FF1565C0"
+ android:pathData="M13,12h7v1.5h-7zM13,9.5h7L20,11h-7zM13,14.5h7L20,16h-7zM21,4L3,4c-1.1,0 -2,0.9 -2,2v13c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,6c0,-1.1 -0.9,-2 -2,-2zM21,19h-9L12,6h9v13z"/>
+</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `chrome_reader_mode`. It is released under the Apache License 2.0. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true"
+ tools:ignore="VectorRaster" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FF8AB4F8"
+ android:pathData="M13,12h7v1.5h-7zM13,9.5h7L20,11h-7zM13,14.5h7L20,16h-7zM21,4L3,4c-1.1,0 -2,0.9 -2,2v13c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,6c0,-1.1 -0.9,-2 -2,-2zM21,19h-9L12,6h9v13z"/>
+</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `chrome_reader_mode`. It is released under the Apache License 2.0. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true"
+ tools:ignore="VectorRaster" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FF616161"
+ android:pathData="M13,12h7v1.5h-7zM13,9.5h7L20,11h-7zM13,14.5h7L20,16h-7zM21,4L3,4c-1.1,0 -2,0.9 -2,2v13c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,6c0,-1.1 -0.9,-2 -2,-2zM21,19h-9L12,6h9v13z"/>
+</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `chrome_reader_mode`. It is released under the Apache License 2.0. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true"
+ tools:ignore="VectorRaster" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FFE0E0E0"
+ android:pathData="M13,12h7v1.5h-7zM13,9.5h7L20,11h-7zM13,14.5h7L20,16h-7zM21,4L3,4c-1.1,0 -2,0.9 -2,2v13c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,6c0,-1.1 -0.9,-2 -2,-2zM21,19h-9L12,6h9v13z"/>
+</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `image`. It is released under the Apache License 2.0. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true"
+ tools:ignore="VectorRaster" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FF616161"
+ android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
+</vector>
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `image`. It is released under the Apache License 2.0. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:autoMirrored="true"
+ tools:ignore="VectorRaster" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FFE0E0E0"
+ android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
+</vector>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- Copyright © 2016-2018,2020 Soren Stoutner <soren@stoutner.com>.
-
- This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
-
- Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>. -->
-
-<!-- The scroll view allows the linear layout to scroll if it exceeds the height of the page. -->
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_height="wrap_content"
- android:layout_width="match_parent" >
-
- <LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:orientation="vertical"
- android:padding="16dp" >
-
- <!-- The `RelativeLayout` contains the header. -->
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <!--`tools:ignore="RtlSymmetry"` suppressed the lint warning about adding `android:paddingStart`, which wouldn't work with this layout.
- `tools:ignore="ContentDescription"` suppresses the lint warning about supplying a content description for the image view,
- which isn't needed in this case because the image view is only decorative. -->
- <ImageView
- android:id="@+id/icon"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:src="@mipmap/privacy_browser"
- android:paddingTop="10dp"
- android:paddingEnd="5dp"
- tools:ignore="RtlSymmetry,ContentDescription" />
-
- <TextView
- android:id="@+id/privacy_browser_textview"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="@string/privacy_browser"
- android:textStyle="bold"
- android:textSize="22sp"
- android:textColor="?attr/blueTitleTextColor"
- android:paddingTop="12dp"
- android:layout_toEndOf="@id/icon" />
-
- <TextView
- android:id="@+id/version"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textColor="?attr/blueTextColor"
- android:textIsSelectable="true"
- android:layout_below="@id/privacy_browser_textview"
- android:layout_toEndOf="@id/icon" />
- </RelativeLayout>
-
- <!-- The purpose of this linear layout is to provide padding on the start of the text views to make them line up with `about_version_icon`.
- Although we don't need it, we have to include `android:paddingEnd` to make lint happy. -->
- <LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:orientation="vertical"
- android:paddingTop="16dp"
- android:paddingStart="4dp"
- android:paddingEnd="0dp" >
-
- <!-- Hardware. -->
- <TextView
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="@string/hardware"
- android:textStyle="bold"
- android:textSize="18sp"
- android:textColor="?attr/blueTitleTextColor" />
-
- <TextView
- android:id="@+id/brand"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/manufacturer"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/model"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/device"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/bootloader"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/radio"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <!-- Software. -->
- <TextView
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="@string/software"
- android:textStyle="bold"
- android:textSize="18sp"
- android:textColor="?attr/blueTitleTextColor"
- android:paddingTop="12dp" />
-
- <TextView
- android:id="@+id/android"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/security_patch"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/build"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/webview_provider"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/webview_version"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/orbot"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/i2p"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/open_keychain"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <!-- Memory usage. -->
- <TextView
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="@string/memory_usage"
- android:textStyle="bold"
- android:textSize="18sp"
- android:textColor="?attr/blueTitleTextColor"
- android:paddingTop="12dp" />
-
- <TextView
- android:id="@+id/app_consumed_memory"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/app_available_memory"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/app_total_memory"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/app_maximum_memory"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/system_consumed_memory"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/system_available_memory"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/system_total_memory"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <!-- Blocklists. -->
- <TextView
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="@string/blocklists"
- android:textStyle="bold"
- android:textSize="18sp"
- android:textColor="?attr/blueTitleTextColor"
- android:paddingTop="12dp" />
-
- <TextView
- android:id="@+id/easylist"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/easyprivacy"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/fanboy_annoyance"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/fanboy_social"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/ultralist"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/ultraprivacy"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <!-- Package Signature. -->
- <TextView
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="@string/package_signature"
- android:textStyle="bold"
- android:textSize="18sp"
- android:textColor="?attr/blueTitleTextColor"
- android:paddingTop="12dp" />
-
- <TextView
- android:id="@+id/certificate_issuer_dn"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/certificate_subject_dn"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/certificate_start_date"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/certificate_end_date"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/certificate_version"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/certificate_serial_number"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
-
- <TextView
- android:id="@+id/certificate_signature_algorithm"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textIsSelectable="true" />
- </LinearLayout>
- </LinearLayout>
-</ScrollView>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright © 2016-2018,2020 Soren Stoutner <soren@stoutner.com>.
+
+ This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+
+ Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>. -->
+
+<!-- The scroll view allows the linear layout to scroll if it exceeds the height of the page. -->
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent" >
+
+ <!-- The background needs to be specified here so that it appears if about version is saved as an image. -->
+ <LinearLayout
+ android:id="@+id/about_version_linearlayout"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ android:padding="16dp"
+ android:background="?android:attr/colorBackground" >
+
+ <!-- The `RelativeLayout` contains the header. -->
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <!--`tools:ignore="RtlSymmetry"` suppressed the lint warning about adding `android:paddingStart`, which wouldn't work with this layout.
+ `tools:ignore="ContentDescription"` suppresses the lint warning about supplying a content description for the image view,
+ which isn't needed in this case because the image view is only decorative. -->
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:src="@mipmap/privacy_browser"
+ android:paddingTop="10dp"
+ android:paddingEnd="5dp"
+ tools:ignore="RtlSymmetry,ContentDescription" />
+
+ <TextView
+ android:id="@+id/privacy_browser_textview"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/privacy_browser"
+ android:textStyle="bold"
+ android:textSize="22sp"
+ android:textColor="?attr/blueTitleTextColor"
+ android:paddingTop="12dp"
+ android:layout_toEndOf="@id/icon" />
+
+ <TextView
+ android:id="@+id/version"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textColor="?attr/blueTextColor"
+ android:textIsSelectable="true"
+ android:layout_below="@id/privacy_browser_textview"
+ android:layout_toEndOf="@id/icon" />
+ </RelativeLayout>
+
+ <!-- The purpose of this linear layout is to provide padding on the start of the text views to make them line up with `about_version_icon`.
+ Although we don't need it, we have to include `android:paddingEnd` to make lint happy. -->
+ <LinearLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ android:paddingTop="16dp"
+ android:paddingStart="4dp"
+ android:paddingEnd="0dp" >
+
+ <!-- Hardware. -->
+ <TextView
+ android:id="@+id/hardware"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/hardware"
+ android:textStyle="bold"
+ android:textSize="18sp"
+ android:textColor="?attr/blueTitleTextColor" />
+
+ <TextView
+ android:id="@+id/brand"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/manufacturer"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/model"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/device"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/bootloader"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/radio"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <!-- Software. -->
+ <TextView
+ android:id="@+id/software"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/software"
+ android:textStyle="bold"
+ android:textSize="18sp"
+ android:textColor="?attr/blueTitleTextColor"
+ android:paddingTop="12dp" />
+
+ <TextView
+ android:id="@+id/android"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/security_patch"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/build"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/webview_provider"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/webview_version"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/orbot"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/i2p"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/open_keychain"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <!-- Memory usage. -->
+ <TextView
+ android:id="@+id/memory_usage"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/memory_usage"
+ android:textStyle="bold"
+ android:textSize="18sp"
+ android:textColor="?attr/blueTitleTextColor"
+ android:paddingTop="12dp" />
+
+ <TextView
+ android:id="@+id/app_consumed_memory"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/app_available_memory"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/app_total_memory"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/app_maximum_memory"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/system_consumed_memory"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/system_available_memory"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/system_total_memory"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <!-- Blocklists. -->
+ <TextView
+ android:id="@+id/blocklists"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/blocklists"
+ android:textStyle="bold"
+ android:textSize="18sp"
+ android:textColor="?attr/blueTitleTextColor"
+ android:paddingTop="12dp" />
+
+ <TextView
+ android:id="@+id/easylist"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/easyprivacy"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/fanboy_annoyance"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/fanboy_social"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/ultralist"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/ultraprivacy"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <!-- Package Signature. -->
+ <TextView
+ android:id="@+id/package_signature"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/package_signature"
+ android:textStyle="bold"
+ android:textSize="18sp"
+ android:textColor="?attr/blueTitleTextColor"
+ android:paddingTop="12dp" />
+
+ <TextView
+ android:id="@+id/certificate_issuer_dn"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/certificate_subject_dn"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/certificate_start_date"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/certificate_end_date"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/certificate_version"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/certificate_serial_number"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+
+ <TextView
+ android:id="@+id/certificate_signature_algorithm"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textIsSelectable="true" />
+ </LinearLayout>
+ </LinearLayout>
+</ScrollView>
\ No newline at end of file
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp" >
- <!-- The text input layout makes the `android:hint` float above the edit text. -->
- <com.google.android.material.textfield.TextInputLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent">
-
- <!-- `android:inputType="TextUri"` disables spell check and places an `/` on the main keyboard. -->
- <com.google.android.material.textfield.TextInputEditText
- android:id="@+id/url_edittext"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:hint="@string/url"
- android:inputType="textMultiLine|textUri" />
- </com.google.android.material.textfield.TextInputLayout>
-
- <!-- File size. -->
- <TextView
- android:id="@+id/file_size_textview"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_marginEnd="3dp"
- android:layout_gravity="end" />
-
<!-- Align the edit text and the select file button horizontally. -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
- android:orientation="horizontal"
- android:layout_marginTop="5dp">
+ android:orientation="horizontal" >
<!-- The text input layout makes the `android:hint` float above the edit text. -->
<com.google.android.material.textfield.TextInputLayout
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
-
- This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
-
- Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>. -->
-
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="wrap_content"
- android:layout_width="match_parent" >
-
- <LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:orientation="vertical"
- android:layout_marginTop="10dp"
- android:layout_marginStart="10dp"
- android:layout_marginEnd="10dp" >
-
- <!-- Align the edit text and the select file button horizontally. -->
- <LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:orientation="horizontal" >
-
- <!-- The text input layout makes the `android:hint` float above the edit text. -->
- <com.google.android.material.textfield.TextInputLayout
- android:layout_height="wrap_content"
- android:layout_width="0dp"
- android:layout_weight="1" >
-
- <!-- `android:inputType="textUri"` disables spell check and places an `/` on the main keyboard. -->
- <com.google.android.material.textfield.TextInputEditText
- android:id="@+id/file_name_edittext"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:hint="@string/file_name"
- android:inputType="textMultiLine|textUri" />
- </com.google.android.material.textfield.TextInputLayout>
-
- <Button
- android:id="@+id/browse_button"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_gravity="center_vertical"
- android:text="@string/browse" />
- </LinearLayout>
-
- <!-- File already exists warning. -->
- <TextView
- android:id="@+id/file_exists_warning_textview"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_gravity="center_horizontal"
- android:layout_margin="5dp"
- android:text="@string/file_exists_warning"
- android:textColor="?attr/redTextColor"
- android:textAlignment="center" />
-
- <!-- Storage permission explanation. -->
- <TextView
- android:id="@+id/storage_permission_textview"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_gravity="center_horizontal"
- android:text="@string/storage_permission_explanation"
- android:textAlignment="center" />
- </LinearLayout>
-</ScrollView>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
+
+ This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+
+ Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>. -->
+
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent" >
+
+ <LinearLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="10dp"
+ android:layout_marginStart="10dp"
+ android:layout_marginEnd="10dp" >
+
+ <!-- The text input layout makes the `android:hint` float above the edit text. -->
+ <com.google.android.material.textfield.TextInputLayout
+ android:id="@+id/url_textinputlayout"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent" >
+
+ <!-- `android:inputType="TextUri"` disables spell check and places an `/` on the main keyboard. -->
+ <com.google.android.material.textfield.TextInputEditText
+ android:id="@+id/url_edittext"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:hint="@string/url"
+ android:inputType="textMultiLine|textUri" />
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <!-- File size. -->
+ <TextView
+ android:id="@+id/file_size_textview"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_marginEnd="3dp"
+ android:layout_marginBottom="5dp"
+ android:layout_gravity="end" />
+
+ <!-- Align the edit text and the select file button horizontally. -->
+ <LinearLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:orientation="horizontal" >
+
+ <!-- The text input layout makes the `android:hint` float above the edit text. -->
+ <com.google.android.material.textfield.TextInputLayout
+ android:layout_height="wrap_content"
+ android:layout_width="0dp"
+ android:layout_weight="1" >
+
+ <!-- `android:inputType="textUri"` disables spell check and places an `/` on the main keyboard. -->
+ <com.google.android.material.textfield.TextInputEditText
+ android:id="@+id/file_name_edittext"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:hint="@string/file_name"
+ android:inputType="textMultiLine|textUri" />
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <Button
+ android:id="@+id/browse_button"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:text="@string/browse" />
+ </LinearLayout>
+
+ <!-- File already exists warning. -->
+ <TextView
+ android:id="@+id/file_exists_warning_textview"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_margin="5dp"
+ android:text="@string/file_exists_warning"
+ android:textColor="?attr/redTextColor"
+ android:textAlignment="center" />
+
+ <!-- Storage permission explanation. -->
+ <TextView
+ android:id="@+id/storage_permission_textview"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:text="@string/storage_permission_explanation"
+ android:textAlignment="center" />
+ </LinearLayout>
+</ScrollView>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright © 2020 Soren Stoutner <soren@stoutner.com>.
+
+ This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+
+ Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>. -->
+
+<menu
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <!-- `android:iconTint` can be used once the minimum API >= 26 instead of including a separate drawable for each theme. -->
+ <item
+ android:id="@+id/copy"
+ android:title="@string/copy_string"
+ android:orderInCategory="10"
+ android:icon="?attr/copyIcon"
+ app:showAsAction="ifRoom" />
+
+ <!-- `android:iconTint` can be used once the minimum API >= 26 instead of including a separate drawable for each theme. -->
+ <item
+ android:id="@+id/share"
+ android:title="@string/share"
+ android:orderInCategory="20"
+ android:icon="?attr/shareIcon"
+ app:showAsAction="ifRoom" />
+
+ <!-- `android:iconTint` can be used once the minimum API >= 26 instead of including a separate drawable for each theme. -->
+ <item
+ android:id="@+id/save_text"
+ android:title="@string/save_text"
+ android:orderInCategory="30"
+ android:icon="?attr/saveTextIcon"
+ app:showAsAction="ifRoom" />
+
+ <!-- `android:iconTint` can be used once the minimum API >= 26 instead of including a separate drawable for each theme. -->
+ <item
+ android:id="@+id/save_image"
+ android:title="@string/save_image"
+ android:orderInCategory="40"
+ android:icon="?attr/saveImageIcon"
+ app:showAsAction="ifRoom" />
+</menu>
\ No newline at end of file
android:orderInCategory="1201"
app:showAsAction="never" />
<item
- android:id="@+id/save_as_archive"
- android:title="@string/save_as_archive"
+ android:id="@+id/save_archive"
+ android:title="@string/save_archive"
android:orderInCategory="1202"
app:showAsAction="never" />
<item
- android:id="@+id/save_as_image"
- android:title="@string/save_as_image"
+ android:id="@+id/save_image"
+ android:title="@string/save_image"
android:orderInCategory="1203"
app:showAsAction="never" />
</menu>
<string name="swipe_to_refresh_options_menu">Herunterziehen zum aktualisieren</string>
<string name="wide_viewport">Breiter Anzeigebereich</string>
<string name="display_images">Bilder anzeigen</string>
+ <string name="dark_webview">Dark WebView</string>
<string name="font_size">Schriftgröße</string>
<string name="find_on_page">Auf Seite finden</string>
<string name="print">Drucken</string>
<string name="privacy_browser_web_page">Privacy Browser-Website</string>
<string name="save">Speichern</string>
- <string name="save_url">URL speichern</string>
- <string name="save_as_archive">Als Archiv speichern</string>
- <string name="save_as_image">Als Grafik speichern</string>
<string name="view_source">Quelltext anzeigen</string>
<string name="add_to_home_screen">Zur Startseite hinzufügen</string>
<string name="share">Teilen</string>
<string name="previous">Vorheriges</string>
<string name="next">Nächstes</string>
- <!-- Save. -->
- <string name="file_name">Dateiname</string>
+ <!-- Save Dialogs. -->
+ <string name="save_url">URL speichern</string>
<string name="save_archive">Archiv speichern</string>
<string name="save_image">Grafik speichern</string>
+ <string name="save_logcat">Logcat speichern</string>
+ <string name="file_name">Dateiname</string>
<string name="webpage_mht">Webseite.mht</string>
<string name="webpage_png">Webseite.png</string>
+ <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
<string name="file">Datei</string>
<string name="bytes">Bytes</string>
<string name="unknown_size">Unbekannte Größe</string>
<string name="invalid_url">Ungültige URL</string>
<string name="ok">OK</string>
<string name="saving_file">Speichere Datei:</string>
- <string name="saving_image">Speichere Grafik…</string>
<string name="file_saved">Datei gespeichert:</string>
- <string name="image_saved">Grafik gespeichert.</string>
<string name="error_saving_file">Fehler beim Speichern der Datei:</string>
- <string name="error_saving_image">Fehler beim Speichern der Grafik:</string>
<!-- View Source. -->
<string name="request_headers">Anfragekopfzeilen</string>
<string name="copy_string">kopieren</string> <!-- `copy` is a reserved word and should not be used as the name. -->
<string name="logcat_copied">Logcat kopiert.</string>
<string name="clear">leeren</string>
- <string name="save_logcat">Logcat speichern</string>
- <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
- <string name="file_saved_successfully">Datei erfolgreich gespeichert.</string>
- <string name="save_failed">Speichern fehlgeschlagen:</string>
<!-- Guide. -->
<string name="overview">Übersicht</string>
<string name="orbot">Orbot:</string>
<string name="i2p">I2P:</string>
<string name="openkeychain">OpenKeychain:</string>
+ <string name="memory_usage">Speicher-Nutzung</string>
+ <string name="app_consumed_memory">von der App genutzter Speicher:</string>
+ <string name="app_available_memory">für die App verfügbarer Speicher:</string>
+ <string name="app_total_memory">gesamter App-Speicher:</string>
+ <string name="app_maximum_memory">maximaler App-Speicher:</string>
+ <string name="system_consumed_memory">vom System genutzter Speicher:</string>
+ <string name="system_available_memory">für das System verfügbarer Speicher:</string>
+ <string name="system_total_memory">gesamter System-Speicher:</string>
+ <string name="mebibyte">MiB</string>
<string name="easylist_label">EasyList:</string>
<string name="easyprivacy_label">EasyPrivacy:</string>
<string name="fanboy_annoyance_label">Fanboy’s Annoyance Sperrliste:</string>
<string name="swipe_to_refresh_options_menu">Deslizar para actualizar</string>
<string name="wide_viewport">Vista amplia</string>
<string name="display_images">Mostrar imágenes</string>
+ <string name="dark_webview">WebView oscuro</string>
<string name="font_size">Tamaño de fuente</string>
<string name="find_on_page">Buscar en página</string>
<string name="print">Imprimir</string>
<string name="privacy_browser_web_page">Página web de Navegador Privado</string>
<string name="save">Guardar</string>
- <string name="save_url">Guardar URL</string>
- <string name="save_as_archive">Guardar como archivo</string>
- <string name="save_as_image">Guardar como imagen</string>
<string name="add_to_home_screen">Añadir a la ventana de inicio</string>
<string name="view_source">Ver la fuente</string>
<string name="share">Compartir</string>
<string name="previous">Anterior</string>
<string name="next">Siguiente</string>
- <!-- Save. -->
- <string name="file_name">Nombre de archivo</string>
+ <!-- Save Dialogs. -->
+ <string name="save_url">Guardar URL</string>
<string name="save_archive">Guardar archivo</string>
<string name="save_image">Guardar imagen</string>
+ <string name="save_logcat">Guardar logcat</string>
+ <string name="file_name">Nombre de archivo</string>
<string name="webpage_mht">PaginaWeb.mht</string>
<string name="webpage_png">PaginaWeb.png</string>
+ <string name="privacy_browser_logcat_txt">Navegador Privado Logcat.txt</string>
<string name="file">Archivo</string>
<string name="bytes">bytes</string>
<string name="unknown_size">Tamaño desconocido</string>
<string name="invalid_url">URL inválida</string>
<string name="ok">OK</string>
<string name="saving_file">Guardando archivo:</string>
- <string name="saving_image">Guardando imagen…</string>
<string name="file_saved">Archivo guardado:</string>
- <string name="image_saved">Imagen guardada.</string>
<string name="error_saving_file">Error guardando archivo:</string>
- <string name="error_saving_image">Error guardando imagen:</string>
<!-- View Source. -->
<string name="request_headers">Cabeceras de solicitud</string>
<string name="copy_string">Copiar</string> <!-- `copy` is a reserved word and should not be used as the name. -->
<string name="logcat_copied">Logcat copiado.</string>
<string name="clear">Borrar</string>
- <string name="save_logcat">Guardar logcat</string>
- <string name="privacy_browser_logcat_txt">Navegador Privado Logcat.txt</string>
- <string name="file_saved_successfully">Archivo guardado con éxito.</string>
- <string name="save_failed">Error al guardar:</string>
<!-- Guide. -->
<string name="overview">Visión general</string>
<string name="orbot">Orbot:</string>
<string name="i2p">I2P:</string>
<string name="openkeychain">OpenKeychain:</string>
+ <string name="memory_usage">Uso de memoria</string>
+ <string name="app_consumed_memory">Memoria conumida de la app:</string>
+ <string name="app_available_memory">Memoria disponible de la app:</string>
+ <string name="app_total_memory">Memoria total de la app:</string>
+ <string name="app_maximum_memory">Memoria máxima de la app:</string>
+ <string name="system_consumed_memory">Memoria consumida del sistema:</string>
+ <string name="system_available_memory">Memoria disponible del sistema:</string>
+ <string name="system_total_memory">Memoria total del sistema:</string>
+ <string name="mebibyte">MiB</string>
<string name="easylist_label">EasyList:</string>
<string name="easyprivacy_label">EasyPrivacy:</string>
<string name="fanboy_annoyance_label">Lista molesta de Fanboy:</string>
<string name="print">Imprimer</string>
<string name="privacy_browser_web_page">Site Web de Privacy Browser</string>
<string name="save">Sauvegarder</string>
- <string name="save_url">Enregistrer l\'URL</string>
- <string name="save_as_archive">Enregistrer en tant qu\'archive</string>
- <string name="save_as_image">Sauvergarder comme image</string>
<string name="add_to_home_screen">Ajouter à l\'écran d\'accueil</string>
<string name="view_source">Voir Source</string>
<string name="share">Partager</string>
<string name="previous">Précédent</string>
<string name="next">Suivant</string>
- <!-- Save. -->
- <string name="file_name">Nom du fichier</string>
+ <!-- Save Dialogs. -->
+ <string name="save_url">Enregistrer l\'URL</string>
<string name="save_archive">Enregistrer l\'archive</string>
<string name="save_image">Sauvegarder en tant qu\'image</string>
+ <string name="save_logcat">Sauvegarder le journal système</string>
+ <string name="file_name">Nom du fichier</string>
<string name="webpage_mht">PageWeb.mht</string>
<string name="webpage_png">PageWeb.png</string>
+ <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
<string name="file">Fichier</string>
<string name="bytes">octets</string>
<string name="unknown_size">taille inconnue</string>
<string name="invalid_url">URL invalide</string>
<string name="ok">OK</string>
<string name="saving_file">Enregistrement du fichier:</string>
- <string name="saving_image">Sauvegarde en cours…</string>
<string name="file_saved">Fichier enregistré:</string>
- <string name="image_saved">Image sauvegardée.</string>
<string name="error_saving_file">Erreur lors de l\'enregistrement du fichier:</string>
- <string name="error_saving_image">Erreur durant la sauvegarde :</string>
<!-- View Source. -->
<string name="request_headers">En-tête de la requête</string>
<string name="copy_string">Copie</string> <!-- `copy` is a reserved word and should not be used as the name. -->
<string name="logcat_copied">Journal système copié.</string>
<string name="clear">Vider</string>
- <string name="save_logcat">Sauvegarder le journal système</string>
- <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
- <string name="file_saved_successfully">Fichier sauvegardé avec succès.</string>
- <string name="save_failed">Echec de sauvegarde :</string>
<!-- Guide. -->
<string name="overview">Présentation</string>
<string name="swipe_to_refresh_options_menu">Swipe per aggiornare</string>
<string name="wide_viewport">Finestra grande</string>
<string name="display_images">Mostra immagini</string>
+ <string name="dark_webview">Dark WebView</string>
<string name="font_size">Dimensione font</string>
<string name="find_on_page">Cerca nella pagina</string>
<string name="print">Stampa</string>
<string name="privacy_browser_web_page">Pagina web di Privacy Browser</string>
<string name="save">Salva</string>
- <string name="save_url">Salva URL</string>
- <string name="save_as_archive">Salva come Archivio</string>
- <string name="save_as_image">Salva come Immagine</string>
<string name="add_to_home_screen">Aggiungi collegamento</string>
<string name="view_source">Visualizza sorgente</string>
<string name="share">Condividi</string>
<string name="previous">Precedente</string>
<string name="next">Successivo</string>
- <!-- Save. -->
- <string name="file_name">Nome File</string>
+ <!-- Save Dialogs. -->
+ <string name="save_url">Salva URL</string>
<string name="save_archive">Salva Archivio</string>
<string name="save_image">Salva Immagine</string>
+ <string name="save_logcat">Salva il log</string>
+ <string name="file_name">Nome File</string>
<string name="webpage_mht">PaginaWeb.mht</string>
<string name="webpage_png">PaginaWeb.png</string>
+ <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
<string name="file">File</string>
<string name="bytes">byte</string>
<string name="unknown_size">Dimensione sconosciuta</string>
<string name="invalid_url">URL non valida</string>
<string name="ok">OK</string>
<string name="saving_file">Salvataggio file:</string>
- <string name="saving_image">Salvataggio immagine…</string>
<string name="file_saved">File salvato:</string>
- <string name="image_saved">Immagine salvata.</string>
<string name="error_saving_file">Errore salvataggio file:</string>
- <string name="error_saving_image">Errore nel salvare l\'immagine:</string>
<!-- View Source. -->
<string name="request_headers">Richiesta Intestazioni</string>
<string name="copy_string">Copia</string> <!-- `copy` is a reserved word and should not be used as the name. -->
<string name="logcat_copied">Logcat copiato.</string>
<string name="clear">Cancella</string>
- <string name="save_logcat">Salva il log</string>
- <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
- <string name="file_saved_successfully">File salvato.</string>
- <string name="save_failed">Errore di salvataggio:</string>
<!-- Guide. -->
<string name="overview">Descrizione</string>
<string name="orbot">Orbot:</string>
<string name="i2p">I2P:</string>
<string name="openkeychain">OpenKeychain:</string>
+ <string name="memory_usage">Utilizzo della Memoria</string>
+ <string name="app_consumed_memory">Memoria utilizzata dalla App:</string>
+ <string name="app_available_memory">Memoria disponibile App:</string>
+ <string name="app_total_memory">Memoria totale App:</string>
+ <string name="app_maximum_memory">Memoria massima App:</string>
+ <string name="system_consumed_memory">Memoria di sistema utilizzata:</string>
+ <string name="system_available_memory">Memoria di sistema disponibile:</string>
+ <string name="system_total_memory">Memoria totale del sistema:</string>
+ <string name="mebibyte">MiB</string>
<string name="easylist_label">EasyList:</string>
<string name="easyprivacy_label">EasyPrivacy:</string>
<string name="fanboy_annoyance_label">Fanboy’s Annoyance List:</string>
<item name="editIcon">@drawable/edit_night</item>
<item name="moveToFolderIcon">@drawable/move_to_folder_night</item>
<item name="saveIcon">@drawable/save_night</item>
+ <item name="saveImageIcon">@drawable/images_options_night</item>
+ <item name="saveTextIcon">@drawable/save_text_night</item>
<item name="selectAllIcon">@drawable/select_all_night</item>
+ <item name="shareIcon">@drawable/share_night</item>
<item name="sortIcon">@drawable/sort_night</item>
</style>
<item name="editIcon">@drawable/edit_night</item>
<item name="moveToFolderIcon">@drawable/move_to_folder_night</item>
<item name="saveIcon">@drawable/save_night</item>
+ <item name="saveImageIcon">@drawable/images_options_night</item>
+ <item name="saveTextIcon">@drawable/save_text_night</item>
<item name="selectAllIcon">@drawable/select_all_night</item>
+ <item name="shareIcon">@drawable/share_night</item>
<item name="sortIcon">@drawable/sort_night</item>
</style>
<item name="editIcon">@drawable/edit_night</item>
<item name="moveToFolderIcon">@drawable/move_to_folder_night</item>
<item name="saveIcon">@drawable/save_night</item>
+ <item name="saveImageIcon">@drawable/images_options_night</item>
+ <item name="saveTextIcon">@drawable/save_text_night</item>
<item name="selectAllIcon">@drawable/select_all_night</item>
+ <item name="shareIcon">@drawable/share_night</item>
<item name="sortIcon">@drawable/sort_night</item>
</style>
<!-- Loading Blocklists. -->
<string name="loading_easylist">Carregando EasyList</string>
<string name="loading_easyprivacy">Carregando EasyPrivacy</string>
- <string name="loading_fanboys_annoyance_list">Carregando Fanboy’s Annoyance List</string>
- <string name="loading_fanboys_social_blocking_list">Carregando Fanboy’s Social Blocking List</string>
+ <string name="loading_fanboys_annoyance_list">Carregando Fanboy’s Annoyance List</string>
+ <string name="loading_fanboys_social_blocking_list">Carregando Fanboy’s Social Blocking List</string>
<string name="loading_ultralist">Carregando UltraList</string>
<string name="loading_ultraprivacy">Carregando UltraPrivacy</string>
<string name="back">Fim</string>
<string name="forward">Avançar</string>
<string name="history">Histórico</string>
- <string name="clear_history">Limpar Histórico</string>
+ <string name="clear_history">Limpar Histórico</string>
<string name="open">Abrir</string>
<string name="downloads">Downloads</string>
<string name="settings">Configurações</string>
<string name="dom_storage">Armazenamento DOM</string>
<string name="form_data">Dados do formulário</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
<string name="clear_data">Limpar dados</string>
- <string name="clear_cookies">Limpar Cookies</string>
- <string name="clear_dom_storage">limpar Armazenamento DOM</string>
- <string name="clear_form_data">Clear Form Data</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
- <string name="options_fanboys_annoyance_list">Lista de Aborrecimento Fanboy’s</string>
- <string name="options_fanboys_social_blocking_list">Lista de bloqueio social Fanboy’s</string>
- <string name="options_block_all_third_party_requests">Bloquear todas as solicitações de terceiros</string>
+ <string name="clear_cookies">Limpar Cookies</string>
+ <string name="clear_dom_storage">Limpar Armazenamento DOM</string>
+ <string name="clear_form_data">Clear Form Data</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
+ <string name="options_fanboys_annoyance_list">Lista de Aborrecimento Fanboy’s</string>
+ <string name="options_fanboys_social_blocking_list">Lista de bloqueio social Fanboy’s</string>
+ <string name="options_block_all_third_party_requests">Bloquear todas as solicitações de terceiros</string>
<string name="page">Página</string>
- <string name="options_user_agent">User Agent</string>
- <string name="user_agent_privacy_browser">Privacy Browser</string>
- <string name="user_agent_webview_default">WebView Default</string>
- <string name="user_agent_firefox_on_android">Firefox para Android</string>
- <string name="user_agent_chrome_on_android">Chrome para Android</string>
- <string name="user_agent_safari_on_ios">Safari para iOS</string>
- <string name="user_agent_firefox_on_linux">Firefox para Linux</string>
- <string name="user_agent_chromium_on_linux">Chromium para Linux</string>
- <string name="user_agent_firefox_on_windows">Firefox para Windows</string>
- <string name="user_agent_chrome_on_windows">Chrome para Windows</string>
- <string name="user_agent_edge_on_windows">Edge para Windows</string>
- <string name="user_agent_internet_explorer_on_windows">Internet Explorer para Windows</string>
- <string name="user_agent_safari_on_macos">Safari para macOS</string>
- <string name="user_agent_custom">Personalizado</string>
- <string name="swipe_to_refresh_options_menu">Deslize para atualizar</string>
- <string name="wide_viewport">Janela ampliada</string>
- <string name="display_images">Exibir imagens</string>
- <string name="dark_webview">Dark WebView</string>
- <string name="font_size">Tamanho da Fonte</string>
- <string name="find_on_page">Procurar</string>
- <string name="print">Imprimir</string>
- <string name="privacy_browser_web_page">Página da Web do Privacy Browser</string>
- <string name="save">Salvar</string>
- <string name="save_url">Salvar URL</string>
- <string name="save_as_archive">Salvar como arquivo</string>
- <string name="save_as_image">Salvar como imagem</string>
- <string name="add_to_home_screen">Adicionar à tela inicial</string>
- <string name="view_source">Ver fonte</string>
+ <string name="options_user_agent">User Agent</string>
+ <string name="user_agent_privacy_browser">Privacy Browser</string>
+ <string name="user_agent_webview_default">WebView Default</string>
+ <string name="user_agent_firefox_on_android">Firefox para Android</string>
+ <string name="user_agent_chrome_on_android">Chrome para Android</string>
+ <string name="user_agent_safari_on_ios">Safari para iOS</string>
+ <string name="user_agent_firefox_on_linux">Firefox para Linux</string>
+ <string name="user_agent_chromium_on_linux">Chromium para Linux</string>
+ <string name="user_agent_firefox_on_windows">Firefox para Windows</string>
+ <string name="user_agent_chrome_on_windows">Chrome para Windows</string>
+ <string name="user_agent_edge_on_windows">Edge para Windows</string>
+ <string name="user_agent_internet_explorer_on_windows">Internet Explorer para Windows</string>
+ <string name="user_agent_safari_on_macos">Safari para macOS</string>
+ <string name="user_agent_custom">Personalizado</string>
+ <string name="swipe_to_refresh_options_menu">Deslize para atualizar</string>
+ <string name="wide_viewport">Janela ampliada</string>
+ <string name="display_images">Exibir imagens</string>
+ <string name="dark_webview">Dark WebView</string>
+ <string name="font_size">Tamanho da Fonte</string>
+ <string name="find_on_page">Procurar</string>
+ <string name="print">Imprimir</string>
+ <string name="privacy_browser_web_page">Página da Web do Privacy Browser</string>
+ <string name="save">Salvar</string>
+ <string name="add_to_home_screen">Adicionar à tela inicial</string>
+ <string name="view_source">Ver fonte</string>
<string name="share">Compartilhar</string>
- <string name="share_url">Compartilhar URL</string>
- <string name="open_with_app">Abrir com aplicativo</string>
- <string name="open_with_browser">Abrir com navegador</string>
+ <string name="share_url">Compartilhar URL</string>
+ <string name="open_with_app">Abrir com aplicativo</string>
+ <string name="open_with_browser">Abrir com navegador</string>
<string name="add_domain_settings">Adicionar configurações de domínio</string>
<string name="edit_domain_settings">Editar configurações de domínio</string>
<string name="previous">Anterior</string>
<string name="next">Próximo</string>
- <!-- Save. -->
- <string name="file_name">Nome do Arquivo</string>
+ <!-- Save Dialogs. -->
+ <string name="save_url">Salvar URL</string>
<string name="save_archive">Salvar Arquivo</string>
<string name="save_image">Salvar Imagem</string>
+ <string name="save_logcat">Salvar logcat</string>
+ <string name="file_name">Nome do Arquivo</string>
<string name="webpage_mht">Pagina_Web.mht</string>
<string name="webpage_png">Pagina_Web.png</string>
+ <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
<string name="file">Arquivo</string>
<string name="bytes">bytes</string>
<string name="unknown_size">tamanho desconhecido</string>
<string name="invalid_url">URL inválida</string>
<string name="ok">OK</string>
<string name="saving_file">Salvando file:</string>
- <string name="saving_image">Salvando imagem:</string>
<string name="file_saved">Arquivo Salvo:</string>
- <string name="image_saved">Imagem salva.</string>
<string name="error_saving_file">Erro ao salvar o arquivo:</string>
- <string name="error_saving_image">Erro ao salvar a imagem:</string>
<!-- View Source. -->
<string name="request_headers">Solicitar cabeçalhos</string>
<string name="all_folders">Todas as pastas</string>
<string name="home_folder">Pasta Pessoal</string>
<string name="sort">Ordenar</string>
- <string name="sorted_by_database_id">Ordenado por ID de banco de dados.</string>
- <string name="sorted_by_display_order">Ordenado por ordem de exibição.</string>
+ <string name="sorted_by_database_id">Ordenado por ID de banco de dados.</string>
+ <string name="sorted_by_display_order">Ordenado por ordem de exibição.</string>
<string name="database_id">ID de banco de dados:</string>
<string name="folder">Pasta:</string>
<string name="parent_folder">Pasta Superior:</string>
<string name="requests">Solicitações</string>
<string name="request_details">Solicitar Detalhes</string>
<string name="disposition">Disposição</string>
- <string name="all">Tudo</string>
- <string name="default_label">Padrão</string>
- <string name="default_allowed">Padrão - Permitido</string>
- <string name="allowed">Permitido</string>
- <string name="allowed_plural">Permitido</string>
- <string name="third_party_plural">Terceiros</string>
- <string name="third_party_blocked">Terceiros - Bloqueados</string>
- <string name="blocked">Bloqueado</string>
- <string name="blocked_plural">Bloqueados</string>
+ <string name="all">Tudo</string>
+ <string name="default_label">Padrão</string>
+ <string name="default_allowed">Padrão - Permitido</string>
+ <string name="allowed">Permitido</string>
+ <string name="allowed_plural">Permitido</string>
+ <string name="third_party_plural">Terceiros</string>
+ <string name="third_party_blocked">Terceiros - Bloqueados</string>
+ <string name="blocked">Bloqueado</string>
+ <string name="blocked_plural">Bloqueados</string>
<string name="blocklist">Lista de bloqueios</string>
- <string name="sublist">Sublista</string>
- <string name="main_whitelist">Lista branca principal</string>
- <string name="final_whitelist">Lista de permissões final</string>
- <string name="domain_whitelist">Lista de permissões de domínio</string>
- <string name="domain_initial_whitelist">Lista de permissões inicial do domínio</string>
- <string name="domain_final_whitelist">Lista de permissões final de domínio</string>
- <string name="third_party_whitelist">Lista de permissões de terceiros</string>
- <string name="third_party_domain_whitelist">Lista de permissões de domínio de terceiros</string>
- <string name="third_party_domain_initial_whitelist">Lista de permissões inicial de domínio de terceiros</string>
- <string name="main_blacklist">Lista negra principal</string>
- <string name="initial_blacklist">Lista negra inicial</string>
- <string name="final_blacklist">Lista negra final</string>
- <string name="domain_blacklist">Lista negra de domínio</string>
- <string name="domain_initial_blacklist">Lista negra inicial do domínio</string>
- <string name="domain_final_blacklist">Lista negra final do domínio</string>
- <string name="domain_regular_expression_blacklist">Lista negra de expressões regulares de domínio</string>
- <string name="third_party_blacklist">Lista negra de terceiros</string>
- <string name="third_party_initial_blacklist">Lista negra inicial de terceiros</string>
- <string name="third_party_domain_blacklist">Lista negra de domínios de terceiros</string>
- <string name="third_party_domain_initial_blacklist">Lista negra inicial de domínios de terceiros</string>
- <string name="third_party_regular_expression_blacklist">Lista negra de expressões regulares de terceiros</string>
- <string name="third_party_domain_regular_expression_blacklist">Lista negra de expressões regulares de domínios de terceiros</string>
- <string name="regular_expression_blacklist">Lista negra de expressões regulares</string>
+ <string name="sublist">Sublista</string>
+ <string name="main_whitelist">Lista branca principal</string>
+ <string name="final_whitelist">Lista de permissões final</string>
+ <string name="domain_whitelist">Lista de permissões de domínio</string>
+ <string name="domain_initial_whitelist">Lista de permissões inicial do domínio</string>
+ <string name="domain_final_whitelist">Lista de permissões final de domínio</string>
+ <string name="third_party_whitelist">Lista de permissões de terceiros</string>
+ <string name="third_party_domain_whitelist">Lista de permissões de domínio de terceiros</string>
+ <string name="third_party_domain_initial_whitelist">Lista de permissões inicial de domínio de terceiros</string>
+ <string name="main_blacklist">Lista negra principal</string>
+ <string name="initial_blacklist">Lista negra inicial</string>
+ <string name="final_blacklist">Lista negra final</string>
+ <string name="domain_blacklist">Lista negra de domínio</string>
+ <string name="domain_initial_blacklist">Lista negra inicial do domínio</string>
+ <string name="domain_final_blacklist">Lista negra final do domínio</string>
+ <string name="domain_regular_expression_blacklist">Lista negra de expressões regulares de domínio</string>
+ <string name="third_party_blacklist">Lista negra de terceiros</string>
+ <string name="third_party_initial_blacklist">Lista negra inicial de terceiros</string>
+ <string name="third_party_domain_blacklist">Lista negra de domínios de terceiros</string>
+ <string name="third_party_domain_initial_blacklist">Lista negra inicial de domínios de terceiros</string>
+ <string name="third_party_regular_expression_blacklist">Lista negra de expressões regulares de terceiros</string>
+ <string name="third_party_domain_regular_expression_blacklist">Lista negra de expressões regulares de domínios de terceiros</string>
+ <string name="regular_expression_blacklist">Lista negra de expressões regulares</string>
<string name="blocklist_entries">Entradas da lista de bloqueio</string>
<string name="blocklist_original_entry">Entrada original da lista de bloqueio</string>
<item>Imagens desabilitadas</item>
</string-array>
<string name="pinned_ssl_certificate">Certificado SSL fixado</string>
- <string name="saved_ssl_certificate">Certificado SSL salvo</string>
- <string name="current_website_ssl_certificate">Certificado SSL do site atual</string>
- <string name="load_an_encrypted_website">Carregue um site criptografado antes de abrir as configurações de domínio para preencher o certificado SSL do site atual.</string>
+ <string name="saved_ssl_certificate">Certificado SSL salvo</string>
+ <string name="current_website_ssl_certificate">Certificado SSL do site atual</string>
+ <string name="load_an_encrypted_website">Carregue um site criptografado antes de abrir as configurações de domínio para preencher o certificado SSL do site atual.</string>
<string name="pinned_ip_addresses">Endereços IP fixados</string>
- <string name="saved_ip_addresses">Endereços IP salvos</string>
- <string name="current_ip_addresses">Endereços IP atuais</string>
+ <string name="saved_ip_addresses">Endereços IP salvos</string>
+ <string name="current_ip_addresses">Endereços IP atuais</string>
<!-- Import/Export. -->
<string name="encryption">Encriptação</string>
<string name="copy_string">Cópia</string> <!-- `copy` is a reserved word and should not be used as the name. -->
<string name="logcat_copied">Logcat copiado.</string>
<string name="clear">Limpar</string>
- <string name="save_logcat">Salvar logcat</string>
- <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
- <string name="file_saved_successfully">Arquivo salvo com sucesso.</string>
- <string name="save_failed">Falha ao salvar:</string>
<!-- Guide. -->
<string name="overview">Visão geral</string>
<string name="orbot">Orbot:</string>
<string name="i2p">I2P:</string>
<string name="openkeychain">OpenKeychain:</string>
+ <string name="memory_usage">Uso da Memória</string>
+ <string name="app_consumed_memory">Consumo da Memória do Aplicativo:</string>
+ <string name="app_available_memory">Memória Disponível do Aplicativo:</string>
+ <string name="app_total_memory">Memória Total do Aplicativo:</string>
+ <string name="app_maximum_memory">Memória Máxima do Aplicativo:</string>
+ <string name="system_consumed_memory">Memória Consumida do Sistema:</string>
+ <string name="system_available_memory">Memória Disponível do Sistema:</string>
+ <string name="system_total_memory">Memória Total do Sistema:</string>
+ <string name="mebibyte">MiB</string>
<string name="easylist_label">EasyList:</string>
<string name="easyprivacy_label">EasyPrivacy:</string>
- <string name="fanboy_annoyance_label">Fanboy’s Annoyance List:</string>
- <string name="fanboy_social_label">Fanboy’s Social Blocking List:</string>
+ <string name="fanboy_annoyance_label">Fanboy’s Annoyance List:</string>
+ <string name="fanboy_social_label">Fanboy’s Social Blocking List:</string>
<string name="ultralist_label">UltraList:</string>
<string name="ultraprivacy_label">UltraPrivacy:</string>
<string name="package_signature">Assinatura do Pacote</string>
<!-- Preferences. -->
<string name="privacy">Privacidade</string>
- <string name="javascript_preference">JavaScript</string>
- <string name="javascript_preference_summary">JavaScript permite que sites executem programas (scripts) no dispositivo.</string>
- <string name="first_party_cookies_preference">Cookies primários</string>
- <string name="first_party_cookies_preference_summary">Como os cookies primários são uma configuração de nível de aplicativo, quando a guia ativa tem cookies habilitados,
- todas as solicitações de rede feitas em segundo plano por outras guias também incluirão quaisquer cookies armazenados para seus domínios.
- O Android KitKat (versão 4.4.x) não diferencia entre cookies primários e de terceiros e os habilitará com esta configuração.</string>
- <string name="third_party_cookies_preference">Cookies de terceiros</string>
- <string name="third_party_cookies_summary">Esta configuração requer Android Lollipop (versão 5.0) ou superior. Não tem efeito se os cookies primários estiverem desativados.</string>
- <string name="dom_storage_preference">Armazenamento DOM</string>
- <string name="dom_storage_preference_summary">JavaScript deve estar habilitado para que o armazenamento DOM funcione.</string>
- <string name="save_form_data_preference">Dados do formulário</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
- <string name="save_form_data_preference_summary">Dados de formulário salvos podem preencher campos automaticamente em sites.</string>
+ <string name="javascript_preference">JavaScript</string>
+ <string name="javascript_preference_summary">JavaScript permite que sites executem programas (scripts) no dispositivo.</string>
+ <string name="first_party_cookies_preference">Cookies primários</string>
+ <string name="first_party_cookies_preference_summary">Como os cookies primários são uma configuração de nível de aplicativo, quando a guia ativa tem cookies habilitados,
+ todas as solicitações de rede feitas em segundo plano por outras guias também incluirão quaisquer cookies armazenados para seus domínios.
+ O Android KitKat (versão 4.4.x) não diferencia entre cookies primários e de terceiros e os habilitará com esta configuração.</string>
+ <string name="third_party_cookies_preference">Cookies de terceiros</string>
+ <string name="third_party_cookies_summary">Esta configuração requer Android Lollipop (versão 5.0) ou superior. Não tem efeito se os cookies primários estiverem desativados.</string>
+ <string name="dom_storage_preference">Armazenamento DOM</string>
+ <string name="dom_storage_preference_summary">JavaScript deve estar habilitado para que o armazenamento DOM funcione.</string>
+ <string name="save_form_data_preference">Dados do formulário</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
+ <string name="save_form_data_preference_summary">Dados de formulário salvos podem preencher campos automaticamente em sites.</string>
<!-- The form data strings can be removed once the minimum API >= 26. -->
- <string name="user_agent">Mimetizar o Navegador:</string>
- <string-array name="translated_user_agent_names">
- <item>Privacy Browser</item>
- <item>WebView Padrão</item>
- <item>Firefox para Android</item>
- <item>Chrome para Android</item>
- <item>Safari para iOS</item>
- <item>Firefox para Linux</item>
- <item>Chromium para Linux</item>
- <item>Firefox para Windows</item>
- <item>Chrome para Windows</item>
- <item>Edge para Windows</item>
- <item>Internet Explorer para Windows</item>
- <item>Safari para macOS</item>
- <item>Personalizado</item>
- </string-array>
- <string-array name="translated_domain_settings_user_agent_names"> <!-- The translated names of the user agents with a System Default option for the domains spinner. -->
- <item>Padrão do Sistema</item>
- <item>Privacy Browser</item>
- <item>WebView Padrão</item>
- <item>Firefox para Android</item>
- <item>Chrome para Android</item>
- <item>Safari para iOS</item>
- <item>Firefox para Linux</item>
- <item>Chromium para Linux</item>
- <item>Firefox para Windows</item>
- <item>Chrome para Windows</item>
- <item>Edge para Windows</item>
- <item>Internet Explorer para Windows</item>
- <item>Safari para macOS</item>
- <item>Personalizado</item>
- </string-array>
- <string name="custom_user_agent">Agente de usuário personalizado</string>
- <string name="incognito_mode">Modo de navegação anônima</string>
- <string name="incognito_mode_summary">Limpe o histórico e o cache após o término do carregamento de cada página da web. No modo de navegação anônima,
- volta para fechar a guia (ou o aplicativo, se houver apenas uma guia).</string>
- <string name="do_not_track">Não rastreie</string>
- <string name="do_not_track_summary">Envie \'Não Rastreie\' ao cabeçalho, que sugere educadamente que os servidores da web não rastreiam este navegador.</string>
- <string name="allow_screenshots">Permitir capturas de tela</string>
- <string name="allow_screenshots_summary">Permitir capturas de tela, gravação de vídeo e visualização em monitores não seguros. Alterar esta configuração irá reiniciar o Privacy Browser.</string>
+ <string name="user_agent">Mimetizar o Navegador:</string>
+ <string-array name="translated_user_agent_names">
+ <item>Privacy Browser</item>
+ <item>WebView Padrão</item>
+ <item>Firefox para Android</item>
+ <item>Chrome para Android</item>
+ <item>Safari para iOS</item>
+ <item>Firefox para Linux</item>
+ <item>Chromium para Linux</item>
+ <item>Firefox para Windows</item>
+ <item>Chrome para Windows</item>
+ <item>Edge para Windows</item>
+ <item>Internet Explorer para Windows</item>
+ <item>Safari para macOS</item>
+ <item>Personalizado</item>
+ </string-array>
+ <string-array name="translated_domain_settings_user_agent_names"> <!-- The translated names of the user agents with a System Default option for the domains spinner. -->
+ <item>Padrão do Sistema</item>
+ <item>Privacy Browser</item>
+ <item>WebView Padrão</item>
+ <item>Firefox para Android</item>
+ <item>Chrome para Android</item>
+ <item>Safari para iOS</item>
+ <item>Firefox para Linux</item>
+ <item>Chromium para Linux</item>
+ <item>Firefox para Windows</item>
+ <item>Chrome para Windows</item>
+ <item>Edge para Windows</item>
+ <item>Internet Explorer para Windows</item>
+ <item>Safari para macOS</item>
+ <item>Personalizado</item>
+ </string-array>
+ <string name="custom_user_agent">Agente de usuário personalizado</string>
+ <string name="incognito_mode">Modo de navegação anônima</string>
+ <string name="incognito_mode_summary">Limpe o histórico e o cache após o término do carregamento de cada página da web. No modo de navegação anônima,
+ volta para fechar a guia (ou o aplicativo, se houver apenas uma guia).</string>
+ <string name="do_not_track">Não rastreie</string>
+ <string name="do_not_track_summary">Envie \'Não Rastreie\' ao cabeçalho, que sugere educadamente que os servidores da web não rastreiam este navegador.</string>
+ <string name="allow_screenshots">Permitir capturas de tela</string>
+ <string name="allow_screenshots_summary">Permitir capturas de tela, gravação de vídeo e visualização em monitores não seguros. Alterar esta configuração irá reiniciar o Privacy Browser.</string>
<string name="blocklists">Blocklists</string>
- <string name="easylist">EasyList</string>
- <string name="easylist_summary">Lista principal de bloqueio de anúncios.</string>
- <string name="easyprivacy">EasyPrivacy</string>
- <string name="easyprivacy_summary">Lista de bloqueio do rastreador principal.</string>
- <string name="fanboys_annoyance_list"> Lista de importunação Fanboy’s</string>
- <string name="fanboys_annoyance_list_summary">Bloqueie popups e links irritantes. Inclui listas de bloqueio social do Fanboy.</string>
- <string name="fanboys_social_blocking_list">Lista de bloqueio social do Fanboy</string>
- <string name="fanboys_social_blocking_list_summary">Bloqueia conteúdo de mídia social de terceiros.</string>
- <string name="ultralist">UltraList</string>
- <string name="ultralist_summary">O UltraList bloqueia anúncios que EasyList não bloqueia porque fazer isso pode quebrar sites.</string>
- <string name="ultraprivacy">UltraPrivacy</string>
- <string name="ultraprivacy_summary">O UltraPrivacy bloqueia rastreadores que o EasyPrivacy não bloqueia, pois isso pode corromper sites.</string>
- <string name="block_all_third_party_requests">Bloquear todas as solicitações de terceiros</string>
- <string name="block_all_third_party_requests_summary">Bloquear todas as solicitações de terceiros aumenta a privacidade, mas quebra muitos sites.</string>
+ <string name="easylist">EasyList</string>
+ <string name="easylist_summary">Lista principal de bloqueio de anúncios.</string>
+ <string name="easyprivacy">EasyPrivacy</string>
+ <string name="easyprivacy_summary">Lista de bloqueio do rastreador principal.</string>
+ <string name="fanboys_annoyance_list"> Lista de importunação Fanboy</string>
+ <string name="fanboys_annoyance_list_summary">Bloqueie popups e links irritantes. Inclui listas de bloqueio social do Fanboy.</string>
+ <string name="fanboys_social_blocking_list">Lista de bloqueio social do Fanboy</string>
+ <string name="fanboys_social_blocking_list_summary">Bloqueia conteúdo de mídia social de terceiros.</string>
+ <string name="ultralist">UltraList</string>
+ <string name="ultralist_summary">O UltraList bloqueia anúncios que EasyList não bloqueia porque fazer isso pode quebrar sites.</string>
+ <string name="ultraprivacy">UltraPrivacy</string>
+ <string name="ultraprivacy_summary">O UltraPrivacy bloqueia rastreadores que o EasyPrivacy não bloqueia, pois isso pode corromper sites.</string>
+ <string name="block_all_third_party_requests">Bloquear todas as solicitações de terceiros</string>
+ <string name="block_all_third_party_requests_summary">Bloquear todas as solicitações de terceiros aumenta a privacidade, mas quebra muitos sites.</string>
<string name="url_modification">Modificação de URL</string>
- <string name="google_analytics">Google Analytics</string>
- <string name="google_analytics_summary">Remova utm_ e amp; utm_ e qualquer coisa depois deles dos URLs.</string>
- <string name="facebook_click_ids">IDs de clique do Facebook</string>
- <string name="facebook_click_ids_summary">Remover “?fbclid=†, “&fbclid=†, “?fbadid=†, e “&fbadid=†e qualquer coisa depois deles a partir de URLs.</string>
- <string name="twitter_amp_redirects">Redirecionamentos de AMP do Twitter</string>
- <string name="twitter_amp_redirects_summary">Remover “?amp=1†e qualquer coisa depois de URLs.</string>
+ <string name="google_analytics">Google Analytics</string>
+ <string name="google_analytics_summary">Remova utm_ e amp; utm_ e qualquer coisa depois deles dos URLs.</string>
+ <string name="facebook_click_ids">IDs de clique do Facebook</string>
+ <string name="facebook_click_ids_summary">Remover “?fbclid=†, “&fbclid=†, “?fbadid=†, e “&fbadid=†e qualquer coisa depois deles a partir de URLs.</string>
+ <string name="twitter_amp_redirects">Redirecionamentos de AMP do Twitter</string>
+ <string name="twitter_amp_redirects_summary">Remover “?amp=1†e qualquer coisa depois de URLs.</string>
<string name="search">Search</string>
- <string-array name="search_entries">
- <item>Startpage</item>
- <item>Mojeek</item>
- <item>DuckDuckGo - JavaScript desativado</item>
- <item>DuckDuckGo - JavaScript ativado</item>
- <item>Google</item>
- <item>Bing</item>
- <item>Yahoo - JavaScript desativado</item>
- <item>Yahoo - JavaScript ativado</item>
- <item>Custom</item>
- </string-array>
- <string name="custom_url">URL personalizado</string>
- <string name="search_custom_url">URL personalizado de pesquisa</string>
+ <string-array name="search_entries">
+ <item>Startpage</item>
+ <item>Mojeek</item>
+ <item>DuckDuckGo - JavaScript desativado</item>
+ <item>DuckDuckGo - JavaScript ativado</item>
+ <item>Google</item>
+ <item>Bing</item>
+ <item>Yahoo - JavaScript desativado</item>
+ <item>Yahoo - JavaScript ativado</item>
+ <item>Custom</item>
+ </string-array>
+ <string name="custom_url">URL personalizado</string>
+ <string name="search_custom_url">URL personalizado de pesquisa</string>
<string name="proxy">Proxy</string>
- <string name="proxy_none">Nenhum</string>
- <string name="proxy_tor">Tor</string>
- <string name="proxy_i2p">I2P</string>
- <string name="proxy_custom">Personalizado</string>
- <string-array name="proxy_entries">
- <item>Nenhum</item>
- <item>Tor</item>
- <item>I2P</item>
- <item>Personalizado</item>
- </string-array>
- <string name="no_proxy_enabled">Nenhum - conecte-se diretamente à Internet.</string>
- <string name="tor_enabled">Tor - conecte-se por meio do socks://localhost:9050.</string>
- <string name="tor_enabled_kitkat">Tor - conecte-se por meio de http://localhost:8118.</string>
- <string name="i2p_enabled">I2P - conecte-se por meio de http://localhost:4444.</string>
- <string name="custom_proxy">Personalizar proxy</string>
- <string name="proxy_custom_url">URL de proxy personalizado</string>
+ <string name="proxy_none">Nenhum</string>
+ <string name="proxy_tor">Tor</string>
+ <string name="proxy_i2p">I2P</string>
+ <string name="proxy_custom">Personalizado</string>
+ <string-array name="proxy_entries">
+ <item>Nenhum</item>
+ <item>Tor</item>
+ <item>I2P</item>
+ <item>Personalizado</item>
+ </string-array>
+ <string name="no_proxy_enabled">Nenhum - conecte-se diretamente à Internet.</string>
+ <string name="tor_enabled">Tor - conecte-se por meio do socks://localhost:9050.</string>
+ <string name="tor_enabled_kitkat">Tor - conecte-se por meio de http://localhost:8118.</string>
+ <string name="i2p_enabled">I2P - conecte-se por meio de http://localhost:4444.</string>
+ <string name="custom_proxy">Personalizar proxy</string>
+ <string name="proxy_custom_url">URL de proxy personalizado</string>
<string name="full_screen">Tela Cheia</string>
- <string name="full_screen_browsing_mode">Modo de navegação em tela inteira</string>
- <string name="full_screen_browsing_mode_summary">Toque duas vezes para alternar o modo de navegação em tela inteira.</string>
- <string name="hide_app_bar">Ocultar a barra de aplicativos</string>
- <string name="hide_app_bar_summary">Oculte a barra de aplicativos que contém o URL.</string>
+ <string name="full_screen_browsing_mode">Modo de navegação em tela inteira</string>
+ <string name="full_screen_browsing_mode_summary">Toque duas vezes para alternar o modo de navegação em tela inteira.</string>
+ <string name="hide_app_bar">Ocultar a barra de aplicativos</string>
+ <string name="hide_app_bar_summary">Oculte a barra de aplicativos que contém o URL.</string>
<string name="clear_everything">Limpar tudo</string>
- <!-- The form data part of this string can be removed once the minimum API >= 26. -->
- <string name="clear_everything_summary">Limpa cookies, armazenamento DOM, dados de formulário e cache do WebView. Em seguida, exclui manualmente todos os diretórios “app_webview” e “cache”.</string>
- <string name="clear_cookies_preference">Limpar cookies</string>
- <string name="clear_cookies_summary">Limpa os cookies originais e de terceiros.</string>
- <string name="clear_dom_storage_preference">Limpar armazenamento DOM</string>
- <string name="clear_dom_storage_summary">Limpa o armazenamento DOM.</string>
- <string name="clear_form_data_preference">Limpar dados do formulário</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
- <string name="clear_form_data_summary">Limpa os dados do formulário.</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
- <string name="clear_cache">Limpar cache</string>
- <string name="clear_cache_summary">Limpa o cache do WebView.</string>
+ <!-- The form data part of this string can be removed once the minimum API >= 26. -->
+ <string name="clear_everything_summary">Limpa cookies, armazenamento DOM, dados de formulário e cache do WebView. Em seguida, exclui manualmente todos os diretórios “app_webview” e “cache”.</string>
+ <string name="clear_cookies_preference">Limpar cookies</string>
+ <string name="clear_cookies_summary">Limpa os cookies originais e de terceiros.</string>
+ <string name="clear_dom_storage_preference">Limpar armazenamento DOM</string>
+ <string name="clear_dom_storage_summary">Limpa o armazenamento DOM.</string>
+ <string name="clear_form_data_preference">Limpar dados do formulário</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
+ <string name="clear_form_data_summary">Limpa os dados do formulário.</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
+ <string name="clear_cache">Limpar cache</string>
+ <string name="clear_cache_summary">Limpa o cache do WebView.</string>
<string name="general">Geral</string>
- <string name="homepage">Pagina inicial</string>
- <string name="download_location">Localização de Download</string>
- <string-array name="download_location_entries">
- <item>Automático</item>
- <item>Diretório do aplicativo</item>
- <item>Diretório público</item>
- <item>Personalizado</item>
- </string-array>
- <string name="download_custom_location">Localização de Download Personalizada</string>
- <string name="font_size_preference">Tamanho da Fonte</string>
- <string name="open_intents_in_new_tab">Abrir conteúdo em uma nova guia</string>
- <string name="open_intents_in_new_tab_summary">Conteúdos são links enviados de outros aplicativos.</string>
- <string name="swipe_to_refresh">Deslize para atualizar</string>
- <string name="swipe_to_refresh_summary">Alguns sites não funcionam bem se deslizar para atualizar estiver habilitado.</string>
- <string name="scroll_app_bar">Role a barra de aplicativos</string>
- <string name="scroll_app_bar_summary">Role a barra de aplicativos para fora da parte superior da tela quando o WebView rola para baixo.</string>
- <string name="display_additional_app_bar_icons">Exibir ícones adicionais da barra de aplicativos</string>
- <string name="display_additional_app_bar_icons_summary">Exibe ícones na barra de aplicativos para atualizar o WebView e, se houver espaço, para alternar cookies e armazenamento DOM.</string>
- <string name="app_theme">Tema do aplicativo</string>
- <string-array name="app_theme_entries">
- <item>Padrão do Sitema</item>
- <item>Claro</item>
- <item>Escuro</item>
- </string-array>
- <string name="webview_theme">Tema do WebView</string>
- <string-array name="webview_theme_entries">
- <item>Padrão do Sitema</item>
- <item>Claro</item>
- <item>Escuro</item>
- </string-array>
- <string name="wide_viewport_preference">Janela de visualização ampla</string>
- <string name="wide_viewport_summary">Usar uma janela de visualização ampla torna o layout de algumas páginas da web mais parecido com o site para desktop.</string>
- <string name="display_webpage_images">Exibir imagens da página da web</string>
- <string name="display_webpage_images_summary">Desative para conservar a largura de banda.</string>
+ <string name="homepage">Pagina inicial</string>
+ <string name="download_location">Localização de Download</string>
+ <string-array name="download_location_entries">
+ <item>Automático</item>
+ <item>Diretório do aplicativo</item>
+ <item>Diretório público</item>
+ <item>Personalizado</item>
+ </string-array>
+ <string name="download_custom_location">Localização de Download Personalizada</string>
+ <string name="font_size_preference">Tamanho da Fonte</string>
+ <string name="open_intents_in_new_tab">Abrir conteúdo em uma nova guia</string>
+ <string name="open_intents_in_new_tab_summary">Conteúdos são links enviados de outros aplicativos.</string>
+ <string name="swipe_to_refresh">Deslize para atualizar</string>
+ <string name="swipe_to_refresh_summary">Alguns sites não funcionam bem se deslizar para atualizar estiver habilitado.</string>
+ <string name="scroll_app_bar">Role a barra de aplicativos</string>
+ <string name="scroll_app_bar_summary">Role a barra de aplicativos para fora da parte superior da tela quando o WebView rola para baixo.</string>
+ <string name="display_additional_app_bar_icons">Exibir ícones adicionais da barra de aplicativos</string>
+ <string name="display_additional_app_bar_icons_summary">Exibe ícones na barra de aplicativos para atualizar o WebView e, se houver espaço, para alternar cookies e armazenamento DOM.</string>
+ <string name="app_theme">Tema do aplicativo</string>
+ <string-array name="app_theme_entries">
+ <item>Padrão do Sitema</item>
+ <item>Claro</item>
+ <item>Escuro</item>
+ </string-array>
+ <string name="webview_theme">Tema do WebView</string>
+ <string-array name="webview_theme_entries">
+ <item>Padrão do Sitema</item>
+ <item>Claro</item>
+ <item>Escuro</item>
+ </string-array>
+ <string name="wide_viewport_preference">Janela de visualização ampla</string>
+ <string name="wide_viewport_summary">Usar uma janela de visualização ampla torna o layout de algumas páginas da web mais parecido com o site para desktop.</string>
+ <string name="display_webpage_images">Exibir imagens da página da web</string>
+ <string name="display_webpage_images_summary">Desative para conservar a largura de banda.</string>
<!-- Ad Control. There are no ads in the standard flavor, but these strings must exist because they are referenced in the code. -->
<string name="ad_consent">Consentimento de Anúncio</string>
<string name="swipe_to_refresh_options_menu">Потянуть для обновления</string>
<string name="wide_viewport">Широкий вид просмотра</string>
<string name="display_images">Показывать изображения</string>
+ <string name="dark_webview">Темный WebView</string>
<string name="font_size">Размер шрифта</string>
<string name="find_on_page">Найти на странице</string>
<string name="print">Печать</string>
<string name="privacy_browser_web_page">Privacy Browser веб-страница</string>
<string name="save">Сохранить</string>
- <string name="save_url">Сохранить URL</string>
- <string name="save_as_archive">Сохранить как архив</string>
- <string name="save_as_image">Сохранить как изображение</string>
<string name="add_to_home_screen">Добавить на главный экран</string>
<string name="view_source">Просмотр исходного кода</string>
<string name="share">Поделиться</string>
<string name="previous">Предыдущий</string>
<string name="next">Следующий</string>
- <!-- Save. -->
- <string name="file_name">Имя файла</string>
+ <!-- Save Dialogs. -->
+ <string name="save_url">Сохранить URL</string>
<string name="save_archive">Сохранить архив</string>
<string name="save_image">Сохранить изображение</string>
+ <string name="save_logcat">Сохранить logcat</string>
+ <string name="file_name">Имя файла</string>
<string name="webpage_mht">Webpage.mht</string>
<string name="webpage_png">Webpage.png</string>
+ <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
<string name="file">Файл</string>
<string name="bytes">байтов</string>
<string name="unknown_size">неизвестный размер</string>
<string name="invalid_url">неправильный URL</string>
<string name="ok">OK</string>
<string name="saving_file">Сохранение файла:</string>
- <string name="saving_image">Сохранение изображения…</string>
<string name="file_saved">Файл сохранен:</string>
- <string name="image_saved">Изображение сохранено.</string>
<string name="error_saving_file">Ошибка сохранения файла:</string>
- <string name="error_saving_image">Ошибка сохранения изображения:</string>
<!-- View Source. -->
<string name="request_headers">Заголовки запроса</string>
<string name="copy_string">Копировать</string> <!-- `copy` is a reserved word and should not be used as the name. -->
<string name="logcat_copied">Logcat скопирован.</string>
<string name="clear">Очистить</string>
- <string name="save_logcat">Сохранить logcat</string>
- <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
- <string name="file_saved_successfully">Файл успешно сохранен.</string>
- <string name="save_failed">Сохранить не удалось:</string>
<!-- Guide. -->
<string name="overview">Обзор</string>
<string name="orbot">Orbot:</string>
<string name="i2p">I2P:</string>
<string name="openkeychain">OpenKeychain:</string>
+ <string name="memory_usage">Использование памяти</string>
+ <string name="app_consumed_memory">Потребляемая приложением память:</string>
+ <string name="app_available_memory">Доступная приложению память:</string>
+ <string name="app_total_memory">Общая память приложения:</string>
+ <string name="app_maximum_memory">Максимальная память приложения:</string>
+ <string name="system_consumed_memory">Потребляемая системой память:</string>
+ <string name="system_available_memory">Доступная системе память:</string>
+ <string name="system_total_memory">Общая память системы:</string>
+ <string name="mebibyte">МиБ</string>
<string name="easylist_label">EasyList:</string>
<string name="easyprivacy_label">EasyPrivacy:</string>
<string name="fanboy_annoyance_label">Fanboy’s Annoyance List:</string>
<string name="print">Yazdır</string>
<string name="privacy_browser_web_page">Privacy Browser Web Sayfası</string>
<string name="save">Kaydet</string>
- <string name="save_as_image">Resmi farklı kaydet</string>
<string name="add_to_home_screen">Ana ekrana ekle</string>
<string name="view_source">Kaynağı görüntüle</string>
<string name="share">Paylaş</string>
<string name="previous">Önceki</string>
<string name="next">Sonraki</string>
- <!-- Save. -->
- <string name="file_name">Dosya adı</string>
+ <!-- Save Dialogs. -->
<string name="save_image">Resmi kaydet</string>
+ <string name="save_logcat">Logcat kaydet</string>
+ <string name="file_name">Dosya adı</string>
<string name="webpage_png">Websayfası.png</string>
<string name="unknown_size">Bilinmeyen boyut</string>
+ <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
<string name="ok">OK</string>
- <string name="saving_image">Resim kaydediliyor…</string>
- <string name="image_saved">Resim kaydedildi</string>
- <string name="error_saving_image">Resim kaydı başarısız:</string>
<!-- View Source. -->
<string name="request_headers">İstek Başlıkları</string>
<string name="copy_string">Kopyala</string> <!-- `copy` is a reserved word and should not be used as the name. -->
<string name="logcat_copied">Logcat kopyalandı.</string>
<string name="clear">Temizle</string>
- <string name="save_logcat">Logcat kaydet</string>
- <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
- <string name="file_saved_successfully">Dosya başarıyla kaydedildi.</string>
- <string name="save_failed">Kayıt başarısız:</string>
<!-- Guide. -->
<string name="overview">Genel Bakış</string>
<item name="editIcon">@drawable/edit_day</item>
<item name="moveToFolderIcon">@drawable/move_to_folder_day</item>
<item name="saveIcon">@drawable/save_day</item>
+ <item name="saveImageIcon">@drawable/images_options_day</item>
+ <item name="saveTextIcon">@drawable/save_text_day</item>
<item name="selectAllIcon">@drawable/select_all_day</item>
+ <item name="shareIcon">@drawable/share_day</item>
<item name="sortIcon">@drawable/sort_day</item>
</style>
<item name="editIcon">@drawable/edit_day</item>
<item name="moveToFolderIcon">@drawable/move_to_folder_day</item>
<item name="saveIcon">@drawable/save_day</item>
+ <item name="saveImageIcon">@drawable/images_options_day</item>
+ <item name="saveTextIcon">@drawable/save_text_day</item>
<item name="selectAllIcon">@drawable/select_all_day</item>
+ <item name="shareIcon">@drawable/share_day</item>
<item name="sortIcon">@drawable/sort_day</item>
</style>
<attr name="homepageIcon" format="reference" />
<attr name="moveToFolderIcon" format="reference" />
<attr name="saveIcon" format="reference" />
+ <attr name="saveImageIcon" format="reference" />
+ <attr name="saveTextIcon" format="reference" />
<attr name="searchIcon" format="reference" />
<attr name="selectAllIcon" format="reference" />
+ <attr name="shareIcon" format="reference" />
<attr name="sortIcon" format="reference" />
<attr name="userAgentIcon" format="reference" />
</resources>
\ No newline at end of file
<string name="print">Print</string>
<string name="privacy_browser_web_page">Privacy Browser Web Page</string>
<string name="save">Save</string>
- <string name="save_url">Save URL</string>
- <string name="save_as_archive">Save as Archive</string>
- <string name="save_as_image">Save as Image</string>
<string name="add_to_home_screen">Add to Home Screen</string>
<string name="view_source">View Source</string>
<string name="share">Share</string>
<string name="previous">Previous</string>
<string name="next">Next</string>
- <!-- Save. -->
+ <!-- Save Dialogs. -->
<string name="save_dialog" translatable="false">Save Dialog</string> <!-- This string is used to tag the save dialog. It is never displayed to the user. -->
- <string name="file_name">File name</string>
+ <string name="save_url">Save URL</string>
<string name="save_archive">Save Archive</string>
+ <string name="save_text">Save Text</string>
<string name="save_image">Save Image</string>
+ <string name="save_logcat">Save Logcat</string>
+ <string name="file_name">File name</string>
<string name="webpage_mht">Webpage.mht</string>
<string name="webpage_png">Webpage.png</string>
+ <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
+ <string name="privacy_browser_version_txt">Privacy Browser Version.txt</string>
+ <string name="privacy_browser_version_png">Privacy Browser Version.png</string>
<string name="file">File</string>
<string name="bytes">bytes</string>
<string name="unknown_size">unknown size</string>
<string name="invalid_url">invalid URL</string>
<string name="ok">OK</string>
<string name="saving_file">Saving file:</string>
- <string name="saving_image">Saving image…</string>
+ <string name="processing_image">Processing image… :</string>
<string name="file_saved">File saved:</string>
- <string name="image_saved">Image saved.</string>
<string name="error_saving_file">Error saving file:</string>
- <string name="error_saving_image">Error saving image:</string>
<!-- View Source. -->
<string name="request_headers">Request Headers</string>
<string name="copy_string">Copy</string> <!-- `copy` is a reserved word and should not be used as the name. -->
<string name="logcat_copied">Logcat copied.</string>
<string name="clear">Clear</string>
- <string name="save_logcat">Save logcat</string>
- <string name="privacy_browser_logcat_txt">Privacy Browser Logcat.txt</string>
- <string name="file_saved_successfully">File saved successfully.</string>
- <string name="save_failed">Save failed:</string>
<!-- Guide. -->
<string name="overview">Overview</string>
<string name="licenses">Licenses</string>
<string name="contributors">Contributors</string>
<string name="links">Links</string>
+ <string name="version_info_copied">Version info copied.</string>
+ <string name="email">Email</string> <!-- This is a verb. -->
<!-- Preferences. -->
<string name="privacy">Privacy</string>
<item name="editIcon">@drawable/edit_day</item>
<item name="moveToFolderIcon">@drawable/move_to_folder_day</item>
<item name="saveIcon">@drawable/save_day</item>
+ <item name="saveImageIcon">@drawable/images_options_day</item>
+ <item name="saveTextIcon">@drawable/save_text_day</item>
<item name="selectAllIcon">@drawable/select_all_day</item>
+ <item name="shareIcon">@drawable/share_day</item>
<item name="sortIcon">@drawable/sort_day</item>
</style>