Bug 1225092 - Improper behavior when accessing log in screen from on-boarding screen. r=ally
authorChenxia Liu <liuche@mozilla.com>
Fri, 20 Nov 2015 15:23:49 -0500
changeset 310789 6502f752a806bbb9f485968d19704b3ec1802e99
parent 310788 11a75b65a0f5d82213be0db96b8f2002901baaa1
child 310790 085e53fcfa82c89f4b9db22c64c083eea61b5471
child 310791 d7f5fc8192f5f4230e768f8c7ce0cf325e5c2cca
push id7793
push usercliu@mozilla.com
push dateTue, 24 Nov 2015 00:21:42 +0000
reviewersally
bugs1225092
milestone45.0a1
Bug 1225092 - Improper behavior when accessing log in screen from on-boarding screen. r=ally
mobile/android/base/BrowserApp.java
mobile/android/base/firstrun/FirstrunPager.java
mobile/android/base/firstrun/FirstrunPane.java
mobile/android/base/firstrun/FirstrunPanel.java
mobile/android/base/firstrun/SyncPanel.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -2394,17 +2394,19 @@ public class BrowserApp extends GeckoApp
     private void showFirstrunPager() {
         if (mFirstrunPane == null) {
             final ViewStub firstrunPagerStub = (ViewStub) findViewById(R.id.firstrun_pager_stub);
             mFirstrunPane = (FirstrunPane) firstrunPagerStub.inflate();
             mFirstrunPane.load(getApplicationContext(), getSupportFragmentManager());
             mFirstrunPane.registerOnFinishListener(new FirstrunPane.OnFinishListener() {
                 @Override
                 public void onFinish() {
-                    enterEditingMode();
+                    if (mFirstrunPane.showBrowserHint()) {
+                        enterEditingMode();
+                    }
                 }
             });
         }
 
         mHomePagerContainer.setVisibility(View.VISIBLE);
     }
 
     private void showHomePager(String panelId) {
--- a/mobile/android/base/firstrun/FirstrunPager.java
+++ b/mobile/android/base/firstrun/FirstrunPager.java
@@ -101,17 +101,17 @@ public class FirstrunPager extends ViewP
 
             @Override
             public void onPageScrollStateChanged(int i) {}
         });
 
         animateLoad();
     }
 
-    public void hide() {
+    public void cleanup() {
         setAdapter(null);
     }
 
     private void animateLoad() {
         ViewHelper.setTranslationY(this, 500);
         ViewHelper.setAlpha(this, 0);
 
         final Animator translateAnimator = ObjectAnimator.ofFloat(this, "translationY", 0);
@@ -124,17 +124,17 @@ public class FirstrunPager extends ViewP
         final AnimatorSet set = new AnimatorSet();
         set.playTogether(alphaAnimator, translateAnimator);
         set.setStartDelay(400);
         TransitionsTracker.track(set);
 
         set.start();
     }
 
-    private class ViewPagerAdapter extends FragmentPagerAdapter {
+    protected class ViewPagerAdapter extends FragmentPagerAdapter {
         private final List<FirstrunPagerConfig.FirstrunPanelConfig> panels;
         private final Fragment[] fragments;
 
         public ViewPagerAdapter(FragmentManager fm, List<FirstrunPagerConfig.FirstrunPanelConfig> panels) {
             super(fm);
             this.panels = panels;
             this.fragments = new Fragment[panels.size()];
             for (FirstrunPagerConfig.FirstrunPanelConfig panel : panels) {
--- a/mobile/android/base/firstrun/FirstrunPane.java
+++ b/mobile/android/base/firstrun/FirstrunPane.java
@@ -49,17 +49,16 @@ public class FirstrunPane extends Linear
     }
 
     public boolean isVisible() {
         return visible;
     }
 
     public void hide() {
         visible = false;
-        pager.hide();
         if (onFinishListener != null) {
             onFinishListener.onFinish();
         }
         animateHide();
 
         // Stop all versions of firstrun A/B sessions.
         Telemetry.stopUISession(TelemetryContract.Session.EXPERIMENT, FirstrunPagerConfig.ONBOARDING_A);
         Telemetry.stopUISession(TelemetryContract.Session.EXPERIMENT, FirstrunPagerConfig.ONBOARDING_B);
@@ -75,12 +74,19 @@ public class FirstrunPane extends Linear
             }
         });
 
         TransitionsTracker.track(alphaAnimator);
 
         alphaAnimator.start();
     }
 
+    public boolean showBrowserHint() {
+        final int currentPage = pager.getCurrentItem();
+        FirstrunPanel currentPanel = (FirstrunPanel) ((FirstrunPager.ViewPagerAdapter) pager.getAdapter()).getItem(currentPage);
+        pager.cleanup();
+        return currentPanel.shouldShowBrowserHint();
+    }
+
     public void registerOnFinishListener(OnFinishListener listener) {
         this.onFinishListener = listener;
     }
 }
--- a/mobile/android/base/firstrun/FirstrunPanel.java
+++ b/mobile/android/base/firstrun/FirstrunPanel.java
@@ -5,16 +5,18 @@
 
 package org.mozilla.gecko.firstrun;
 
 import android.support.v4.app.Fragment;
 
 public class FirstrunPanel extends Fragment {
 
     public static final int TITLE_RES = -1;
+    protected boolean showBrowserHint = true;
+
     public interface PagerNavigation {
         void next();
         void finish();
     }
     protected PagerNavigation pagerNavigation;
 
     public void setPagerNavigation(PagerNavigation listener) {
         this.pagerNavigation = listener;
@@ -26,9 +28,13 @@ public class FirstrunPanel extends Fragm
         }
     }
 
     protected void close() {
         if (pagerNavigation != null) {
             pagerNavigation.finish();
         }
     }
+
+    protected boolean shouldShowBrowserHint() {
+        return showBrowserHint;
+    }
 }
--- a/mobile/android/base/firstrun/SyncPanel.java
+++ b/mobile/android/base/firstrun/SyncPanel.java
@@ -23,16 +23,17 @@ public class SyncPanel extends FirstrunP
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
         final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.firstrun_sync_fragment, container, false);
         // TODO: Update id names.
         root.findViewById(R.id.welcome_account).setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-sync");
+                showBrowserHint = false;
 
                 final Intent intent = new Intent(FxAccountConstants.ACTION_FXA_GET_STARTED);
                 intent.putExtra(FxAccountWebFlowActivity.EXTRA_ENDPOINT, FxAccountConstants.ENDPOINT_FIRSTRUN);
                 intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                 startActivity(intent);
 
                 close();
             }