Bug 977155 - (Part 2) Rename HomeBanner setEnabled to setActive. r=bnicholson
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 28 Feb 2014 17:26:54 -0800
changeset 171793 2fb022dbbe729a716567849a62d06f85e91d0fb2
parent 171792 f1910593bd406542b93fe6a14eb0784a4dc4def4
child 171794 6de7f6039a6841c6437d7256d1a37f62016657fe
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersbnicholson
bugs977155
milestone30.0a1
Bug 977155 - (Part 2) Rename HomeBanner setEnabled to setActive. r=bnicholson
mobile/android/base/home/HomeBanner.java
mobile/android/base/home/HomePager.java
--- a/mobile/android/base/home/HomeBanner.java
+++ b/mobile/android/base/home/HomeBanner.java
@@ -38,18 +38,18 @@ public class HomeBanner extends LinearLa
     private static final String LOGTAG = "GeckoHomeBanner";
 
     // Used for tracking scroll length
     private float mTouchY = -1;
 
     // Used to detect for upwards scroll to push banner all the way up
     private boolean mSnapBannerToTop;
 
-    // Tracks if the banner has been enabled by HomePager to avoid race conditions.
-    private boolean mEnabled = false;
+    // Tracks whether or not the banner should be shown.
+    private boolean mActive = false;
 
     // The user is currently swiping between HomePager pages
     private boolean mScrollingPages = false;
 
     // Tracks whether the user swiped the banner down, preventing us from autoshowing when the user
     // switches back to the default page.
     private boolean mUserSwipedDown = false;
 
@@ -134,18 +134,18 @@ public class HomeBanner extends LinearLa
 
             // Update the banner message on the UI thread.
             ThreadUtils.postToUiThread(new Runnable() {
                 @Override
                 public void run() {
                     mTextView.setText(text);
                     setVisibility(VISIBLE);
 
-                    // Animate the banner if it is currently enabled.
-                    if (mEnabled) {
+                    // Animate the banner if it is currently active.
+                    if (mActive) {
                         animateUp();
                     }
                 }
             });
         } catch (JSONException e) {
             Log.e(LOGTAG, "Exception handling " + event + " message", e);
             return;
         }
@@ -160,30 +160,30 @@ public class HomeBanner extends LinearLa
                     mIconView.setVisibility(View.GONE);
                 } else {
                     mIconView.setImageDrawable(d);
                 }
             }
         });
     }
 
-    public void setEnabled(boolean enabled) {
+    public void setActive(boolean active) {
         // No need to animate if not changing
-        if (mEnabled == enabled) {
+        if (mActive == active) {
             return;
         }
 
-        mEnabled = enabled;
+        mActive = active;
 
         // Don't animate if the banner isn't visible.
         if (getVisibility() != View.VISIBLE) {
             return;
         }
 
-        if (enabled) {
+        if (active) {
             animateUp();
         } else {
             animateDown();
         }
     }
 
     private void animateUp() {
         // Don't try to animate if the banner is already translated, or if the user swiped
@@ -204,17 +204,17 @@ public class HomeBanner extends LinearLa
         }
 
         final PropertyAnimator animator = new PropertyAnimator(100);
         animator.attach(this, Property.TRANSLATION_Y, getHeight());
         animator.start();
     }
 
     public void handleHomeTouch(MotionEvent event) {
-        if (!mEnabled || getVisibility() == GONE || mScrollingPages) {
+        if (!mActive || getVisibility() == GONE || mScrollingPages) {
             return;
         }
 
         switch (event.getActionMasked()) {
             case MotionEvent.ACTION_DOWN: {
                 // Track the beginning of the touch
                 mTouchY = event.getRawY();
                 break;
--- a/mobile/android/base/home/HomePager.java
+++ b/mobile/android/base/home/HomePager.java
@@ -243,34 +243,34 @@ public class HomePager extends ViewPager
         if (mHomeBanner != null) {
             mHomeBanner.handleHomeTouch(event);
         }
 
         return super.dispatchTouchEvent(event);
     }
 
     public void onToolbarFocusChange(boolean hasFocus) {
-        // We should only enable the banner if the toolbar is not focused and we are on the default page
-        final boolean enabled = !hasFocus && getCurrentItem() == mDefaultPageIndex;
-        mHomeBanner.setEnabled(enabled);
+        // We should only make the banner active if the toolbar is not focused and we are on the default page
+        final boolean active = !hasFocus && getCurrentItem() == mDefaultPageIndex;
+        mHomeBanner.setActive(active);
     }
 
     private void updateUiFromPanelConfigs(List<PanelConfig> panelConfigs) {
         // We only care about the adapter if HomePager is currently
         // loaded, which means it's visible in the activity.
         if (!mLoaded) {
             return;
         }
 
         if (mDecor != null) {
             mDecor.removeAllPagerViews();
         }
 
         if (mHomeBanner != null) {
-            mHomeBanner.setEnabled(false);
+            mHomeBanner.setActive(false);
         }
 
         final HomeAdapter adapter = (HomeAdapter) getAdapter();
 
         // Destroy any existing panels currently loaded
         // in the pager.
         setAdapter(null);
 
@@ -340,17 +340,17 @@ public class HomePager extends ViewPager
     private class PageChangeListener implements ViewPager.OnPageChangeListener {
         @Override
         public void onPageSelected(int position) {
             if (mDecor != null) {
                 mDecor.onPageSelected(position);
             }
 
             if (mHomeBanner != null) {
-                mHomeBanner.setEnabled(position == mDefaultPageIndex);
+                mHomeBanner.setActive(position == mDefaultPageIndex);
             }
         }
 
         @Override
         public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
             if (mDecor != null) {
                 mDecor.onPageScrolled(position, positionOffset, positionOffsetPixels);
             }