Bug 1074570 - Dismiss start pane on touch. r=rnewman
authorChenxia Liu <liuche@mozilla.com>
Wed, 01 Oct 2014 10:26:17 -0700
changeset 208182 611fa34ae0863337fae33b00ad4b83949b288fb9
parent 208181 e8b947548ce64607f1dbfc952a4c9d61d619485e
child 208183 79211bb59624727f46a0d7febfe25b0b89c2c109
push id27579
push userkwierso@gmail.com
push dateWed, 01 Oct 2014 23:02:13 +0000
treeherderautoland@f771fd927304 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1074570
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1074570 - Dismiss start pane on touch. r=rnewman
mobile/android/base/StartPane.java
mobile/android/base/resources/layout/onboard_start_pane.xml
--- a/mobile/android/base/StartPane.java
+++ b/mobile/android/base/StartPane.java
@@ -1,17 +1,21 @@
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.fxa.activities.FxAccountGetStartedActivity;
+import org.mozilla.gecko.util.HardwareUtils;
 
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.View.OnTouchListener;
 import android.widget.Button;
 
 public class StartPane extends Activity {
 
     @Override
     public void onCreate(Bundle bundle) {
         super.onCreate(bundle);
         setContentView(R.layout.onboard_start_pane);
@@ -30,22 +34,44 @@ public class StartPane extends Activity 
         browserButton.setOnClickListener(new OnClickListener() {
 
             @Override
             public void onClick(View v) {
                 Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-browser");
                 showBrowser();
             }
         });
+
+        if (!HardwareUtils.isTablet() && !HardwareUtils.isTelevision()) {
+            addDismissHandler();
+        }
     }
 
     private void showBrowser() {
         // StartPane is on the stack above the browser, so just kill this activity.
         finish();
     }
 
     private void showAccountSetup() {
         final Intent intent = new Intent(this, FxAccountGetStartedActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(intent);
         finish();
     }
+
+    // Add handler for dismissing the StartPane on a single click.
+    private void addDismissHandler() {
+        final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
+            @Override
+            public boolean onSingleTapUp(MotionEvent e) {
+                StartPane.this.finish();
+                return true;
+            }
+        });
+
+        findViewById(R.id.onboard_content).setOnTouchListener(new OnTouchListener() {
+            @Override
+            public boolean onTouch(View v, MotionEvent event) {
+                return gestureDetector.onTouchEvent(event);
+            }
+        });
+    }
 }
--- a/mobile/android/base/resources/layout/onboard_start_pane.xml
+++ b/mobile/android/base/resources/layout/onboard_start_pane.xml
@@ -5,17 +5,18 @@
 
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
               style="@style/OnboardStartLayout"
               android:orientation="vertical"
               android:background="@color/onboard_start"
               android:windowIsFloating="true">
 
-    <ScrollView android:layout_width="match_parent"
+    <ScrollView android:id="@+id/onboard_content"
+                android:layout_width="match_parent"
                 android:layout_height="0dp"
                 android:layout_weight="1"
                 android:fillViewport="true" >
 
         <LinearLayout android:orientation="vertical"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content">