Bug 862996: Put text headings back in the tab menu. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 17 Apr 2013 16:09:02 -0700
changeset 141224 14be1f919f01920d345e2b94b95a13a92afeba82
parent 141223 7f6151df416096615b047e3097b9c480fb37f417
child 141225 f5a56da67edccf9f01b7dafd74af4b6bb9410fb4
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs862996
milestone23.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 862996: Put text headings back in the tab menu. [r=mfinkle]
mobile/android/base/TabsPanel.java
mobile/android/base/resources/layout-large-land-v11/tabs_panel_header.xml
mobile/android/base/resources/layout/tabs_panel_indicator.xml
mobile/android/base/resources/values/attrs.xml
mobile/android/base/widget/IconTabWidget.java
--- a/mobile/android/base/TabsPanel.java
+++ b/mobile/android/base/TabsPanel.java
@@ -98,29 +98,24 @@ public class TabsPanel extends LinearLay
         mAddTab = (ImageButton) findViewById(R.id.add_tab);
         mAddTab.setOnClickListener(new Button.OnClickListener() {
             @Override
             public void onClick(View v) {
                 TabsPanel.this.addTab();
             }
         });
 
-        ImageButton button;
+        Button button;
         Resources resources = getContext().getResources();
 
         mTabWidget = (IconTabWidget) findViewById(R.id.tab_widget);
 
-        button = mTabWidget.addTab(R.drawable.tabs_normal);
-        button.setContentDescription(resources.getString(R.string.tabs_normal));
-
-        button = mTabWidget.addTab(R.drawable.tabs_private);
-        button.setContentDescription(resources.getString(R.string.tabs_private));
-
-        button = mTabWidget.addTab(R.drawable.tabs_synced);
-        button.setContentDescription(resources.getString(R.string.tabs_synced));
+        button = mTabWidget.addTab(R.drawable.tabs_normal, R.string.tabs_normal);
+        button = mTabWidget.addTab(R.drawable.tabs_private, R.string.tabs_private);
+        button = mTabWidget.addTab(R.drawable.tabs_synced, R.string.tabs_synced);
 
         mTabWidget.setTabSelectionListener(this);
     }
 
     public void addTab() {
         if (mCurrentPanel == Panel.NORMAL_TABS)
            mActivity.addTab();
         else
--- a/mobile/android/base/resources/layout-large-land-v11/tabs_panel_header.xml
+++ b/mobile/android/base/resources/layout-large-land-v11/tabs_panel_header.xml
@@ -1,14 +1,16 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- 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/. -->
 
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+       xmlns:gecko="http://schemas.android.com/apk/res-auto">
 
     <Gecko.IconTabWidget android:id="@+id/tab_widget"
                          android:layout_width="wrap_content"
                          android:layout_height="fill_parent"
                          android:tabStripEnabled="false"
-                         android:divider="@drawable/tab_indicator_divider"/>
+                         android:divider="@drawable/tab_indicator_divider"
+                         gecko:display="icon"/>
 
 </merge>
--- a/mobile/android/base/resources/layout/tabs_panel_indicator.xml
+++ b/mobile/android/base/resources/layout/tabs_panel_indicator.xml
@@ -1,13 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- 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/. -->
 
-<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
-             style="@style/AddressBar.ImageButton"
-             android:layout_width="@dimen/tabs_panel_indicator_width"
-             android:layout_height="@dimen/browser_toolbar_height"
-             android:minWidth="@dimen/tabs_panel_indicator_width"
-             android:paddingTop="@dimen/browser_toolbar_button_padding"
-             android:paddingBottom="@dimen/browser_toolbar_button_padding"
-             android:background="@drawable/tabs_panel_indicator"/>
+<Button xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="@dimen/browser_toolbar_height"
+        android:minWidth="@dimen/tabs_panel_indicator_width"
+        android:padding="@dimen/browser_toolbar_button_padding"
+        android:background="@drawable/tabs_panel_indicator"
+        android:textAppearance="@style/TextAppearance.Micro"
+        android:textColor="#99FFFFFF"
+        android:textStyle="bold"/>
--- a/mobile/android/base/resources/values/attrs.xml
+++ b/mobile/android/base/resources/values/attrs.xml
@@ -152,10 +152,17 @@
         <attr name="android:orientation"/>
 
         <!-- Imported from AbsListView -->
         <attr name="android:choiceMode"/>
         <attr name="android:drawSelectorOnTop"/>
         <attr name="android:listSelector"/>
     </declare-styleable>
 
+    <declare-styleable name="IconTabWidget">
+        <attr name="display">
+            <flag name="text" value="0x00" />
+            <flag name="icon" value="0x01" />
+        </attr>
+    </declare-styleable>
+
 </resources>
 
--- a/mobile/android/base/widget/IconTabWidget.java
+++ b/mobile/android/base/widget/IconTabWidget.java
@@ -2,38 +2,49 @@
  * 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.widget;
 
 import org.mozilla.gecko.R;
 
 import android.content.Context;
+import android.content.res.TypedArray;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.widget.ImageButton;
+import android.widget.Button;
 import android.widget.TabWidget;
 
 public class IconTabWidget extends TabWidget {
-    private Context mContext;
     private OnTabChangedListener mListener;
+    private boolean mIsIcon;
 
     public static interface OnTabChangedListener {
         public void onTabChanged(int tabIndex);
     }
 
     public IconTabWidget(Context context, AttributeSet attrs) {
         super(context, attrs);
-        mContext = context;
+
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconTabWidget);
+        int type = a.getInt(R.styleable.IconTabWidget_display, 0x00);
+        a.recycle();
+
+        mIsIcon = (type == 0x01);
     }
 
-    public ImageButton addTab(int resId) {
-        ImageButton button = (ImageButton) LayoutInflater.from(mContext).inflate(R.layout.tabs_panel_indicator, null);
-        button.setImageResource(resId);
+    public Button addTab(int imageResId, int stringResId) {
+        Button button = (Button) LayoutInflater.from(getContext()).inflate(R.layout.tabs_panel_indicator, null);
+        if (mIsIcon) {
+            button.setCompoundDrawablesWithIntrinsicBounds(imageResId, 0, 0, 0);
+            button.setContentDescription(getContext().getString(stringResId));
+        } else {
+            button.setText(getContext().getString(stringResId).toUpperCase());
+        }
 
         addView(button);
         button.setOnClickListener(new TabClickListener(getTabCount() - 1));
         button.setOnFocusChangeListener(this);
         return button;
     }
 
     public void setTabSelectionListener(OnTabChangedListener listener) {