]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Add an option to always have home screen shortcuts open in Privacy Browser. https...
authorSoren Stoutner <soren@stoutner.com>
Mon, 25 Feb 2019 21:12:14 +0000 (14:12 -0700)
committerSoren Stoutner <soren@stoutner.com>
Mon, 25 Feb 2019 21:12:14 +0000 (14:12 -0700)
app/src/free/res/values/strings.xml
app/src/main/java/com/stoutner/privacybrowser/dialogs/CreateHomeScreenShortcutDialog.java
app/src/main/res/layout/create_home_screen_shortcut_dialog.xml
app/src/main/res/values-it/strings.xml
app/src/main/res/values/strings.xml

index cb6b21b5c3ceabfb8fa228ca25e9df0664dd7077..cead48b1995857a766d2bb4384a2b7eef986eb7e 100644 (file)
     <!-- Activities. -->
     <string name="privacy_browser">Privacy Browser Free</string>
 
     <!-- Activities. -->
     <string name="privacy_browser">Privacy Browser Free</string>
 
-    <!-- Ad Control. -->
-    <string name="google_app_id" translatable="false">ca-app-pub-5962503714887045~2738552414</string>
-    <string name="ad_unit_id" translatable="false">ca-app-pub-5962503714887045/2738552414</string>
-
-    <!-- Test Ad Control.
-    <string name="google_app_id" translatable="false">ca-app-pub-3940256099942544~3347511713</string>
-    <string name="ad_unit_id" translatable="false">ca-app-pub-3940256099942544/6300978111</string> -->
+    <!-- Create Home Screen Shortcut Alert Dialog. -->
+    <string name="open_with_privacy_browser">Open with Privacy Browser Free.</string>
 
     <!-- Ad Consent. -->
     <string name="ad_consent_text">Privacy Browser Free displays a banner ad on the bottom of the screen.
 
     <!-- Ad Consent. -->
     <string name="ad_consent_text">Privacy Browser Free displays a banner ad on the bottom of the screen.
         \n\nThe standard version of Privacy Browser does not contain app ads.</string>
     <string name="close_browser">Close Browser</string>
     <string name="accept_ads">Accept Ads</string>
         \n\nThe standard version of Privacy Browser does not contain app ads.</string>
     <string name="close_browser">Close Browser</string>
     <string name="accept_ads">Accept Ads</string>
+
+    <!-- Ad Control. -->
+    <string name="google_app_id" translatable="false">ca-app-pub-5962503714887045~2738552414</string>
+    <string name="ad_unit_id" translatable="false">ca-app-pub-5962503714887045/2738552414</string>
+
+    <!-- Test Ad Control.
+    <string name="google_app_id" translatable="false">ca-app-pub-3940256099942544~3347511713</string>
+    <string name="ad_unit_id" translatable="false">ca-app-pub-3940256099942544/6300978111</string> -->
 </resources>
\ No newline at end of file
 </resources>
\ No newline at end of file
index 32cd5facd7cffac1bd57bfa8ca1fbc2ce76122c1..e3221a212c2450c795b5932181e24023a58d9707 100644 (file)
@@ -39,14 +39,16 @@ import android.view.View;
 import android.view.WindowManager;
 import android.widget.Button;
 import android.widget.EditText;
 import android.view.WindowManager;
 import android.widget.Button;
 import android.widget.EditText;
+import android.widget.RadioButton;
 
 import androidx.annotation.NonNull;
 
 import androidx.annotation.NonNull;
-// `ShortcutInfoCompat`, `ShortcutManagerCompat`, and `IconCompat` can be switched to the non-compat versions once API >= 26.
+// `ShortcutInfoCompat`, `ShortcutManagerCompat`, and `IconCompat` can be switched to the non-compat versions once the minimum API >= 26.
 import androidx.core.content.pm.ShortcutInfoCompat;
 import androidx.core.content.pm.ShortcutManagerCompat;
 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 androidx.core.content.pm.ShortcutInfoCompat;
 import androidx.core.content.pm.ShortcutManagerCompat;
 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 com.stoutner.privacybrowser.activities.MainWebViewActivity;
 import com.stoutner.privacybrowser.R;
 
