diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java index ff31dec2ff0cd..2949208b3ef16 100644 --- a/core/java/android/widget/TabHost.java +++ b/core/java/android/widget/TabHost.java @@ -21,6 +21,7 @@ import com.android.internal.R; import android.app.LocalActivityManager; import android.content.Context; import android.content.Intent; +import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; @@ -63,6 +64,8 @@ public class TabHost extends FrameLayout implements ViewTreeObserver.OnTouchMode private OnTabChangeListener mOnTabChangeListener; private OnKeyListener mTabKeyListener; + private int mTabLayoutId; + public TabHost(Context context) { super(context); initTabHost(); @@ -70,6 +73,18 @@ public class TabHost extends FrameLayout implements ViewTreeObserver.OnTouchMode public TabHost(Context context, AttributeSet attrs) { super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.TabWidget, + com.android.internal.R.attr.tabWidgetStyle, 0); + + mTabLayoutId = a.getResourceId(R.styleable.TabWidget_tabLayout, 0); + if (mTabLayoutId == 0) { + throw new IllegalArgumentException("Invalid TabWidget tabLayout id"); + } + + a.recycle(); + initTabHost(); } @@ -214,6 +229,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); if (tabSpec.mIndicatorStrategy instanceof ViewIndicatorStrategy) { mTabWidget.setStripEnabled(false); } + mTabWidget.addView(tabIndicator); mTabSpecs.add(tabSpec); @@ -513,7 +529,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); final Context context = getContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View tabIndicator = inflater.inflate(R.layout.tab_indicator, + View tabIndicator = inflater.inflate(mTabLayoutId, mTabWidget, // tab widget is the parent false); // no inflate params @@ -525,7 +541,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); tabIndicator.setBackgroundResource(R.drawable.tab_indicator_v4); tv.setTextColor(context.getResources().getColorStateList(R.color.tab_indicator_text_v4)); } - + return tabIndicator; } } @@ -547,7 +563,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); final Context context = getContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View tabIndicator = inflater.inflate(R.layout.tab_indicator, + View tabIndicator = inflater.inflate(mTabLayoutId, mTabWidget, // tab widget is the parent false); // no inflate params @@ -555,14 +571,17 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); tv.setText(mLabel); final ImageView iconView = (ImageView) tabIndicator.findViewById(R.id.icon); - iconView.setImageDrawable(mIcon); + if (mIcon != null) { + iconView.setImageDrawable(mIcon); + iconView.setVisibility(VISIBLE); + } if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) { // Donut apps get old color scheme tabIndicator.setBackgroundResource(R.drawable.tab_indicator_v4); tv.setTextColor(context.getResources().getColorStateList(R.color.tab_indicator_text_v4)); } - + return tabIndicator; } } diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java index 0469e7bf72276..36adacdf26209 100644 --- a/core/java/android/widget/TabWidget.java +++ b/core/java/android/widget/TabWidget.java @@ -120,7 +120,9 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { final Context context = mContext; final Resources resources = context.getResources(); - + + // Tests the target Sdk version, as set in the Manifest. Could not be set using styles.xml + // in a values-v? directory which targets the current platform Sdk version instead. if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) { // Donut apps get old color scheme if (mLeftStrip == null) { @@ -131,16 +133,6 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { mRightStrip = resources.getDrawable( com.android.internal.R.drawable.tab_bottom_right_v4); } - } else { - // Use modern color scheme for Eclair and beyond - if (mLeftStrip == null) { - mLeftStrip = resources.getDrawable( - com.android.internal.R.drawable.tab_bottom_left); - } - if (mRightStrip == null) { - mRightStrip = resources.getDrawable( - com.android.internal.R.drawable.tab_bottom_right); - } } // Deal with focus, as we don't want the focus to go by default diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 09563fc564fed..6897537a5a6d3 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -7142,6 +7142,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case Gravity.RIGHT: return 0.0f; case Gravity.CENTER_HORIZONTAL: + case Gravity.FILL_HORIZONTAL: return (mLayout.getLineWidth(0) - ((mRight - mLeft) - getCompoundPaddingLeft() - getCompoundPaddingRight())) / getHorizontalFadingEdgeLength(); diff --git a/core/res/res/drawable-hdpi/tab_arrow_left_holo_dark.png b/core/res/res/drawable-hdpi/tab_arrow_left_holo_dark.png deleted file mode 100644 index cfd6f785c8803..0000000000000 Binary files a/core/res/res/drawable-hdpi/tab_arrow_left_holo_dark.png and /dev/null differ diff --git a/core/res/res/drawable-hdpi/tab_arrow_left_holo_light.png b/core/res/res/drawable-hdpi/tab_arrow_left_holo_light.png deleted file mode 100644 index 036aa8c0b6ad2..0000000000000 Binary files a/core/res/res/drawable-hdpi/tab_arrow_left_holo_light.png and /dev/null differ diff --git a/core/res/res/drawable-hdpi/tab_arrow_right_holo_dark.png b/core/res/res/drawable-hdpi/tab_arrow_right_holo_dark.png deleted file mode 100644 index b226038795616..0000000000000 Binary files a/core/res/res/drawable-hdpi/tab_arrow_right_holo_dark.png and /dev/null differ diff --git a/core/res/res/drawable-hdpi/tab_arrow_right_holo_light.png b/core/res/res/drawable-hdpi/tab_arrow_right_holo_light.png deleted file mode 100644 index 0e5fbe671c01f..0000000000000 Binary files a/core/res/res/drawable-hdpi/tab_arrow_right_holo_light.png and /dev/null differ diff --git a/core/res/res/drawable-hdpi/tab_bottom_holo.9.png b/core/res/res/drawable-hdpi/tab_bottom_holo.9.png new file mode 100644 index 0000000000000..ec9fa8d8054e0 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_bottom_holo.9.png differ diff --git a/core/res/res/drawable-hdpi/tab_divider_holo_dark.png b/core/res/res/drawable-hdpi/tab_divider_holo_dark.png deleted file mode 100644 index 112cb04b829e9..0000000000000 Binary files a/core/res/res/drawable-hdpi/tab_divider_holo_dark.png and /dev/null differ diff --git a/core/res/res/drawable-hdpi/tab_divider_holo_light.png b/core/res/res/drawable-hdpi/tab_divider_holo_light.png deleted file mode 100644 index 1bf4d386881a5..0000000000000 Binary files a/core/res/res/drawable-hdpi/tab_divider_holo_light.png and /dev/null differ diff --git a/core/res/res/drawable-hdpi/tab_selected_focused_holo.9.png b/core/res/res/drawable-hdpi/tab_selected_focused_holo.9.png new file mode 100644 index 0000000000000..1ba35d5548112 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_selected_focused_holo.9.png differ diff --git a/core/res/res/drawable-hdpi/tab_selected_holo.9.png b/core/res/res/drawable-hdpi/tab_selected_holo.9.png new file mode 100644 index 0000000000000..ef913cc8e5934 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_selected_holo.9.png differ diff --git a/core/res/res/drawable-hdpi/tab_selected_pressed_focused_holo.9.png b/core/res/res/drawable-hdpi/tab_selected_pressed_focused_holo.9.png new file mode 100644 index 0000000000000..d7e968806aed3 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_selected_pressed_focused_holo.9.png differ diff --git a/core/res/res/drawable-hdpi/tab_selected_pressed_holo.9.png b/core/res/res/drawable-hdpi/tab_selected_pressed_holo.9.png new file mode 100644 index 0000000000000..b8b1fcfe26558 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_selected_pressed_holo.9.png differ diff --git a/core/res/res/drawable-hdpi/tab_selector_holo_dark.9.png b/core/res/res/drawable-hdpi/tab_selector_holo_dark.9.png deleted file mode 100644 index f01b9bc3f92e2..0000000000000 Binary files a/core/res/res/drawable-hdpi/tab_selector_holo_dark.9.png and /dev/null differ diff --git a/core/res/res/drawable-hdpi/tab_strip_holo.9.png b/core/res/res/drawable-hdpi/tab_strip_holo.9.png deleted file mode 100644 index d937f6b9e2a30..0000000000000 Binary files a/core/res/res/drawable-hdpi/tab_strip_holo.9.png and /dev/null differ diff --git a/core/res/res/drawable-hdpi/tab_unselected_focused_holo.9.png b/core/res/res/drawable-hdpi/tab_unselected_focused_holo.9.png new file mode 100644 index 0000000000000..256e8e7302e49 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_unselected_focused_holo.9.png differ diff --git a/core/res/res/drawable-hdpi/tab_unselected_holo.9.png b/core/res/res/drawable-hdpi/tab_unselected_holo.9.png new file mode 100644 index 0000000000000..eaa306aee14b3 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_unselected_holo.9.png differ diff --git a/core/res/res/drawable-hdpi/tab_unselected_pressed_focused_holo.9.png b/core/res/res/drawable-hdpi/tab_unselected_pressed_focused_holo.9.png new file mode 100644 index 0000000000000..d17b82026b645 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_unselected_pressed_focused_holo.9.png differ diff --git a/core/res/res/drawable-hdpi/tab_unselected_pressed_holo.9.png b/core/res/res/drawable-hdpi/tab_unselected_pressed_holo.9.png new file mode 100644 index 0000000000000..a344994fb5c90 Binary files /dev/null and b/core/res/res/drawable-hdpi/tab_unselected_pressed_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_arrow_left_holo_dark.png b/core/res/res/drawable-mdpi/tab_arrow_left_holo_dark.png deleted file mode 100644 index 4f8bafe08ce04..0000000000000 Binary files a/core/res/res/drawable-mdpi/tab_arrow_left_holo_dark.png and /dev/null differ diff --git a/core/res/res/drawable-mdpi/tab_arrow_left_holo_light.png b/core/res/res/drawable-mdpi/tab_arrow_left_holo_light.png deleted file mode 100644 index 8e225fce686ed..0000000000000 Binary files a/core/res/res/drawable-mdpi/tab_arrow_left_holo_light.png and /dev/null differ diff --git a/core/res/res/drawable-mdpi/tab_arrow_right_holo_dark.png b/core/res/res/drawable-mdpi/tab_arrow_right_holo_dark.png deleted file mode 100644 index 0a8006de9829c..0000000000000 Binary files a/core/res/res/drawable-mdpi/tab_arrow_right_holo_dark.png and /dev/null differ diff --git a/core/res/res/drawable-mdpi/tab_arrow_right_holo_light.png b/core/res/res/drawable-mdpi/tab_arrow_right_holo_light.png deleted file mode 100644 index 85aae47d55f2b..0000000000000 Binary files a/core/res/res/drawable-mdpi/tab_arrow_right_holo_light.png and /dev/null differ diff --git a/core/res/res/drawable-mdpi/tab_bottom_holo.9.png b/core/res/res/drawable-mdpi/tab_bottom_holo.9.png new file mode 100644 index 0000000000000..1e40b9c553ade Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_bottom_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_divider_holo_dark.png b/core/res/res/drawable-mdpi/tab_divider_holo_dark.png deleted file mode 100644 index 89d7b8bec2e35..0000000000000 Binary files a/core/res/res/drawable-mdpi/tab_divider_holo_dark.png and /dev/null differ diff --git a/core/res/res/drawable-mdpi/tab_divider_holo_light.png b/core/res/res/drawable-mdpi/tab_divider_holo_light.png deleted file mode 100644 index 878b2b42aa83b..0000000000000 Binary files a/core/res/res/drawable-mdpi/tab_divider_holo_light.png and /dev/null differ diff --git a/core/res/res/drawable-mdpi/tab_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_focused_holo.9.png new file mode 100644 index 0000000000000..187d8c56e11e2 Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_focused_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_pressed_holo.9.png b/core/res/res/drawable-mdpi/tab_pressed_holo.9.png new file mode 100644 index 0000000000000..a76fbae5be065 Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_pressed_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_selected_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_selected_focused_holo.9.png new file mode 100644 index 0000000000000..9a33cd2d92874 Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_selected_focused_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_selected_holo.9.png b/core/res/res/drawable-mdpi/tab_selected_holo.9.png new file mode 100644 index 0000000000000..e029e577a711e Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_selected_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_selected_pressed_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_selected_pressed_focused_holo.9.png new file mode 100644 index 0000000000000..285116e31e1c3 Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_selected_pressed_focused_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_selected_pressed_holo.9.png b/core/res/res/drawable-mdpi/tab_selected_pressed_holo.9.png new file mode 100644 index 0000000000000..dadefa758af52 Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_selected_pressed_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_selector_holo_dark.9.png b/core/res/res/drawable-mdpi/tab_selector_holo_dark.9.png deleted file mode 100644 index 30d30df42b1dd..0000000000000 Binary files a/core/res/res/drawable-mdpi/tab_selector_holo_dark.9.png and /dev/null differ diff --git a/core/res/res/drawable-mdpi/tab_unselected_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_unselected_focused_holo.9.png new file mode 100644 index 0000000000000..032a9921c54eb Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_unselected_focused_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_unselected_holo.9.png b/core/res/res/drawable-mdpi/tab_unselected_holo.9.png new file mode 100644 index 0000000000000..848f3f13363cb Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_unselected_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_unselected_pressed_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_unselected_pressed_focused_holo.9.png new file mode 100644 index 0000000000000..3845135847312 Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_unselected_pressed_focused_holo.9.png differ diff --git a/core/res/res/drawable-mdpi/tab_unselected_pressed_holo.9.png b/core/res/res/drawable-mdpi/tab_unselected_pressed_holo.9.png new file mode 100644 index 0000000000000..23fd8c9b351c7 Binary files /dev/null and b/core/res/res/drawable-mdpi/tab_unselected_pressed_holo.9.png differ diff --git a/core/res/res/drawable/tab_bottom_right.xml b/core/res/res/drawable/tab_bottom_right.xml index f7f5c2f5a07c0..450c461e983bf 100644 --- a/core/res/res/drawable/tab_bottom_right.xml +++ b/core/res/res/drawable/tab_bottom_right.xml @@ -16,6 +16,6 @@ - - + + diff --git a/core/res/res/drawable/tab_indicator_holo.xml b/core/res/res/drawable/tab_indicator_holo.xml new file mode 100644 index 0000000000000..0d46e0c471fd6 --- /dev/null +++ b/core/res/res/drawable/tab_indicator_holo.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/core/res/res/layout/tab_indicator.xml b/core/res/res/layout/tab_indicator.xml index 71e400180898e..bc657c399c265 100644 --- a/core/res/res/layout/tab_indicator.xml +++ b/core/res/res/layout/tab_indicator.xml @@ -20,7 +20,6 @@ android:layout_weight="1" android:layout_marginLeft="-3dip" android:layout_marginRight="-3dip" - android:orientation="vertical" android:background="@android:drawable/tab_indicator"> + + + + + + + + + + + diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index d5f1610a23ac9..dab627c8a39f1 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2137,6 +2137,8 @@ + + diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index c441f5a193afa..76a3c34abb221 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -560,6 +560,12 @@ @style/TextAppearance.Widget.TabWidget marquee true + @android:drawable/tab_bottom_left + @android:drawable/tab_bottom_right + true + @null + fill_horizontal|center_vertical + @android:layout/tab_indicator @@ -1421,6 +1427,13 @@ -