]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Add a new Share URL menu entry. https://redmine.stoutner.com/issues/838
authorSoren Stoutner <soren@stoutner.com>
Thu, 31 Mar 2022 19:38:35 +0000 (12:38 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 31 Mar 2022 19:38:35 +0000 (12:38 -0700)
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/res/menu/webview_options_menu.xml
app/src/main/res/values/strings.xml

index ecab353f0dd1b0b6cea8e4da652ee4cddf7555a2..45a1de5b1c94e2c9267c6355eeaa8e9ccf113622 100644 (file)
@@ -1850,24 +1850,45 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
             // Consume the event.
             return true;
 
             // Consume the event.
             return true;
-        } else if (menuItemId == R.id.share_url) {  // Share URL.
-            // Setup the share string.
+        } else if (menuItemId == R.id.share_message) {  // Share a message.
+            // Prepare the share string.
             String shareString = currentWebView.getTitle() + " – " + currentWebView.getUrl();
 
             // Create the share intent.
             String shareString = currentWebView.getTitle() + " – " + currentWebView.getUrl();
 
             // Create the share intent.
-            Intent shareIntent = new Intent(Intent.ACTION_SEND);
+            Intent shareMessageIntent = new Intent(Intent.ACTION_SEND);
 
             // Add the share string to the intent.
 
             // Add the share string to the intent.
-            shareIntent.putExtra(Intent.EXTRA_TEXT, shareString);
+            shareMessageIntent.putExtra(Intent.EXTRA_TEXT, shareString);
 
             // Set the MIME type.
 
             // Set the MIME type.
-            shareIntent.setType("text/plain");
+            shareMessageIntent.setType("text/plain");
 
             // Set the intent to open in a new task.
 
             // Set the intent to open in a new task.
-            shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            shareMessageIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
             // Make it so.
 
             // Make it so.
-            startActivity(Intent.createChooser(shareIntent, getString(R.string.share_url)));
+            startActivity(Intent.createChooser(shareMessageIntent, getString(R.string.share_message)));
+
+            // Consume the event.
+            return true;
+        } else if (menuItemId == R.id.share_url) {  // Share URL.
+            // Create the share intent.
+            Intent shareUrlIntent = new Intent(Intent.ACTION_SEND);
+
+            // Add the URL to the intent.
+            shareUrlIntent.putExtra(Intent.EXTRA_TEXT, currentWebView.getUrl());
+
+            // Add the title to the intent.
+            shareUrlIntent.putExtra(Intent.EXTRA_SUBJECT, currentWebView.getTitle());
+
+            // Set the MIME type.
+            shareUrlIntent.setType("text/plain");
+
+            // Set the intent to open in a new task.
+            shareUrlIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+            //Make it so.
+            startActivity(Intent.createChooser(shareUrlIntent, getString(R.string.share_url)));
 
             // Consume the event.
             return true;
 
             // Consume the event.
             return true;
index dcebc2e3d852b533bf960a007eceafc265d002c0..3587bf8e6af6784defb52befc792ab51ca244e6c 100644 (file)
         app:showAsAction="never" >
 
         <menu>
         app:showAsAction="never" >
 
         <menu>
+            <item
+                android:id="@+id/share_message"
+                android:title="@string/share_message"
+                android:orderInCategory="1310"
+                app:showAsAction="never" />
+
             <item
                 android:id="@+id/share_url"
                 android:title="@string/share_url"
             <item
                 android:id="@+id/share_url"
                 android:title="@string/share_url"
-                android:orderInCategory="1310"
+                android:orderInCategory="1320"
                 app:showAsAction="never" />
 
             <item
                 android:id="@+id/open_with_app"
                 android:title="@string/open_with_app"
                 app:showAsAction="never" />
 
             <item
                 android:id="@+id/open_with_app"
                 android:title="@string/open_with_app"
-                android:orderInCategory="1320"
+                android:orderInCategory="1330"
                 app:showAsAction="never" />
 
             <item
                 android:id="@+id/open_with_browser"
                 android:title="@string/open_with_browser"
                 app:showAsAction="never" />
 
             <item
                 android:id="@+id/open_with_browser"
                 android:title="@string/open_with_browser"
-                android:orderInCategory="1330"
+                android:orderInCategory="1340"
                 app:showAsAction="never" />
         </menu>
     </item>
                 app:showAsAction="never" />
         </menu>
     </item>
index bf0b642872142cd762c068e4c1b8a81b993a3bc0..2ea42e68529a8b12e38179120baa357ca165ade3 100644 (file)
         <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="add_to_home_screen">Add to Home Screen</string>
         <string name="view_source">View Source</string>
     <string name="share">Share</string>
+        <string name="share_message">Share Message</string>
         <string name="share_url">Share URL</string>
         <string name="open_with_app">Open with App</string>
         <string name="open_with_browser">Open with Browser</string>
         <string name="share_url">Share URL</string>
         <string name="open_with_app">Open with App</string>
         <string name="open_with_browser">Open with Browser</string>