Bug 1155860 - open a shared link -r?ahunt draft
authorShubham <shubham2892@gmail.com>
Fri, 18 Nov 2016 12:50:53 -0500
changeset 441319 20d2e8cdc22709de3cbcbfcd20f46b0b7a5c5266
parent 441209 a103e1713a2eda3b4e88d71df82d140487c8db87
child 537527 846c0c4226fb4548bf1668531014deb939be0a13
push id36392
push userbmo:shubham2892@gmail.com
push dateFri, 18 Nov 2016 18:13:55 +0000
bugs1155860
milestone53.0a1
Bug 1155860 - open a shared link -r?ahunt MozReview-Commit-ID: 6Vwfmpt4UQY
mobile/android/base/java/org/mozilla/gecko/overlays/ui/ShareDialog.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/resources/layout/overlay_share_button.xml
mobile/android/base/resources/layout/overlay_share_dialog.xml
mobile/android/base/strings.xml.in
--- a/mobile/android/base/java/org/mozilla/gecko/overlays/ui/ShareDialog.java
+++ b/mobile/android/base/java/org/mozilla/gecko/overlays/ui/ShareDialog.java
@@ -8,16 +8,17 @@ package org.mozilla.gecko.overlays.ui;
 import java.net.URISyntaxException;
 
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.Locales;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
+import org.mozilla.gecko.db.BrowserContract;
 import org.mozilla.gecko.db.LocalBrowserDB;
 import org.mozilla.gecko.db.RemoteClient;
 import org.mozilla.gecko.overlays.OverlayConstants;
 import org.mozilla.gecko.overlays.service.OverlayActionService;
 import org.mozilla.gecko.overlays.service.sharemethods.SendTab;
 import org.mozilla.gecko.overlays.service.sharemethods.ShareMethod;
 import org.mozilla.gecko.sync.setup.activities.WebURLFinder;
 import org.mozilla.gecko.util.IntentUtils;
@@ -61,16 +62,17 @@ public class ShareDialog extends Locales
 
     /** The maximum number of devices we'll show in the dialog when in State.DEFAULT. **/
     private static final int MAXIMUM_INLINE_DEVICES = 2;
 
     private State state;
 
     private SendTabList sendTabList;
     private OverlayDialogButton bookmarkButton;
+    private OverlayDialogButton openBrowserButton;
 
     // The bookmark button drawable set from XML - we need this to reset state.
     private Drawable bookmarkButtonDrawable;
 
     private String url;
     private String title;
 
     // The override intent specified by SendTab (if any). See SendTab.java.
@@ -174,28 +176,32 @@ public class ShareDialog extends Locales
         // Send tab.
         sendTabList = (SendTabList) findViewById(R.id.overlay_send_tab_btn);
 
         // Register ourselves as both the listener and the context for the Adapter.
         final SendTabDeviceListArrayAdapter adapter = new SendTabDeviceListArrayAdapter(this, this);
         sendTabList.setAdapter(adapter);
         sendTabList.setSendTabTargetSelectedListener(this);
 
-        bookmarkButton = (OverlayDialogButton) findViewById(R.id.overlay_share_bookmark_btn);
-
-        bookmarkButtonDrawable = bookmarkButton.getBackground();
-
         // Bookmark button
         bookmarkButton = (OverlayDialogButton) findViewById(R.id.overlay_share_bookmark_btn);
         bookmarkButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 addBookmark();
             }
         });
