Bug 771726 - Fix toolbar focus order. r=sriram
authorEitan Isaacson <eitan@monotonous.org>
Tue, 10 Jul 2012 16:10:15 -0700
changeset 98887 e3c42c6b420e1a7c9faddc33033f9dca20c108fe
parent 98886 d540e12b6c6b5a29b94ea9048d3eadb875b349dc
child 98888 5d1fd77da308041d47703a11548b89d2e5da4913
push id11706
push usereisaacson@mozilla.com
push dateTue, 10 Jul 2012 23:10:32 +0000
treeherdermozilla-inbound@e3c42c6b420e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs771726
milestone16.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 771726 - Fix toolbar focus order. r=sriram
mobile/android/base/BrowserToolbar.java
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -2,16 +2,18 @@
  * 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;
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
 
 import android.content.ClipboardManager;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.graphics.Color;
 import android.graphics.drawable.AnimationDrawable;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.ColorDrawable;
@@ -60,16 +62,17 @@ public class BrowserToolbar implements V
     public ImageButton mSiteSecurity;
     public ImageButton mReader;
     private AnimationDrawable mProgressSpinner;
     private TextSwitcher mTabsCount;
     private ImageView mShadow;
     private ImageButton mMenu;
     private LinearLayout mActionItemBar;
     private MenuPopup mMenuPopup;
+    private List<View> mFocusOrder;
 
     final private Context mContext;
     private LayoutInflater mInflater;
     private Handler mHandler;
     private int[] mPadding;
     private boolean mHasSoftMenuButton;
 
     private boolean mShowSiteSecurity;
@@ -259,16 +262,18 @@ public class BrowserToolbar implements V
                 panel = GeckoApp.mAppContext.getMenuPanel();
 
                 if (mHasSoftMenuButton) {
                     mMenuPopup = new MenuPopup(mContext);
                     mMenuPopup.setPanelView(panel);
                 }
             }
         }
+
+        mFocusOrder = Arrays.asList(mBack, mForward, mAwesomeBar, mReader, mSiteSecurity, mStop, mTabs);
     }
 
     public View getLayout() {
         return mLayout;
     }
 
     public void requestLayout() {
         mLayout.invalidate();
@@ -423,16 +428,34 @@ public class BrowserToolbar implements V
 
         mSiteSecurity.setVisibility(mShowSiteSecurity && !visible ? View.VISIBLE : View.GONE);
         mReader.setVisibility(mShowReader && !visible ? View.VISIBLE : View.GONE);
 
         if (!visible && !mShowSiteSecurity && !mShowReader)
             mAwesomeBar.setPadding(mPadding[0], mPadding[1], mPadding[2], mPadding[3]);
         else
             mAwesomeBar.setPadding(mPadding[0], mPadding[1], mPadding[0], mPadding[3]);
+
+        updateFocusOrder();
+    }
+
+    private void updateFocusOrder() {
+        View prevView = null;
+
+        for (View view : mFocusOrder) {
+            if (view.getVisibility() != View.VISIBLE)
+                continue;
+
+            if (prevView != null) {
+                view.setNextFocusLeftId(prevView.getId());
+                prevView.setNextFocusRightId(view.getId());
+            }
+
+            prevView = view;
+        }
     }
 
     public void setShadowVisibility(boolean visible) {
         mShadow.setVisibility(visible ? View.VISIBLE : View.GONE);
     }
 
     public void setTitle(CharSequence title) {
         Tab tab = Tabs.getInstance().getSelectedTab();