Bug 1149208 - Make it easier to create a Firefox Account pointing at stage. r=rnewman
☠☠ backed out by 2231275e63c3 ☠ ☠
authorNick Alexander <nalexander@mozilla.com>
Mon, 30 Mar 2015 13:31:58 -0700
changeset 238661 1993201b592bb4a7b56aa6eef7404d32117d388a
parent 238660 82c4a7172cbe8dd4bf92bb6afcc4e760072f2cea
child 238662 2231275e63c393b5f150702bc2dd035ea396e295
push idunknown
push userunknown
push dateunknown
reviewersrnewman
bugs1149208
milestone40.0a1
Bug 1149208 - Make it easier to create a Firefox Account pointing at stage. r=rnewman ======== https://github.com/mozilla-services/android-sync/commit/a0ccd381743fde6b8016783951beb991ddce934a Author: Nick Alexander <nalexander@mozilla.com> Bug 1149208 - Make it easier to create a Firefox Account pointing at stage. Tap the Firefox icon 5 times on the Getting Started screen, and the account sign up flow will start, pointing at the stage account constellation.
mobile/android/base/fxa/activities/FxAccountGetStartedActivity.java
--- a/mobile/android/base/fxa/activities/FxAccountGetStartedActivity.java
+++ b/mobile/android/base/fxa/activities/FxAccountGetStartedActivity.java
@@ -1,23 +1,25 @@
 /* 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.fxa.activities;
 
 import java.util.Locale;
 
+import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.Locales;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.background.common.log.Logger;
 import org.mozilla.gecko.background.fxa.FxAccountAgeLockoutHelper;
 import org.mozilla.gecko.background.fxa.FxAccountUtils;
 import org.mozilla.gecko.fxa.FirefoxAccounts;
 import org.mozilla.gecko.fxa.FxAccountConstants;
+import org.mozilla.gecko.fxa.FxAccountServerConfiguration;
 import org.mozilla.gecko.sync.setup.activities.ActivityUtils;
 
 import android.accounts.AccountAuthenticatorActivity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.os.SystemClock;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -30,16 +32,24 @@ import android.widget.TextView;
 /**
  * Activity which displays sign up/sign in screen to the user.
  */
 public class FxAccountGetStartedActivity extends AccountAuthenticatorActivity {
   protected static final String LOG_TAG = FxAccountGetStartedActivity.class.getSimpleName();
 
   private static final int CHILD_REQUEST_CODE = 1;
 
+  // If the user clicks the email field this many times, the account sign up flow will start,
+  // using the stage server configuration.
+  @SuppressWarnings("unused")
+  private final int NUMBER_OF_CLICKS_TO_LAUNCH_STAGE_FLOW =
+      // !defined(MOZILLA_OFFICIAL) || defined(NIGHTLY_BUILD) || defined(MOZ_DEBUG)
+      (!AppConstants.MOZILLA_OFFICIAL || AppConstants.NIGHTLY_BUILD || AppConstants.DEBUG_BUILD) ? 5 : -1 /* infinite */;
+  private int stageFlowClickCount = 0;
+
   /**
    * {@inheritDoc}
    */
   @Override
   public void onCreate(Bundle icicle) {
     Logger.setThreadLogTag(FxAccountConstants.GLOBAL_LOG_TAG);
     Logger.debug(LOG_TAG, "onCreate(" + icicle + ")");
 
@@ -58,41 +68,52 @@ public class FxAccountGetStartedActivity
         Bundle extras = null; // startFlow accepts null.
         if (getIntent() != null) {
           extras = getIntent().getExtras();
         }
         startFlow(extras);
       }
     });
 
-    animateIconIn();
+    final View iconView = findViewById(R.id.icon);
+    animateIconIn(iconView);
+
+    iconView.setOnClickListener(new OnClickListener() {
+      @Override
+      public void onClick(View v) {
+        stageFlowClickCount += 1;
+        if (NUMBER_OF_CLICKS_TO_LAUNCH_STAGE_FLOW > 0 && stageFlowClickCount >= NUMBER_OF_CLICKS_TO_LAUNCH_STAGE_FLOW) {
+          stageFlowClickCount = 0;
+          startFlow(FxAccountServerConfiguration.Stage.toBundle());
+        }
+      }
+    });
   }
 
   /**
    * Float the icon up, starting from below and moving up to its final layout
    * position.  Also, fade the icon in.
    * <p>
    * We animate relative to the size of the icon rather than from the bottom of
    * the containing view for two reasons: first, the distance from bottom could
    * be large on tablets; two, animating with absolute values requires that
    * measurement has happened first, which requires a (sometimes buggy)
    * onPreDrawListener.
    */
-  protected void animateIconIn() {
+  protected void animateIconIn(View iconView) {
     final AlphaAnimation a = new AlphaAnimation(0.0f, 1.0f);
     final TranslateAnimation t = new TranslateAnimation(
         Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
         Animation.RELATIVE_TO_SELF, 2.0f, Animation.RELATIVE_TO_SELF, 0.0f);
 
     final AnimationSet animationSet = new AnimationSet(true);
     animationSet.setDuration(150 * 7); // Straight outta... fxa-content-server.
     animationSet.addAnimation(a);
     animationSet.addAnimation(t);
 
-    final View iconView = findViewById(R.id.icon);
     iconView.startAnimation(animationSet);
   }
 
   protected void startFlow(Bundle extras) {
     final Intent intent = new Intent(this, FxAccountCreateAccountActivity.class);
     // Per http://stackoverflow.com/a/8992365, this triggers a known bug with
     // the soft keyboard not being shown for the started activity. Why, Android, why?
     intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);