+        bookmarkButtonDrawable = bookmarkButton.getBackground();
+        openBrowserButton = (OverlayDialogButton) findViewById(R.id.overlay_share_open_browser_btn);
+        openBrowserButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                launchBrowser();
+            }
+        });
     }
 
     @Override
     protected void onResume() {
         super.onResume();
 
         final Intent intent = getIntent();
 
@@ -256,33 +262,22 @@ public class ShareDialog extends Locales
         subtitleView.setMarqueeRepeatLimit(5);
         subtitleView.setSelected(true);
 
         final View titleView = findViewById(R.id.title);
 
         if (state == State.DEVICES_ONLY) {
             bookmarkButton.setVisibility(View.GONE);
 
-            titleView.setOnClickListener(null);
-            subtitleView.setOnClickListener(null);
+            openBrowserButton.setVisibility(View.GONE);
             return;
         }
 
         bookmarkButton.setVisibility(View.VISIBLE);
-
-        // Configure buttons.
-        final View.OnClickListener launchBrowser = new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                ShareDialog.this.launchBrowser();
-            }
-        };
-
-        titleView.setOnClickListener(launchBrowser);
-        subtitleView.setOnClickListener(launchBrowser);
+        openBrowserButton.setVisibility(View.VISIBLE);
 
         final LocalBrowserDB browserDB = new LocalBrowserDB(getCurrentProfile());
         setButtonState(url, browserDB);
     }
 
     @Override
     protected void onNewIntent(final Intent intent) {
         super.onNewIntent(intent);
@@ -389,17 +384,19 @@ public class ShareDialog extends Locales
 
         Telemetry.sendUIEvent(TelemetryContract.Event.SAVE, TelemetryContract.Method.SHARE_OVERLAY, "bookmark");
     }
 
     public void launchBrowser() {
         try {
             // This can launch in the guest profile. Sorry.
             final Intent i = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
+            i.putExtra(BrowserContract.SKIP_TAB_QUEUE_FLAG, true);
             i.setClassName(AppConstants.ANDROID_PACKAGE_NAME, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
+
             startActivity(i);
         } catch (URISyntaxException e) {
             // Nothing much we can do.
         } finally {
             // Since we're changing apps, users expect the default app switch animations.
             finish(false);
         }
     }
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -151,16 +151,17 @@
 
 <!-- Localization note (overlay_share_bookmark_btn_label) : This string is
      used in the share overlay menu to select an action. It is the verb
      "to bookmark", not the noun "a bookmark". -->
 <!ENTITY overlay_share_bookmark_btn_label "Bookmark">
 <!ENTITY overlay_share_bookmark_btn_label_already "Already bookmarked">
 <!ENTITY overlay_share_send_other "Send to other devices">
 
+<!ENTITY overlay_share_open_browser_btn_label "Open in &brandShortName;">
 <!-- Localization note (overlay_share_send_tab_btn_label) : Used on the
      share overlay menu to represent the "Send Tab" action when the user
      either has not set up Sync, or has no other devices to send a tab
      to. -->
 <!ENTITY overlay_share_send_tab_btn_label "Send to another device">
 <!ENTITY overlay_share_no_url "No link found in this share">
 <!ENTITY overlay_share_select_device "Select device">
 <!-- Localization note (overlay_no_synced_devices) : Used when the menu option
--- a/mobile/android/base/resources/layout/overlay_share_button.xml
+++ b/mobile/android/base/resources/layout/overlay_share_button.xml
@@ -1,24 +1,27 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-    <ImageView
-        android:layout_width="60dp"
-        android:layout_height="match_parent"
-        android:id="@+id/overlaybtn_icon"
-        android:padding="30dp"
-        android:scaleType="center"/>
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+       xmlns:gecko="http://schemas.android.com/apk/res-auto">
+    <org.mozilla.gecko.widget.themed.ThemedImageView
+            android:id="@+id/overlaybtn_icon"
+            android:layout_width="30dp"
+            android:layout_height="30dp"
+            android:layout_margin="15dp"
+            gecko:drawableTintList="@color/action_bar_secondary_menu_item_colors"
+            android:scaleType="centerInside"/>
 
     <TextView
-        android:textAppearance="@style/TextAppearance.ShareOverlay"
-        android:id="@+id/overlaybtn_label"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:clickable="false"
-        android:enabled="false"
-        android:maxLines="1"
-        android:textSize="14sp"
-        android:textColor="@color/primary_text_selector"/>
+            android:textAppearance="@style/TextAppearance.ShareOverlay"
+            android:id="@+id/overlaybtn_label"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:clickable="false"
+            android:enabled="false"
+            android:maxLines="1"
+            android:textSize="14sp"
+            android:textColor="@color/primary_text_selector"/>
 </merge>
--- a/mobile/android/base/resources/layout/overlay_share_dialog.xml
+++ b/mobile/android/base/resources/layout/overlay_share_dialog.xml
@@ -58,16 +58,26 @@
             android:id="@+id/overlay_share_bookmark_btn"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:enabled="false"
             gecko:drawable="@drawable/overlay_share_bookmark_button"
             gecko:enabledText="@string/overlay_share_bookmark_btn_label"
             gecko:disabledText="@string/overlay_share_bookmark_btn_label_already"/>
 
+        <!-- "Open in Browser" -->
+        <org.mozilla.gecko.overlays.ui.OverlayDialogButton
+                style="@style/ShareOverlayRow"
+                android:id="@+id/overlay_share_open_browser_btn"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:enabled="false"
+                gecko:drawable="@drawable/icon_search_empty_firefox"
+                gecko:enabledText="@string/overlay_share_open_browser_btn_label"/>
+
     </LinearLayout>
 
     <ImageView
         android:id="@+id/check"
         android:layout_height="wrap_content"
         android:layout_width="wrap_content"
         android:layout_gravity="center"
         android:src="@drawable/overlay_check"
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -126,16 +126,17 @@
   <string name="find_next">&find_next;</string>
   <string name="find_close">&find_close;</string>
 
   <string name="media_sending_to">&media_sending_to;</string>
   <string name="media_play">&media_play;</string>
   <string name="media_pause">&media_pause;</string>
   <string name="media_stop">&media_stop;</string>
 
+  <string name="overlay_share_open_browser_btn_label">&overlay_share_open_browser_btn_label;</string>
   <string name="overlay_share_send_other">&overlay_share_send_other;</string>
   <string name="overlay_share_label">&overlay_share_label;</string>
   <string name="overlay_share_bookmark_btn_label">&overlay_share_bookmark_btn_label;</string>
   <string name="overlay_share_bookmark_btn_label_already">&overlay_share_bookmark_btn_label_already;</string>
   <string name="overlay_share_send_tab_btn_label">&overlay_share_send_tab_btn_label;</string>
   <string name="overlay_share_no_url">&overlay_share_no_url;</string>
   <string name="overlay_share_select_device">&overlay_share_select_device;</string>
   <string name="overlay_no_synced_devices">&overlay_no_synced_devices;</string>