Bug 1073010 - Allow browsing from share overlay. r=margaret, a=sledru
authorRichard Newman <rnewman@mozilla.com>
Tue, 14 Oct 2014 17:05:31 -0700
changeset 225611 58d1381493ffba3d5d19c2183beebdcce2f079fb
parent 225610 e3652317f6f1ad90708ec455e872e095d974d272
child 225612 8949cb909bafc5ea0565e2f60c603dc34b16d152
push id7130
push userryanvm@gmail.com
push dateMon, 20 Oct 2014 17:19:48 +0000
treeherdermozilla-aurora@8949cb909baf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, sledru
bugs1073010
milestone35.0a2
Bug 1073010 - Allow browsing from share overlay. r=margaret, a=sledru
mobile/android/base/overlays/ui/ShareDialog.java
mobile/android/base/resources/layout/overlay_share_dialog.xml
--- a/mobile/android/base/overlays/ui/ShareDialog.java
+++ b/mobile/android/base/overlays/ui/ShareDialog.java
@@ -1,50 +1,55 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * 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/. */
 
 package org.mozilla.gecko.overlays.ui;
 
+import java.net.URISyntaxException;
+
+import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.Assert;
+import org.mozilla.gecko.GeckoProfile;
+import org.mozilla.gecko.LocaleAware;
+import org.mozilla.gecko.R;
+import org.mozilla.gecko.db.LocalBrowserDB;
+import org.mozilla.gecko.overlays.OverlayConstants;
+import org.mozilla.gecko.overlays.service.OverlayActionService;
+import org.mozilla.gecko.overlays.service.sharemethods.ParcelableClientRecord;
+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.HardwareUtils;
+import org.mozilla.gecko.util.StringUtils;
+import org.mozilla.gecko.util.ThreadUtils;
+import org.mozilla.gecko.util.UIAsyncTask;
+
 import android.content.BroadcastReceiver;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Parcelable;
 import android.support.v4.content.LocalBroadcastManager;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.animation.Animation;
 import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.Toast;
 
-import org.mozilla.gecko.Assert;
-import org.mozilla.gecko.GeckoProfile;
-import org.mozilla.gecko.R;
-import org.mozilla.gecko.db.LocalBrowserDB;
-import org.mozilla.gecko.overlays.OverlayConstants;
-import org.mozilla.gecko.overlays.service.OverlayActionService;
-import org.mozilla.gecko.overlays.service.sharemethods.ParcelableClientRecord;
-import org.mozilla.gecko.overlays.service.sharemethods.SendTab;
-import org.mozilla.gecko.overlays.service.sharemethods.ShareMethod;
-import org.mozilla.gecko.LocaleAware;
-import org.mozilla.gecko.sync.setup.activities.WebURLFinder;
-import org.mozilla.gecko.util.HardwareUtils;
-import org.mozilla.gecko.util.StringUtils;
-import org.mozilla.gecko.util.ThreadUtils;
-import org.mozilla.gecko.util.UIAsyncTask;
-
 /**
  * A transparent activity that displays the share overlay.
  */
 public class ShareDialog extends LocaleAware.LocaleAwareActivity implements SendTabTargetSelectedListener {
     private static final String LOGTAG = "GeckoShareDialog";
 
     private String url;
     private String title;
@@ -160,16 +165,28 @@ public class ShareDialog extends LocaleA
         subtitleView.setMarqueeRepeatLimit(5);
         subtitleView.setSelected(true);
 
         // Start the slide-up animation.
         Animation anim = AnimationUtils.loadAnimation(this, R.anim.overlay_slide_up);
         findViewById(R.id.sharedialog).startAnimation(anim);
 
         // Configure buttons.
+        final ImageView foxIcon = (ImageView) findViewById(R.id.share_overlay_icon);
+        final LinearLayout topBar = (LinearLayout) findViewById(R.id.share_overlay_top_bar);
+        View.OnClickListener launchBrowser = new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                ShareDialog.this.launchBrowser();
+            }
+        };
+
+        foxIcon.setOnClickListener(launchBrowser);
+        topBar.setOnClickListener(launchBrowser);
+
         final OverlayDialogButton bookmarkBtn = (OverlayDialogButton) findViewById(R.id.overlay_share_bookmark_btn);
 
         final String bookmarkEnabledLabel = resources.getString(R.string.overlay_share_bookmark_btn_label);
         final Drawable bookmarkEnabledIcon = resources.getDrawable(R.drawable.overlay_bookmark_icon);
         bookmarkBtn.setEnabledLabelAndIcon(bookmarkEnabledLabel, bookmarkEnabledIcon);
 
         final String bookmarkDisabledLabel = resources.getString(R.string.overlay_share_bookmark_btn_label_already);
         final Drawable bookmarkDisabledIcon = resources.getDrawable(R.drawable.overlay_bookmarked_already_icon);
@@ -313,16 +330,29 @@ public class ShareDialog extends LocaleA
         slideOut();
     }
 
     public void addBookmark() {
         startService(getServiceIntent(ShareMethod.Type.ADD_BOOKMARK));
         slideOut();
     }
 
+    public void launchBrowser() {
+        try {
+            // This can launch in the guest profile. Sorry.
+            final Intent i = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
+            i.setClassName(AppConstants.ANDROID_PACKAGE_NAME, AppConstants.BROWSER_INTENT_CLASS_NAME);
+            startActivity(i);
+        } catch (URISyntaxException e) {
+            // Nothing much we can do.
+        } finally {
+            slideOut();
+        }
+    }
+
     private String getCurrentProfile() {
         return GeckoProfile.DEFAULT_PROFILE;
     }
 
     /**
      * Slide the overlay down off the screen and destroy it.
      */
     private void slideOut() {
--- a/mobile/android/base/resources/layout/overlay_share_dialog.xml
+++ b/mobile/android/base/resources/layout/overlay_share_dialog.xml
@@ -22,16 +22,17 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:paddingTop="8dp"
         android:orientation="vertical"
         android:background="@drawable/share_overlay_background">
 
         <!-- Header -->
         <LinearLayout
+            android:id="@+id/share_overlay_top_bar"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_margin="0dp"
             android:background="@color/overlay_share_header_background"
             android:orientation="vertical"
             android:paddingTop="10dp"
             android:paddingBottom="15dp"
             android:paddingLeft="15dp"
@@ -99,16 +100,17 @@
                 android:id="@+id/overlay_share_bookmark_btn"
                 android:enabled="false"/>
 
         </LinearLayout>
     </LinearLayout>
 
     <!-- Firefox logo (has to appear higher in the z-order than the content. -->
     <ImageView
+        android:id="@+id/share_overlay_icon"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_above="@+id/share_overlay_content"
         android:scaleType="center"
         android:layout_centerHorizontal="true"
         android:src="@drawable/icon"
         android:layout_marginBottom="-6dp"/>
 </RelativeLayout>