diff options
author | Evan Millar <emillar@google.com> | 2009-08-21 13:58:41 -0700 |
---|---|---|
committer | Evan Millar <emillar@google.com> | 2009-08-26 10:56:45 -0700 |
commit | 3730bb1cd59bcfa9f5cad8361997b84113ed5923 (patch) | |
tree | 557c7816779f8e303e47cc0255ae68ab5b9004d3 | |
parent | 4b8e3fb51155ab6c990803ff7780cd1b8c8f3dcf (diff) | |
download | frameworks_base-3730bb1cd59bcfa9f5cad8361997b84113ed5923.zip frameworks_base-3730bb1cd59bcfa9f5cad8361997b84113ed5923.tar.gz frameworks_base-3730bb1cd59bcfa9f5cad8361997b84113ed5923.tar.bz2 |
New List and Tab assets.
New tab assets. We decided to do a straight swap and then assess the
damage.
New default dark background color.
New list divider assets.
Change-Id: Ia00a9bb0ee1bad4f955f1c3b5b67526f62572015
28 files changed, 115 insertions, 54 deletions
diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java index 1bee9db..ee3b91e 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 47f5c6c..889f37f 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 ce321db..5f5c2a4 100644 --- a/core/res/res/color/tab_indicator_text.xml +++ b/core/res/res/color/tab_indicator_text.xml @@ -15,6 +15,6 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_selected="true" android:color="#323232"/> - <item android:color="#FFF"/> <!-- not selected --> + <item android:state_selected="true" android:color="#ffffff"/> + <item android:color="#808080"/> <!-- not selected --> </selector> diff --git a/core/res/res/drawable/dark_header.9.png b/core/res/res/drawable/dark_header.9.png Binary files differindex 8fa5f09..7242b61 100644 --- a/core/res/res/drawable/dark_header.9.png +++ b/core/res/res/drawable/dark_header.9.png 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 0000000..0741fa4 --- /dev/null +++ b/core/res/res/drawable/dark_header_dither.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<nine-patch xmlns:android="http://schemas.android.com/apk/res/android" + android:src="@drawable/dark_header" + android:dither="true" +/> diff --git a/core/res/res/drawable/divider_horizontal_bright.9.png b/core/res/res/drawable/divider_horizontal_bright.9.png Binary files differindex 144fc22..395227a 100644 --- a/core/res/res/drawable/divider_horizontal_bright.9.png +++ b/core/res/res/drawable/divider_horizontal_bright.9.png diff --git a/core/res/res/drawable/divider_horizontal_bright_opaque.9.png b/core/res/res/drawable/divider_horizontal_bright_opaque.9.png Binary files differindex 30c9b2b..5c537ee 100644 --- a/core/res/res/drawable/divider_horizontal_bright_opaque.9.png +++ b/core/res/res/drawable/divider_horizontal_bright_opaque.9.png diff --git a/core/res/res/drawable/divider_horizontal_dark.9.png b/core/res/res/drawable/divider_horizontal_dark.9.png Binary files differindex 08838ca..548d0bd 100644 --- a/core/res/res/drawable/divider_horizontal_dark.9.png +++ b/core/res/res/drawable/divider_horizontal_dark.9.png diff --git a/core/res/res/drawable/divider_horizontal_dark_opaque.9.png b/core/res/res/drawable/divider_horizontal_dark_opaque.9.png Binary files differindex ce21acd..8f35315 100644 --- a/core/res/res/drawable/divider_horizontal_dark_opaque.9.png +++ b/core/res/res/drawable/divider_horizontal_dark_opaque.9.png diff --git a/core/res/res/drawable/divider_vertical_bright.9.png b/core/res/res/drawable/divider_vertical_bright.9.png Binary files differindex da6e4ec..395227a 100644 --- a/core/res/res/drawable/divider_vertical_bright.9.png +++ b/core/res/res/drawable/divider_vertical_bright.9.png diff --git a/core/res/res/drawable/divider_vertical_bright_opaque.9.png b/core/res/res/drawable/divider_vertical_bright_opaque.9.png Binary files differnew file mode 100644 index 0000000..5c537ee --- /dev/null +++ b/core/res/res/drawable/divider_vertical_bright_opaque.9.png diff --git a/core/res/res/drawable/divider_vertical_dark.9.png b/core/res/res/drawable/divider_vertical_dark.9.png Binary files differnew file mode 100644 index 0000000..548d0bd --- /dev/null +++ b/core/res/res/drawable/divider_vertical_dark.9.png diff --git a/core/res/res/drawable/divider_vertical_dark_opaque.9.png b/core/res/res/drawable/divider_vertical_dark_opaque.9.png Binary files differnew file mode 100644 index 0000000..8f35315 --- /dev/null +++ b/core/res/res/drawable/divider_vertical_dark_opaque.9.png diff --git a/core/res/res/drawable/light_header.9.png b/core/res/res/drawable/light_header.9.png Binary files differindex ad5dce1..fcd9e2d 100644 --- a/core/res/res/drawable/light_header.9.png +++ b/core/res/res/drawable/light_header.9.png 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 0000000..c54b6c2 --- /dev/null +++ b/core/res/res/drawable/light_header_dither.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<nine-patch xmlns:android="http://schemas.android.com/apk/res/android" + android:src="@drawable/light_header" + android:dither="true" +/> diff --git a/core/res/res/drawable/tab_focus.9.png b/core/res/res/drawable/tab_focus.9.png Binary files differindex 2806da9..d9bcc57 100755 --- a/core/res/res/drawable/tab_focus.9.png +++ b/core/res/res/drawable/tab_focus.9.png diff --git a/core/res/res/drawable/tab_focus_bar_left.9.png b/core/res/res/drawable/tab_focus_bar_left.9.png Binary files differindex 21421cb..2536d94 100755 --- a/core/res/res/drawable/tab_focus_bar_left.9.png +++ b/core/res/res/drawable/tab_focus_bar_left.9.png diff --git a/core/res/res/drawable/tab_focus_bar_right.9.png b/core/res/res/drawable/tab_focus_bar_right.9.png Binary files differindex b6304d9..2536d94 100755 --- a/core/res/res/drawable/tab_focus_bar_right.9.png +++ b/core/res/res/drawable/tab_focus_bar_right.9.png diff --git a/core/res/res/drawable/tab_press.9.png b/core/res/res/drawable/tab_press.9.png Binary files differindex 3fb717c..3332660 100755 --- a/core/res/res/drawable/tab_press.9.png +++ b/core/res/res/drawable/tab_press.9.png diff --git a/core/res/res/drawable/tab_press_bar_left.9.png b/core/res/res/drawable/tab_press_bar_left.9.png Binary files differindex 95ef2d3..d2c75e3 100755 --- a/core/res/res/drawable/tab_press_bar_left.9.png +++ b/core/res/res/drawable/tab_press_bar_left.9.png diff --git a/core/res/res/drawable/tab_press_bar_right.9.png b/core/res/res/drawable/tab_press_bar_right.9.png Binary files differindex 7ae938b5..d2c75e3 100755 --- a/core/res/res/drawable/tab_press_bar_right.9.png +++ b/core/res/res/drawable/tab_press_bar_right.9.png diff --git a/core/res/res/drawable/tab_selected.9.png b/core/res/res/drawable/tab_selected.9.png Binary files differindex f929d99..54190ea 100644 --- a/core/res/res/drawable/tab_selected.9.png +++ b/core/res/res/drawable/tab_selected.9.png diff --git a/core/res/res/drawable/tab_selected_bar_left.9.png b/core/res/res/drawable/tab_selected_bar_left.9.png Binary files differindex 58e2d35..d20f3a2 100755 --- a/core/res/res/drawable/tab_selected_bar_left.9.png +++ b/core/res/res/drawable/tab_selected_bar_left.9.png diff --git a/core/res/res/drawable/tab_selected_bar_right.9.png b/core/res/res/drawable/tab_selected_bar_right.9.png Binary files differindex 0c9c8dd..d20f3a2 100755 --- a/core/res/res/drawable/tab_selected_bar_right.9.png +++ b/core/res/res/drawable/tab_selected_bar_right.9.png diff --git a/core/res/res/drawable/tab_unselected.9.png b/core/res/res/drawable/tab_unselected.9.png Binary files differindex 9036c1d..1b8a69c 100644 --- a/core/res/res/drawable/tab_unselected.9.png +++ b/core/res/res/drawable/tab_unselected.9.png diff --git a/core/res/res/layout/tab_indicator.xml b/core/res/res/layout/tab_indicator.xml index fcf0b5e..e3ea555 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 0fd6861..1057c09 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -19,7 +19,7 @@ --> <resources> <drawable name="screen_background_light">#fff9f9f9</drawable> - <drawable name="screen_background_dark">#ff1a1a1a</drawable> + <drawable name="screen_background_dark">#ff202020</drawable> <drawable name="status_bar_closed_default_background">#ff000000</drawable> <drawable name="status_bar_opened_default_background">#ff000000</drawable> <drawable name="search_bar_default_color">#ff000000</drawable> @@ -28,7 +28,7 @@ <color name="white">#ffffffff</color> <color name="black">#ff000000</color> <color name="transparent">#00000000</color> - <color name="background_dark">#ff1a1a1a</color> + <color name="background_dark">#ff202020</color> <color name="bright_foreground_dark">#ffffffff</color> <color name="bright_foreground_dark_disabled">#80ffffff</color> <color name="bright_foreground_dark_inverse">#ff000000</color> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 10d2093..3950cb1 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -339,7 +339,7 @@ </style> <style name="Widget.TextView.ListSeparator"> - <item name="android:background">@android:drawable/dark_header</item> + <item name="android:background">@android:drawable/dark_header_dither</item> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">25dip</item> <item name="android:textStyle">bold</item> @@ -351,7 +351,7 @@ <style name="Widget.TextView.ListSeparator.White"> <item name="android:textColor">?textColorPrimaryInverse</item> - <item name="android:background">@android:drawable/light_header</item> + <item name="android:background">@android:drawable/light_header_dither</item> </style> <style name="Widget.EditText"> |