From 231b7c038227e36f96ed28e9c2ff8bde793133ec Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Thu, 21 Mar 2019 14:17:24 -0700 Subject: [PATCH] Handle the options menu. --- .../activities/BookmarksActivity.java | 10 +- .../activities/MainWebViewActivity.java | 120 +++++++++++++----- .../dialogs/CreateBookmarkDialog.java | 92 ++++++++++++-- .../CreateHomeScreenShortcutDialog.java | 18 ++- .../main/res/menu/webview_options_menu.xml | 2 +- app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + .../android/it-IT/full_description.txt | 17 ++- 12 files changed, 202 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java index d635cbc6..bd274ec2 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java @@ -79,6 +79,10 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma // `restartFromBookmarksDatabaseViewActivity` is public static so it can be accessed from `BookmarksDatabaseViewActivity`. It is also used in `onRestart()`. public static boolean restartFromBookmarksDatabaseViewActivity; + // The current WebView strings are public static so they can be updated from `MainWebViewActivity`. They are use in `onCreate()`. + public static String currentWebViewUrl; + public static String currentWebViewTitle; + // `bookmarksDatabaseHelper` is used in `onCreate()`, `onOptionsItemSelected()`, `onBackPressed()`, `onCreateBookmark()`, `onCreateBookmarkFolder()`, `onSaveBookmark()`, `onSaveBookmarkFolder()`, // `onMoveToFolder()`, `deleteBookmarkFolderContents()`, `loadFolder()`, and `onDestroy()`. @@ -553,8 +557,10 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma // Set the create new bookmark FAB to display the `AlertDialog`. createBookmarkFab.setOnClickListener(view -> { - // Show the `CreateBookmarkDialog` `AlertDialog` and name the instance `@string/create_bookmark`. - DialogFragment createBookmarkDialog = new CreateBookmarkDialog(); + // Instantiate the create bookmark dialog. + DialogFragment createBookmarkDialog = CreateBookmarkDialog.createBookmark(currentWebViewUrl, currentWebViewTitle, MainWebViewActivity.favoriteIconBitmap); + + // Display the create bookmark dialog. createBookmarkDialog.show(getSupportFragmentManager(), getResources().getString(R.string.create_bookmark)); }); } diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 14095ab0..f092f3e9 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -111,8 +111,8 @@ import androidx.viewpager.widget.ViewPager; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.navigation.NavigationView; import com.google.android.material.snackbar.Snackbar; - import com.google.android.material.tabs.TabLayout; + import com.stoutner.privacybrowser.BuildConfig; import com.stoutner.privacybrowser.R; import com.stoutner.privacybrowser.asynctasks.GetHostIpAddresses; @@ -120,12 +120,14 @@ import com.stoutner.privacybrowser.dialogs.AdConsentDialog; import com.stoutner.privacybrowser.dialogs.CreateBookmarkDialog; import com.stoutner.privacybrowser.dialogs.CreateBookmarkFolderDialog; import com.stoutner.privacybrowser.dialogs.CreateHomeScreenShortcutDialog; +import com.stoutner.privacybrowser.dialogs.DownloadFileDialog; import com.stoutner.privacybrowser.dialogs.DownloadImageDialog; import com.stoutner.privacybrowser.dialogs.DownloadLocationPermissionDialog; import com.stoutner.privacybrowser.dialogs.EditBookmarkDialog; import com.stoutner.privacybrowser.dialogs.EditBookmarkFolderDialog; import com.stoutner.privacybrowser.dialogs.HttpAuthenticationDialog; import com.stoutner.privacybrowser.dialogs.PinnedMismatchDialog; +import com.stoutner.privacybrowser.dialogs.SslCertificateErrorDialog; import com.stoutner.privacybrowser.dialogs.UrlHistoryDialog; import com.stoutner.privacybrowser.dialogs.ViewSslCertificateDialog; import com.stoutner.privacybrowser.fragments.WebViewTabFragment; @@ -134,8 +136,6 @@ import com.stoutner.privacybrowser.helpers.BlockListHelper; import com.stoutner.privacybrowser.helpers.BookmarksDatabaseHelper; import com.stoutner.privacybrowser.helpers.DomainsDatabaseHelper; import com.stoutner.privacybrowser.helpers.OrbotProxyHelper; -import com.stoutner.privacybrowser.dialogs.DownloadFileDialog; -import com.stoutner.privacybrowser.dialogs.SslCertificateErrorDialog; import com.stoutner.privacybrowser.views.NestedScrollWebView; import java.io.ByteArrayInputStream; @@ -162,22 +162,26 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook EditBookmarkFolderDialog.EditBookmarkFolderListener, HttpAuthenticationDialog.HttpAuthenticationListener, NavigationView.OnNavigationItemSelectedListener, WebViewTabFragment.NewTabListener, PinnedMismatchDialog.PinnedMismatchListener, SslCertificateErrorDialog.SslCertificateErrorListener, UrlHistoryDialog.UrlHistoryListener { + // TODO Consider removing // `darkTheme` is public static so it can be accessed from everywhere. public static boolean darkTheme; + // TODO Consider removing // `allowScreenshots` is public static so it can be accessed from everywhere. It is also used in `onCreate()`. public static boolean allowScreenshots; - // `favoriteIconBitmap` is public static so it can be accessed from `CreateHomeScreenShortcutDialog`, `BookmarksActivity`, `BookmarksDatabaseViewActivity`, `CreateBookmarkDialog`, - // `CreateBookmarkFolderDialog`, `EditBookmarkDialog`, `EditBookmarkFolderDialog`, `EditBookmarkDatabaseViewDialog`, and `ViewSslCertificateDialog`. It is also used in `onCreate()`, - // `onCreateBookmark()`, `onCreateBookmarkFolder()`, `onCreateHomeScreenShortcut()`, `onSaveEditBookmark()`, `onSaveEditBookmarkFolder()`, and `applyDomainSettings()`. + // TODO Remove + // `favoriteIconBitmap` is public static so it can be accessed from `BookmarksActivity`, `BookmarksDatabaseViewActivity`, `CreateBookmarkFolderDialog`, + // `EditBookmarkDialog`, `EditBookmarkFolderDialog`, `EditBookmarkDatabaseViewDialog`, and `ViewSslCertificateDialog`. It is also used in `onCreate()`, `onCreateBookmark()`, `onCreateBookmarkFolder()`, + // `onCreateHomeScreenShortcut()`, `onSaveEditBookmark()`, `onSaveEditBookmarkFolder()`, and `applyDomainSettings()`. public static Bitmap favoriteIconBitmap; + // TODO Remove // `favoriteIconDefaultBitmap` public static so it can be accessed from `PinnedMismatchDialog`. It is also used in `onCreate()` and `applyDomainSettings`. public static Bitmap favoriteIconDefaultBitmap; - // `formattedUrlString` is public static so it can be accessed from `AddDomainDialog`, `BookmarksActivity`, `DomainSettingsFragment`, `CreateBookmarkDialog`, - // and `PinnedMismatchDialog`. + // TODO Consider removing the formatted URL string. + // `formattedUrlString` is public static so it can be accessed from `AddDomainDialog`, `BookmarksActivity`, `DomainSettingsFragment`, and `PinnedMismatchDialog`. // It is also used in `onCreate()`, `onOptionsItemSelected()`, `onNavigationItemSelected()`, `onCreateHomeScreenShortcutCreate()`, `loadUrlFromTextBox()`, and `applyProxyThroughOrbot()`. public static String formattedUrlString; @@ -199,9 +203,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // `orbotStatus` is public static so it can be accessed from `OrbotProxyHelper`. It is also used in `onCreate()`, `onResume()`, and `applyProxyThroughOrbot()`. public static String orbotStatus; - // `webViewTitle` is public static so it can be accessed from `CreateBookmarkDialog`. It is also used in `onCreate()`. - public static String webViewTitle; - // `appliedUserAgentString` is public static so it can be accessed from `ViewSourceActivity`. It is also used in `applyDomainSettings()`. public static String appliedUserAgentString; @@ -791,6 +792,10 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Set the launch bookmarks activity FAB to launch the bookmarks activity. launchBookmarksActivityFab.setOnClickListener(v -> { + // Store the current WebView url and title in the bookmarks activity. + BookmarksActivity.currentWebViewUrl = currentWebView.getUrl(); + BookmarksActivity.currentWebViewTitle = currentWebView.getTitle(); + // Create an intent to launch the bookmarks activity. Intent bookmarksIntent = new Intent(getApplicationContext(), BookmarksActivity.class); @@ -810,8 +815,10 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Set the create new bookmark FAB to display an alert dialog. createBookmarkFab.setOnClickListener(view -> { - // Show the create bookmark dialog and name the instance `@string/create_bookmark`. - DialogFragment createBookmarkDialog = new CreateBookmarkDialog(); + // Instantiate the create bookmark dialog. + DialogFragment createBookmarkDialog = CreateBookmarkDialog.createBookmark(currentWebView.getUrl(), currentWebView.getTitle(), favoriteIconBitmap); + + // Display the create bookmark dialog. createBookmarkDialog.show(fragmentManager, resources.getString(R.string.create_bookmark)); }); @@ -1016,11 +1023,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook saveFormDataEnabled = false; // Form data can be removed once the minimum API >= 26. nightMode = false; + // Inflate a bare WebView to get the default user agent. It is not used to render content on the screen. + @SuppressLint("InflateParams") View webViewLayout = getLayoutInflater().inflate(R.layout.bare_webview, null, false); + + // Get a handle for the WebView. + WebView bareWebView = webViewLayout.findViewById(R.id.bare_webview); + // Store the default user agent. - // TODO webViewDefaultUserAgent = mainWebView.getSettings().getUserAgentString(); + webViewDefaultUserAgent = bareWebView.getSettings().getUserAgentString(); - // Initialize the WebView title. - webViewTitle = getString(R.string.no_title); + // Destroy the bare WebView. + bareWebView.destroy(); // Initialize the favorite icon bitmap. `ContextCompat` must be used until API >= 21. Drawable favoriteIconDrawable = ContextCompat.getDrawable(getApplicationContext(), R.drawable.world); @@ -1137,8 +1150,23 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Reload the webpage if displaying of images has been disabled in the Settings activity. if (reloadOnRestart) { // Reload the WebViews. - // TODO - currentWebView.reload(); + for (int i = 0; i < webViewPagerAdapter.webViewFragmentsList.size(); i++) { + // Get the WebView tab fragment. + WebViewTabFragment webViewTabFragment = webViewPagerAdapter.webViewFragmentsList.get(i); + + // Get the fragment view. + View fragmentView = webViewTabFragment.getView(); + + // Only reload the WebViews if they exist. + if (fragmentView != null) { + // Get the nested scroll WebView from the tab fragment. + NestedScrollWebView nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview); + + // TODO this doesn't seem to work if for WebViews that aren't visible. + // Reload the WebView. + nestedScrollWebView.reload(); + } + } // Reset `reloadOnRestartBoolean`. reloadOnRestart = false; @@ -1398,7 +1426,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook ultraPrivacyMenuItem.setChecked(ultraPrivacyEnabled); blockAllThirdPartyRequestsMenuItem.setChecked(blockAllThirdPartyRequests); swipeToRefreshMenuItem.setChecked(swipeRefreshLayout.isEnabled()); - // TODO displayImagesMenuItem.setChecked(mainWebView.getSettings().getLoadsImagesAutomatically()); + displayImagesMenuItem.setChecked(currentWebView.getSettings().getLoadsImagesAutomatically()); nightModeMenuItem.setChecked(nightMode); proxyThroughOrbotMenuItem.setChecked(proxyThroughOrbot); @@ -1453,8 +1481,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook blockAllThirdPartyRequestsMenuItem.setTitle(thirdPartyBlockedRequests + " - " + getString(R.string.block_all_third_party_requests)); // Get the current user agent. - // TODO String currentUserAgent = mainWebView.getSettings().getUserAgentString(); - String currentUserAgent = ""; + String currentUserAgent = currentWebView.getSettings().getUserAgentString(); // Select the current user agent menu item. A switch statement cannot be used because the user agents are not compile time constants. if (currentUserAgent.equals(getResources().getStringArray(R.array.user_agent_data)[0])) { // Privacy Browser. @@ -1486,8 +1513,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } // Initialize font size variables. - // TODO int fontSize = mainWebView.getSettings().getTextZoom(); - int fontSize = 100; + int fontSize = currentWebView.getSettings().getTextZoom(); String fontSizeTitle; MenuItem selectedFontSizeMenuItem; @@ -2138,7 +2164,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook case R.id.share_url: // Setup the share string. - String shareString = webViewTitle + " – " + formattedUrlString; + String shareString = currentWebView.getTitle() + " – " + formattedUrlString; // Create the share intent. Intent shareIntent = new Intent(Intent.ACTION_SEND); @@ -3458,8 +3484,24 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook customHeaders.remove("DNT"); } - // Set the app bar scrolling. - currentWebView.setNestedScrollingEnabled(sharedPreferences.getBoolean("scroll_app_bar", true)); + // TODO this also needs to be set when creating a new tab. + // Set the app bar scrolling for each WebView. + for (int i = 0; i < webViewPagerAdapter.webViewFragmentsList.size(); i++) { + // Get the WebView tab fragment. + WebViewTabFragment webViewTabFragment = webViewPagerAdapter.webViewFragmentsList.get(i); + + // Get the fragment view. + View fragmentView = webViewTabFragment.getView(); + + // Only modify the WebViews if they exist. + if (fragmentView != null) { + // Get the nested scroll WebView from the tab fragment. + NestedScrollWebView nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview); + + // Set the app bar scrolling. + nestedScrollWebView.setNestedScrollingEnabled(sharedPreferences.getBoolean("scroll_app_bar", true)); + } + } // Update the full screen browsing mode settings. if (fullScreenBrowsingModeEnabled && inFullScreenBrowsingMode) { // Privacy Browser is currently in full screen browsing mode. @@ -4031,9 +4073,25 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Reset `waitingForOrbot. waitingForOrbot = false; - // Reload the website if requested. + // Reload the WebViews if requested. if (reloadWebsite) { - currentWebView.reload(); + // Reload the WebViews. + for (int i = 0; i < webViewPagerAdapter.webViewFragmentsList.size(); i++) { + // Get the WebView tab fragment. + WebViewTabFragment webViewTabFragment = webViewPagerAdapter.webViewFragmentsList.get(i); + + // Get the fragment view. + View fragmentView = webViewTabFragment.getView(); + + // Only reload the WebViews if they exist. + if (fragmentView != null) { + // Get the nested scroll WebView from the tab fragment. + NestedScrollWebView nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview); + + // Reload the WebView. + nestedScrollWebView.reload(); + } + } } } } @@ -4690,12 +4748,8 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Save a copy of the title when it changes. @Override public void onReceivedTitle(WebView view, String title) { - // Save a copy of the title. - // TODO. Replace `webViewTitle` with `currentWebView.getTitle()`. - webViewTitle = title; - // Set the title as the tab text. - tabTitleTextView.setText(webViewTitle); + tabTitleTextView.setText(title); } // Enter full screen video. diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java index 6d4e84e6..00e604e0 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateBookmarkDialog.java @@ -24,10 +24,13 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.content.SharedPreferences; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.preference.PreferenceManager; import android.view.KeyEvent; import android.view.View; import android.view.WindowManager; @@ -36,38 +39,101 @@ import android.widget.EditText; import androidx.annotation.NonNull; import androidx.fragment.app.DialogFragment; // The AndroidX dialog fragment must be used or an error is produced on API <=22. -import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.R; +import java.io.ByteArrayOutputStream; + public class CreateBookmarkDialog extends DialogFragment { + // Create the class variables. + String url; + String title; + Bitmap favoriteIconBitmap; + // The public interface is used to send information back to the parent activity. public interface CreateBookmarkListener { void onCreateBookmark(DialogFragment dialogFragment); } - // `createBookmarkListener` is used in `onAttach()` and `onCreateDialog()` + // The create bookmark listener is initialized in `onAttach()` and used in `onCreateDialog()`. private CreateBookmarkListener createBookmarkListener; - public void onAttach(Context context) { + // Run the default commands. super.onAttach(context); // Get a handle for `CreateBookmarkListener` from the launching context. createBookmarkListener = (CreateBookmarkListener) context; } + public static CreateBookmarkDialog createBookmark(String url, String title, Bitmap favoriteIconBitmap) { + // Scale the favorite icon bitmap down if it is larger than 256 x 256. Filtering uses bilinear interpolation. + if ((favoriteIconBitmap.getHeight() > 256) || (favoriteIconBitmap.getWidth() > 256)) { + favoriteIconBitmap = Bitmap.createScaledBitmap(favoriteIconBitmap, 256, 256, true); + } + + // Create a favorite icon byte array output stream. + ByteArrayOutputStream favoriteIconByteArrayOutputStream = new ByteArrayOutputStream(); + + // Convert the favorite icon to a PNG and place it in the byte array output stream. `0` is for lossless compression (the only option for a PNG). + favoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, favoriteIconByteArrayOutputStream); + + // Convert the byte array output stream to a byte array. + byte[] favoriteIconByteArray = favoriteIconByteArrayOutputStream.toByteArray(); + + // Create a bundle. + Bundle bundle = new Bundle(); + + // Store the variables in the bundle + bundle.putString("url", url); + bundle.putString("title", title); + bundle.putByteArray("favorite_icon_byte_array", favoriteIconByteArray); + + // Create a new instance of the dialog. + CreateBookmarkDialog createBookmarkDialog = new CreateBookmarkDialog(); + + // Add the bundle to the dialog. + createBookmarkDialog.setArguments(bundle); + + // Return the new dialog. + return createBookmarkDialog; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + // Run the default commands. + super.onCreate(savedInstanceState); + + // Get the arguments. + Bundle arguments = getArguments(); + + // Remove the incorrect lint warning below that the arguments might be null. + assert arguments != null; + + // Store the contents of the arguments in class variables. + url = arguments.getString("url"); + title = arguments.getString("title"); + + // Get the favorite icon byte array. + byte[] favoriteIconByteArray = arguments.getByteArray("favorite_icon_byte_array"); + + // Remove the incorrect lint warning below that the favorite icon byte array might be null. + assert favoriteIconByteArray != null; + + // Convert the favorite icon byte array to a bitmap and store it in a class variable. + favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.length); + } + // `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`. @SuppressLint("InflateParams") @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { - // Get a copy of the favorite icon bitmap. - Bitmap favoriteIconBitmap = MainWebViewActivity.favoriteIconBitmap; + // Get a handle for the shared preferences. + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); - // Scale the favorite icon bitmap down if it is larger than 256 x 256. Filtering uses bilinear interpolation. - if ((favoriteIconBitmap.getHeight() > 256) || (favoriteIconBitmap.getWidth() > 256)) { - favoriteIconBitmap = Bitmap.createScaledBitmap(favoriteIconBitmap, 256, 256, true); - } + // Get the theme and screenshot preferences. + boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false); + boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false); // Create a drawable version of the favorite icon. Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), favoriteIconBitmap); @@ -76,7 +142,7 @@ public class CreateBookmarkDialog extends DialogFragment { AlertDialog.Builder dialogBuilder; // Set the style according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); } else { dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); @@ -110,7 +176,7 @@ public class CreateBookmarkDialog extends DialogFragment { assert alertDialog.getWindow() != null; // Disable screenshots if not allowed. - if (!MainWebViewActivity.allowScreenshots) { + if (!allowScreenshots) { alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); } @@ -124,7 +190,7 @@ public class CreateBookmarkDialog extends DialogFragment { EditText createBookmarkNameEditText = alertDialog.findViewById(R.id.create_bookmark_name_edittext); // Set the current `WebView` title as the text for `create_bookmark_name_edittext`. - createBookmarkNameEditText.setText(MainWebViewActivity.webViewTitle); + createBookmarkNameEditText.setText(title); // Allow the `enter` key on the keyboard to create the bookmark from `create_bookmark_name_edittext`. createBookmarkNameEditText.setOnKeyListener((View view, int keyCode, KeyEvent event) -> { @@ -145,7 +211,7 @@ public class CreateBookmarkDialog extends DialogFragment { // Set the formattedUrlString as the initial text of `create_bookmark_url_edittext`. EditText createBookmarkUrlEditText = alertDialog.findViewById(R.id.create_bookmark_url_edittext); - createBookmarkUrlEditText.setText(MainWebViewActivity.formattedUrlString); + createBookmarkUrlEditText.setText(url); // Allow the `enter` key on the keyboard to create the bookmark from `create_bookmark_url_edittext`. createBookmarkUrlEditText.setOnKeyListener((View v, int keyCode, KeyEvent event) -> { diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java index e3221a21..95a3ef5e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java @@ -25,12 +25,14 @@ import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; +import android.preference.PreferenceManager; import android.text.Editable; import android.text.TextWatcher; import android.view.KeyEvent; @@ -49,7 +51,6 @@ import androidx.core.graphics.drawable.IconCompat; import androidx.fragment.app.DialogFragment; // The AndroidX dialog fragment must be used or an error is produced on API <=22. import com.stoutner.privacybrowser.BuildConfig; -import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.R; import java.io.ByteArrayOutputStream; @@ -100,7 +101,7 @@ public class CreateHomeScreenShortcutDialog extends DialogFragment { // Get the arguments. Bundle arguments = getArguments(); - // Remove the incorrect lint warning that the arguments might be null. + // Remove the incorrect lint warning below that the arguments might be null. assert arguments != null; // Store the strings in class variables. @@ -122,7 +123,14 @@ public class CreateHomeScreenShortcutDialog extends DialogFragment { @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { - // Remove the incorrect lint warning below that `getLayoutInflater()` might be null. + // Get a handle for the shared preferences. + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); + + // Get the theme and screenshot preferences. + boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false); + boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false); + + // Remove the incorrect lint warning below that the layout inflater might be null. assert getActivity() != null; // Get the activity's layout inflater. @@ -135,7 +143,7 @@ public class CreateHomeScreenShortcutDialog extends DialogFragment { AlertDialog.Builder dialogBuilder; // Set the style according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); } else { dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); @@ -164,7 +172,7 @@ public class CreateHomeScreenShortcutDialog extends DialogFragment { assert alertDialog.getWindow() != null; // Disable screenshots if not allowed. - if (!MainWebViewActivity.allowScreenshots) { + if (allowScreenshots) { alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); } diff --git a/app/src/main/res/menu/webview_options_menu.xml b/app/src/main/res/menu/webview_options_menu.xml index 6391bf6b..cc630b46 100644 --- a/app/src/main/res/menu/webview_options_menu.xml +++ b/app/src/main/res/menu/webview_options_menu.xml @@ -159,7 +159,7 @@ diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 992dc40d..e38c9e8c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -139,6 +139,7 @@ Fanboy’s Social Blocking Sperrliste Alle Zugriffe auf Dritt-Anbieter-Inhalte blockieren Ansicht + Privacy Browser WebView-Standard Firefox auf Android Chrome auf Android diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 564bbdf4..01d730e9 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -136,6 +136,7 @@ Lista de bloqueo social de Fanboy Bloquear todas las solicitudes de terceros Diseño + Navegador Privado WebView por defecto Firefox en Android Chrome en Android diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 168a3ed9..cecfe49c 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -136,6 +136,7 @@ Fanboy’s social blocking list Blocca tutte le richieste di Terze Parti Layout + Privacy Browser WebView Default Firefox su Android Chrome su Android diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 9ff1ed06..72de66e4 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -133,6 +133,7 @@ Fanboy’s social blocking list Блокировать все сторонние запросы Внешний вид + Privacy Browser WebView по умолчанию Firefox на Android Chrome на Android diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index e6dfa98c..414414e3 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -133,6 +133,7 @@ Fanboy Sosyal Engelleme Listesi Tüm Üçüncü Taraf İstekleri Engelle Düzen + Privacy Browser Varsayılan Web Görünümü Android\'te kurulu Firefox Android\'te kurulu Chrome diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0013e8e6..0a847464 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -143,6 +143,7 @@ Fanboy’s Social Blocking List Block All Third-Party Requests Layout + Privacy Browser WebView Default Firefox on Android Chrome on Android diff --git a/fastlane/metadata/android/it-IT/full_description.txt b/fastlane/metadata/android/it-IT/full_description.txt index c615cfc4..30f1208d 100644 --- a/fastlane/metadata/android/it-IT/full_description.txt +++ b/fastlane/metadata/android/it-IT/full_description.txt @@ -1,14 +1,13 @@ -Privacy Browser protegge la privacy perchè disabilita funzionalità come JavaScript, DOM storage e i cookie, che sono utilizzati dai siti web per tracciare gli utenti. Quando è necessario, le impostazioni possono però essere modificate per i singoli domini oppure globalmente in modo da abilitare queste funzionalità. In aggiunta, Privacy Browser include le block list di Easylist, che sono in grado di bloccare molte tecnologie di tracking anche con Javascript abilitato. +La maggioranza dei browser fornisce silenziosamente ai siti web un'enorme quantità di informazioni per permettere loro di tracciare l'utente e compromettere la sua privacy. I siti web e le reti pubblicitarie utilizzano diverse tecnologie, come JavaScript, i cookie, il DOM storage, gli user agent e molte altre, con lo scopo di identificare in modo univoco ogni utente e di tracciare la sua navigazione attraverso la rete. -Privacy Browser non permette ancora la navigazione con tab. Questa funzionalità è prevista per le release della serie 3.x. +Privacy Browser è progettato con lo scopo di minimizzare la quantità di informazioni che il browser fornisce ai siti web. Le funzionalità sensibili alla privacy sono disabilitate di default. Se però una di queste tecnologie è necessaria per il corretto funzionamento di un sito web l'utente può abilitarla anche per un accesso momentaneo. In alternativa è possibile utilizzare le impostazioni dei domini per abilitare in modo automatico determinate funzionalità nel momento in cui si accede ad un determinato sito web, così che siano poi disabilitate nel momento in cui si abbandona il sito. -Privacy Browser utilizza, per la visualizzazione delle pagine web, WebView nativo di Android. Per questo motivo il funzionamento è ottimale se Webview è aggiornato all'ultima versione. Nella futura serie 4.x Privacy Browser utilizzerà una versione modificata di Webview denominata Privacy WebView che introdurrà funzionalità avanzate per la privacy. +Privacy Browser utilizza attualmente la WebView nativa di Android per la visualizzazione delle pagine web. Per questo motivo si ha un funzionamento ottimale solo se è installata la versione più recente di WebView (si veda in proposito https://www.stoutner.com/privacy-browser/common-settings/webview/). A partire dalle release della serie 4.x, Privacy Browser passerà ad una versione modificata della WebView di Android chiamata Privacy WebView che permetterà l'utilizzo di funzionalità di privacy più avanzate. -Attenzione: Privacy Browser è vulnerabile agli attacchi MITM (Man In The Middle) quando si accede a siti non sicuri con dispositivi su cui è installato Android KitKat (versione 4.4.x, API 19). -Per maggiori informazioni sul problema è possibile consultare: https://www.stoutner.com/kitkat-security-problems/ +Attenzione: Android KitKat (versione 4.4.x, API 19) incorpora una versione più vecchia di OpenSSL, suscettibile agli attacchi MITM (Man In The Middle) quando si naviga su siti web che utilizzano protocolli e suite di cifratura superati. Maggiori informazioni al riguardo sono disponibili visitando la pagina web: https://www.stoutner.com/kitkat-security-problems/. Funzionalità: -• Supporto per Tor Orbot proxy. -• Possibilità di appuntare i certificati SSL. -• Navigazione a schermo intero. -• Modalità notte. +• Blocco degli annunci EasyList integrato. +• Possibilità di utilizzare il proxy Tor Orbot. +• Salvataggio dei certificati SSL. +• Import/Export delle impostazioni e dei segnalibri. \ No newline at end of file -- 2.43.0