diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java index 1bee9dbcf5c89..ee3b91e5f7825 100644 --- a/core/java/android/widget/TabHost.java +++ b/core/java/android/widget/TabHost.java @@ -101,8 +101,8 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); throw new RuntimeException( "Your TabHost must have a TabWidget whose id attribute is 'android.R.id.tabs'"); } - - // KeyListener to attach to all tabs. Detects non-navigation keys + + // KeyListener to attach to all tabs. Detects non-navigation keys // and relays them to the tab content. mTabKeyListener = new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { @@ -114,14 +114,14 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_ENTER: return false; - + } mTabContent.requestFocus(View.FOCUS_FORWARD); return mTabContent.dispatchKeyEvent(event); } - + }; - + mTabWidget.setTabSelectionListener(new TabWidget.OnTabSelectionChanged() { public void onTabSelectionChanged(int tabIndex, boolean clicked) { setCurrentTab(tabIndex); @@ -134,7 +134,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); mTabContent = (FrameLayout) findViewById(com.android.internal.R.id.tabcontent); if (mTabContent == null) { throw new RuntimeException( - "Your TabHost must have a FrameLayout whose id attribute is " + "Your TabHost must have a FrameLayout whose id attribute is " + "'android.R.id.tabcontent'"); } } @@ -284,7 +284,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); playSoundEffect(SoundEffectConstants.NAVIGATION_UP); return true; } - return handled; + return handled; } @@ -313,7 +313,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); // Call the tab widget's focusCurrentTab(), instead of just // selecting the tab. mTabWidget.focusCurrentTab(mCurrentTab); - + // tab content mCurrentView = spec.mContentStrategy.getContentView(); @@ -368,7 +368,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); public interface TabContentFactory { /** * Callback to make the tab contents - * + * * @param tag * Which tab was selected. * @return The view to display the contents of the selected tab. @@ -502,6 +502,8 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); View tabIndicator = inflater.inflate(R.layout.tab_indicator, mTabWidget, // tab widget is the parent false); // no inflate params + // TODO: Move this to xml when bug 2068024 is resolved. + tabIndicator.getBackground().setDither(true); final TextView tv = (TextView) tabIndicator.findViewById(R.id.title); tv.setText(mLabel); @@ -529,6 +531,8 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); View tabIndicator = inflater.inflate(R.layout.tab_indicator, mTabWidget, // tab widget is the parent false); // no inflate params + // TODO: Move this to xml when bug 2068024 is resolved. + tabIndicator.getBackground().setDither(true); final TextView tv = (TextView) tabIndicator.findViewById(R.id.title); tv.setText(mLabel); @@ -638,7 +642,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); } } mLaunchedView = wd; - + // XXX Set FOCUS_AFTER_DESCENDANTS on embedded activities for now so they can get // focus if none of their children have it. They need focus to be able to // display menu items. diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java index 47f5c6c264da2..889f37ff7e5b1 100644 --- a/core/java/android/widget/TabWidget.java +++ b/core/java/android/widget/TabWidget.java @@ -30,7 +30,7 @@ import android.view.View.OnFocusChangeListener; /** - * + * * Displays a list of tab labels representing each page in the parent's tab * collection. The container object for this widget is * {@link android.widget.TabHost TabHost}. When the user selects a tab, this @@ -64,21 +64,36 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { super(context, attrs); initTabWidget(); - TypedArray a = + TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.TabWidget, defStyle, 0); a.recycle(); } - + @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { mStripMoved = true; super.onSizeChanged(w, h, oldw, oldh); } + @Override + protected int getChildDrawingOrder(int childCount, int i) { + // Always draw the selected tab last, so that drop shadows are drawn + // in the correct z-order. + if (i == childCount - 1) { + return mSelectedTab; + } else if (i >= mSelectedTab) { + return i + 1; + } else { + return i; + } + } + private void initTabWidget() { setOrientation(LinearLayout.HORIZONTAL); + mGroupFlags |= FLAG_USE_CHILD_DRAWING_ORDER; + mBottomLeftStrip = mContext.getResources().getDrawable( com.android.internal.R.drawable.tab_bottom_left); mBottomRightStrip = mContext.getResources().getDrawable( @@ -156,7 +171,7 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { } super.childDrawableStateChanged(child); } - + @Override public void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); @@ -169,17 +184,17 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { } View selectedChild = getChildTabViewAt(mSelectedTab); - + mBottomLeftStrip.setState(selectedChild.getDrawableState()); mBottomRightStrip.setState(selectedChild.getDrawableState()); - + if (mStripMoved) { Rect selBounds = new Rect(); // Bounds of the selected tab indicator selBounds.left = selectedChild.getLeft(); selBounds.right = selectedChild.getRight(); final int myHeight = getHeight(); mBottomLeftStrip.setBounds( - Math.min(0, selBounds.left + Math.min(0, selBounds.left - mBottomLeftStrip.getIntrinsicWidth()), myHeight - mBottomLeftStrip.getIntrinsicHeight(), selBounds.left, @@ -187,12 +202,12 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { mBottomRightStrip.setBounds( selBounds.right, myHeight - mBottomRightStrip.getIntrinsicHeight(), - Math.max(getWidth(), + Math.max(getWidth(), selBounds.right + mBottomRightStrip.getIntrinsicWidth()), myHeight); mStripMoved = false; } - + mBottomLeftStrip.draw(canvas); mBottomRightStrip.draw(canvas); } @@ -202,26 +217,26 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { * This method is used to bring a tab to the front of the Widget, * and is used to post to the rest of the UI that a different tab * has been brought to the foreground. - * - * Note, this is separate from the traditional "focus" that is - * employed from the view logic. - * - * For instance, if we have a list in a tabbed view, a user may be - * navigating up and down the list, moving the UI focus (orange - * highlighting) through the list items. The cursor movement does - * not effect the "selected" tab though, because what is being - * scrolled through is all on the same tab. The selected tab only - * changes when we navigate between tabs (moving from the list view + * + * Note, this is separate from the traditional "focus" that is + * employed from the view logic. + * + * For instance, if we have a list in a tabbed view, a user may be + * navigating up and down the list, moving the UI focus (orange + * highlighting) through the list items. The cursor movement does + * not effect the "selected" tab though, because what is being + * scrolled through is all on the same tab. The selected tab only + * changes when we navigate between tabs (moving from the list view * to the next tabbed view, in this example). - * + * * To move both the focus AND the selected tab at once, please use - * {@link #setCurrentTab}. Normally, the view logic takes care of - * adjusting the focus, so unless you're circumventing the UI, + * {@link #setCurrentTab}. Normally, the view logic takes care of + * adjusting the focus, so unless you're circumventing the UI, * you'll probably just focus your interest here. - * + * * @param index The tab that you want to indicate as the selected * tab (tab brought to the front of the widget) - * + * * @see #focusCurrentTab */ public void setCurrentTab(int index) { @@ -234,19 +249,19 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { getChildTabViewAt(mSelectedTab).setSelected(true); mStripMoved = true; } - + /** * Sets the current tab and focuses the UI on it. - * This method makes sure that the focused tab matches the selected - * tab, normally at {@link #setCurrentTab}. Normally this would not - * be an issue if we go through the UI, since the UI is responsible - * for calling TabWidget.onFocusChanged(), but in the case where we - * are selecting the tab programmatically, we'll need to make sure + * This method makes sure that the focused tab matches the selected + * tab, normally at {@link #setCurrentTab}. Normally this would not + * be an issue if we go through the UI, since the UI is responsible + * for calling TabWidget.onFocusChanged(), but in the case where we + * are selecting the tab programmatically, we'll need to make sure * focus keeps up. - * - * @param index The tab that you want focused (highlighted in orange) + * + * @param index The tab that you want focused (highlighted in orange) * and selected (tab brought to the front of the widget) - * + * * @see #setCurrentTab */ public void focusCurrentTab(int index) { @@ -254,18 +269,18 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { // set the tab setCurrentTab(index); - + // change the focus if applicable. if (oldTab != index) { getChildTabViewAt(index).requestFocus(); } } - + @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); int count = getTabCount(); - + for (int i = 0; i < count; i++) { View child = getChildTabViewAt(i); child.setEnabled(enabled); @@ -318,7 +333,7 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { getChildTabViewAt(mSelectedTab).requestFocus(); return; } - + if (hasFocus) { int i = 0; int numTabs = getTabCount(); @@ -354,7 +369,7 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { /** * Informs the TabHost which tab was selected. It also indicates * if the tab was clicked/pressed or just focused into. - * + * * @param tabIndex index of the tab that was selected * @param clicked whether the selection changed due to a touch/click * or due to focus entering the tab through navigation. Pass true diff --git a/core/res/res/color/tab_indicator_text.xml b/core/res/res/color/tab_indicator_text.xml index ce321db352e62..5f5c2a4a265fb 100644 --- a/core/res/res/color/tab_indicator_text.xml +++ b/core/res/res/color/tab_indicator_text.xml @@ -15,6 +15,6 @@ --> - - + + diff --git a/core/res/res/drawable/dark_header.9.png b/core/res/res/drawable/dark_header.9.png index 8fa5f09152136..7242b61494fd2 100644 Binary files a/core/res/res/drawable/dark_header.9.png and b/core/res/res/drawable/dark_header.9.png differ diff --git a/core/res/res/drawable/dark_header_dither.xml b/core/res/res/drawable/dark_header_dither.xml new file mode 100644 index 0000000000000..0741fa4739c06 --- /dev/null +++ b/core/res/res/drawable/dark_header_dither.xml @@ -0,0 +1,20 @@ + + + + diff --git a/core/res/res/drawable/divider_horizontal_bright.9.png b/core/res/res/drawable/divider_horizontal_bright.9.png index 144fc224e9269..395227a00db08 100644 Binary files a/core/res/res/drawable/divider_horizontal_bright.9.png and b/core/res/res/drawable/divider_horizontal_bright.9.png differ diff --git a/core/res/res/drawable/divider_horizontal_bright_opaque.9.png b/core/res/res/drawable/divider_horizontal_bright_opaque.9.png index 30c9b2b63e4ab..5c537eec512fe 100644 Binary files a/core/res/res/drawable/divider_horizontal_bright_opaque.9.png and b/core/res/res/drawable/divider_horizontal_bright_opaque.9.png differ diff --git a/core/res/res/drawable/divider_horizontal_dark.9.png b/core/res/res/drawable/divider_horizontal_dark.9.png index 08838cafa8153..548d0bd663ad5 100644 Binary files a/core/res/res/drawable/divider_horizontal_dark.9.png and b/core/res/res/drawable/divider_horizontal_dark.9.png differ diff --git a/core/res/res/drawable/divider_horizontal_dark_opaque.9.png b/core/res/res/drawable/divider_horizontal_dark_opaque.9.png index ce21acd8a9d42..8f35315aef86b 100644 Binary files a/core/res/res/drawable/divider_horizontal_dark_opaque.9.png and b/core/res/res/drawable/divider_horizontal_dark_opaque.9.png differ diff --git a/core/res/res/drawable/divider_vertical_bright.9.png b/core/res/res/drawable/divider_vertical_bright.9.png index da6e4ecd20690..395227a00db08 100644 Binary files a/core/res/res/drawable/divider_vertical_bright.9.png and b/core/res/res/drawable/divider_vertical_bright.9.png differ diff --git a/core/res/res/drawable/divider_vertical_bright_opaque.9.png b/core/res/res/drawable/divider_vertical_bright_opaque.9.png new file mode 100644 index 0000000000000..5c537eec512fe Binary files /dev/null and b/core/res/res/drawable/divider_vertical_bright_opaque.9.png differ diff --git a/core/res/res/drawable/divider_vertical_dark.9.png b/core/res/res/drawable/divider_vertical_dark.9.png new file mode 100644 index 0000000000000..548d0bd663ad5 Binary files /dev/null and b/core/res/res/drawable/divider_vertical_dark.9.png differ diff --git a/core/res/res/drawable/divider_vertical_dark_opaque.9.png b/core/res/res/drawable/divider_vertical_dark_opaque.9.png new file mode 100644 index 0000000000000..8f35315aef86b Binary files /dev/null and b/core/res/res/drawable/divider_vertical_dark_opaque.9.png differ diff --git a/core/res/res/drawable/light_header.9.png b/core/res/res/drawable/light_header.9.png index ad5dce1e241e9..fcd9e2d2ed5e8 100644 Binary files a/core/res/res/drawable/light_header.9.png and b/core/res/res/drawable/light_header.9.png differ diff --git a/core/res/res/drawable/light_header_dither.xml b/core/res/res/drawable/light_header_dither.xml new file mode 100644 index 0000000000000..c54b6c286c1ce --- /dev/null +++ b/core/res/res/drawable/light_header_dither.xml @@ -0,0 +1,20 @@ + + + + diff --git a/core/res/res/drawable/tab_focus.9.png b/core/res/res/drawable/tab_focus.9.png index 2806da98f76b2..d9bcc57a245ae 100755 Binary files a/core/res/res/drawable/tab_focus.9.png and b/core/res/res/drawable/tab_focus.9.png differ diff --git a/core/res/res/drawable/tab_focus_bar_left.9.png b/core/res/res/drawable/tab_focus_bar_left.9.png index 21421cb81689b..2536d9450c2eb 100755 Binary files a/core/res/res/drawable/tab_focus_bar_left.9.png and b/core/res/res/drawable/tab_focus_bar_left.9.png differ diff --git a/core/res/res/drawable/tab_focus_bar_right.9.png b/core/res/res/drawable/tab_focus_bar_right.9.png index b6304d9c7de44..2536d9450c2eb 100755 Binary files a/core/res/res/drawable/tab_focus_bar_right.9.png and b/core/res/res/drawable/tab_focus_bar_right.9.png differ diff --git a/core/res/res/drawable/tab_press.9.png b/core/res/res/drawable/tab_press.9.png index 3fb717c01735b..3332660c874fb 100755 Binary files a/core/res/res/drawable/tab_press.9.png and b/core/res/res/drawable/tab_press.9.png differ diff --git a/core/res/res/drawable/tab_press_bar_left.9.png b/core/res/res/drawable/tab_press_bar_left.9.png index 95ef2d3c3cc62..d2c75e3cc3d02 100755 Binary files a/core/res/res/drawable/tab_press_bar_left.9.png and b/core/res/res/drawable/tab_press_bar_left.9.png differ diff --git a/core/res/res/drawable/tab_press_bar_right.9.png b/core/res/res/drawable/tab_press_bar_right.9.png index 7ae938b546e98..d2c75e3cc3d02 100755 Binary files a/core/res/res/drawable/tab_press_bar_right.9.png and b/core/res/res/drawable/tab_press_bar_right.9.png differ diff --git a/core/res/res/drawable/tab_selected.9.png b/core/res/res/drawable/tab_selected.9.png index f929d99864882..54190ea203be2 100644 Binary files a/core/res/res/drawable/tab_selected.9.png and b/core/res/res/drawable/tab_selected.9.png differ diff --git a/core/res/res/drawable/tab_selected_bar_left.9.png b/core/res/res/drawable/tab_selected_bar_left.9.png index 58e2d3539fcb3..d20f3a2e62170 100755 Binary files a/core/res/res/drawable/tab_selected_bar_left.9.png and b/core/res/res/drawable/tab_selected_bar_left.9.png differ diff --git a/core/res/res/drawable/tab_selected_bar_right.9.png b/core/res/res/drawable/tab_selected_bar_right.9.png index 0c9c8dd58a832..d20f3a2e62170 100755 Binary files a/core/res/res/drawable/tab_selected_bar_right.9.png and b/core/res/res/drawable/tab_selected_bar_right.9.png differ diff --git a/core/res/res/drawable/tab_unselected.9.png b/core/res/res/drawable/tab_unselected.9.png index 9036c1df16bf2..1b8a69c95893c 100644 Binary files a/core/res/res/drawable/tab_unselected.9.png and b/core/res/res/drawable/tab_unselected.9.png differ diff --git a/core/res/res/layout/tab_indicator.xml b/core/res/res/layout/tab_indicator.xml index fcf0b5e1012ad..e3ea555db9060 100644 --- a/core/res/res/layout/tab_indicator.xml +++ b/core/res/res/layout/tab_indicator.xml @@ -18,6 +18,8 @@ android:layout_width="0dip" android:layout_height="64dip" android:layout_weight="1" + android:layout_marginLeft="-4px" + android:layout_marginRight="-4px" android:orientation="vertical" android:background="@android:drawable/tab_indicator"> diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml index 0fd6861fd6afc..1057c09582526 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -19,7 +19,7 @@ --> #fff9f9f9 - #ff1a1a1a + #ff202020 #ff000000 #ff000000 #ff000000 @@ -28,7 +28,7 @@ #ffffffff #ff000000 #00000000 - #ff1a1a1a + #ff202020 #ffffffff #80ffffff #ff000000 diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 10d2093901988..3950cb16d5dbe 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -339,7 +339,7 @@