@@ -59,6 +61,7 @@ public class CreateHomeScreenShortcutDialog extends DialogFragment {
     private Bitmap favoriteIconBitmap;
     private EditText shortcutNameEditText;
     private EditText urlEditText;
     private Bitmap favoriteIconBitmap;
     private EditText shortcutNameEditText;
     private EditText urlEditText;
+    private RadioButton openWithPrivacyBrowserRadioButton;
     private Button createButton;
 
     public static CreateHomeScreenShortcutDialog createDialog(String shortcutName, String urlString, Bitmap favoriteIconBitmap) {
     private Button createButton;
 
     public static CreateHomeScreenShortcutDialog createDialog(String shortcutName, String urlString, Bitmap favoriteIconBitmap) {
@@ -168,17 +171,16 @@ public class CreateHomeScreenShortcutDialog extends DialogFragment {
         // The alert dialog must be shown before the contents may be edited.
         alertDialog.show();
 
         // The alert dialog must be shown before the contents may be edited.
         alertDialog.show();
 
-        // Get a handle for the edit texts.
+        // Get handles for the views.
         shortcutNameEditText = alertDialog.findViewById(R.id.shortcut_name_edittext);
         urlEditText = alertDialog.findViewById(R.id.url_edittext);
         shortcutNameEditText = alertDialog.findViewById(R.id.shortcut_name_edittext);
         urlEditText = alertDialog.findViewById(R.id.url_edittext);
+        openWithPrivacyBrowserRadioButton = alertDialog.findViewById(R.id.open_with_privacy_browser_radiobutton);
+        createButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
 
         // Populate the edit texts.
         shortcutNameEditText.setText(initialShortcutName);
         urlEditText.setText(initialUrlString);
 
 
         // Populate the edit texts.
         shortcutNameEditText.setText(initialShortcutName);
         urlEditText.setText(initialUrlString);
 
-        // Get a handle for the create button.
-        createButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
-
         // Add a text change listener to the shortcut name edit text.
         shortcutNameEditText.addTextChangedListener(new TextWatcher() {
             @Override
         // Add a text change listener to the shortcut name edit text.
         shortcutNameEditText.addTextChangedListener(new TextWatcher() {
             @Override
@@ -292,8 +294,16 @@ public class CreateHomeScreenShortcutDialog extends DialogFragment {
         // Convert the favorite icon bitmap to an icon.  `IconCompat` must be used until the minimum API >= 26.
         IconCompat favoriteIcon = IconCompat.createWithBitmap(favoriteIconBitmap);
 
         // Convert the favorite icon bitmap to an icon.  `IconCompat` must be used until the minimum API >= 26.
         IconCompat favoriteIcon = IconCompat.createWithBitmap(favoriteIconBitmap);
 
-        // Setup the shortcut intent.
+        // Create a shortcut intent.
         Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
         Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
+
+        // Check to see if the shortcut should open up Privacy Browser explicitly.
+        if (openWithPrivacyBrowserRadioButton.isChecked()) {
+            // Set the current application ID as the target package.
+            shortcutIntent.setPackage(BuildConfig.APPLICATION_ID);
+        }
+
+        // Add the URL to the intent.
         shortcutIntent.setData(Uri.parse(urlString));
 
         // Create a shortcut info builder.  The shortcut name becomes the shortcut ID.
         shortcutIntent.setData(Uri.parse(urlString));
 
         // Create a shortcut info builder.  The shortcut name becomes the shortcut ID.
index 3b3c2449701d8ebd3d561420e50a6a1bbbc4a17d..aaadcd459facdf7bc324802eeb25d063ee740037 100644 (file)
@@ -33,7 +33,7 @@
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
             android:layout_marginTop="16dp"
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
             android:layout_marginTop="16dp"
-            android:layout_marginBottom="5dp"
+            android:layout_marginBottom="4dp"
             android:layout_marginStart="8dp"
             android:layout_marginEnd="8dp" >
 
             android:layout_marginStart="8dp"
             android:layout_marginEnd="8dp" >
 
@@ -52,8 +52,8 @@
         <com.google.android.material.textfield.TextInputLayout
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
         <com.google.android.material.textfield.TextInputLayout
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
-            android:layout_marginTop="5dp"
-            android:layout_marginBottom="10dp"
+            android:layout_marginTop="4dp"
+            android:layout_marginBottom="8dp"
             android:layout_marginStart="8dp"
             android:layout_marginEnd="8dp" >
 
             android:layout_marginStart="8dp"
             android:layout_marginEnd="8dp" >
 
                 android:inputType="textUri"
                 android:selectAllOnFocus="true" />
         </com.google.android.material.textfield.TextInputLayout>
                 android:inputType="textUri"
                 android:selectAllOnFocus="true" />
         </com.google.android.material.textfield.TextInputLayout>
+
+        <RadioGroup
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:layout_marginBottom="2dp"
+            android:layout_marginStart="6dp"
+            android:layout_marginEnd="6dp"
+            android:checkedButton="@+id/open_with_default_browser_radiobutton" >
+
+            <RadioButton
+                android:id="@id/open_with_default_browser_radiobutton"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:layout_marginBottom="4dp"
+                android:text="@string/open_with_default_browser"
+                android:textSize="18sp"
+                android:textColor="?android:textColorPrimary" />
+
+            <RadioButton
+                android:id="@+id/open_with_privacy_browser_radiobutton"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:layout_marginTop="4dp"
+                android:text="@string/open_with_privacy_browser"
+                android:textSize="18sp"
+                android:textColor="?android:textColorPrimary" />
+        </RadioGroup>
     </LinearLayout>
 </ScrollView>
\ No newline at end of file
     </LinearLayout>
 </ScrollView>
\ No newline at end of file
index 9c6a23b86641077f9766866b470bd968b04649d4..26893f212d45a94a74491034d81970f59908e924 100644 (file)
     <string name="full_screen">Schermo intero</string>
         <string name="full_screen_browsing_mode">Navigazione a schermo intero</string>
         <string name="full_screen_browsing_mode_summary">Toccare due volte per avviare la navigazione a schermo intero.</string>
     <string name="full_screen">Schermo intero</string>
         <string name="full_screen_browsing_mode">Navigazione a schermo intero</string>
         <string name="full_screen_browsing_mode_summary">Toccare due volte per avviare la navigazione a schermo intero.</string>
+        <string name="hide_app_bar">Nascondi la barra dell\'applicazione</string>
+        <string name="hide_app_bar_summary">Nasconde la barra che contiene l\'URL.</string>
     <string name="clear_everything">Elimina tutto</string>
         <string name="clear_everything_summary">Cancella i cookies, il DOM storage, i dati dei moduli e la cache di WebView.  Cancella completamente le cartelle “app_webview” e “cache”.</string>
         <string name="clear_cookies_preference">Elimina i cookie</string>
     <string name="clear_everything">Elimina tutto</string>
         <string name="clear_everything_summary">Cancella i cookies, il DOM storage, i dati dei moduli e la cache di WebView.  Cancella completamente le cartelle “app_webview” e “cache”.</string>
         <string name="clear_cookies_preference">Elimina i cookie</string>
             </string-array>
         <string name="swipe_to_refresh">Swipe per aggiornare</string>
         <string name="swipe_to_refresh_summary">Alcuni siti non funzionano correttamente se questa opzione è abilitata.</string>
             </string-array>
         <string name="swipe_to_refresh">Swipe per aggiornare</string>
         <string name="swipe_to_refresh_summary">Alcuni siti non funzionano correttamente se questa opzione è abilitata.</string>
+        <string name="scroll_app_bar">Permetti lo scrolling della barra dell\'applicazione</string>
+        <string name="scroll_app_bar_summary">Permette lo scorrere della barra dell\'applicazione dalla parte alta dello schermo quando si effettua lo scrolling.</string>
         <string name="display_additional_app_bar_icons">Mostra icone addizionali nella barra dell\'applicazione</string>
         <string name="display_additional_app_bar_icons_summary">Mostra nella barra dell\'applicazione le icone per l\'aggiornamento di WebView e, se lo spazio è sufficiente,
             per l\'attivazione dei cookie e del DOM storage.</string>
         <string name="display_additional_app_bar_icons">Mostra icone addizionali nella barra dell\'applicazione</string>
         <string name="display_additional_app_bar_icons_summary">Mostra nella barra dell\'applicazione le icone per l\'aggiornamento di WebView e, se lo spazio è sufficiente,
             per l\'attivazione dei cookie e del DOM storage.</string>
index c4e39018ed66a29e84eea2f1f9d11187431c0d9a..3a8ed17e5adf0f1882ef76949d861ca30a408b4f 100644 (file)
     <!-- Create Home Screen Shortcut Alert Dialog. -->
     <string name="create_shortcut">Create Shortcut</string>
     <string name="shortcut_name">Shortcut name</string>
     <!-- Create Home Screen Shortcut Alert Dialog. -->
     <string name="create_shortcut">Create Shortcut</string>
     <string name="shortcut_name">Shortcut name</string>
+    <string name="open_with_default_browser">Open with default browser.</string>
+    <string name="open_with_privacy_browser">Open with Privacy Browser.</string>
     <string name="cancel">Cancel</string>
     <string name="create">Create</string>
 
     <string name="cancel">Cancel</string>
     <string name="create">Create</string>
 
         <string name="display_webpage_images">Display webpage images</string>
         <string name="display_webpage_images_summary">Disable to conserve bandwidth.</string>
 
         <string name="display_webpage_images">Display webpage images</string>
         <string name="display_webpage_images_summary">Disable to conserve bandwidth.</string>
 
-    <!-- Non-translatable preference items. -->
+    <!-- Non-translatable preference default values. -->
     <string name="user_agent_default_value" translatable="false">Privacy Browser</string>
     <string name="custom_user_agent_default_value" translatable="false">PrivacyBrowser/1.0</string>
     <string name="tor_homepage_default_value" translatable="false">http://ulrn6sryqaifefld.onion/</string>
     <string name="user_agent_default_value" translatable="false">Privacy Browser</string>
     <string name="custom_user_agent_default_value" translatable="false">PrivacyBrowser/1.0</string>
     <string name="tor_homepage_default_value" translatable="false">http://ulrn6sryqaifefld.onion/</string>